Title: [208242] trunk
Revision
208242
Author
[email protected]
Date
2016-11-01 14:43:55 -0700 (Tue, 01 Nov 2016)

Log Message

[Modern Media Controls] Media Controller: Placard support
https://bugs.webkit.org/show_bug.cgi?id=163731
<rdar://problem/28869598>

Patch by Antoine Quint <[email protected]> on 2016-11-01
Reviewed by Dean Jackson.

Source/WebCore:

We introduce the PlacardSupport class which brings support for showing the
appropriate placard when the media is played via AirPlay or in picture-in-picture.

Tests: media/modern-media-controls/placard-support/placard-support-airplay.html
       media/modern-media-controls/placard-support/placard-support-pip.html

* Modules/modern-media-controls/js-files:
* Modules/modern-media-controls/media/media-controller.js:
(MediaController):
* Modules/modern-media-controls/media/placard-support.js: Added.
(PlacardSupport):
(PlacardSupport.prototype.get mediaEvents):
(PlacardSupport.prototype.handleEvent):
(PlacardSupport.prototype._updatePlacard):
* WebCore.xcodeproj/project.pbxproj:

LayoutTests:

Adding two new tests to check that the picture-in-picture and AirPlay placards are shown
based on the media presentation mode.

* media/modern-media-controls/placard-support/placard-support-airplay-expected.txt: Added.
* media/modern-media-controls/placard-support/placard-support-airplay.html: Added.
* media/modern-media-controls/placard-support/placard-support-pip-expected.txt: Added.
* media/modern-media-controls/placard-support/placard-support-pip.html: Added.
* platform/ios-simulator/TestExpectations:
* platform/mac/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208241 => 208242)


--- trunk/LayoutTests/ChangeLog	2016-11-01 21:43:12 UTC (rev 208241)
+++ trunk/LayoutTests/ChangeLog	2016-11-01 21:43:55 UTC (rev 208242)
@@ -1,3 +1,30 @@
+2016-11-01  Antoine Quint  <[email protected]>
+
+        [Modern Media Controls] Media Controller: Placard support
+        https://bugs.webkit.org/show_bug.cgi?id=163731
+        <rdar://problem/28869598>
+
+        Reviewed by Dean Jackson.
+
+        Adding two new tests to check that the picture-in-picture and AirPlay placards are shown
+        based on the media presentation mode.
+
+        * media/modern-media-controls/placard-support/placard-support-airplay-expected.txt: Added.
+        * media/modern-media-controls/placard-support/placard-support-airplay.html: Added.
+        * media/modern-media-controls/placard-support/placard-support-pip-expected.txt: Added.
+        * media/modern-media-controls/placard-support/placard-support-pip.html: Added.
+        * platform/ios-simulator/TestExpectations:
+        * platform/mac/TestExpectations:
+
+2016-11-01  Ryan Haddad  <[email protected]>
+
+        Marking inspector/storage/domStorage-events.html as flaky.
+        https://bugs.webkit.org/show_bug.cgi?id=164278
+
+        Unreviewed test gardening.
+
+        * platform/mac/TestExpectations:
+
 2016-11-01  Alex Christensen  <[email protected]>
 
         Percent-encode non-ASCII code points in hosts of URLs with unrecognized schemes

Added: trunk/LayoutTests/media/modern-media-controls/placard-support/placard-support-airplay-expected.txt (0 => 208242)


--- trunk/LayoutTests/media/modern-media-controls/placard-support/placard-support-airplay-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/placard-support/placard-support-airplay-expected.txt	2016-11-01 21:43:55 UTC (rev 208242)
@@ -0,0 +1,11 @@
+Testing the PlacardSupport behavior when playing media through AirPlay.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS mediaController.controls.showsPlacard is true
+PASS mediaController.controls.children.includes(mediaController.controls.airplayPlacard) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/media/modern-media-controls/placard-support/placard-support-airplay.html (0 => 208242)


--- trunk/LayoutTests/media/modern-media-controls/placard-support/placard-support-airplay.html	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/placard-support/placard-support-airplay.html	2016-11-01 21:43:55 UTC (rev 208242)
@@ -0,0 +1,56 @@
+<script src=""
+<script src="" type="text/_javascript_"></script>
+<body>
+<style type="text/css" media="screen">
+    
+    video, #host {
+        position: absolute;
+        top: 0;
+        left: 0;
+    }
+
+    video {
+        width: 800px;
+        height: 240px;
+    }
+    
+</style>
+<video src="" autoplay></video>
+<div id="host"></div>
+<script type="text/_javascript_">
+
+window.jsTestIsAsync = true;
+
+description("Testing the <code>PlacardSupport</code> behavior when playing media through AirPlay.");
+
+iconService.directoryPath = "../../../../Source/WebCore/Modules/modern-media-controls/images";
+
+const container = document.querySelector("div#host");
+const media = document.querySelector("video");
+const mediaController = createControls(container, media, null);
+
+if (window.internals) {
+    window.internals.settings.setAllowsAirPlayForMediaPlayback(true);
+    window.internals.setMediaElementRestrictions(media, "norestrictions");
+}
+
+media.addEventListener("webkitcurrentplaybacktargetiswirelesschanged", () => {
+    if (!media.paused && media.webkitCurrentPlaybackTargetIsWireless) {
+        shouldBeTrue("mediaController.controls.showsPlacard");
+        shouldBeTrue("mediaController.controls.children.includes(mediaController.controls.airplayPlacard)");
+
+        container.remove();
+        media.remove();
+        finishJSTest();
+    }
+});
+
+media.addEventListener("play", () => {
+    media.webkitShowPlaybackTargetPicker();
+    if (window.internals)
+        window.internals.setMockMediaPlaybackTargetPickerState("Sleepy TV", "DeviceAvailable");
+});
+
+</script>
+<script src=""
+</body>

Added: trunk/LayoutTests/media/modern-media-controls/placard-support/placard-support-pip-expected.txt (0 => 208242)


--- trunk/LayoutTests/media/modern-media-controls/placard-support/placard-support-pip-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/placard-support/placard-support-pip-expected.txt	2016-11-01 21:43:55 UTC (rev 208242)
@@ -0,0 +1,13 @@
+Testing the PlacardSupport behavior when entering picture-in-picture.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS mediaController.controls.showsPlacard is true
+PASS mediaController.controls.children.includes(mediaController.controls.pipPlacard) is true
+PASS mediaController.controls.showsPlacard is false
+PASS mediaController.controls.children.includes(mediaController.controls.pipPlacard) is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/media/modern-media-controls/placard-support/placard-support-pip.html (0 => 208242)


--- trunk/LayoutTests/media/modern-media-controls/placard-support/placard-support-pip.html	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/placard-support/placard-support-pip.html	2016-11-01 21:43:55 UTC (rev 208242)
@@ -0,0 +1,69 @@
+<script src=""
+<script src="" type="text/_javascript_"></script>
+<body>
+<style type="text/css" media="screen">
+    
+    video, #host {
+        position: absolute;
+        top: 0;
+        left: 0;
+    }
+
+    video {
+        width: 800px;
+        height: 240px;
+    }
+    
+</style>
+<video src="" autoplay></video>
+<div id="host"></div>
+<script type="text/_javascript_">
+
+window.jsTestIsAsync = true;
+
+description("Testing the <code>PlacardSupport</code> behavior when entering picture-in-picture.");
+
+iconService.directoryPath = "../../../../Source/WebCore/Modules/modern-media-controls/images";
+
+if (window.internals)
+    window.internals.settings.setAllowsPictureInPictureMediaPlayback(true);
+
+const container = document.querySelector("div#host");
+const media = document.querySelector("video");
+const mediaController = createControls(container, media, null);
+
+const button = document.body.appendChild(document.createElement("button"));
+
+button.addEventListener("click", () => {
+    media.webkitSetPresentationMode(media.webkitPresentationMode == "inline" ? "picture-in-picture" : "inline");
+});
+
+media.addEventListener("webkitpresentationmodechanged", () => {
+    if (media.webkitPresentationMode == "picture-in-picture") {
+        shouldBeTrue("mediaController.controls.showsPlacard");
+        shouldBeTrue("mediaController.controls.children.includes(mediaController.controls.pipPlacard)");
+        clickButton();
+    } else {
+        shouldBeFalse("mediaController.controls.showsPlacard");
+        shouldBeFalse("mediaController.controls.children.includes(mediaController.controls.pipPlacard)");
+        container.remove();
+        media.remove();
+        finishJSTest();
+    }
+});
+
+media.addEventListener("play", clickButton);
+
+function clickButton() {
+    const bounds = button.getBoundingClientRect();
+    const centerX = bounds.left + bounds.width / 2;
+    const centerY = bounds.top + bounds.height / 2;
+
+    eventSender.mouseMoveTo(centerX, centerY);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+</script>
+<script src=""
+</body>

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (208241 => 208242)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-11-01 21:43:12 UTC (rev 208241)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-11-01 21:43:55 UTC (rev 208242)
@@ -2741,3 +2741,6 @@
 
 # Only Mac has implemented DictionaryLookup
 fast/layers/prevent-hit-test-during-layout.html [ Skip ]
+
+# Internal APIs to test PiP and AirPlay are not available on iOS.
+media/modern-media-controls/placard-support [ Skip ]

Modified: trunk/LayoutTests/platform/mac/TestExpectations (208241 => 208242)


--- trunk/LayoutTests/platform/mac/TestExpectations	2016-11-01 21:43:12 UTC (rev 208241)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2016-11-01 21:43:55 UTC (rev 208242)
@@ -1450,3 +1450,6 @@
 
 webkit.org/b/164088 [ Yosemite ] media/modern-media-controls/scrubber-support/scrubber-support-click.html [ Skip ]
 webkit.org/b/164088 [ Yosemite ] media/modern-media-controls/scrubber-support/scrubber-support-drag.html [ Skip ]
+
+# Internal APIs to test PiP and AirPlay are not available on Yosemite.
+[ Yosemite ] media/modern-media-controls/placard-support [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (208241 => 208242)


--- trunk/Source/WebCore/ChangeLog	2016-11-01 21:43:12 UTC (rev 208241)
+++ trunk/Source/WebCore/ChangeLog	2016-11-01 21:43:55 UTC (rev 208242)
@@ -1,3 +1,27 @@
+2016-11-01  Antoine Quint  <[email protected]>
+
+        [Modern Media Controls] Media Controller: Placard support
+        https://bugs.webkit.org/show_bug.cgi?id=163731
+        <rdar://problem/28869598>
+
+        Reviewed by Dean Jackson.
+
+        We introduce the PlacardSupport class which brings support for showing the
+        appropriate placard when the media is played via AirPlay or in picture-in-picture.
+
+        Tests: media/modern-media-controls/placard-support/placard-support-airplay.html
+               media/modern-media-controls/placard-support/placard-support-pip.html
+
+        * Modules/modern-media-controls/js-files:
+        * Modules/modern-media-controls/media/media-controller.js:
+        (MediaController):
+        * Modules/modern-media-controls/media/placard-support.js: Added.
+        (PlacardSupport):
+        (PlacardSupport.prototype.get mediaEvents):
+        (PlacardSupport.prototype.handleEvent):
+        (PlacardSupport.prototype._updatePlacard):
+        * WebCore.xcodeproj/project.pbxproj:
+
 2016-11-01  Zalan Bujtas  <[email protected]>
 
         ShowRenderTree: Add information about the type of the needsLayout bit.

Modified: trunk/Source/WebCore/Modules/modern-media-controls/js-files (208241 => 208242)


--- trunk/Source/WebCore/Modules/modern-media-controls/js-files	2016-11-01 21:43:12 UTC (rev 208241)
+++ trunk/Source/WebCore/Modules/modern-media-controls/js-files	2016-11-01 21:43:55 UTC (rev 208242)
@@ -30,6 +30,7 @@
 media/media-controller-support.js
 media/elapsed-time-support.js
 media/mute-support.js
+media/placard-support.js
 media/playback-support.js
 media/remaining-time-support.js
 media/scrubbing-support.js

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


--- trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js	2016-11-01 21:43:12 UTC (rev 208241)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js	2016-11-01 21:43:55 UTC (rev 208242)
@@ -40,6 +40,7 @@
 
         new ElapsedTimeSupport(this);
         new MuteSupport(this);
+        new PlacardSupport(this);
         new PlaybackSupport(this);
         new RemainingTimeSupport(this);
         new ScrubbingSupport(this);

Copied: trunk/Source/WebCore/Modules/modern-media-controls/media/placard-support.js (from rev 208241, trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js) (0 => 208242)


--- trunk/Source/WebCore/Modules/modern-media-controls/media/placard-support.js	                        (rev 0)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/placard-support.js	2016-11-01 21:43:55 UTC (rev 208242)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+class PlacardSupport extends MediaControllerSupport
+{
+
+    constructor(mediaController)
+    {
+        super(mediaController);
+        this._updatePlacard();
+    }
+
+    // Protected
+
+    get mediaEvents()
+    {
+        return ["webkitpresentationmodechanged", "webkitcurrentplaybacktargetiswirelesschanged"];
+    }
+
+    handleEvent(event)
+    {
+        this._updatePlacard();
+    }
+
+    // Private
+
+    _updatePlacard()
+    {
+        const controls = this.mediaController.controls;
+        if (controls.showsStartButton)
+            return;
+
+        const media = this.mediaController.media;
+        if (media.webkitPresentationMode === "picture-in-picture")
+            controls.showPlacard(controls.pipPlacard);
+        else if (media.webkitCurrentPlaybackTargetIsWireless)
+            controls.showPlacard(controls.airplayPlacard);
+        else
+            controls.hidePlacard();    
+    }
+
+}

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (208241 => 208242)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-11-01 21:43:12 UTC (rev 208241)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-11-01 21:43:55 UTC (rev 208242)
@@ -9871,6 +9871,7 @@
 		7117445714BC34E200EE5FC8 /* SVGTextMetricsBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTextMetricsBuilder.h; sourceTree = "<group>"; };
 		7118FED215685CC60030B79A /* JSSVGViewSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGViewSpec.cpp; sourceTree = "<group>"; };
 		7118FED315685CC60030B79A /* JSSVGViewSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSVGViewSpec.h; sourceTree = "<group>"; };
+		711FB0751DC7688F00C4C708 /* placard-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = "placard-support.js"; sourceTree = "<group>"; };
 		7134496B146941B300720312 /* SVGLengthContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGLengthContext.cpp; sourceTree = "<group>"; };
 		7134496C146941B300720312 /* SVGLengthContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGLengthContext.h; sourceTree = "<group>"; };
 		713E70AF1733E8B300A22D00 /* plugIns.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode._javascript_; path = plugIns.js; sourceTree = "<group>"; };
@@ -17881,6 +17882,7 @@
 				7177E2461DB80D2F00919A0B /* media-controller-support.js */,
 				71D02D921DB55C4E00DD5CF5 /* media-controller.js */,
 				7177E2471DB80D2F00919A0B /* mute-support.js */,
+				711FB0751DC7688F00C4C708 /* placard-support.js */,
 				71004B9D1DC1398800A52A38 /* playback-support.js */,
 				71004B9B1DC1109300A52A38 /* remaining-time-support.js */,
 				7157E3D11DC1EE4B0094550E /* scrubbing-support.js */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to