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

Side by Side Diff: ext/content.js

Issue 29570614: Issue 5028 - Use browser namespace (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Update adblockplusui dependency Created Oct. 17, 2017, 1:02 p.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 chrome.devtools will always 7 // Note that Firefox processes API access lazily, so browser.devtools will
8 // 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 (!chrome.devtools) 9 if (!browser.devtools)
10 { 10 {
11 // Listen for messages from the background page. 11 // Listen for messages from the background page.
12 chrome.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() 18 (function()
19 { 19 {
20 let port = null; 20 let port = null;
21 21
22 ext.onExtensionUnloaded = { 22 ext.onExtensionUnloaded = {
23 addListener(listener) 23 addListener(listener)
24 { 24 {
25 if (!port) 25 if (!port)
26 port = chrome.runtime.connect(); 26 port = browser.runtime.connect();
27 27
28 // When the extension is reloaded, disabled or uninstalled the 28 // When the extension is reloaded, disabled or uninstalled the
29 // background page dies and automatically disconnects all ports 29 // background page dies and automatically disconnects all ports
30 port.onDisconnect.addListener(listener); 30 port.onDisconnect.addListener(listener);
31 }, 31 },
32 removeListener(listener) 32 removeListener(listener)
33 { 33 {
34 if (port) 34 if (port)
35 { 35 {
36 port.onDisconnect.removeListener(listener); 36 port.onDisconnect.removeListener(listener);
37 37
38 if (!port.onDisconnect.hasListeners()) 38 if (!port.onDisconnect.hasListeners())
39 { 39 {
40 port.disconnect(); 40 port.disconnect();
41 port = null; 41 port = null;
42 } 42 }
43 } 43 }
44 } 44 }
45 }; 45 };
46 }()); 46 }());
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