Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <title>Keyboard lock interface</title> | |
|
whywhat
2017/04/13 02:34:36
nit: It's common to keep each test case in a singl
Hzj_jie
2017/04/13 22:24:25
Oh, I misunderstood your meaning: in content_brows
| |
| 3 <script src="/resources/testharness.js"></script> | |
| 4 <script src="/resources/testharnessreport.js"></script> | |
| 5 <script> | |
| 6 'use strict'; | |
| 7 | |
| 8 test(() => { | |
| 9 // NavigatorKeyboardLock implements both requestKeyLock() and cancelKeyLock() | |
| 10 // functions; | |
| 11 assert_true('requestKeyLock' in navigator); | |
|
whywhat
2017/04/13 02:34:36
nit: you can add checks that these are both functi
Hzj_jie
2017/04/13 22:24:25
Done.
| |
| 12 assert_true('cancelKeyLock' in navigator); | |
| 13 }, 'Keyboard Lock IDL test'); | |
| 14 | |
| 15 promise_test((t) => { | |
| 16 const p1 = navigator.requestKeyLock(['a', 'b']); | |
| 17 const p2 = navigator.requestKeyLock(['c', 'd']); | |
| 18 | |
| 19 return p1.then(() => { | |
| 20 promise_rejects(t, null, p2, | |
|
whywhat
2017/04/13 02:34:36
I tried your cl locally. If I change the Navigator
Hzj_jie
2017/04/13 22:24:25
This is out of my expectation: Promise.then() retu
whywhat
2017/04/13 22:40:24
Ack. Maybe returning promise_rejects() is all it t
| |
| 21 'requestKeyLock() should only be ' + | |
| 22 'executed if another request has finished.'); | |
| 23 }).catch((reason) => { | |
| 24 assert_true(false, 'The first request should be allowed.'); | |
| 25 }); | |
| 26 }, 'Keyboard Lock requestKeyLock twice concurrently test'); | |
| 27 | |
| 28 promise_test(() => { | |
| 29 return navigator.requestKeyLock(['a', 'b']) | |
| 30 .then(() => {}) | |
| 31 .catch((reason) => { | |
| 32 assert_true(false, 'requestKeyLock should succeed.'); | |
| 33 }); | |
| 34 }, 'Keyboard Lock requestKeyLock test'); | |
| 35 | |
| 36 promise_test(() => { | |
| 37 return navigator.requestKeyLock(['a', 'b']) | |
|
whywhat
2017/04/13 02:34:36
This test still passes if I comment all the rest o
Hzj_jie
2017/04/13 22:24:25
After some investigations, the behavior of promise
whywhat
2017/04/13 22:40:24
Yeah, I was wondering that chaining should work. G
| |
| 38 .then(() => { | |
| 39 navigator.requestKeyLock(['c', 'd']) | |
| 40 .then(() => {}) | |
| 41 .catch((reason) => { | |
| 42 assert_true(false, 'requestKeyLock should succeed.'); | |
| 43 }); | |
| 44 }) | |
| 45 .catch((reason) => { | |
| 46 assert_true(false, 'requestKeyLock should succeed.'); | |
| 47 }); | |
| 48 }, 'Keyboard Lock requestKeyLock twice sequentially test'); | |
| 49 | |
| 50 test(() => { | |
| 51 navigator.cancelKeyLock(); | |
| 52 }, 'Keyboard Lock cancelKeyLock test'); | |
| 53 | |
| 54 </script> | |
| OLD | NEW |