Bug 1636000 [wpt PR 23447] - [idle] Merge IdleState attributes into IdleDetector, a=testonly
authorReilly Grant <reillyg@chromium.org>
Wed, 13 May 2020 09:49:31 +0000
changeset 531172 c48fdd11379deeb353691ccac0ac7cf681e5484f
parent 531171 06b070586f340407c4911bc70e962f99150b53a0
child 531173 baf4094cc5e5775e7048b2636e7143ef110dead6
push id37435
push userapavel@mozilla.com
push dateWed, 20 May 2020 15:28:23 +0000
treeherdermozilla-central@5415da14ec9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1636000, 23447, 878979, 2186655, 767107
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1636000 [wpt PR 23447] - [idle] Merge IdleState attributes into IdleDetector, a=testonly Automatic update from web-platform-tests [idle] Merge IdleState attributes into IdleDetector The IdleState interface adds unnecessary overhead (code size and memory usage). These attributes can be added directly to the IdleDetector interface. Explainer PR: https://github.com/samuelgoto/idle-detection/pull/22 Bug: 878979 Change-Id: Ic92f5fff0ee540d640dc009d391a60c372490bfc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2186655 Commit-Queue: Reilly Grant <reillyg@chromium.org> Auto-Submit: Reilly Grant <reillyg@chromium.org> Reviewed-by: Kentaro Hara <haraken@chromium.org> Reviewed-by: Ayu Ishii <ayui@chromium.org> Cr-Commit-Position: refs/heads/master@{#767107} -- wpt-commits: 3a7b40eb73bf5359adf0d378b71d36488885057f wpt-pr: 23447
testing/web-platform/tests/idle-detection/basics.tentative.https.window.js
testing/web-platform/tests/idle-detection/idle-detection.idl
testing/web-platform/tests/idle-detection/idle-permission.tentative.https.window.js
testing/web-platform/tests/idle-detection/idlharness.https.window.js
testing/web-platform/tests/idle-detection/interceptor.https.html
testing/web-platform/tests/idle-detection/resources/idlharness-worker.js
--- a/testing/web-platform/tests/idle-detection/basics.tentative.https.window.js
+++ b/testing/web-platform/tests/idle-detection/basics.tentative.https.window.js
@@ -4,27 +4,27 @@
 
 'use strict';
 
 promise_setup(async t => {
   await test_driver.set_permission({ name: 'notifications' }, 'granted', false);
 })
 
 promise_test(async t => {
-  let status = new IdleDetector();
-  let watcher = new EventWatcher(t, status, ["change"]);
+  let detector = new IdleDetector();
+  let watcher = new EventWatcher(t, detector, ["change"]);
   let initial_state = watcher.wait_for("change");
 
-  await status.start();
+  await detector.start();
   await initial_state;
 
-  assert_true(['active', 'idle'].includes(status.state.user),
-                'status has a valid user state');
-  assert_true(['locked', 'unlocked'].includes(status.state.screen),
-                'status has a valid screen state');
+  assert_true(['active', 'idle'].includes(detector.userState),
+                'has a valid user state');
+  assert_true(['locked', 'unlocked'].includes(detector.screenState),
+                'has a valid screen state');
 }, 'start() basics');
 
 promise_test(async t => {
   let used = false;
 
   const detector = new IdleDetector();
   detector.start({
     get threshold() {
--- a/testing/web-platform/tests/idle-detection/idle-detection.idl
+++ b/testing/web-platform/tests/idle-detection/idle-detection.idl
@@ -1,32 +1,25 @@
 dictionary IdleOptions {
   [EnforceRange] unsigned long threshold;
   AbortSignal signal;
 };
 
-[
-  SecureContext,
-  Exposed=(Window,Worker)
-] interface IdleDetector : EventTarget {
-  constructor();
-  readonly attribute IdleState state;
-  attribute EventHandler onchange;
-  Promise<any> start(optional IdleOptions options = {});
-};
-
-[
-  SecureContext,
-  Exposed=(Window,Worker)
-] interface IdleState {
-  readonly attribute UserIdleState user;
-  readonly attribute ScreenIdleState screen;
-};
-
 enum UserIdleState {
     "active",
     "idle"
 };
 
 enum ScreenIdleState {
     "locked",
     "unlocked"
 };
+
+[
+  SecureContext,
+  Exposed=(Window,Worker)
+] interface IdleDetector : EventTarget {
+  constructor();
+  readonly attribute UserIdleState? userState;
+  readonly attribute ScreenIdleState? screenState;
+  attribute EventHandler onchange;
+  Promise<any> start(optional IdleOptions options = {});
+};
--- a/testing/web-platform/tests/idle-detection/idle-permission.tentative.https.window.js
+++ b/testing/web-platform/tests/idle-detection/idle-permission.tentative.https.window.js
@@ -1,24 +1,24 @@
 // META: script=/resources/testdriver.js
 // META: script=/resources/testdriver-vendor.js
 'use strict';
 
 promise_test(async t => {
     await test_driver.set_permission(
         { name: 'notifications' }, 'denied', false);
 
-    let status = new IdleDetector();
-    await promise_rejects_dom(t, 'NotAllowedError', status.start());
+    let detector = new IdleDetector();
+    await promise_rejects_dom(t, 'NotAllowedError', detector.start());
 }, "Deny notifications permission should work.");
 
 promise_test(async t => {
     await test_driver.set_permission(
         { name: 'notifications' }, 'granted', false);
 
-    let status = new IdleDetector();
-    await status.start();
+    let detector = new IdleDetector();
+    await detector.start();
 
-    assert_true(['active', 'idle'].includes(status.state.user),
-                  'status has a valid user state');
-    assert_true(['locked', 'unlocked'].includes(status.state.screen),
-                  'status has a valid screen state');
+    assert_true(['active', 'idle'].includes(detector.userState),
+                  'has a valid user state');
+    assert_true(['locked', 'unlocked'].includes(detector.screenState),
+                  'has a valid screen state');
 }, "Grant notifications permission should work.");
--- a/testing/web-platform/tests/idle-detection/idlharness.https.window.js
+++ b/testing/web-platform/tests/idle-detection/idlharness.https.window.js
@@ -26,13 +26,12 @@ promise_test(async (t) => {
   self.idle = new IdleDetector();
   let watcher = new EventWatcher(t, self.idle, ["change"]);
   let initial_state = watcher.wait_for("change");
   await self.idle.start();
   await initial_state;
 
   idl_array.add_objects({
     IdleDetector: ['idle'],
-    IdleState: ['idle.state']
   });
 
   idl_array.test();
 }, 'Test IDL implementation of Idle Detection API');
--- a/testing/web-platform/tests/idle-detection/interceptor.https.html
+++ b/testing/web-platform/tests/idle-detection/interceptor.https.html
@@ -32,18 +32,18 @@ promise_test(async t => {
   const controller = new AbortController();
   const detector = new IdleDetector();
   const watcher = new EventWatcher(t, detector, ["change"]);
   const initial_state = watcher.wait_for("change");
 
   await detector.start({ signal: controller.signal });
   await initial_state;
 
-  assert_equals(detector.state.user, "active");
-  assert_equals(detector.state.screen, "locked");
+  assert_equals(detector.userState, "active");
+  assert_equals(detector.screenState, "locked");
 
   controller.abort();
 }, 'start()');
 
 promise_test(async t => {
   // Verifies that an event is thrown when a change of state from IDLE to ACTIVE
   // is detected.
   expect(addMonitor).andReturn((threshold, monitorPtr) => {
@@ -70,18 +70,18 @@ promise_test(async t => {
   const initial_state = watcher.wait_for("change");
 
   await detector.start({ signal: controller.signal });
   await initial_state;
 
   // Wait for the first change in state.
   await watcher.wait_for("change");
 
-  assert_equals(detector.state.user, "idle");
-  assert_equals(detector.state.screen, "unlocked");
+  assert_equals(detector.userState, "idle");
+  assert_equals(detector.screenState, "unlocked");
 
   controller.abort();
 }, 'updates once');
 
 
 promise_test(async t => {
   // Simulates the user being active, going idle and then going back active
   // again.
@@ -115,21 +115,21 @@ promise_test(async t => {
   const watcher = new EventWatcher(t, detector, ["change"]);
   const initial_state = watcher.wait_for("change");
 
   await detector.start({ signal: controller.signal });
   await initial_state;
 
   // Waits for the first event.
   await watcher.wait_for("change");
-  assert_equals(detector.state.user, "idle");
+  assert_equals(detector.userState, "idle");
 
   // Waits for the second event.
   await watcher.wait_for("change");
-  assert_equals(detector.state.user, "active");
+  assert_equals(detector.userState, "active");
 
   controller.abort();
 }, 'updates twice');
 
 promise_test(async t => {
   // Simulates a locked screen.
   expect(addMonitor).andReturn((threshold, monitorPtr) => {
       return Promise.resolve({
@@ -143,17 +143,17 @@ promise_test(async t => {
   const controller = new AbortController();
   const detector = new IdleDetector();
   const watcher = new EventWatcher(t, detector, ["change"]);
   const initial_state = watcher.wait_for("change");
 
   await detector.start({ signal: controller.signal });
   await initial_state;
 
-  assert_equals(detector.state.screen, "locked");
+  assert_equals(detector.screenState, "locked");
 
   controller.abort();
 }, 'locked screen');
 
 promise_test(async t => {
   expect(addMonitor).andReturn((threshold, monitorPtr) => {
       return Promise.resolve({
         state: {
@@ -170,18 +170,18 @@ promise_test(async t => {
     detector.onchange = resolve;
   });
 
   await detector.start({ signal: controller.signal });
 
   // Waits for the first event.
   await event;
 
-  assert_equals(detector.state.user, "active");
-  assert_equals(detector.state.screen, "locked");
+  assert_equals(detector.userState, "active");
+  assert_equals(detector.screenState, "locked");
 
   controller.abort();
 }, 'IdleDetector.onchange');
 
 promise_test(async t => {
   expect(addMonitor).andReturn((threshold, monitorPtr) => {
       return Promise.resolve({
         state: {
@@ -198,18 +198,18 @@ promise_test(async t => {
   const initial_state = watcher.wait_for("change");
 
   // Only the first call to start() is allowed.
   const start_promise = detector.start();
   await promise_rejects_dom(t, 'InvalidStateError', detector.start());
   await start_promise;
 
   await initial_state;
-  assert_equals(detector.state.user, "active");
-  assert_equals(detector.state.screen, "unlocked");
+  assert_equals(detector.userState, "active");
+  assert_equals(detector.screenState, "unlocked");
 
   // Calling abort() multiple times is safe.
   controller.abort();
   controller.abort();
   controller.abort();
   controller.abort();
 }, 'Safe to call start() or stop() multiple times');
 
@@ -263,15 +263,15 @@ promise_test(async t => {
     });
 
   // Restarting the monitor.
   controller = new AbortController();
 
   initial_state = watcher.wait_for("change");
   await detector.start({ signal: controller.signal });
   await initial_state;
-  assert_equals(detector.state.user, "idle");
-  assert_equals(detector.state.screen, "locked");
+  assert_equals(detector.userState, "idle");
+  assert_equals(detector.screenState, "locked");
 
   controller.abort();
 }, 'Calling start() after stop(): re-starting monitor.');
 
 </script>
--- a/testing/web-platform/tests/idle-detection/resources/idlharness-worker.js
+++ b/testing/web-platform/tests/idle-detection/resources/idlharness-worker.js
@@ -10,14 +10,13 @@ idl_test(
       self.idle = new IdleDetector();
       let watcher = new EventWatcher(t, self.idle, ["change"]);
       let initial_state = watcher.wait_for("change");
       await self.idle.start();
       await initial_state;
 
       idl_array.add_objects({
         IdleDetector: ['idle'],
-        IdleState: ['idle.state']
       });
     }
 );
 
 done();