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

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: 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 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..e3dcdbe41d8302039477cfd6f436ff8498e97f26
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/runtime/restartOnWatchdog/test.js
@@ -0,0 +1,70 @@
+// 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 sendMessage = chrome.test.sendMessage;
+
+function assertTrue(condition) {
+ chrome.test.assertTrue(condition);
+ if (!condition)
+ sendMessage('fail');
+}
+
+function testRestartOnWatchdog() {
+ sendMessage('ready', function(response) {
+ if (response == 'test1') {
+ chrome.runtime.restartOnWatchdog(-1, function() {
+ // Even though there's nothing schduled right now, this call should
+ // succeed.
+ assertTrue(chrome.runtime.lastError === undefined);
Devlin 2016/05/25 21:53:21 nit: prefer "assertNoLastError()"
afakhry 2016/05/26 00:18:39 Done.
+ testRestartOnWatchdog();
+ });
+ } else if (response == 'test2') {
+ chrome.runtime.restartOnWatchdog(2, function() {
+ // 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.
+ // be cancelled by test3.
+ assertTrue(chrome.runtime.lastError === undefined);
+ 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.
+ testRestartOnWatchdog();
+ });
+ });
+ } else if (response == 'test3') {
+ chrome.runtime.restartOnWatchdog(2, function() {
+ assertTrue(chrome.runtime.lastError === undefined);
+ sendMessage('request2', function(response) {
+ testRestartOnWatchdog();
+ });
+ });
+ } else if (response == 'test4') {
+ // This cancels any previous restart request.
+ chrome.runtime.restartOnWatchdog(-1, function() {
+ assertTrue(chrome.runtime.lastError === undefined);
+ sendMessage('request3', function(response) {
+ testRestartOnWatchdog();
+ });
+ });
+ } else if (response == 'test5') {
+ // The test will wait for this request until the restart request is
+ // successfully accomplished.
+ chrome.runtime.restartOnWatchdog(3, function() {
+ assertTrue(chrome.runtime.lastError === undefined);
+ sendMessage('request4', function(response) {
+ testRestartOnWatchdog();
+ });
+ });
+ } else if (response = 'test6') {
+ // Too soon request after a successful restart. It will be throttled and
+ // 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
+ chrome.runtime.restartOnWatchdog(1, function() {
+ assertTrue(chrome.runtime.lastError === undefined);
+ sendMessage('request5', function(response) {
+ testRestartOnWatchdog();
+ });
+ });
+ } 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.
+ return;
+ }
+ });
+}
+
+testRestartOnWatchdog();

Powered by Google App Engine
This is Rietveld 408576698