Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / executescript / subframes_on_load / test.js
blob4480f1af42f31bd6b208458e83461a4d8a0798c3
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
8 // into don't exist.
9 if (changeInfo.status != 'complete')
10 return;
12 chrome.test.runTests([
13 function() {
14 var injectFrameCode = 'chrome.runtime.sendMessage("ping");';
15 var pings = 0;
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.
20 if (++pings == 2)
21 chrome.test.succeed();
22 });
23 chrome.tabs.executeScript(
24 tabId,
25 {code: injectFrameCode, allFrames: true, runAt: 'document_idle'});
27 ]);
28 });
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});
35 });