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

Side by Side Diff: polyfill.js

Issue 29895567: Noissue - Avoid access to stack trace unless necessary (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Move declaration Created Sept. 29, 2018, 3:45 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 | « no previous file | 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
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 return; 82 return;
83 83
84 // If the property is not writable assigning it will fail, so we use 84 // If the property is not writable assigning it will fail, so we use
85 // Object.defineProperty here instead. Assuming the property isn't 85 // Object.defineProperty here instead. Assuming the property isn't
86 // inherited its other attributes (e.g. enumerable) are preserved, 86 // inherited its other attributes (e.g. enumerable) are preserved,
87 // except for accessor attributes (e.g. get and set) which are discarded 87 // except for accessor attributes (e.g. get and set) which are discarded
88 // since we're specifying a value. 88 // since we're specifying a value.
89 Object.defineProperty(object, name, { 89 Object.defineProperty(object, name, {
90 value(...args) 90 value(...args)
91 { 91 {
92 let callStack = new Error().stack;
93
94 if (typeof args[args.length - 1] == "function") 92 if (typeof args[args.length - 1] == "function")
95 return func.apply(object, args); 93 return func.apply(object, args);
96 94
97 // If the last argument is undefined, we drop it from the list assuming 95 // If the last argument is undefined, we drop it from the list assuming
98 // it stands for the optional callback. We must do this, because we have 96 // it stands for the optional callback. We must do this, because we have
99 // to replace it with our own callback. If we simply append our own 97 // to replace it with our own callback. If we simply append our own
100 // callback to the list, it won't match the signature of the function 98 // callback to the list, it won't match the signature of the function
101 // and will cause an exception. 99 // and will cause an exception.
102 if (typeof args[args.length - 1] == "undefined") 100 if (typeof args[args.length - 1] == "undefined")
103 args.pop(); 101 args.pop();
104 102
105 let resolvePromise = null; 103 let resolvePromise = null;
106 let rejectPromise = null; 104 let rejectPromise = null;
107 105
Sebastian Noack 2018/09/29 16:07:14 Nit: This blank line seems redundant.
Manish Jethani 2018/09/29 16:39:08 I'd prefer to keep the variable standing out from
106 let callStack = new Error().stack;
107
108 func.call(object, ...args, result => 108 func.call(object, ...args, result =>
109 { 109 {
110 let error = browser.runtime.lastError; 110 let error = browser.runtime.lastError;
111 if (error && !portClosedBeforeResponseError.test(error.message)) 111 if (error && !portClosedBeforeResponseError.test(error.message))
112 { 112 {
113 // runtime.lastError is already an Error instance on Edge, while on 113 // runtime.lastError is already an Error instance on Edge, while on
114 // Chrome it is a plain object with only a message property. 114 // Chrome it is a plain object with only a message property.
115 if (!(error instanceof Error)) 115 if (!(error instanceof Error))
116 { 116 {
117 error = new Error(error.message); 117 error = new Error(error.message);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList 232 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList
233 // didn't have iterator support before Chrome 51. 233 // didn't have iterator support before Chrome 51.
234 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699 234 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699
235 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList]) 235 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList])
236 { 236 {
237 if (!(Symbol.iterator in object.prototype)) 237 if (!(Symbol.iterator in object.prototype))
238 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; 238 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
239 } 239 }
240 } 240 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld