Closed Bug 1136516 Opened 10 years ago Closed 10 years ago

Stop using JS_DeprecatedNewObjectWithGivenProtoAndParent in XPCWrappedNative

Categories

(Core :: XPConnect, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

Details

Attachments

(1 file)

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.
I guess there's nothing to enforce; we'd just end up with the global as parent.
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+
Done as: MOZ_ASSERT(betterScope != Scope, "How can we have the same scope for two different globals?"); return GetNewOrUsed(helper, betterScope, Interface, resultWrapper);
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: