Closed
Bug 1136516
Opened 10 years ago
Closed 10 years ago
Stop using JS_DeprecatedNewObjectWithGivenProtoAndParent in XPCWrappedNative
Categories
(Core :: XPConnect, defect)
Tracking
()
RESOLVED
FIXED
mozilla39
Tracking | Status | |
---|---|---|
firefox39 | --- | fixed |
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
Details
Attachments
(1 file)
(deleted),
patch
|
bholley
:
review+
|
Details | Diff | Splinter Review |
This is used because we might have a nontrivial parent from PreCreate. But in practice, we have the following PreCreate implementations:
nsDOMClassInfo::PreCreate: sets *parentObj = globalObj
nsDOMConstructorSH::PreCreate: sets *parentObj to the win->FastGetGlobalJSObject() of an inner window (via nsDOMConstructor::PreCreate).
nsEventTargetSH::PreCreate: sets *parentObj to the GetGlobalJSObject() of some nsIScriptGlobalObject (or globalObj, if it doesn't find one).
ComponentsSH::PreCreate: sets *parentObj to self->GetScope()->GetGlobalJSObject().
BackstagePass::PreCreate: sets *parentObj to global->GetGlobalJSObject().
OK, so they're all globals. We can either assert this or do an extra (no-op in practice) GetGlobalFromObject call to enforce it.
Assignee | ||
Comment 1•10 years ago
|
||
I guess there's nothing to enforce; we'd just end up with the global as parent.
Assignee | ||
Comment 2•10 years ago
|
||
Attachment #8568930 -
Flags: review?(bobbyholley)
Comment 3•10 years ago
|
||
Comment on attachment 8568930 [details] [diff] [review]
Stop using JS_DeprecatedNewObjectWithGivenProtoAndParent in XPCWrappedNative
Review of attachment 8568930 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/xpconnect/src/XPCWrappedNative.cpp
@@ +375,5 @@
> if (betterScope != Scope)
> return GetNewOrUsed(helper, betterScope, Interface, resultWrapper);
>
> + // XXXXbz Can we really get here? Since parent and plannedParent
> + // are both globals and they're not equal to each other....
Agreed. Please MOZ_ASSERT and simplify this code.
Attachment #8568930 -
Flags: review?(bobbyholley) → review+
Assignee | ||
Comment 4•10 years ago
|
||
Done as:
MOZ_ASSERT(betterScope != Scope,
"How can we have the same scope for two different globals?");
return GetNewOrUsed(helper, betterScope, Interface, resultWrapper);
Assignee | ||
Comment 5•10 years ago
|
||
Status: NEW → 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
•