https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 32b86b82958c2f48931274b26840a1a4a45a8857 authored by Adam Rice on 20 March 2018, 12:30:43 UTC
Correctly reject in-progress body methods with AbortError
Tip revision: 32b86b8
picture-in-picture-helpers.js
function callWithTrustedClick(callback) {
  return new Promise(resolve => {
    let button = document.createElement('button');
    button.textContent = 'click to continue test';
    button.style.display = 'block';
    button.style.fontSize = '20px';
    button.style.padding = '10px';
    button.onclick = () => {
      document.body.removeChild(button);
      resolve(callback());
    };
    document.body.appendChild(button);
    test_driver.click(button);
  });
}

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