Update web-platform-tests to revision dc5cbf088edcdb266541d4e5a76149a2c6e716a0

This commit is contained in:
Ms2ger 2016-09-09 09:40:35 +02:00
parent 1d40075f03
commit 079092dfea
2381 changed files with 90360 additions and 17722 deletions

View file

@ -0,0 +1,3 @@
@louaybassbouss
@tidoust
@zqzhang

View file

@ -7,26 +7,33 @@
<script src="/resources/testharnessreport.js"></script>
<script>
var wrong_presentation_url = null;
/**
* Test if PresentationRequest constructor returns a TypeError() by missing presentation URL
*/
test(function() {
assert_throws(new TypeError(), function() {
new PresentationRequest();
});
}, 'Call PresentationRequest() constructor without presentation URL. TypeError Exception expected.');
/**
* Test if PresentationRequest constructor returns a TypeError() by wrong presentation URL
*/
test(function() {
assert_throws(new TypeError(), function() {
new PresentationRequest(wrong_presentation_url);
new PresentationRequest(null);
});
}, 'Call PresentationRequest() constructor with null presentation URL. TypeError Exception expected.');
}, 'Call PresentationRequest constructor with null presentation URL. TypeError Exception expected.');
test(function() {
assert_throws('NotSupportedError', function() {
new PresentationRequest([]);
});
}, 'Call PresentationRequest constructor with an empty sequence. NotSupportedError Exception expected.');
test(function() {
assert_throws('SyntaxError', function() {
new PresentationRequest(':invalid');
});
}, 'Call PresentationRequest constructor with an invalid URL. SyntaxError Exception expected.');
test(function() {
assert_throws('SyntaxError', function() {
new PresentationRequest(['presentation.html', ':invalid']);
});
}, 'Call PresentationRequest constructor with a sequence of URLs, one of them invalid. SyntaxError Exception expected.');
</script>

View file

@ -7,23 +7,37 @@
<script src="/resources/testharnessreport.js"></script>
<script>
var client_id = String(new Date().getTime()) + String(Math.floor(Math.random() * 1e5));
//relative presentation URL
var presentation_url = "../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__="+ client_id;
/**
* Test if PresentationRequest constructor returns a SyntaxError() by missing presentation URL
*/
test(function() {
try{
var request = new PresentationRequest(presentation_url);
try {
var request = new PresentationRequest('presentation.html');
assert_true(request instanceof PresentationRequest);
}
catch (ex){
assert_unreached("Call PresentationRequest() constructor with valid presentation URL....????");
catch (ex) {
assert_unreached('PresentationRequest constructor threw an unexpected exception "' + ex.name + '"');
}
}, 'Call PresentationRequest() constructor with valid presentation URL. No Exception expected.');
}, 'Call PresentationRequest constructor with a valid relative presentation URL. No Exception expected.');
test(function() {
try {
var request = new PresentationRequest('http://example.org/');
assert_true(request instanceof PresentationRequest);
}
catch (ex) {
assert_unreached('PresentationRequest constructor threw an unexpected exception "' + ex.name + '"');
}
}, 'Call PresentationRequest constructor with a valid absolute presentation URL. No Exception expected.');
test(function() {
try {
var request = new PresentationRequest([
'presentation.html',
'http://example.org/presentation/'
]);
assert_true(request instanceof PresentationRequest);
}
catch (ex) {
assert_unreached('PresentationRequest constructor threw an unexpected exception "' + ex.name + '"');
}
}, 'Call PresentationRequest constructor with a set of valid presentation URLs. No Exception expected.');
</script>

View file

@ -0,0 +1,52 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Presentation API, testing to start a new presentation with an default request setup. (success - manual)</title>
<link rel="author" title="Marius Wessel" href="http://www.fokus.fraunhofer.de">
<link rel="help" href="http://w3c.github.io/presentation-api/#dfn-controlling-user-agent">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<p>Click the button below and select the available casting device, to start the manual test.</p>
<button onclick="startPresentation()">Start Presentation Test</button>
<script>
// disable the timeout function for the tests
// and call 'done()' when the tests cases are finished.
setup({explicit_timeout: true});
// -------------------
// defaultRequest init
// -------------------
var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)),
validPresURL = '../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__=' + validUnixDate;
navigator.presentation.defaultRequest = new PresentationRequest(validPresURL);
var startPresentation = function () {
promise_test(function () {
return navigator.presentation.defaultRequest.start();
}, "The presentation was started successfully.");
}
// ------------------------------
// Start New Presentation with
// 'default request' Test - BEGIN
// ------------------------------
navigator.presentation.defaultRequest.onconnectionavailable = function (evt) {
var connection = evt.connection;
test(function () {
assert_equals(connection.state, "connected", "The presentation has an connected state.");
assert_true(!!connection.id, "The connection ID is set.");
assert_true(typeof connection.id === 'string', "The connection ID is a string.");
assert_true(connection instanceof PresentationConnection, "The connection is an instance of PresentationConnection.");
}, "The presentation was started successfully.");
done();
};
// ----------------------------
// Start New Presentation with
// 'default request' Test - END
// ----------------------------
</script>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Calling "getAvailability" with an a priori unauthenticated URL in an HTTPS context throws a SecurityError exception.</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-getavailability">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function getAvailability() {
var request = new PresentationRequest('http://example.org/presentation.html');
return request.getAvailability();
}
promise_test(function (t) {
return promise_rejects(t, 'SecurityError', getAvailability());
});
</script>

View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Sandboxing: Retrieving display availability from a nested context fails when allow-presentation is not set</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-getavailability">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function (t) {
function startWhenReady(ev) {
var childFrame = document.getElementById('childFrame');
if (ev.data === 'ready') {
window.removeEventListener('message', startWhenReady);
childFrame.contentWindow.postMessage('getAvailability', '*');
window.addEventListener('message', t.step_func(function (ev) {
assert_equals(ev.data, 'SecurityError',
'Presentation sandboxing did not work as expected.');
t.done();
}));
}
}
window.addEventListener('message', startWhenReady);
});
</script>
<iframe id="childFrame" sandbox="allow-scripts" style="display:none" src="support/iframe.html"></iframe>

View file

@ -0,0 +1,25 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Sandboxing: Retrieving display availability from a nested context succeeds when allow-presentation is set</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-getavailability">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function (t) {
function startWhenReady(ev) {
var childFrame = document.getElementById('childFrame');
if (ev.data === 'ready') {
window.removeEventListener('message', startWhenReady);
childFrame.contentWindow.postMessage('getAvailability', '*');
window.addEventListener('message', t.step_func(function (ev) {
assert_equals(ev.data, 'success',
'Presentation sandboxing did not work as expected.');
t.done();
}));
}
}
window.addEventListener('message', startWhenReady);
});
</script>
<iframe id="childFrame" sandbox="allow-scripts allow-presentation" style="display:none" src="support/iframe.html"></iframe>

View file

@ -35,7 +35,7 @@ partial interface Presentation {
};
[Constructor(DOMString url),
Constructor(DOMString[] urls)]
Constructor(sequence<DOMString> urls)]
interface PresentationRequest : EventTarget {
Promise<PresentationConnection> start();
Promise<PresentationConnection> reconnect(DOMString presentationId);
@ -72,7 +72,8 @@ enum BinaryType {
};
interface PresentationConnection : EventTarget {
readonly attribute DOMString? id;
readonly attribute DOMString id;
readonly attribute DOMString url;
readonly attribute PresentationConnectionState state;
void close();
void terminate();
@ -96,12 +97,12 @@ enum PresentationConnectionClosedReason {
};
[Constructor(DOMString type, PresentationConnectionClosedEventInit eventInitDict)]
interface PresentationConnectionClosedEvent : Event {
interface PresentationConnectionCloseEvent : Event {
readonly attribute PresentationConnectionClosedReason reason;
readonly attribute DOMString message;
};
dictionary PresentationConnectionClosedEventInit : EventInit {
dictionary PresentationConnectionCloseEventInit : EventInit {
required PresentationConnectionClosedReason reason;
DOMString message = "";
};
@ -114,9 +115,13 @@ dictionary PresentationConnectionClosedEventInit : EventInit {
var idls = document.getElementById('idl').textContent;
idl_array.add_untested_idls(document.getElementById('untested_idl').textContent);
idl_array.add_idls(idls);
window.presentation_request = new PresentationRequest("/presentation-api/receiving-ua/idlharness.html");
window.presentation_request_urls = new PresentationRequest(["/presentation-api/receiving-ua/idlharness.html",
"http://www.example.com/presentation.html"]);
navigator.presentation.defaultRequest = presentation_request;
idl_array.add_objects({
Presentation: ['navigator.presentation'],
PresentationRequest: ['navigator.presentation.defaultRequest', 'new PresentationRequest("/presentation-api/receiving-ua/idlharness.html")']
PresentationRequest: ['navigator.presentation.defaultRequest', 'presentation_request', 'presentation_request_urls']
});
idl_array.test();
})();

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Calling "reconnect" with an a priori unauthenticated URL in an HTTPS context throws a SecurityError exception.</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-reconnect">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function reconnectToPresentation() {
var request = new PresentationRequest('http://example.org/presentation.html');
return request.reconnect('someid');
}
promise_test(function (t) {
return promise_rejects(t, 'SecurityError', reconnectToPresentation());
});
</script>

View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Sandboxing: Reconnecting a presentation from a nested context fails when allow-presentation is not set</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-reconnect">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function (t) {
function startWhenReady(ev) {
var childFrame = document.getElementById('childFrame');
if (ev.data === 'ready') {
window.removeEventListener('message', startWhenReady);
childFrame.contentWindow.postMessage('reconnect', '*');
window.addEventListener('message', t.step_func(function (ev) {
assert_equals(ev.data, 'SecurityError',
'Presentation sandboxing did not work as expected.');
t.done();
}));
}
}
window.addEventListener('message', startWhenReady);
});
</script>
<iframe id="childFrame" sandbox="allow-scripts" style="display:none" src="support/iframe.html"></iframe>

View file

@ -0,0 +1,25 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Sandboxing: Reconnecting a presentation from a nested context succeeds when allow-presentation is set</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-reconnect">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function (t) {
function startWhenReady(ev) {
var childFrame = document.getElementById('childFrame');
if (ev.data === 'ready') {
window.removeEventListener('message', startWhenReady);
childFrame.contentWindow.postMessage('reconnect', '*');
window.addEventListener('message', t.step_func(function (ev) {
assert_equals(ev.data, 'NotFoundError',
'Presentation sandboxing did not work as expected.');
t.done();
}));
}
}
window.addEventListener('message', startWhenReady);
});
</script>
<iframe id="childFrame" sandbox="allow-scripts allow-presentation" style="display:none" src="support/iframe.html"></iframe>

View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Calling "start" with an a priori unauthenticated URL in an HTTPS context throws a SecurityError exception.</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-start">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<p>Click the button below to start the manual test. If prompted to select a device, please dismiss the dialog box. The test passes if a "PASS" result appears.</p>
<button id="presentBtn" onclick="startPresentationTest()">Start Presentation Test</button>
<script>
setup({explicit_timeout: true});
var presentBtn = document.getElementById("presentBtn");
function startPresentation() {
var request = new PresentationRequest('http://example.org/presentation.html');
return request.start();
};
function startPresentationTest() {
presentBtn.disabled = true;
promise_test(function (t) {
return promise_rejects(t, 'SecurityError', startPresentation());
});
}
</script>

View file

@ -0,0 +1,32 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Calling "start" with a set of URLs containing an a priori unauthenticated URL in an HTTPS context throws a SecurityError exception.</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-start">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<p>Click the button below to start the manual test. If prompted to select a device, please dismiss the dialog box. The test passes if a "PASS" result appears.</p>
<button id="presentBtn" onclick="startPresentationTest()">Start Presentation Test</button>
<script>
setup({explicit_timeout: true});
var presentBtn = document.getElementById("presentBtn");
function startPresentation() {
var request = new PresentationRequest([
'presentation.html',
'http://example.org/presentation.html'
]);
return request.start();
};
function startPresentationTest() {
presentBtn.disabled = true;
promise_test(function (t) {
return promise_rejects(t, 'SecurityError', startPresentation());
});
}
</script>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Sandboxing: starting a presentation from a nested context fails when allow-presentation is not set</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-start">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe id="childFrame" sandbox="allow-scripts" style="display:none" src="support/iframe.html"></iframe>
<p>Click the button below to start the manual test. If prompted to select a device, please dismiss the dialog box. The test passes if a "PASS" result appears.</p>
<button id="presentBtn" onclick="startPresentationTest()">Start Presentation Test</button>
<script>
setup({explicit_timeout: true});
var presentBtn = document.getElementById('presentBtn');
var childFrame = document.getElementById('childFrame');
function startPresentationTest() {
presentBtn.disabled = true;
async_test(function (t) {
childFrame.contentWindow.postMessage('start', '*');
window.addEventListener('message', t.step_func(function (ev) {
assert_equals(ev.data, 'SecurityError',
'Presentation sandboxing did not work as expected.');
t.done();
}));
});
}
</script>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Sandboxing: starting a presentation from a nested context succeeds when allow-presentation is set</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-start">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe id="childFrame" sandbox="allow-scripts allow-presentation" style="display:none" src="support/iframe.html"></iframe>
<p>Click the button below to start the manual test. If prompted to select a device, please dismiss the dialog box. The test passes if a "PASS" result appears.</p>
<button id="presentBtn" onclick="startPresentationTest()">Start Presentation Test</button>
<script>
setup({explicit_timeout: true});
var presentBtn = document.getElementById('presentBtn');
var childFrame = document.getElementById('childFrame');
function startPresentationTest() {
presentBtn.disabled = true;
async_test(function (t) {
childFrame.contentWindow.postMessage('start', '*');
window.addEventListener('message', t.step_func(function (ev) {
assert_equals(ev.data, 'success',
'Presentation could not be started from nested frame.');
t.done();
}));
});
}
</script>

View file

@ -0,0 +1,59 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Presentation API - controlling ua - sandboxing</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-start">
<script>
window.onmessage = function (ev) {
try {
var request = new PresentationRequest('presentation.html');;
if (ev.data === 'start') {
request.start()
.then(function () {
parent.window.postMessage('success', '*');
})
.catch(function (err) {
if ((err.name === 'NotFoundError') ||
(err.name === 'NotAllowedError')) {
// These errors either mean that the user dismissed the dialog
// box or that the UA could not find any available or suitable
// screen. This is equivalent of succeeding for the purpose of
// iframe tests.
parent.window.postMessage('success', '*');
}
else {
parent.window.postMessage(err.name, '*');
}
});
}
else if (ev.data === 'reconnect') {
request.reconnect('someid')
.then(function () {
parent.window.postMessage('success', '*');
})
.catch(function (err) {
parent.window.postMessage(err.name, '*');
});
}
else if (ev.data === 'getAvailability') {
request.getAvailability()
.then(function () {
parent.window.postMessage('success', '*');
})
.catch(function (err) {
if (err.name === 'NotSupportedError') {
parent.window.postMessage('success', '*');
}
else {
parent.window.postMessage(err.name, '*');
}
});
}
}
catch (err) {
parent.window.postMessage('Could not create PresentationRequest', '*');
}
}
parent.window.postMessage('ready', '*');
</script>