|
Line 0
a/LayoutTests/media/remove-video-element-in-pip-from-document.html_sec1
|
|
|
1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<script src="video-test.js"></script> |
| 5 |
<script src="media-file.js"></script> |
| 6 |
<script> |
| 7 |
window.addEventListener('load', async event => { |
| 8 |
if (!window.internals) { |
| 9 |
failTest('This test requires window.internals.'); |
| 10 |
return; |
| 11 |
} |
| 12 |
|
| 13 |
consoleWrite(''); |
| 14 |
run('internals.settings.setAllowsPictureInPictureMediaPlayback(true)'); |
| 15 |
run('internals.setMockVideoPresentationModeEnabled(true)'); |
| 16 |
|
| 17 |
findMediaElement(); |
| 18 |
video.src = findMediaFile("video", "content/test"); |
| 19 |
|
| 20 |
await waitFor(video, 'canplaythrough'); |
| 21 |
|
| 22 |
runWithKeyDown(() => { |
| 23 |
video.webkitSetPresentationMode('picture-in-picture'); |
| 24 |
}); |
| 25 |
|
| 26 |
waitForEventOnce('enterpictureinpicture', event => { |
| 27 |
window.pipWindow = event.pictureInPictureWindow; |
| 28 |
testExpected('pipWindow.width', 0, '>'); |
| 29 |
testExpected('pipWindow.height', 0, '>'); |
| 30 |
|
| 31 |
const observer = new MutationObserver(() => { |
| 32 |
consoleWrite('The video element has been removed from DOM.'); |
| 33 |
setTimeout(endTest, 1000); |
| 34 |
}); |
| 35 |
observer.observe(document.body, { childList: true }); |
| 36 |
waitForEvent('webkitpresentationmodechanged', () => { |
| 37 |
failTest('PiP window is closed!'); |
| 38 |
}); |
| 39 |
document.body.removeChild(video); |
| 40 |
}); |
| 41 |
}); |
| 42 |
</script> |
| 43 |
</head> |
| 44 |
<body> |
| 45 |
<div>Test that removing a video element from the DOM while the video is in the picture-in-picture mode does not close the PiP window.</div> |
| 46 |
<video controls playsinline></video> |
| 47 |
</body> |
| 48 |
</html> |