OLD | NEW |
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 { | 62 { |
63 object = object[node]; | 63 object = object[node]; |
64 | 64 |
65 if (!object) | 65 if (!object) |
66 return; | 66 return; |
67 } | 67 } |
68 | 68 |
69 let func = object[name]; | 69 let func = object[name]; |
70 if (!func) | 70 if (!func) |
71 return; | 71 return; |
72 | 72 let descriptor = Object.getOwnPropertyDescriptor(object, name); |
73 object[name] = function(...args) | 73 delete descriptor["get"]; |
| 74 delete descriptor["set"]; |
| 75 descriptor.value = function(...args) |
74 { | 76 { |
75 let callStack = new Error().stack; | 77 let callStack = new Error().stack; |
76 | 78 |
77 if (typeof args[args.length - 1] == "function") | 79 if (typeof args[args.length - 1] == "function") |
78 return func.apply(object, args); | 80 return func.apply(object, args); |
79 | 81 |
80 // If the last argument is undefined, we drop it from the list assuming | 82 // If the last argument is undefined, we drop it from the list assuming |
81 // it stands for the optional callback. We must do this, because we have | 83 // it stands for the optional callback. We must do this, because we have |
82 // to replace it with our own callback. If we simply append our own | 84 // to replace it with our own callback. If we simply append our own |
83 // callback to the list, it won't match the signature of the function and | 85 // callback to the list, it won't match the signature of the function and |
(...skipping 20 matching lines...) Expand all Loading... |
104 | 106 |
105 reject(error); | 107 reject(error); |
106 } | 108 } |
107 else | 109 else |
108 { | 110 { |
109 resolve(result); | 111 resolve(result); |
110 } | 112 } |
111 }); | 113 }); |
112 }); | 114 }); |
113 }; | 115 }; |
| 116 Object.defineProperty(object, name, descriptor); |
114 } | 117 } |
115 | 118 |
116 function shouldWrapAPIs() | 119 function shouldWrapAPIs() |
117 { | 120 { |
118 try | 121 try |
119 { | 122 { |
120 return !(browser.storage.local.get([]) instanceof Promise); | 123 return !(browser.storage.local.get([]) instanceof Promise); |
121 } | 124 } |
122 catch (error) | 125 catch (error) |
123 { | 126 { |
(...skipping 16 matching lines...) Expand all Loading... |
140 | 143 |
141 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList | 144 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList |
142 // didn't have iterator support before Chrome 51. | 145 // didn't have iterator support before Chrome 51. |
143 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699 | 146 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699 |
144 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList]) | 147 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList]) |
145 { | 148 { |
146 if (!(Symbol.iterator in object.prototype)) | 149 if (!(Symbol.iterator in object.prototype)) |
147 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; | 150 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; |
148 } | 151 } |
149 } | 152 } |
OLD | NEW |