From 47b25987acbbcb4a8d42aecd37c977fcf2c678d1 Mon Sep 17 00:00:00 2001 From: Joe Downing Date: Tue, 20 Mar 2018 08:09:09 -0700 Subject: [PATCH] Move 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.leyboardUnlock(); 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 --- interfaces/keyboard-apis.idl | 8 ++++ keyboard-apis/idlharness.https.html | 34 +++++++++++++++ ...oard-lock-two-parallel-requests.https.html | 8 ++-- ...rd-lock-two-sequential-requests.https.html | 6 +-- .../navigator-keyboard-lock.https.html | 4 +- .../navigator-keyboard-unlock.https.html | 4 +- keyboard-lock/idlharness.https.html | 41 ------------------- 7 files changed, 53 insertions(+), 52 deletions(-) create mode 100644 interfaces/keyboard-apis.idl create mode 100644 keyboard-apis/idlharness.https.html rename keyboard-lock/navigator-keyboardLock-two-parallel-requests.https.html => keyboard-apis/navigator-keyboard-lock-two-parallel-requests.https.html (57%) rename keyboard-lock/navigator-keyboardLock-two-sequential-requests.https.html => keyboard-apis/navigator-keyboard-lock-two-sequential-requests.https.html (56%) rename keyboard-lock/navigator-keyboardLock.https.html => keyboard-apis/navigator-keyboard-lock.https.html (72%) rename keyboard-lock/navigator-keyboardUnlock.https.html => keyboard-apis/navigator-keyboard-unlock.https.html (70%) delete mode 100644 keyboard-lock/idlharness.https.html diff --git a/interfaces/keyboard-apis.idl b/interfaces/keyboard-apis.idl new file mode 100644 index 000000000000000..771c716ccadf7cb --- /dev/null +++ b/interfaces/keyboard-apis.idl @@ -0,0 +1,8 @@ +partial interface Navigator { + [SecureContext, SameObject] readonly attribute Keyboard keyboard; +}; + +[SecureContext, Exposed=Window] interface Keyboard { + Promise lock(optional sequence keyCodes = []); + void unlock(); +}; diff --git a/keyboard-apis/idlharness.https.html b/keyboard-apis/idlharness.https.html new file mode 100644 index 000000000000000..68a4d6ee0640e06 --- /dev/null +++ b/keyboard-apis/idlharness.https.html @@ -0,0 +1,34 @@ + + + +Keyboard IDL tests + + + + + + diff --git a/keyboard-lock/navigator-keyboardLock-two-parallel-requests.https.html b/keyboard-apis/navigator-keyboard-lock-two-parallel-requests.https.html similarity index 57% rename from keyboard-lock/navigator-keyboardLock-two-parallel-requests.https.html rename to keyboard-apis/navigator-keyboard-lock-two-parallel-requests.https.html index d553c064d50660d..501f36fb358e132 100644 --- a/keyboard-lock/navigator-keyboardLock-two-parallel-requests.https.html +++ b/keyboard-apis/navigator-keyboard-lock-two-parallel-requests.https.html @@ -5,11 +5,11 @@ 'use strict'; promise_test((t) => { - const p1 = navigator.keyboardLock(['a', 'b']); - const p2 = navigator.keyboardLock(['c', 'd']); + const p1 = navigator.keyboard.lock(['a', 'b']); + const p2 = navigator.keyboard.lock(['c', 'd']); return promise_rejects(t, null, p2, - 'keyboardLock() should only be ' + + 'keyboard.lock() should only be ' + 'executed if another request has finished.'); -}, 'Keyboard Lock keyboardLock twice in parallel'); +}, '[Keyboard Lock] keyboard.lock twice in parallel'); diff --git a/keyboard-lock/navigator-keyboardLock-two-sequential-requests.https.html b/keyboard-apis/navigator-keyboard-lock-two-sequential-requests.https.html similarity index 56% rename from keyboard-lock/navigator-keyboardLock-two-sequential-requests.https.html rename to keyboard-apis/navigator-keyboard-lock-two-sequential-requests.https.html index 7670be4f3830ee9..4403930bf62c2ee 100644 --- a/keyboard-lock/navigator-keyboardLock-two-sequential-requests.https.html +++ b/keyboard-apis/navigator-keyboard-lock-two-sequential-requests.https.html @@ -5,10 +5,10 @@ 'use strict'; promise_test(() => { - return navigator.keyboardLock(['a', 'b']) + return navigator.keyboard.lock(['a', 'b']) .then(() => { - return navigator.keyboardLock(['c', 'd']); + return navigator.keyboard.lock(['c', 'd']); }); -}, 'Keyboard Lock keyboardLock twice sequentially'); +}, '[Keyboard Lock] keyboard.lock called twice sequentially'); diff --git a/keyboard-lock/navigator-keyboardLock.https.html b/keyboard-apis/navigator-keyboard-lock.https.html similarity index 72% rename from keyboard-lock/navigator-keyboardLock.https.html rename to keyboard-apis/navigator-keyboard-lock.https.html index 6711decc121485b..d39e8907647a44e 100644 --- a/keyboard-lock/navigator-keyboardLock.https.html +++ b/keyboard-apis/navigator-keyboard-lock.https.html @@ -5,9 +5,9 @@ 'use strict'; promise_test(() => { - const p = navigator.keyboardLock(['a', 'b']); + const p = navigator.keyboard.lock(['a', 'b']); assert_true(p instanceof Promise); return p; -}, 'Keyboard Lock keyboardLock'); +}, '[Keyboard Lock] keyboard.lock'); diff --git a/keyboard-lock/navigator-keyboardUnlock.https.html b/keyboard-apis/navigator-keyboard-unlock.https.html similarity index 70% rename from keyboard-lock/navigator-keyboardUnlock.https.html rename to keyboard-apis/navigator-keyboard-unlock.https.html index ceb7a968949ddb5..87b10ee49a9c8cb 100644 --- a/keyboard-lock/navigator-keyboardUnlock.https.html +++ b/keyboard-apis/navigator-keyboard-unlock.https.html @@ -5,8 +5,8 @@ 'use strict'; test(() => { - assert_equals(navigator.keyboardUnlock(), + assert_equals(navigator.keyboard.unlock(), undefined); -}, 'Keyboard Lock keyboardUnlock'); +}, '[Keyboard Lock] keyboard.unlock'); diff --git a/keyboard-lock/idlharness.https.html b/keyboard-lock/idlharness.https.html deleted file mode 100644 index 9caa379f4f68268..000000000000000 --- a/keyboard-lock/idlharness.https.html +++ /dev/null @@ -1,41 +0,0 @@ - - - -Keyboard Lock IDL tests - - - - - - - - - - - -
- -