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: Created Sept. 29, 2018, 1:37 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
95 let callStack = new Error().stack;
Sebastian Noack 2018/09/29 13:53:21 Nit: Perhaps initialize this variable along the re
Manish Jethani 2018/09/29 15:49:10 Done.
96
97 // If the last argument is undefined, we drop it from the list assuming 97 // 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 98 // 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 99 // 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 100 // callback to the list, it won't match the signature of the function
101 // and will cause an exception. 101 // and will cause an exception.
102 if (typeof args[args.length - 1] == "undefined") 102 if (typeof args[args.length - 1] == "undefined")
103 args.pop(); 103 args.pop();
104 104
105 let resolvePromise = null; 105 let resolvePromise = null;
106 let rejectPromise = null; 106 let rejectPromise = null;
(...skipping 124 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