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

Side by Side Diff: polyfill.js

Issue 29589668: Issue 5938 - Use top-level var for global variables (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created Oct. 26, 2017, 8:44 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
« include.preload.js ('K') | « include.preload.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 "use strict"; 18 "use strict";
19 19
20 var browser;
21
20 { 22 {
21 const asyncAPIs = [ 23 const asyncAPIs = [
22 "contextMenus.removeAll", 24 "contextMenus.removeAll",
23 "devtools.panels.create", 25 "devtools.panels.create",
24 "notifications.clear", 26 "notifications.clear",
25 "notifications.create", 27 "notifications.create",
26 "runtime.openOptionsPage", 28 "runtime.openOptionsPage",
27 "runtime.sendMessage", 29 "runtime.sendMessage",
28 "runtime.setUninstallURL", 30 "runtime.setUninstallURL",
29 "storage.local.get", 31 "storage.local.get",
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 127
126 return true; 128 return true;
127 } 129 }
128 130
129 if (shouldWrapAPIs()) 131 if (shouldWrapAPIs())
130 { 132 {
131 // Unlike Firefox and Microsoft Edge, Chrome doesn't have a "browser" object , 133 // Unlike Firefox and Microsoft Edge, Chrome doesn't have a "browser" object ,
132 // but provides the extension API through the "chrome" namespace 134 // but provides the extension API through the "chrome" namespace
133 // (non-standard). 135 // (non-standard).
134 if (typeof browser == "undefined") 136 if (typeof browser == "undefined")
135 window.browser = chrome; 137 browser = chrome;
136 138
137 for (let api of asyncAPIs) 139 for (let api of asyncAPIs)
138 wrapAPI(api); 140 wrapAPI(api);
139 } 141 }
140 142
141 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList 143 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList
142 // didn't have iterator support before Chrome 51. 144 // didn't have iterator support before Chrome 51.
143 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699 145 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699
144 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList]) 146 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList])
145 { 147 {
146 if (!(Symbol.iterator in object.prototype)) 148 if (!(Symbol.iterator in object.prototype))
147 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; 149 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
148 } 150 }
149 } 151 }
OLDNEW
« include.preload.js ('K') | « include.preload.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld