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

Side by Side Diff: chrome/test/data/extensions/api_test/executescript/in_frame/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 pass = chrome.test.callbackPass; 5 var pass = chrome.test.callbackPass;
6 var fail = chrome.test.callbackFail; 6 var fail = chrome.test.callbackFail;
7 var assertEq = chrome.test.assertEq; 7 var assertEq = chrome.test.assertEq;
8 var assertTrue = chrome.test.assertTrue; 8 var assertTrue = chrome.test.assertTrue;
9 var relativePath = 9 var relativePath =
10 '/files/extensions/api_test/executescript/in_frame/test_executescript.html'; 10 '/files/extensions/api_test/executescript/in_frame/test_executescript.html';
11 var testUrl = 'http://a.com:PORT' + relativePath; 11 var testUrl = 'http://a.com:PORT' + relativePath;
12 12
13 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { 13 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
14 if (changeInfo.status != 'complete') 14 if (changeInfo.status != 'complete')
15 return; 15 return;
16 16
17 chrome.test.runTests([ 17 chrome.test.runTests([
18 function executeJavaScriptCodeInAllFramesShouldSucceed() { 18 function executeJavaScriptCodeInAllFramesShouldSucceed() {
19 var script_file = {}; 19 var script_file = {};
20 script_file.code = "var extensionPort = chrome.extension.connect();"; 20 script_file.code = "var extensionPort = chrome.runtime.connect();";
21 script_file.code = script_file.code + 21 script_file.code = script_file.code +
22 "extensionPort.postMessage({message: document.title});"; 22 "extensionPort.postMessage({message: document.title});";
23 script_file.allFrames = true; 23 script_file.allFrames = true;
24 var counter = 0; 24 var counter = 0;
25 var totalTitles = ''; 25 var totalTitles = '';
26 function eventListener(port) { 26 function eventListener(port) {
27 port.onMessage.addListener(function(data) { 27 port.onMessage.addListener(function(data) {
28 counter++; 28 counter++;
29 totalTitles += data.message; 29 totalTitles += data.message;
30 }); 30 });
31 }; 31 };
32 chrome.extension.onConnect.addListener(eventListener); 32 chrome.runtime.onConnect.addListener(eventListener);
33 chrome.tabs.executeScript(tabId, script_file, pass(function() { 33 chrome.tabs.executeScript(tabId, script_file, pass(function() {
34 assertEq(counter, 5); 34 assertEq(counter, 5);
35 assertEq(totalTitles, 'frametest0test1test2test3'); 35 assertEq(totalTitles, 'frametest0test1test2test3');
36 chrome.extension.onConnect.removeListener(eventListener); 36 chrome.runtime.onConnect.removeListener(eventListener);
37 })); 37 }));
38 }, 38 },
39 39
40 function insertCSSTextInAllFramesShouldSucceed() { 40 function insertCSSTextInAllFramesShouldSucceed() {
41 var css_file = {}; 41 var css_file = {};
42 css_file.code = "p {display:none;}"; 42 css_file.code = "p {display:none;}";
43 css_file.allFrames = true; 43 css_file.allFrames = true;
44 var newStyle = ''; 44 var newStyle = '';
45 var counter = 0; 45 var counter = 0;
46 function eventListener(port) { 46 function eventListener(port) {
47 port.onMessage.addListener(function(data) { 47 port.onMessage.addListener(function(data) {
48 counter++; 48 counter++;
49 newStyle += data.message; 49 newStyle += data.message;
50 }); 50 });
51 }; 51 };
52 chrome.extension.onConnect.addListener(eventListener); 52 chrome.runtime.onConnect.addListener(eventListener);
53 chrome.tabs.insertCSS(tabId, css_file, function() { 53 chrome.tabs.insertCSS(tabId, css_file, function() {
54 var script_file = {}; 54 var script_file = {};
55 script_file.file = 'script.js'; 55 script_file.file = 'script.js';
56 script_file.allFrames = true; 56 script_file.allFrames = true;
57 chrome.tabs.executeScript(tabId, script_file, 57 chrome.tabs.executeScript(tabId, script_file,
58 pass(function() { 58 pass(function() {
59 assertEq(newStyle, 'nonenonenonenone'); 59 assertEq(newStyle, 'nonenonenonenone');
60 assertEq(counter, 4); 60 assertEq(counter, 4);
61 chrome.extension.onConnect.removeListener(eventListener); 61 chrome.runtime.onConnect.removeListener(eventListener);
62 })); 62 }));
63 }); 63 });
64 } 64 }
65 ]); 65 ]);
66 }); 66 });
67 67
68 chrome.test.getConfig(function(config) { 68 chrome.test.getConfig(function(config) {
69 testUrl = testUrl.replace(/PORT/, config.testServer.port); 69 testUrl = testUrl.replace(/PORT/, config.testServer.port);
70 chrome.tabs.create({ url: testUrl }); 70 chrome.tabs.create({ url: testUrl });
71 }); 71 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698