| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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 var stage = 0; | |
| 6 | |
| 7 function step() { | |
| 8 chrome.screenlockPrivate.getLocked(function gotLocked(locked) { | |
| 9 if (stage === 0) { | |
| 10 if (locked) { | |
| 11 chrome.test.fail('locked at stage ' + stage); | |
| 12 } else { | |
| 13 chrome.screenlockPrivate.setLocked(true); | |
| 14 ++stage; | |
| 15 return true; | |
| 16 } | |
| 17 } else if (stage === 1) { | |
| 18 if (!locked) { | |
| 19 chrome.test.fail('unlocked at stage ' + stage); | |
| 20 } else { | |
| 21 chrome.screenlockPrivate.setLocked(false); | |
| 22 ++stage; | |
| 23 return true; | |
| 24 } | |
| 25 } else if (stage === 2) { | |
| 26 if (locked) { | |
| 27 chrome.test.fail('locked at stage ' + stage); | |
| 28 } else { | |
| 29 chrome.test.succeed(); | |
| 30 } | |
| 31 } | |
| 32 }); | |
| 33 }; | |
| 34 | |
| 35 chrome.screenlockPrivate.onChanged.addListener(function(locked) { | |
| 36 if (locked != (1 == (stage % 2))) { | |
| 37 chrome.test.fail((locked ? '' : 'un') + 'locked at stage ' + stage + | |
| 38 ' onChanged'); | |
| 39 } else { | |
| 40 return step(); | |
| 41 } | |
| 42 }); | |
| 43 | |
| 44 step(); | |
| OLD | NEW |