Bug 1447321 [wpt PR 10111] - Move KeyboardLock API methods to a 'keyboard' object, a=testonly
authorJoe Downing <joedow@chromium.org>
Mon, 09 Apr 2018 17:37:41 +0000
changeset 467154 446e4d678d9135c132d4cf30cc736fbab7d64af2
parent 467153 f2cb9ba956877b2b03bc4aa85a5c940948c2ee2d
child 467155 1facf5ae4b13c54c8f80319f4d1a3c1aa00961d7
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1447321, 10111, 680809, 969656, 544996
milestone61.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 1447321 [wpt PR 10111] - Move KeyboardLock API methods to a 'keyboard' object, a=testonly Automatic update from web-platform-testsMove KeyboardLock API methods to a 'keyboard' object This change moves the KeyboardLock API methods to a 'keyboard' namespace on the Navigator object. We are doing this work now as there has been a request for additional keyboard functionality that would also be placed on the new keyboard object and we wanted to move the KeyboardLock methods there for consistency before we launch. KeyboardLock API Spec is here: https://w3c.github.io/keyboard-lock/#API Old calling pattern: Navigator.keyboardLock(); Navigator.keyboardUnlock(); New calling pattern: Navigator.keyboard.lock(); Navigator.keyboard.unlock(); Note: The main logic in the KeyboardLock.cpp class and tests is the same as it was, however the file changed enough that git does not recognize it as a file move. BUG=680809 Change-Id: I234b2ab12d5ecd44c894ed5103863fd96fd548d4 Reviewed-on: https://chromium-review.googlesource.com/969656 Reviewed-by: Philip J├Ągenstedt <foolip@chromium.org> Reviewed-by: Gary Kacmarcik <garykac@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Commit-Queue: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/master@{#544996} wpt-commits: 5ffa5051c36c670be1a38000de442b002920ac12 wpt-pr: 10111 wpt-commits: 5ffa5051c36c670be1a38000de442b002920ac12 wpt-pr: 10111
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/interfaces/keyboard-lock.idl
testing/web-platform/tests/keyboard-lock/idlharness.https.html
testing/web-platform/tests/keyboard-lock/navigator-keyboard-lock-two-parallel-requests.https.html
testing/web-platform/tests/keyboard-lock/navigator-keyboard-lock-two-sequential-requests.https.html
testing/web-platform/tests/keyboard-lock/navigator-keyboard-lock.https.html
testing/web-platform/tests/keyboard-lock/navigator-keyboard-unlock.https.html
testing/web-platform/tests/keyboard-lock/navigator-keyboardLock-two-parallel-requests.https.html
testing/web-platform/tests/keyboard-lock/navigator-keyboardLock-two-sequential-requests.https.html
testing/web-platform/tests/keyboard-lock/navigator-keyboardLock.https.html
testing/web-platform/tests/keyboard-lock/navigator-keyboardUnlock.https.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -285530,16 +285530,21 @@
      {}
     ]
    ],
    "interfaces/html.idl": [
     [
      {}
     ]
    ],
+   "interfaces/keyboard-lock.idl": [
+    [
+     {}
+    ]
+   ],
    "interfaces/magnetometer.idl": [
     [
      {}
     ]
    ],
    "interfaces/mediacapture-main.idl": [
     [
      {}
@@ -338968,37 +338973,37 @@
     ]
    ],
    "keyboard-lock/idlharness.https.html": [
     [
      "/keyboard-lock/idlharness.https.html",
      {}
     ]
    ],
-   "keyboard-lock/navigator-keyboardLock-two-parallel-requests.https.html": [
-    [
-     "/keyboard-lock/navigator-keyboardLock-two-parallel-requests.https.html",
-     {}
-    ]
-   ],
-   "keyboard-lock/navigator-keyboardLock-two-sequential-requests.https.html": [
-    [
-     "/keyboard-lock/navigator-keyboardLock-two-sequential-requests.https.html",
-     {}
-    ]
-   ],
-   "keyboard-lock/navigator-keyboardLock.https.html": [
-    [
-     "/keyboard-lock/navigator-keyboardLock.https.html",
-     {}
-    ]
-   ],
-   "keyboard-lock/navigator-keyboardUnlock.https.html": [
-    [
-     "/keyboard-lock/navigator-keyboardUnlock.https.html",
+   "keyboard-lock/navigator-keyboard-lock-two-parallel-requests.https.html": [
+    [
+     "/keyboard-lock/navigator-keyboard-lock-two-parallel-requests.https.html",
+     {}
+    ]
+   ],
+   "keyboard-lock/navigator-keyboard-lock-two-sequential-requests.https.html": [
+    [
+     "/keyboard-lock/navigator-keyboard-lock-two-sequential-requests.https.html",
+     {}
+    ]
+   ],
+   "keyboard-lock/navigator-keyboard-lock.https.html": [
+    [
+     "/keyboard-lock/navigator-keyboard-lock.https.html",
+     {}
+    ]
+   ],
+   "keyboard-lock/navigator-keyboard-unlock.https.html": [
+    [
+     "/keyboard-lock/navigator-keyboard-unlock.https.html",
      {}
     ]
    ],
    "longtask-timing/longtask-attributes.html": [
     [
      "/longtask-timing/longtask-attributes.html",
      {}
     ]
@@ -572645,16 +572650,20 @@
   "interfaces/hr-time.idl": [
    "db4f313176e4fdfb8efd78545079da42cbb0729b",
    "support"
   ],
   "interfaces/html.idl": [
    "b2b35732b54cbe3406493a6c121363eccceb4f5c",
    "support"
   ],
+  "interfaces/keyboard-lock.idl": [
+   "7188a9233db3acc741650d46156e16e9e7a132fa",
+   "support"
+  ],
   "interfaces/magnetometer.idl": [
    "ffac480912edba82886fef6d5368092d237a0c7f",
    "support"
   ],
   "interfaces/mediacapture-main.idl": [
    "3400c775504ebf32af3f8e1165a53ca60f258495",
    "support"
   ],
@@ -572934,33 +572943,33 @@
    "aac7ab0c0e6beecf28ede1967ecff3ea226e8883",
    "testharness"
   ],
   "js/builtins/WeakMap.prototype-properties.html": [
    "581702f5f6b8f6e547918ae8f8a8547b103a9b6c",
    "testharness"
   ],
   "keyboard-lock/idlharness.https.html": [
-   "4b41c1c46a8f7d2374d0ff9d796f3f938c1f74d8",
-   "testharness"
-  ],
-  "keyboard-lock/navigator-keyboardLock-two-parallel-requests.https.html": [
-   "ee6fe59233abea9325bf7f5e14c1472a72e45a11",
-   "testharness"
-  ],
-  "keyboard-lock/navigator-keyboardLock-two-sequential-requests.https.html": [
-   "02ad8f54b7cebed96553bd96bbd7e8fc0227d3b1",
-   "testharness"
-  ],
-  "keyboard-lock/navigator-keyboardLock.https.html": [
-   "572f4e827bc3807f4c71641e102d7bac9df3e391",
-   "testharness"
-  ],
-  "keyboard-lock/navigator-keyboardUnlock.https.html": [
-   "c4de12456714a34fb791b070304da31c99da080f",
+   "010771094a9dc58e03a2c1ca2d8416866284fc2b",
+   "testharness"
+  ],
+  "keyboard-lock/navigator-keyboard-lock-two-parallel-requests.https.html": [
+   "b594f75f5b0c89c2a5f2b934d170b8ff81ad9839",
+   "testharness"
+  ],
+  "keyboard-lock/navigator-keyboard-lock-two-sequential-requests.https.html": [
+   "8990cc5772cdba1281c0a05c6a3c2a80b08b810e",
+   "testharness"
+  ],
+  "keyboard-lock/navigator-keyboard-lock.https.html": [
+   "f95f8408986d73501ec7cce09106a8536bd891b4",
+   "testharness"
+  ],
+  "keyboard-lock/navigator-keyboard-unlock.https.html": [
+   "f5cc2141ea7c74964d308784901d6d2c242f4369",
    "testharness"
   ],
   "longtask-timing/OWNERS": [
    "30a9c29ba53bac131c0cca801c01dddb4779824e",
    "support"
   ],
   "longtask-timing/longtask-attributes.html": [
    "247359327818f59871be00d22942f6ecde5281a7",
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/interfaces/keyboard-lock.idl
@@ -0,0 +1,8 @@
+partial interface Navigator {
+  [SecureContext, SameObject] readonly attribute Keyboard keyboard;
+};
+
+[SecureContext, Exposed=Window] interface Keyboard {
+  Promise<void> lock(optional sequence<DOMString> keyCodes = []);
+  void unlock();
+};
--- a/testing/web-platform/tests/keyboard-lock/idlharness.https.html
+++ b/testing/web-platform/tests/keyboard-lock/idlharness.https.html
@@ -1,41 +1,34 @@
 <!doctype html>
 <html>
 <head>
-<title>Keyboard Lock IDL tests</title>
-<link rel="help" href="https://github.com/w3c/keyboard-lock"/>
+<title>Keyboard IDL tests</title>
+<link rel="help" href="https://w3c.github.io/keyboard-lock/"/>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="/resources/WebIDLParser.js"></script>
 <script src="/resources/idlharness.js"></script>
-</head>
-<body>
-<pre id="untested_idl" style="display: none">
-interface Navigator {
+<script>
+'use strict';
+
+function doTest(idls) {
+  var idl_array = new IdlArray();
+  idl_array.add_untested_idls('interface Navigator {};');
+  for (let idl of idls) {
+    idl_array.add_idls(idl);
+  }
+  idl_array.add_objects({
+    Navigator: ['navigator'],
+    Keyboard: ['navigator.keyboard'],
+  });
+  idl_array.test();
 };
-</pre>
-<!--
-  The reason of the failure of keyboardLock test looks like a code defect in
-  idlharness.js. media-capabilities/idlharness.html is also impacted by this
-  issue. See https://codereview.chromium.org/2805763004/#ps620001, which
-  includes a potential fix.
-  TODO(joedow): Submit the fix.
--->
-<pre id="idl" style="display: none">
-partial interface Navigator {
-  [SecureContext] Promise<void> keyboardLock(optional sequence<DOMString> keyCodes = []);
-  [SecureContext] void keyboardUnlock();
-};
-</pre>
-<script>
-var idl_array = new IdlArray();
-idl_array.add_untested_idls(
-    document.getElementById("untested_idl").textContent);
-idl_array.add_idls(document.getElementById("idl").textContent);
-idl_array.add_objects({
-  Navigator: ["navigator"]
-});
-idl_array.test();
+
+function fetchText(url) {
+  return fetch(url).then((response) => response.text());
+}
+
+promise_test(() => {
+  return Promise.all(["/interfaces/keyboard-lock.idl"].map(fetchText))
+    .then(doTest);
+}, "Test driver");
 </script>
-<div id="log"></div>
-</body>
-</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/keyboard-lock/navigator-keyboard-lock-two-parallel-requests.https.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+'use strict';
+
+promise_test((t) => {
+  const p1 = navigator.keyboard.lock(['a', 'b']);
+  const p2 = navigator.keyboard.lock(['c', 'd']);
+  return promise_rejects(t, null, p2,
+      'keyboard.lock() should only be ' +
+      'executed if another request has finished.');
+}, '[Keyboard Lock] keyboard.lock twice in parallel');
+
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/keyboard-lock/navigator-keyboard-lock-two-sequential-requests.https.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+'use strict';
+
+promise_test(() => {
+  return navigator.keyboard.lock(['a', 'b'])
+      .then(() => {
+        return navigator.keyboard.lock(['c', 'd']);
+      });
+}, '[Keyboard Lock] keyboard.lock called twice sequentially');
+
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/keyboard-lock/navigator-keyboard-lock.https.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+'use strict';
+
+promise_test(() => {
+  const p = navigator.keyboard.lock(['a', 'b']);
+  assert_true(p instanceof Promise);
+  return p;
+}, '[Keyboard Lock] keyboard.lock');
+
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/keyboard-lock/navigator-keyboard-unlock.https.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+'use strict';
+
+test(() => {
+  assert_equals(navigator.keyboard.unlock(),
+                undefined);
+}, '[Keyboard Lock] keyboard.unlock');
+
+</script>
deleted file mode 100644
--- a/testing/web-platform/tests/keyboard-lock/navigator-keyboardLock-two-parallel-requests.https.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
-'use strict';
-
-promise_test((t) => {
-  const p1 = navigator.keyboardLock(['a', 'b']);
-  const p2 = navigator.keyboardLock(['c', 'd']);
-  return promise_rejects(t, null, p2,
-      'keyboardLock() should only be ' +
-      'executed if another request has finished.');
-}, 'Keyboard Lock keyboardLock twice in parallel');
-
-</script>
deleted file mode 100644
--- a/testing/web-platform/tests/keyboard-lock/navigator-keyboardLock-two-sequential-requests.https.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
-'use strict';
-
-promise_test(() => {
-  return navigator.keyboardLock(['a', 'b'])
-      .then(() => {
-        return navigator.keyboardLock(['c', 'd']);
-      });
-}, 'Keyboard Lock keyboardLock twice sequentially');
-
-</script>
deleted file mode 100644
--- a/testing/web-platform/tests/keyboard-lock/navigator-keyboardLock.https.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
-'use strict';
-
-promise_test(() => {
-  const p = navigator.keyboardLock(['a', 'b']);
-  assert_true(p instanceof Promise);
-  return p;
-}, 'Keyboard Lock keyboardLock');
-
-</script>
deleted file mode 100644
--- a/testing/web-platform/tests/keyboard-lock/navigator-keyboardUnlock.https.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE html>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
-'use strict';
-
-test(() => {
-  assert_equals(navigator.keyboardUnlock(),
-                undefined);
-}, 'Keyboard Lock keyboardUnlock');
-
-</script>