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 |
Yoyo Zhou
2012/03/02 03:10:46
I'm mildly surprised that the test server doesn't
|
+ // 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); |
+ }); |
+}); |