Commit 204a8c28 authored by Mounir Lamouri's avatar Mounir Lamouri Committed by Commit Bot

Picture-in-Picture: refactor browser tests to not use a resize counter.

Bug: None
Change-Id: I962397a6c916b176970a451093bcef82bea83258
Reviewed-on: https://chromium-review.googlesource.com/1125403Reviewed-by: default avatarapacible <apacible@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572447}
parent 0bed5b24
......@@ -15,7 +15,7 @@
function enterPictureInPicture() {
video.requestPictureInPicture().then(() => {
domAutomationController.send('done');
domAutomationController.send(true);
});
}
......
......@@ -3,7 +3,7 @@
<script>
function enterPictureInPicture() {
document.querySelector('video').requestPictureInPicture().then(() => {
document.title = 'entered_pip';
window.domAutomationController.send(true);
});
}
</script>
......@@ -8,8 +8,6 @@
</body>
<script>
const video = document.querySelector('video');
let pipWindow = null;
let sizeCountUpdates = 0;
// This video is created here in order to be used in
// `secondPictureInPicture()`. Unfortunately, the `requestPictureInPicture()`
......@@ -19,13 +17,6 @@
secondVideo.src = '../bigbuck.webm';
secondVideo.load();
function updateTitle() {
// TODO(mlamouri): ideally, we should send the actual size but it will be
// flaky and require some minutia so starting with the basics.
sizeCountUpdates++;
document.title = sizeCountUpdates;
}
function requestPictureInPictureAndDisable() {
enterPictureInPictureInternal();
video.disablePictureInPicture = true;
......@@ -50,16 +41,18 @@
function enterPictureInPictureInternal() {
video.requestPictureInPicture()
.then(win => {
pipWindow = win;
updateTitle();
pipWindow.addEventListener('resize', updateTitle);
win.addEventListener('resize', () => {
document.title = 'resized';
}, { once: true });
video.addEventListener('leavepictureinpicture', () => {
document.title = 'left';
}, { once: true });
window.domAutomationController.send(true);
})
.catch(e => {
document.title = 'rejected';
window.domAutomationController.send(false);
});
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment