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