Bug 1497267 [wpt PR 13380] - [Picture-in-Picture] Refactor test_driver.bless in tests., a=testonly
authorFrançois Beaufort <beaufort.francois@gmail.com>
Thu, 11 Oct 2018 10:04:06 +0000
changeset 489296 ae1c90415cecf2c482f79547bd20ab4e69c0a680
parent 489295 e816bcd461abb456bad50c9df457d7a0fdcbe83b
child 489297 b7ab99069b378041a5d7ba300e298d5a0755007b
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerstestonly
bugs1497267, 13380, 1264157, 598456
milestone64.0a1
Bug 1497267 [wpt PR 13380] - [Picture-in-Picture] Refactor test_driver.bless in tests., a=testonly Automatic update from web-platform-tests[Picture-in-Picture] Refactor test_driver.bless in tests. This CL does not change any functionality. It simply uses await for test_driver.bless. Change-Id: I921221776eb598770b7e0c1e29485f3fd90a85bb Reviewed-on: https://chromium-review.googlesource.com/c/1264157 Reviewed-by: Mounir Lamouri <mlamouri@chromium.org> Reviewed-by: Fran├žois Beaufort <beaufort.francois@gmail.com> Commit-Queue: Fran├žois Beaufort <beaufort.francois@gmail.com> Cr-Commit-Position: refs/heads/master@{#598456} -- wpt-commits: 07fbaece684299705d3b8a41bfc3661fea131a9b wpt-pr: 13380
testing/web-platform/tests/picture-in-picture/disable-picture-in-picture.html
testing/web-platform/tests/picture-in-picture/request-picture-in-picture-twice.html
testing/web-platform/tests/picture-in-picture/resources/picture-in-picture-helpers.js
--- a/testing/web-platform/tests/picture-in-picture/disable-picture-in-picture.html
+++ b/testing/web-platform/tests/picture-in-picture/disable-picture-in-picture.html
@@ -28,22 +28,21 @@ promise_test(async t => {
   const video = await loadVideo();
   video.disablePictureInPicture = true;
   return promise_rejects(t, 'InvalidStateError',
       requestPictureInPictureWithTrustedClick(video));
 }, 'Request Picture-in-Picture rejects if disablePictureInPicture is true');
 
 promise_test(async t => {
   const video = await loadVideo();
-  return test_driver.bless('request Picture-in-Picture', async () => {
-    const promise = video.requestPictureInPicture();
-    video.disablePictureInPicture = true;
-    await promise_rejects(t, 'InvalidStateError', promise);
-    assert_equals(document.pictureInPictureElement, null);
-  });
+  await test_driver.bless('request Picture-in-Picture');
+  const promise = video.requestPictureInPicture();
+  video.disablePictureInPicture = true;
+  await promise_rejects(t, 'InvalidStateError', promise);
+  assert_equals(document.pictureInPictureElement, null);
 }, 'Request Picture-in-Picture rejects if disablePictureInPicture becomes ' +
    'true before promise resolves.');
 
 promise_test(async t => {
   const video = await loadVideo();
   return requestPictureInPictureWithTrustedClick(video)
   .then(() => {
     video.disablePictureInPicture = true;
--- a/testing/web-platform/tests/picture-in-picture/request-picture-in-picture-twice.html
+++ b/testing/web-platform/tests/picture-in-picture/request-picture-in-picture-twice.html
@@ -5,17 +5,14 @@
 <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(async t => {
   const video1 = await loadVideo();
   const video2 = await loadVideo();
-  return test_driver.bless(
-    'request Picture-in-Picture',
-    async () => {
-      video1.requestPictureInPicture();
-      promise_rejects(t, 'NotAllowedError', video2.requestPictureInPicture());
-    }
-  );
+  await test_driver.bless('request Picture-in-Picture');
+  const promise = video1.requestPictureInPicture();
+  await promise_rejects(t, 'NotAllowedError', video2.requestPictureInPicture());
+  return promise;
 }, 'request Picture-in-Picture consumes user gesture');
 </script>
--- a/testing/web-platform/tests/picture-in-picture/resources/picture-in-picture-helpers.js
+++ b/testing/web-platform/tests/picture-in-picture/resources/picture-in-picture-helpers.js
@@ -10,13 +10,12 @@ function loadVideo(activeDocument, sourc
     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 test_driver.bless(
-    'request Picture-in-Picture',
-    () => videoElement.requestPictureInPicture());
+async function requestPictureInPictureWithTrustedClick(videoElement) {
+  await test_driver.bless('request Picture-in-Picture');
+  return videoElement.requestPictureInPicture();
 }