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 / frame_after_load / test.js
blobc2aa092b9283f730e40adeb2180068f7d78f1049
1 // Copyright (c) 2012 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 var baseUrl = 'http://a.com:PORT/extensions/api_test/executescript/' +
6 'frame_after_load/';
8 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
9 if (changeInfo.status != 'complete')
10 return;
12 chrome.test.runTests([
13 function() {
14 // Tests that we can still execute scripts after a frame has loaded after
15 // the main document has completed.
16 var injectFrameCode =
17 'var frame = document.createElement("iframe");\n' +
18 'frame.src = "' + baseUrl + 'inner.html";\n' +
19 'frame.onload = function() {\n' +
20 ' chrome.runtime.connect().postMessage("loaded");\n' +
21 '};\n' +
22 'document.body.appendChild(frame);';
23 var postFrameCode = 'chrome.runtime.connect().postMessage("done");';
25 chrome.runtime.onConnect.addListener(function(port) {
26 port.onMessage.addListener(function(data) {
27 if (data == 'loaded') {
28 chrome.tabs.executeScript(tabId, {code: postFrameCode});
29 } else if (data == 'done') {
30 chrome.test.succeed();
32 });
33 });
34 chrome.tabs.executeScript(tabId, {code: injectFrameCode});
36 ]);
37 });
39 chrome.test.getConfig(function(config) {
40 baseUrl = baseUrl.replace(/PORT/, config.testServer.port);
41 chrome.tabs.create({ url: baseUrl + 'outer.html' });
42 });