<!DOCTYPE html>
<title>Verify that moving a video element to a new document, still loads it normally</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<video></video>
<iframe></iframe>
<script>
async_test(function(t) {
var video = document.querySelector('video');
navigator.webkitGetUserMedia(
{video:true},
t.step_func(stream => video.srcObject = stream),
t.unreached_func("Did not get mediastream"));
video.onloadeddata = t.step_func(function() {
video.onloadeddata = null;
assert_true(video.networkState == video.NETWORK_IDLE || video.networkState == video.NETWORK_LOADING);
assert_greater_than(video.readyState, video.HAVE_METADATA);
// Move the video element to iframe document from
// main document and verify that it does reload
// Video does reload because player reuse is currently
// not enabled for non-pip related move.
document.querySelector('iframe').contentDocument.body.appendChild(video);
assert_equals(video.networkState, video.NETWORK_NO_SOURCE);
assert_equals(video.readyState, video.HAVE_NOTHING);
var actual_events = [];
var expected_events = ['emptied', 'loadstart', 'loadeddata'];
expected_events.forEach(function(type) {
video.addEventListener(type, t.step_func(function() {
actual_events.push(type);
if (type == 'loadeddata') {
assert_array_equals(actual_events, expected_events);
t.done();
}
}));
});
});
});
</script>