OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This test runs through an expected use of a live background page: | 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 | 6 // - A live (web-extent) web page is loaded (a.html), which opens the background |
7 // page. | 7 // page. |
8 // - The first page is closed and a second live web page is loaded (b.html), | 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 | 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 | 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. | 11 // called once from each of the first and second pages. |
12 // - The background page closes itself. | 12 // - The background page closes itself. |
13 | 13 |
14 var pageA; | 14 var pageA; |
15 var pageB; | 15 var pageB; |
16 var backgroundPageResponded = false; | 16 var backgroundPageResponded = false; |
17 | 17 |
18 var pagePrefix = | 18 var pagePrefix = |
19 'http://a.com:PORT/files/extensions/api_test/app_background_page/common'; | 19 'http://a.com:PORT/extensions/api_test/app_background_page/common'; |
20 | 20 |
21 // Dispatch "tunneled" functions from the live web pages to this testing page. | 21 // Dispatch "tunneled" functions from the live web pages to this testing page. |
22 chrome.extension.onRequest.addListener(function(request) { | 22 chrome.extension.onRequest.addListener(function(request) { |
23 window[request.name](request.args); | 23 window[request.name](request.args); |
24 }); | 24 }); |
25 | 25 |
26 // At no point should a window be created that contains the background page | 26 // At no point should a window be created that contains the background page |
27 // (bg.html). | 27 // (bg.html). |
28 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { | 28 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { |
29 if (tab.url.match("bg\.html$")) { | 29 if (tab.url.match("bg\.html$")) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } else { | 70 } else { |
71 chrome.test.notifyPass(); | 71 chrome.test.notifyPass(); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 // The background counter check found an unexpected value (most likely caused | 75 // The background counter check found an unexpected value (most likely caused |
76 // by an unwanted navigation. | 76 // by an unwanted navigation. |
77 function onCounterError() { | 77 function onCounterError() { |
78 chrome.test.notifyFail("checkCounter found an unexpected value"); | 78 chrome.test.notifyFail("checkCounter found an unexpected value"); |
79 } | 79 } |
OLD | NEW |