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

Side by Side Diff: chrome/test/data/extensions/api_test/content_scripts/fragment/background.html

Issue 8725019: Move another bunch of extension API tests to manifest_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 var failed = false; 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
3 3 * source code is governed by a BSD-style license that can be found in the
4 function did_fail() { 4 * LICENSE file.
5 return failed; 5 -->
6 } 6 <script src="background.js"></script>
7
8 function set_failed(val) {
9 failed = val;
10 }
11
12 function fail() {
13 set_failed(true);
14 if (!did_fail()) {
15 chrome.test.fail();
16 }
17 }
18
19 var test_url = "http://localhost:PORT/files/extensions/test_file.html";
20
21 // For running in normal chrome (ie outside of the browser_tests environment),
22 // set debug to 1 here.
23 var debug = 0;
24 if (debug) {
25 test_url = "http://www.google.com";
26 chrome.test.log = function(msg) { console.log(msg) };
27 chrome.test.runTests = function(tests) {
28 for (var i in tests) {
29 tests[i]();
30 }
31 };
32 chrome.test.succeed = function(){ console.log("succeed"); };
33 chrome.test.fail = function(){ console.log("fail"); };
34 }
35
36 function runTests() {
37 chrome.test.runTests([
38 function test1() {
39 chrome.extension.onRequest.addListener(function(req, sender) {
40 chrome.test.log("got request: " + JSON.stringify(req));
41 if (req == "fail") {
42 fail();
43 } else if (req == "content_script_start") {
44 var tab = sender.tab;
45 if (tab.url.indexOf("#") != -1) {
46 fail();
47 } else {
48 chrome.tabs.update(tab.id, {"url": tab.url + "#foo"});
49 }
50 }
51 });
52 chrome.tabs.onUpdated.addListener(function(tabid, info, tab) {
53 chrome.test.log("onUpdated status: " + info.status + " url:" + tab.url);
54 if (info.status == "complete" && tab.url.indexOf("#foo") != -1) {
55 setTimeout(function() {
56 if (!did_fail()) {
57 chrome.test.succeed();
58 }
59 }, 750);
60 }
61 });
62 chrome.test.log("creating tab");
63 chrome.tabs.create({"url": test_url});
64 }
65 ]);
66 }
67
68 if (debug) {
69 runTests();
70 } else {
71 chrome.test.getConfig(function(config) {
72 test_url = test_url.replace(/PORT/, config.testServer.port);
73 runTests();
74 });
75 }
76
77 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698