Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1578)

Unified Diff: content/test/data/keyboard_lock/keyboard_lock.js

Issue 2805763004: [System-Keyboard-Lock] Forward navigator functions to RenderFrameHost (Closed)
Patch Set: Add external/wpt tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/test/data/keyboard_lock/keyboard_lock.js
diff --git a/content/test/data/keyboard_lock/keyboard_lock.js b/content/test/data/keyboard_lock/keyboard_lock.js
new file mode 100644
index 0000000000000000000000000000000000000000..b8273b74f0c46d730febcf53754ca852eb265e37
--- /dev/null
+++ b/content/test/data/keyboard_lock/keyboard_lock.js
@@ -0,0 +1,55 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function respondResult(result) {
+ window.domAutomationController.send(result);
+}
+
+function testRequestKeyLock() {
+ try {
+ navigator.requestKeyLock(['a', 'b'])
+ .then(() => {
+ respondResult('Succeeded');
+ })
+ .catch((reason) => {
+ respondResult('Failed: ' + reason);
+ });
+ } catch (exception) {
+ respondResult('Failed: ' + exception);
+ }
+}
+
+function testCancelKeyLock() {
+ try {
+ navigator.cancelKeyLock();
+ respondResult('Succeeded');
+ } catch (exception) {
+ respondResult('Failed: ' + exception);
+ }
+}
+
+function testRequestKeyLockTwice() {
+ try {
+ let result = '';
+ const p1 = navigator.requestKeyLock(['a', 'b'])
+ .then(() => {
+ result += 'Succeeded\n';
+ })
+ .catch((reason) => {
+ result += 'Failed: ' + reason + '\n';
+ });
+ const p2 = navigator.requestKeyLock(['c', 'd'])
+ .then(() => {
+ result += 'Succeeded\n';
+ })
+ .catch((reason) => {
+ result += 'Failed: ' + reason + '\n';
+ });
+ return Promise.all([p1, p2]).then(() => {
+ respondResult(result);
+ });
+ } catch (exception) {
+ result += 'Failed: ' + exception + '\n';
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698