From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../web-platform/tests/presentation-api/META.yml | 4 + .../web-platform/tests/presentation-api/README.md | 28 ++ ...entationAvailability_onchange-manual.https.html | 89 ++++++ .../PresentationConnectionCloseEvent.https.html | 24 ++ ...resentationConnection_onclose-manual.https.html | 145 +++++++++ ...sentationConnection_onconnect-manual.https.html | 72 +++++ ...sentationConnection_onmessage-manual.https.html | 144 +++++++++ ...ntationConnection_onterminate-manual.https.html | 157 ++++++++++ .../PresentationConnection_send-manual.https.html | 125 ++++++++ .../PresentationRequest_error.https.html | 36 +++ .../PresentationRequest_mixedcontent.https.html | 18 ++ ...ntationRequest_mixedcontent_multiple.https.html | 21 ++ ...Request_onconnectionavailable-manual.https.html | 85 ++++++ ...PresentationRequest_sandboxing_error.https.html | 26 ++ ...esentationRequest_sandboxing_success.https.html | 26 ++ .../PresentationRequest_success.https.html | 31 ++ .../presentation-api/controlling-ua/common.js | 25 ++ .../controlling-ua/defaultRequest.https.html | 24 ++ .../defaultRequest_success-manual.https.html | 63 ++++ .../controlling-ua/getAvailability.https.html | 54 ++++ .../getAvailability_sandboxing_success.https.html | 25 ++ .../controlling-ua/idlharness.https.html | 51 ++++ ...MultiplePresentations_success-manual.https.html | 138 +++++++++ ...ToPresentation_notfound_error-manual.https.html | 61 ++++ ...ectToPresentation_sandboxing_success.https.html | 25 ++ ...connectToPresentation_success-manual.https.html | 185 ++++++++++++ ...MultiplePresentations_success-manual.https.html | 99 +++++++ ...resentation_displaynotallowed-manual.https.html | 45 +++ ...wPresentation_displaynotfound-manual.https.html | 45 +++ .../startNewPresentation_error.https.html | 20 ++ ...esentation_sandboxing_success-manual.https.html | 31 ++ .../startNewPresentation_success-manual.https.html | 95 ++++++ ...Presentation_unsettledpromise-manual.https.html | 44 +++ .../controlling-ua/support/iframe.html | 181 ++++++++++++ .../controlling-ua/support/presentation.html | 98 ++++++ .../controlling-ua/support/stash.js | 83 ++++++ .../controlling-ua/support/stash.py | 10 + ...ionList_onconnectionavailable-manual.https.html | 77 +++++ ...resentationConnection_onclose-manual.https.html | 84 ++++++ ...sentationConnection_onmessage-manual.https.html | 64 ++++ .../PresentationConnection_send-manual.https.html | 97 ++++++ ...sentationConnection_terminate-manual.https.html | 71 +++++ .../PresentationReceiver_create-manual.https.html | 272 +++++++++++++++++ .../tests/presentation-api/receiving-ua/cache.txt | 1 + .../tests/presentation-api/receiving-ua/common.js | 63 ++++ .../receiving-ua/idlharness-manual.https.html | 44 +++ .../presentation-api/receiving-ua/serviceworker.js | 15 + ...ionList_onconnectionavailable_receiving-ua.html | 92 ++++++ ...resentationConnection_onclose_receiving-ua.html | 89 ++++++ ...sentationConnection_onmessage_receiving-ua.html | 108 +++++++ .../PresentationConnection_send_receiving-ua.html | 45 +++ ...sentationConnection_terminate_receiving-ua.html | 23 ++ .../PresentationReceiver_create_receiving-ua.html | 328 +++++++++++++++++++++ ...entationReceiver_create_receiving-ua_child.html | 171 +++++++++++ ...resentationReceiver_unreached_receiving-ua.html | 21 ++ .../support/idlharness_receiving-ua.html | 41 +++ .../receiving-ua/support/iframe.html | 22 ++ .../receiving-ua/support/serviceworker.js | 9 + .../presentation-api/receiving-ua/support/stash.js | 98 ++++++ .../presentation-api/receiving-ua/support/stash.py | 10 + 60 files changed, 4278 insertions(+) create mode 100644 testing/web-platform/tests/presentation-api/META.yml create mode 100644 testing/web-platform/tests/presentation-api/README.md create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/PresentationAvailability_onchange-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnectionCloseEvent.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onclose-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onconnect-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onmessage-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onterminate-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_send-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_error.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_mixedcontent.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_mixedcontent_multiple.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_onconnectionavailable-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_sandboxing_error.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_sandboxing_success.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_success.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/common.js create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/defaultRequest.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/defaultRequest_success-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/getAvailability.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_sandboxing_success.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/idlharness.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/reconnectToMultiplePresentations_success-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_notfound_error-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_success.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_success-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/startMultiplePresentations_success-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_displaynotallowed-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_displaynotfound-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_error.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_sandboxing_success-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_success-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_unsettledpromise-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/support/iframe.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/support/presentation.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/support/stash.js create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/support/stash.py create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnectionList_onconnectionavailable-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_onclose-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_onmessage-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_send-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_terminate-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/PresentationReceiver_create-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/cache.txt create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/common.js create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/idlharness-manual.https.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/serviceworker.js create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnectionList_onconnectionavailable_receiving-ua.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_onclose_receiving-ua.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_onmessage_receiving-ua.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_send_receiving-ua.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_terminate_receiving-ua.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationReceiver_create_receiving-ua.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationReceiver_create_receiving-ua_child.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationReceiver_unreached_receiving-ua.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/support/idlharness_receiving-ua.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/support/iframe.html create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/support/serviceworker.js create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/support/stash.js create mode 100644 testing/web-platform/tests/presentation-api/receiving-ua/support/stash.py (limited to 'testing/web-platform/tests/presentation-api') diff --git a/testing/web-platform/tests/presentation-api/META.yml b/testing/web-platform/tests/presentation-api/META.yml new file mode 100644 index 0000000000..beba890621 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/META.yml @@ -0,0 +1,4 @@ +spec: https://w3c.github.io/presentation-api/ +suggested_reviewers: + - tidoust + - zqzhang 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 0000000000..417769a498 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/README.md @@ -0,0 +1,28 @@ +# Presentation API Tests + +This test suite is currently tracking the [Editor's 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 + +The [controlling-ua](./controlling-ua) and [receiving-ua](./receiving-ua) subfolders contain files `idlharness.https.html` and `idlharness-manual.https.html` that define IDL tests of the Presentation API for controlling and receiving user agents, respectively. The WebIDL of the Presentation API spec is extracted from the [Editor's 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 = '
';
+  document.body.firstChild.textContent = s;
+  })();
+```
+
+## Receiving User Agent Tests
+
+The [receiving-ua](./receiving-ua) subfolder contains receiving user agent tests to be initiated by _a controlling user agent_. When the controlling user agent starts the test, it will ask a user to click a button and choose a presentation display. Once the presentation display is selected, the controlling user agent will request the receiving user agent to load and run the corresponding test placed in the [receiving-ua/support](./receiving-ua/support) subfolder. When the test ends, all results will appear on the controlling user agent's window.
+
+[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/PresentationAvailability_onchange-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationAvailability_onchange-manual.https.html
new file mode 100644
index 0000000000..48ecb610c6
--- /dev/null
+++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationAvailability_onchange-manual.https.html
@@ -0,0 +1,89 @@
+
+
+Monitoring the list of available presentation displays.
+
+
+
+
+
+
+

Please wait for a moment...

+

The test passes if a "PASS" result appears.

+ + \ No newline at end of file diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnectionCloseEvent.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnectionCloseEvent.https.html new file mode 100644 index 0000000000..34c935a603 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnectionCloseEvent.https.html @@ -0,0 +1,24 @@ + + +Constructing a PresentationConnectionCloseEvent + + + + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onclose-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onclose-manual.https.html new file mode 100644 index 0000000000..f63806f82b --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onclose-manual.https.html @@ -0,0 +1,145 @@ + + + +Closing a PresentationConnection + + + + + + + + +

Description

+

+ This test validates that after connection close,
+ the connection state is set closed,
+ the onclose EventHandler is triggered. +

+
+

Click the button below to start the test.

+ + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onconnect-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onconnect-manual.https.html new file mode 100644 index 0000000000..0f4a4ac369 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onconnect-manual.https.html @@ -0,0 +1,72 @@ + + + +Establishing a presentation connection + + + + + + + +

Description

+

+ This test validates that after connection starts,
+ the onconnect EventHandler is triggered and connection state is connected. +

+
+

Click the button below to start the test.

+ + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onmessage-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onmessage-manual.https.html new file mode 100644 index 0000000000..59d7e8c0e0 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onmessage-manual.https.html @@ -0,0 +1,144 @@ + + + +Receiving a message through PresentationConnection + + + + + + + +

+ Click the button below and select the available presentation display, to start the manual test. The test passes if a "PASS" result appears.
+ +

+ + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onterminate-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onterminate-manual.https.html new file mode 100644 index 0000000000..7fdc2dbdcd --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_onterminate-manual.https.html @@ -0,0 +1,157 @@ + + + +Terminating a presentation in a controlling browsing context + + + + + + + + +

+ Click the button below and select the available presentation display, to start the manual test. The test passes if a "PASS" result appears.
+ This test asks you to click the button twice, unless the test fails.
+

+ + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_send-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_send-manual.https.html new file mode 100644 index 0000000000..fcc91212e0 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationConnection_send-manual.https.html @@ -0,0 +1,125 @@ + + + +Sending a message through PresentationConnection + + + + + + + +

+ Click the button below and select the available presentation display, to start the manual test. The test passes if a "PASS" result appears.
+ +

+ + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_error.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_error.https.html new file mode 100644 index 0000000000..68e0fbcd22 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_error.https.html @@ -0,0 +1,36 @@ + + +Constructing a PresentationRequest (Error) + + + + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_mixedcontent.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_mixedcontent.https.html new file mode 100644 index 0000000000..3b19b9c9bd --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_mixedcontent.https.html @@ -0,0 +1,18 @@ + + +Creating a PresentationRequest with an a priori unauthenticated URL in an HTTPS context throws a SecurityError exception. + + + + + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_mixedcontent_multiple.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_mixedcontent_multiple.https.html new file mode 100644 index 0000000000..e9571224d6 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_mixedcontent_multiple.https.html @@ -0,0 +1,21 @@ + + +Creating a PresentationRequest with a set of URLs containing an a priori unauthenticated URL in an HTTPS context throws a SecurityError exception. + + + + + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_onconnectionavailable-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_onconnectionavailable-manual.https.html new file mode 100644 index 0000000000..d06daae11c --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_onconnectionavailable-manual.https.html @@ -0,0 +1,85 @@ + + +Firing a connectionavailable event at a controlling user agent + + + + + +

Click the button below and select the available presentation display, to start the manual test.

+ + + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_sandboxing_error.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_sandboxing_error.https.html new file mode 100644 index 0000000000..ad5e32a45a --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_sandboxing_error.https.html @@ -0,0 +1,26 @@ + + +Sandboxing: Creating a PresentationRequest from a nested context fails when allow-presentation is not set + + + + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_sandboxing_success.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_sandboxing_success.https.html new file mode 100644 index 0000000000..7ede80d595 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_sandboxing_success.https.html @@ -0,0 +1,26 @@ + + +Sandboxing: Creating a PresentationRequest from a nested context succeeds when allow-presentation is set + + + + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_success.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_success.https.html new file mode 100644 index 0000000000..890e0ed624 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/PresentationRequest_success.https.html @@ -0,0 +1,31 @@ + + +Constructing a PresentationRequest + + + + + + + \ No newline at end of file diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/common.js b/testing/web-platform/tests/presentation-api/controlling-ua/common.js new file mode 100644 index 0000000000..4a73acd1de --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/common.js @@ -0,0 +1,25 @@ +(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 = 'cast:' + castAppId; + + window.presentationUrls = [ + 'support/presentation.html', + castUrl + ]; + + // Both a controlling side and a receiving one must share the same Stash ID to + // transmit data from one to the other. On the other hand, due to polling mechanism + // which cleans up a stash, stashes in both controller-to-receiver direction + // and one for receiver-to-controller are necessary. + window.stashIds = { + toController: '9bf08fea-a71a-42f9-b3c4-fa19499e4d12', + toReceiver: 'f1fdfd10-b606-4748-a644-0a8e9df3bdd6' + } +})(window); diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/defaultRequest.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/defaultRequest.https.html new file mode 100644 index 0000000000..713cea7f9a --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/defaultRequest.https.html @@ -0,0 +1,24 @@ + + +Setting a default presentation request + + + + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/defaultRequest_success-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/defaultRequest_success-manual.https.html new file mode 100644 index 0000000000..840b72b849 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/defaultRequest_success-manual.https.html @@ -0,0 +1,63 @@ + + +[Optional] Starting a presentation from the browser using a default presentation request. + + + + + + + +

+ Click the button or the menu item for presentation on your browser (for example, "Cast"),
+ to start the manual test, and select a presentation display when prompted to do so.
+ The test passes if a "PASS" result appears. +

+

+ If your browser does not support defaultRequest, please click this button: +

+ + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability.https.html new file mode 100644 index 0000000000..71b19e6a4e --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability.https.html @@ -0,0 +1,54 @@ + + +Getting the presentation displays availability information. + + + + + + + + +

The test passes if a "PASS" result appears.

+ + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_sandboxing_success.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_sandboxing_success.https.html new file mode 100644 index 0000000000..daa0a0ff14 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/getAvailability_sandboxing_success.https.html @@ -0,0 +1,25 @@ + + +Sandboxing: Retrieving display availability from a nested context succeeds when allow-presentation is set + + + + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/idlharness.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/idlharness.https.html new file mode 100644 index 0000000000..1cb8830f89 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/idlharness.https.html @@ -0,0 +1,51 @@ + + +Presentation API IDL tests for Controlling User Agent + + + + + + + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToMultiplePresentations_success-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToMultiplePresentations_success-manual.https.html new file mode 100644 index 0000000000..ab1bd8089d --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToMultiplePresentations_success-manual.https.html @@ -0,0 +1,138 @@ + + +Reconnecting presentations on two distinct displays + + + + + + + +

Click the button below and select the available presentation display, to start the manual test.

+

Click the button below and select the other available presentation display, to continue the manual test.

+

This test asks you to click the button twice, unless the test fails.
+This test requires two or more available displays.

+ + + + \ No newline at end of file diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_notfound_error-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_notfound_error-manual.https.html new file mode 100644 index 0000000000..f92ab80f73 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_notfound_error-manual.https.html @@ -0,0 +1,61 @@ + + +Calling "reconnect" with a wrong presentation ID fails with a NotFoundError exception + + + + + + + + +

Click the button below to start the manual test. Select a presentation device after the selection dialog is prompted. + The test assumes that at least one presentation device is available. The test passes if a "PASS" result appears.

+ + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_success.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_success.https.html new file mode 100644 index 0000000000..96505aca05 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_success.https.html @@ -0,0 +1,25 @@ + + +Sandboxing: Reconnecting a presentation from a nested context succeeds when allow-presentation is set + + + + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_success-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_success-manual.https.html new file mode 100644 index 0000000000..a2619042f8 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/reconnectToPresentation_success-manual.https.html @@ -0,0 +1,185 @@ + + +Reconnect to presentation success manual test + + + + + + + + +

Click the button below to start the manual test. Select a presentation device after the selection dialog is prompted. + The test assumes that at least one presentation device is available. The test passes if a "PASS" result appears.

+ + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/startMultiplePresentations_success-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/startMultiplePresentations_success-manual.https.html new file mode 100644 index 0000000000..0268bd87e8 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/startMultiplePresentations_success-manual.https.html @@ -0,0 +1,99 @@ + + +Starting presentations on two distinct displays + + + + + + + +

Click the button below and select the available presentation display, to start the manual test.

+

Click the button below and select the other available presentation display, to continue the manual test.

+

This test asks you to click the button twice, unless the test fails.
+This test requires two or more available displays.

+ + + + \ No newline at end of file diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_displaynotallowed-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_displaynotallowed-manual.https.html new file mode 100644 index 0000000000..877c17a35d --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_displaynotallowed-manual.https.html @@ -0,0 +1,45 @@ + + +Calling "start" when the user denied permission to use the display returns a Promise rejected with a NotAllowedError exception. + + + + + + +

Before starting this test, confirm that there are one or more available presentation display on your local network.

+

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. +

+ + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_displaynotfound-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_displaynotfound-manual.https.html new file mode 100644 index 0000000000..edfea3a4fd --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_displaynotfound-manual.https.html @@ -0,0 +1,45 @@ + + +Calling "start" when there is no available presentation display returns a Promise rejected with a NotFoundError exception. + + + + + + +

Before starting this test, confirm that there is no available presentation display on your local network.

+

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. +

+ + + \ No newline at end of file diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_error.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_error.https.html new file mode 100644 index 0000000000..3171c6c104 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_error.https.html @@ -0,0 +1,20 @@ + + +Presentation API, start new presentation tests for Controlling User Agent (error) + + + + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_sandboxing_success-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_sandboxing_success-manual.https.html new file mode 100644 index 0000000000..68e037a5c0 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_sandboxing_success-manual.https.html @@ -0,0 +1,31 @@ + + +Sandboxing: starting a presentation from a nested context succeeds when allow-presentation is set + + + + + + +

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.

+ + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_success-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_success-manual.https.html new file mode 100644 index 0000000000..c9378c0e68 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_success-manual.https.html @@ -0,0 +1,95 @@ + + +Checking the chain of events when starting a new presentation + + + + + + + +

Click the button below and select the available presentation display, to start the manual test.

+ + + + \ No newline at end of file diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_unsettledpromise-manual.https.html b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_unsettledpromise-manual.https.html new file mode 100644 index 0000000000..fb747eb0a4 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/startNewPresentation_unsettledpromise-manual.https.html @@ -0,0 +1,44 @@ + + +Calling "start" when there is already an unsettled Promise returns a Promise rejected with an OperationError exception. + + + + + + +

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.

+ + + \ No newline at end of file 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 0000000000..e2171deaa8 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/support/iframe.html @@ -0,0 +1,181 @@ + + +Presentation API - controlling ua - sandboxing + + + + + + + + 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 0000000000..8ad838062f --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/support/presentation.html @@ -0,0 +1,98 @@ + + + + + + + + + + \ No newline at end of file diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/support/stash.js b/testing/web-platform/tests/presentation-api/controlling-ua/support/stash.js new file mode 100644 index 0000000000..616907d4f2 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/support/stash.js @@ -0,0 +1,83 @@ +var Stash = function(inbound, outbound) { + this.stashPath = '/presentation-api/controlling-ua/support/stash.py?id='; + this.inbound = inbound; + this.outbound = outbound; +} + +// initialize a stash on wptserve +Stash.prototype.init = function() { + return Promise.all([ + fetch(this.stashPath + this.inbound).then(response => { + return response.text(); + }), + fetch(this.stashPath + this.outbound).then(response => { + return response.text(); + }) + ]); +} + +// upload a test result to a stash on wptserve +Stash.prototype.send = function(result) { + return fetch(this.stashPath + this.outbound, { + method: 'POST', + body: JSON.stringify({ type: 'data', data: result }) + }).then(response => { + return response.text(); + }).then(text => { + return text === 'ok' ? null : Promise.reject(); + }) +}; + +// wait until a test result is uploaded to a stash on wptserve +Stash.prototype.receive = function() { + return new Promise((resolve, reject) => { + let intervalId; + const interval = 500; // msec + const polling = () => { + return fetch(this.stashPath + this.inbound).then(response => { + return response.text(); + }).then(text => { + if (text) { + try { + const json = JSON.parse(text); + if (json.type === 'data') + resolve(json.data); + else + reject(); + } catch(e) { + resolve(text); + } + clearInterval(intervalId); + } + }); + }; + intervalId = setInterval(polling, interval); + }); +}; + +// reset a stash on wptserve +Stash.prototype.stop = function() { + return Promise.all([ + fetch(this.stashPath + this.inbound).then(response => { + return response.text(); + }), + fetch(this.stashPath + this.outbound).then(response => { + return response.text(); + }) + ]).then(() => { + return Promise.all([ + fetch(this.stashPath + this.inbound, { + method: 'POST', + body: JSON.stringify({ type: 'stop' }) + }).then(response => { + return response.text(); + }), + fetch(this.stashPath + this.outbound, { + method: 'POST', + body: JSON.stringify({ type: 'stop' }) + }).then(response => { + return response.text(); + }) + ]); + }); +} diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/support/stash.py b/testing/web-platform/tests/presentation-api/controlling-ua/support/stash.py new file mode 100644 index 0000000000..83653d365a --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/support/stash.py @@ -0,0 +1,10 @@ +def main(request, response): + key = request.GET.first(b"id") + + if request.method == u"POST": + request.server.stash.put(key, request.body) + return b"ok" + else: + value = request.server.stash.take(key) + assert request.server.stash.take(key) is None + return value \ No newline at end of file diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnectionList_onconnectionavailable-manual.https.html b/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnectionList_onconnectionavailable-manual.https.html new file mode 100644 index 0000000000..9b75a85e9f --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnectionList_onconnectionavailable-manual.https.html @@ -0,0 +1,77 @@ + + +Monitoring incoming presentation connections + + + + + + +

Click the button below and select the available presentation display, to start the manual test.

+ + + + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_onclose-manual.https.html b/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_onclose-manual.https.html new file mode 100644 index 0000000000..50585f7813 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_onclose-manual.https.html @@ -0,0 +1,84 @@ + + +Closing a PresentationConnection + + + + + + +

Click the button below and select the available presentation display, to start the manual test.

+ + + + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_onmessage-manual.https.html b/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_onmessage-manual.https.html new file mode 100644 index 0000000000..53451a6cef --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_onmessage-manual.https.html @@ -0,0 +1,64 @@ + + +Receiving a message through PresentationConnection + + + + + +

Click the button below and select the available presentation display, to start the manual test.

+ + + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_send-manual.https.html b/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_send-manual.https.html new file mode 100644 index 0000000000..188f7e3fc1 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_send-manual.https.html @@ -0,0 +1,97 @@ + + +Sending a message through PresentationConnection + + + + + + + +

Click the button below and select the available presentation display, to start the manual test.

+ + + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_terminate-manual.https.html b/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_terminate-manual.https.html new file mode 100644 index 0000000000..6484e97c5a --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/PresentationConnection_terminate-manual.https.html @@ -0,0 +1,71 @@ + + +Terminating a presentation in a receiving browsing context + + + + + + + + +

Click the button below and select the available presentation display, to start the manual test.

+ + + + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/PresentationReceiver_create-manual.https.html b/testing/web-platform/tests/presentation-api/receiving-ua/PresentationReceiver_create-manual.https.html new file mode 100644 index 0000000000..96fc6f345d --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/PresentationReceiver_create-manual.https.html @@ -0,0 +1,272 @@ + + +Creating a receiving browsing context + + + + + + + +

+ Click the button below and select the available presentation display, to start the manual test. The test passes if a "PASS" result appears.
+ This test asks you to click the button twice, unless the test fails.
+ +

+ + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/cache.txt b/testing/web-platform/tests/presentation-api/receiving-ua/cache.txt new file mode 100644 index 0000000000..551e8ff210 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/cache.txt @@ -0,0 +1 @@ +Hello, Presentation API! \ No newline at end of file diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/common.js b/testing/web-platform/tests/presentation-api/receiving-ua/common.js new file mode 100644 index 0000000000..cbee5b4702 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/common.js @@ -0,0 +1,63 @@ +(window => { + // Both a controlling side and a receiving one must share the same Stash ID to + // transmit data from one to the other. On the other hand, due to polling mechanism + // which cleans up a stash, stashes in both controller-to-receiver direction + // and one for receiver-to-controller are necessary. + window.stashIds = { + toController: '0c382524-5738-4df0-837d-4f53ea8addc2', + toReceiver: 'a9618cd1-ca2b-4155-b7f6-630dce953c44' + } + + // handle a test result received from a receiving page + const parseValue = value => { + let r; + + // String + if (r = value.match(/^(\(string\)\s+)?"(.*)"$/)) + return r[2]; + // Object + else if (r = value.match(/^(\(object\)\s+)?object\s+"\[object\s+(.*)\]"$/)) + return window[r[2]].prototype; + // Number, boolean, null, undefined + else { + if (r = value.match(/^(\(\S+\)\s+)?(\S+)$/)) { + try { + return JSON.parse(r[2]); + } catch(e) { + return value; + } + } + else + return value; + } + }; + + window.parseResult = message => { + let r = message.match(/^(assert_.*):\s+(.*)$/); + if (r) { + const assertion = r[1]; + const body = r[2]; + let args; + switch (assertion) { + case 'assert_equals': + if (r = body.match(/^((.*)\s+)?expected\s+((\(\S*\)\s+)?(\S+|(\S+\s+)?\".*\"))\s+but\s+got\s+((\(\S*\)\s+)?(\S+|(\S+\s+)?\".*\"))$/)) + args = [parseValue(r[7]), parseValue(r[3]), r[2]]; + break; + case 'assert_true': + if (r = body.match(/^((.*)\s+)?expected\s+(true|false)\s+got\s+(\S+|(\S+\s+)?\".*\")$/)) + args = [parseValue(r[4]), r[2]]; + break; + case 'assert_unreached': + if (r = body.match(/^((.*)\s+)?Reached\s+unreachable\s+code$/)) + args = [r[2]]; + break; + } + if (args) { + window[assertion](args[0], args[1], args[2]); + return; + } + } + // default + assert_unreached('Test result received from a receiving user agent: ' + message + ': '); + }; +})(window); \ No newline at end of file diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/idlharness-manual.https.html b/testing/web-platform/tests/presentation-api/receiving-ua/idlharness-manual.https.html new file mode 100644 index 0000000000..c7bd7344d5 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/idlharness-manual.https.html @@ -0,0 +1,44 @@ + + +Presentation API IDL tests for Receiving User Agent + + + + + +

Click the button below and select the available presentation display, to start the manual test.

+ + + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/serviceworker.js b/testing/web-platform/tests/presentation-api/receiving-ua/serviceworker.js new file mode 100644 index 0000000000..ae50ad6498 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/serviceworker.js @@ -0,0 +1,15 @@ +self.addEventListener('install', () => { + // activate this service worker immediately + self.skipWaiting(); +}); + +self.addEventListener('activate', event => { + // let this service worker control window clients immediately + event.waitUntil(self.clients.claim()); +}); + +self.addEventListener('message', event => { + event.waitUntil(clients.matchAll().then(windows => { + event.ports[0].postMessage(windows.map(w => { return w.url; }).sort()); + })); +}); diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnectionList_onconnectionavailable_receiving-ua.html b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnectionList_onconnectionavailable_receiving-ua.html new file mode 100644 index 0000000000..74d8dfa0ed --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnectionList_onconnectionavailable_receiving-ua.html @@ -0,0 +1,92 @@ + + + +Monitoring incoming presentation connections + + + + + + + + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_onclose_receiving-ua.html b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_onclose_receiving-ua.html new file mode 100644 index 0000000000..7194c6f4d9 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_onclose_receiving-ua.html @@ -0,0 +1,89 @@ + + + +Closing a PresentationConnection + + + + + + + + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_onmessage_receiving-ua.html b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_onmessage_receiving-ua.html new file mode 100644 index 0000000000..0734a5570c --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_onmessage_receiving-ua.html @@ -0,0 +1,108 @@ + + +Receiving a message through PresentationConnection + + + + + + + + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_send_receiving-ua.html b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_send_receiving-ua.html new file mode 100644 index 0000000000..bc482e9dfd --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_send_receiving-ua.html @@ -0,0 +1,45 @@ + + + +Sending a message through PresentationConnection + + + + + + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_terminate_receiving-ua.html b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_terminate_receiving-ua.html new file mode 100644 index 0000000000..3a234aaa83 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationConnection_terminate_receiving-ua.html @@ -0,0 +1,23 @@ + + + +Terminating a presentation in a receiving browsing context + + + + + + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationReceiver_create_receiving-ua.html b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationReceiver_create_receiving-ua.html new file mode 100644 index 0000000000..53f7601442 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationReceiver_create_receiving-ua.html @@ -0,0 +1,328 @@ + + + +Creating a receiving browsing context + + + + + + + + + +

Checking : if you see this message, please wait for test to time out.

+do not navigate + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationReceiver_create_receiving-ua_child.html b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationReceiver_create_receiving-ua_child.html new file mode 100644 index 0000000000..2f67f7fac0 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationReceiver_create_receiving-ua_child.html @@ -0,0 +1,171 @@ + + + +Creating a receiving browsing context + + + + +

Checking : if you see this message, please wait for test to time out.

+ + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationReceiver_unreached_receiving-ua.html b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationReceiver_unreached_receiving-ua.html new file mode 100644 index 0000000000..2b2a8b315e --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/support/PresentationReceiver_unreached_receiving-ua.html @@ -0,0 +1,21 @@ + + + +Creating a receiving browsing context + + + + + + + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/support/idlharness_receiving-ua.html b/testing/web-platform/tests/presentation-api/receiving-ua/support/idlharness_receiving-ua.html new file mode 100644 index 0000000000..2d5a5b17f1 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/support/idlharness_receiving-ua.html @@ -0,0 +1,41 @@ + + +Presentation API IDL tests for Receiving User Agent + + + + + + + + + + + diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/support/iframe.html b/testing/web-platform/tests/presentation-api/receiving-ua/support/iframe.html new file mode 100644 index 0000000000..61f18b8912 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/support/iframe.html @@ -0,0 +1,22 @@ + + +Helper functions invoked by a nested browsing context + + + + \ No newline at end of file diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/support/serviceworker.js b/testing/web-platform/tests/presentation-api/receiving-ua/support/serviceworker.js new file mode 100644 index 0000000000..d2d4449ded --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/support/serviceworker.js @@ -0,0 +1,9 @@ +self.addEventListener('install', () => { + // activate this service worker immediately + self.skipWaiting(); +}); + +self.addEventListener('activate', event => { + // let this service worker control window clients immediately + event.waitUntil(self.clients.claim()); +}); diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/support/stash.js b/testing/web-platform/tests/presentation-api/receiving-ua/support/stash.js new file mode 100644 index 0000000000..eb63bb8623 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/support/stash.js @@ -0,0 +1,98 @@ +var Stash = function(inbound, outbound) { + this.stashPath = '/presentation-api/receiving-ua/support/stash.py?id='; + this.inbound = inbound; + this.outbound = outbound; +} + +// initialize a stash on wptserve +Stash.prototype.init = function() { + return Promise.all([ + fetch(this.stashPath + this.inbound).then(response => { + return response.text(); + }), + fetch(this.stashPath + this.outbound).then(response => { + return response.text(); + }) + ]); +} + +// upload a test result to a stash on wptserve +Stash.prototype.send = function(result) { + return fetch(this.stashPath + this.outbound, { + method: 'POST', + body: JSON.stringify({ type: 'data', data: result }) + }).then(response => { + return response.text(); + }).then(text => { + return text === 'ok' ? null : Promise.reject(); + }) +}; + +// upload a test result to a stash on wptserve via navigator.sendBeacon +Stash.prototype.sendBeacon = function(result) { + if ('sendBeacon' in navigator) { + navigator.sendBeacon(this.stashPath + this.outbound, JSON.stringify({ type: 'data', data: result })); + } + // Note: The following could be discarded, since XHR in synchronous mode is now being deprecated. + else { + return new Promise(resolve, reject => { + const xhr = new XMLHttpRequest(); + xhr.open('POST', this.stashPath + this.outbound, false); + xhr.send(JSON.stringify({ type: 'data', data: result })); + }); + } +}; + +// wait until a test result is uploaded to a stash on wptserve +Stash.prototype.receive = function() { + return new Promise((resolve, reject) => { + let intervalId; + const interval = 500; // msec + const polling = () => { + return fetch(this.stashPath + this.inbound).then(response => { + return response.text(); + }).then(text => { + if (text) { + try { + const json = JSON.parse(text); + if (json.type === 'data') + resolve(json.data); + else + reject(); + } catch(e) { + resolve(text); + } + clearInterval(intervalId); + } + }); + }; + intervalId = setInterval(polling, interval); + }); +}; + +// reset a stash on wptserve +Stash.prototype.stop = function() { + return Promise.all([ + fetch(this.stashPath + this.inbound).then(response => { + return response.text(); + }), + fetch(this.stashPath + this.outbound).then(response => { + return response.text(); + }) + ]).then(() => { + return Promise.all([ + fetch(this.stashPath + this.inbound, { + method: 'POST', + body: JSON.stringify({ type: 'stop' }) + }).then(response => { + return response.text(); + }), + fetch(this.stashPath + this.outbound, { + method: 'POST', + body: JSON.stringify({ type: 'stop' }) + }).then(response => { + return response.text(); + }) + ]); + }); +} diff --git a/testing/web-platform/tests/presentation-api/receiving-ua/support/stash.py b/testing/web-platform/tests/presentation-api/receiving-ua/support/stash.py new file mode 100644 index 0000000000..83653d365a --- /dev/null +++ b/testing/web-platform/tests/presentation-api/receiving-ua/support/stash.py @@ -0,0 +1,10 @@ +def main(request, response): + key = request.GET.first(b"id") + + if request.method == u"POST": + request.server.stash.put(key, request.body) + return b"ok" + else: + value = request.server.stash.take(key) + assert request.server.stash.take(key) is None + return value \ No newline at end of file -- cgit v1.2.3