| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 assertEq = chrome.test.assertEq; |
| 6 var assertTrue = chrome.test.assertTrue; |
| 7 var assertFalse = chrome.test.assertFalse; |
| 8 var fail = chrome.test.fail; |
| 9 var succeed = chrome.test.succeed; |
| 10 |
| 11 chrome.test.runTests([ |
| 12 |
| 13 function testRestartOnWatchdog() { |
| 14 chrome.runtime.restartOnWatchdog(1, function() { |
| 15 // This will be canceled by the following call, and we should never |
| 16 // receive a callback. |
| 17 fail(); |
| 18 }); |
| 19 |
| 20 chrome.runtime.restartOnWatchdog(1, function() { |
| 21 // This will be canceled by the following call, and we should never |
| 22 // receive a callback. |
| 23 fail(); |
| 24 }); |
| 25 |
| 26 var start = Date.now(); |
| 27 chrome.runtime.restartOnWatchdog(2, function(success, message) { |
| 28 assertTrue(success); |
| 29 |
| 30 var end = Date.now(); |
| 31 if ((end - start) < 2000) { |
| 32 console.log('Error: Restarting sooner than requested: ' + |
| 33 (end - start) + ' ms.'); |
| 34 fail(); |
| 35 } |
| 36 |
| 37 succeed(); |
| 38 }); |
| 39 }, |
| 40 |
| 41 function testThrottlingRestartRequests() { |
| 42 chrome.runtime.restartOnWatchdog(3, function(success, message) { |
| 43 // This request will succeed. |
| 44 assertTrue(success); |
| 45 |
| 46 chrome.runtime.restartOnWatchdog(1, function(success, message) { |
| 47 // This request will be throttled. |
| 48 assertEq(message, 'Error: Called too soon since the last restart.'); |
| 49 assertFalse(success); |
| 50 succeed(); |
| 51 }); |
| 52 }); |
| 53 } |
| 54 |
| 55 ]); |
| OLD | NEW |