Closed Bug 1131801 Opened 5 years ago Closed 5 years ago

remove use of parent in XPCWrappedNative's RescueOrphans


(Core :: XPConnect, defect)

Not set



Tracking Status
firefox38 --- fixed


(Reporter: sfink, Assigned: bzbarsky)




(3 files)

Split out from bug 805052, item 12: RescueOrphans in XPCWrappedNative, which has a cross-compartment wrapper as parent??
OK, so RescueOrphans is meant to deal with an XPCWrappedNative whose parent gets reparented.

For an XPCWrappedNative to have an interesting (non-global-object) parent, it needs to have a PreCreate hook.

We have the following PreCreate hooks in our codebase:

1) nsDOMConstructorSH::PreCreate, which calls nsDOMConstructor::PreCreate, which does SetParentToWindow(win, parentObj), so the parent always ends up being a window.

2) nsEventTargetSH::PreCreate which does:

   *parentObj = native_parent ? native_parent->GetGlobalJSObject() : globalObj;

where native_parent is an nsIScriptGlobalObject and globalObj is the aGlobalObj that was passed in.

3) nsDOMClassInfo::PreCreate, which does "*parentObj = globalObj;".

4) ComponentsSH::PreCreate, which does:

  *parentObj = self->GetScope()->GetGlobalJSObject();

5)  BackstagePass::PreCreate which sets *parentObj to global->GetGlobalJSObject(), where global is an nsIGlobalObject.

That's it.  So the parent always ends up being a global, and those of course never get reparented.

Given that, we can just kill off RescueOrphans entirely.
Assignee: nobody → bzbarsky
Depends on: 1131887
Blocks: 1132184
Blocks: 1127475
No longer blocks: 1127475
Attachment #8562984 - Flags: review?(peterv) → review+
Attachment #8562985 - Flags: review?(peterv) → review+
Attachment #8562986 - Flags: review?(peterv) → review+
You need to log in before you can comment on or make changes to this bug.