OLD | NEW |
1 <script> | 1 <!-- |
2 var receivedRequests = {}; | 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 chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { | 4 * LICENSE file. |
5 if (receivedRequests[request.source]) { | 5 --> |
6 chrome.test.fail( | 6 <script src="background.js"></script> |
7 'Received multiple requests from "' + request.source + '".'); | |
8 return; | |
9 } | |
10 | |
11 chrome.test.assertEq(request.source == 'a.com', request.modified); | |
12 receivedRequests[request.source] = true; | |
13 if (receivedRequests['a.com'] && receivedRequests['b.com']) | |
14 chrome.test.succeed(); | |
15 }); | |
16 | |
17 // We load two pages. On a.com, both our modify and test script will run and we | |
18 // will receive a request that says that the page was modified. On b.com, only | |
19 // the test script will run, and the request will say that the page was not | |
20 // modified. | |
21 chrome.test.getConfig(function(config) { | |
22 chrome.tabs.create({ | |
23 url: 'http://a.com:' + config.testServer.port + | |
24 '/files/extensions/test_file.html'}); | |
25 chrome.tabs.create({ | |
26 url: 'http://b.com:' + config.testServer.port + | |
27 '/files/extensions/test_file.html'}); | |
28 }); | |
29 </script> | |
OLD | NEW |