originalHandler.handleEvent is not a function, XHR broken in Nightly?

186 views
Skip to first unread message

Jan Honza Odvarko

unread,
Apr 2, 2012, 1:58:47 PM4/2/12
to
Firebug is overriding <xhr-request>.onreadystatechange and when the
callback is executed it calls the original handler, see here:
https://github.com/firebug/firebug/blob/master/extension/content/firebug/net/spy.js#L815

When I updated to today's nightly build (http://hg.mozilla.org/mozilla-
central/rev/3e46009daea3) execution of the original callback throws an
exception:

Error: originalHandler.handleEvent is not a function
Source File: chrome://firebug/content/net/spy.js
Line: 815

Is there any XHR related change in the latest nightly?

STR:

1) Install Firebug http://getfirebug.com/releases/firebug/1.10/firebug-1.10.0a6.xpi
2) Load www.google.com
3) Type something into the search box.
4) Watch Firefox Error Console

Honza

Kyle Huey

unread,
Apr 2, 2012, 4:54:05 PM4/2/12
to Jan Honza Odvarko, dev-pl...@lists.mozilla.org
>
> Is there any XHR related change in the latest nightly?
>

Yes. The "original" onfoo handler is no longer an nsIDOMEventListener, its
just a regular JS function.

- Kyle

Boris Zbarsky

unread,
Apr 2, 2012, 5:16:46 PM4/2/12
to
On 4/2/12 1:58 PM, Jan Honza Odvarko wrote:
> Firebug is overriding<xhr-request>.onreadystatechange and when the
> callback is executed it calls the original handler, see here:
> https://github.com/firebug/firebug/blob/master/extension/content/firebug/net/spy.js#L815
>
> When I updated to today's nightly build (http://hg.mozilla.org/mozilla-
> central/rev/3e46009daea3) execution of the original callback throws an
> exception:
>
> Error: originalHandler.handleEvent is not a function
> Source File: chrome://firebug/content/net/spy.js
> Line: 815
>
> Is there any XHR related change in the latest nightly?

Yes, XHR was switched to the new DOM bindings, which actually implement
the current WebIDL and DOM specs.

In particular, onreadystatechange is now just a Function object, not an
nsIDOMEventHandler, per spec. So it has no handleEvent. However,
calling it (with the appropriate "this" object) should work fine.

-Boris

Jan Honza Odvarko

unread,
Apr 3, 2012, 1:47:47 AM4/3/12
to
On Apr 2, 11:16 pm, Boris Zbarsky <bzbar...@mit.edu> wrote:
> In particular, onreadystatechange is now just a Function object, not an
> nsIDOMEventHandler, per spec.  So it has no handleEvent.  However,
> calling it (with the appropriate "this" object) should work fine.

I tried following:

if (originalHandler.handleEvent)
originalHandler.handleEvent(event);
else
originalHandler.call(xhrRequest, event);

Where:
* The originalHandler is the original onreadystatechange (so, should
be a function object)
* xhrRequest is XMLHttpRequest object

And it causes crash:
https://crash-stats.mozilla.com/report/index/bp-2fcfa090-a26b-43d6-bbcc-45aef2120403

Perhaps I am doing it wrong? (but it shouldn't crash anyway).

Honza



Gavin Sharp

unread,
Apr 3, 2012, 11:02:53 AM4/3/12
to Jan Honza Odvarko, dev-pl...@lists.mozilla.org
On Mon, Apr 2, 2012 at 10:47 PM, Jan Honza Odvarko <odv...@gmail.com> wrote:
> And it causes crash:
> https://crash-stats.mozilla.com/report/index/bp-2fcfa090-a26b-43d6-bbcc-45aef2120403

This looks like bug 737780. It looks like a potential fix landed on
mozilla-central earlier today.

Gavin

Boris Zbarsky

unread,
Apr 3, 2012, 11:44:51 AM4/3/12
to
On 4/3/12 1:47 AM, Jan Honza Odvarko wrote:
> And it causes crash:
> https://crash-stats.mozilla.com/report/index/bp-2fcfa090-a26b-43d6-bbcc-45aef2120403
>
> Perhaps I am doing it wrong? (but it shouldn't crash anyway).

Indeed, it should not crash. Can you please file a bug on this and cc
me and peterv? It looks like we may be missing a cross-compartment
wrapper somewhere here, based on the bug Gavin linked to!

If you can attach a testcase reproducing the problem to the bug, that
would be _very_ helpful.

Thanks,
Boris

Jan Honza Odvarko

unread,
Apr 4, 2012, 2:33:17 AM4/4/12
to
Reply all
Reply to author
Forward
0 new messages