Last Comment Bug 394676 - XBL constructors fire after window.onload event
: XBL constructors fire after window.onload event
: regression, verified1.8.1.8
Product: Core
Classification: Components
Component: XBL (show other bugs)
: unspecified
: x86 All
: -- normal (vote)
: ---
Assigned To: Boris Zbarsky [:bz] (still a bit busy)
: Andrew Overholt [:overholt]
Depends on: 394014 398289
Blocks: 267833
  Show dependency treegraph
Reported: 2007-09-02 16:44 PDT by Chris Burnette
Modified: 2007-10-05 03:28 PDT (History)
5 users (show)
dveditz: blocking1.8.1.8+
bzbarsky: in‑testsuite+
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

XBL HTML Test file (1015 bytes, text/html)
2007-09-02 16:45 PDT, Chris Burnette
no flags Details
XBL Binding Test file (636 bytes, application/xml)
2007-09-02 16:46 PDT, Chris Burnette
no flags Details
Like so (trunk patch) (5.11 KB, patch)
2007-10-02 12:30 PDT, Boris Zbarsky [:bz] (still a bit busy)
jonas: review+
jonas: superreview+
jonas: approval1.9+
Details | Diff | Splinter Review

Description Chris Burnette 2007-09-02 16:44:03 PDT
User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9a7) Gecko/2007090203 Minefield/3.0a7

Starting around Firefox 3 Alpha 3, XBL constructors started firing after the window.onload event. Prior to that, XBL constructors fire before the window.onload event. 

Because of this, XBL bindings cannot hook into the window.onload event.

I've tested this under both Linux and Windows OS's.

Reproducible: Always

Steps to Reproduce:
Save the attached files (xbl_test.htm and xbl_test.xml) to your computer and open the HTML file with Firefox Alpha 3 or higher (at least through Alpha 7)

Actual Results:  
You should see at the top of the page:

which is the order that these events occured in. Not that the window.onload event is first and that the onload listeners installed by the constructors never fire since the window.onload fired before the constructors were called.

Expected Results:  
Under Firefox 2.x, you see:

Comment 1 Chris Burnette 2007-09-02 16:45:28 PDT
Created attachment 279380 [details]
XBL HTML Test file

This file illustrates the problem (along w/ the xbl_test.xml file).
Comment 2 Chris Burnette 2007-09-02 16:46:20 PDT
Created attachment 279381 [details]
XBL Binding Test file

This file illustrates the problem (along w/ the xbl_test.htm file).
Comment 3 Boris Zbarsky [:bz] (still a bit busy) 2007-09-02 21:04:51 PDT
The patch in bug 394014 will fix this.

That said, I tried to write a mochitest for this and discovered that the bug disappeared; something mochitest is doing is perturbing the test document to cause an extra begin/end update before any load events I can attach fire.  I've ended up writing a reftest for this...
Comment 4 Boris Zbarsky [:bz] (still a bit busy) 2007-09-14 12:18:11 PDT
Fixed by checkin for bug 394014.
Comment 5 Boris Zbarsky [:bz] (still a bit busy) 2007-09-14 14:20:56 PDT
Branch patch attached to bug 267833 as part of the big branch patch there.
Comment 6 Boris Zbarsky [:bz] (still a bit busy) 2007-10-02 12:05:45 PDT
Fixed on branch by checkin for bug 267833.

I thought about it some more, and we should also add some robustness stuff on trunk...
Comment 7 Boris Zbarsky [:bz] (still a bit busy) 2007-10-02 12:30:07 PDT
Created attachment 283231 [details] [diff] [review]
Like so (trunk patch)
Comment 8 Boris Zbarsky [:bz] (still a bit busy) 2007-10-03 16:38:40 PDT
Checked that in on trunk.
Comment 9 Martijn Wargers [:mwargers] (not working for Mozilla) 2007-10-04 16:37:42 PDT
With Firefox2.0.0.7, I get:

But with using 2007-10-04 1.8 branch build I get:

I guess that means this is fixed on the 1.8 branch? (although constructors still seem to have fired before onload)
Comment 10 Boris Zbarsky [:bz] (still a bit busy) 2007-10-04 16:51:48 PDT
This didn't regress on branch, because I rolled the fix into the branch fix for the bug that regressed it.  It needs verifying as not having regressed, though.
Comment 11 Martijn Wargers [:mwargers] (not working for Mozilla) 2007-10-04 17:07:59 PDT
Well, I guess it didn't regress on the branch then, since all the constructors fired before window.onload as I noted in comment 9.
The constructor order seems to have changed, though.

On current trunk build, I get:
Comment 12 Boris Zbarsky [:bz] (still a bit busy) 2007-10-04 20:26:00 PDT
Yeah, the firing order of the constructors changed.  That's fine, as far as I'm concerned: no ordering of separate async loads is guaranteed.
Comment 13 Martijn Wargers [:mwargers] (not working for Mozilla) 2007-10-05 03:28:16 PDT
Ok, thanks Boris. Marking verified1.8.1.8.

Note You need to log in before you can comment on or make changes to this bug.