https://github.com/web-platform-tests/wpt
Raw File
Tip revision: e1dec59097506a0bf5bfe29f9521b4061e2cf72e authored by Geoffrey Sneddon on 13 March 2018, 22:23:22 UTC
Revert "Add a lint to catch adding files that would otherwise be ignored by git."
Tip revision: e1dec59
picture-in-picture-window.html
<!DOCTYPE html>
<title>Test Picture-in-Picture window</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="resources/picture-in-picture-helpers.js"></script>
<body></body>
<script>
promise_test(t => {
  return requestPictureInPictureWithTrustedClick(document.createElement('video'))
  .then(pipWindow => {
    assert_not_equals(pipWindow.width, 0);
    assert_not_equals(pipWindow.height, 0);
  });
}, 'Picture-in-Picture window dimensions are set after entering Picture-in-Picture');

promise_test(t => {
  const video1 = document.createElement('video');
  const video2 = document.createElement('video');
  return requestPictureInPictureWithTrustedClick(video1)
  .then(pipWindow1 => {
    return requestPictureInPictureWithTrustedClick(video2)
    .then(pipWindow2 => {
      assert_equals(pipWindow1.width, 0);
      assert_equals(pipWindow1.height, 0);
      assert_not_equals(pipWindow2.width, 0);
      assert_not_equals(pipWindow2.height, 0);
    });
  });
}, 'Picture-in-Picture window dimensions are set to 0 after entering ' +
   'Picture-in-Picture for another video');

promise_test(t => {
  return requestPictureInPictureWithTrustedClick(document.createElement('video'))
  .then(pipWindow => {
    return document.exitPictureInPicture()
    .then(() => {
      assert_equals(pipWindow.width, 0);
      assert_equals(pipWindow.height, 0);
    });
  })
}, 'Picture-in-Picture window dimensions are set to 0 after exiting Picture-in-Picture');

promise_test(t => {
  const video = document.createElement('video');
  let thePipWindow;

  video.addEventListener('leavepictureinpicture', t.step_func_done(event => {
    assert_equals(thePipWindow.width, 0);
    assert_equals(thePipWindow.height, 0);
  }));

  return requestPictureInPictureWithTrustedClick(video)
  .then(pipWindow => {
    thePipWindow = pipWindow;
    video.disablePictureInPicture = true;
  });
}, 'Picture-in-Picture window dimensions are set to 0 if ' +
   'disablePictureInPicture becomes true');
</script>
back to top