Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: chrome/test/data/extensions/api_test/app_background_page/basic/test.html

Issue 8760001: Update these manifest.json files to mainfest_version 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <script> 1 <!--
2 // This test runs through an expected use of a live background page: 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
3 // - A live (web-extent) web page is loaded (a.html), which opens the background 3 * source code is governed by a BSD-style license that can be found in the
4 // page. 4 * LICENSE file.
5 // - The first page is closed and a second live web page is loaded (b.html), 5 -->
6 // which attempts to get still-running running background page. This second 6 <script src="test.js"></script>
7 // page also checks a counter which should have a value consistent with being
8 // called once from each of the first and second pages.
9 // - The background page closes itself.
10
11 var pageA;
12 var pageB;
13 var backgroundPageResponded = false;
14
15 var pagePrefix =
16 'http://a.com:PORT/files/extensions/api_test/app_background_page/common';
17
18 // Dispatch "tunneled" functions from the live web pages to this testing page.
19 chrome.extension.onRequest.addListener(function(request) {
20 window[request.name](request.args);
21 });
22
23 // At no point should a window be created that contains the background page
24 // (bg.html).
25 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
26 if (tab.url.match("bg\.html$")) {
27 chrome.test.notifyFail("popup opened instead of background page");
28 }
29 });
30
31 // Start the test by opening the first page in the app.
32 window.onload = function() {
33 // We wait for window.onload before getting the test config. If the
34 // config is requested before onload, then sometimes onload has already
35 // fired by the time chrome.test.getConfig()'s callback runs.
36 chrome.test.getConfig(function(config) {
37 var a_url =
38 pagePrefix.replace(/PORT/, config.testServer.port) + '/a.html';
39 chrome.tabs.create({ 'url': a_url }, function(tab) {
40 pageA = tab;
41 });
42 });
43 }
44
45 // Background page opened by pageA.
46 function onBackgroundPageLoaded() {
47 chrome.tabs.remove(pageA.id, function() {
48 chrome.test.getConfig(function(config) {
49 var b_url =
50 pagePrefix.replace(/PORT/, config.testServer.port) + '/b.html';
51 chrome.tabs.create({ url: b_url }, function(tab) {
52 pageB = tab;
53 });
54 });
55 });
56 }
57
58 // Background page responded to pageB.
59 function onBackgroundPageResponded() {
60 backgroundPageResponded = true;
61 }
62
63 // Background page is closing itself.
64 function onBackgroundPageClosing() {
65 if (!backgroundPageResponded) {
66 chrome.test.notifyFail("background never responded to pageB");
67 } else {
68 chrome.test.notifyPass();
69 }
70 }
71
72 // The background counter check found an unexpected value (most likely caused
73 // by an unwanted navigation.
74 function onCounterError() {
75 chrome.test.notifyFail("checkCounter found an unexpected value");
76 }
77
78 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698