mirror of
https://github.com/servo/servo.git
synced 2025-08-18 11:55:39 +01:00
Update web-platform-tests to revision e8bfc205e36ad699601212cd50083870bad9a75d
This commit is contained in:
parent
65dd6d4340
commit
ccdb0a3458
1428 changed files with 118036 additions and 9786 deletions
|
@ -7,6 +7,7 @@
|
|||
<link rel="help" href="http://w3c.github.io/presentation-api/#interface-presentationconnection">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="common.js"></script>
|
||||
<h2>Description</h2>
|
||||
<p>
|
||||
This test validates that after connection close,<br/>
|
||||
|
@ -15,15 +16,14 @@
|
|||
</p>
|
||||
<br/>
|
||||
<p>Click the button below to start the test.</p>
|
||||
<button id="presentStartBtn" onclick="startPresentation()">Start Presentation Test</button>
|
||||
<button id="presentBtn" onclick="startPresentation()">Start Presentation Test</button>
|
||||
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
var startPresentation = function () {
|
||||
document.getElementById('presentBtn').disabled = true;
|
||||
async_test(function(t) {
|
||||
var client_id = String(new Date().getTime()) + String(Math.floor(Math.random() * 1e5));
|
||||
var url = "support/presentation.html#__castAppId__=C2335F62/__castClientId__="+ client_id;
|
||||
var request = new PresentationRequest(url);
|
||||
var request = new PresentationRequest(presentationUrls);
|
||||
request.start()
|
||||
.then(function(connection) {
|
||||
assert_true(connection instanceof PresentationConnection, 'the connection is setup');
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<link rel="help" href="http://w3c.github.io/presentation-api/#interface-presentationconnection">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="common.js"></script>
|
||||
<h2>Description</h2>
|
||||
<p>
|
||||
This test validates that after connection starts,<br/>
|
||||
|
@ -14,15 +15,14 @@
|
|||
</p>
|
||||
<br/>
|
||||
<p>Click the button below to start the test.</p>
|
||||
<button id="presentStartBtn" onclick="startPresentation()">Start Presentation Test</button>
|
||||
<button id="presentBtn" onclick="startPresentation()">Start Presentation Test</button>
|
||||
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
var startPresentation = function () {
|
||||
document.getElementById('presentBtn').disabled = true;
|
||||
async_test(function(t) {
|
||||
var client_id = String(new Date().getTime()) + String(Math.floor(Math.random() * 1e5));
|
||||
var url = "support/presentation.html#__castAppId__=C2335F62/__castClientId__="+ client_id;
|
||||
var request = new PresentationRequest(url);
|
||||
var request = new PresentationRequest(presentationUrls);
|
||||
request.start()
|
||||
.then(function(connection) {
|
||||
assert_true(connection instanceof PresentationConnection);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<link rel="help" href="http://w3c.github.io/presentation-api/#starting-a-presentation">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="common.js"></script>
|
||||
<h2>Description</h2>
|
||||
<p>
|
||||
This test validates that after connection terminate,<br/>
|
||||
|
@ -15,18 +16,21 @@
|
|||
</p>
|
||||
<br/>
|
||||
<p>Click the button below to start the test.</p>
|
||||
<button id="presentStartBtn" onclick="startPresentation()">Start Presentation Test</button>
|
||||
<button id="presentBtn" onclick="startPresentation()">Start Presentation Test</button>
|
||||
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
var startPresentation = function () {
|
||||
document.getElementById('presentBtn').disabled = true;
|
||||
async_test(function(t) {
|
||||
var client_id = String(new Date().getTime()) + String(Math.floor(Math.random() * 1e5));
|
||||
var url = "support/presentation.html#__castAppId__=C2335F62/__castClientId__="+ client_id;
|
||||
var request = new PresentationRequest(url);
|
||||
var request = new PresentationRequest(presentationUrls);
|
||||
request.start()
|
||||
.then(function(connection) {
|
||||
assert_true(connection instanceof PresentationConnection);
|
||||
connection.onconnected = t.step_func(function(evt) {
|
||||
assert_equals(evt.state, "connected");
|
||||
connection.terminate();
|
||||
});
|
||||
connection.onterminate = t.step_func_done(function(evt) {
|
||||
assert_equals(evt.type, "terminate");
|
||||
assert_equals(connection.state, "terminated");
|
||||
|
@ -34,7 +38,6 @@
|
|||
connection.onclose = t.step_func_done(function(evt) {
|
||||
assert_unreached("Wrong, the onclose shouldn't be triggered!");
|
||||
});
|
||||
connection.terminate();
|
||||
})
|
||||
.catch(function(ex) {
|
||||
assert_unreached(ex.name + ":" + ex.message);
|
||||
|
|
|
@ -13,12 +13,6 @@
|
|||
});
|
||||
}, 'Call PresentationRequest() constructor without presentation URL. TypeError Exception expected.');
|
||||
|
||||
test(function() {
|
||||
assert_throws(new TypeError(), function() {
|
||||
new PresentationRequest(null);
|
||||
});
|
||||
}, 'Call PresentationRequest constructor with null presentation URL. TypeError Exception expected.');
|
||||
|
||||
test(function() {
|
||||
assert_throws('NotSupportedError', function() {
|
||||
new PresentationRequest([]);
|
||||
|
@ -27,13 +21,13 @@
|
|||
|
||||
test(function() {
|
||||
assert_throws('SyntaxError', function() {
|
||||
new PresentationRequest(':invalid');
|
||||
new PresentationRequest('http://@');
|
||||
});
|
||||
}, 'Call PresentationRequest constructor with an invalid URL. SyntaxError Exception expected.');
|
||||
|
||||
test(function() {
|
||||
assert_throws('SyntaxError', function() {
|
||||
new PresentationRequest(['presentation.html', ':invalid']);
|
||||
new PresentationRequest(['presentation.html', 'http://@']);
|
||||
});
|
||||
}, 'Call PresentationRequest constructor with a sequence of URLs, one of them invalid. SyntaxError Exception expected.');
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>PresentationRequest.onconnectionavailable (manual test)</title>
|
||||
<link rel="author" title="Tomoyuki Shimizu" href="https://github.com/tomoyukilabs">
|
||||
<link rel="help" href="https://w3c.github.io/presentation-api/#starting-a-presentation">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="common.js"></script>
|
||||
<p>Click the button below and select the available presentation display, to start the manual test.</p>
|
||||
<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");
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Start New PresentationRequest.onconnectionavailable Test (success) - begin
|
||||
// --------------------------------------------------------------------------
|
||||
var startPresentation = function () {
|
||||
presentBtn.disabled = true;
|
||||
promise_test(function (t) {
|
||||
// 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) {
|
||||
var request = new PresentationRequest(presentationUrls);
|
||||
request.onconnectionavailable = function (evt) {
|
||||
resolve(evt.connection);
|
||||
};
|
||||
// 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() {
|
||||
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
|
||||
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.');
|
||||
}
|
||||
presentBtn.onclick = startPresentation;
|
||||
// ------------------------------------------------------------------------
|
||||
// Start New PresentationRequest.onconnectionavailable Test (success) - end
|
||||
// ------------------------------------------------------------------------
|
||||
</script>
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
(function (window) {
|
||||
// Cast ID of the main custom receiver application linked with the test suite
|
||||
// That application ID, maintained by W3C team, points at:
|
||||
// https://[W3C test server]/presentation-api/controlling-ua/support/presentation.html
|
||||
//
|
||||
// NB: this mechanism should be improved later on as tests should not depend
|
||||
// on something that directly or indirectly maps to a resource on the W3C test
|
||||
// server.
|
||||
var castAppId = '915D2A2C';
|
||||
var castUrl = 'https://google.com/cast#__castAppId__=' + castAppId;
|
||||
|
||||
window.presentationUrls = [
|
||||
'support/presentation.html',
|
||||
castUrl
|
||||
];
|
||||
})(window);
|
|
@ -1,50 +1,58 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Presentation API, testing to start a new presentation with an default request setup. (success - manual)</title>
|
||||
<title>[Optional] Starting a presentation from the browser using a default presentation request.</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/#dom-presentation-defaultrequest">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="common.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>
|
||||
<p>
|
||||
Click the button or the menu item for presentation on your browser (for example, "Cast"), <br>
|
||||
to start the manual test, and select a presentation display when prompted to do so.<br>
|
||||
The test passes if a "PASS" result appears.
|
||||
</p>
|
||||
<p id="notice">
|
||||
If your browser does not support <code>defaultRequest</code>, please click this button: <button id="notsupported">Not Supported</button>
|
||||
</p>
|
||||
|
||||
<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;
|
||||
// -----------
|
||||
// DOM Element
|
||||
// -----------
|
||||
var button = document.getElementById('notsupported'),
|
||||
notice = document.getElementById('notice');
|
||||
|
||||
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();
|
||||
};
|
||||
async_test(function(t) {
|
||||
// clean up the instruction notice when the test ends
|
||||
t.add_cleanup(function() {
|
||||
notice.parentNode.removeChild(notice);
|
||||
});
|
||||
// set an event handler to make the test fail when the button is clicked
|
||||
button.onclick = t.step_func_done(function() {
|
||||
assert_unreached('This browser does not support defaultRequest.');
|
||||
});
|
||||
// set up a default presentation request
|
||||
var request = new PresentationRequest(presentationUrls);
|
||||
navigator.presentation.defaultRequest = request;
|
||||
request.onconnectionavailable = t.step_func_done(function (evt) {
|
||||
var 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.');
|
||||
assert_true(typeof connection.id === 'string', 'The connection ID is a string.');
|
||||
assert_true(connection instanceof PresentationConnection, 'The connection is an instance of PresentationConnection.');
|
||||
});
|
||||
});
|
||||
// ----------------------------
|
||||
// Start New Presentation with
|
||||
// 'default request' Test - END
|
||||
|
|
|
@ -5,15 +5,14 @@
|
|||
<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>
|
||||
<script src="common.js"></script>
|
||||
|
||||
<script>
|
||||
// ---------------------------------
|
||||
// Helper Function
|
||||
// ---------------------------------
|
||||
var createRequestObject = function () {
|
||||
var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)),
|
||||
presUrl = "../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__=" + validUnixDate,
|
||||
request = new PresentationRequest(presUrl);
|
||||
var request = new PresentationRequest(presentationUrls);
|
||||
return request;
|
||||
}
|
||||
|
||||
|
@ -64,19 +63,6 @@
|
|||
assert_true(availability.value);
|
||||
});
|
||||
}, "There is an availability.");
|
||||
|
||||
|
||||
// Invalid Presentation URL Test
|
||||
promise_test(function () {
|
||||
var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)),
|
||||
invalidPresUrl = "../receiving-ua/idlharness.html#__castAppId__=3445E44B/__castClientId__=" + validUnixDate,
|
||||
request = new PresentationRequest(invalidPresUrl);
|
||||
|
||||
return request.getAvailability()
|
||||
.then(function (availability) {
|
||||
assert_false(availability.value);
|
||||
});
|
||||
}, "There is no availability for an invalid presentation URL.");
|
||||
// -------------------------------
|
||||
// Screen Availability Tests - end
|
||||
// -------------------------------
|
||||
|
|
|
@ -96,7 +96,7 @@ enum PresentationConnectionClosedReason {
|
|||
"wentaway"
|
||||
};
|
||||
|
||||
[Constructor(DOMString type, PresentationConnectionClosedEventInit eventInitDict)]
|
||||
[Constructor(DOMString type, PresentationConnectionCloseEventInit eventInitDict)]
|
||||
interface PresentationConnectionCloseEvent : Event {
|
||||
readonly attribute PresentationConnectionClosedReason reason;
|
||||
readonly attribute DOMString message;
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>Presentation API reconnect a presentation for Controlling User Agent (Error - manual test)</title>
|
||||
<link rel="author" title="Franck William Taffo" 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>
|
||||
<script>
|
||||
|
||||
/**
|
||||
*
|
||||
* Test if reconnect returns a NotFoundError() by wrong presentation ID
|
||||
*/
|
||||
|
||||
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;
|
||||
var request = new PresentationRequest(presentation_url);
|
||||
var wrong_presentationId = null;
|
||||
|
||||
var reconnect = function () {
|
||||
promise_test(function () {
|
||||
|
||||
var presId = "presId";
|
||||
// presId is mandatory when reconnecting to a presentation.
|
||||
return request.reconnect(presId)
|
||||
.then(function (setConnection) {
|
||||
assert_unreached("reconnect should not return a Promise resolve by wrong presentation ID");
|
||||
})
|
||||
}, "Check that the promise is rejected by wrong presentation Id");
|
||||
};
|
||||
|
||||
setup({explicit_timeout: true})
|
||||
</script>
|
||||
<p>click on the button to the perfom the test</p>
|
||||
<button id="reconnectBtn" onclick="reconnect()">Reconnect</button>
|
|
@ -0,0 +1,16 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>Calling "reconnect" with an unknown presentation ID fails with a NotFoundError exception</title>
|
||||
<link rel="author" title="Franck William Taffo" href="http://www.fokus.fraunhofer.de">
|
||||
<link rel="author" title="Louay Bassbouss" href="http://www.fokus.fraunhofer.de">
|
||||
<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 src="common.js"></script>
|
||||
<script>
|
||||
promise_test(function (t) {
|
||||
var wrongPresentationId = "wrongPresentationId";
|
||||
var request = new PresentationRequest(presentationUrls);
|
||||
return promise_rejects(t, 'NotFoundError', request.reconnect(wrongPresentationId));
|
||||
});
|
||||
</script>
|
|
@ -5,6 +5,7 @@
|
|||
<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>
|
||||
<script src="common.js"></script>
|
||||
|
||||
<ol>
|
||||
<li>Start the presentation with the blue button.</li>
|
||||
|
@ -31,9 +32,7 @@
|
|||
// ------------
|
||||
// Request init
|
||||
// ------------
|
||||
var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)),
|
||||
validPresURL = '../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__=' + validUnixDate,
|
||||
request = new PresentationRequest(validPresURL);
|
||||
var request = new PresentationRequest(presentationUrls);
|
||||
|
||||
|
||||
// ----------------------------------------
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Calling "start" when the user denied permission to use the display returns a Promise rejected with a NotAllowedError exception.</title>
|
||||
<link rel="author" title="Tomoyuki Shimizu" href="https://github.com/tomoyukilabs/">
|
||||
<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>
|
||||
<script src="common.js"></script>
|
||||
|
||||
<p>Before starting this test, confirm that there are one or more 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>
|
||||
|
||||
<script>
|
||||
// ----------
|
||||
// DOM Object
|
||||
// ----------
|
||||
var presentBtn = document.getElementById("presentBtn");
|
||||
|
||||
// -------------------------------------------
|
||||
// Start New Presentation Test (error) - begin
|
||||
// -------------------------------------------
|
||||
var startPresentation = function () {
|
||||
presentBtn.disabled = true;
|
||||
promise_test(function (t) {
|
||||
var request = new PresentationRequest(presentationUrls);
|
||||
return promise_rejects(t, 'NotAllowedError', request.start());
|
||||
});
|
||||
};
|
||||
// -----------------------------------------
|
||||
// Start New Presentation Test (error) - end
|
||||
// -----------------------------------------
|
||||
</script>
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Calling "start" when there is no available presentation display returns a Promise rejected with a NotFoundError exception.</title>
|
||||
<link rel="author" title="Tomoyuki Shimizu" href="https://github.com/tomoyukilabs/">
|
||||
<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>
|
||||
<script src="common.js"></script>
|
||||
|
||||
<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>
|
||||
|
||||
<script>
|
||||
// ----------
|
||||
// DOM Object
|
||||
// ----------
|
||||
var presentBtn = document.getElementById("presentBtn");
|
||||
|
||||
// -------------------------------------------
|
||||
// Start New Presentation Test (error) - begin
|
||||
// -------------------------------------------
|
||||
var startPresentation = function () {
|
||||
presentBtn.disabled = true;
|
||||
promise_test(function (t) {
|
||||
var request = new PresentationRequest(presentationUrls);
|
||||
return promise_rejects(t, 'NotFoundError', request.start());
|
||||
});
|
||||
};
|
||||
// -----------------------------------------
|
||||
// Start New Presentation Test (error) - end
|
||||
// -----------------------------------------
|
||||
</script>
|
|
@ -1,50 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Presentation API, start new presentation tests for Controlling User Agent (error - manual test)</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 abort the selection for an device, to start the manual test.</p>
|
||||
<button id="presentBtn" onclick="startPresentation()">Start Presentation Test</button>
|
||||
|
||||
<script>
|
||||
// ----------
|
||||
// DOM Object
|
||||
// ----------
|
||||
var presentBtn = document.getElementById("presentBtn");
|
||||
|
||||
// ------------
|
||||
// Request init
|
||||
// ------------
|
||||
var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)),
|
||||
validPresURL = '../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__=' + validUnixDate,
|
||||
request = new PresentationRequest(validPresURL);
|
||||
|
||||
// -------------------------------------------
|
||||
// Start New Presentation Test (error) - begin
|
||||
// -------------------------------------------
|
||||
var startPresentation = function () {
|
||||
promise_test(function () {
|
||||
return request.start()
|
||||
.catch(function (err) {
|
||||
|
||||
test(function () {
|
||||
assert_true(err.code == 20, 'The error code is equal to 20.');
|
||||
}, 'Check, if the error code is correct.')
|
||||
|
||||
test(function () {
|
||||
assert_true(err.message === 'Dialog closed.', 'The error message is equal to "Dialog closed."');
|
||||
}, 'Check, if the error message is correct.')
|
||||
|
||||
assert_true(err.name === 'AbortError', 'The error name is AbortError.');
|
||||
|
||||
});
|
||||
}, "The starting process for the presentation has been aborted.");
|
||||
}
|
||||
// -----------------------------------------
|
||||
// Start New Presentation Test (error) - end
|
||||
// -----------------------------------------
|
||||
</script>
|
||||
|
|
@ -6,24 +6,12 @@
|
|||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
|
||||
// ------------
|
||||
// Request init
|
||||
// ------------
|
||||
var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)),
|
||||
validPresURL = '../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__=' + validUnixDate,
|
||||
request = new PresentationRequest(validPresURL);
|
||||
|
||||
// -----------------------------------
|
||||
// Start New Presentation Test - begin
|
||||
// -----------------------------------
|
||||
promise_test(function () {
|
||||
return request.start()
|
||||
.catch(function (error) {
|
||||
assert_true(error instanceof InvalidAccessError);
|
||||
});
|
||||
|
||||
promise_test(function (t) {
|
||||
var request = new PresentationRequest('presentation.html');
|
||||
promise_rejects(t, 'InvalidAccessError', request.start());
|
||||
}, "The presentation could not start, because a user gesture is required.");
|
||||
// ----------------------------------
|
||||
// Launch New Presentation Test - end
|
||||
|
|
|
@ -1,59 +1,90 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Presentation API, start new presentation tests for Controlling User Agent (success - manual test)</title>
|
||||
<title>Checking the chain of events when starting a new presentation</title>
|
||||
<link rel="author" title="Marius Wessel" href="http://www.fokus.fraunhofer.de">
|
||||
<link rel="author" title="Tomoyuki Shimizu" href="https://github.com/tomoyukilabs">
|
||||
<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>
|
||||
<script src="common.js"></script>
|
||||
|
||||
<p>Click the button below and select the available casting device, to start the manual test.</p>
|
||||
<button id="presentBtn" onclick="startPresentation()">Start Presentation Test</button>
|
||||
<p>Click the button below and select the available presentation display, to start the manual test.</p>
|
||||
<button id="presentBtn">Start Presentation Test</button>
|
||||
|
||||
|
||||
<script>
|
||||
// description of event order
|
||||
var description = [
|
||||
"Phase #1: Promise is resolved",
|
||||
"Phase #2: 'connectionavailable' event fired",
|
||||
"Phase #3: 'connect' event fired"
|
||||
];
|
||||
var step = 0;
|
||||
|
||||
// presentation connection
|
||||
var connection;
|
||||
|
||||
// disable the timeout function for the tests
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
// ----------
|
||||
// DOM Object
|
||||
// ----------
|
||||
var presentBtn = document.getElementById("presentBtn");
|
||||
|
||||
// ------------
|
||||
// Request init
|
||||
// ------------
|
||||
var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)),
|
||||
validPresURL = '../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__=' + validUnixDate,
|
||||
request = new PresentationRequest(validPresURL);
|
||||
|
||||
// ---------------------------------------------
|
||||
// Start New Presentation Test (success) - begin
|
||||
// ---------------------------------------------
|
||||
var startPresentation = function () {
|
||||
promise_test(function () {
|
||||
return request.start()
|
||||
.then(function (connection) {
|
||||
presentBtn.onclick = function () {
|
||||
presentBtn.disabled = true;
|
||||
promise_test(function (t) {
|
||||
var phase = -1, actual = -1;
|
||||
|
||||
// assert case for the promise_test
|
||||
assert_equals(connection.state, "connected", "The presentation has an connected state.");
|
||||
// increment the count in the actual event order
|
||||
var count = function(evt) { actual++; return evt; };
|
||||
// increment the count in the expected event order and compare it with the actual event order
|
||||
var checkPhase = function(evt) { phase++; assert_equals(description[actual], description[phase], 'Event order is incorrect.'); return evt; };
|
||||
|
||||
// Check, if the connection ID is set
|
||||
test(function () {
|
||||
assert_true(!!connection.id);
|
||||
}, 'The connection ID is set.');
|
||||
var request = new PresentationRequest(presentationUrls);
|
||||
var eventWatcher = new EventWatcher(t, request, 'connectionavailable');
|
||||
var waitConnectionavailable = eventWatcher.wait_for('connectionavailable').then(count);
|
||||
var waitConnect;
|
||||
|
||||
// Check the type of the connection.id
|
||||
test(function () {
|
||||
assert_true(typeof connection.id === 'string');
|
||||
}, 'The connection ID is a string.');
|
||||
return request.start().then(count)
|
||||
.then(checkPhase).then(function (c) {
|
||||
// Phase #1: Promise is resolved
|
||||
connection = c;
|
||||
|
||||
// Check the instance of the connection
|
||||
test(function () {
|
||||
assert_true(connection instanceof PresentationConnection);
|
||||
}, 'The connection is an instance of PresentationConnection.');
|
||||
});
|
||||
// No more user input needed, re-enable timeout
|
||||
t.step_timeout(function() {
|
||||
t.force_timeout();
|
||||
t.done();
|
||||
}, 5000);
|
||||
|
||||
}, "The presentation was started successfully.");
|
||||
// Check the initial state of the presentation connection
|
||||
assert_equals(connection.state, 'connecting', 'Check the initial state of the presentation connection.');
|
||||
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.');
|
||||
|
||||
var eventWatcher = new EventWatcher(t, connection, 'connect');
|
||||
waitConnect = eventWatcher.wait_for('connect').then(count);
|
||||
|
||||
return waitConnectionavailable;
|
||||
})
|
||||
.then(checkPhase).then(function (evt) {
|
||||
// Phase #2: "connectionavailable" event fired
|
||||
assert_equals(connection, evt.connection, 'Both Promise from PresentationRequest() and a "connectionavailable" event handler receive the same presentation connection.');
|
||||
|
||||
return waitConnect;
|
||||
})
|
||||
.then(checkPhase).then(function () {
|
||||
// Phase #3: "connect" event fired
|
||||
assert_equals(connection.state, 'connected', 'The state of the presentation connection is "connected" when a "connect" event fires.');
|
||||
});
|
||||
});
|
||||
}
|
||||
// -------------------------------------------
|
||||
// Start New Presentation Test (success) - end
|
||||
// -------------------------------------------
|
||||
</script>
|
||||
|
||||
</script>
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Calling "start" when there is already an unsettled Promise returns a Promise rejected with an OperationError exception.</title>
|
||||
<link rel="author" title="Tomoyuki Shimizu" href="https://github.com/tomoyukilabs/">
|
||||
<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>
|
||||
<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>
|
||||
|
||||
<script>
|
||||
// ----------
|
||||
// DOM Object
|
||||
// ----------
|
||||
var presentBtn = document.getElementById("presentBtn");
|
||||
|
||||
// -------------------------------------------
|
||||
// Start New Presentation Test (error) - begin
|
||||
// -------------------------------------------
|
||||
var startPresentation = 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());
|
||||
});
|
||||
};
|
||||
// -----------------------------------------
|
||||
// Start New Presentation Test (error) - end
|
||||
// -----------------------------------------
|
||||
</script>
|
|
@ -3,10 +3,21 @@
|
|||
<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 src="../common.js"></script>
|
||||
<script>
|
||||
window.onmessage = function (ev) {
|
||||
try {
|
||||
var request = new PresentationRequest('presentation.html');;
|
||||
// Presentation URLs are relative to the "controlling-ua" folder,
|
||||
// update relative URLs for this folder
|
||||
var urls = presentationUrls.map(function (url) {
|
||||
if (/:\/\//.test(url)) {
|
||||
return url;
|
||||
}
|
||||
else {
|
||||
return '../' + url;
|
||||
}
|
||||
});
|
||||
var request = new PresentationRequest(urls);
|
||||
if (ev.data === 'start') {
|
||||
request.start()
|
||||
.then(function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue