Bug 1592166 - part5 : add test case to check that activating child's frame would also activate parent's frame. r=jya
authorAlastor Wu <alwu@mozilla.com>
Wed, 06 Nov 2019 04:49:00 +0000
changeset 500876 3af45c300fb209a4bf5c4940f224e66d7dd455ef
parent 500875 7b98209dbf52ac70c16c6206f60b447591494ae0
child 500877 9d78accbdc5108a7347af693ccdf4505180ca567
push id114166
push userapavel@mozilla.com
push dateThu, 07 Nov 2019 10:04:01 +0000
treeherdermozilla-inbound@d271c572a9bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1592166
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1592166 - part5 : add test case to check that activating child's frame would also activate parent's frame. r=jya Increase test cases of activating child frame would also activate its parent frame, no matter the child frame is cross-origin or not. Differential Revision: https://phabricator.services.mozilla.com/D51691
dom/media/test/file_autoplay_policy_activation_frame.html
dom/media/test/file_autoplay_policy_activation_window.html
dom/media/test/test_autoplay_policy_activation.html
--- a/dom/media/test/file_autoplay_policy_activation_frame.html
+++ b/dom/media/test/file_autoplay_policy_activation_frame.html
@@ -13,16 +13,17 @@
     </style>
   </head>
   <body>
     <script>
       window.addEventListener("message",
         (event) => {
           if (event.data == "click") {
             SpecialPowers.wrap(document).notifyUserGestureActivation();
+            event.source.postMessage("activated", "*");
           } else if (event.data == "play-audible") {
             playAndPostResult(false, event.source);
           } else if (event.data == "play-muted") {
             playAndPostResult(true, event.source);
           }
         });
       let w = window.opener || window.parent;
       w.postMessage("ready", "*");
--- a/dom/media/test/file_autoplay_policy_activation_window.html
+++ b/dom/media/test/file_autoplay_policy_activation_window.html
@@ -23,24 +23,25 @@
             ? "http://mochi.test:8888" : "http://example.org";
           frame.src = origin + "/tests/dom/media/test/file_autoplay_policy_activation_frame.html";
           // Wait for it to load...
           document.body.appendChild(frame);
           is((await nextWindowMessage()).data, "ready", "Expected a 'ready' message");
           return frame;
         }
 
-        function activateDocument(testInfo) {
+        async function activateDocument(testInfo) {
           // Click the window to activate if appropriate.
           if (testInfo.activated_from == "parent") {
             info(`activate parent's document`);
             SpecialPowers.wrap(document).notifyUserGestureActivation();
           } else if (testInfo.activated_from == "child") {
             info(`activate child's document`);
             testInfo.childFrame.contentWindow.postMessage("click", "*");
+            is((await nextWindowMessage()).data, "activated", "has activated child frame.");
           }
         }
 
         function testAutoplayInWindow(testInfo) {
           info(`start autoplay from parent frame`);
           playAndPostResult(testInfo.muted, testInfo.parentWindow);
         }
 
@@ -56,17 +57,17 @@
         }
 
         nextWindowMessage().then(
           async (event) => {
             let testInfo = event.data;
             testInfo.parentWindow = event.source;
             testInfo.childFrame = await createChildFrame(testInfo);
 
-            activateDocument(testInfo);
+            await activateDocument(testInfo);
             switch (testInfo.play_from) {
               case "parent":
                 testAutoplayInWindow(testInfo);
                 break;
               case "child":
                 testAutoplayInChildFrame(testInfo);
                 break;
               default:
--- a/dom/media/test/test_autoplay_policy_activation.html
+++ b/dom/media/test/test_autoplay_policy_activation.html
@@ -115,16 +115,34 @@
             name: "audible playback in unactivated document -> blocked",
             muted: false,
             activated_from: "none",
             play_from: "parent",
             should_play: false,
           },
 
           {
+            name: "audible playback in activated document (via cross-origin child) -> allowed",
+            muted: false,
+            same_origin_child: false,
+            activated_from: "child",
+            play_from: "parent",
+            should_play: true,
+          },
+
+          {
+            name: "audible playback in activated document (via same-origin child) -> allowed",
+            muted: false,
+            same_origin_child: true,
+            activated_from: "child",
+            play_from: "parent",
+            should_play: true,
+          },
+
+          {
             name: "inaudible playback in activated document -> allowed",
             muted: true,
             activated_from: "parent",
             play_from: "parent",
             should_play: true,
           },
 
           {