Media documents inside iframes should not get controls in the TouchBar unless the
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 May 2017 17:18:50 +0000 (17:18 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 May 2017 17:18:50 +0000 (17:18 +0000)
video is playing
https://bugs.webkit.org/show_bug.cgi?id=172620
-and corresponding-
rdar://problem/32165477

Reviewed by Jon Lee.

Source/WebCore:

Media documents get to return early with true, but that should only apply to
mainframe media documents.
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::canShowControlsManager):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit2Cocoa/offscreen-iframe-of-media-document.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217496 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/MediaElementSession.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/offscreen-iframe-of-media-document.html [new file with mode: 0644]

index 523e01f..f07e376 100644 (file)
@@ -1,3 +1,18 @@
+2017-05-26  Beth Dakin  <bdakin@apple.com>
+
+        Media documents inside iframes should not get controls in the TouchBar unless the 
+        video is playing
+        https://bugs.webkit.org/show_bug.cgi?id=172620
+        -and corresponding-
+        rdar://problem/32165477
+
+        Reviewed by Jon Lee.
+
+        Media documents get to return early with true, but that should only apply to 
+        mainframe media documents. 
+        * html/MediaElementSession.cpp:
+        (WebCore::MediaElementSession::canShowControlsManager):
+
 2017-05-26  Youenn Fablet  <youenn@apple.com>
 
         Minor clean-up related to DocumentThreadableLoader redirections
index 0e49bad..c2a1e28 100644 (file)
@@ -275,7 +275,7 @@ bool MediaElementSession::canShowControlsManager(PlaybackControlsPurpose purpose
         return false;
     }
 
-    if (m_element.document().isMediaDocument()) {
+    if (m_element.document().isMediaDocument() && (m_element.document().frame() && m_element.document().frame()->isMainFrame())) {
         LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is media document");
         return true;
     }
index e9b7bb3..a0a6fd3 100644 (file)
@@ -1,3 +1,18 @@
+2017-05-26  Beth Dakin  <bdakin@apple.com>
+
+        Media documents inside iframes should not get controls in the TouchBar unless the 
+        video is playing
+        https://bugs.webkit.org/show_bug.cgi?id=172620
+        -and corresponding-
+        rdar://problem/32165477
+
+        Reviewed by Jon Lee.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKit2Cocoa/offscreen-iframe-of-media-document.html: Added.
+
 2017-05-25  Joseph Pecoraro  <pecoraro@apple.com>
 
         _WKUserStyleSheet and WKUserScript leak string data
index 146a48c..dcf6474 100644 (file)
                93AF4ECE1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93AF4ECD1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp */; };
                93AF4ED11506F130007FD57E /* lots-of-images.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 93AF4ECF1506F123007FD57E /* lots-of-images.html */; };
                93CFA8671CEB9E38000565A8 /* autofocused-text-input.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 93CFA8661CEB9DE1000565A8 /* autofocused-text-input.html */; };
+               93E2D2761ED7D53200FA76F6 /* offscreen-iframe-of-media-document.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 93E2D2751ED7D51700FA76F6 /* offscreen-iframe-of-media-document.html */; };
                93F1DB3414DA20870024C362 /* NewFirstVisuallyNonEmptyLayout_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1DB3314DA20870024C362 /* NewFirstVisuallyNonEmptyLayout_Bundle.cpp */; };
                93F1DB5714DB1B840024C362 /* NewFirstVisuallyNonEmptyLayoutFails_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1DB5614DB1B840024C362 /* NewFirstVisuallyNonEmptyLayoutFails_Bundle.cpp */; };
                93F56DA71E5F9174003EDE84 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 7C83E0331D0A5F2700FEBCF3 /* libicucore.dylib */; };
                F4451C761EB8FD890020C5DA /* two-paragraph-contenteditable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4451C751EB8FD7C0020C5DA /* two-paragraph-contenteditable.html */; };
                F4538EF71E8473E600B5C953 /* large-red-square.png in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4538EF01E846B4100B5C953 /* large-red-square.png */; };
                F47728991E4AE3C1007ABF6A /* full-page-contenteditable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F47728981E4AE3AD007ABF6A /* full-page-contenteditable.html */; };
-               F47D30EC1ED28631000482E1 /* apple.gif in Copy Resources */ = {isa = PBXBuildFile; fileRef = F47D30EB1ED28619000482E1 /* apple.gif */; };
-               F47D30EE1ED28E7D000482E1 /* gif-and-file-input.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F47D30ED1ED28A6C000482E1 /* gif-and-file-input.html */; };
                F4856CA31E649EA8009D7EE7 /* attachment-element.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4856CA21E6498A8009D7EE7 /* attachment-element.html */; };
                F4BFA68E1E4AD08000154298 /* DragAndDropPasteboardTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */; };
                F4C2AB221DD6D95E00E06D5B /* enormous-video-with-sound.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */; };
                        dstPath = TestWebKitAPI.resources;
                        dstSubfolderSpec = 7;
                        files = (
+                               93E2D2761ED7D53200FA76F6 /* offscreen-iframe-of-media-document.html in Copy Resources */,
                                CDA3159A1ED548F1009F60D3 /* MediaPlaybackSleepAssertion.html in Copy Resources */,
                                C9B1043E1ECF9848000520FA /* autoplay-inherits-gesture-from-document.html in Copy Resources */,
                                3FCC4FE81EC4E8CA0076E37C /* PictureInPictureDelegate.html in Copy Resources */,
                93CFA8681CEBCFED000565A8 /* CandidateTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CandidateTests.mm; sourceTree = "<group>"; };
                93D3D19B17B1A7B000C7C415 /* all-content-in-one-iframe.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "all-content-in-one-iframe.html"; sourceTree = "<group>"; };
                93D3D19D17B1A84200C7C415 /* LayoutMilestonesWithAllContentInFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutMilestonesWithAllContentInFrame.cpp; sourceTree = "<group>"; };
+               93E2D2751ED7D51700FA76F6 /* offscreen-iframe-of-media-document.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "offscreen-iframe-of-media-document.html"; sourceTree = "<group>"; };
                93E943F11CD3E87E00AC08C2 /* VideoControlsManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoControlsManager.mm; sourceTree = "<group>"; };
                93F1DB3014DA20760024C362 /* NewFirstVisuallyNonEmptyLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayout.cpp; sourceTree = "<group>"; };
                93F1DB3314DA20870024C362 /* NewFirstVisuallyNonEmptyLayout_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayout_Bundle.cpp; sourceTree = "<group>"; };
                                46C519E31D35629600DAA51A /* LocalStorageNullEntries.localstorage */,
                                46C519E41D35629600DAA51A /* LocalStorageNullEntries.localstorage-shm */,
                                7A6A2C711DCCFB0200C0D085 /* LocalStorageQuirkEnabled.html */,
+                               93E2D2751ED7D51700FA76F6 /* offscreen-iframe-of-media-document.html */,
                                7CCB99221D3B44E7003922F6 /* open-multiple-external-url.html */,
                                CEBCA1341E3A803400C73293 /* page-with-csp-iframe.html */,
                                CEBCA1351E3A803400C73293 /* page-with-csp.html */,
index 1d630c9..7bc515c 100644 (file)
@@ -413,6 +413,15 @@ TEST(VideoControlsManager, VideoControlsManagerSmallVideoInMediaDocument)
     // We expect the media controller to be present because this is a media document.
     EXPECT_TRUE([webView _hasActiveVideoForControlsManager]);
 }
+    
+TEST(VideoControlsManager, VideoControlsManagerOffscreenIframeMediaDocument)
+{
+    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600));
+    [webView loadTestPageNamed:@"offscreen-iframe-of-media-document"];
+    
+    // We do not expect a controls manager becuase the media document is in an iframe.
+    [webView expectControlsManager:NO afterReceivingMessage:@"loaded"];
+}
 
 TEST(VideoControlsManager, VideoControlsManagerLongSkinnyVideoInWideMainFrame)
 {
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/offscreen-iframe-of-media-document.html b/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/offscreen-iframe-of-media-document.html
new file mode 100644 (file)
index 0000000..c2e7b9b
--- /dev/null
@@ -0,0 +1,17 @@
+<html>
+<head>
+<script>
+    function loaded() {
+        try {
+            window.webkit.messageHandlers.testHandler.postMessage("loaded");
+       } catch(e) { }
+    }
+</script>
+</head>
+<body onload="loaded()">
+    
+<div style="width:25px; height:800px;"></div>
+<iframe width="320" height="240" src="test.mp4" />
+
+</body>
+</html>