OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 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 // This test runs through an expected use of a live background page: | |
6 // - A live (web-extent) web page is loaded (a.html), which opens the background | |
7 // page. | |
8 // - The first page is closed and a second live web page is loaded (b.html), | |
9 // which attempts to get still-running running background page. This second | |
10 // page also checks a counter which should have a value consistent with being | |
11 // called once from each of the first and second pages. | |
12 // - The background page closes itself. | |
13 | |
14 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.
| |
15 | |
16 var pagePrefix = | |
17 'http://a.com:PORT/files/extensions/api_test/app_background_page/common'; | |
18 | |
19 // Dispatch "tunneled" functions from the live web pages to this testing page. | |
20 chrome.extension.onRequest.addListener(function(request) { | |
21 window[request.name](request.args); | |
22 }); | |
23 | |
24 // At no point should a window be created that contains the background page | |
25 // (bg.html). | |
26 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { | |
27 if (tab.url.match("bg\.html$")) { | |
28 chrome.test.notifyFail("popup opened instead of background page"); | |
29 } | |
30 }); | |
31 | |
32 // Start the test by opening the first page in the app. | |
33 window.onload = function() { | |
34 // We wait for window.onload before getting the test config. If the | |
35 // config is requested before onload, then sometimes onload has already | |
36 // fired by the time chrome.test.getConfig()'s callback runs. | |
37 chrome.test.getConfig(function(config) { | |
38 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.
| |
39 pagePrefix.replace(/PORT/, config.testServer.port) + '/close.html'; | |
40 chrome.tabs.create({ 'url': close_url }, function(tab) { | |
41 pageCloser = tab; | |
42 }); | |
43 }); | |
44 }; | |
45 | |
46 // Background page is closed now. | |
47 function onBackgroundPageClosed() { | |
48 chrome.test.notifyPass(); | |
49 }; | |
OLD | NEW |