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

Delta Between Two Patch Sets: polyfill.js

Issue 29895567: Noissue - Avoid access to stack trace unless necessary (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Created Sept. 29, 2018, 1:37 p.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (typeof args[args.length - 1] == "function") 92 if (typeof args[args.length - 1] == "function")
93 return func.apply(object, args); 93 return func.apply(object, args);
94 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 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;
105
106 let callStack = new Error().stack;
107 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 {
(...skipping 114 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 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld