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.
11 function set_failed(val) {
22 var test_url = "http://localhost:PORT/extensions/test_file.html";
24 // For running in normal chrome (ie outside of the browser_tests environment),
25 // set debug to 1 here.
28 test_url = "http://www.google.com";
29 chrome.test.log = function(msg) { console.log(msg) };
30 chrome.test.runTests = function(tests) {
31 for (var i in tests) {
35 chrome.test.succeed = function(){ console.log("succeed"); };
36 chrome.test.fail = function(){ console.log("fail"); };
40 chrome.test.runTests([
42 chrome.extension.onRequest.addListener(function(req, sender) {
43 chrome.test.log("got request: " + JSON.stringify(req));
46 } else if (req == "content_script_start") {
48 if (tab.url.indexOf("#") != -1) {
51 chrome.tabs.update(tab.id, {"url": tab.url + "#foo"});
55 chrome.tabs.onUpdated.addListener(function(tabid, info, tab) {
56 chrome.test.log("onUpdated status: " + info.status + " url:" + tab.url);
57 if (info.status == "complete" && tab.url.indexOf("#foo") != -1) {
58 setTimeout(function() {
60 chrome.test.succeed();
65 chrome.test.log("creating tab");
66 chrome.tabs.create({"url": test_url});
74 chrome.test.getConfig(function(config) {
75 test_url = test_url.replace(/PORT/, config.testServer.port);