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 @@ ...@@ -15,7 +15,7 @@
function enterPictureInPicture() { function enterPictureInPicture() {
video.requestPictureInPicture().then(() => { video.requestPictureInPicture().then(() => {
domAutomationController.send('done'); domAutomationController.send(true);
}); });
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<script> <script>
function enterPictureInPicture() { function enterPictureInPicture() {
document.querySelector('video').requestPictureInPicture().then(() => { document.querySelector('video').requestPictureInPicture().then(() => {
document.title = 'entered_pip'; window.domAutomationController.send(true);
}); });
} }
</script> </script>
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
</body> </body>
<script> <script>
const video = document.querySelector('video'); const video = document.querySelector('video');
let pipWindow = null;
let sizeCountUpdates = 0;
// This video is created here in order to be used in // This video is created here in order to be used in
// `secondPictureInPicture()`. Unfortunately, the `requestPictureInPicture()` // `secondPictureInPicture()`. Unfortunately, the `requestPictureInPicture()`
...@@ -19,13 +17,6 @@ ...@@ -19,13 +17,6 @@
secondVideo.src = '../bigbuck.webm'; secondVideo.src = '../bigbuck.webm';
secondVideo.load(); 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() { function requestPictureInPictureAndDisable() {
enterPictureInPictureInternal(); enterPictureInPictureInternal();
video.disablePictureInPicture = true; video.disablePictureInPicture = true;
...@@ -50,16 +41,18 @@ ...@@ -50,16 +41,18 @@
function enterPictureInPictureInternal() { function enterPictureInPictureInternal() {
video.requestPictureInPicture() video.requestPictureInPicture()
.then(win => { .then(win => {
pipWindow = win; win.addEventListener('resize', () => {
updateTitle(); document.title = 'resized';
pipWindow.addEventListener('resize', updateTitle); }, { once: true });
video.addEventListener('leavepictureinpicture', () => { video.addEventListener('leavepictureinpicture', () => {
document.title = 'left'; document.title = 'left';
}, { once: true }); }, { once: true });
window.domAutomationController.send(true);
}) })
.catch(e => { .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