| Index: chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html
|
| diff --git a/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html b/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html
|
| index a8bfe7e67a19738d9fd8cc2be7ff228f97a6d181..84c7db0feeff900362d8af7b36519f6b83104d96 100644
|
| --- a/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html
|
| +++ b/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html
|
| @@ -1,65 +1,80 @@
|
| -<script>
|
| -window.onload = function() {
|
| - chrome.extension.onConnect.addListener(function(port) {
|
| - console.log('onConnect');
|
| - port.onMessage.addListener(function(msg) {
|
| - console.log('got message');
|
| - if (msg.testPostMessageFromTab) {
|
| - port.postMessage({success: true});
|
| - console.log('sent success');
|
| - }
|
| - // Ignore other messages since they are from us.
|
| - });
|
| - });
|
| -};
|
| -
|
| -// Tests that postMessage to the tab and its response works.
|
| -function testPostMessage() {
|
| - chrome.tabs.getSelected(null, function(tab) {
|
| - var port = chrome.tabs.connect(tab.id);
|
| - console.log('connect to ' + tab.id);
|
| - port.postMessage({testPostMessage: true});
|
| - port.onMessage.addListener(function(msg) {
|
| - window.domAutomationController.send(msg.success);
|
| - port.disconnect();
|
| - });
|
| - });
|
| -}
|
| -
|
| -// Tests that postMessage from the tab and its response works.
|
| -function testPostMessageFromTab() {
|
| - chrome.tabs.getSelected(null, function(tab) {
|
| - var port = chrome.tabs.connect(tab.id);
|
| - console.log('connect to ' + tab.id);
|
| - port.postMessage({testPostMessageFromTab: true});
|
| - port.onMessage.addListener(function(msg) {
|
| - window.domAutomationController.send(msg.success);
|
| - port.disconnect();
|
| - });
|
| - });
|
| -}
|
| -
|
| -// Tests that we get the disconnect event when the tab disconnect.
|
| -function testDisconnect() {
|
| - chrome.tabs.getSelected(null, function(tab) {
|
| - var port = chrome.tabs.connect(tab.id);
|
| - console.log('connect to ' + tab.id);
|
| - port.postMessage({testDisconnect: true});
|
| - port.onDisconnect.addListener(function() {
|
| - window.domAutomationController.send(true);
|
| - });
|
| - });
|
| -}
|
| -
|
| -// Tests that we get the disconnect event when the tab context closes.
|
| -function testDisconnectOnClose() {
|
| - chrome.tabs.getSelected(null, function(tab) {
|
| - var port = chrome.tabs.connect(tab.id);
|
| - console.log('connect to ' + tab.id);
|
| - port.postMessage({testDisconnectOnClose: true});
|
| - port.onDisconnect.addListener(function() {
|
| - window.domAutomationController.send(true);
|
| - });
|
| - });
|
| -}
|
| -</script>
|
| +<script>
|
| +window.onload = function() {
|
| + chrome.extension.onConnect.addListener(function(port) {
|
| + console.log('onConnect');
|
| + port.onMessage.addListener(function(msg) {
|
| + console.log('got message');
|
| + if (msg.testPostMessageFromTab) {
|
| + port.postMessage({success: true, portName: port.name});
|
| + console.log('sent success');
|
| + }
|
| + // Ignore other messages since they are from us.
|
| + });
|
| + });
|
| +};
|
| +
|
| +// Tests that postMessage to the tab and its response works.
|
| +function testPostMessage() {
|
| + chrome.tabs.getSelected(null, function(tab) {
|
| + var port = chrome.tabs.connect(tab.id);
|
| + console.log('connect to ' + tab.id);
|
| + port.postMessage({testPostMessage: true});
|
| + port.onMessage.addListener(function(msg) {
|
| + window.domAutomationController.send(msg.success);
|
| + port.disconnect();
|
| + });
|
| + });
|
| +}
|
| +
|
| +// Tests that port name is sent & received correctly.
|
| +function testPortName() {
|
| + chrome.tabs.getSelected(null, function(tab) {
|
| + var portName = "lemonjello";
|
| + var port = chrome.tabs.connect(tab.id, {name: portName});
|
| + console.log('naming port ' + portName);
|
| + port.postMessage({testPortName: true});
|
| + port.onMessage.addListener(function(msg) {
|
| + console.log('got name ' + msg.portName);
|
| + window.domAutomationController.send(msg.portName == portName);
|
| + port.disconnect();
|
| + });
|
| + });
|
| +}
|
| +
|
| +// Tests that postMessage from the tab and its response works.
|
| +function testPostMessageFromTab() {
|
| + chrome.tabs.getSelected(null, function(tab) {
|
| + var port = chrome.tabs.connect(tab.id);
|
| + console.log('connect to ' + tab.id);
|
| + port.postMessage({testPostMessageFromTab: true});
|
| + port.onMessage.addListener(function(msg) {
|
| + window.domAutomationController.send(msg.success);
|
| + port.disconnect();
|
| + });
|
| + });
|
| +}
|
| +
|
| +// Tests that we get the disconnect event when the tab disconnect.
|
| +function testDisconnect() {
|
| + chrome.tabs.getSelected(null, function(tab) {
|
| + var port = chrome.tabs.connect(tab.id);
|
| + console.log('connect to ' + tab.id);
|
| + port.postMessage({testDisconnect: true});
|
| + port.onDisconnect.addListener(function() {
|
| + window.domAutomationController.send(true);
|
| + });
|
| + });
|
| +}
|
| +
|
| +// Tests that we get the disconnect event when the tab context closes.
|
| +function testDisconnectOnClose() {
|
| + chrome.tabs.getSelected(null, function(tab) {
|
| + var port = chrome.tabs.connect(tab.id);
|
| + console.log('connect to ' + tab.id);
|
| + port.postMessage({testDisconnectOnClose: true});
|
| + port.onDisconnect.addListener(function() {
|
| + window.domAutomationController.send(true);
|
| + });
|
| + });
|
| +}
|
| +</script>
|
|
|