Closed Bug 1383662 Opened 2 years ago Closed 2 years ago

JavaScript error: resource:///modules/ZoomUI.jsm, line 62: TypeError: aBrowser is null

Categories

(Firefox :: Address Bar, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
Firefox 56
Tracking Status
firefox-esr52 --- unaffected
firefox54 --- unaffected
firefox55 --- unaffected
firefox56 --- fixed

People

(Reporter: florian, Assigned: jaws)

References

Details

(Keywords: regression)

Attachments

(2 files)

I frequently see errors like "JavaScript error: resource:///modules/ZoomUI.jsm, line 62: TypeError: aBrowser is null" in browser chrome test logs lately. Not sure what the exact steps to reproduce are.
I can reproduce this easily by loading "resource:///modules/ZoomUI.jsm" in a tab.

I have a patch coming soon that will silence these errors but I can't figure out why it is happening.

Basically, in the TextZoomChange event we get a document from event.target.defaultView.top.document which has no documentElement. The documentURI in this case is "resource:///modules/ZoomUI.jsm", and when I manually call gBrowser.getBrowserForDocument(gBrowser.browsers[0].contentDocument); I have no problems. Manually calling document.documentElement from within the content console has no issue either. My guess is that this has to do with synthetic documents?

I can also reproduce this error when entering Customize mode.

I did also find that we dispatch the TextZoomChange event even if there is no change in zoom level, however for FullZoomChange we only dispatch if the zoom level has actually changed. I included this fix in my patches.
Assignee: nobody → jaws
Status: NEW → ASSIGNED
(In reply to Jared Wein [:jaws] (please needinfo? me) from comment #1)

> Basically, in the TextZoomChange event we get a document from
> event.target.defaultView.top.document which has no documentElement. The
> documentURI in this case is "resource:///modules/ZoomUI.jsm", and when I
> manually call
> gBrowser.getBrowserForDocument(gBrowser.browsers[0].contentDocument); I have
> no problems. Manually calling document.documentElement from within the
> content console has no issue either. My guess is that this has to do with
> synthetic documents?

Could it be because the document hasn't finished loading?
Comment on attachment 8889487 [details]
Bug 1383662 - Return early from onZoomChange if the document being referenced by the TextZoomChange event is missing a documentElement since we will not be able to find the related browser for the document in this case.

https://reviewboard.mozilla.org/r/160522/#review165764
Attachment #8889487 - Flags: review?(florian) → review+
(In reply to Florian Quèze [:florian] [:flo] from comment #4)
> (In reply to Jared Wein [:jaws] (please needinfo? me) from comment #1)
> 
> > Basically, in the TextZoomChange event we get a document from
> > event.target.defaultView.top.document which has no documentElement. The
> > documentURI in this case is "resource:///modules/ZoomUI.jsm", and when I
> > manually call
> > gBrowser.getBrowserForDocument(gBrowser.browsers[0].contentDocument); I have
> > no problems. Manually calling document.documentElement from within the
> > content console has no issue either. My guess is that this has to do with
> > synthetic documents?
> 
> Could it be because the document hasn't finished loading?

Perhaps, it might make sense why I am able to reproduce this easily for local documents like resource URIs and customization mode.

Thanks for the quick review.
Comment on attachment 8889486 [details]
Bug 1383662 - Only dispatch TextZoomChange events if the zoom level has changed.

https://reviewboard.mozilla.org/r/160520/#review165892
Attachment #8889486 - Flags: review?(felipc) → review+
Pushed by jwein@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c841226514b4
Only dispatch TextZoomChange events if the zoom level has changed. r=Felipe
https://hg.mozilla.org/integration/autoland/rev/d85361c56299
Return early from onZoomChange if the document being referenced by the TextZoomChange event is missing a documentElement since we will not be able to find the related browser for the document in this case. r=florian
https://hg.mozilla.org/mozilla-central/rev/c841226514b4
https://hg.mozilla.org/mozilla-central/rev/d85361c56299
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 56
You need to log in before you can comment on or make changes to this bug.