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.onMessage[internal].dispatch( |
| 17 message, {}, sendResponse |
| 18 ).includes(true); |
15 }); | 19 }); |
16 } | 20 } |
17 | 21 |
18 { | 22 { |
19 let port = null; | 23 let port = null; |
20 | 24 |
21 ext.onExtensionUnloaded = { | 25 ext.onExtensionUnloaded = { |
22 addListener(listener) | 26 addListener(listener) |
23 { | 27 { |
24 if (!port) | 28 if (!port) |
(...skipping 11 matching lines...) Expand all Loading... |
36 | 40 |
37 if (!port.onDisconnect.hasListeners()) | 41 if (!port.onDisconnect.hasListeners()) |
38 { | 42 { |
39 port.disconnect(); | 43 port.disconnect(); |
40 port = null; | 44 port = null; |
41 } | 45 } |
42 } | 46 } |
43 } | 47 } |
44 }; | 48 }; |
45 } | 49 } |
OLD | NEW |