| OLD | NEW |
| 1 /* global internal */ |
| 2 |
| 1 "use strict"; | 3 "use strict"; |
| 2 | 4 |
| 3 // Firefox 55 erroneously sends messages from the content script to the | 5 // Firefox 55 erroneously sends messages from the content script to the |
| 4 // devtools panel: | 6 // devtools panel: |
| 5 // https://bugzilla.mozilla.org/show_bug.cgi?id=1383310 | 7 // https://bugzilla.mozilla.org/show_bug.cgi?id=1383310 |
| 6 // As a workaround, listen for messages only if this isn't the devtools panel. | 8 // As a workaround, listen for messages only if this isn't the devtools panel. |
| 7 // Note that Firefox processes API access lazily, so browser.devtools will | 9 // Note that Firefox processes API access lazily, so browser.devtools will |
| 8 // always exist but will have undefined as its value on other pages. | 10 // always exist but will have undefined as its value on other pages. |
| 9 if (!browser.devtools) | 11 if (!browser.devtools) |
| 10 { | 12 { |
| 11 // Listen for messages from the background page. | 13 // Listen for messages from the background page. |
| 12 browser.runtime.onMessage.addListener((message, sender, sendResponse) => | 14 browser.runtime.onMessage.addListener((message, sender, sendResponse) => |
| 13 { | 15 { |
| 14 return ext.onMessage._dispatch(message, {}, sendResponse).includes(true); | 16 return ext[internal].dispatchEvent( |
| 17 ext.onMessage, |
| 18 message, {}, sendResponse |
| 19 ).includes(true); |
| 15 }); | 20 }); |
| 16 } | 21 } |
| 17 | 22 |
| 18 { | 23 { |
| 19 let port = null; | 24 let port = null; |
| 20 | 25 |
| 21 ext.onExtensionUnloaded = { | 26 ext.onExtensionUnloaded = { |
| 22 addListener(listener) | 27 addListener(listener) |
| 23 { | 28 { |
| 24 if (!port) | 29 if (!port) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 36 | 41 |
| 37 if (!port.onDisconnect.hasListeners()) | 42 if (!port.onDisconnect.hasListeners()) |
| 38 { | 43 { |
| 39 port.disconnect(); | 44 port.disconnect(); |
| 40 port = null; | 45 port = null; |
| 41 } | 46 } |
| 42 } | 47 } |
| 43 } | 48 } |
| 44 }; | 49 }; |
| 45 } | 50 } |
| OLD | NEW |