I thought you can just point to
https://garykac.github.io/system-keyboard-lock/You can update it later if/when it moves.
https://codereview.chromium.org/2805763004/diff/380001/third_party/WebKit/LayoutTests/external/wpt/keyboard-lock/idl-KeyboardLock.htmlFile
third_party/WebKit/LayoutTests/external/wpt/keyboard-lock/idl-KeyboardLock.html
(right):
https://codereview.chromium.org/2805763004/diff/380001/third_party/WebKit/LayoutTests/external/wpt/keyboard-lock/idl-KeyboardLock.html#newcode2third_party/WebKit/LayoutTests/external/wpt/keyboard-lock/idl-KeyboardLock.html:2:
<title>Keyboard lock interface</title>
nit: It's common to keep each test case in a single file as they may run
in parallel and have dependencies (see my comment below about the check
that a second request fails if there's one pending).
https://codereview.chromium.org/2805763004/diff/380001/third_party/WebKit/LayoutTests/external/wpt/keyboard-lock/idl-KeyboardLock.html#newcode11third_party/WebKit/LayoutTests/external/wpt/keyboard-lock/idl-KeyboardLock.html:11:
assert_true('requestKeyLock' in navigator);
nit: you can add checks that these are both functions and even their
return types by checking the result of typeof of their results.
assert_equals(typeof(navigator.requestKeyLock), "function");
https://codereview.chromium.org/2805763004/diff/380001/third_party/WebKit/LayoutTests/external/wpt/keyboard-lock/idl-KeyboardLock.html#newcode20third_party/WebKit/LayoutTests/external/wpt/keyboard-lock/idl-KeyboardLock.html:20:
promise_rejects(t, null, p2,
I tried your cl locally. If I change the NavigatorKeyboardLock.cpp like
below, the test still passes:
index 4069544f2637..2c22ca763590 100644
---
a/third_party/WebKit/Source/modules/keyboard_lock/NavigatorKeyboardLock.cpp
+++
b/third_party/WebKit/Source/modules/keyboard_lock/NavigatorKeyboardLock.cpp
@@ -41,9 +41,10 @@ ScriptPromise NavigatorKeyboardLock::requestKeyLock(
const Vector<String>& keycodes) {
DCHECK(state);
if (request_keylock_resolver_) {
- return ScriptPromise::Reject(
- state, V8String(state->GetIsolate(),
- "Last requestKeyLock() has not finished
yet."));
+ request_keylock_resolver_->Resolve();
+ // return ScriptPromise::Reject(
+ // state, V8String(state->GetIsolate(),
+ // "Last requestKeyLock() has not finished
yet."));
}
if (!service_) {
@@ -89,6 +90,7 @@ void NavigatorKeyboardLock::cancelKeyLock(Navigator&
navigator) {
void NavigatorKeyboardLock::LockRequestFinished(bool allowed,
const String& reason) {
+ if (!request_keylock_resolver_) return;
DCHECK(request_keylock_resolver_);
if (allowed)
request_keylock_resolver_->Resolve();
Note that for promise_test() you return one promise and the test will
pass if this promise fulfills and fail if it rejects. Once it's settled,
no further callback code will have effect (as test.done() is called) so
calling promise_rejects from there doesn't have any effect AFAIK.
I think you could just return promise_rejects():
promise_test((t) => {
const p1 = navigator.requestKeyLock(['a', 'b']);
const p2 = navigator.requestKeyLock(['c', 'd']);
return promise_rejects(t, null, p2);
}, 'Test that calling requestKeyLock() rejects before the previous
promise was settled');
However, as is, the next test would fail because it may be run before p1
is resolved so its promise will get rejected too.
Having each test in a separate file fixes that.
https://codereview.chromium.org/2805763004/diff/380001/third_party/WebKit/LayoutTests/external/wpt/keyboard-lock/idl-KeyboardLock.html#newcode37third_party/WebKit/LayoutTests/external/wpt/keyboard-lock/idl-KeyboardLock.html:37:
return navigator.requestKeyLock(['a', 'b'])
This test still passes if I comment all the rest out and modify the
implementation like this:
index 4069544f2637..fe74ebfba76c 100644
---
a/third_party/WebKit/Source/modules/keyboard_lock/NavigatorKeyboardLock.cpp
+++
b/third_party/WebKit/Source/modules/keyboard_lock/NavigatorKeyboardLock.cpp
@@ -94,7 +94,7 @@ void NavigatorKeyboardLock::LockRequestFinished(bool
allowed,
request_keylock_resolver_->Resolve();
else
request_keylock_resolver_->Reject(reason);
- request_keylock_resolver_ = nullptr;
+// request_keylock_resolver_ = nullptr;
}
// static
For similar reasons - as long as the first promise resolves,
promise_test() marks the test as done and catch for the second promise
doesn't fail the test.
This should be an async_test that can be written like this (note
t.step_func() usage as it's not a promise_test()):
async_test((t) => {
navigator.requestKeyLock([]).then(t.step_func(() => {
navigator.requestKeyLock([])
.then(t.step_func_done())
.catch(t.unreached_func());
}))
.catch(t.unreached_func());
}, 'Tests that second requestKeyLock succeeds once the promise returned
by the first one is fulfilled.');
https://codereview.chromium.org/2805763004/