1 // Copyright 2014 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 // Test that injecting an ad via tabs.executeScript doesn't circumvent
6 // detection. This is a very simple test, since the methods are tested much
7 // more extensively in the
8 // chrome/test/data/extensions/activity_log/ad_injection.
9 // If this test grows, it could use the same setup as that test, but there's no
10 // need for that at the time.
12 var didInject = false;
14 "document.body.appendChild(document.createElement('iframe')).src = " +
15 "'http://www.known-ads.adnetwork';";
18 * Injects an ad into the tab using chrome.tabs.executeScript().
19 * @param {number} tabId The id of the tab to inject into.
21 function injectScript(tabId) {
22 console.log('injectScript');
24 console.log('injecting');
26 chrome.tabs.executeScript(tabId, {code: code}, function() {
27 console.log('injected');
28 chrome.test.sendMessage('Done');
33 // Inject the script when the tab is updated.
34 chrome.tabs.onUpdated.addListener(injectScript);