Closed
Bug 1138059
Opened 10 years ago
Closed 10 years ago
XPCOMUtils.defineLazyGetter behavior is weird, causing warnings
Categories
(Core :: XPConnect, defect)
Tracking
()
RESOLVED
FIXED
mozilla39
Tracking | Status | |
---|---|---|
firefox39 | --- | fixed |
People
(Reporter: jorendorff, Assigned: jorendorff)
Details
Attachments
(1 file, 1 obsolete file)
(deleted),
patch
|
mak
:
review+
|
Details | Diff | Splinter Review |
Sorry, complicated explanation...
XPCOMUtils.defineLazyGetter defines an accessor property that's supposed to replace itself with a data property the first time it's accessed.
But it does so using a delete followed by a set:
get: function () {
delete aObject[aName];
return aObject[aName] = aLambda.apply(aObject);
}
Now sometimes after aObject[aName] is deleted, there's *another* lazy getter property on aObject's prototype chain. Seems weird; but I have a test case where a Sandbox object with a "Services" lazy getter inherits from a ChromeWindow object that also has a "Services" lazy getter. Maybe it's normal.
Anyway, because the inherited property has no setter, the assignment fails. In strict mode, it would be a TypeError.
This means the property, instead of turning into a data property, simply disappears; and from then on aObject[aName] is inherited.
This is going to be an "extra warning" from now on (side effect of bug 1113369 causing a *ton* of error handling to be more consistent) and it fires way too often. In fact it causes a devtools test to fail because the test expects no warnings to happen during the test.
Assignee | ||
Comment 1•10 years ago
|
||
Attachment #8570918 -
Flags: review?(bobbyholley)
Assignee | ||
Updated•10 years ago
|
Assignee: nobody → jorendorff
Status: NEW → ASSIGNED
Assignee | ||
Comment 2•10 years ago
|
||
Comment on attachment 8570918 [details] [diff] [review]
Tweak XPCOMUtils.defineLazyGetter behavior to avoid weird behavior in weird cases
Review of attachment 8570918 [details] [diff] [review]:
-----------------------------------------------------------------
wrong reviewer, oops
Attachment #8570918 -
Flags: review?(bobbyholley) → review?(mak77)
Assignee | ||
Comment 3•10 years ago
|
||
Attachment #8570927 -
Flags: review?(mak77)
Assignee | ||
Updated•10 years ago
|
Attachment #8570918 -
Attachment is obsolete: true
Attachment #8570918 -
Flags: review?(mak77)
Comment 4•10 years ago
|
||
Comment on attachment 8570927 [details] [diff] [review]
Tweak XPCOMUtils.defineLazyGetter behavior to avoid weird behavior in weird cases
Review of attachment 8570927 [details] [diff] [review]:
-----------------------------------------------------------------
lgtm!
::: js/xpconnect/loader/XPCOMUtils.jsm
@@ +196,2 @@
> delete aObject[aName];
> + var value = aLambda.apply(aObject);
nit: we usually use let in newer code.
@@ +198,5 @@
> + Object.defineProperty(aObject, aName, {
> + value,
> + writable: true,
> + configurable: true,
> + enumerable: true});
nit: maybe add whitespace before } for readability or indent }); with Object
Attachment #8570927 -
Flags: review?(mak77) → review+
Assignee | ||
Comment 5•10 years ago
|
||
Comment 6•10 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
status-firefox39:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
You need to log in
before you can comment on or make changes to this bug.
Description
•