| Index: chrome/test/data/extensions/api_test/runtime/restartOnWatchdog/test.js
|
| diff --git a/chrome/test/data/extensions/api_test/runtime/restartOnWatchdog/test.js b/chrome/test/data/extensions/api_test/runtime/restartOnWatchdog/test.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7bf9a0ad5009c313108f0347f4e494bc39448b7a
|
| --- /dev/null
|
| +++ b/chrome/test/data/extensions/api_test/runtime/restartOnWatchdog/test.js
|
| @@ -0,0 +1,55 @@
|
| +// Copyright 2016 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.
|
| +
|
| +var assertEq = chrome.test.assertEq;
|
| +var assertTrue = chrome.test.assertTrue;
|
| +var assertFalse = chrome.test.assertFalse;
|
| +var fail = chrome.test.fail;
|
| +var succeed = chrome.test.succeed;
|
| +
|
| +chrome.test.runTests([
|
| +
|
| + function testRestartOnWatchdog() {
|
| + chrome.runtime.restartOnWatchdog(1, function() {
|
| + // This will be canceled by the following call, and we should never
|
| + // receive a callback.
|
| + fail();
|
| + });
|
| +
|
| + chrome.runtime.restartOnWatchdog(1, function() {
|
| + // This will be canceled by the following call, and we should never
|
| + // receive a callback.
|
| + fail();
|
| + });
|
| +
|
| + var start = Date.now();
|
| + chrome.runtime.restartOnWatchdog(2, function(success, message) {
|
| + assertTrue(success);
|
| +
|
| + var end = Date.now();
|
| + if ((end - start) < 2000) {
|
| + console.log('Error: Restarting sooner than requested: ' +
|
| + (end - start) + ' ms.');
|
| + fail();
|
| + }
|
| +
|
| + succeed();
|
| + });
|
| + },
|
| +
|
| + function testThrottlingRestartRequests() {
|
| + chrome.runtime.restartOnWatchdog(3, function(success, message) {
|
| + // This request will succeed.
|
| + assertTrue(success);
|
| +
|
| + chrome.runtime.restartOnWatchdog(1, function(success, message) {
|
| + // This request will be throttled.
|
| + assertEq(message, 'Error: Called too soon since the last restart.');
|
| + assertFalse(success);
|
| + succeed();
|
| + });
|
| + });
|
| + }
|
| +
|
| +]);
|
|
|