Bug 1441424 - Fix autoplay activation test. r=kamidphish
authorChris Pearce <cpearce@mozilla.com>
Thu, 01 Mar 2018 17:21:09 +1300
changeset 461257 f8688efe482431851107b74a1dd9815f3292a8b7
parent 461256 b59a2fcd3435ec59ceaea010324db3761edb596e
child 461258 4e681b986b5cdd36dbb8b50c232b8b5d4db8e4f3
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskamidphish
bugs1441424, 1193394
milestone60.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 1441424 - Fix autoplay activation test. r=kamidphish Post landing of bug 1193394 test_autoplay_policy_activation was failing. This is because we weren't clicking the child frame properly in the test. Fix the test, and re-enable. MozReview-Commit-ID: Ius4GWIX8Ng
dom/media/test/AutoplayTestUtils.js
dom/media/test/file_autoplay_policy_activation_frame.html
dom/media/test/file_autoplay_policy_activation_window.html
dom/media/test/mochitest.ini
dom/media/test/test_autoplay_policy_activation.html
--- a/dom/media/test/AutoplayTestUtils.js
+++ b/dom/media/test/AutoplayTestUtils.js
@@ -1,14 +1,12 @@
-function playAndPostResult(test_case, parent_window) {
-  log("runTest " + test_case.name);
-
+function playAndPostResult(muted, parent_window) {
   let element = document.createElement("video");
   element.preload = "auto";
-  element.muted = test_case.muted;
+  element.muted = muted;
   element.src = "short.mp4";
   element.id = "video";
   document.body.appendChild(element);
 
   element.play().then(
       () => {
         parent_window.postMessage({played: true}, "*");
       },
--- a/dom/media/test/file_autoplay_policy_activation_frame.html
+++ b/dom/media/test/file_autoplay_policy_activation_frame.html
@@ -1,21 +1,28 @@
 <!DOCTYPE HTML>
 <html>
   <head>
     <title>Autoplay policy frame</title>
     <script type="text/javascript" src="AutoplayTestUtils.js"></script>
+    <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <style>
       video {
         width: 50%;
         height: 50%;
       }
     </style>
   </head>
   <body>
     <script>
-      nextWindowMessage().then(
+      window.addEventListener("message",
         (event) => {
-          playAndPostResult(event.data, event.source);
-        });
+          if (event.data == "click") {
+            synthesizeMouseAtCenter(document.body, {});
+          } else if (event.data == "play-audible") {
+            playAndPostResult(false, event.source);
+          } else if (event.data == "play-muted") {
+            playAndPostResult(true, event.source);
+          }
+        }, false);
     </script>
   </body>
 </html>
--- a/dom/media/test/file_autoplay_policy_activation_window.html
+++ b/dom/media/test/file_autoplay_policy_activation_window.html
@@ -14,35 +14,36 @@
     <script type="text/javascript" src="AutoplayTestUtils.js"></script>
   </head>
   <body>
     <pre id="test">
       <script>
 
         function testAutoplayInWindow(test_case, parent_window) {
           log("testAutoplayInWindow: " + test_case.name);
-          playAndPostResult(test_case, parent_window);
+          playAndPostResult(test_case.muted, parent_window);
         }
 
         async function testAutoplayInChildFrame(test_case, parent_window) {
           log("testAutoplayInChildFrame: " + test_case.name);
           // Create a child iframe...
           var frame = document.createElement("iframe");
           var origin = test_case.same_origin_child
             ? "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);
           await once(frame, "load");
           // Click the iframe to activate if appropriate.
           if (test_case.activated_child) {
-            synthesizeMouseAtCenter(frame, {});
+            frame.contentWindow.postMessage("click", "*");
           }
           // Ask the child iframe to try to play video.
-          frame.contentWindow.postMessage(test_case, "*");
+          let play_message = test_case.muted ? "play-muted" : "play-audible";
+          frame.contentWindow.postMessage(play_message, "*");
           // Wait for the iframe to tell us whether it could play video.
           let result = await nextWindowMessage();
           // Report whether the iframe could play to the parent.
           parent_window.postMessage(result.data, "*");
         }
 
         nextWindowMessage().then(
           (event) => {
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -683,18 +683,17 @@ skip-if = android_version == '15' # andr
 [test_audioDocumentTitle.html]
 skip-if = true # bug 475110 - disabled since we don't play Wave files standalone
 [test_autoplay.html]
 [test_autoplay_contentEditable.html]
 skip-if = android_version == '15' || android_version == '17' || android_version == '22' # android(bug 1232305, bug 1232318, bug 1372457)
 [test_autoplay_policy.html]
 skip-if = android_version == '23' # bug 1424903
 [test_autoplay_policy_activation.html]
-#skip-if = android_version == '23' # bug 1424903
-skip-if = true # bug 1441424 - temporarily disabled to land bug 1193394
+skip-if = android_version == '23' # bug 1424903
 [test_buffered.html]
 skip-if = android_version == '15' || android_version == '22' # bug 1308388, android(bug 1232305)
 [test_bug448534.html]
 [test_bug463162.xhtml]
 [test_bug465498.html]
 skip-if = toolkit == 'android' # android(bug 1232305)
 [test_bug495145.html]
 skip-if = (os == 'mac' && os_version == '10.6') || (toolkit == 'android')  # bug 1311229, android(bug 1232305)
--- a/dom/media/test/test_autoplay_policy_activation.html
+++ b/dom/media/test/test_autoplay_policy_activation.html
@@ -71,25 +71,24 @@
             name: "inaudible playback in unactivated cross-origin iframe in unactivated parent allowed",
             muted: true,
             same_origin_child: false,
             activated_child: false,
             activated_parent: false,
             should_play: true,
           },
 
-          // TODO: This case fails, Firefox's behaviour needs to be fixed.
-          // {
-          //   name: "audible playback in unactivated cross-origin iframe in activated parent blocked",
-          //   muted: false,
-          //   same_origin_child: false,
-          //   activated_child: false,
-          //   activated_parent: true,
-          //   should_play: false,
-          // },
+          {
+            name: "audible playback in unactivated cross-origin iframe in activated parent blocked",
+            muted: false,
+            same_origin_child: false,
+            activated_child: false,
+            activated_parent: true,
+            should_play: false,
+          },
 
           {
             name: "audible playback in unactivated cross-origin iframe in unactivated parent blocked",
             muted: false,
             same_origin_child: false,
             activated_child: false,
             activated_parent: false,
             should_play: false,