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

Side by Side 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 unified diff | Download patch
OLDNEW
(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 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698