Skip to content

Commit

Permalink
[Picture-in-Picture] Add a layout test for detached frame.
Browse files Browse the repository at this point in the history
This CL adds a test to make sure requesting Picture-in-Picture rejects
when frame is detached.

Bug: 806249
Change-Id: I2f9a029cc03fa8977400f908c87f80ed69674e93
Reviewed-on: https://chromium-review.googlesource.com/1065732
Reviewed-by: Mounir Lamouri <mlamouri@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Cr-Commit-Position: refs/heads/master@{#560605}
  • Loading branch information
beaufortfrancois authored and chromium-wpt-export-bot committed May 22, 2018
1 parent 31c2aeb commit 1895bf8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions picture-in-picture/resources/picture-in-picture-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@ function callWithTrustedClick(callback) {
});
}

function loadVideo() {
return new Promise(resolve => {
let video = document.createElement('video');
video.src = '/media/movie_5.ogv';
function loadVideo(activeDocument, sourceUrl) {
return new Promise((resolve, reject) => {
const document = activeDocument || window.document;
const video = document.createElement('video');
video.src = sourceUrl || '/media/movie_5.ogv';
video.onloadedmetadata = () => {
resolve(video);
};
video.onerror = error => {
reject(error);
};
});
}

// Calls requestPictureInPicture() in a context that's 'allowed to request PiP'.
function requestPictureInPictureWithTrustedClick(videoElement) {
return callWithTrustedClick(
() => videoElement.requestPictureInPicture());
}
}

0 comments on commit 1895bf8

Please sign in to comment.