When javascript adopts a node into a different frame, and then the frame into which the node was adopted navigates to a different page (e.g. by location.href), then the adopted node will be dead after the navigation even though a parse-created node in the original document is still alive. Furthermore, behavior is different depending on how long we wait.
Created attachment 112596 [details] test
The only sane behavior I can think of here is that we need to keep the frame's original document alive until the reference to the adopted node goes away.
This test is quite complicated. I don't think that it's showing what the title implies, and I'm not sure if it's showing any bug. Notably, the adopt() function is called twice - once when the document is loaded, and then again after you click a link to test. This is what resets "target" variable to null.
(In reply to comment #3) > Notably, the adopt() function is called twice - once when the document is loaded, and then again after you click a link to test. This is what resets "target" variable to null. No, if you click the one with 0 timeout, then you'll still have target variable. Only when you bump up the timeout, will you see target going away.
The fact that a zero delay timer behaves differently is likely because it fires before the navigation has finished. Timing dependency doesn't necessarily mean that it's garbage collection.
(In reply to comment #5) > The fact that a zero delay timer behaves differently is likely because it fires before the navigation has finished. Timing dependency doesn't necessarily mean that it's garbage collection. It's probably to do with the timer in HTMLFrameElementBase.
Could you please make a smaller reduction if you think that there is a bug here? What I see looks like correct behavior.
Still unsure what the issue here is, if any. But see bug 107859.