4 <title>crash after removing
<source
> test
</title>
5 <script src=video-test.js
></script>
6 <script src=media-file.js
></script>
12 tests
: [removeChild
, innerHTML
, replaceChild
]
15 function removeChild(sources
)
17 consoleWrite("Removing all <source> elements with <i>removeChild()<" + "/i>");
18 for (var ndx
= 0; ndx
< sources
.length
; ++ndx
) {
19 consoleWrite(" -> removeChild(" + ndx
+ ")");
20 video
.removeChild(sources
[ndx
]);
26 consoleWrite("Removing all <source> by setting <i>.innerHTML<" + "/i>");
27 consoleWrite(" -> video.innerHTML = ''");
30 function replaceChild(sources
)
32 consoleWrite("Removing all <source> elements with <i>replaceChild()<" + "/i>");
33 var span
= document
.createElement("span")
34 span
.appendChild(document
.createTextNode("Yo"));
35 for (var ndx
= 0; ndx
< sources
.length
; ++ndx
) {
36 consoleWrite(" -> replaceChild(" + ndx
+ ")");
37 video
.replaceChild(span
, sources
[ndx
]);
43 testInfo
.tests
[testInfo
.current
](document
.querySelectorAll('source'));
44 setTimeout(configureNextTest
, 100);
47 function addSource(index
)
49 source
= document
.createElement('source');
50 source
.src
= findMediaFile("video", index
+ "-" + Date
.now());
51 source
.type
= mimeTypeForExtension(source
.src
.split('.').pop());
52 video
.appendChild(source
);
55 function runNextTest()
58 if (++testInfo
.current
>= testInfo
.tests
.length
) {
59 consoleWrite("PASS: A crash did not occur when removing <source> elements.<br>");
64 video
= mediaElement
= document
.createElement('video');
65 document
.body
.appendChild(video
);
66 video
.addEventListener("loadstart", runOneTest
);
68 // Add a bunch of source elements with bogus urls because we want to remove elements
69 // after the media engine begins processing sources, and we can't predict the delay
70 // between when the media element fires an 'error' event and our handler is called,
71 // but we need to guarantee that there are <source> elements that haven't been processed
72 // when we run the test.
73 for (var ndx
= 1; ndx
<= 10; ndx
++)
77 function configureNextTest()
79 var videos
= document
.querySelectorAll('video');
80 for (var ndx
= 0; ndx
< videos
.length
; ++ndx
)
81 videos
[ndx
].parentNode
.removeChild(videos
[ndx
]);
82 video
= mediaElement
= null;
83 setTimeout(runNextTest
, 100);
89 Test to make sure removing a media element's
<source
>(s) does not cause a crash.
90 <script>configureNextTest()</script>