summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/presentation-api
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/presentation-api
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/presentation-api')
-rw-r--r--testing/web-platform/tests/presentation-api/OWNERS3
-rw-r--r--testing/web-platform/tests/presentation-api/README.md24
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onclosed-manual.html41
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onconnected-manual.html39
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onterminated-manual.html47
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_error.html33
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_success.html43
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/defaultRequest_success-manual.html52
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/getAvailability.html83
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_mixedcontent.https.html18
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_sandboxing_error.html26
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_sandboxing_success.html25
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/idlharness.html129
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_error-manual.html36
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_mixedcontent.https.html18
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_error.html26
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_success.html25
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_success-manual.html73
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_error.html28
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_mixedcontent-manual.https.html29
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_mixedcontent_multiple-manual.https.html32
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_sandboxing_error-manual.html31
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_sandboxing_success-manual.html31
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_success-manual.html59
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/support/iframe.html59
-rw-r--r--testing/web-platform/tests/presentation-api/controlling-ua/support/presentation.html24
-rw-r--r--testing/web-platform/tests/presentation-api/receiving-ua/idlharness.html120
27 files changed, 1154 insertions, 0 deletions
diff --git a/testing/web-platform/tests/presentation-api/OWNERS b/testing/web-platform/tests/presentation-api/OWNERS
new file mode 100644
index 000000000..47731cfab
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/OWNERS
@@ -0,0 +1,3 @@
+@louaybassbouss
+@tidoust
+@zqzhang \ No newline at end of file
diff --git a/testing/web-platform/tests/presentation-api/README.md b/testing/web-platform/tests/presentation-api/README.md
new file mode 100644
index 000000000..77861e0e0
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/README.md
@@ -0,0 +1,24 @@
+# Presentation API Tests
+
+This test suite is currently tracking the [Editor Draft][editor-draft] of the Presentation API. The Presentation API describes the [conformance criteria for two classes of user agents][conformance-classes] ([controlling user agent][dfn-controlling-user-agent] and [receiving user agent][dfn-receiving-user-agent]). Each of the two subfolders [controlling-ua](./controlling-ua) and [receiving-ua](./receiving-ua) contains the Presentation API tests for each class of user agents.
+
+## IDL Tests
+
+Each of the [controlling-ua](./controlling-ua) and [receiving-ua](./receiving-ua) subfolders contains a file `idlharness.html` that defines IDL tests of the Presentation API for controlling and receiving user agents. The WebIDL of the Presentation API spec is extracted from the [Editor Draft][editor-draft] by running the following JavaScript code in the Dev. console of the Browser.
+
+```javascript
+(function(){
+ var s = "";
+ [].forEach.call(document.getElementsByClassName("idl"), function(idl) {
+ if (!idl.classList.contains("extract"))
+ s += idl.textContent + "\n\n";
+ });
+ document.body.innerHTML = '<pre></pre>';
+ document.body.firstChild.textContent = s;
+ })();
+```
+
+[editor-draft]: http://w3c.github.io/presentation-api/
+[conformance-classes]: http://w3c.github.io/presentation-api/#conformance-classes
+[dfn-controlling-user-agent]: http://w3c.github.io/presentation-api/#dfn-controlling-user-agent
+[dfn-receiving-user-agent]: http://w3c.github.io/presentation-api/#dfn-receiving-user-agent \ No newline at end of file
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onclosed-manual.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onclosed-manual.html
new file mode 100644
index 000000000..c83f659dd
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onclosed-manual.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+
+<meta charset="utf-8">
+<title>PresentationConnection.onclose</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="author" title="He Yue" href="mailto:yue.he@intel.com">
+<link rel="help" href="http://w3c.github.io/presentation-api/#interface-presentationconnection">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<h2>Description</h2>
+<p>
+ This test validates that after connection close,<br/>
+ the connection state is set closed,<br/>
+ the onclose EventHandler is triggered.
+</p>
+<br/>
+<p>Click the button below to start the test.</p>
+<button id="presentStartBtn" onclick="startPresentation()">Start Presentation Test</button>
+
+<script>
+ setup({explicit_timeout: true});
+ var startPresentation = function () {
+ 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);
+ request.start()
+ .then(function(connection) {
+ assert_true(connection instanceof PresentationConnection, 'the connection is setup');
+ connection.onclose = t.step_func_done(function(evt) {
+ assert_equals(evt.type, "close");
+ assert_equals(connection.state, "closed");
+ });
+ connection.close();
+ })
+ .catch(function(ex) {
+ assert_unreached(ex.name + ":" + ex.message);
+ });
+ }, "the onclose is fired and the connection state is closed.");
+ }
+</script>
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onconnected-manual.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onconnected-manual.html
new file mode 100644
index 000000000..ce6b9cb2e
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onconnected-manual.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+
+<meta charset="utf-8">
+<title>PresentationConnection.onconnect</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="author" title="He Yue" href="mailto:yue.he@intel.com">
+<link rel="help" href="http://w3c.github.io/presentation-api/#interface-presentationconnection">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<h2>Description</h2>
+<p>
+ This test validates that after connection starts,<br/>
+ the onconnect EventHandler is triggered and connection state is connected.
+</p>
+<br/>
+<p>Click the button below to start the test.</p>
+<button id="presentStartBtn" onclick="startPresentation()">Start Presentation Test</button>
+
+<script>
+ setup({explicit_timeout: true});
+ var startPresentation = function () {
+ 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);
+ request.start()
+ .then(function(connection) {
+ assert_true(connection instanceof PresentationConnection);
+ connection.onconnect = t.step_func_done(function() {
+ assert_equals(connection.state, "connected");
+ });
+ connection.close();
+ })
+ .catch(function(ex) {
+ assert_unreached(ex.name + ":" + ex.message);
+ });
+ }, "the onconnect is fired and the connection state is connected");
+ }
+</script>
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onterminated-manual.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onterminated-manual.html
new file mode 100644
index 000000000..cb3204536
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onterminated-manual.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+
+<meta charset="utf-8">
+<title>PresentationConnection.onterminate</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="author" title="Chunyan Wang" href="mailto:chunyanx.wang@intel.com">
+<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>
+<h2>Description</h2>
+<p>
+ This test validates that after connection terminate,<br/>
+ the connection state is set terminated,<br/>
+ the onterminate EventHandler is triggered.
+</p>
+<br/>
+<p>Click the button below to start the test.</p>
+<button id="presentStartBtn" onclick="startPresentation()">Start Presentation Test</button>
+
+<script>
+ setup({explicit_timeout: true});
+ var startPresentation = function () {
+ 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);
+ 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");
+ });
+ connection.onclose = t.step_func_done(function(evt) {
+ assert_unreached("Wrong, the onclose shouldn't be triggered!");
+ });
+ })
+ .catch(function(ex) {
+ assert_unreached(ex.name + ":" + ex.message);
+ });
+ }, "the onterminate is fired and the connection state is terminated");
+ }
+</script>
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_error.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_error.html
new file mode 100644
index 000000000..d6324ea56
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_error.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Presentation API PresentationRequest for Controlling User Agent (Error)</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(function() {
+ assert_throws(new TypeError(), function() {
+ new PresentationRequest();
+ });
+ }, 'Call PresentationRequest() constructor without 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('http://@');
+ });
+ }, 'Call PresentationRequest constructor with an invalid URL. SyntaxError Exception expected.');
+
+ test(function() {
+ assert_throws('SyntaxError', function() {
+ new PresentationRequest(['presentation.html', 'http://@']);
+ });
+ }, 'Call PresentationRequest constructor with a sequence of URLs, one of them invalid. SyntaxError Exception expected.');
+</script>
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_success.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_success.html
new file mode 100644
index 000000000..4e1570e83
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_success.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Presentation API PresentationRequest for Controlling User Agent (Success)</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(function() {
+ try {
+ var request = new PresentationRequest('presentation.html');
+ assert_true(request instanceof PresentationRequest);
+ }
+ catch (ex) {
+ assert_unreached('PresentationRequest constructor threw an unexpected exception "' + ex.name + '"');
+ }
+ }, '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> \ No newline at end of file
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/defaultRequest_success-manual.html b/testing/web-platform/tests/presentation-api/controlling-ua/defaultRequest_success-manual.html
new file mode 100644
index 000000000..8535d8337
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/defaultRequest_success-manual.html
@@ -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>
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability.html b/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability.html
new file mode 100644
index 000000000..de6ca2b74
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability.html
@@ -0,0 +1,83 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Presentation API - monitor screen availability tests for Controlling User Agent</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>
+
+<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);
+ return request;
+ }
+
+ // ---------------------------------
+ // Screen Availability Tests - begin
+ // ---------------------------------
+
+ // Instance of Promise Test
+ test(function () {
+ var request = createRequestObject();
+ assert_true(request.getAvailability() instanceof Promise);
+ }, 'The request is an Promise.')
+
+ // Instance of PresentationRequest Test
+ test(function () {
+ var request = createRequestObject();
+ assert_true(request instanceof PresentationRequest);
+ }, 'The request is an instance of PresentationRequest.')
+
+ // Instance of PresentationAvailability Test
+ promise_test(function () {
+ var request = createRequestObject();
+
+ return request.getAvailability()
+ .then(function (availability) {
+ assert_true(availability instanceof PresentationAvailability);
+ });
+ }, "The promise is an instance of PresentationAvailability");
+
+ // Availability.value is set Test
+ promise_test(function () {
+ var request = createRequestObject();
+
+ 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.");
+
+
+ // 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
+ // -------------------------------
+</script>
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_mixedcontent.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_mixedcontent.https.html
new file mode 100644
index 000000000..4e8cb1f22
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_mixedcontent.https.html
@@ -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>
+
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_sandboxing_error.html b/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_sandboxing_error.html
new file mode 100644
index 000000000..88cae73c0
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_sandboxing_error.html
@@ -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>
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_sandboxing_success.html b/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_sandboxing_success.html
new file mode 100644
index 000000000..daa0a0ff1
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_sandboxing_success.html
@@ -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>
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/idlharness.html b/testing/web-platform/tests/presentation-api/controlling-ua/idlharness.html
new file mode 100644
index 000000000..8c3268af2
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/idlharness.html
@@ -0,0 +1,129 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Presentation API IDL tests for Controlling User Agent</title>
+<link rel="author" title="Louay Bassbouss" 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 src="/resources/WebIDLParser.js"></script>
+<script src="/resources/idlharness.js"></script>
+
+<script id="untested_idl" type="text/plain">
+interface Navigator {
+};
+interface EventTarget {
+};
+interface EventHandler {
+};
+interface Event {
+};
+dictionary EventInit {
+};
+</script>
+
+<script id='idl' type="text/plain">
+partial interface Navigator {
+ [SameObject]
+ readonly attribute Presentation? presentation;
+};
+
+interface Presentation {
+};
+
+partial interface Presentation {
+ attribute PresentationRequest? defaultRequest;
+};
+
+[Constructor(DOMString url),
+ Constructor(sequence<DOMString> urls)]
+interface PresentationRequest : EventTarget {
+ Promise<PresentationConnection> start();
+ Promise<PresentationConnection> reconnect(DOMString presentationId);
+ Promise<PresentationAvailability> getAvailability();
+
+ attribute EventHandler onconnectionavailable;
+};
+
+interface PresentationAvailability : EventTarget {
+ readonly attribute boolean value;
+ attribute EventHandler onchange;
+};
+
+[Constructor(DOMString type, PresentationConnectionAvailableEventInit eventInitDict)]
+interface PresentationConnectionAvailableEvent : Event {
+ [SameObject]
+ readonly attribute PresentationConnection connection;
+};
+
+dictionary PresentationConnectionAvailableEventInit : EventInit {
+ required PresentationConnection connection;
+};
+
+enum PresentationConnectionState {
+ "connecting",
+ "connected",
+ "closed",
+ "terminated"
+};
+
+enum BinaryType {
+ "blob",
+ "arraybuffer"
+};
+
+interface PresentationConnection : EventTarget {
+ readonly attribute DOMString id;
+ readonly attribute DOMString url;
+ readonly attribute PresentationConnectionState state;
+ void close();
+ void terminate();
+ attribute EventHandler onconnect;
+ attribute EventHandler onclose;
+ attribute EventHandler onterminate;
+
+ // Communication
+ attribute BinaryType binaryType;
+ attribute EventHandler onmessage;
+ void send(DOMString message);
+ void send(Blob data);
+ void send(ArrayBuffer data);
+ void send(ArrayBufferView data);
+};
+
+enum PresentationConnectionClosedReason {
+ "error",
+ "closed",
+ "wentaway"
+};
+
+[Constructor(DOMString type, PresentationConnectionCloseEventInit eventInitDict)]
+interface PresentationConnectionCloseEvent : Event {
+ readonly attribute PresentationConnectionClosedReason reason;
+ readonly attribute DOMString message;
+};
+
+dictionary PresentationConnectionCloseEventInit : EventInit {
+ required PresentationConnectionClosedReason reason;
+ DOMString message = "";
+};
+</script>
+
+<script>
+ (function() {
+ "use strict";
+ var idl_array = new IdlArray();
+ 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', 'presentation_request', 'presentation_request_urls']
+ });
+ idl_array.test();
+ })();
+</script>
+
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_error-manual.html b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_error-manual.html
new file mode 100644
index 000000000..7d340e8f6
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_error-manual.html
@@ -0,0 +1,36 @@
+<!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> \ No newline at end of file
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_mixedcontent.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_mixedcontent.https.html
new file mode 100644
index 000000000..b1043a103
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_mixedcontent.https.html
@@ -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>
+
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_error.html b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_error.html
new file mode 100644
index 000000000..c3286f55a
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_error.html
@@ -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>
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_success.html b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_success.html
new file mode 100644
index 000000000..96505aca0
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_success.html
@@ -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>
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_success-manual.html b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_success-manual.html
new file mode 100644
index 000000000..f2c9ac32f
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_success-manual.html
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Presentation API, reconnect to presentation tests for Controlling User Agent (success - 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>
+
+<ol>
+ <li>Start the presentation with the blue button.</li>
+ <li>After the presentation ist running successfully, disconnect the connected device.</li>
+ <li>Reconnect the device and press the green button, to start the reconnection process.</li>
+</ol>
+
+<button id="startBtn" onclick="startPresentation()" style="background-color: #2aabd2;">Start Presentation</button>
+<button id="reconnectBtn" onclick="reconnectToPresentation()" style="background-color: #5cb85c;">Reconnect Presentation
+ Test
+</button>
+
+<script>
+ // disable the timeout function for the tests
+ // and call 'done()' when the tests cases are finished.
+ setup({explicit_timeout: true});
+
+ // ----------
+ // DOM Object
+ // ----------
+ var startBtn = document.getElementById("startBtn"),
+ reconnectBtn = document.getElementById("reconnectBtn");
+
+ // ------------
+ // 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);
+
+
+ // ----------------------------------------
+ // Helper Function - start the presentation
+ // ----------------------------------------
+ var startPresentation = function () {
+ return request.start()
+ .then(function (connection) {
+ // save the presentation id within the
+ // local storage of the browser
+ localStorage["presId"] = connection.id;
+ });
+ }
+
+ // ------------------------------------------------
+ // Reconnect to Presentation Test (success) - begin
+ // ------------------------------------------------
+ var reconnectToPresentation = function () {
+
+ promise_test(function () {
+
+ // get the saved presentation id
+ // for the reconnect function if exist
+ if (localStorage["presId"]) var presId = localStorage["presId"];
+
+ return request.reconnect(presId)
+ .then(function (connection) {
+ assert_true(connection instanceof PresentationConnection);
+ done();
+ });
+ }, 'The reconnection was successful.');
+ }
+ // ----------------------------------------------
+ // Reconnect to Presentation Test (success) - end
+ // ----------------------------------------------
+</script>
+
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_error.html b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_error.html
new file mode 100644
index 000000000..eea3486cd
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_error.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Presentation API, start new presentation tests for Controlling User Agent (error)</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>
+<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 (t) {
+ promise_rejects(t, 'InvalidAccessError', request.start());
+ }, "The presentation could not start, because a user gesture is required.");
+ // ----------------------------------
+ // Launch New Presentation Test - end
+ // ----------------------------------
+</script>
+
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_mixedcontent-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_mixedcontent-manual.https.html
new file mode 100644
index 000000000..1a0c39e82
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_mixedcontent-manual.https.html
@@ -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>
+
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_mixedcontent_multiple-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_mixedcontent_multiple-manual.https.html
new file mode 100644
index 000000000..3987de505
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_mixedcontent_multiple-manual.https.html
@@ -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>
+
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_sandboxing_error-manual.html b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_sandboxing_error-manual.html
new file mode 100644
index 000000000..06334b000
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_sandboxing_error-manual.html
@@ -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>
+
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_sandboxing_success-manual.html b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_sandboxing_success-manual.html
new file mode 100644
index 000000000..68e037a5c
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_sandboxing_success-manual.html
@@ -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>
+
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_success-manual.html b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_success-manual.html
new file mode 100644
index 000000000..8e1cc7b83
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_success-manual.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Presentation API, start new presentation tests for Controlling User Agent (success - 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 select the available casting 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 (success) - begin
+ // ---------------------------------------------
+ var startPresentation = function () {
+ promise_test(function () {
+ return request.start()
+ .then(function (connection) {
+
+ // assert case for the promise_test
+ assert_equals(connection.state, "connected", "The presentation has an connected state.");
+
+ // Check, if the connection ID is set
+ test(function () {
+ assert_true(!!connection.id);
+ }, 'The connection ID is set.');
+
+ // Check the type of the connection.id
+ test(function () {
+ assert_true(typeof connection.id === 'string');
+ }, 'The connection ID is a string.');
+
+ // Check the instance of the connection
+ test(function () {
+ assert_true(connection instanceof PresentationConnection);
+ }, 'The connection is an instance of PresentationConnection.');
+ });
+
+ }, "The presentation was started successfully.");
+ }
+ // -------------------------------------------
+ // Start New Presentation Test (success) - end
+ // -------------------------------------------
+</script>
+
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/support/iframe.html b/testing/web-platform/tests/presentation-api/controlling-ua/support/iframe.html
new file mode 100644
index 000000000..60f94b69d
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/support/iframe.html
@@ -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>
+
diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/support/presentation.html b/testing/web-platform/tests/presentation-api/controlling-ua/support/presentation.html
new file mode 100644
index 000000000..ea13ded4a
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/support/presentation.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+
+<meta charset="utf-8">
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="author" title="He Yue" href="mailto:yue.he@intel.com">
+<link rel="help" href="http://w3c.github.io/presentation-api/#interface-presentationconnectionlist">
+<script>
+ var addConnection = function(connection) {
+ connection.onconnected = function () {
+ this.onmessage = function (evt) {
+ this.send(evt.data);
+ };
+ };
+ navigator.receiver.connectionList
+ .then(function(list) {
+ list.onconnectionavailable = function(connections) {
+ addConnection(connections[connections.length - 1]);
+ };
+ list.connections.map(function(connection) {
+ addConnection(connection);
+ });
+ });
+ }
+</script>
diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/idlharness.html b/testing/web-platform/tests/presentation-api/receiving-ua/idlharness.html
new file mode 100644
index 000000000..24b0859a6
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/receiving-ua/idlharness.html
@@ -0,0 +1,120 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Presentation API IDL tests for Receiving User Agent</title>
+<link rel="author" title="Louay Bassbouss" href="http://www.fokus.fraunhofer.de">
+<link rel="help" href="http://w3c.github.io/presentation-api/#dfn-receiving-user-agent">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/WebIDLParser.js"></script>
+<script src="/resources/idlharness.js"></script>
+
+<script id="untested_idl" type="text/plain">
+interface Navigator {
+};
+interface EventTarget {
+};
+interface EventHandler {
+};
+interface Event {
+};
+dictionary EventInit {
+};
+</script>
+
+<script id='idl' type="text/plain">
+partial interface Navigator {
+ [SameObject]
+ readonly attribute Presentation? presentation;
+};
+
+interface Presentation {
+};
+
+partial interface Presentation {
+ [SameObject]
+ readonly attribute PresentationReceiver? receiver;
+};
+
+[Constructor(DOMString type, PresentationConnectionAvailableEventInit eventInitDict)]
+interface PresentationConnectionAvailableEvent : Event {
+ [SameObject]
+ readonly attribute PresentationConnection connection;
+};
+
+dictionary PresentationConnectionAvailableEventInit : EventInit {
+ required PresentationConnection connection;
+};
+
+enum PresentationConnectionState {
+ "connecting",
+ "connected",
+ "closed",
+ "terminated"
+};
+
+enum BinaryType {
+ "blob",
+ "arraybuffer"
+};
+
+interface PresentationConnection : EventTarget {
+ readonly attribute DOMString? id;
+ readonly attribute PresentationConnectionState state;
+ void close();
+ void terminate();
+ attribute EventHandler onconnect;
+ attribute EventHandler onclose;
+ attribute EventHandler onterminate;
+
+ // Communication
+ attribute BinaryType binaryType;
+ attribute EventHandler onmessage;
+ void send(DOMString message);
+ void send(Blob data);
+ void send(ArrayBuffer data);
+ void send(ArrayBufferView data);
+};
+
+enum PresentationConnectionClosedReason {
+ "error",
+ "closed",
+ "wentaway"
+};
+
+[Constructor(DOMString type, PresentationConnectionCloseEventInit eventInitDict)]
+interface PresentationConnectionCloseEvent : Event {
+ readonly attribute PresentationConnectionClosedReason reason;
+ readonly attribute DOMString message;
+};
+
+dictionary PresentationConnectionCloseEventInit : EventInit {
+ required PresentationConnectionClosedReason reason;
+ DOMString message = "";
+};
+
+interface PresentationReceiver {
+ [SameObject]
+ readonly attribute Promise<PresentationConnectionList> connectionList;
+};
+
+interface PresentationConnectionList : EventTarget {
+ readonly attribute FrozenArray<PresentationConnection> connections;
+ attribute EventHandler onconnectionavailable;
+};
+</script>
+
+<script>
+ (function() {
+ "use strict";
+ var idl_array = new IdlArray();
+ var idls = document.getElementById('idl').textContent;
+ idl_array.add_untested_idls(document.getElementById('untested_idl').textContent);
+ idl_array.add_idls(idls);
+ idl_array.add_objects({
+ Presentation: ['navigator.presentation'],
+ PresentationReceiver: ['navigator.presentation.receiver']
+ });
+ idl_array.test();
+ })();
+</script>
+