Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/embedded-content/media-elements/track/track-element/track-node-add-remove.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Add and remove track node</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
test(function() {
var video = document.createElement('video');
var tracka = document.createElement('track');
video.appendChild(tracka);
var trackb = document.createElement('track');
video.appendChild(trackb);
// Adding tracks outside the DOM tree.
assert_array_equals(video.textTracks, [tracka.track, trackb.track]);
// Inserting the parent video element into the document.
document.body.appendChild(video);
assert_array_equals(video.textTracks, [tracka.track, trackb.track]);
// Inserting and removing another track in the document.
var trackc = document.createElement('track');
video.appendChild(trackc);
assert_array_equals(video.textTracks, [tracka.track, trackb.track, trackc.track]);
trackb.parentNode.removeChild(trackb);
assert_array_equals(video.textTracks, [tracka.track, trackc.track]);
// Removing the video from the document.
document.body.removeChild(video);
assert_array_equals(video.textTracks, [tracka.track, trackc.track]);
tracka.parentNode.removeChild(tracka);
assert_array_equals(video.textTracks, [trackc.track]);
});
</script>