OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 function respondResult(result) { |
| 6 window.domAutomationController.send(result); |
| 7 } |
| 8 |
| 9 function testRequestKeyLock() { |
| 10 try { |
| 11 navigator.requestKeyLock(['a', 'b']) |
| 12 .then(() => { |
| 13 respondResult('Succeeded'); |
| 14 }) |
| 15 .catch((reason) => { |
| 16 respondResult('Failed: ' + reason); |
| 17 }); |
| 18 } catch (exception) { |
| 19 respondResult('Failed: ' + exception); |
| 20 } |
| 21 } |
| 22 |
| 23 function testCancelKeyLock() { |
| 24 try { |
| 25 navigator.cancelKeyLock(); |
| 26 respondResult('Succeeded'); |
| 27 } catch (exception) { |
| 28 respondResult('Failed: ' + exception); |
| 29 } |
| 30 } |
| 31 |
| 32 function testRequestKeyLockTwice() { |
| 33 try { |
| 34 let result = ''; |
| 35 const p1 = navigator.requestKeyLock(['a', 'b']) |
| 36 .then(() => { |
| 37 result += 'Succeeded\n'; |
| 38 }) |
| 39 .catch((reason) => { |
| 40 result += 'Failed: ' + reason + '\n'; |
| 41 }); |
| 42 const p2 = navigator.requestKeyLock(['c', 'd']) |
| 43 .then(() => { |
| 44 result += 'Succeeded\n'; |
| 45 }) |
| 46 .catch((reason) => { |
| 47 result += 'Failed: ' + reason + '\n'; |
| 48 }); |
| 49 return Promise.all([p1, p2]).then(() => { |
| 50 respondResult(result); |
| 51 }); |
| 52 } catch (exception) { |
| 53 result += 'Failed: ' + exception + '\n'; |
| 54 } |
| 55 } |
OLD | NEW |