OLD | NEW |
(Empty) | |
| 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 baseUrl = 'http://a.com:PORT/files/extensions/api_test/executescript/' + |
| 6 'frame_after_load/'; |
| 7 |
| 8 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { |
| 9 if (changeInfo.status != 'complete') |
| 10 return; |
| 11 |
| 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 = 'var frame = document.createElement("iframe");' + |
| 17 'frame.src = "' + baseUrl + 'inner.html";' + |
| 18 'frame.onload = function() {chrome.extension.connect().postMessage("lo
aded")};' + |
| 19 'document.body.appendChild(frame)'; |
| 20 var postFrameCode = 'chrome.extension.connect().postMessage("done");'; |
| 21 |
| 22 chrome.self.onConnect.addListener(function(port) { |
| 23 port.onMessage.addListener(function(data) { |
| 24 if (data == 'loaded') { |
| 25 chrome.tabs.executeScript(tabId, {code: postFrameCode}); |
| 26 } else if (data == 'done') { |
| 27 chrome.test.succeed(); |
| 28 } |
| 29 }); |
| 30 }); |
| 31 chrome.tabs.executeScript(tabId, {code: injectFrameCode}); |
| 32 } |
| 33 ]); |
| 34 }); |
| 35 |
| 36 chrome.test.getConfig(function(config) { |
| 37 baseUrl = baseUrl.replace(/PORT/, config.testServer.port); |
| 38 chrome.tabs.create({ url: baseUrl + 'outer.html' }); |
| 39 }); |
OLD | NEW |