diff --git a/testing/web-platform/tests/interfaces/wake-lock.idl b/testing/web-platform/tests/interfaces/wake-lock.idl index ac8b70c157a2..89da0b8dc829 100644 --- a/testing/web-platform/tests/interfaces/wake-lock.idl +++ b/testing/web-platform/tests/interfaces/wake-lock.idl @@ -5,17 +5,14 @@ enum WakeLockType { "screen", "system" }; -partial interface Navigator { - [SecureContext] Promise getWakeLock(WakeLockType type); -}; - -[SecureContext, Exposed=Window] interface WakeLock : EventTarget { +[Constructor(WakeLockType type), SecureContext, Exposed=(DedicatedWorker, Window)] +interface WakeLock : EventTarget { readonly attribute WakeLockType type; readonly attribute boolean active; attribute EventHandler onactivechange; - WakeLockRequest createRequest(); + Promise request(optional WakeLockRequestOptions options); }; -[SecureContext, Exposed=Window] interface WakeLockRequest { - void cancel(); +dictionary WakeLockRequestOptions { + AbortSignal? signal; }; diff --git a/testing/web-platform/tests/wake-lock/idlharness.https.any.js b/testing/web-platform/tests/wake-lock/idlharness.https.any.js new file mode 100644 index 000000000000..5e3ae75064c5 --- /dev/null +++ b/testing/web-platform/tests/wake-lock/idlharness.https.any.js @@ -0,0 +1,16 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js + +// https://w3c.github.io/wake-lock/ + +'use strict'; + +idl_test( + ['wake-lock'], + ['dom', 'html'], + idl_array => { + idl_array.add_objects({ + WakeLock: ['new WakeLock("screen")'] + }); + } +); diff --git a/testing/web-platform/tests/wake-lock/idlharness.https.window.js b/testing/web-platform/tests/wake-lock/idlharness.https.window.js deleted file mode 100644 index 21d559a7a26a..000000000000 --- a/testing/web-platform/tests/wake-lock/idlharness.https.window.js +++ /dev/null @@ -1,31 +0,0 @@ -// META: script=/resources/WebIDLParser.js -// META: script=/resources/idlharness.js - -// https://w3c.github.io/wake-lock/ - -'use strict'; - -promise_test(async () => { - const srcs = ['wake-lock', 'dom', 'html']; - const [wakelock, dom, html] = await Promise.all( - srcs.map(i => fetch(`/interfaces/${i}.idl`).then(r => r.text()))); - - const idl_array = new IdlArray(); - idl_array.add_idls(wakelock); - idl_array.add_dependency_idls(dom); - idl_array.add_dependency_idls(html); - - try { - window.wakelock = await navigator.getWakeLock("screen"); - window.request = window.wakelock.createRequest(); - } catch (e) { - // Surfaced in idlharness.js's test_object below. - } - - idl_array.add_objects({ - Navigator: ['navigator'], - WakeLock: ['wakelock'], - WakeLockRequest: ['request'] - }); - idl_array.test(); -}, 'Test IDL implementation of WakeLock API');