OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="/w3c/resources/testharness.js"></script> | 4 <script src="/w3c/resources/testharness.js"></script> |
5 <script src="/w3c/resources/testharnessreport.js"></script> | 5 <script src="/w3c/resources/testharnessreport.js"></script> |
6 <script src="mediasource-util.js"></script> | 6 <script src="mediasource-util.js"></script> |
7 <link rel='stylesheet' href='/w3c/resources/testharness.css'> | 7 <link rel='stylesheet' href='/w3c/resources/testharness.css'> |
8 </head> | 8 </head> |
9 <body> | 9 <body> |
10 <div id="log"></div> | 10 <div id="log"></div> |
11 <script> | 11 <script> |
12 mediasource_test(function(test, mediaElement, mediaSource) | 12 mediasource_test(function(test, mediaElement, mediaSource) |
13 { | 13 { |
14 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_VIDEO_TYPE); | 14 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_VIDEO_TYPE); |
15 assert_true(sourceBuffer != null, "New SourceBuffer returned"); | 15 assert_true(sourceBuffer != null, 'New SourceBuffer returned'); |
16 | 16 |
17 sourceBuffer.appendWindowStart = 100.0; | 17 sourceBuffer.appendWindowStart = 100.0; |
18 sourceBuffer.appendWindowEnd = 500.0; | 18 sourceBuffer.appendWindowEnd = 500.0; |
19 assert_equals(sourceBuffer.appendWindowStart, 100.0, "appendWindow
Start is correctly set'"); | 19 assert_equals(sourceBuffer.appendWindowStart, 100.0, 'appendWindow
Start is correctly set'); |
20 assert_equals(sourceBuffer.appendWindowEnd, 500.0, "appendWindowEn
d is correctly set'"); | 20 assert_equals(sourceBuffer.appendWindowEnd, 500.0, 'appendWindowEn
d is correctly set'); |
21 | 21 |
22 sourceBuffer.appendWindowStart = 200.0; | 22 sourceBuffer.appendWindowStart = 200.0; |
23 sourceBuffer.appendWindowEnd = 400.0; | 23 sourceBuffer.appendWindowEnd = 400.0; |
24 assert_equals(sourceBuffer.appendWindowStart, 200.0, "appendWindow
Start is correctly reset'"); | 24 assert_equals(sourceBuffer.appendWindowStart, 200.0, 'appendWindow
Start is correctly reset'); |
25 assert_equals(sourceBuffer.appendWindowEnd, 400.0, "appendWindowEn
d is correctly reset'"); | 25 assert_equals(sourceBuffer.appendWindowEnd, 400.0, 'appendWindowEn
d is correctly reset'); |
26 test.done(); | 26 test.done(); |
27 }, "Test correctly reset appendWindowStart and appendWindowEnd values"
); | 27 }, 'Test correctly reset appendWindowStart and appendWindowEnd values'
); |
28 | 28 |
29 mediasource_test(function(test, mediaElement, mediaSource) | 29 mediasource_test(function(test, mediaElement, mediaSource) |
30 { | 30 { |
31 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_VIDEO_TYPE); | 31 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_VIDEO_TYPE); |
32 assert_true(sourceBuffer != null, "New SourceBuffer returned"); | 32 assert_true(sourceBuffer != null, 'New SourceBuffer returned'); |
33 sourceBuffer.appendWindowEnd = 500.0; | 33 sourceBuffer.appendWindowEnd = 500.0; |
34 | 34 |
35 assert_throws({name: "TypeError"}, | 35 assert_throws({name: 'TypeError'}, |
36 function() { sourceBuffer.appendWindowStart = Number.NEGATIVE_
INFINITY; }, | 36 function() { sourceBuffer.appendWindowStart = Number.NEGATIVE_
INFINITY; }, |
37 "set appendWindowStart throws an exception for Number.NEGATIVE
_INFINITY."); | 37 'set appendWindowStart throws an exception for Number.NEGATIVE
_INFINITY.'); |
38 | 38 |
39 assert_throws({name: "TypeError"}, | 39 assert_throws({name: 'TypeError'}, |
40 function() { sourceBuffer.appendWindowStart = Number.POSITIVE_
INFINITY; }, | 40 function() { sourceBuffer.appendWindowStart = Number.POSITIVE_
INFINITY; }, |
41 "set appendWindowStart throws an exception for Number.POSITIVE
_INFINITY."); | 41 'set appendWindowStart throws an exception for Number.POSITIVE
_INFINITY.'); |
42 | 42 |
43 assert_throws({name: "TypeError"}, | 43 assert_throws({name: 'TypeError'}, |
44 function() { sourceBuffer.appendWindowStart = Number.NaN; }, | 44 function() { sourceBuffer.appendWindowStart = Number.NaN; }, |
45 "set appendWindowStart throws an exception for Number.NaN."); | 45 'set appendWindowStart throws an exception for Number.NaN.'); |
46 | 46 |
47 assert_throws("InvalidAccessError", | 47 assert_throws('InvalidAccessError', |
48 function() { sourceBuffer.appendWindowStart = 600.0; }, | 48 function() { sourceBuffer.appendWindowStart = 600.0; }, |
49 "set appendWindowStart throws an exception when greater than a
ppendWindowEnd."); | 49 'set appendWindowStart throws an exception when greater than a
ppendWindowEnd.'); |
50 | 50 |
51 assert_throws("InvalidAccessError", | 51 assert_throws('InvalidAccessError', |
52 function() { sourceBuffer.appendWindowStart = sourceBuffer.app
endWindowEnd; }, | 52 function() { sourceBuffer.appendWindowStart = sourceBuffer.app
endWindowEnd; }, |
53 "set appendWindowStart throws an exception when equal to appen
dWindowEnd."); | 53 'set appendWindowStart throws an exception when equal to appen
dWindowEnd.'); |
54 | 54 |
55 assert_throws("InvalidAccessError", | 55 assert_throws('InvalidAccessError', |
| 56 function() { sourceBuffer.appendWindowEnd = sourceBuffer.appen
dWindowStart; }, |
| 57 'set appendWindowEnd throws an exception when equal to appendW
indowStart.'); |
| 58 |
| 59 assert_throws('InvalidAccessError', |
| 60 function() { sourceBuffer.appendWindowEnd = sourceBuffer.appen
dWindowStart - 1; }, |
| 61 'set appendWindowEnd throws an exception if less than appendWi
ndowStart.'); |
| 62 |
| 63 assert_throws('InvalidAccessError', |
56 function() { sourceBuffer.appendWindowStart = -100.0; }, | 64 function() { sourceBuffer.appendWindowStart = -100.0; }, |
57 "set appendWindowStart throws an exception when less than 0.")
; | 65 'set appendWindowStart throws an exception when less than 0.')
; |
58 | 66 |
59 assert_throws("InvalidAccessError", | 67 assert_throws('InvalidAccessError', |
| 68 function() { sourceBuffer.appendWindowEnd = -100.0; }, |
| 69 'set appendWindowEnd throws an exception when less than 0.'); |
| 70 |
| 71 assert_throws('InvalidAccessError', |
60 function() { sourceBuffer.appendWindowEnd = Number.NaN; }, | 72 function() { sourceBuffer.appendWindowEnd = Number.NaN; }, |
61 "set appendWindowEnd throws an exception if NaN."); | 73 'set appendWindowEnd throws an exception if NaN.'); |
62 | 74 |
63 assert_throws("InvalidAccessError", | 75 assert_throws('InvalidAccessError', |
64 function() { sourceBuffer.appendWindowEnd = undefined; }, | 76 function() { sourceBuffer.appendWindowEnd = undefined; }, |
65 "set appendWindowEnd throws an exception if undefined."); | 77 'set appendWindowEnd throws an exception if undefined.'); |
66 | 78 |
67 assert_throws({name: "TypeError"}, | 79 assert_throws({name: 'TypeError'}, |
68 function() { sourceBuffer.appendWindowStart = undefined; }, | 80 function() { sourceBuffer.appendWindowStart = undefined; }, |
69 "set appendWindowStart throws an exception if undefined."); | 81 'set appendWindowStart throws an exception if undefined.'); |
70 | 82 |
71 test.done(); | 83 test.done(); |
72 }, "Test set wrong values to appendWindowStart and appendWindowEnd."); | 84 }, 'Test set wrong values to appendWindowStart and appendWindowEnd.'); |
73 | 85 |
74 mediasource_test(function(test, mediaElement, mediaSource) | 86 mediasource_test(function(test, mediaElement, mediaSource) |
75 { | 87 { |
76 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_VIDEO_TYPE); | 88 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_VIDEO_TYPE); |
77 assert_true(sourceBuffer != null, "New SourceBuffer returned"); | 89 assert_true(sourceBuffer != null, 'New SourceBuffer returned'); |
78 | 90 |
79 sourceBuffer.appendWindowStart = ""; | 91 sourceBuffer.appendWindowStart = ''; |
80 assert_true(sourceBuffer.appendWindowStart == 0, "appendWindowStar
t is 0"); | 92 assert_true(sourceBuffer.appendWindowStart == 0, 'appendWindowStar
t is 0'); |
81 | 93 |
82 sourceBuffer.appendWindowStart = "10"; | 94 sourceBuffer.appendWindowStart = '10'; |
83 assert_true(sourceBuffer.appendWindowStart == 10, "appendWindowSta
rt is 10"); | 95 assert_true(sourceBuffer.appendWindowStart == 10, 'appendWindowSta
rt is 10'); |
84 | 96 |
85 sourceBuffer.appendWindowStart = null; | 97 sourceBuffer.appendWindowStart = null; |
86 assert_true(sourceBuffer.appendWindowStart == 0, "appendWindowStar
t is 0"); | 98 assert_true(sourceBuffer.appendWindowStart == 0, 'appendWindowStar
t is 0'); |
87 | 99 |
88 sourceBuffer.appendWindowStart = true; | 100 sourceBuffer.appendWindowStart = true; |
89 assert_true(sourceBuffer.appendWindowStart == 1, "appendWindowStar
t is 1"); | 101 assert_true(sourceBuffer.appendWindowStart == 1, 'appendWindowStar
t is 1'); |
90 | 102 |
91 sourceBuffer.appendWindowStart = false; | 103 sourceBuffer.appendWindowStart = false; |
92 assert_true(sourceBuffer.appendWindowStart == 0, "appendWindowStar
t is 0"); | 104 assert_true(sourceBuffer.appendWindowStart == 0, 'appendWindowStar
t is 0'); |
93 | 105 |
94 sourceBuffer.appendWindowEnd = "100"; | 106 sourceBuffer.appendWindowEnd = '100'; |
95 assert_true(sourceBuffer.appendWindowEnd == 100, "appendWindowEnd
is 100"); | 107 assert_true(sourceBuffer.appendWindowEnd == 100, 'appendWindowEnd
is 100'); |
96 | 108 |
97 test.done(); | 109 test.done(); |
98 | 110 |
99 }, "Test set correct values to appendWindowStart and appendWindowEnd."
); | 111 }, 'Test set correct values to appendWindowStart and appendWindowEnd.'
); |
100 | 112 |
101 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 113 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
102 { | 114 { |
103 mediaSource.removeSourceBuffer(sourceBuffer); | 115 mediaSource.removeSourceBuffer(sourceBuffer); |
104 assert_throws("InvalidStateError", | 116 assert_throws('InvalidStateError', |
105 function() { sourceBuffer.appendWindowStart = 100.0; }, | 117 function() { sourceBuffer.appendWindowStart = 100.0; }, |
106 "set appendWindowStart throws an exception when mediasource ob
ject is not associated with a buffer."); | 118 'set appendWindowStart throws an exception when mediasource ob
ject is not associated with a buffer.'); |
107 | 119 |
108 assert_throws("InvalidStateError", | 120 assert_throws('InvalidStateError', |
109 function() { sourceBuffer.appendWindowEnd = 500.0; }, | 121 function() { sourceBuffer.appendWindowEnd = 500.0; }, |
110 "set appendWindowEnd throws an exception when mediasource obje
ct is not associated with a buffer."); | 122 'set appendWindowEnd throws an exception when mediasource obje
ct is not associated with a buffer.'); |
111 test.done(); | 123 test.done(); |
112 | 124 |
113 }, "Test appendwindow throw error when mediasource object is not assoc
iated with a sourebuffer."); | 125 }, 'Test appendwindow throw error when mediasource object is not assoc
iated with a sourebuffer.'); |
114 | 126 |
115 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 127 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
116 { | 128 { |
117 test.expectEvent(sourceBuffer, "updateend", "sourceBuffer"); | 129 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer'); |
118 sourceBuffer.appendBuffer(mediaData); | 130 sourceBuffer.appendBuffer(mediaData); |
119 assert_true(sourceBuffer.updating, "updating attribute is true"); | 131 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
120 | 132 |
121 assert_throws("InvalidStateError", | 133 assert_throws('InvalidStateError', |
122 function() { sourceBuffer.appendWindowStart = 100.0; }, | 134 function() { sourceBuffer.appendWindowStart = 100.0; }, |
123 "set appendWindowStart throws an exception when there is a pen
ding append."); | 135 'set appendWindowStart throws an exception when there is a pen
ding append.'); |
124 | 136 |
125 assert_throws("InvalidStateError", | 137 assert_throws('InvalidStateError', |
126 function() { sourceBuffer.appendWindowEnd = 500.0; }, | 138 function() { sourceBuffer.appendWindowEnd = 500.0; }, |
127 "set appendWindowEnd throws an exception when there is a pendi
ng append."); | 139 'set appendWindowEnd throws an exception when there is a pendi
ng append.'); |
128 | 140 |
129 test.waitForExpectedEvents(function() | 141 test.waitForExpectedEvents(function() |
130 { | 142 { |
131 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 143 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
132 test.done(); | 144 test.done(); |
133 }); | 145 }); |
134 }, "Test set appendWindowStart and appendWindowEnd when source buffer
updating."); | 146 }, 'Test set appendWindowStart and appendWindowEnd when source buffer
updating.'); |
135 | 147 |
136 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 148 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
137 { | 149 { |
138 test.expectEvent(sourceBuffer, "updateend", "sourceBuffer"); | 150 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer'); |
139 sourceBuffer.appendBuffer(mediaData); | 151 sourceBuffer.appendBuffer(mediaData); |
140 assert_true(sourceBuffer.updating, "updating attribute is true"); | 152 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
141 | 153 |
142 sourceBuffer.abort(); | 154 sourceBuffer.abort(); |
143 assert_equals(sourceBuffer.appendWindowStart, 0, "appendWindowStar
t is 0 after an abort'"); | 155 assert_equals(sourceBuffer.appendWindowStart, 0, 'appendWindowStar
t is 0 after an abort'); |
144 assert_equals(sourceBuffer.appendWindowEnd, Number.POSITIVE_INFINI
TY, | 156 assert_equals(sourceBuffer.appendWindowEnd, Number.POSITIVE_INFINI
TY, |
145 "appendWindowStart is POSITIVE_INFINITY after an abo
rt"); | 157 'appendWindowStart is POSITIVE_INFINITY after an abo
rt'); |
146 test.waitForExpectedEvents(function() | 158 test.waitForExpectedEvents(function() |
147 { | 159 { |
148 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 160 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
149 test.done(); | 161 test.done(); |
150 }); | 162 }); |
151 }, "Test appendWindowStart and appendWindowEnd value after a sourceBuf
fer.abort()."); | 163 }, 'Test appendWindowStart and appendWindowEnd value after a sourceBuf
fer.abort().'); |
152 | 164 |
153 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 165 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
154 { | 166 { |
155 assert_equals(sourceBuffer.appendWindowStart, 0, "appendWindowStar
t is 0 initially'"); | 167 assert_equals(sourceBuffer.appendWindowStart, 0, 'appendWindowStar
t is 0 initially'); |
156 assert_equals(sourceBuffer.appendWindowEnd, Number.POSITIVE_INFINI
TY, | 168 assert_equals(sourceBuffer.appendWindowEnd, Number.POSITIVE_INFINI
TY, |
157 "appendWindowStart is POSITIVE_INFINITY initially"); | 169 'appendWindowStart is POSITIVE_INFINITY initially'); |
158 test.waitForExpectedEvents(function() | 170 test.waitForExpectedEvents(function() |
159 { | 171 { |
160 test.done(); | 172 test.done(); |
161 }); | 173 }); |
162 }, "Test read appendWindowStart and appendWindowEnd initial values."); | 174 }, 'Test read appendWindowStart and appendWindowEnd initial values.'); |
163 | 175 |
164 </script> | 176 </script> |
165 </body> | 177 </body> |
166 </html> | 178 </html> |
OLD | NEW |