Bug 1543128 - Fire UAWidgetSetupOrChange for the no-controls <video> case on Desktop. r=jya
authorMike Conley <mconley@mozilla.com>
Mon, 15 Apr 2019 01:08:32 +0000
changeset 469460 15eaea4c4c08bf3bc74f0bf45b97bb1bbf585deb
parent 469459 7900dcbab822a5078491838b5fae04d66c20e975
child 469461 3ac660e7f45c91f5af86614696a1f7acc760049a
push id112792
push userncsoregi@mozilla.com
push dateMon, 15 Apr 2019 09:49:11 +0000
treeherdermozilla-inbound@a57f27d3ccd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1543128
milestone68.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 1543128 - Fire UAWidgetSetupOrChange for the no-controls <video> case on Desktop. r=jya The Picture-in-Picture toggle buttons are now part of the video controls UAWidget bindings, so we need to construct a UAWidget for the no-controls case for Desktop to make that toggle available. Up until now, we've never needed a no-controls UAWidget for Desktop, since we never needed to show UI in that case. Depends on D26809 Differential Revision: https://phabricator.services.mozilla.com/D26803
dom/html/HTMLMediaElement.cpp
dom/media/test/test_cloneElementVisually_no_suspend.html
dom/media/tests/mochitest/test_setSinkId.html
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -4092,29 +4092,17 @@ void HTMLMediaElement::AfterMaybeChangeA
 nsresult HTMLMediaElement::BindToTree(Document* aDocument, nsIContent* aParent,
                                       nsIContent* aBindingParent) {
   nsresult rv =
       nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
 
   if (IsInComposedDoc()) {
     // Construct Shadow Root so web content can be hidden in the DOM.
     AttachAndSetUAShadowRoot();
-#ifdef ANDROID
     NotifyUAWidgetSetupOrChange();
-#else
-    // We don't want to call into JS if the website never asks for native
-    // video controls.
-    // If controls attribute is set later, controls is constructed lazily
-    // with the UAWidgetAttributeChanged event.
-    // This only applies to Desktop because on Fennec we would need to show
-    // an UI if the video is blocked.
-    if (Controls()) {
-      NotifyUAWidgetSetupOrChange();
-    }
-#endif
   }
 
   mUnboundFromTree = false;
 
   if (aDocument) {
     // The preload action depends on the value of the autoplay attribute.
     // It's value may have changed, so update it.
     UpdatePreloadAction();
--- a/dom/media/test/test_cloneElementVisually_no_suspend.html
+++ b/dom/media/test/test_cloneElementVisually_no_suspend.html
@@ -51,26 +51,33 @@ add_task(async () => {
     await waitForEventOnce(originalVideo, "seeked");
 
     let suspendTimerFired = false;
 
     let listener = () => {
       suspendTimerFired = true;
     }
     originalVideo.addEventListener("mozstartvideosuspendtimer", listener);
-    originalVideo.setVisible(false);
+
+    // Have to do this to access normally-preffed off binding methods for some
+    // reason.
+    // See bug 1544257.
+    SpecialPowers.wrap(originalVideo).setVisible(false);
 
     await waitForEventOnce(originalVideo, "ended");
 
     originalVideo.removeEventListener("mozstartvideosuspendtimer", listener);
 
     ok(!suspendTimerFired,
        "mozstartvideosuspendtimer should not have fired.");
 
-    originalVideo.setVisible(true);
+    // Have to do this to access normally-preffed off binding methods for some
+    // reason.
+    // See bug 1544257.
+    SpecialPowers.wrap(originalVideo).setVisible(true);
   });
 
   await originalVideo.play();
 
   // With the clone gone, the original video should be able to suspend now.
   await ensureVideoSuspendable(originalVideo);
 
   await setVideoSrc(originalVideo, TEST_VIDEO_1);
--- a/dom/media/tests/mochitest/test_setSinkId.html
+++ b/dom/media/tests/mochitest/test_setSinkId.html
@@ -25,16 +25,21 @@
       return;
     }
 
     const allDevices = await navigator.mediaDevices.enumerateDevices();
     const audioDevices = allDevices.filter(({kind}) => kind == 'audiooutput');
     info(`Found  ${audioDevices.length} output devices`);
     ok(audioDevices.length > 0, "More than one output device found");
 
+    // Have to do this to access normally-preffed off binding methods for some
+    // reason.
+    // See bug 1544257.
+    let audio = SpecialPowers.wrap(audio);
+
     is(audio.sinkId, "", "Initial value is empty string");
 
     const p = audio.setSinkId(audioDevices[0].deviceId);
     is(audio.sinkId, "", "Value is unchanged upon function return");
     is(await p, undefined, "promise resolves with undefined");
     is(audio.sinkId, audioDevices[0].deviceId, `Sink device is set, id: ${audio.sinkId}`);
 
     await audio.setSinkId(audioDevices[0].deviceId);