Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: LayoutTests/http/tests/media/media-source/mediasource-duration-boundaryconditions.html

Issue 245893002: Improve unprefixed MediaSource test coverage. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="/w3c/resources/testharness.js"></script>
5 <script src="/w3c/resources/testharnessreport.js"></script>
6 <script src="mediasource-util.js"></script>
7 <link rel='stylesheet' href='/w3c/resources/testharness.css'>
8 </head>
9 <body>
10 <div id="log"></div>
11 <script>
12 function DurationBoundaryConditionTest(testDurationValue, expectedErro r, description)
13 {
14 return mediasource_testafterdataloaded(function(test, mediaElement , mediaSource, segmentInfo, sourceBuffer, mediaData)
15 {
16 // Append initialization segment.
17 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
18 test.expectEvent(mediaElement, 'loadedmetadata', 'mediaElement ');
19 sourceBuffer.appendBuffer(MediaSourceUtil.extractSegmentData(m ediaData, segmentInfo.init));
20 test.waitForExpectedEvents(function()
21 {
22 if (expectedError) {
23 assert_throws(expectedError,
24 function() { mediaSource.duration = testDurationVa lue; },
25 "mediaSource.duration assignment throws an excepti on for " + testDurationValue);
26 test.done();
27 return;
28 }
29
30 mediaSource.duration = testDurationValue;
31
32 assert_equals(mediaSource.duration, testDurationValue, "me diaSource.duration");
33 assert_equals(mediaElement.duration, testDurationValue, "m ediaElement.duration");
34
35 test.expectEvent(mediaElement, 'durationchange', 'mediaEle ment');
36 test.waitForExpectedEvents(function()
37 {
38 assert_equals(mediaSource.duration, testDurationValue, "mediaSource.duration");
39 assert_equals(mediaElement.duration, testDurationValue , "mediaElement.duration");
40 test.done();
41 });
42 });
43
44 }, description);
45 }
46
47 DurationBoundaryConditionTest(Math.pow(2, 31) - 1, null, "Set duration to 2^31 - 1");
48 DurationBoundaryConditionTest(1, null, "Set duration to 1");
49 DurationBoundaryConditionTest(Number.MAX_VALUE, null, "Set duration to Number.MAX_VALUE");
50 DurationBoundaryConditionTest(Number.MIN_VALUE, null, "Set duration to Number.MIN_VALUE");
51 DurationBoundaryConditionTest(Number.MAX_VALUE - 1, null, "Set duratio n to Number.MAX_VALUE - 1");
52 DurationBoundaryConditionTest(Number.MIN_VALUE - 1, "InvalidAccessErro r", "Set duration to Number.MIN_VALUE - 1");
53 DurationBoundaryConditionTest(Number.POSITIVE_INFINITY, null, "Set dur ation to Number.POSITIVE_INFINITY");
54 DurationBoundaryConditionTest(Number.NEGATIVE_INFINITY, "InvalidAccess Error", "Set duration to Number.NEGATIVE_INFINITY");
55 DurationBoundaryConditionTest(-1 * Number.MAX_VALUE, "InvalidAccessErr or", "Set duration to lowest value.");
56 DurationBoundaryConditionTest(-101.9, "InvalidAccessError", "Set durat ion to a negative double.");
57 DurationBoundaryConditionTest(101.9, null, "Set duration to a positive double.");
58 DurationBoundaryConditionTest(0, null, "Set duration to zero");
59 DurationBoundaryConditionTest(NaN, "InvalidAccessError", "Set duration to NaN");
60 </script>
61 </body>
62 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698