Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: ext/content.js

Issue 29581937: Noissue - Use anonymous blocks instead of anonymous functions (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created Oct. 18, 2017, 2:10 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ext/common.js ('k') | ext/devtools.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Note that Firefox processes API access lazily, so browser.devtools will 7 // Note that Firefox processes API access lazily, so browser.devtools will
8 // always exist but will have undefined as its value on other pages. 8 // always exist but will have undefined as its value on other pages.
9 if (!browser.devtools) 9 if (!browser.devtools)
10 { 10 {
11 // Listen for messages from the background page. 11 // Listen for messages from the background page.
12 browser.runtime.onMessage.addListener((message, sender, sendResponse) => 12 browser.runtime.onMessage.addListener((message, sender, sendResponse) =>
13 { 13 {
14 return ext.onMessage._dispatch(message, {}, sendResponse).includes(true); 14 return ext.onMessage._dispatch(message, {}, sendResponse).includes(true);
15 }); 15 });
16 } 16 }
17 17
18 (function()
19 { 18 {
20 let port = null; 19 let port = null;
21 20
22 ext.onExtensionUnloaded = { 21 ext.onExtensionUnloaded = {
23 addListener(listener) 22 addListener(listener)
24 { 23 {
25 if (!port) 24 if (!port)
26 port = browser.runtime.connect(); 25 port = browser.runtime.connect();
27 26
28 // When the extension is reloaded, disabled or uninstalled the 27 // When the extension is reloaded, disabled or uninstalled the
29 // background page dies and automatically disconnects all ports 28 // background page dies and automatically disconnects all ports
30 port.onDisconnect.addListener(listener); 29 port.onDisconnect.addListener(listener);
31 }, 30 },
32 removeListener(listener) 31 removeListener(listener)
33 { 32 {
34 if (port) 33 if (port)
35 { 34 {
36 port.onDisconnect.removeListener(listener); 35 port.onDisconnect.removeListener(listener);
37 36
38 if (!port.onDisconnect.hasListeners()) 37 if (!port.onDisconnect.hasListeners())
39 { 38 {
40 port.disconnect(); 39 port.disconnect();
41 port = null; 40 port = null;
42 } 41 }
43 } 42 }
44 } 43 }
45 }; 44 };
46 }()); 45 }
OLDNEW
« no previous file with comments | « ext/common.js ('k') | ext/devtools.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld