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