| Index: lib/content/snippets.js |
| =================================================================== |
| --- a/lib/content/snippets.js |
| +++ b/lib/content/snippets.js |
| @@ -695,22 +695,46 @@ |
| // 2176782336 - 60466176 = 2116316160. This ensure to always have 6 |
| // chars even if Math.random() returns its minimum value 0.0 |
| // |
| return Math.floor(Math.random() * 2116316160 + 60466176).toString(36); |
| } |
| function wrapPropertyAccess(object, property, descriptor) |
| { |
| - let currentDescriptor = Object.getOwnPropertyDescriptor(object, property); |
| + let dot = property.indexOf("."); |
| + if (dot == -1) |
| + { |
| + // simple property case. |
| + let currentDescriptor = Object.getOwnPropertyDescriptor(object, property); |
| + if (currentDescriptor && !currentDescriptor.configurable) |
| + return false; |
| + |
| + Object.defineProperty(object, property, descriptor); |
| + return true; |
| + } |
| + let result = false; |
| + let name = property.slice(0, dot); |
| + property = property.slice(dot + 1); |
| + let value = object[name]; |
| + if (value && typeof value == "object") |
| + result = wrapPropertyAccess(value, property, descriptor); |
| + |
| + let currentDescriptor = Object.getOwnPropertyDescriptor(object, name); |
| if (currentDescriptor && !currentDescriptor.configurable) |
| - return false; |
| + return result; |
| - Object.defineProperty(object, property, descriptor); |
| - return true; |
| + let setter = newValue => |
| + { |
| + value = newValue; |
| + if (newValue && typeof newValue == "object") |
| + wrapPropertyAccess(newValue, property, descriptor); |
| + }; |
| + Object.defineProperty(object, name, {get: () => value, set: setter}); |
| + return result; |
| } |
| /** |
| * Overrides the <code>onerror</code> handler to discard tagged error messages |
| * from our property wrapping. |
| * |
| * @param {string} magic The magic string that tags the error message. |
| */ |