| OLD | NEW |
| 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 |
| 1 var win = window; | 5 var win = window; |
| 2 if (typeof(contentWindow) != 'undefined') { | 6 if (typeof(contentWindow) != 'undefined') { |
| 3 win = contentWindow; | 7 win = contentWindow; |
| 4 } | 8 } |
| 5 | 9 |
| 6 chrome.extension.onConnect.addListener(function(port) { | 10 chrome.extension.onConnect.addListener(function(port) { |
| 7 console.log('connected'); | 11 console.log('connected'); |
| 8 port.onMessage.addListener(function(msg) { | 12 port.onMessage.addListener(function(msg) { |
| 9 console.log('got ' + msg); | 13 console.log('got ' + msg); |
| 10 if (msg.testPostMessage) { | 14 if (msg.testPostMessage) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 }); | 39 }); |
| 36 console.log('posted message'); | 40 console.log('posted message'); |
| 37 } | 41 } |
| 38 | 42 |
| 39 // Workaround two bugs: shutdown crash if we hook 'unload', and content script | 43 // Workaround two bugs: shutdown crash if we hook 'unload', and content script |
| 40 // GC if we don't register any event handlers. | 44 // GC if we don't register any event handlers. |
| 41 // http://code.google.com/p/chromium/issues/detail?id=17410 | 45 // http://code.google.com/p/chromium/issues/detail?id=17410 |
| 42 // http://code.google.com/p/chromium/issues/detail?id=17582 | 46 // http://code.google.com/p/chromium/issues/detail?id=17582 |
| 43 function foo() {} | 47 function foo() {} |
| 44 win.addEventListener('error', foo); | 48 win.addEventListener('error', foo); |
| OLD | NEW |