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

Unified Diff: chrome/test/data/extensions/api_test/lazy_background_page/wait_for_request/background.js

Issue 9562017: Keep lazy background page alive while there are pending network requests or (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fixins Created 8 years, 10 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/lazy_background_page/wait_for_request/background.js
diff --git a/chrome/test/data/extensions/api_test/lazy_background_page/wait_for_request/background.js b/chrome/test/data/extensions/api_test/lazy_background_page/wait_for_request/background.js
new file mode 100644
index 0000000000000000000000000000000000000000..c17447b2b74eadc741fced6f895eefa1a4806ba7
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/lazy_background_page/wait_for_request/background.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 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 testServerHost = "www.a.com";
+var testServerPort;
+function getServerURL(path) {
+ var host = testServerHost;
+ return "http://" + host + ":" + testServerPort + "/" + path;
+}
+
+var hangingRequest;
+function abortRequest() {
+ hangingRequest.abort();
+ window.domAutomationController.send(true);
+}
+
+chrome.experimental.extension.onInstalled.addListener(function() {
+ chrome.test.getConfig(function(config) {
+ testServerPort = config.testServer.port;
+
+ // Start a request that will "never" finish (at least, not for 1000
+ // minutes). The browser code will keep us alive until the request is
+ // killed.
+ hangingRequest = new XMLHttpRequest();
+ hangingRequest.onreadystatechange = function() {
+ // The request hangs, so this is only ever called once.
+ chrome.test.notifyPass();
+ }
+ hangingRequest.open("GET", getServerURL("slow?60000"), true);
+ hangingRequest.send(null);
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698