RE: Tests for asynchronous events (10.2, 11.2)

On Tue, Sep 2, 2014 at 8:28 AM, Olli Pettay <olli@pettay.fi> wrote:
>
> On 09/02/2014 06:25 PM, Olli Pettay wrote:
>>
>> On 09/02/2014 05:53 PM, Olli Pettay wrote:
>>>
>>> I think the issue here is that in one place the spec says got/lostpointercapture are async (sure, the table is non-normative, but still),
>>> and then https://dvcs.w3.org/hg/pointerevents/raw-file/tip/pointerEvents.html#process-pending-pointer-capture and other places in the spec say that
>>> in some cases the got/lostpointercapture is dispatched in more sync manner.
>>>
>>> So, I think the non-normative table should says sync/async for got/lostpointercapture.
>>
>> Or am I thinking a wrong case here.
>> setTimeout certainly needs two task before it is actually runs, and async events only one.
>
> But in fact, got/lostpointercapture aren't really async, but still, setTimeout
> doesn't guarantee anything here. Effectively racy test, as far as I see.

Per Olli's suggestion, I've updated the spec to say sync/async [1].  I agree the setTimeout() doesn't work in the test.  The algorithm in the spec is that these events get fired right before the next pointer event (that is not got/lost capture) [2]. So you can't pick a timeout guaranteed to fire at the right moment. For the test, I'd recommend the flag system Olli suggested on the call (or at least I think this was what you said, Olli :-)):

1. Call setPointerCapture()
2. set flag true
3. In the gotpointercapture handler, check that the flag is true and then reset to false
4. In the next pointer event that is not got/lost capture, check that the flag is false

-Jacob

[1] https://dvcs.w3.org/hg/pointerevents/rev/3c757c7ca2d9 
[2] https://dvcs.w3.org/hg/pointerevents/raw-file/tip/pointerEvents.html#firing-events-using-the-pointerevent-interface 

Received on Friday, 5 September 2014 18:23:48 UTC