Title: [227904] trunk
Revision
227904
Author
[email protected]
Date
2018-01-31 09:35:15 -0800 (Wed, 31 Jan 2018)

Log Message

[Modern Media Controls] Turn media/modern-media-controls/start-support tests back on
https://bugs.webkit.org/show_bug.cgi?id=182297

Reviewed by Jon Lee and Eric Carlson.

Source/WebCore:

We identified one cause of flakiness when turning those tests back on and fix it in this patch. There would be
cases where the play/pause button would never actually become visible because we would first set it as one of
the buttons in the left container in the bottom controls bar before we would identify that we should show the
prominent play/pause button, and then once we did, we would add it as a child to the InlineMediaControls. But,
because the actual layout of the ButtonsContainer would happen in a rAF due to being a layout() method, we would
remove the play/pause button from the InlineMediaControls and set it as a child of the left container even
though it wasn't visible.

Performing the layout of a ButtonsContainer should really happen immediately when we set the buttons, so in this
patch we remove the "buttons" property and clients of ButtonsContainer can simply add or remove children which
will be laid out in a row. To support this, we've added two notification methods to LayoutNode, one that indicates
when children have changed, didChangeChildren(), which we override in ButtonsContainer to perform a synchronous
layout. The other method is willRemoveChild() which we also override in ButtonsContainer, this time to reset
the "x" and "visible" properties which we set while performing layout.

This fixes flakiness for media/modern-media-controls/start-support/start-support-click-to-start.html, and maybe
other modern-media-controls tests that could have been affected by this unexpected behavior.

* Modules/modern-media-controls/controls/buttons-container.js:
(ButtonsContainer.prototype.willRemoveChild):
(ButtonsContainer.prototype.didChangeChildren):
(ButtonsContainer.prototype.layout):
(ButtonsContainer.prototype.get buttons): Deleted.
(ButtonsContainer.prototype.set buttons): Deleted.
* Modules/modern-media-controls/controls/inline-media-controls.js:
(InlineMediaControls.prototype.layout):
(InlineMediaControls.prototype._updateBottomControlsBarLabel):
(InlineMediaControls.prototype._addTopRightBarWithMuteButtonToChildren):
(InlineMediaControls):
* Modules/modern-media-controls/controls/layout-node.js:
(LayoutNode.prototype.set children):
(LayoutNode.prototype.addChild):
(LayoutNode.prototype.removeChild):
(LayoutNode.prototype.willRemoveChild):
(LayoutNode.prototype.didChangeChildren):
* Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js:
(MacOSFullscreenMediaControls.prototype.layout):
* Modules/modern-media-controls/media/media-controller.js: Drive-by fix to correctly set the value passed as
data-auto-hide-delay on a <video> element.

LayoutTests:

Update tests to account for the new variable name for the playPauseButton and ensure we only listen to the
fullscreen event once to avoid flakiness in cases where we might exit fullscreen before the test completes.

We also update other tests that tested the behavior of ButtonsContainer.

* media/modern-media-controls/buttons-container/buttons-container-buttons-property-expected.txt:
* media/modern-media-controls/buttons-container/buttons-container-buttons-property.html:
* media/modern-media-controls/buttons-container/buttons-container-constructor-expected.txt:
* media/modern-media-controls/buttons-container/buttons-container-constructor.html:
* media/modern-media-controls/buttons-container/buttons-container-layout-expected.txt:
* media/modern-media-controls/buttons-container/buttons-container-layout.html:
* media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-rtl-expected.txt:
* media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-rtl.html:
* media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-top-right-controls-bar-hidden-when-mute-button-disabled-expected.txt:
* media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-top-right-controls-bar-hidden-when-mute-button-disabled.html:
* media/modern-media-controls/pip-support/pip-support-click.html:
* media/modern-media-controls/start-support/start-support-click-to-start.html:
* media/modern-media-controls/start-support/start-support-fullscreen.html:
* media/modern-media-controls/start-support/start-support-lowPowerMode-expected.txt:
* media/modern-media-controls/start-support/start-support-lowPowerMode.html:
* platform/ios/TestExpectations:
* platform/mac/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (227903 => 227904)


--- trunk/LayoutTests/ChangeLog	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/ChangeLog	2018-01-31 17:35:15 UTC (rev 227904)
@@ -1,3 +1,33 @@
+2018-01-31  Antoine Quint  <[email protected]>
+
+        [Modern Media Controls] Turn media/modern-media-controls/start-support tests back on
+        https://bugs.webkit.org/show_bug.cgi?id=182297
+
+        Reviewed by Jon Lee and Eric Carlson.
+
+        Update tests to account for the new variable name for the playPauseButton and ensure we only listen to the
+        fullscreen event once to avoid flakiness in cases where we might exit fullscreen before the test completes.
+
+        We also update other tests that tested the behavior of ButtonsContainer.
+
+        * media/modern-media-controls/buttons-container/buttons-container-buttons-property-expected.txt:
+        * media/modern-media-controls/buttons-container/buttons-container-buttons-property.html:
+        * media/modern-media-controls/buttons-container/buttons-container-constructor-expected.txt:
+        * media/modern-media-controls/buttons-container/buttons-container-constructor.html:
+        * media/modern-media-controls/buttons-container/buttons-container-layout-expected.txt:
+        * media/modern-media-controls/buttons-container/buttons-container-layout.html:
+        * media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-rtl-expected.txt:
+        * media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-rtl.html:
+        * media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-top-right-controls-bar-hidden-when-mute-button-disabled-expected.txt:
+        * media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-top-right-controls-bar-hidden-when-mute-button-disabled.html:
+        * media/modern-media-controls/pip-support/pip-support-click.html:
+        * media/modern-media-controls/start-support/start-support-click-to-start.html:
+        * media/modern-media-controls/start-support/start-support-fullscreen.html:
+        * media/modern-media-controls/start-support/start-support-lowPowerMode-expected.txt:
+        * media/modern-media-controls/start-support/start-support-lowPowerMode.html:
+        * platform/ios/TestExpectations:
+        * platform/mac/TestExpectations:
+
 2018-01-31  Saam Barati  <[email protected]>
 
         JSC incorrectly interpreting script, sets Global Property instead of Global Lexical variable (LiteralParser / JSONP path)

Modified: trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-buttons-property-expected.txt (227903 => 227904)


--- trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-buttons-property-expected.txt	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-buttons-property-expected.txt	2018-01-31 17:35:15 UTC (rev 227904)
@@ -3,9 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS container.buttons.length is 3
 PASS container.children.length is 3
-PASS container.buttons is container.children
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-buttons-property.html (227903 => 227904)


--- trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-buttons-property.html	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-buttons-property.html	2018-01-31 17:35:15 UTC (rev 227904)
@@ -14,13 +14,11 @@
     buttonMargin: 10
 });
 
-container.buttons = [new Button, new Button, new Button];
+container.children = [new Button, new Button, new Button];
 
 scheduler.frameDidFire = function()
 {
-    shouldBe("container.buttons.length", "3");
     shouldBe("container.children.length", "3");
-    shouldBe("container.buttons", "container.children");
     finishMediaControlsTest();
 };
 

Modified: trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-constructor-expected.txt (227903 => 227904)


--- trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-constructor-expected.txt	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-constructor-expected.txt	2018-01-31 17:35:15 UTC (rev 227904)
@@ -8,7 +8,7 @@
 PASS defaultContainer.buttonMargin is 16
 PASS defaultContainer.leftMargin is 16
 PASS defaultContainer.rightMargin is 16
-PASS defaultContainer.buttons is []
+PASS defaultContainer.children is []
 PASS containerWithParameters.element.localName is "div"
 PASS containerWithParameters.element.classList.contains('buttons-container') is true
 PASS containerWithParameters.element.classList.contains('foo') is true
@@ -15,7 +15,7 @@
 PASS containerWithParameters.buttonMargin is 10
 PASS containerWithParameters.leftMargin is 20
 PASS containerWithParameters.rightMargin is 20
-PASS containerWithParameters.buttons is buttons
+PASS containerWithParameters.children is buttons
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-constructor.html (227903 => 227904)


--- trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-constructor.html	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-constructor.html	2018-01-31 17:35:15 UTC (rev 227904)
@@ -11,7 +11,7 @@
 shouldBe("defaultContainer.buttonMargin", "16");
 shouldBe("defaultContainer.leftMargin", "16");
 shouldBe("defaultContainer.rightMargin", "16");
-shouldBe("defaultContainer.buttons", "[]");
+shouldBe("defaultContainer.children", "[]");
 
 const buttons = [new Button, new Button];
 const containerWithParameters = new ButtonsContainer({
@@ -18,7 +18,7 @@
     buttonMargin: 10,
     leftMargin: 20,
     rightMargin: 20,
-    buttons: buttons,
+    children: buttons,
     cssClassName: "foo"
 });
 shouldBeEqualToString("containerWithParameters.element.localName", "div");
@@ -27,7 +27,7 @@
 shouldBe("containerWithParameters.buttonMargin", "10");
 shouldBe("containerWithParameters.leftMargin", "20");
 shouldBe("containerWithParameters.rightMargin", "20");
-shouldBe("containerWithParameters.buttons", "buttons");
+shouldBe("containerWithParameters.children", "buttons");
 
 </script>
 <script src=""

Modified: trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-layout-expected.txt (227903 => 227904)


--- trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-layout-expected.txt	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-layout-expected.txt	2018-01-31 17:35:15 UTC (rev 227904)
@@ -3,10 +3,12 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS container.children.length is 3
-PASS container.children[0] is tenPtWideButton
-PASS container.children[1] is twentyPtWideButton
-PASS container.children[2] is thirtyPtWideButton
+PASS container.children.length is 5
+PASS tenPtWideButton.visible is true
+PASS disabledButton.visible is false
+PASS twentyPtWideButton.visible is true
+PASS droppedButton.visible is false
+PASS thirtyPtWideButton.visible is true
 PASS tenPtWideButton.x is 20
 PASS twentyPtWideButton.x is 40
 PASS thirtyPtWideButton.x is 70

Modified: trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-layout.html (227903 => 227904)


--- trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-layout.html	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/media/modern-media-controls/buttons-container/buttons-container-layout.html	2018-01-31 17:35:15 UTC (rev 227904)
@@ -28,14 +28,15 @@
     buttonMargin: 10,
     leftMargin: 20,
     rightMargin: 20,
-    buttons: [tenPtWideButton, disabledButton, twentyPtWideButton, droppedButton, thirtyPtWideButton]
+    children: [tenPtWideButton, disabledButton, twentyPtWideButton, droppedButton, thirtyPtWideButton]
 });
 
-container.layout();
-shouldBe("container.children.length", "3");
-shouldBe("container.children[0]", "tenPtWideButton");
-shouldBe("container.children[1]", "twentyPtWideButton");
-shouldBe("container.children[2]", "thirtyPtWideButton");
+shouldBe("container.children.length", "5");
+shouldBeTrue("tenPtWideButton.visible");
+shouldBeFalse("disabledButton.visible");
+shouldBeTrue("twentyPtWideButton.visible");
+shouldBeFalse("droppedButton.visible");
+shouldBeTrue("thirtyPtWideButton.visible");
 shouldBe("tenPtWideButton.x", "20");
 shouldBe("twentyPtWideButton.x", "40");
 shouldBe("thirtyPtWideButton.x", "70");

Modified: trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-rtl-expected.txt (227903 => 227904)


--- trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-rtl-expected.txt	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-rtl-expected.txt	2018-01-31 17:35:15 UTC (rev 227904)
@@ -7,7 +7,7 @@
 muted = false
 usesLTRUserInterfaceLayoutDirection = true
 PASS mediaControls.muteButton.iconName became Icons.Volume
-PASS mediaControls.topLeftControlsBar.children[1].buttons became [mediaControls.fullscreenButton, mediaControls.pipButton]
+PASS mediaControls.topLeftControlsBar.children[1].children became [mediaControls.fullscreenButton, mediaControls.pipButton]
 PASS getComputedStyle(mediaControls.topLeftControlsBar.element).left became "6px"
 
 width = 600
@@ -14,7 +14,7 @@
 muted = false
 usesLTRUserInterfaceLayoutDirection = false
 PASS mediaControls.muteButton.iconName became Icons.Volume
-PASS mediaControls.topLeftControlsBar.children[1].buttons became [mediaControls.pipButton, mediaControls.fullscreenButton]
+PASS mediaControls.topLeftControlsBar.children[1].children became [mediaControls.pipButton, mediaControls.fullscreenButton]
 PASS getComputedStyle(mediaControls.topLeftControlsBar.element).right became "6px"
 
 width = 250
@@ -21,7 +21,7 @@
 muted = false
 usesLTRUserInterfaceLayoutDirection = false
 PASS mediaControls.muteButton.iconName became Icons.VolumeRTL
-PASS mediaControls.topLeftControlsBar.children[1].buttons became [mediaControls.pipButton, mediaControls.fullscreenButton]
+PASS mediaControls.topLeftControlsBar.children[1].children became [mediaControls.pipButton, mediaControls.fullscreenButton]
 PASS getComputedStyle(mediaControls.topLeftControlsBar.element).right became "6px"
 
 width = 250
@@ -28,7 +28,7 @@
 muted = true
 usesLTRUserInterfaceLayoutDirection = false
 PASS mediaControls.muteButton.iconName became Icons.VolumeMutedRTL
-PASS mediaControls.topLeftControlsBar.children[1].buttons became [mediaControls.pipButton, mediaControls.fullscreenButton]
+PASS mediaControls.topLeftControlsBar.children[1].children became [mediaControls.pipButton, mediaControls.fullscreenButton]
 PASS getComputedStyle(mediaControls.topLeftControlsBar.element).right became "6px"
 
 width = 250
@@ -35,7 +35,7 @@
 muted = true
 usesLTRUserInterfaceLayoutDirection = true
 PASS mediaControls.muteButton.iconName became Icons.VolumeMuted
-PASS mediaControls.topLeftControlsBar.children[1].buttons became [mediaControls.fullscreenButton, mediaControls.pipButton]
+PASS mediaControls.topLeftControlsBar.children[1].children became [mediaControls.fullscreenButton, mediaControls.pipButton]
 PASS getComputedStyle(mediaControls.topLeftControlsBar.element).left became "6px"
 
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-rtl.html (227903 => 227904)


--- trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-rtl.html	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-rtl.html	2018-01-31 17:35:15 UTC (rev 227904)
@@ -22,7 +22,7 @@
     debug("muted = false");
     debug("usesLTRUserInterfaceLayoutDirection = true");
     shouldBecomeEqual("mediaControls.muteButton.iconName", "Icons.Volume", () => {
-        shouldBecomeEqual("mediaControls.topLeftControlsBar.children[1].buttons", "[mediaControls.fullscreenButton, mediaControls.pipButton]", () => {
+        shouldBecomeEqual("mediaControls.topLeftControlsBar.children[1].children", "[mediaControls.fullscreenButton, mediaControls.pipButton]", () => {
             shouldBecomeEqualToString("getComputedStyle(mediaControls.topLeftControlsBar.element).left", "6px", step2);
         });
     });
@@ -36,7 +36,7 @@
     debug("usesLTRUserInterfaceLayoutDirection = false");
     mediaControls.usesLTRUserInterfaceLayoutDirection = false;
     shouldBecomeEqual("mediaControls.muteButton.iconName", "Icons.Volume", () => {
-        shouldBecomeEqual("mediaControls.topLeftControlsBar.children[1].buttons", "[mediaControls.pipButton, mediaControls.fullscreenButton]", () => {
+        shouldBecomeEqual("mediaControls.topLeftControlsBar.children[1].children", "[mediaControls.pipButton, mediaControls.fullscreenButton]", () => {
             shouldBecomeEqualToString("getComputedStyle(mediaControls.topLeftControlsBar.element).right", "6px", step3);
         });
     });
@@ -50,7 +50,7 @@
     debug("usesLTRUserInterfaceLayoutDirection = false");
     mediaControls.width = 250;
     shouldBecomeEqual("mediaControls.muteButton.iconName", "Icons.VolumeRTL", () => {
-        shouldBecomeEqual("mediaControls.topLeftControlsBar.children[1].buttons", "[mediaControls.pipButton, mediaControls.fullscreenButton]", () => {
+        shouldBecomeEqual("mediaControls.topLeftControlsBar.children[1].children", "[mediaControls.pipButton, mediaControls.fullscreenButton]", () => {
             shouldBecomeEqualToString("getComputedStyle(mediaControls.topLeftControlsBar.element).right", "6px", step4);
         });
     });
@@ -64,7 +64,7 @@
     debug("usesLTRUserInterfaceLayoutDirection = false");
     mediaControls.muteButton.muted = true;
     shouldBecomeEqual("mediaControls.muteButton.iconName", "Icons.VolumeMutedRTL", () => {
-        shouldBecomeEqual("mediaControls.topLeftControlsBar.children[1].buttons", "[mediaControls.pipButton, mediaControls.fullscreenButton]", () => {
+        shouldBecomeEqual("mediaControls.topLeftControlsBar.children[1].children", "[mediaControls.pipButton, mediaControls.fullscreenButton]", () => {
             shouldBecomeEqualToString("getComputedStyle(mediaControls.topLeftControlsBar.element).right", "6px", step5);
         });
     });
@@ -78,7 +78,7 @@
     debug("usesLTRUserInterfaceLayoutDirection = true");
     mediaControls.usesLTRUserInterfaceLayoutDirection = true;
     shouldBecomeEqual("mediaControls.muteButton.iconName", "Icons.VolumeMuted", () => {
-        shouldBecomeEqual("mediaControls.topLeftControlsBar.children[1].buttons", "[mediaControls.fullscreenButton, mediaControls.pipButton]", () => {
+        shouldBecomeEqual("mediaControls.topLeftControlsBar.children[1].children", "[mediaControls.fullscreenButton, mediaControls.pipButton]", () => {
             shouldBecomeEqualToString("getComputedStyle(mediaControls.topLeftControlsBar.element).left", "6px", done);
         });
     });

Modified: trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-top-right-controls-bar-hidden-when-mute-button-disabled-expected.txt (227903 => 227904)


--- trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-top-right-controls-bar-hidden-when-mute-button-disabled-expected.txt	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-top-right-controls-bar-hidden-when-mute-button-disabled-expected.txt	2018-01-31 17:35:15 UTC (rev 227904)
@@ -8,7 +8,7 @@
 PASS mediaControls.topRightControlsBar.parent is mediaControls
 
 Mute button is disabled
-PASS mediaControls.muteButton.parent.parent is mediaControls.topRightControlsBar
+PASS mediaControls.muteButton.parent.parent is mediaControls.bottomControlsBar
 PASS mediaControls.topRightControlsBar.parent is null
 
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-top-right-controls-bar-hidden-when-mute-button-disabled.html (227903 => 227904)


--- trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-top-right-controls-bar-hidden-when-mute-button-disabled.html	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-top-right-controls-bar-hidden-when-mute-button-disabled.html	2018-01-31 17:35:15 UTC (rev 227904)
@@ -15,7 +15,7 @@
 debug("")
 debug("Mute button is disabled");
 mediaControls.muteButton.enabled = false;
-shouldBe("mediaControls.muteButton.parent.parent", "mediaControls.topRightControlsBar");
+shouldBe("mediaControls.muteButton.parent.parent", "mediaControls.bottomControlsBar");
 shouldBeNull("mediaControls.topRightControlsBar.parent");
 
 debug("");

Modified: trunk/LayoutTests/media/modern-media-controls/start-support/start-support-click-to-start.html (227903 => 227904)


--- trunk/LayoutTests/media/modern-media-controls/start-support/start-support-click-to-start.html	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/media/modern-media-controls/start-support/start-support-click-to-start.html	2018-01-31 17:35:15 UTC (rev 227904)
@@ -3,7 +3,7 @@
 <script src="" type="text/_javascript_"></script>
 <body>
 <video src="" style="width: 320px; height: 240px;" controls></video>
-<div id="shadow"></div>
+<div id="shadow" style="width: 320px; height: 240px;"></div>
 <script type="text/_javascript_">
 
 window.jsTestIsAsync = true;
@@ -10,7 +10,7 @@
 
 description("Testing the <code>MediaController</code> click-to-start behavior.");
 
-const shadowRoot = document.querySelector("div#shadow").attachShadow({ mode: "open" });
+const shadowRoot = document.querySelector("div#shadow");
 const media = document.querySelector("video");
 const mediaController = createControls(shadowRoot, media, null);
 
@@ -18,7 +18,7 @@
     shouldBeTrue("mediaController.controls.showsStartButton");
     debug("");
     debug("Pressing on the start button");
-    window.requestAnimationFrame(() => pressOnElement(mediaController.controls.startButton.element));
+    window.requestAnimationFrame(() => pressOnElement(mediaController.controls.playPauseButton.element));
 });
 
 media.addEventListener("play", function() {
@@ -25,7 +25,7 @@
     debug("Media is playing");
     shouldBeFalse("mediaController.controls.showsStartButton");
     debug("");
-    shadowRoot.host.remove();
+    shadowRoot.remove();
     media.remove();
     finishJSTest();
 });

Modified: trunk/LayoutTests/media/modern-media-controls/start-support/start-support-fullscreen.html (227903 => 227904)


--- trunk/LayoutTests/media/modern-media-controls/start-support/start-support-fullscreen.html	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/media/modern-media-controls/start-support/start-support-fullscreen.html	2018-01-31 17:35:15 UTC (rev 227904)
@@ -1,5 +1,6 @@
 <script src=""
 <script src="" type="text/_javascript_"></script>
+<script src="" type="text/_javascript_"></script>
 <body>
 <video src="" style="width: 320px; height: 240px;"></video>
 <div id="shadow"></div>
@@ -14,6 +15,7 @@
 const mediaController = createControls(shadowRoot, media, null);
 
 const button = document.body.appendChild(document.createElement("button"));
+button.textContent = "Enter Fullscreen";
 button.addEventListener("click", event => {
     try {
         media.webkitEnterFullscreen();
@@ -23,7 +25,7 @@
     }
 });
 
-media.addEventListener("webkitfullscreenchange", function() {
+media.addEventListener("webkitfullscreenchange", () => {
     debug("Media entered fullscreen");
     shouldBeFalse("mediaController.controls.showsStartButton");
     debug("");
@@ -31,17 +33,9 @@
     media.remove();
     button.remove();
     finishJSTest();
-});
+}, { once: true });
 
-media.addEventListener("loadedmetadata", event => {
-    if ("eventSender" in window) {
-        // Click the button so that we may enter fullscreen.
-        eventSender.mouseMoveTo(button.offsetLeft + 1, button.offsetTop + 1);
-        eventSender.mouseDown();
-        eventSender.mouseUp();
-    } else
-        debug("This test is designed to run in DRT");
-});
+media.addEventListener("loadedmetadata", () => pressOnElement(button), { once: true });
 
 </script>
 <script src=""

Modified: trunk/LayoutTests/media/modern-media-controls/start-support/start-support-lowPowerMode-expected.txt (227903 => 227904)


--- trunk/LayoutTests/media/modern-media-controls/start-support/start-support-lowPowerMode-expected.txt	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/media/modern-media-controls/start-support/start-support-lowPowerMode-expected.txt	2018-01-31 17:35:15 UTC (rev 227904)
@@ -4,12 +4,12 @@
 
 
 Received 'canplaythrough' event
-PASS !!internals.shadowRoot(media).querySelector('button.start') became true
+PASS !!internals.shadowRoot(media).querySelector('button.play-pause') became true
 PASS media.controls is false
 Pressing on the start button
 Received 'play' event
 PASS media.controls is false
-PASS internals.shadowRoot(media).querySelector('button.start') became null
+PASS internals.shadowRoot(media).querySelector('button.play-pause') became null
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/media/modern-media-controls/start-support/start-support-lowPowerMode.html (227903 => 227904)


--- trunk/LayoutTests/media/modern-media-controls/start-support/start-support-lowPowerMode.html	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/media/modern-media-controls/start-support/start-support-lowPowerMode.html	2018-01-31 17:35:15 UTC (rev 227904)
@@ -26,12 +26,12 @@
 media.addEventListener("canplaythrough", function() {
     debug("Received 'canplaythrough' event");
     // We should display the start button since we denied autoplay and the user needs a way to start playback.
-    shouldBecomeEqual("!!internals.shadowRoot(media).querySelector('button.start')", "true", function() {
+    shouldBecomeEqual("!!internals.shadowRoot(media).querySelector('button.play-pause')", "true", function() {
         shouldBeFalse("media.controls");
 
         debug("Pressing on the start button");
         hasUserGesture = true;
-        pressOnElement(internals.shadowRoot(media).querySelector('button.start'));
+        pressOnElement(internals.shadowRoot(media).querySelector('button.play-pause'));
     });
 });
 
@@ -39,7 +39,7 @@
     debug("Received 'play' event");
     shouldBeFalse("media.controls");
     if (hasUserGesture) {
-        shouldBecomeEqual("internals.shadowRoot(media).querySelector('button.start')", "null", endTest);
+        shouldBecomeEqual("internals.shadowRoot(media).querySelector('button.play-pause')", "null", endTest);
     } else {
         testFailed("Media started playing without user interaction");
         endTest();

Modified: trunk/LayoutTests/platform/ios/TestExpectations (227903 => 227904)


--- trunk/LayoutTests/platform/ios/TestExpectations	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2018-01-31 17:35:15 UTC (rev 227904)
@@ -3228,6 +3228,7 @@
 media/modern-media-controls/skip-back-button [ Pass ]
 media/modern-media-controls/skip-forward-button [ Pass ]
 media/modern-media-controls/slider [ Pass ]
+media/modern-media-controls/start-support [ Pass ]
 media/modern-media-controls/status-label [ Pass ]
 media/modern-media-controls/status-support [ Pass ]
 media/modern-media-controls/time-control [ Pass ]
@@ -3253,6 +3254,8 @@
 media/modern-media-controls/pip-support/ipad/pip-support-tap.html [ Skip ]
 media/modern-media-controls/placard-support/ipad [ Skip ]
 media/modern-media-controls/scrubber-support/ipad/scrubber-support-drag.html [ Skip ]
+media/modern-media-controls/start-support/start-support-click-to-start.html [ Skip ]
+media/modern-media-controls/start-support/start-support-lowPowerMode.html [ Skip ]
 
 # There is no focus state for on iOS
 media/modern-media-controls/button/button-focus-state.html [ Skip ]
@@ -3267,6 +3270,7 @@
 media/modern-media-controls/media-controller/media-controller-inline-to-fullscreen-to-inline.html [ Skip ]
 media/modern-media-controls/media-controller/media-controller-inline-to-fullscreen-to-pip-to-inline.html [ Skip ]
 media/modern-media-controls/placard-support/placard-support-airplay-fullscreen.html [ Skip ]
+media/modern-media-controls/start-support/start-support-fullscreen.html [ Skip ]
 
 # These tests specifically test iOS-only media controls features
 media/modern-media-controls/ios-inline-media-controls/ios-inline-media-controls-button-padding.html [ Pass ]

Modified: trunk/LayoutTests/platform/mac/TestExpectations (227903 => 227904)


--- trunk/LayoutTests/platform/mac/TestExpectations	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2018-01-31 17:35:15 UTC (rev 227904)
@@ -1488,6 +1488,7 @@
 media/modern-media-controls/skip-back-button [ Pass ]
 media/modern-media-controls/skip-forward-button [ Pass ]
 media/modern-media-controls/slider [ Pass ]
+media/modern-media-controls/start-support [ Pass ]
 media/modern-media-controls/status-label [ Pass ]
 media/modern-media-controls/status-support [ Pass ]
 media/modern-media-controls/text-tracks [ Pass ]

Modified: trunk/Source/WebCore/ChangeLog (227903 => 227904)


--- trunk/Source/WebCore/ChangeLog	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/Source/WebCore/ChangeLog	2018-01-31 17:35:15 UTC (rev 227904)
@@ -1,3 +1,50 @@
+2018-01-31  Antoine Quint  <[email protected]>
+
+        [Modern Media Controls] Turn media/modern-media-controls/start-support tests back on
+        https://bugs.webkit.org/show_bug.cgi?id=182297
+
+        Reviewed by Jon Lee and Eric Carlson.
+
+        We identified one cause of flakiness when turning those tests back on and fix it in this patch. There would be
+        cases where the play/pause button would never actually become visible because we would first set it as one of
+        the buttons in the left container in the bottom controls bar before we would identify that we should show the
+        prominent play/pause button, and then once we did, we would add it as a child to the InlineMediaControls. But,
+        because the actual layout of the ButtonsContainer would happen in a rAF due to being a layout() method, we would
+        remove the play/pause button from the InlineMediaControls and set it as a child of the left container even
+        though it wasn't visible.
+
+        Performing the layout of a ButtonsContainer should really happen immediately when we set the buttons, so in this
+        patch we remove the "buttons" property and clients of ButtonsContainer can simply add or remove children which
+        will be laid out in a row. To support this, we've added two notification methods to LayoutNode, one that indicates
+        when children have changed, didChangeChildren(), which we override in ButtonsContainer to perform a synchronous
+        layout. The other method is willRemoveChild() which we also override in ButtonsContainer, this time to reset
+        the "x" and "visible" properties which we set while performing layout.
+        
+        This fixes flakiness for media/modern-media-controls/start-support/start-support-click-to-start.html, and maybe
+        other modern-media-controls tests that could have been affected by this unexpected behavior.
+
+        * Modules/modern-media-controls/controls/buttons-container.js:
+        (ButtonsContainer.prototype.willRemoveChild):
+        (ButtonsContainer.prototype.didChangeChildren):
+        (ButtonsContainer.prototype.layout):
+        (ButtonsContainer.prototype.get buttons): Deleted.
+        (ButtonsContainer.prototype.set buttons): Deleted.
+        * Modules/modern-media-controls/controls/inline-media-controls.js:
+        (InlineMediaControls.prototype.layout):
+        (InlineMediaControls.prototype._updateBottomControlsBarLabel):
+        (InlineMediaControls.prototype._addTopRightBarWithMuteButtonToChildren):
+        (InlineMediaControls):
+        * Modules/modern-media-controls/controls/layout-node.js:
+        (LayoutNode.prototype.set children):
+        (LayoutNode.prototype.addChild):
+        (LayoutNode.prototype.removeChild):
+        (LayoutNode.prototype.willRemoveChild):
+        (LayoutNode.prototype.didChangeChildren):
+        * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js:
+        (MacOSFullscreenMediaControls.prototype.layout):
+        * Modules/modern-media-controls/media/media-controller.js: Drive-by fix to correctly set the value passed as
+        data-auto-hide-delay on a <video> element.
+
 2018-01-31  Zalan Bujtas  <[email protected]>
 
         [RenderTreeBuilder] Move RenderMultiColumnFlow::resolveMovedChild to RenderTreeBuilder.

Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/buttons-container.js (227903 => 227904)


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/buttons-container.js	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/buttons-container.js	2018-01-31 17:35:15 UTC (rev 227904)
@@ -26,30 +26,31 @@
 class ButtonsContainer extends LayoutNode
 {
 
-    constructor({ buttons = [], leftMargin = 16, rightMargin = 16, buttonMargin = 16, cssClassName = "" } = {})
+    constructor({ children = [], leftMargin = 16, rightMargin = 16, buttonMargin = 16, cssClassName = "" } = {})
     {
         super(`<div class="buttons-container ${cssClassName}"></div>`);
 
-        this.buttons = buttons;
         this.leftMargin = leftMargin;
         this.rightMargin = rightMargin;
         this.buttonMargin = buttonMargin;
+        this.children = children;
     }
 
     // Public
 
-    get buttons()
+    willRemoveChild(child)
     {
-        return this._buttons;
+        super.willRemoveChild(child);
+
+        // We reset properties that we may have overridden during layout to their default values.
+        child.visible = true;
+        child.x = 0;
     }
 
-    set buttons(buttons)
+    didChangeChildren()
     {
-        if (!Array.isArray(buttons))
-            return;
-
-        this._buttons = buttons;
-        this.needsLayout = true;
+        super.didChangeChildren();
+        this.layout();
     }
 
     layout()
@@ -56,23 +57,23 @@
     {
         super.layout();
 
-        const children = [];
         let x = this.leftMargin;
+        let numberOfVisibleButtons = 0;
 
-        this._buttons.forEach(button => {
-            if (!button.enabled || button.dropped)
+        this._children.forEach(button => {
+            button.visible = button.enabled && !button.dropped;
+            if (!button.visible)
                 return;
+
             button.x = x;
             x += button.width + this.buttonMargin;
-            children.push(button);
+            numberOfVisibleButtons++;
         });
 
-        if (children.length)
+        if (numberOfVisibleButtons)
             this.width = x - this.buttonMargin + this.rightMargin;
         else
             this.width = this.buttonMargin + this.rightMargin;
-
-        this.children = children;
     }
 
 }

Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/inline-media-controls.js (227903 => 227904)


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/inline-media-controls.js	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/inline-media-controls.js	2018-01-31 17:35:15 UTC (rev 227904)
@@ -129,7 +129,7 @@
             return;
 
         // Update the top left controls bar.
-        this._topLeftControlsBarContainer.buttons = this._topLeftContainerButtons();
+        this._topLeftControlsBarContainer.children = this._topLeftContainerButtons();
         this._topLeftControlsBarContainer.layout();
         this.topLeftControlsBar.width = this._topLeftControlsBarContainer.width;
         this.topLeftControlsBar.visible = this._topLeftControlsBarContainer.children.length > 0;
@@ -160,9 +160,9 @@
         // Iterate through controls to see if we need to drop any of them. Reset all default states before we proceed.
         this.bottomControlsBar.visible = true;
         this.playPauseButton.style = Button.Styles.Bar;
-        this.leftContainer.buttons = this._leftContainerButtons();
-        this.rightContainer.buttons = this._rightContainerButtons();
-        this.rightContainer.buttons.concat(this.leftContainer.buttons).forEach(button => delete button.dropped);
+        this.leftContainer.children = this._leftContainerButtons();
+        this.rightContainer.children = this._rightContainerButtons();
+        this.rightContainer.children.concat(this.leftContainer.children).forEach(button => delete button.dropped);
         this.muteButton.style = this.preferredMuteButtonStyle;
         this.muteButton.usesRTLIconVariant = false;
 
@@ -232,7 +232,8 @@
 
     // Private
 
-    _updateBottomControlsBarLabel() {
+    _updateBottomControlsBarLabel()
+    {
         this.bottomControlsBar.element.setAttribute("aria-label", this._shouldUseAudioLayout ? UIString("Audio Controls") : UIString("Video Controls"));
     }
     
@@ -284,7 +285,7 @@
         delete this.muteButton.dropped;
         this.muteButton.style = Button.Styles.Bar;
         this.muteButton.usesRTLIconVariant = !this.usesLTRUserInterfaceLayoutDirection;
-        this._topRightControlsBarContainer.buttons = [this.muteButton];
+        this._topRightControlsBarContainer.children = [this.muteButton];
         this._topRightControlsBarContainer.layout();
         this.topRightControlsBar.width = this._topRightControlsBarContainer.width;
         children.push(this.topRightControlsBar);

Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/layout-node.js (227903 => 227904)


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/layout-node.js	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/layout-node.js	2018-01-31 17:35:15 UTC (rev 227904)
@@ -142,11 +142,16 @@
                 return;
         }
 
+        this._updatingChildren = true;
+
         while (this._children.length)
             this.removeChild(this._children[0]);
 
         for (let child of children)
             this.addChild(child);
+
+        delete this._updatingChildren;
+        this.didChangeChildren();
     }
 
     parentOfType(type)
@@ -169,6 +174,9 @@
         this._children.splice(index, 0, child);
         child._parent = this;
 
+        if (!this._updatingChildren)
+            this.didChangeChildren();
+
         child._markNodeManipulation(LayoutNode.DOMManipulation.Addition);
 
         return child;
@@ -194,9 +202,13 @@
         if (index === -1)
             return;
 
+        this.willRemoveChild(child);
         this._children.splice(index, 1);
         child._parent = null;
 
+        if (!this._updatingChildren)
+            this.didChangeChildren();
+
         child._markNodeManipulation(LayoutNode.DOMManipulation.Removal);
 
         return child;
@@ -267,6 +279,16 @@
         }
     }
 
+    willRemoveChild(child)
+    {
+        // Implemented by subclasses.
+    }
+
+    didChangeChildren()
+    {
+        // Implemented by subclasses.
+    }
+
     // Private
 
     _markNodeManipulation(manipulation)

Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js (227903 => 227904)


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js	2018-01-31 17:35:15 UTC (rev 227904)
@@ -51,7 +51,7 @@
         this.volumeSlider.width = 60;
 
         this._leftContainer = new ButtonsContainer({
-            buttons: [this.volumeDownButton, this.volumeSlider, this.volumeUpButton],
+            children: [this.volumeDownButton, this.volumeSlider, this.volumeUpButton],
             cssClassName: "left",
             leftMargin: 12,
             rightMargin: 0,
@@ -59,7 +59,7 @@
         });
 
         this._centerContainer = new ButtonsContainer({
-            buttons: [this.rewindButton, this.playPauseButton, this.forwardButton],
+            children: [this.rewindButton, this.playPauseButton, this.forwardButton],
             cssClassName: "center",
             leftMargin: 27,
             rightMargin: 27,
@@ -67,7 +67,7 @@
         });
 
         this._rightContainer = new ButtonsContainer({
-            buttons: [this.airplayButton, this.pipButton, this.tracksButton, this.fullscreenButton],
+            children: [this.airplayButton, this.pipButton, this.tracksButton, this.fullscreenButton],
             cssClassName: "right",
             leftMargin: 12,
             rightMargin: 12
@@ -113,7 +113,7 @@
         if (!this._rightContainer)
             return;
 
-        const numberOfEnabledButtons = this._rightContainer.buttons.filter(button => button.enabled).length;
+        const numberOfEnabledButtons = this._rightContainer.children.filter(button => button.enabled).length;
 
         let buttonMargin = ButtonMarginForFiveButtons;
         if (numberOfEnabledButtons === 4)

Modified: trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js (227903 => 227904)


--- trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js	2018-01-31 16:45:30 UTC (rev 227903)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js	2018-01-31 17:35:15 UTC (rev 227904)
@@ -197,7 +197,7 @@
         this.controls.delegate = this;
 
         if (this.shadowRoot.host && this.shadowRoot.host.dataset.autoHideDelay)
-            this.controls.bottomControlsBar.autoHideDelay = this.shadowRoot.host.dataset.autoHideDelay;
+            this.controls.autoHideController.autoHideDelay = this.shadowRoot.host.dataset.autoHideDelay;
 
         if (previousControls) {
             this.controls.fadeIn();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to