Left: | ||
Right: |
OLD | NEW |
---|---|
1 "use strict"; | 1 "use strict"; |
2 | 2 |
3 chrome.runtime.onMessage.addListener((message, sender, sendResponse) => | 3 // Firefox 55 erroneously sends messages from the content script to the |
4 // devtools panel: | |
5 // https://bugzilla.mozilla.org/show_bug.cgi?id=1383310 | |
6 // As a workaround, listen for messages only if this isn't the devtools panel. | |
7 if (!chrome.devtools) | |
4 { | 8 { |
5 return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != -1; | 9 // Listen for messages from the background page. |
Manish Jethani
2017/07/25 12:52:28
I've added this extra comment here to clarify what
| |
6 }); | 10 chrome.runtime.onMessage.addListener((message, sender, sendResponse) => |
11 { | |
12 return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != | |
13 -1; | |
14 }); | |
Wladimir Palant
2017/08/16 08:56:44
I might be missing something here, but this way th
Manish Jethani
2017/08/16 09:18:54
Yeah, so the devtools panel opens a persistent con
Wladimir Palant
2017/08/16 09:28:33
I see. So why is devtools-panel.html loading ext/c
Manish Jethani
2017/08/16 09:42:43
I went down that route [1] but decided to back off
Wladimir Palant
2017/08/16 10:05:19
You are right, doesn't seem to be worth it right n
| |
15 } | |
7 | 16 |
8 (function() | 17 (function() |
9 { | 18 { |
10 let port = null; | 19 let port = null; |
11 | 20 |
12 ext.onExtensionUnloaded = { | 21 ext.onExtensionUnloaded = { |
13 addListener(listener) | 22 addListener(listener) |
14 { | 23 { |
15 if (!port) | 24 if (!port) |
16 port = chrome.runtime.connect(); | 25 port = chrome.runtime.connect(); |
(...skipping 10 matching lines...) Expand all Loading... | |
27 | 36 |
28 if (!port.onDisconnect.hasListeners()) | 37 if (!port.onDisconnect.hasListeners()) |
29 { | 38 { |
30 port.disconnect(); | 39 port.disconnect(); |
31 port = null; | 40 port = null; |
32 } | 41 } |
33 } | 42 } |
34 } | 43 } |
35 }; | 44 }; |
36 }()); | 45 }()); |
OLD | NEW |