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
merged 1 commit into from Mar 22, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+44 −43
Diff settings

Always

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:
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}
  • 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>
<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 {
};
</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();
'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();
};
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>
@@ -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');
</script>
@@ -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');
</script>
@@ -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');
</script>
@@ -5,8 +5,8 @@
'use strict';
test(() => {
assert_equals(navigator.keyboardUnlock(),
assert_equals(navigator.keyboard.unlock(),
undefined);
}, 'Keyboard Lock keyboardUnlock');
}, '[Keyboard Lock] keyboard.unlock');
</script>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.