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

Side by Side Diff: chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html

Issue 262016: Implement chrome.extension.connectExternal and fix various API inconsistencies. (Closed)
Patch Set: addressed comments Created 11 years, 2 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
« no previous file with comments | « chrome/test/data/extensions/api_test/connect_external/manifest.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <script> 1 <script>
2 window.onload = function() { 2 window.onload = function() {
3 chrome.extension.onConnect.addListener(function(port) { 3 chrome.extension.onConnect.addListener(function(port) {
4 console.log('onConnect'); 4 console.log('onConnect');
5 port.onMessage.addListener(function(msg) { 5 port.onMessage.addListener(function(msg) {
6 console.log('got message'); 6 console.log('got message');
7 if (msg.testPostMessageFromTab) { 7 if (msg.testPostMessageFromTab) {
8 port.postMessage({success: true, portName: port.name}); 8 port.postMessage({success: true, portName: port.name});
9 console.log('sent success'); 9 console.log('sent success');
10 } 10 }
11 // Ignore other messages since they are from us. 11 // Ignore other messages since they are from us.
12 }); 12 });
13 }); 13 });
14 chrome.extension.onConnectExternal.addListener(function(port) {
15 port.onMessage.addListener(function(msg) {
16 if (msg.testConnectExternal) {
17 port.postMessage({success: true, senderId: port.sender.id});
18 }
19 });
20 });
14 }; 21 };
15 22
16 // Tests that postMessage to the tab and its response works. 23 // Tests that postMessage to the tab and its response works.
17 function testPostMessage() { 24 function testPostMessage() {
18 chrome.tabs.getSelected(null, function(tab) { 25 chrome.tabs.getSelected(null, function(tab) {
19 var port = chrome.tabs.connect(tab.id); 26 var port = chrome.tabs.connect(tab.id);
20 console.log('connect to ' + tab.id); 27 console.log('connect to ' + tab.id);
21 port.postMessage({testPostMessage: true}); 28 port.postMessage({testPostMessage: true});
22 port.onMessage.addListener(function(msg) { 29 port.onMessage.addListener(function(msg) {
23 window.domAutomationController.send(msg.success); 30 window.domAutomationController.send(msg.success);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 chrome.tabs.getSelected(null, function(tab) { 78 chrome.tabs.getSelected(null, function(tab) {
72 var port = chrome.tabs.connect(tab.id); 79 var port = chrome.tabs.connect(tab.id);
73 console.log('connect to ' + tab.id); 80 console.log('connect to ' + tab.id);
74 port.postMessage({testDisconnectOnClose: true}); 81 port.postMessage({testDisconnectOnClose: true});
75 port.onDisconnect.addListener(function() { 82 port.onDisconnect.addListener(function() {
76 window.domAutomationController.send(true); 83 window.domAutomationController.send(true);
77 }); 84 });
78 }); 85 });
79 } 86 }
80 </script> 87 </script>
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/connect_external/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698