Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/test/data/extensions/api_test/executescript/frame_after_load/test.js

Issue 11745015: Update references to the extension messaging APIs to point to the "runtime" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var baseUrl = 'http://a.com:PORT/files/extensions/api_test/executescript/' + 5 var baseUrl = 'http://a.com:PORT/files/extensions/api_test/executescript/' +
6 'frame_after_load/'; 6 'frame_after_load/';
7 7
8 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { 8 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
9 if (changeInfo.status != 'complete') 9 if (changeInfo.status != 'complete')
10 return; 10 return;
11 11
12 chrome.test.runTests([ 12 chrome.test.runTests([
13 function() { 13 function() {
14 // Tests that we can still execute scripts after a frame has loaded after 14 // Tests that we can still execute scripts after a frame has loaded after
15 // the main document has completed. 15 // the main document has completed.
16 var injectFrameCode = 'var frame = document.createElement("iframe");' + 16 var injectFrameCode =
17 'frame.src = "' + baseUrl + 'inner.html";' + 17 'var frame = document.createElement("iframe");\n' +
18 'frame.onload = function() {chrome.extension.connect().postMessage("lo aded")};' + 18 'frame.src = "' + baseUrl + 'inner.html";\n' +
19 'document.body.appendChild(frame)'; 19 'frame.onload = function() {\n' +
20 var postFrameCode = 'chrome.extension.connect().postMessage("done");'; 20 ' chrome.runtime.connect().postMessage("loaded");\n' +
21 '};\n' +
22 'document.body.appendChild(frame);';
23 var postFrameCode = 'chrome.runtime.connect().postMessage("done");';
21 24
22 chrome.extension.onConnect.addListener(function(port) { 25 chrome.runtime.onConnect.addListener(function(port) {
23 port.onMessage.addListener(function(data) { 26 port.onMessage.addListener(function(data) {
24 if (data == 'loaded') { 27 if (data == 'loaded') {
25 chrome.tabs.executeScript(tabId, {code: postFrameCode}); 28 chrome.tabs.executeScript(tabId, {code: postFrameCode});
26 } else if (data == 'done') { 29 } else if (data == 'done') {
27 chrome.test.succeed(); 30 chrome.test.succeed();
28 } 31 }
29 }); 32 });
30 }); 33 });
31 chrome.tabs.executeScript(tabId, {code: injectFrameCode}); 34 chrome.tabs.executeScript(tabId, {code: injectFrameCode});
32 } 35 }
33 ]); 36 ]);
34 }); 37 });
35 38
36 chrome.test.getConfig(function(config) { 39 chrome.test.getConfig(function(config) {
37 baseUrl = baseUrl.replace(/PORT/, config.testServer.port); 40 baseUrl = baseUrl.replace(/PORT/, config.testServer.port);
38 chrome.tabs.create({ url: baseUrl + 'outer.html' }); 41 chrome.tabs.create({ url: baseUrl + 'outer.html' });
39 }); 42 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698