Title: [220542] trunk
Revision
220542
Author
bb...@apple.com
Date
2017-08-10 13:34:40 -0700 (Thu, 10 Aug 2017)

Log Message

WKPreferences should conform to NSCopying
https://bugs.webkit.org/show_bug.cgi?id=175303
<rdar://problem/33764939>

Reviewed by Dan Bernstein.

Source/WebKit:

* UIProcess/API/Cocoa/WKPreferencesPrivate.h:
Add conformance in the private header, as there is not consensus that this
needs to be API.

* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences copyWithZone:]):
Copy the wrapped WebPreferences instance and return its wrapper.

Tools:

Add unit test to make sure a WKPreference and its copy are
not aliased to each other or affect each other's properties.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/Copying.mm: Added.
(TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (220541 => 220542)


--- trunk/Source/WebKit/ChangeLog	2017-08-10 19:39:28 UTC (rev 220541)
+++ trunk/Source/WebKit/ChangeLog	2017-08-10 20:34:40 UTC (rev 220542)
@@ -1,3 +1,19 @@
+2017-08-10  Brian Burg  <bb...@apple.com>
+
+        WKPreferences should conform to NSCopying
+        https://bugs.webkit.org/show_bug.cgi?id=175303
+        <rdar://problem/33764939>
+
+        Reviewed by Dan Bernstein.
+
+        * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
+        Add conformance in the private header, as there is not consensus that this
+        needs to be API.
+
+        * UIProcess/API/Cocoa/WKPreferences.mm:
+        (-[WKPreferences copyWithZone:]):
+        Copy the wrapped WebPreferences instance and return its wrapper.
+
 2017-08-10  Michael Catanzaro  <mcatanz...@igalia.com>
 
         REGRESSION(r220515) [GTK][CMake] Build with ENABLE_GEOLOCATION fails on Debian Jessie

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm (220541 => 220542)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm	2017-08-10 19:39:28 UTC (rev 220541)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm	2017-08-10 20:34:40 UTC (rev 220542)
@@ -88,6 +88,11 @@
     return self;
 }
 
+- (id)copyWithZone:(NSZone *)zone
+{
+    return wrapper(_preferences->copy().leakRef());
+}
+
 - (CGFloat)minimumFontSize
 {
     return _preferences->minimumFontSize();

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h (220541 => 220542)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h	2017-08-10 19:39:28 UTC (rev 220541)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h	2017-08-10 20:34:40 UTC (rev 220542)
@@ -48,6 +48,9 @@
 
 @class _WKExperimentalFeature;
 
+@interface WKPreferences () <NSCopying>
+@end
+
 @interface WKPreferences (WKPrivate)
 
 // FIXME: This property should not have the verb "is" in it.

Modified: trunk/Tools/ChangeLog (220541 => 220542)


--- trunk/Tools/ChangeLog	2017-08-10 19:39:28 UTC (rev 220541)
+++ trunk/Tools/ChangeLog	2017-08-10 20:34:40 UTC (rev 220542)
@@ -1,3 +1,18 @@
+2017-08-10  Brian Burg  <bb...@apple.com>
+
+        WKPreferences should conform to NSCopying
+        https://bugs.webkit.org/show_bug.cgi?id=175303
+        <rdar://problem/33764939>
+
+        Reviewed by Dan Bernstein.
+
+        Add unit test to make sure a WKPreference and its copy are
+        not aliased to each other or affect each other's properties.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/Copying.mm: Added.
+        (TEST):
+
 2017-08-10  Tim Horton  <timothy_hor...@apple.com>
 
         Remove some unused lambda captures so that WebKit builds with -Wunused-lambda-capture

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (220541 => 220542)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-08-10 19:39:28 UTC (rev 220541)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-08-10 20:34:40 UTC (rev 220542)
@@ -523,6 +523,7 @@
 		95646E5B1F1DB60E00DE0EB9 /* InspectorValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 953F47911F1DB40300E3D1E3 /* InspectorValue.cpp */; };
 		9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9984FACA1CFFAEEE008D198C /* WKWebViewTextInput.mm */; };
 		9984FACE1CFFB090008D198C /* editable-body.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9984FACD1CFFB038008D198C /* editable-body.html */; };
+		9999108B1F393C96008AD455 /* Copying.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9999108A1F393C8B008AD455 /* Copying.mm */; };
 		9B0786A51C5885C300D159E3 /* InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp */; };
 		9B19CDA01F06DFE3000548DD /* NetworkProcessCrashWithPendingConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B19CD9E1F06DFE3000548DD /* NetworkProcessCrashWithPendingConnection.mm */; };
 		9B26FCCA159D16DE00CC3765 /* HTMLFormCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */; };
@@ -1429,6 +1430,7 @@
 		953F47911F1DB40300E3D1E3 /* InspectorValue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorValue.cpp; sourceTree = "<group>"; };
 		9984FACA1CFFAEEE008D198C /* WKWebViewTextInput.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewTextInput.mm; sourceTree = "<group>"; };
 		9984FACD1CFFB038008D198C /* editable-body.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "editable-body.html"; sourceTree = "<group>"; };
+		9999108A1F393C8B008AD455 /* Copying.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Copying.mm; sourceTree = "<group>"; };
 		9B0786A21C58830F00D159E3 /* InjectedBundleMakeAllShadowRootsOpen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleMakeAllShadowRootsOpen.cpp; sourceTree = "<group>"; };
 		9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp; sourceTree = "<group>"; };
 		9B19CD9E1F06DFE3000548DD /* NetworkProcessCrashWithPendingConnection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NetworkProcessCrashWithPendingConnection.mm; path = WebKit2/NetworkProcessCrashWithPendingConnection.mm; sourceTree = "<group>"; };
@@ -1876,6 +1878,7 @@
 				A14FC5861B8991B600D107EB /* ContentFiltering.mm */,
 				A14FC5891B89927100D107EB /* ContentFilteringPlugIn.mm */,
 				5C2936911D5BF63E00DEAB1E /* CookieAcceptPolicy.mm */,
+				9999108A1F393C8B008AD455 /* Copying.mm */,
 				2DC4CF761D2D9DD800ECCC94 /* DataDetection.mm */,
 				CEC16EA41EE863BF00DE479A /* DecidePolicyForNavigationAction.mm */,
 				2DC60E221E79F88C00FA6C7D /* DoAfterNextPresentationUpdateAfterCrash.mm */,
@@ -3315,6 +3318,7 @@
 				51DB16CE1F085137001FA4C5 /* WebViewIconLoading.mm in Sources */,
 				7CCE7F1B1A411AE600447C4C /* WillLoad.cpp in Sources */,
 				7CCE7ED71A411A7E00447C4C /* WillPerformClientRedirectToURLCrash.mm in Sources */,
+				9999108B1F393C96008AD455 /* Copying.mm in Sources */,
 				7CCE7F1C1A411AE600447C4C /* WillSendSubmitEvent.cpp in Sources */,
 				7CCE7ED81A411A7E00447C4C /* WillSendSubmitEvent.mm in Sources */,
 				7CCE7ED91A411A7E00447C4C /* WindowlessWebViewWithMedia.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Copying.mm (0 => 220542)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Copying.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Copying.mm	2017-08-10 20:34:40 UTC (rev 220542)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#import "config.h"
+
+#if WK_API_ENABLED
+
+#import <wtf/RetainPtr.h>
+
+TEST(Copying, WKPreferences)
+{
+    // Change all defaults to something else.
+    RetainPtr<WKPreferences> a = adoptNS([[WKPreferences alloc] init]);
+    [a setMinimumFontSize:10];
+    [a setJavaScriptEnabled:NO];
+#if PLATFORM(IOS)
+    [a setJavaScriptCanOpenWindowsAutomatically:YES];
+#else
+    [a setJavaScriptCanOpenWindowsAutomatically:NO];
+    [a setJavaEnabled:YES];
+    [a setPlugInsEnabled:YES];
+    [a setTabFocusesLinks:YES];
+#endif
+
+    // Check that values are equal in both instances.
+    RetainPtr<WKPreferences> b = adoptNS([a copy]);
+    EXPECT_EQ([a minimumFontSize], [b minimumFontSize]);
+    EXPECT_EQ([a _javascript_Enabled], [b _javascript_Enabled]);
+    EXPECT_EQ([a _javascript_CanOpenWindowsAutomatically], [b _javascript_CanOpenWindowsAutomatically]);
+#if PLATFORM(MAC)
+    EXPECT_EQ([a javaEnabled], [b javaEnabled]);
+    EXPECT_EQ([a plugInsEnabled], [b plugInsEnabled]);
+    EXPECT_EQ([a tabFocusesLinks], [b tabFocusesLinks]);
+#endif
+
+    // Change all defaults on the copied instance.
+    [b setMinimumFontSize:13];
+    [b setJavaScriptEnabled:YES];
+#if PLATFORM(IOS)
+    [b setJavaScriptCanOpenWindowsAutomatically:NO];
+#else
+    [b setJavaScriptCanOpenWindowsAutomatically:YES];
+    [b setJavaEnabled:NO];
+    [b setPlugInsEnabled:NO];
+    [b setTabFocusesLinks:NO];
+#endif
+
+    // Check that the mutations of 'b' did not affect 'a'.
+    EXPECT_NE([a minimumFontSize], [b minimumFontSize]);
+    EXPECT_NE([a _javascript_Enabled], [b _javascript_Enabled]);
+    EXPECT_NE([a _javascript_CanOpenWindowsAutomatically], [b _javascript_CanOpenWindowsAutomatically]);
+#if PLATFORM(MAC)
+    EXPECT_NE([a javaEnabled], [b javaEnabled]);
+    EXPECT_NE([a plugInsEnabled], [b plugInsEnabled]);
+    EXPECT_NE([a tabFocusesLinks], [b tabFocusesLinks]);
+#endif
+
+}
+
+#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to