Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / media / media-source / mediasource-appendwindow.html
blob1a9fcd91589d7d1ee26e651bc842b446c1599692
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 mediasource_test(function(test, mediaElement, mediaSource)
14 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE);
15 assert_true(sourceBuffer != null, 'New SourceBuffer returned');
17 sourceBuffer.appendWindowStart = 100.0;
18 sourceBuffer.appendWindowEnd = 500.0;
19 assert_equals(sourceBuffer.appendWindowStart, 100.0, 'appendWindowStart is correctly set');
20 assert_equals(sourceBuffer.appendWindowEnd, 500.0, 'appendWindowEnd is correctly set');
22 sourceBuffer.appendWindowStart = 200.0;
23 sourceBuffer.appendWindowEnd = 400.0;
24 assert_equals(sourceBuffer.appendWindowStart, 200.0, 'appendWindowStart is correctly reset');
25 assert_equals(sourceBuffer.appendWindowEnd, 400.0, 'appendWindowEnd is correctly reset');
26 test.done();
27 }, 'Test correctly reset appendWindowStart and appendWindowEnd values');
29 mediasource_test(function(test, mediaElement, mediaSource)
31 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE);
32 assert_true(sourceBuffer != null, 'New SourceBuffer returned');
33 sourceBuffer.appendWindowEnd = 500.0;
35 assert_throws({name: 'TypeError'},
36 function() { sourceBuffer.appendWindowStart = Number.NEGATIVE_INFINITY; },
37 'set appendWindowStart throws an exception for Number.NEGATIVE_INFINITY.');
39 assert_throws({name: 'TypeError'},
40 function() { sourceBuffer.appendWindowStart = Number.POSITIVE_INFINITY; },
41 'set appendWindowStart throws an exception for Number.POSITIVE_INFINITY.');
43 assert_throws({name: 'TypeError'},
44 function() { sourceBuffer.appendWindowStart = Number.NaN; },
45 'set appendWindowStart throws an exception for Number.NaN.');
47 assert_throws('InvalidAccessError',
48 function() { sourceBuffer.appendWindowStart = 600.0; },
49 'set appendWindowStart throws an exception when greater than appendWindowEnd.');
51 assert_throws('InvalidAccessError',
52 function() { sourceBuffer.appendWindowStart = sourceBuffer.appendWindowEnd; },
53 'set appendWindowStart throws an exception when equal to appendWindowEnd.');
55 assert_throws('InvalidAccessError',
56 function() { sourceBuffer.appendWindowEnd = sourceBuffer.appendWindowStart; },
57 'set appendWindowEnd throws an exception when equal to appendWindowStart.');
59 assert_throws('InvalidAccessError',
60 function() { sourceBuffer.appendWindowEnd = sourceBuffer.appendWindowStart - 1; },
61 'set appendWindowEnd throws an exception if less than appendWindowStart.');
63 assert_throws('InvalidAccessError',
64 function() { sourceBuffer.appendWindowStart = -100.0; },
65 'set appendWindowStart throws an exception when less than 0.');
67 assert_throws('InvalidAccessError',
68 function() { sourceBuffer.appendWindowEnd = -100.0; },
69 'set appendWindowEnd throws an exception when less than 0.');
71 assert_throws('InvalidAccessError',
72 function() { sourceBuffer.appendWindowEnd = Number.NaN; },
73 'set appendWindowEnd throws an exception if NaN.');
75 assert_throws('InvalidAccessError',
76 function() { sourceBuffer.appendWindowEnd = undefined; },
77 'set appendWindowEnd throws an exception if undefined.');
79 assert_throws({name: 'TypeError'},
80 function() { sourceBuffer.appendWindowStart = undefined; },
81 'set appendWindowStart throws an exception if undefined.');
83 test.done();
84 }, 'Test set wrong values to appendWindowStart and appendWindowEnd.');
86 mediasource_test(function(test, mediaElement, mediaSource)
88 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE);
89 assert_true(sourceBuffer != null, 'New SourceBuffer returned');
91 sourceBuffer.appendWindowStart = '';
92 assert_true(sourceBuffer.appendWindowStart == 0, 'appendWindowStart is 0');
94 sourceBuffer.appendWindowStart = '10';
95 assert_true(sourceBuffer.appendWindowStart == 10, 'appendWindowStart is 10');
97 sourceBuffer.appendWindowStart = null;
98 assert_true(sourceBuffer.appendWindowStart == 0, 'appendWindowStart is 0');
100 sourceBuffer.appendWindowStart = true;
101 assert_true(sourceBuffer.appendWindowStart == 1, 'appendWindowStart is 1');
103 sourceBuffer.appendWindowStart = false;
104 assert_true(sourceBuffer.appendWindowStart == 0, 'appendWindowStart is 0');
106 sourceBuffer.appendWindowEnd = '100';
107 assert_true(sourceBuffer.appendWindowEnd == 100, 'appendWindowEnd is 100');
109 test.done();
111 }, 'Test set correct values to appendWindowStart and appendWindowEnd.');
113 mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
115 mediaSource.removeSourceBuffer(sourceBuffer);
116 assert_throws('InvalidStateError',
117 function() { sourceBuffer.appendWindowStart = 100.0; },
118 'set appendWindowStart throws an exception when mediasource object is not associated with a buffer.');
120 assert_throws('InvalidStateError',
121 function() { sourceBuffer.appendWindowEnd = 500.0; },
122 'set appendWindowEnd throws an exception when mediasource object is not associated with a buffer.');
123 test.done();
125 }, 'Test appendwindow throw error when mediasource object is not associated with a sourebuffer.');
127 mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
129 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
130 sourceBuffer.appendBuffer(mediaData);
131 assert_true(sourceBuffer.updating, 'updating attribute is true');
133 assert_throws('InvalidStateError',
134 function() { sourceBuffer.appendWindowStart = 100.0; },
135 'set appendWindowStart throws an exception when there is a pending append.');
137 assert_throws('InvalidStateError',
138 function() { sourceBuffer.appendWindowEnd = 500.0; },
139 'set appendWindowEnd throws an exception when there is a pending append.');
141 test.waitForExpectedEvents(function()
143 assert_false(sourceBuffer.updating, 'updating attribute is false');
144 test.done();
146 }, 'Test set appendWindowStart and appendWindowEnd when source buffer updating.');
148 mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
150 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
151 sourceBuffer.appendBuffer(mediaData);
152 assert_true(sourceBuffer.updating, 'updating attribute is true');
154 sourceBuffer.abort();
155 assert_equals(sourceBuffer.appendWindowStart, 0, 'appendWindowStart is 0 after an abort');
156 assert_equals(sourceBuffer.appendWindowEnd, Number.POSITIVE_INFINITY,
157 'appendWindowStart is POSITIVE_INFINITY after an abort');
158 test.waitForExpectedEvents(function()
160 assert_false(sourceBuffer.updating, 'updating attribute is false');
161 test.done();
163 }, 'Test appendWindowStart and appendWindowEnd value after a sourceBuffer.abort().');
165 mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
167 assert_equals(sourceBuffer.appendWindowStart, 0, 'appendWindowStart is 0 initially');
168 assert_equals(sourceBuffer.appendWindowEnd, Number.POSITIVE_INFINITY,
169 'appendWindowStart is POSITIVE_INFINITY initially');
170 test.waitForExpectedEvents(function()
172 test.done();
174 }, 'Test read appendWindowStart and appendWindowEnd initial values.');
176 </script>
177 </body>
178 </html>