Bug 113438

Summary: Add LayoutTests that verify MediaSource.duration behavior.
Product: WebKit Reporter: Aaron Colwell <acolwell>
Component: New BugsAssignee: Aaron Colwell <acolwell>
Status: RESOLVED FIXED    
Severity: Normal CC: eric.carlson, feature-media-reviews, jer.noble, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Aaron Colwell 2013-03-27 13:40:13 PDT
Add LayoutTests that verify MediaSource.duration behavior.
Comment 1 Aaron Colwell 2013-03-27 13:40:38 PDT
Created attachment 195388 [details]
Patch
Comment 2 Aaron Colwell 2013-03-27 13:44:14 PDT
Comment on attachment 195388 [details]
Patch

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

> LayoutTests/http/tests/media/media-source/video-media-source-duration-boundaryconditions-expected.txt:29
> +EXPECTED (mediaSource.duration == '1.7976931348623157e+308'), OBSERVED '3.4028234663852886e+38' FAIL

This and the two other faiures below are expected right now because HTMLMediaElement.duration is a float instead of a double like the spec state. Eventhough MediaSource.duration is declared as a double, the return value is truncated to the float range so that the mediaSource.duration == video.duration condition required by the Media Source spec is always true. When HTMLMediaElement.duration is changed to a double, then these expectations will be updated.
Comment 3 Eric Carlson 2013-03-29 11:37:20 PDT
Comment on attachment 195388 [details]
Patch

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

> LayoutTests/http/tests/media/media-source/video-media-source-duration-boundaryconditions-expected.txt:6
> +onDurationChange : video.duration is 6.041999816894531

I don't think it makes sense to log time values with full precision, or every port may need to have unique results for the same test.  Comparing the value is fine, but use reportExpected(() so you just log success or failure. See video-loop.html for an example.

> LayoutTests/http/tests/media/media-source/video-media-source-duration-boundaryconditions.html:24
> +          consoleWrite('EXPECTED (mediaSource.duration == video.duration) OK');

Can you use reportExpected( instead of hard coding this?

> LayoutTests/http/tests/media/media-source/video-media-source-duration-boundaryconditions.html:27
> +        consoleWrite('EXPECTED (mediaSource.duration == video.duration), OBSERVED ' + mediaSource.duration + ' vs ' + video.duration + ' FAIL');

Ditto.
Comment 4 Aaron Colwell 2013-03-29 14:04:49 PDT
Comment on attachment 195388 [details]
Patch

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

>> LayoutTests/http/tests/media/media-source/video-media-source-duration-boundaryconditions-expected.txt:6
>> +onDurationChange : video.duration is 6.041999816894531
> 
> I don't think it makes sense to log time values with full precision, or every port may need to have unique results for the same test.  Comparing the value is fine, but use reportExpected(() so you just log success or failure. See video-loop.html for an example.

Done

>> LayoutTests/http/tests/media/media-source/video-media-source-duration-boundaryconditions.html:24
>> +          consoleWrite('EXPECTED (mediaSource.duration == video.duration) OK');
> 
> Can you use reportExpected( instead of hard coding this?

Yes. Done.

>> LayoutTests/http/tests/media/media-source/video-media-source-duration-boundaryconditions.html:27
>> +        consoleWrite('EXPECTED (mediaSource.duration == video.duration), OBSERVED ' + mediaSource.duration + ' vs ' + video.duration + ' FAIL');
> 
> Ditto.

Done.
Comment 5 Aaron Colwell 2013-03-29 14:05:17 PDT
Created attachment 195796 [details]
Patch
Comment 6 Eric Carlson 2013-03-29 14:32:47 PDT
Comment on attachment 195796 [details]
Patch

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

> LayoutTests/http/tests/media/media-source/video-media-source-duration-boundaryconditions-expected.txt:29
> +EXPECTED (mediaSource.duration == 'testDurationValue'), OBSERVED '3.4028234663852886e+38' FAIL

Are these failures expected? If so, this suffers from the same problem as the previous patch: not all ports will have exactly the same duration so each will need custom results.
Comment 7 Aaron Colwell 2013-03-29 14:49:11 PDT
(In reply to comment #6)
> (From update of attachment 195796 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=195796&action=review
> 
> > LayoutTests/http/tests/media/media-source/video-media-source-duration-boundaryconditions-expected.txt:29
> > +EXPECTED (mediaSource.duration == 'testDurationValue'), OBSERVED '3.4028234663852886e+38' FAIL
> 
> Are these failures expected? If so, this suffers from the same problem as the previous patch: not all ports will have exactly the same duration so each will need custom results.

Yes these are expected because HTMLMediaElement.duration is a float and MediaSource.duration is a double. Until HTMLMediaElement.duration is updated to a double to match the HTML5 spec, these test cases will fail. :/ These expectations were just to capture the fact that MediaSource.duration truncates itself to the float range so that MediaSource.duration always equals HTMLMediaElement.duration.
Comment 8 Eric Carlson 2013-03-29 15:02:11 PDT
Comment on attachment 195796 [details]
Patch

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

>>> LayoutTests/http/tests/media/media-source/video-media-source-duration-boundaryconditions-expected.txt:29
>>> +EXPECTED (mediaSource.duration == 'testDurationValue'), OBSERVED '3.4028234663852886e+38' FAIL
>> 
>> Are these failures expected? If so, this suffers from the same problem as the previous patch: not all ports will have exactly the same duration so each will need custom results.
> 
> Yes these are expected because HTMLMediaElement.duration is a float and MediaSource.duration is a double. Until HTMLMediaElement.duration is updated to a double to match the HTML5 spec, these test cases will fail. :/ These expectations were just to capture the fact that MediaSource.duration truncates itself to the float range so that MediaSource.duration always equals HTMLMediaElement.duration.

Why not just fix HTMLMediaElement? Have you filed a bug about the issue?
Comment 9 Aaron Colwell 2013-03-29 15:08:19 PDT
(In reply to comment #8)
> (From update of attachment 195796 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=195796&action=review
> 
> >>> LayoutTests/http/tests/media/media-source/video-media-source-duration-boundaryconditions-expected.txt:29
> >>> +EXPECTED (mediaSource.duration == 'testDurationValue'), OBSERVED '3.4028234663852886e+38' FAIL
> >> 
> >> Are these failures expected? If so, this suffers from the same problem as the previous patch: not all ports will have exactly the same duration so each will need custom results.
> > 
> > Yes these are expected because HTMLMediaElement.duration is a float and MediaSource.duration is a double. Until HTMLMediaElement.duration is updated to a double to match the HTML5 spec, these test cases will fail. :/ These expectations were just to capture the fact that MediaSource.duration truncates itself to the float range so that MediaSource.duration always equals HTMLMediaElement.duration.
> 
> Why not just fix HTMLMediaElement? Have you filed a bug about the issue?

I plan on doing so. My initial survey of the code made me think this was going to be a large disruptive yak shave. I'll file a bug and start working on a patch to see how bad it really ends up being.
Comment 10 WebKit Review Bot 2013-03-29 15:16:21 PDT
Comment on attachment 195796 [details]
Patch

Clearing flags on attachment: 195796

Committed r147255: <http://trac.webkit.org/changeset/147255>
Comment 11 WebKit Review Bot 2013-03-29 15:16:24 PDT
All reviewed patches have been landed.  Closing bug.