Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move KeyboardLock API methods to a 'keyboard' object #10111

merged 1 commit into from Mar 22, 2018
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+44 −43
Diff settings


Just for now

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:

Old calling pattern:

New calling pattern:

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.


Change-Id: I234b2ab12d5ecd44c894ed5103863fd96fd548d4
Reviewed-by: Philip Jägenstedt <>
Reviewed-by: Gary Kacmarcik <>
Reviewed-by: Daniel Cheng <>
Commit-Queue: Daniel Cheng <>
Cr-Commit-Position: refs/heads/master@{#544996}
  • Loading branch information...
Joe Downing authored and chromium-wpt-export-bot committed Mar 22, 2018
commit b55e29597d92ab89063673f031151e2bdb4b9479
@@ -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();
@@ -1,41 +1,34 @@
<!doctype html>
<title>Keyboard Lock IDL tests</title>
<link rel="help" href=""/>
<title>Keyboard IDL tests</title>
<link rel="help" href=""/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
<pre id="untested_idl" style="display: none">
interface Navigator {
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, 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();
var idl_array = new IdlArray();
Navigator: ["navigator"]
'use strict';
function doTest(idls) {
var idl_array = new IdlArray();
idl_array.add_untested_idls('interface Navigator {};');
for (let idl of idls) {
Navigator: ['navigator'],
Keyboard: ['navigator.keyboard'],
function fetchText(url) {
return fetch(url).then((response) => response.text());
promise_test(() => {
return Promise.all(["/interfaces/keyboard-lock.idl"].map(fetchText))
}, "Test driver");
<div id="log"></div>
@@ -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');
@@ -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');
@@ -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');
@@ -5,8 +5,8 @@
'use strict';
test(() => {
}, 'Keyboard Lock keyboardUnlock');
}, '[Keyboard Lock] keyboard.unlock');
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.