Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2708)

Unified Diff: chrome/test/data/extensions/api_test/runtime/restartOnWatchdog/test.js

Issue 1970613003: Add a new app API to enable watchdog behavior restarts in kiosk apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unneeded include and forward declare Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
+ });
+ });
+ }
+
+]);

Powered by Google App Engine
This is Rietveld 408576698