1 // Copyright 2015 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 chrome
.tabs
.onUpdated
.addListener(function(tabId
, changeInfo
, tab
) {
6 // If we want to inject into subframes using execute script, we need to wait
7 // for the tab to finish loading. Otherwise, the frames that would be injected
9 if (changeInfo
.status
!= 'complete')
12 chrome
.test
.runTests([
14 var injectFrameCode
= 'chrome.runtime.sendMessage("ping");';
16 chrome
.runtime
.onMessage
.addListener(
17 function(request
, sender
, sendResponse
) {
18 chrome
.test
.assertEq(request
, "ping");
19 // Wait for two pings - the main frame and the iframe.
21 chrome
.test
.succeed();
23 chrome
.tabs
.executeScript(
25 {code
: injectFrameCode
, allFrames
: true, runAt
: 'document_idle'});
30 chrome
.test
.getConfig(function(config
) {
31 var url
= ('http://a.com:PORT/extensions/api_test/executescript/' +
32 'subframes_on_load/outer.html').replace(/PORT
/,
33 config
.testServer
.port
);
34 chrome
.tabs
.create({url
: url
});