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

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: Rebase + Devlin's comments 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 sendMessage = chrome.test.sendMessage;
6
7 function assertTrue(condition) {
8 chrome.test.assertTrue(condition);
9 if (!condition)
10 sendMessage('fail');
11 }
12
13 function testRestartOnWatchdog() {
14 sendMessage('ready', function(response) {
15 if (response == 'test1') {
16 chrome.runtime.restartOnWatchdog(-1, function() {
17 // Even though there's nothing schduled right now, this call should
18 // succeed.
19 assertTrue(chrome.runtime.lastError === undefined);
Devlin 2016/05/25 21:53:21 nit: prefer "assertNoLastError()"
afakhry 2016/05/26 00:18:39 Done.
20 testRestartOnWatchdog();
21 });
22 } else if (response == 'test2') {
23 chrome.runtime.restartOnWatchdog(2, function() {
24 // This request will be successfully rescheduled even though it will
Devlin 2016/05/25 21:53:21 rescheduled? When was it first scheduled?
afakhry 2016/05/26 00:18:39 Done.
25 // be cancelled by test3.
26 assertTrue(chrome.runtime.lastError === undefined);
27 sendMessage('request1', function(response) {
Devlin 2016/05/25 21:53:21 nit: might be a bit easier to read these if the nu
afakhry 2016/05/26 00:18:39 Done.
28 testRestartOnWatchdog();
29 });
30 });
31 } else if (response == 'test3') {
32 chrome.runtime.restartOnWatchdog(2, function() {
33 assertTrue(chrome.runtime.lastError === undefined);
34 sendMessage('request2', function(response) {
35 testRestartOnWatchdog();
36 });
37 });
38 } else if (response == 'test4') {
39 // This cancels any previous restart request.
40 chrome.runtime.restartOnWatchdog(-1, function() {
41 assertTrue(chrome.runtime.lastError === undefined);
42 sendMessage('request3', function(response) {
43 testRestartOnWatchdog();
44 });
45 });
46 } else if (response == 'test5') {
47 // The test will wait for this request until the restart request is
48 // successfully accomplished.
49 chrome.runtime.restartOnWatchdog(3, function() {
50 assertTrue(chrome.runtime.lastError === undefined);
51 sendMessage('request4', function(response) {
52 testRestartOnWatchdog();
53 });
54 });
55 } else if (response = 'test6') {
56 // Too soon request after a successful restart. It will be throttled and
57 // scheduled to happen after 3 seconds, even though we requested 1 second.
Devlin 2016/05/25 21:53:21 API question - should we automatically reschedule
afakhry 2016/05/26 00:18:39 Me and Xiyuan agreed to schedule a restart after t
58 chrome.runtime.restartOnWatchdog(1, function() {
59 assertTrue(chrome.runtime.lastError === undefined);
60 sendMessage('request5', function(response) {
61 testRestartOnWatchdog();
62 });
63 });
64 } else if (response == 'success') {
Devlin 2016/05/25 21:53:21 needed?
afakhry 2016/05/26 00:18:39 No, I was just being explicit. Removed.
65 return;
66 }
67 });
68 }
69
70 testRestartOnWatchdog();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698