LEFT | RIGHT |
1 /* global internal */ | 1 /* global internal */ |
2 | 2 |
3 "use strict"; | 3 "use strict"; |
4 | 4 |
5 // Firefox 55 erroneously sends messages from the content script to the | 5 // Firefox 55 erroneously sends messages from the content script to the |
6 // devtools panel: | 6 // devtools panel: |
7 // https://bugzilla.mozilla.org/show_bug.cgi?id=1383310 | 7 // https://bugzilla.mozilla.org/show_bug.cgi?id=1383310 |
8 // 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. |
9 // Note that Firefox processes API access lazily, so browser.devtools will | 9 // Note that Firefox processes API access lazily, so browser.devtools will |
10 // 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. |
11 if (!browser.devtools) | 11 if (!browser.devtools) |
12 { | 12 { |
13 // Listen for messages from the background page. | 13 // Listen for messages from the background page. |
14 browser.runtime.onMessage.addListener((message, sender, sendResponse) => | 14 browser.runtime.onMessage.addListener((message, sender, sendResponse) => |
15 { | 15 { |
16 return ext[internal].dispatchEvent( | 16 return ext.onMessage[internal].dispatch( |
17 ext.onMessage, | |
18 message, {}, sendResponse | 17 message, {}, sendResponse |
19 ).includes(true); | 18 ).includes(true); |
20 }); | 19 }); |
21 } | 20 } |
22 | 21 |
23 { | 22 { |
24 let port = null; | 23 let port = null; |
25 | 24 |
26 ext.onExtensionUnloaded = { | 25 ext.onExtensionUnloaded = { |
27 addListener(listener) | 26 addListener(listener) |
(...skipping 13 matching lines...) Expand all Loading... |
41 | 40 |
42 if (!port.onDisconnect.hasListeners()) | 41 if (!port.onDisconnect.hasListeners()) |
43 { | 42 { |
44 port.disconnect(); | 43 port.disconnect(); |
45 port = null; | 44 port = null; |
46 } | 45 } |
47 } | 46 } |
48 } | 47 } |
49 }; | 48 }; |
50 } | 49 } |
LEFT | RIGHT |