This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 19947 - Need to clearly define this objects for setTimeout and setInterval
Summary: Need to clearly define this objects for setTimeout and setInterval
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-13 00:12 UTC by contributor
Modified: 2013-03-06 23:03 UTC (History)
3 users (show)

See Also:


Attachments

Description contributor 2012-11-13 00:12:38 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html
Multipage: http://www.whatwg.org/C#timers
Complete: http://www.whatwg.org/c#timers

Comment:
Need to clearly define this objects for setTimeout and setInterval

Posted from: 64.213.70.194 by bzbarsky@mit.edu
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:19.0) Gecko/19.0 Firefox/19.0
Comment 1 Boris Zbarsky 2012-11-13 00:15:52 UTC
If code in window A calls setTimeout on window B with a function from window A, then when the function is called it's interoperably using window B as "this".  That includes strict mode functions at least in Chrome and Firefox.

The spec right now says to pass undefined as this, which should cause the function to use "the" global. But of course ES doesn't define multi-global situations in any way.... and in any case what the spec says is not compatible with what UAs actually do.
Comment 2 Ian 'Hixie' Hickson 2013-01-07 19:28:12 UTC
So I should just pass the WindowProxy object of the Window object on which setTimeout/setInterval was called, instead of passing undefined?
Comment 3 Boris Zbarsky 2013-01-07 19:35:26 UTC
That's what I'm doing in the Gecko implementation of this stuff on top of WebIDL, yeah.
Comment 4 contributor 2013-03-06 23:03:41 UTC
Checked in as WHATWG revision r7737.
Check-in comment: Try to more closely match reality.
http://html5.org/tools/web-apps-tracker?from=7736&to=7737