From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../web-platform/tests/screen-wake-lock/META.yml | 6 ++ .../screen-wake-lock/chrome-bug-1348019.https.html | 35 +++++++++ .../screen-wake-lock/idlharness.https.window.js | 27 +++++++ .../tests/screen-wake-lock/resources/page1.html | 1 + .../tests/screen-wake-lock/resources/page2.html | 1 + .../wakelock-active-document.https.window.js | 87 ++++++++++++++++++++++ ...elock-disabled-by-permissions-policy.https.html | 41 ++++++++++ ...sabled-by-permissions-policy.https.html.headers | 1 + .../wakelock-document-hidden.https.html | 49 ++++++++++++ ...ns-policy-attribute-redirect-on-load.https.html | 39 ++++++++++ ...bled-by-permissions-policy-attribute.https.html | 37 +++++++++ ...kelock-enabled-by-permissions-policy.https.html | 47 ++++++++++++ ...nabled-by-permissions-policy.https.html.headers | 1 + ...on-self-origin-by-permissions-policy.https.html | 44 +++++++++++ ...origin-by-permissions-policy.https.html.headers | 1 + .../wakelock-insecure-context.any.js | 5 ++ .../screen-wake-lock/wakelock-onrelease.https.html | 54 ++++++++++++++ .../screen-wake-lock/wakelock-released.https.html | 20 +++++ .../wakelock-request-denied.https.html | 17 +++++ .../wakelock-screen-type-on-worker.https.worker.js | 8 ++ .../wakelock-supported-by-permissions-policy.html | 11 +++ .../screen-wake-lock/wakelock-type.https.window.js | 21 ++++++ .../wakelockpermissiondescriptor.https.html | 16 ++++ 23 files changed, 569 insertions(+) create mode 100644 testing/web-platform/tests/screen-wake-lock/META.yml create mode 100644 testing/web-platform/tests/screen-wake-lock/chrome-bug-1348019.https.html create mode 100644 testing/web-platform/tests/screen-wake-lock/idlharness.https.window.js create mode 100644 testing/web-platform/tests/screen-wake-lock/resources/page1.html create mode 100644 testing/web-platform/tests/screen-wake-lock/resources/page2.html create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-active-document.https.window.js create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-disabled-by-permissions-policy.https.html create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-disabled-by-permissions-policy.https.html.headers create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-document-hidden.https.html create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy-attribute-redirect-on-load.https.html create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy-attribute.https.html create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy.https.html create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy.https.html.headers create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-enabled-on-self-origin-by-permissions-policy.https.html create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-enabled-on-self-origin-by-permissions-policy.https.html.headers create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-insecure-context.any.js create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-onrelease.https.html create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-released.https.html create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-request-denied.https.html create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-screen-type-on-worker.https.worker.js create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-supported-by-permissions-policy.html create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelock-type.https.window.js create mode 100644 testing/web-platform/tests/screen-wake-lock/wakelockpermissiondescriptor.https.html (limited to 'testing/web-platform/tests/screen-wake-lock') diff --git a/testing/web-platform/tests/screen-wake-lock/META.yml b/testing/web-platform/tests/screen-wake-lock/META.yml new file mode 100644 index 0000000000..b311993d82 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/META.yml @@ -0,0 +1,6 @@ +spec: https://w3c.github.io/screen-wake-lock/ +suggested_reviewers: + - Honry + - marcoscaceres + - rakuco + - reillyeon diff --git a/testing/web-platform/tests/screen-wake-lock/chrome-bug-1348019.https.html b/testing/web-platform/tests/screen-wake-lock/chrome-bug-1348019.https.html new file mode 100644 index 0000000000..7c9909581c --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/chrome-bug-1348019.https.html @@ -0,0 +1,35 @@ + + + + +Releasing wake locks upon visibility change does not cause crash if an iframe is appended in event listener + + + + + + + + + diff --git a/testing/web-platform/tests/screen-wake-lock/idlharness.https.window.js b/testing/web-platform/tests/screen-wake-lock/idlharness.https.window.js new file mode 100644 index 0000000000..6509d9c70e --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/idlharness.https.window.js @@ -0,0 +1,27 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js +// META: timeout=long + +// https://w3c.github.io/screen-wake-lock/ + +'use strict'; + +idl_test( + ['screen-wake-lock'], + ['dom', 'html'], + async idl_array => { + idl_array.add_objects({ Navigator: ['navigator'] }); + + idl_array.add_objects({ + WakeLock: ['navigator.wakeLock'], + WakeLockSentinel: ['sentinel'], + }); + + await test_driver.set_permission( + { name: 'screen-wake-lock' }, 'granted'); + self.sentinel = await navigator.wakeLock.request('screen'); + self.sentinel.release(); + } +); diff --git a/testing/web-platform/tests/screen-wake-lock/resources/page1.html b/testing/web-platform/tests/screen-wake-lock/resources/page1.html new file mode 100644 index 0000000000..7fc080d380 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/resources/page1.html @@ -0,0 +1 @@ + diff --git a/testing/web-platform/tests/screen-wake-lock/resources/page2.html b/testing/web-platform/tests/screen-wake-lock/resources/page2.html new file mode 100644 index 0000000000..7fc080d380 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/resources/page2.html @@ -0,0 +1 @@ + diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-active-document.https.window.js b/testing/web-platform/tests/screen-wake-lock/wakelock-active-document.https.window.js new file mode 100644 index 0000000000..724ce09196 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-active-document.https.window.js @@ -0,0 +1,87 @@ +function getWakeLockObject(iframe, url) { + return new Promise(resolve => { + iframe.addEventListener( + "load", + () => { + const { wakeLock } = iframe.contentWindow.navigator; + resolve(wakeLock); + }, + { once: true } + ); + iframe.src = url; + }); +} + +promise_test(async t => { + const iframe = document.createElement("iframe"); + document.body.appendChild(iframe); + // We first got to page1.html, grab a WakeLock object. + const wakeLock1 = await getWakeLockObject( + iframe, + "/screen-wake-lock/resources/page1.html" + ); + // Save the DOMException of page1.html before navigating away. + const frameDOMException1 = iframe.contentWindow.DOMException; + // We navigate the iframe again, putting wakeLock1's document into an inactive state. + const wakeLock2 = await getWakeLockObject( + iframe, + "/screen-wake-lock/resources/page2.html" + ); + // Now, wakeLock1's relevant global object's document is no longer active. + // So, call .request(), and make sure it rejects appropriately. + await promise_rejects_dom( + t, + "NotAllowedError", + frameDOMException1, + wakeLock1.request('screen'), + "Inactive document, so must throw NotAllowedError" + ); + // We are done, so clean up. + iframe.remove(); +}, "navigator.wakeLock.request() aborts if the document is not active."); + +promise_test(async t => { + // We nest two iframes and wait for them to load. + const outerIframe = document.createElement("iframe"); + document.body.appendChild(outerIframe); + // Load the outer iframe (we don't care about the awaited request) + await getWakeLockObject( + outerIframe, + "/screen-wake-lock/resources/page1.html" + ); + + // Now we create the inner iframe + const innerIframe = outerIframe.contentDocument.createElement("iframe"); + + // nest them + outerIframe.contentDocument.body.appendChild(innerIframe); + + // load innerIframe, and get the WakeLock instance + const wakeLock = await getWakeLockObject( + innerIframe, + "/screen-wake-lock/resources/page2.html" + ); + // Save DOMException from innerIframe before navigating away. + const innerIframeDOMException = innerIframe.contentWindow.DOMException; + + // Navigate the outer iframe to a new location. + // Wait for the load event to fire. + await new Promise(resolve => { + outerIframe.addEventListener("load", resolve); + outerIframe.src = "/screen-wake-lock/resources/page2.html"; + }); + + // Now, request's relevant global object's document is still active + // (it is the active document of the inner iframe), but is not fully active + // (since the parent of the inner iframe is itself no longer active). + // So, call request.show() and make sure it rejects appropriately. + await promise_rejects_dom( + t, + "NotAllowedError", + innerIframeDOMException, + wakeLock.request('screen'), + "Active, but not fully active, so must throw NotAllowedError" + ); + // We are done, so clean up. + outerIframe.remove(); +}, "navigator.wakeLock.request() aborts if the document is active, but not fully active."); diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-disabled-by-permissions-policy.https.html b/testing/web-platform/tests/screen-wake-lock/wakelock-disabled-by-permissions-policy.https.html new file mode 100644 index 0000000000..354b0a5e15 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-disabled-by-permissions-policy.https.html @@ -0,0 +1,41 @@ + + + + + + + + + + diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-disabled-by-permissions-policy.https.html.headers b/testing/web-platform/tests/screen-wake-lock/wakelock-disabled-by-permissions-policy.https.html.headers new file mode 100644 index 0000000000..66f07f4c1c --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-disabled-by-permissions-policy.https.html.headers @@ -0,0 +1 @@ +Permissions-Policy: screen-wake-lock=() diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-document-hidden.https.html b/testing/web-platform/tests/screen-wake-lock/wakelock-document-hidden.https.html new file mode 100644 index 0000000000..c8c9712bdd --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-document-hidden.https.html @@ -0,0 +1,49 @@ + + +Screen wake locks respect page visibility changes + + + + + + + + + + diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy-attribute-redirect-on-load.https.html b/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy-attribute-redirect-on-load.https.html new file mode 100644 index 0000000000..8898a571e8 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy-attribute-redirect-on-load.https.html @@ -0,0 +1,39 @@ + + + + + + + + + + diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy-attribute.https.html b/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy-attribute.https.html new file mode 100644 index 0000000000..ea3ebf2449 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy-attribute.https.html @@ -0,0 +1,37 @@ + + + + + + + + + + diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy.https.html b/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy.https.html new file mode 100644 index 0000000000..cc9106967e --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy.https.html @@ -0,0 +1,47 @@ + + + + + + + + + + diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy.https.html.headers b/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy.https.html.headers new file mode 100644 index 0000000000..ea7d848e74 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy.https.html.headers @@ -0,0 +1 @@ +Permissions-Policy: screen-wake-lock=* diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-on-self-origin-by-permissions-policy.https.html b/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-on-self-origin-by-permissions-policy.https.html new file mode 100644 index 0000000000..5b90b4f4ce --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-on-self-origin-by-permissions-policy.https.html @@ -0,0 +1,44 @@ + + + + + + + + + + + diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-on-self-origin-by-permissions-policy.https.html.headers b/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-on-self-origin-by-permissions-policy.https.html.headers new file mode 100644 index 0000000000..9849d6b89b --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-enabled-on-self-origin-by-permissions-policy.https.html.headers @@ -0,0 +1 @@ +Permissions-Policy: screen-wake-lock=self diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-insecure-context.any.js b/testing/web-platform/tests/screen-wake-lock/wakelock-insecure-context.any.js new file mode 100644 index 0000000000..f32cc3c354 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-insecure-context.any.js @@ -0,0 +1,5 @@ +//META: title=Wake Lock API is not exposed in an insecure context + +test(() => { + assert_false("WakeLock" in self, "'WakeLock' must not be exposed"); +}, "Wake Lock API is not exposed in an insecure context"); diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-onrelease.https.html b/testing/web-platform/tests/screen-wake-lock/wakelock-onrelease.https.html new file mode 100644 index 0000000000..896748411b --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-onrelease.https.html @@ -0,0 +1,54 @@ + + + + + + + diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-released.https.html b/testing/web-platform/tests/screen-wake-lock/wakelock-released.https.html new file mode 100644 index 0000000000..8d351e3e68 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-released.https.html @@ -0,0 +1,20 @@ + + + + + + + diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-request-denied.https.html b/testing/web-platform/tests/screen-wake-lock/wakelock-request-denied.https.html new file mode 100644 index 0000000000..f3fede6e10 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-request-denied.https.html @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-screen-type-on-worker.https.worker.js b/testing/web-platform/tests/screen-wake-lock/wakelock-screen-type-on-worker.https.worker.js new file mode 100644 index 0000000000..0201294e23 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-screen-type-on-worker.https.worker.js @@ -0,0 +1,8 @@ +//META: title=Screen wake lock should not be allowed in dedicated worker +importScripts("/resources/testharness.js"); + +promise_test(t => { + return promise_rejects_dom(t, "NotAllowedError", navigator.wakeLock.request('screen')); +}, "Screen wake lock should not be allowed in dedicated worker"); + +done(); diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-supported-by-permissions-policy.html b/testing/web-platform/tests/screen-wake-lock/wakelock-supported-by-permissions-policy.html new file mode 100644 index 0000000000..cc0bb963b1 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-supported-by-permissions-policy.html @@ -0,0 +1,11 @@ + +Test that screen-wake-lock is advertised in the feature list + + + + + diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-type.https.window.js b/testing/web-platform/tests/screen-wake-lock/wakelock-type.https.window.js new file mode 100644 index 0000000000..5008064684 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelock-type.https.window.js @@ -0,0 +1,21 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js + +promise_test(async t => { + await test_driver.set_permission( + {name: 'screen-wake-lock'}, 'granted'); + + const lock = await navigator.wakeLock.request(); + t.add_cleanup(() => { + lock.release(); + }); + assert_equals(lock.type, 'screen'); +}, '\'type\' parameter in WakeLock.request() defaults to \'screen\''); + +promise_test(t => { + const invalidTypes = ['invalid', null, 123, {}, '', true]; + return Promise.all(invalidTypes.map(invalidType => { + return promise_rejects_js( + t, TypeError, navigator.wakeLock.request(invalidType)); + })); +}, '\'TypeError\' is thrown when set an invalid wake lock type'); diff --git a/testing/web-platform/tests/screen-wake-lock/wakelockpermissiondescriptor.https.html b/testing/web-platform/tests/screen-wake-lock/wakelockpermissiondescriptor.https.html new file mode 100644 index 0000000000..252aa3ce28 --- /dev/null +++ b/testing/web-platform/tests/screen-wake-lock/wakelockpermissiondescriptor.https.html @@ -0,0 +1,16 @@ + + + + + + + -- cgit v1.2.3