| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 "use strict"; | 1 "use strict"; |
| 2 | 2 |
| 3 // Firefox 55 erroneously sends messages from the content script to the | 3 // Firefox 55 erroneously sends messages from the content script to the |
| 4 // devtools panel: | 4 // devtools panel: |
| 5 // https://bugzilla.mozilla.org/show_bug.cgi?id=1383310 | 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. | 6 // As a workaround, listen for messages only if this isn't the devtools panel. |
| 7 if (!chrome.devtools) | 7 if (!("devtools" in chrome)) |
| 8 { | 8 { |
| 9 // Listen for messages from the background page. | 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
| |
| 10 chrome.runtime.onMessage.addListener((message, sender, sendResponse) => | 10 chrome.runtime.onMessage.addListener((message, sender, sendResponse) => |
| 11 { | 11 { |
| 12 return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != | 12 return ext.onMessage._dispatch(message, {}, sendResponse).includes(true); |
| 13 -1; | |
| 14 }); | 13 }); |
|
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 } | 14 } |
| 16 | 15 |
| 17 (function() | 16 (function() |
| 18 { | 17 { |
| 19 let port = null; | 18 let port = null; |
| 20 | 19 |
| 21 ext.onExtensionUnloaded = { | 20 ext.onExtensionUnloaded = { |
| 22 addListener(listener) | 21 addListener(listener) |
| 23 { | 22 { |
| 24 if (!port) | 23 if (!port) |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 36 | 35 |
| 37 if (!port.onDisconnect.hasListeners()) | 36 if (!port.onDisconnect.hasListeners()) |
| 38 { | 37 { |
| 39 port.disconnect(); | 38 port.disconnect(); |
| 40 port = null; | 39 port = null; |
| 41 } | 40 } |
| 42 } | 41 } |
| 43 } | 42 } |
| 44 }; | 43 }; |
| 45 }()); | 44 }()); |
| LEFT | RIGHT |