Index: chrome/test/data/extensions/api_test/app_background_page/basic_close/test.js |
diff --git a/chrome/test/data/extensions/api_test/app_background_page/basic_close/test.js b/chrome/test/data/extensions/api_test/app_background_page/basic_close/test.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..08da01c5b981ae706509f80af32e1080bb31f8c9 |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/app_background_page/basic_close/test.js |
@@ -0,0 +1,49 @@ |
+// Copyright (c) 2011 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. |
+ |
+// This test runs through an expected use of a live background page: |
+// - A live (web-extent) web page is loaded (a.html), which opens the background |
+// page. |
+// - The first page is closed and a second live web page is loaded (b.html), |
+// which attempts to get still-running running background page. This second |
+// page also checks a counter which should have a value consistent with being |
+// called once from each of the first and second pages. |
+// - The background page closes itself. |
+ |
+var pageCloser; |
Mihai Parparita -not on Chrome
2012/05/03 00:54:11
This seems unused (it's set, but never read).
Andrew T Wilson (Slow)
2012/05/03 07:42:56
Done.
|
+ |
+var pagePrefix = |
+ 'http://a.com:PORT/files/extensions/api_test/app_background_page/common'; |
+ |
+// Dispatch "tunneled" functions from the live web pages to this testing page. |
+chrome.extension.onRequest.addListener(function(request) { |
+ window[request.name](request.args); |
+}); |
+ |
+// At no point should a window be created that contains the background page |
+// (bg.html). |
+chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { |
+ if (tab.url.match("bg\.html$")) { |
+ chrome.test.notifyFail("popup opened instead of background page"); |
+ } |
+}); |
+ |
+// Start the test by opening the first page in the app. |
+window.onload = function() { |
+ // We wait for window.onload before getting the test config. If the |
+ // config is requested before onload, then sometimes onload has already |
+ // fired by the time chrome.test.getConfig()'s callback runs. |
+ chrome.test.getConfig(function(config) { |
+ var close_url = |
Mihai Parparita -not on Chrome
2012/05/03 00:54:11
Nit: this should be called closeUrl.
Andrew T Wilson (Slow)
2012/05/03 07:42:56
Done.
|
+ pagePrefix.replace(/PORT/, config.testServer.port) + '/close.html'; |
+ chrome.tabs.create({ 'url': close_url }, function(tab) { |
+ pageCloser = tab; |
+ }); |
+ }); |
+}; |
+ |
+// Background page is closed now. |
+function onBackgroundPageClosed() { |
+ chrome.test.notifyPass(); |
+}; |