Update web-platform-tests and CSS tests.

- Update CSS tests to revision e05bfd5e30ed662c2f8a353577003f8eed230180.
- Update web-platform-tests to revision a052787dd5c069a340031011196b73affbd68cd9.
This commit is contained in:
Ms2ger 2017-02-06 11:06:12 +01:00
parent fb4f421c8b
commit 296fa2512b
21852 changed files with 2080936 additions and 892894 deletions

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Creating a PresentationRequest 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/#constructing-a-presentationrequest">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function createPresentation() {
var request = new PresentationRequest('http://example.org/presentation.html');
};
test(function () {
assert_throws('SecurityError', createPresentation);
});
</script>

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Creating a PresentationRequest 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/#constructing-a-presentationrequest">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function createPresentation() {
var request = new PresentationRequest([
'presentation.html',
'http://example.org/presentation.html'
]);
};
test(function () {
assert_throws('SecurityError', createPresentation);
});
</script>

View file

@ -25,6 +25,12 @@
var startPresentation = function () {
presentBtn.disabled = true;
promise_test(function (t) {
var connection;
t.add_cleanup(function() {
if(connection)
connection.terminate();
});
// Note: During starting a presentation, the connectionavailable event is fired (step 20)
// after the promise P is resolved (step 19).
return new Promise(function(resolve, reject) {
@ -34,20 +40,15 @@
};
// This test fails if request.onconnectionavailable is not invoked although the presentation is started successfully
// or the presentation fails to be started
request.start().then(function() {
request.start().then(function(c) {
connection = c;
t.step_timeout(function() { assert_unreached('The connectionavailable event was not fired.'); }, 5000);
}, reject);
}).then(function(connection) {
// Check the initial state of a presentation connection
}).then(function(c) {
connection = c;
assert_equals(connection.state, 'connecting', 'The initial state of the presentation connection is "connecting".');
// Check, if the connection ID is set
assert_true(!!connection.id, 'The connection ID is set.');
// Check the type of the connection.id
assert_true(typeof connection.id === 'string', 'The connection ID is a string.');
// Check the instance of the connection
assert_true(connection instanceof PresentationConnection, 'The connection is an instance of PresentationConnection.');
});
}, 'The connectionavailable event was fired successfully.');

View file

@ -1,24 +1,24 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Sandboxing: Reconnecting a presentation from a nested context fails when allow-presentation is not set</title>
<title>Sandboxing: Creating a PresentationRequest 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">
<link rel="help" href="http://w3c.github.io/presentation-api/#constructing-a-presentationrequest">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function (t) {
function startWhenReady(ev) {
var startWhenReady = t.step_func(function (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', checkFinalMessage);
childFrame.contentWindow.postMessage('create', '*');
}
}
});
var checkFinalMessage = t.step_func_done(function (ev) {
assert_equals(ev.data, 'SecurityError', 'Presentation sandboxing did not work as expected.');
});
window.addEventListener('message', startWhenReady);
});

View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Sandboxing: Creating a PresentationRequest 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/#constructing-a-presentationrequest">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function (t) {
var startWhenReady = t.step_func(function (ev) {
var childFrame = document.getElementById('childFrame');
if (ev.data === 'ready') {
window.removeEventListener('message', startWhenReady);
window.addEventListener('message', checkFinalMessage);
childFrame.contentWindow.postMessage('create', '*');
}
});
var checkFinalMessage = t.step_func_done(function (ev) {
assert_equals(ev.data, 'success', 'Presentation sandboxing did not work as expected.');
});
window.addEventListener('message', startWhenReady);
});
</script>
<iframe id="childFrame" sandbox="allow-scripts allow-presentation" style="display:none" src="support/iframe.html"></iframe>

View file

@ -33,9 +33,12 @@
// 'default request' Test - BEGIN
// ------------------------------
async_test(function(t) {
// clean up the instruction notice when the test ends
// clean up the presentation and the instruction notice when the test ends
var connection;
t.add_cleanup(function() {
notice.parentNode.removeChild(notice);
if(connection)
connection.terminate();
});
// set an event handler to make the test fail when the button is clicked
button.onclick = t.step_func_done(function() {
@ -45,7 +48,7 @@
var request = new PresentationRequest(presentationUrls);
navigator.presentation.defaultRequest = request;
request.onconnectionavailable = t.step_func_done(function (evt) {
var connection = evt.connection;
connection = evt.connection;
// check the presentation connection and its attributes
assert_equals(connection.state, 'connecting', 'The initial state of the presentation connection is "connecting".');
assert_true(!!connection.id, 'The connection ID is set.');

View file

@ -1,69 +1,48 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Presentation API - monitor screen availability tests for Controlling User Agent</title>
<title>Getting the presentation displays availability information.</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">
<link rel="author" title="Tomoyuki Shimizu" href="https://github.com/tomoyukilabs">
<link rel="help" href="http://w3c.github.io/presentation-api/#dfn-presentation-display-availability">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="common.js"></script>
<p>The test passes if a "PASS" result appears.</p>
<script>
// ---------------------------------
// Helper Function
// ---------------------------------
var createRequestObject = function () {
// ---------------------------------------
// Presentation Availability Tests - begin
// ---------------------------------------
promise_test(function(t) {
var availability;
var request = new PresentationRequest(presentationUrls);
return request;
}
assert_true(request instanceof PresentationRequest, 'The request is an instance of PresentationRequest.');
// ---------------------------------
// Screen Availability Tests - begin
// ---------------------------------
var promise = request.getAvailability();
assert_equals(promise, request.getAvailability(), 'If the PresentationRequest object has an unsettled Promise, getAvailability returns that Promise.');
// Instance of Promise Test
test(function () {
var request = createRequestObject();
assert_true(request.getAvailability() instanceof Promise);
}, 'The request is an Promise.')
function catchNotSupported(err) {
assert_equals(err.name, 'NotSupportedError', 'getAvailability() rejects a Promise with a NotSupportedError exception, if the browser can find presentation displays only when starting a connection.')
}
// Instance of PresentationRequest Test
test(function () {
var request = createRequestObject();
assert_true(request instanceof PresentationRequest);
}, 'The request is an instance of PresentationRequest.')
return promise.then(function (a) {
availability = a;
// Instance of PresentationAvailability Test
promise_test(function () {
var request = createRequestObject();
assert_true(availability instanceof PresentationAvailability, 'The promise is resolved with an instance of PresentationAvailability.');
assert_equals(typeof availability.value, 'boolean', 'The availability has an boolean value.');
assert_true(availability.value, 'The availability value is true when any presentation display is available.');
return request.getAvailability()
.then(function (availability) {
assert_true(availability instanceof PresentationAvailability);
});
}, "The promise is an instance of PresentationAvailability");
var newPromise = request.getAvailability();
assert_not_equals(promise, newPromise, 'If the Promise from a previous call to getAvailability has already been settled, getAvailability returns a new Promise.');
// Availability.value is set Test
promise_test(function () {
var request = createRequestObject();
return newPromise.then(function (newAvailability) {
assert_equals(availability, newAvailability, 'Promises from a PresentationRequest\'s getAvailability are resolved with the same PresentationAvailability object.');
}, catchNotSupported);
}, catchNotSupported);
});
return request.getAvailability()
.then(function (availability) {
assert_true(typeof availability.value == 'boolean');
});
}, "The availability has an boolean value.");
// Best Case Scenario Test
// -----------------------
promise_test(function () {
var request = createRequestObject();
return request.getAvailability()
.then(function (availability) {
assert_true(availability.value);
});
}, "There is an availability.");
// -------------------------------
// Screen Availability Tests - end
// -------------------------------
</script>

View file

@ -1,18 +0,0 @@
<!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

@ -1,26 +0,0 @@
<!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

@ -1,18 +0,0 @@
<!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

@ -21,7 +21,15 @@
promise_test(function (t) {
var request = new PresentationRequest(presentationUrls);
var presentationId = null;
return request.start().then(function (connection) {
var connection;
t.add_cleanup(function() {
if(connection)
connection.terminate();
});
return request.start().then(function (c) {
connection = c;
presentationId = connection.id;
// No more user input needed, re-enable test timeout
@ -36,7 +44,8 @@
}).then(function () {
// Connection now closed, let's reconnect to it
return request.reconnect(presentationId);
}).then(function (connection) {
}).then(function (c) {
connection = c;
assert_equals(connection.state, "connecting", "connection should be in 'connecting' state");
assert_equals(connection.id, presentationId, "Ids of old and new connections must be equal");
});

View file

@ -13,6 +13,9 @@
<button id="presentBtn" onclick="startPresentation()">Start Presentation Test</button>
<script>
// disable the timeout function for the tests
setup({explicit_timeout: true});
// ----------
// DOM Object
// ----------
@ -21,11 +24,19 @@
// -------------------------------------------
// Start New Presentation Test (error) - begin
// -------------------------------------------
var startPresentation = function () {
presentBtn.onclick = function () {
presentBtn.disabled = true;
promise_test(function (t) {
var request = new PresentationRequest(presentationUrls);
return promise_rejects(t, 'NotAllowedError', request.start());
// terminate the presentation connection when the presentation is started by accident
var connection;
t.add_cleanup(function() {
if(connection)
connection.terminate();
});
return promise_rejects(t, 'NotAllowedError', request.start().then(function(c) { connection = c; }));
});
};
// -----------------------------------------

View file

@ -10,9 +10,12 @@
<p>Before starting this test, confirm that there is no available presentation display on your local network.</p>
<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="startPresentation()">Start Presentation Test</button>
<button id="presentBtn">Start Presentation Test</button>
<script>
// disable the timeout function for the tests
setup({explicit_timeout: true});
// ----------
// DOM Object
// ----------
@ -21,11 +24,19 @@
// -------------------------------------------
// Start New Presentation Test (error) - begin
// -------------------------------------------
var startPresentation = function () {
presentBtn.onclick = function () {
presentBtn.disabled = true;
promise_test(function (t) {
var request = new PresentationRequest(presentationUrls);
return promise_rejects(t, 'NotFoundError', request.start());
// terminate the presentation connection when the presentation is started by accident
var connection;
t.add_cleanup(function() {
if(connection)
connection.terminate();
});
return promise_rejects(t, 'NotFoundError', request.start().then(function(c) { connection = c; }));
});
};
// -----------------------------------------

View file

@ -1,29 +0,0 @@
<!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

@ -1,32 +0,0 @@
<!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

@ -1,31 +0,0 @@
<!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

@ -47,9 +47,14 @@
var request = new PresentationRequest(presentationUrls);
var eventWatcher = new EventWatcher(t, request, 'connectionavailable');
var waitConnectionavailable = eventWatcher.wait_for('connectionavailable').then(count);
var waitConnectionavailable = eventWatcher.wait_for('connectionavailable').then(count).then(function(evt) { connection = connection || evt.connection; });
var waitConnect;
t.add_cleanup(function() {
if(connection)
connection.terminate();
});
return request.start().then(count)
.then(checkPhase).then(function (c) {
// Phase #1: Promise is resolved

View file

@ -8,24 +8,34 @@
<script src="common.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="startPresentation()">Start Presentation Test</button>
<button id="presentBtn">Start Presentation Test</button>
<script>
// disable the timeout function for the tests
setup({explicit_timeout: true});
// ----------
// DOM Object
// ----------
var presentBtn = document.getElementById("presentBtn");
// -----------------------------------------------
// Terminate a presentation if started by accident
// -----------------------------------------------
function terminate(connection) {
connection.terminate();
}
// -------------------------------------------
// Start New Presentation Test (error) - begin
// -------------------------------------------
var startPresentation = function () {
presentBtn.onclick = function () {
presentBtn.disabled = true;
promise_test(function (t) {
var request1 = new PresentationRequest(presentationUrls),
request2 = new PresentationRequest(presentationUrls);
request1.start().catch(function(){});
return promise_rejects(t, 'OperationError', request2.start());
request1.start().then(terminate, function(){});
return promise_rejects(t, 'OperationError', request2.start().then(terminate));
});
};
// -----------------------------------------

View file

@ -17,8 +17,18 @@
return '../' + url;
}
});
var request = new PresentationRequest(urls);
if (ev.data === 'start') {
var request = null;
if (ev.data === 'create') {
try {
request = new PresentationRequest(urls);
parent.window.postMessage('success', '*');
}
catch (err) {
parent.window.postMessage(err.name, '*');
}
}
else if (ev.data === 'start') {
request = new PresentationRequest(urls);
request.start()
.then(function () {
parent.window.postMessage('success', '*');
@ -38,6 +48,7 @@
});
}
else if (ev.data === 'reconnect') {
request = new PresentationRequest(urls);
request.reconnect('someid')
.then(function () {
parent.window.postMessage('success', '*');
@ -47,6 +58,7 @@
});
}
else if (ev.data === 'getAvailability') {
request = new PresentationRequest(urls);
request.getAvailability()
.then(function () {
parent.window.postMessage('success', '*');