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

Side by Side Diff: polyfill.js

Issue 29590603: Issue 5954 - Read-only properties cannot be assigned in strict mode in Edge (Closed)
Patch Set: Delete accessor methods explicitly Created Nov. 8, 2017, 1:57 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Some descriptors like setUninstallURL are in fact accessor descriptors.
kzar 2017/11/10 14:16:14 Nit: This comment doesn't read too well and I don'
74 // We convert them to data descriptors.
75 delete descriptor["get"];
76 delete descriptor["set"];
77 descriptor.value = function(...args)
74 { 78 {
75 let callStack = new Error().stack; 79 let callStack = new Error().stack;
76 80
77 if (typeof args[args.length - 1] == "function") 81 if (typeof args[args.length - 1] == "function")
78 return func.apply(object, args); 82 return func.apply(object, args);
79 83
80 // If the last argument is undefined, we drop it from the list assuming 84 // 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 85 // 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 86 // 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 87 // callback to the list, it won't match the signature of the function and
(...skipping 20 matching lines...) Expand all
104 108
105 reject(error); 109 reject(error);
106 } 110 }
107 else 111 else
108 { 112 {
109 resolve(result); 113 resolve(result);
110 } 114 }
111 }); 115 });
112 }); 116 });
113 }; 117 };
118 Object.defineProperty(object, name, descriptor);
114 } 119 }
115 120
116 function shouldWrapAPIs() 121 function shouldWrapAPIs()
117 { 122 {
118 try 123 try
119 { 124 {
120 return !(browser.storage.local.get([]) instanceof Promise); 125 return !(browser.storage.local.get([]) instanceof Promise);
121 } 126 }
122 catch (error) 127 catch (error)
123 { 128 {
(...skipping 16 matching lines...) Expand all
140 145
141 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList 146 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList
142 // didn't have iterator support before Chrome 51. 147 // didn't have iterator support before Chrome 51.
143 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699 148 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699
144 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList]) 149 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList])
145 { 150 {
146 if (!(Symbol.iterator in object.prototype)) 151 if (!(Symbol.iterator in object.prototype))
147 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; 152 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
148 } 153 }
149 } 154 }
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