OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <!-- original: https://github.com/w3c/web-platform-tests/blob/6b3893bb99f70e4238
011dbcd1f380891e89ec5e/html/semantics/embedded-content-0/media-elements/autoplay
.html --> | 2 <!-- original: https://github.com/w3c/web-platform-tests/blob/6b3893bb99f70e4238
011dbcd1f380891e89ec5e/html/semantics/embedded-content-0/media-elements/autoplay
.html --> |
3 <title>autoplay</title> | 3 <title>autoplay</title> |
4 <script src="../resources/testharness.js"></script> | 4 <script src="../resources/testharness.js"></script> |
5 <script src="../resources/testharnessreport.js"></script> | 5 <script src="../resources/testharnessreport.js"></script> |
6 <script src="media-file.js"></script> | 6 <script src="media-file.js"></script> |
7 <div id="log"></div> | 7 <div id="log"></div> |
8 <script> | 8 <script> |
9 function autoplay_test(tagName, src) | 9 function autoplay_test(tagName, src) |
10 { | 10 { |
11 async_test(function(t) | 11 async_test(function(t) |
12 { | 12 { |
13 var e = document.createElement(tagName); | 13 var e = document.createElement(tagName); |
14 // add to body to prevent GC pending http://crbug.com/400659 | |
15 document.body.appendChild(e); | |
16 e.src = src; | 14 e.src = src; |
17 e.autoplay = true; | 15 e.autoplay = true; |
18 var actual_events = []; | 16 var actual_events = []; |
19 var expected_events = ['canplay', 'play', 'playing', 'canplaythrough']; | 17 var expected_events = ['canplay', 'play', 'playing', 'canplaythrough']; |
20 expected_events.forEach(function(type) | 18 expected_events.forEach(function(type) |
21 { | 19 { |
22 e.addEventListener(type, t.step_func(function() | 20 e.addEventListener(type, t.step_func(function() |
23 { | 21 { |
24 assert_equals(e.readyState, e.HAVE_ENOUGH_DATA); | 22 assert_equals(e.readyState, e.HAVE_ENOUGH_DATA); |
25 assert_false(e.paused); | 23 assert_false(e.paused); |
26 actual_events.push(type); | 24 actual_events.push(type); |
27 if (type == 'canplaythrough') { | 25 if (type == 'canplaythrough') { |
28 assert_array_equals(actual_events, expected_events); | 26 assert_array_equals(actual_events, expected_events); |
29 t.done(); | 27 t.done(); |
30 } | 28 } |
31 })); | 29 })); |
32 }); | 30 }); |
33 }, tagName + '.autoplay'); | 31 }, tagName + '.autoplay'); |
34 } | 32 } |
35 | 33 |
36 autoplay_test('audio', findMediaFile('audio', 'content/test')); | 34 autoplay_test('audio', findMediaFile('audio', 'content/test')); |
37 autoplay_test('video', findMediaFile('video', 'content/test')); | 35 autoplay_test('video', findMediaFile('video', 'content/test')); |
38 </script> | 36 </script> |
OLD | NEW |