On Sat, Mar 19, 2011 at 1:34 PM, Peter van der Zee <e...@qfox.nl> wrote:

> [...]
> And re: return value. Some scripts might rely on the fact that the timers
> return a number (an int, even). So if backwards compat is important (and it
> always is), you can't really break with `typeof token == 'number'`. So if
> there was a new native type, typeof would still have to return 'number',
> which is not very desirable (null anyone?...).
>

I agree that if compat requires `typeof token === 'number'`, then the token
itself must remain a number. Has anyone seen seen any such dependency in the
wild?




> Also, given that setTimeout and setInterval are already implemented in
> browsers for a while with returning numbers, is it really still a problem we
> need to solve? Will browsers really start implementing a setTimeout that
> returns a special timer object? I think any implementation that uses
> "setTimeout" and "setInterval" would have to mimic the current behavior in
> the browser...
>

In Caja, setTimeout/setInterval does indeed return an object, where `typeof
token === 'object'` and that object is accepted by Caja's
clearTimeout/clearInterval. AFAIK, we have not encountered a single
incompatibility as a result of this change. If anyone knows a
counter-example in the wild, please speak up.

And yes, this is a problem that SES needs to solve.



>
> (Even if we implement a host-environment yield kind of thing, I'd still
> prefer a built-in setTimeout abstraction built on it for convience. But I
> don't know about the security or whatever involved.)
>
> Kyle: If there was a way to determine which timers are currently queued,
> would that solve your problem? That's probably the only thing I'm missing
> right now from the timer api: Some array with all queued timeouts/intervals.
> Maybe that's to prevent the clear "attack" mentioned before, looping all
> numbers and clearing them. I don't know. But if you had such an array
> (either with just ints, or even an object with {int,time/interval,callback})
> would that suffice for you? You could check the list and block while there
> are timers left.
>
> - peter
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
    Cheers,
    --MarkM
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to