Revert "Only store leading 13 bits of password hash."
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / executescript / fragment / background.js
blobde101fb02ff3872dc9de9f8cc386cfecb7c2afb3
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.
5 var got_request = false;
7 var test_url = "http://localhost:PORT/extensions/test_file.html";
9 // For running in normal chrome (ie outside of the browser_tests environment),
10 // set debug to 1 here.
11 var debug = 0;
12 if (debug) {
13 test_url = "http://www.google.com/";
14 chrome.test.log = function(msg) { console.log(msg) };
15 chrome.test.runTests = function(tests) {
16 for (var i in tests) {
17 tests[i]();
20 chrome.test.succeed = function(){ console.log("succeed"); };
21 chrome.test.fail = function(){ console.log("fail"); };
24 function navigate_to_fragment(tab, callback) {
25 var new_url = test_url + "#foo";
26 chrome.test.log("navigating tab to " + new_url);
27 chrome.tabs.update(tab.id, {"url": new_url}, callback);
30 var succeeded = false;
32 function do_execute(tab) {
33 chrome.tabs.executeScript(tab.id, {"file": "execute_script.js"});
34 setTimeout(function() {
35 if (!succeeded) {
36 chrome.test.fail("timed out");
38 }, 10000);
41 function runTests() {
42 chrome.test.runTests([
43 // When the tab is created, a content script will send a request letting
44 // know the onload has fired. Then we navigate to a fragment, and try
45 // running chrome.tabs.executeScript.
46 function test1() {
47 chrome.extension.onRequest.addListener(function(req, sender) {
48 chrome.test.log("got request: " + JSON.stringify(req));
49 if (req == "content_script") {
50 navigate_to_fragment(sender.tab, do_execute);
51 } else if (req == "execute_script") {
52 suceeded = true;
53 chrome.test.succeed();
55 });
56 chrome.test.log("creating tab");
57 chrome.tabs.create({"url": test_url});
59 ]);
62 if (debug) {
63 // No port to fix. Run tests directly.
64 runTests();
65 } else {
66 chrome.test.getConfig(function(config) {
67 test_url = test_url.replace(/PORT/, config.testServer.port);
68 runTests();
69 });