Closed Bug 802394 Opened 12 years ago Closed 12 years ago

document.body is null in aboutHome.js

Categories

(Firefox :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 19

People

(Reporter: jaws, Assigned: jaws)

Details

Attachments

(1 file, 2 obsolete files)

Timestamp: 10/16/2012 3:29:58 PM
Error: TypeError: document.body is null
Source File: chrome://browser/content/abouthome/aboutHome.js
Line: 236

where line 236 is:
>   } else if (document.body.hasAttribute("narrow")) {
STR:
Have about:home as the homepage for the browser
Open the Error Console
Open a New Window
Look at Error Console
Attached patch Patch (obsolete) — Splinter Review
By placing some alert()'s in the code, I found that new windows are getting the 'resize' event before 'load', and that is what is causing document.body to be null.
Attachment #672077 - Flags: review?(fryn)
Comment on attachment 672077 [details] [diff] [review]
Patch

> function fitToWidth() {
>+  if (!gPageLoaded)

Does |if (document.readyState != "complete")| work here?
Attached patch Patch v2 (obsolete) — Splinter Review
Yeah, that's a better approach and works well.
Attachment #672077 - Attachment is obsolete: true
Attachment #672077 - Flags: review?(fryn)
Attachment #672121 - Flags: review?(dao)
Updated STR,

(In reply to Jared Wein [:jaws] from comment #1)
> STR:
> Have about:home as the homepage for the browser
Open a sidebar.
> Open the Error Console
> Open a New Window
> Look at Error Console

The open sidebar causes the resize before the document has loaded.
(In reply to Jared Wein [:jaws] from comment #5)
> The open sidebar causes the resize before the document has loaded.

Works for me, although this isn't too surprising if this is a race condition.

Do you get the error in Firefox 16, aurora, beta, nightly or only in a custom build?
I can reproduce in a regular Nightly build with the social sidebar open.
What code opens the social side bar?
Comment on attachment 672121 [details] [diff] [review]
Patch v2

Anyway... I think a better fix would be to move window.addEventListener("resize", fitToWidth); inside the load listener.
Attachment #672121 - Flags: review?(dao) → review-
Attached patch Patch v2.1Splinter Review
Attachment #672121 - Attachment is obsolete: true
Attachment #672615 - Flags: review?(dao)
To show the social sidebar, go to about:config and set social.active=true and social.enabled=true. You can then use the menu from the toolbar button to toggle the sidebar visibility.
(In reply to Jared Wein [:jaws] from comment #11)
I think Dão was asking for the line(s) of code that perform that operation.
This is the call stack,
SocialSidebar_updateSidebar@chrome://browser/content/browser.js:4644
SocialSidebar_init@chrome://browser/content/browser.js:4605
SocialUI_providerReady@chrome://browser/content/browser.js:3977
chrome://browser/content/browser.js:4646

note that since browser.js was split into multiple files, much of this code will actually be found in browser-social.js.
Attachment #672615 - Flags: review?(dao) → review+
https://hg.mozilla.org/mozilla-central/rev/142ee4ac9b30
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Target Milestone: --- → Firefox 19
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: