Closed Bug 1375573 Opened 7 years ago Closed 7 years ago

setupJSON() instantiates about:blank

Categories

(Core :: DOM: Core & HTML, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla56
Tracking Status
firefox56 --- fixed

People

(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

See this profile please: http://bit.ly/2t01q4e

Seems like this is caused by the code added in bug 980766: <https://searchfox.org/mozilla-central/rev/ae94cfb36d804727dfb38f2750bfcaab4621df6e/toolkit/content/browser-child.js#85>

nsDocShell::GetDocument() never returns null <https://searchfox.org/mozilla-central/rev/ae94cfb36d804727dfb38f2750bfcaab4621df6e/docshell/base/nsDocShell.cpp#4575> and instead it instantiates about:blank if you force it to, which is what this code is doing instead of its intended purpose which is presumably not doing this work if we don't have a document yet.

Bill, what do you think should be done about this?
Flags: needinfo?(wmccloskey)
We only use documentContentType in a STATE_STOP onStateChange handler or in onLocationChange. Presumably the only time we don't have a document is in onStateChange with STATE_START. So we could avoid looking up the content type in that case.
Flags: needinfo?(wmccloskey)
Hmm, I'm trying a patch that does what you suggested but it's not working.  Investigating why...
Assignee: nobody → ehsan
The other part of this puzzle that I was missing before was the DOMWindow getter here: https://searchfox.org/mozilla-central/rev/ae94cfb36d804727dfb38f2750bfcaab4621df6e/toolkit/content/browser-child.js#62

It was trying to create a wrapper for the Window object, and since at the point this code runs we may not yet have an inner window, this leads to a forceful creation of the WebIDL binding and as part of it the about:blank document.  In fact this issue is visible if you squint at the profile in comment 0 hard enough.

I've got patches to fix both issues.
Attachment #8881482 - Flags: review?(wmccloskey) → review+
Attachment #8881483 - Flags: review?(wmccloskey) → review+
Pushed by eakhgari@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/a872b197585a
Part 1: Avoid creating an about:blank document in setupJSON() by accessing content.document before STATE_STOP; r=billm
https://hg.mozilla.org/integration/mozilla-inbound/rev/dc98dc9e0725
Part 2: Avoid creating an about:blank document in setupJSON() by creating a Window binding through exposing a getter for the inner window ID on nsIWebProgress; r=billm
https://hg.mozilla.org/mozilla-central/rev/a872b197585a
https://hg.mozilla.org/mozilla-central/rev/dc98dc9e0725
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.