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'; |
+ } |
+} |