summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/picture-in-picture/resources/picture-in-picture-helpers.js
blob: 7561944a18d0296b33dbb3acb1f3a82b1512d08f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function loadVideo(activeDocument, sourceUrl) {
  return new Promise((resolve, reject) => {
    const document = activeDocument || window.document;
    const video = document.createElement('video');
    video.src = sourceUrl || getVideoURI('/media/movie_5');
    video.onloadedmetadata = () => { resolve(video); };
    video.onerror = error => { reject(error); };
  });
}

// Calls requestPictureInPicture() in a context that's 'allowed to request PiP'.
async function requestPictureInPictureWithTrustedClick(videoElement) {
  await test_driver.bless('request Picture-in-Picture');
  return videoElement.requestPictureInPicture();
}