Title: [203478] trunk/Tools
Revision
203478
Author
commit-qu...@webkit.org
Date
2016-07-20 16:24:15 -0700 (Wed, 20 Jul 2016)

Log Message

Add API test for layout constraints after exit fullscreen
https://bugs.webkit.org/show_bug.cgi?id=159900

Patch by Jeremy Jones <jere...@apple.com> on 2016-07-20
Reviewed by Jon Lee.

Added Fullscreen.LaytoutConstraints API test.
Tests fix from https://bugs.webkit.org/show_bug.cgi?id=159731

This test compares layout constraints on the web view before and after fullscreen to make sure
they are preserved.

* TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenLayoutConstraints.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenLayoutConstraints.mm: Added.
(-[FullscreenStateChangeMessageHandler userContentController:didReceiveScriptMessage:]):
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (203477 => 203478)


--- trunk/Tools/ChangeLog	2016-07-20 23:23:56 UTC (rev 203477)
+++ trunk/Tools/ChangeLog	2016-07-20 23:24:15 UTC (rev 203478)
@@ -1,3 +1,21 @@
+2016-07-20  Jeremy Jones  <jere...@apple.com>
+
+        Add API test for layout constraints after exit fullscreen
+        https://bugs.webkit.org/show_bug.cgi?id=159900
+
+        Reviewed by Jon Lee.
+
+        Added Fullscreen.LaytoutConstraints API test. 
+        Tests fix from https://bugs.webkit.org/show_bug.cgi?id=159731
+
+        This test compares layout constraints on the web view before and after fullscreen to make sure 
+        they are preserved.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenLayoutConstraints.html: Added.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenLayoutConstraints.mm: Added.
+        (-[FullscreenStateChangeMessageHandler userContentController:didReceiveScriptMessage:]):
+        (TestWebKitAPI::TEST):
+
 2016-07-20  Ryan Haddad  <ryanhad...@apple.com>
 
         Disable two failing API tests.

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (203477 => 203478)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2016-07-20 23:23:56 UTC (rev 203477)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2016-07-20 23:24:15 UTC (rev 203478)
@@ -65,6 +65,7 @@
 		37D36ED71AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */; };
 		37DC6791140D7D7600ABCCDB /* DOMRangeOfString.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */; };
 		37E1064C1697681800B78BD0 /* DOMHTMLTableCellElementCellAbove.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 37E1064B169767F700B78BD0 /* DOMHTMLTableCellElementCellAbove.html */; };
+		3FBD1B4A1D3D66AB00E6D6FA /* FullscreenLayoutConstraints.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 3FBD1B491D39D1DB00E6D6FA /* FullscreenLayoutConstraints.html */; };
 		46C519DA1D355AB200DAA51A /* LocalStorageNullEntries.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46C519D81D355A7300DAA51A /* LocalStorageNullEntries.mm */; };
 		46C519E61D3563FD00DAA51A /* LocalStorageNullEntries.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 46C519E21D35629600DAA51A /* LocalStorageNullEntries.html */; };
 		46C519E71D3563FD00DAA51A /* LocalStorageNullEntries.localstorage in Copy Resources */ = {isa = PBXBuildFile; fileRef = 46C519E31D35629600DAA51A /* LocalStorageNullEntries.localstorage */; };
@@ -512,6 +513,7 @@
 				51714EB41CF8C78C004723C4 /* WebProcessKillIDBCleanup-1.html in Copy Resources */,
 				51714EB51CF8C78C004723C4 /* WebProcessKillIDBCleanup-2.html in Copy Resources */,
 				CDE195B51CFE0B880053D256 /* FullscreenTopContentInset.html in Copy Resources */,
+				3FBD1B4A1D3D66AB00E6D6FA /* FullscreenLayoutConstraints.html in Copy Resources */,
 				93CFA8671CEB9E38000565A8 /* autofocused-text-input.html in Copy Resources */,
 				93625D271CD9741C006DC1F1 /* large-video-without-audio.html in Copy Resources */,
 				936F72801CD7D9EC0068A0FB /* large-video-with-audio.html in Copy Resources */,
@@ -717,6 +719,8 @@
 		37E1064A1697676400B78BD0 /* DOMHTMLTableCellCellAbove.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMHTMLTableCellCellAbove.mm; sourceTree = "<group>"; };
 		37E1064B169767F700B78BD0 /* DOMHTMLTableCellElementCellAbove.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DOMHTMLTableCellElementCellAbove.html; sourceTree = "<group>"; };
 		37E38C33169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewDidRemoveFrameFromHierarchy.mm; sourceTree = "<group>"; };
+		3F1B52681D3D7129008D60C4 /* FullscreenLayoutConstraints.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenLayoutConstraints.mm; sourceTree = "<group>"; };
+		3FBD1B491D39D1DB00E6D6FA /* FullscreenLayoutConstraints.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FullscreenLayoutConstraints.html; sourceTree = "<group>"; };
 		41973B5A1AF2286A006C7B36 /* FileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystem.cpp; sourceTree = "<group>"; };
 		41973B5C1AF22875006C7B36 /* SharedBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedBuffer.cpp; sourceTree = "<group>"; };
 		440A1D3814A0103A008A66F2 /* URL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URL.cpp; sourceTree = "<group>"; };
@@ -1212,6 +1216,7 @@
 				A1A4FE5D18DD3DB700B5EA8A /* Download.mm */,
 				2D8104CB1BEC13E70020DA46 /* FindInPage.mm */,
 				2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */,
+				3F1B52681D3D7129008D60C4 /* FullscreenLayoutConstraints.mm */,
 				CDE195B31CFE0ADE0053D256 /* FullscreenTopContentInset.mm */,
 				51A587841D272EF3004BA9AF /* IndexedDBDatabaseProcessKill.mm */,
 				510477751D298E03009747EB /* IDBDeleteRecovery.mm */,
@@ -1329,6 +1334,7 @@
 				5714ECBA1CA8BFD100051AC8 /* DownloadRequestOriginalURLFrame.html */,
 				9984FACD1CFFB038008D198C /* editable-body.html */,
 				93575C551D30366E000D604D /* focus-inputs.html */,
+				3FBD1B491D39D1DB00E6D6FA /* FullscreenLayoutConstraints.html */,
 				CDE195B21CFE0ADE0053D256 /* FullscreenTopContentInset.html */,
 				510477761D298E57009747EB /* IDBDeleteRecovery.html */,
 				5104776F1D298D85009747EB /* IDBDeleteRecovery.sqlite3 */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenLayoutConstraints.html (0 => 203478)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenLayoutConstraints.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenLayoutConstraints.html	2016-07-20 23:24:15 UTC (rev 203478)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script>
+        function load() {
+            window.webkit.messageHandlers.fullscreenStateChangeHandler.postMessage('load');
+        }
+        document.addEventListener('webkitfullscreenchange', function(event) {
+            window.webkit.messageHandlers.fullscreenStateChangeHandler.postMessage('fullscreenchange');
+        });
+        document.addEventListener('mousedown', function(event) {
+            // Toggle fullscreen
+            var target = document.getElementById('target');
+            if (document.webkitFullscreenElement == target)
+                document.webkitExitFullscreen();
+            else
+                target.webkitRequestFullScreen();
+        });
+    </script>
+    <style>
+    #target {
+        background-color: red;
+        width: 150px;
+        height: 150px;
+    }
+    </style>
+</head>
+<body _onload_="load()">
+    <div id="target"></div>
+</body>
+</html>

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenLayoutConstraints.mm (0 => 203478)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenLayoutConstraints.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenLayoutConstraints.mm	2016-07-20 23:24:15 UTC (rev 203478)
@@ -0,0 +1,95 @@
+/*
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#include "config.h"
+
+#if WK_API_ENABLED && PLATFORM(MAC)
+
+#import "PlatformUtilities.h"
+#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+static bool receivedLoadedMessage;
+static bool receivedFullscreenChangeMessage;
+
+@interface FullscreenStateChangeMessageHandler : NSObject <WKScriptMessageHandler>
+@end
+
+@implementation FullscreenStateChangeMessageHandler
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+    NSString *bodyString = (NSString *)[message body];
+    if ([bodyString isEqualToString:@"fullscreenchange"])
+        receivedFullscreenChangeMessage = true;
+    else if ([bodyString isEqualToString:@"load"])
+        receivedLoadedMessage = true;
+}
+@end
+
+namespace TestWebKitAPI {
+
+TEST(Fullscreen, LayoutConstraints)
+{
+    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
+    [configuration preferences]._fullScreenEnabled = YES;
+    RetainPtr<FullscreenStateChangeMessageHandler> handler = adoptNS([[FullscreenStateChangeMessageHandler alloc] init]);
+    [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"fullscreenStateChangeHandler"];
+
+    RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
+    webView.get().translatesAutoresizingMaskIntoConstraints = NO;
+    [[window contentView] addSubview:webView.get()];
+    
+    [[window contentView] addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-0-[webView]-0-|" options:0 metrics:nil views:@{@"webView" : webView.get()}]];
+
+    [[window contentView] addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[webView]-0-|" options:0 metrics:nil views:@{@"webView" : webView.get()}]];
+    
+    NSArray* originalConstraints = [[window contentView] constraints];
+    
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"FullscreenLayoutConstraints" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    [webView loadRequest:request];
+    TestWebKitAPI::Util::run(&receivedLoadedMessage);
+
+    NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseDown location:NSMakePoint(5, 5) modifierFlags:0 timestamp:0 windowNumber:window.get().windowNumber context:0 eventNumber:0 clickCount:0 pressure:0];
+    [webView mouseDown:event];
+
+    TestWebKitAPI::Util::run(&receivedFullscreenChangeMessage);
+    
+    receivedFullscreenChangeMessage = false;
+    
+    NSEvent *exitFSEvent = [NSEvent mouseEventWithType:NSLeftMouseDown location:NSMakePoint(5, 5) modifierFlags:0 timestamp:0 windowNumber:window.get().windowNumber context:0 eventNumber:0 clickCount:0 pressure:0];
+    [webView mouseDown:exitFSEvent];
+    
+    TestWebKitAPI::Util::run(&receivedFullscreenChangeMessage);
+
+    NSArray* finalConstraints = [[window contentView] constraints];
+    ASSERT_TRUE([originalConstraints isEqual:finalConstraints]);
+}
+    
+} // namespace TestWebKitAPI
+
+#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to