OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 opens a single background page opened by a.html. |
| 6 |
| 7 var pagePrefix = |
| 8 'http://a.com:PORT/files/extensions/api_test/app_background_page/common'; |
| 9 |
| 10 // Dispatch "tunneled" functions from the live web pages to this testing page. |
| 11 chrome.extension.onRequest.addListener(function(request) { |
| 12 window[request.name](request.args); |
| 13 }); |
| 14 |
| 15 // At no point should a window be created that contains the background page |
| 16 // (bg.html). |
| 17 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { |
| 18 if (tab.url.match("bg\.html$")) { |
| 19 chrome.test.notifyFail("popup opened instead of background page"); |
| 20 } |
| 21 }); |
| 22 |
| 23 // Start the test by opening the first page in the app. |
| 24 window.onload = function() { |
| 25 // We wait for window.onload before getting the test config. If the |
| 26 // config is requested before onload, then sometimes onload has already |
| 27 // fired by the time chrome.test.getConfig()'s callback runs. |
| 28 chrome.test.getConfig(function(config) { |
| 29 var closeUrl = |
| 30 pagePrefix.replace(/PORT/, config.testServer.port) + '/a.html'; |
| 31 chrome.tabs.create({ 'url': closeUrl }, function(tab) {}); |
| 32 }); |
| 33 }; |
| 34 |
| 35 // Background page is open now. |
| 36 function onBackgroundPageLoaded() { |
| 37 chrome.test.notifyPass(); |
| 38 }; |
OLD | NEW |