Bug 154245

Summary: Regression(r196563): It is no longer possible to call window.addEventListener without an explicit 'this'
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: BindingsAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, cgarcia, commit-queue, darin, ggaren, ossy, rniwa, sam
Priority: P2 Keywords: WebExposed
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
URL: http://heycam.github.io/webidl/#ImplicitThis
Bug Depends on:    
Bug Blocks: 154170    
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2016-02-15 09:02:48 PST
Regression(r196563): It is no longer possible to call window.addEventListener without an explicit 'this'.

E.g. the following no longer works:
var f = window.addEventListener
f.call(undefined, "click", function() {});

It should use the global window object.

This is causing Dromaeo/cssquery-dojo.html to fail.
Comment 1 Chris Dumez 2016-02-15 09:45:55 PST
Created attachment 271346 [details]
Patch
Comment 2 Ryosuke Niwa 2016-02-15 12:03:20 PST
Comment on attachment 271346 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=271346&action=review

> LayoutTests/fast/dom/Window/addEventListener-implicit-this.html:23
> +bodyDispatchEventFunction = document.body.dispatchEvent;
> +shouldBeTrue("bodyDispatchEventFunction.call(undefined, new Event('myevent'))");

Why don't we try some non-Node event target such as XHR object?
Comment 3 Chris Dumez 2016-02-15 12:09:04 PST
Created attachment 271353 [details]
Patch
Comment 4 Chris Dumez 2016-02-15 12:09:52 PST
Comment on attachment 271353 [details]
Patch

Clearing flags on attachment: 271353

Committed r196588: <http://trac.webkit.org/changeset/196588>
Comment 5 Chris Dumez 2016-02-15 12:09:57 PST
All reviewed patches have been landed.  Closing bug.
Comment 6 Chris Dumez 2016-02-15 12:14:04 PST
(In reply to comment #2)
> Comment on attachment 271346 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=271346&action=review
> 
> > LayoutTests/fast/dom/Window/addEventListener-implicit-this.html:23
> > +bodyDispatchEventFunction = document.body.dispatchEvent;
> > +shouldBeTrue("bodyDispatchEventFunction.call(undefined, new Event('myevent'))");
> 
> Why don't we try some non-Node event target such as XHR object?

I added coverage for XHR before landing and checks that the test behaves the same in Chrome and Firefox.