From cff6bf3ab05deaf07c707d1ae09e167d2d46ed4f Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Wed, 28 Sep 2022 15:33:53 +1000 Subject: [PATCH 01/12] Remove set_permission, use bless() for transient activation --- screen-wake-lock/idlharness.https.window.js | 8 ++-- ...k-enabled-by-permissions-policy.https.html | 8 ++-- ...lf-origin-by-permissions-policy.https.html | 6 +-- .../wakelock-null-browsing-context.https.html | 28 ++++++++++++++ .../wakelock-onrelease.https.html | 37 +++++-------------- screen-wake-lock/wakelock-released.https.html | 2 +- .../wakelock-request-denied.https.html | 15 +++++--- 7 files changed, 59 insertions(+), 45 deletions(-) create mode 100644 screen-wake-lock/wakelock-null-browsing-context.https.html diff --git a/screen-wake-lock/idlharness.https.window.js b/screen-wake-lock/idlharness.https.window.js index 6509d9c70e2578..69e7eff5a94bcd 100644 --- a/screen-wake-lock/idlharness.https.window.js +++ b/screen-wake-lock/idlharness.https.window.js @@ -12,16 +12,14 @@ idl_test( ['screen-wake-lock'], ['dom', 'html'], async idl_array => { + await test_driver.bless("screen wake lock"); + self.sentinel = await navigator.wakeLock.request('screen'); + await self.sentinel.release(); 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/screen-wake-lock/wakelock-enabled-by-permissions-policy.https.html b/screen-wake-lock/wakelock-enabled-by-permissions-policy.https.html index cc9106967ef522..d59226806196f2 100644 --- a/screen-wake-lock/wakelock-enabled-by-permissions-policy.https.html +++ b/screen-wake-lock/wakelock-enabled-by-permissions-policy.https.html @@ -6,6 +6,7 @@ + diff --git a/screen-wake-lock/wakelock-enabled-on-self-origin-by-permissions-policy.https.html b/screen-wake-lock/wakelock-enabled-on-self-origin-by-permissions-policy.https.html index 5b90b4f4ce0ddd..7fdc802e789acc 100644 --- a/screen-wake-lock/wakelock-enabled-on-self-origin-by-permissions-policy.https.html +++ b/screen-wake-lock/wakelock-enabled-on-self-origin-by-permissions-policy.https.html @@ -18,9 +18,9 @@ const header = 'Permissions-Policy header "screen-wake-lock=self"'; promise_test(async t => { - await test_driver.set_permission( - { name: 'screen-wake-lock' }, 'granted'); - await navigator.wakeLock.request('screen').then(lock => lock.release()); + await test_driver.bless("screen wake lock"); + const lock = await navigator.wakeLock.request('screen'); + await lock.release(); }, `${header} allows the top-level document.`); async_test(t => { diff --git a/screen-wake-lock/wakelock-null-browsing-context.https.html b/screen-wake-lock/wakelock-null-browsing-context.https.html new file mode 100644 index 00000000000000..10f9619b6b3c4e --- /dev/null +++ b/screen-wake-lock/wakelock-null-browsing-context.https.html @@ -0,0 +1,28 @@ + + + + + + + + + diff --git a/screen-wake-lock/wakelock-onrelease.https.html b/screen-wake-lock/wakelock-onrelease.https.html index fb071b3763d6e1..f29931d6af07bb 100644 --- a/screen-wake-lock/wakelock-onrelease.https.html +++ b/screen-wake-lock/wakelock-onrelease.https.html @@ -6,34 +6,17 @@ diff --git a/screen-wake-lock/wakelock-released.https.html b/screen-wake-lock/wakelock-released.https.html index 8d351e3e682522..53a4599d80c5a8 100644 --- a/screen-wake-lock/wakelock-released.https.html +++ b/screen-wake-lock/wakelock-released.https.html @@ -6,7 +6,7 @@ + From 0ffdb533063d6e99a9b1d9d0be6cb3ef05ef8c98 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Wed, 28 Sep 2022 15:47:06 +1000 Subject: [PATCH 02/12] Rename wakelock-request-denied to wakelock-request-transient-activation --- ...ttps.html => wakelock-request-transient-activation.https.html} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename screen-wake-lock/{wakelock-request-denied.https.html => wakelock-request-transient-activation.https.html} (100%) diff --git a/screen-wake-lock/wakelock-request-denied.https.html b/screen-wake-lock/wakelock-request-transient-activation.https.html similarity index 100% rename from screen-wake-lock/wakelock-request-denied.https.html rename to screen-wake-lock/wakelock-request-transient-activation.https.html From 673b3a29354c48cba86af9dc253e36855d0955e0 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Wed, 28 Sep 2022 16:28:25 +1000 Subject: [PATCH 03/12] Remove/rename files --- .../wakelock-screen-type-on-worker.https.worker.js | 8 -------- ...lock-type.https.window.js => wakelock-type.https.html} | 0 2 files changed, 8 deletions(-) delete mode 100644 screen-wake-lock/wakelock-screen-type-on-worker.https.worker.js rename screen-wake-lock/{wakelock-type.https.window.js => wakelock-type.https.html} (100%) diff --git a/screen-wake-lock/wakelock-screen-type-on-worker.https.worker.js b/screen-wake-lock/wakelock-screen-type-on-worker.https.worker.js deleted file mode 100644 index 0201294e2365ab..00000000000000 --- a/screen-wake-lock/wakelock-screen-type-on-worker.https.worker.js +++ /dev/null @@ -1,8 +0,0 @@ -//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/screen-wake-lock/wakelock-type.https.window.js b/screen-wake-lock/wakelock-type.https.html similarity index 100% rename from screen-wake-lock/wakelock-type.https.window.js rename to screen-wake-lock/wakelock-type.https.html From 4c0dcaa34bcceb4e619afa747f57e0ec070533ee Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Wed, 28 Sep 2022 16:43:20 +1000 Subject: [PATCH 04/12] convert wakelock-insecure-context to normal test --- screen-wake-lock/wakelock-insecure-context.any.js | 5 ----- screen-wake-lock/wakelock-insecure-context.http.html | 9 +++++++++ 2 files changed, 9 insertions(+), 5 deletions(-) delete mode 100644 screen-wake-lock/wakelock-insecure-context.any.js create mode 100644 screen-wake-lock/wakelock-insecure-context.http.html diff --git a/screen-wake-lock/wakelock-insecure-context.any.js b/screen-wake-lock/wakelock-insecure-context.any.js deleted file mode 100644 index f32cc3c354354f..00000000000000 --- a/screen-wake-lock/wakelock-insecure-context.any.js +++ /dev/null @@ -1,5 +0,0 @@ -//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/screen-wake-lock/wakelock-insecure-context.http.html b/screen-wake-lock/wakelock-insecure-context.http.html new file mode 100644 index 00000000000000..e9e77b499ee91f --- /dev/null +++ b/screen-wake-lock/wakelock-insecure-context.http.html @@ -0,0 +1,9 @@ + + + + + From 351663bbd86c7620ef7d9e604cbf3f7e02a474ab Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Wed, 28 Sep 2022 16:44:49 +1000 Subject: [PATCH 05/12] convert wakelock-type.https.html to normal test --- screen-wake-lock/wakelock-type.https.html | 41 ++++++++++++----------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/screen-wake-lock/wakelock-type.https.html b/screen-wake-lock/wakelock-type.https.html index 5008064684e215..447f316b25fd89 100644 --- a/screen-wake-lock/wakelock-type.https.html +++ b/screen-wake-lock/wakelock-type.https.html @@ -1,21 +1,24 @@ -// 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'); - + + + + + + From 527e9a13891e9a6d333f3006cdbb82b19db7670e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 29 Sep 2022 09:59:09 +1000 Subject: [PATCH 06/12] Update screen-wake-lock/wakelock-type.https.html --- screen-wake-lock/wakelock-type.https.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screen-wake-lock/wakelock-type.https.html b/screen-wake-lock/wakelock-type.https.html index 447f316b25fd89..b13992608b7671 100644 --- a/screen-wake-lock/wakelock-type.https.html +++ b/screen-wake-lock/wakelock-type.https.html @@ -13,7 +13,7 @@ promise_test(async (t) => { const invalidTypes = ["invalid", null, 123, {}, "", true]; - for (const type of invalidTypes) { + for (const invalidType of invalidTypes) { await promise_rejects_js( t, TypeError, From 18b0e31c5d7947e70438d8cf82ca5b02b0949474 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Thu, 29 Sep 2022 10:10:06 +1000 Subject: [PATCH 07/12] Rewrite event order tests --- .../wakelock-onrelease.https.html | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/screen-wake-lock/wakelock-onrelease.https.html b/screen-wake-lock/wakelock-onrelease.https.html index f29931d6af07bb..3f4ef1388685a1 100644 --- a/screen-wake-lock/wakelock-onrelease.https.html +++ b/screen-wake-lock/wakelock-onrelease.https.html @@ -19,4 +19,25 @@ assert_false(ev.bubbles); assert_false(ev.cancelable); }, "Test onreleased event firing and attributes"); + +promise_test(async ()=>{ + await test_driver.bless("screen wake lock"); + const lock = await navigator.wakeLock.request("screen"); + let result = ""; + const releaseEventPromise = new Promise(resolve => { + lock.onrelease = ()=>{ + result += "onrelease event fired"; + resolve(); + } + }); + + const releasePromise = lock.release().then(()=>{ + result += " then release promise resolved"; + }); + + await Promise.all([releaseEventPromise, releasePromise]); + assert_equals(result, "onrelease event fired then release promise resolved"); +}, "Ensure onreleased is called before WakeLockSentinel.release() resolves"); + + From 605d19dd1a145911fe781485d9f98ebdbd25eb9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 29 Sep 2022 10:59:06 +1000 Subject: [PATCH 08/12] Update screen-wake-lock/wakelock-onrelease.https.html --- screen-wake-lock/wakelock-onrelease.https.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screen-wake-lock/wakelock-onrelease.https.html b/screen-wake-lock/wakelock-onrelease.https.html index 3f4ef1388685a1..59e4fcffa57792 100644 --- a/screen-wake-lock/wakelock-onrelease.https.html +++ b/screen-wake-lock/wakelock-onrelease.https.html @@ -31,7 +31,7 @@ } }); - const releasePromise = lock.release().then(()=>{ + const releasePromise = lock.release().then(() => { result += " then release promise resolved"; }); From 4a939424c72ee943a22a5d6df3a21ecee3c9acdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 29 Sep 2022 11:00:25 +1000 Subject: [PATCH 09/12] Update screen-wake-lock/wakelock-onrelease.https.html --- screen-wake-lock/wakelock-onrelease.https.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screen-wake-lock/wakelock-onrelease.https.html b/screen-wake-lock/wakelock-onrelease.https.html index 59e4fcffa57792..3b84eed571ec6a 100644 --- a/screen-wake-lock/wakelock-onrelease.https.html +++ b/screen-wake-lock/wakelock-onrelease.https.html @@ -37,7 +37,7 @@ await Promise.all([releaseEventPromise, releasePromise]); assert_equals(result, "onrelease event fired then release promise resolved"); -}, "Ensure onreleased is called before WakeLockSentinel.release() resolves"); +}, "Ensure onreleased is called before WakeLockSentinel.release() resolves"); From 1df871fc1c4030fa13012bed14910f9998974cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 29 Sep 2022 11:04:49 +1000 Subject: [PATCH 10/12] Update screen-wake-lock/wakelock-onrelease.https.html --- screen-wake-lock/wakelock-onrelease.https.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screen-wake-lock/wakelock-onrelease.https.html b/screen-wake-lock/wakelock-onrelease.https.html index 3b84eed571ec6a..1346d5d3b401c9 100644 --- a/screen-wake-lock/wakelock-onrelease.https.html +++ b/screen-wake-lock/wakelock-onrelease.https.html @@ -25,7 +25,7 @@ const lock = await navigator.wakeLock.request("screen"); let result = ""; const releaseEventPromise = new Promise(resolve => { - lock.onrelease = ()=>{ + lock.onrelease = () => { result += "onrelease event fired"; resolve(); } From 26755a0326aae531286fe7df50db9e3d4da90a9a Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Thu, 29 Sep 2022 15:39:50 +1000 Subject: [PATCH 11/12] Remove transient activation test --- ...ck-request-transient-activation.https.html | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 screen-wake-lock/wakelock-request-transient-activation.https.html diff --git a/screen-wake-lock/wakelock-request-transient-activation.https.html b/screen-wake-lock/wakelock-request-transient-activation.https.html deleted file mode 100644 index bfd2df1599fca8..00000000000000 --- a/screen-wake-lock/wakelock-request-transient-activation.https.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - From fc80e7157c927ee844e9b6964966aeef3737e19a Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Tue, 4 Oct 2022 10:45:07 +1100 Subject: [PATCH 12/12] Check NotAllowedError --- .../wakelock-null-browsing-context.https.html | 28 ------------------- .../wakelock-request-denied.https.html | 19 +++++++++++++ 2 files changed, 19 insertions(+), 28 deletions(-) delete mode 100644 screen-wake-lock/wakelock-null-browsing-context.https.html create mode 100644 screen-wake-lock/wakelock-request-denied.https.html diff --git a/screen-wake-lock/wakelock-null-browsing-context.https.html b/screen-wake-lock/wakelock-null-browsing-context.https.html deleted file mode 100644 index 10f9619b6b3c4e..00000000000000 --- a/screen-wake-lock/wakelock-null-browsing-context.https.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - diff --git a/screen-wake-lock/wakelock-request-denied.https.html b/screen-wake-lock/wakelock-request-denied.https.html new file mode 100644 index 00000000000000..96556d26000015 --- /dev/null +++ b/screen-wake-lock/wakelock-request-denied.https.html @@ -0,0 +1,19 @@ + + + + + + + + + + +