Title: [204565] trunk
Revision
204565
Author
[email protected]
Date
2016-08-17 12:19:05 -0700 (Wed, 17 Aug 2016)

Log Message

[Cocoa] -[NSString isEqualToString:] returns NO for any WKNSString argument
https://bugs.webkit.org/show_bug.cgi?id=160938
<rdar://problem/27876652>

Reviewed by Anders Carlsson.

Source/WebKit2:

-[NSString isEqualToString:] calls an internal NSObject method on its argument, which
NSString subclasses override to return YES, but WKObject does not override and does not
forward to its target NSString.

To fix this issue and other similar issues, we make WKObject a root class instead of an
NSObject subclass.

Test: TestWebKitAPI/Tests/WebKit2Cocoa/WKObject.mm

* Platform/spi/Cocoa/objcSPI.h: Added.

* Shared/Cocoa/WKObject.h: Make WKObject a root class instead of inhereting from NSObject.

* Shared/Cocoa/WKObject.mm:
(+[WKObject class]): Return self.
(-[WKObject allowsWeakReference]): Added. Called by the Objective-C runtime.
(-[WKObject retainWeakReference]): Ditto.
(-[WKObject hash]): If we don’t have a target, return our address.
(-[WKObject superclass]): Implement this NSObject protocol method.
(-[WKObject class]): Ditto.
(-[WKObject self]): Ditto.
(-[WKObject performSelector:]): Ditto.
(-[WKObject performSelector:withObject:]): Ditto.
(-[WKObject performSelector:withObject:withObject:]): Ditto.
(-[WKObject isProxy]): Ditto.
(-[WKObject respondsToSelector:]): Changed to not call super.
(-[WKObject conformsToProtocol:]): Ditto.
(-[WKObject description]): Ditto.
(-[WKObject retain]): Implement this NSObject protocol method.
(-[WKObject release]): Ditto.
(-[WKObject autorelease]): Ditto.
(-[WKObject retainCount]): Ditto.
(-[WKObject zone]): Ditto.
(-[WKObject dealloc]): Deleted.
(-[WKObject classForCoder]): Deleted.
(-[WKObject classForKeyedArchiver]): Deleted.
(-[WKObject _cfTypeID]): Deleted.

* WebKit2.xcodeproj/project.pbxproj: Added reference to new file.

Tools:

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

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (204564 => 204565)


--- trunk/Source/WebKit2/ChangeLog	2016-08-17 18:15:58 UTC (rev 204564)
+++ trunk/Source/WebKit2/ChangeLog	2016-08-17 19:19:05 UTC (rev 204565)
@@ -1,3 +1,51 @@
+2016-08-17  Dan Bernstein  <[email protected]>
+
+        [Cocoa] -[NSString isEqualToString:] returns NO for any WKNSString argument
+        https://bugs.webkit.org/show_bug.cgi?id=160938
+        <rdar://problem/27876652>
+
+        Reviewed by Anders Carlsson.
+
+        -[NSString isEqualToString:] calls an internal NSObject method on its argument, which
+        NSString subclasses override to return YES, but WKObject does not override and does not
+        forward to its target NSString.
+
+        To fix this issue and other similar issues, we make WKObject a root class instead of an
+        NSObject subclass.
+
+        Test: TestWebKitAPI/Tests/WebKit2Cocoa/WKObject.mm
+
+        * Platform/spi/Cocoa/objcSPI.h: Added.
+
+        * Shared/Cocoa/WKObject.h: Make WKObject a root class instead of inhereting from NSObject.
+
+        * Shared/Cocoa/WKObject.mm:
+        (+[WKObject class]): Return self.
+        (-[WKObject allowsWeakReference]): Added. Called by the Objective-C runtime.
+        (-[WKObject retainWeakReference]): Ditto.
+        (-[WKObject hash]): If we don’t have a target, return our address.
+        (-[WKObject superclass]): Implement this NSObject protocol method.
+        (-[WKObject class]): Ditto.
+        (-[WKObject self]): Ditto.
+        (-[WKObject performSelector:]): Ditto.
+        (-[WKObject performSelector:withObject:]): Ditto.
+        (-[WKObject performSelector:withObject:withObject:]): Ditto.
+        (-[WKObject isProxy]): Ditto.
+        (-[WKObject respondsToSelector:]): Changed to not call super.
+        (-[WKObject conformsToProtocol:]): Ditto.
+        (-[WKObject description]): Ditto.
+        (-[WKObject retain]): Implement this NSObject protocol method.
+        (-[WKObject release]): Ditto.
+        (-[WKObject autorelease]): Ditto.
+        (-[WKObject retainCount]): Ditto.
+        (-[WKObject zone]): Ditto.
+        (-[WKObject dealloc]): Deleted.
+        (-[WKObject classForCoder]): Deleted.
+        (-[WKObject classForKeyedArchiver]): Deleted.
+        (-[WKObject _cfTypeID]): Deleted.
+
+        * WebKit2.xcodeproj/project.pbxproj: Added reference to new file.
+
 2016-08-17  Hunseop Jeong  <[email protected]>
 
         [EFL] Fix test_ewk2_view after r203612 

Added: trunk/Source/WebKit2/Platform/spi/Cocoa/objcSPI.h (0 => 204565)


--- trunk/Source/WebKit2/Platform/spi/Cocoa/objcSPI.h	                        (rev 0)
+++ trunk/Source/WebKit2/Platform/spi/Cocoa/objcSPI.h	2016-08-17 19:19:05 UTC (rev 204565)
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <objc/objc-internal.h>
+
+#endif
+
+OBJC_EXPORT id _objc_rootRetain(id obj);
+OBJC_EXPORT bool _objc_rootReleaseWasZero(id obj);
+OBJC_EXPORT bool _objc_rootTryRetain(id obj);
+OBJC_EXPORT bool _objc_rootIsDeallocating(id obj);
+OBJC_EXPORT id _objc_rootAutorelease(id obj);
+OBJC_EXPORT uintptr_t _objc_rootRetainCount(id obj);
+OBJC_EXPORT void _objc_rootDealloc(id obj);

Modified: trunk/Source/WebKit2/Shared/Cocoa/WKObject.h (204564 => 204565)


--- trunk/Source/WebKit2/Shared/Cocoa/WKObject.h	2016-08-17 18:15:58 UTC (rev 204564)
+++ trunk/Source/WebKit2/Shared/Cocoa/WKObject.h	2016-08-17 19:19:05 UTC (rev 204565)
@@ -52,7 +52,8 @@
 
 @end
 
-@interface WKObject : NSObject <WKObject>
+NS_ROOT_CLASS
+@interface WKObject <WKObject>
 
 - (NSObject *)_web_createTarget NS_RETURNS_RETAINED;
 

Modified: trunk/Source/WebKit2/Shared/Cocoa/WKObject.mm (204564 => 204565)


--- trunk/Source/WebKit2/Shared/Cocoa/WKObject.mm	2016-08-17 18:15:58 UTC (rev 204564)
+++ trunk/Source/WebKit2/Shared/Cocoa/WKObject.mm	2016-08-17 19:19:05 UTC (rev 204565)
@@ -29,22 +29,18 @@
 #if WK_API_ENABLED
 
 #import "APIObject.h"
+#import "objcSPI.h"
+#import <wtf/ObjcRuntimeExtras.h>
 
-@interface NSObject ()
-- (CFTypeID)_cfTypeID;
-@end
-
 @implementation WKObject {
+    Class _isa;
     BOOL _hasInitializedTarget;
     NSObject *_target;
 }
 
-- (void)dealloc
++ (Class)class
 {
-    static_cast<API::Object*>(object_getIndexedIvars(self))->~Object();
-    [_target release];
-
-    [super dealloc];
+    return self;
 }
 
 static inline void initializeTargetIfNeeded(WKObject *self)
@@ -56,6 +52,27 @@
     self->_target = [self _web_createTarget];
 }
 
+// MARK: Methods used by the Objective-C runtime
+
+- (id)forwardingTargetForSelector:(SEL)selector
+{
+    initializeTargetIfNeeded(self);
+
+    return _target;
+}
+
+- (BOOL)allowsWeakReference
+{
+    return !_objc_rootIsDeallocating(self);
+}
+
+- (BOOL)retainWeakReference
+{
+    return _objc_rootTryRetain(self);
+}
+
+// MARK: NSObject protocol implementation
+
 - (BOOL)isEqual:(id)object
 {
     if (object == self)
@@ -73,9 +90,48 @@
 {
     initializeTargetIfNeeded(self);
 
-    return _target ? [_target hash] : [super hash];
+    return _target ? [_target hash] : reinterpret_cast<NSUInteger>(self);
 }
 
+- (Class)superclass
+{
+    initializeTargetIfNeeded(self);
+
+    return _target ? [_target superclass] : class_getSuperclass(object_getClass(self));
+}
+
+- (Class)class
+{
+    initializeTargetIfNeeded(self);
+
+    return _target ? [_target class] : object_getClass(self);
+}
+
+- (instancetype)self
+{
+    return self;
+}
+
+- (id)performSelector:(SEL)selector
+{
+    return selector ? wtfObjcMsgSend<id>(self, selector) : nil;
+}
+
+- (id)performSelector:(SEL)selector withObject:(id)object
+{
+    return selector ? wtfObjcMsgSend<id>(self, selector, object) : nil;
+}
+
+- (id)performSelector:(SEL)selector withObject:(id)object1 withObject:(id)object2
+{
+    return selector ? wtfObjcMsgSend<id>(self, selector, object1, object2) : nil;
+}
+
+- (BOOL)isProxy
+{
+    return NO;
+}
+
 - (BOOL)isKindOfClass:(Class)aClass
 {
     initializeTargetIfNeeded(self);
@@ -94,7 +150,7 @@
 {
     initializeTargetIfNeeded(self);
 
-    return [_target respondsToSelector:selector] || [super respondsToSelector:selector];
+    return [_target respondsToSelector:selector] || (selector && class_respondsToSelector(object_getClass(self), selector));
 }
 
 - (BOOL)conformsToProtocol:(Protocol *)protocol
@@ -101,14 +157,18 @@
 {
     initializeTargetIfNeeded(self);
 
-    return [_target conformsToProtocol:protocol] || [super conformsToProtocol:protocol];
-}
+    if ([_target conformsToProtocol:protocol])
+        return YES;
 
-- (id)forwardingTargetForSelector:(SEL)selector
-{
-    initializeTargetIfNeeded(self);
+    if (!protocol)
+        return NO;
 
-    return _target;
+    for (Class cls = object_getClass(self); cls; cls = class_getSuperclass(cls)) {
+        if (class_conformsToProtocol(cls, protocol))
+            return YES;
+    }
+
+    return NO;
 }
 
 - (NSString *)description
@@ -115,26 +175,36 @@
 {
     initializeTargetIfNeeded(self);
 
-    return _target ? [_target description] : [super description];
+    return _target ? [_target description] : [NSString stringWithFormat:@"<%s %p>", class_getName(object_getClass(self)), self];
 }
 
-- (Class)classForCoder
+- (instancetype)retain
 {
-    initializeTargetIfNeeded(self);
+    return _objc_rootRetain(self);
+}
 
-    return [_target classForCoder];
+- (oneway void)release
+{
+    if (_objc_rootReleaseWasZero(self)) {
+        static_cast<API::Object*>(object_getIndexedIvars(self))->~Object();
+        [_target release];
+        _objc_rootDealloc(self);
+    }
 }
 
-- (Class)classForKeyedArchiver
+- (instancetype)autorelease
 {
-    initializeTargetIfNeeded(self);
+    return _objc_rootAutorelease(self);
+}
 
-    return [_target classForKeyedArchiver];
+- (NSUInteger)retainCount
+{
+    return _objc_rootRetainCount(self);
 }
 
-- (CFTypeID)_cfTypeID
+- (NSZone *)zone
 {
-    return _target ? [_target _cfTypeID] : [super _cfTypeID];
+    return NSDefaultMallocZone();
 }
 
 - (NSObject *)_web_createTarget

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (204564 => 204565)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2016-08-17 18:15:58 UTC (rev 204564)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2016-08-17 19:19:05 UTC (rev 204565)
@@ -832,6 +832,7 @@
 		37B0D1841C1E499A00D40D64 /* PluginProcessShim.dylib in Copy Shims */ = {isa = PBXBuildFile; fileRef = 1AC25FB012A48EA700BD2671 /* PluginProcessShim.dylib */; };
 		37B0D1851C1E499A00D40D64 /* SecItemShim.dylib in Copy Shims */ = {isa = PBXBuildFile; fileRef = 510031F61379CACB00C8DFE4 /* SecItemShim.dylib */; };
 		37B0D1861C1E499A00D40D64 /* WebProcessShim.dylib in Copy Shims */ = {isa = PBXBuildFile; fileRef = CDC3830617211799008A2FC3 /* WebProcessShim.dylib */; };
+		37B47E2D1D64DB76005F4EFF /* objcSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 37B47E2C1D64DB76005F4EFF /* objcSPI.h */; };
 		37B5045219EEF31300CE2CF8 /* WKErrorPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 37B5045119EEF31300CE2CF8 /* WKErrorPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		37BEC4DD1948FC6A008B4286 /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1C79A100E7FC50078DEBC /* WebCore.framework */; };
 		37BEC4E019491486008B4286 /* CompletionHandlerCallChecker.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37BEC4DE19491486008B4286 /* CompletionHandlerCallChecker.mm */; };
@@ -2870,6 +2871,7 @@
 		37A64E5418F38E3C00EB30F1 /* _WKInputDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInputDelegate.h; sourceTree = "<group>"; };
 		37A64E5618F38F4600EB30F1 /* _WKFormInputSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKFormInputSession.h; sourceTree = "<group>"; };
 		37B418EB1C9624F20031E63B /* WebContent-OSX.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "WebContent-OSX.entitlements"; sourceTree = "<group>"; };
+		37B47E2C1D64DB76005F4EFF /* objcSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = objcSPI.h; sourceTree = "<group>"; };
 		37B5045119EEF31300CE2CF8 /* WKErrorPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKErrorPrivate.h; sourceTree = "<group>"; };
 		37BEC4DE19491486008B4286 /* CompletionHandlerCallChecker.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CompletionHandlerCallChecker.mm; sourceTree = "<group>"; };
 		37BEC4DF19491486008B4286 /* CompletionHandlerCallChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompletionHandlerCallChecker.h; sourceTree = "<group>"; };
@@ -5115,6 +5117,7 @@
 			children = (
 				1A5705101BE410E500874AF1 /* BlockSPI.h */,
 				3754D5441B3A29FD003A4C7F /* NSInvocationSPI.h */,
+				37B47E2C1D64DB76005F4EFF /* objcSPI.h */,
 			);
 			path = Cocoa;
 			sourceTree = "<group>";
@@ -7822,6 +7825,7 @@
 				2684054418B85A630022C38B /* VisibleContentRectUpdateInfo.h in Headers */,
 				1A0F29E4120B44420053D1B9 /* VisitedLinkStore.h in Headers */,
 				1A60224D18C16B9F00C3E8C9 /* VisitedLinkStoreMessages.h in Headers */,
+				37B47E2D1D64DB76005F4EFF /* objcSPI.h in Headers */,
 				1A0F29CC120B37160053D1B9 /* VisitedLinkTable.h in Headers */,
 				1AF4CEF018BC481800BC2D34 /* VisitedLinkTableController.h in Headers */,
 				1A8E7D3D18C15149005A702A /* VisitedLinkTableControllerMessages.h in Headers */,

Modified: trunk/Tools/ChangeLog (204564 => 204565)


--- trunk/Tools/ChangeLog	2016-08-17 18:15:58 UTC (rev 204564)
+++ trunk/Tools/ChangeLog	2016-08-17 19:19:05 UTC (rev 204565)
@@ -1,3 +1,15 @@
+2016-08-17  Dan Bernstein  <[email protected]>
+
+        [Cocoa] -[NSString isEqualToString:] returns NO for any WKNSString argument
+        https://bugs.webkit.org/show_bug.cgi?id=160938
+        <rdar://problem/27876652>
+
+        Reviewed by Anders Carlsson.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/WKObject.mm: Added.
+        (TestWebKitAPI::TEST):
+
 2016-08-17  Chris Fleizach  <[email protected]>
 
         AX: Support abbreviations in iOS

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (204564 => 204565)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2016-08-17 18:15:58 UTC (rev 204564)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2016-08-17 19:19:05 UTC (rev 204565)
@@ -70,6 +70,7 @@
 		378E64771632655E00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378E64751632655D00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp */; };
 		378E64791632707400B6C676 /* link-with-title.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 378E647816326FDF00B6C676 /* link-with-title.html */; };
 		379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 379028B814FABE49007E6B43 /* acceptsFirstMouse.html */; };
+		37B47E301D64E7CA005F4EFF /* WKObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37B47E2E1D64E7CA005F4EFF /* WKObject.mm */; };
 		37BCA61C1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37BCA61B1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm */; };
 		37D36ED71AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */; };
 		37DC6791140D7D7600ABCCDB /* DOMRangeOfString.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */; };
@@ -750,6 +751,7 @@
 		379028B814FABE49007E6B43 /* acceptsFirstMouse.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = acceptsFirstMouse.html; sourceTree = "<group>"; };
 		3799AD3914120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringByEvaluatingJavaScriptFromString.mm; sourceTree = "<group>"; };
 		37A6895D148A9B50005100FA /* SubresourceErrorCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SubresourceErrorCrash.mm; sourceTree = "<group>"; };
+		37B47E2E1D64E7CA005F4EFF /* WKObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKObject.mm; sourceTree = "<group>"; };
 		37BCA61B1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ShouldOpenExternalURLsInNewWindowActions.mm; sourceTree = "<group>"; };
 		37C784DE197C8F2E0010A496 /* RenderedImageFromDOMNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderedImageFromDOMNode.mm; sourceTree = "<group>"; };
 		37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadAlternateHTMLString.mm; sourceTree = "<group>"; };
@@ -1297,6 +1299,7 @@
 				93E943F11CD3E87E00AC08C2 /* VideoControlsManager.mm */,
 				51714EB61CF8C7A4004723C4 /* WebProcessKillIDBCleanup.mm */,
 				1F83571A1D3FFB0E00E3967B /* WKBackForwardList.mm */,
+				37B47E2E1D64E7CA005F4EFF /* WKObject.mm */,
 				2D00065D1C1F58940088E6A7 /* WKPDFViewResizeCrash.mm */,
 				5E4B1D2C1D404C6100053621 /* WKScrollViewDelegateCrash.mm */,
 				7C417F311D19E14800B8EF53 /* WKWebViewDefaultNavigationDelegate.mm */,
@@ -2213,6 +2216,7 @@
 				7C83E0401D0A63E300FEBCF3 /* FirstResponderScrollingPosition.mm in Sources */,
 				7C83E0BC1D0A650700FEBCF3 /* FixedLayoutSize.mm in Sources */,
 				7CCE7EF51A411AE600447C4C /* ForceRepaint.cpp in Sources */,
+				37B47E301D64E7CA005F4EFF /* WKObject.mm in Sources */,
 				7CCE7EC01A411A7E00447C4C /* FragmentNavigation.mm in Sources */,
 				7CCE7EF61A411AE600447C4C /* FrameMIMETypeHTML.cpp in Sources */,
 				7CCE7EF71A411AE600447C4C /* FrameMIMETypePNG.cpp in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKObject.mm (0 => 204565)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKObject.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKObject.mm	2016-08-17 19:19:05 UTC (rev 204565)
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+#import "config.h"
+
+#import <WebKit/WKFoundation.h>
+
+#if WK_API_ENABLED && WK_HAVE_C_SPI
+
+#import <WebKit/WKString.h>
+#import <objc/runtime.h>
+
+namespace TestWebKitAPI {
+
+TEST(WebKit2, WKObject)
+{
+    WKStringRef stringRef = WKStringCreateWithUTF8CString("just testing");
+    ASSERT_TRUE([@"just testing" isEqualToString:(NSString *)stringRef]);
+
+    NSString *weakString = nil;
+
+    objc_storeWeak(&weakString, (NSString *)stringRef);
+    ASSERT_NE((id)0, weakString);
+
+    WKRelease(stringRef);
+    ASSERT_EQ((id)0, weakString);
+}
+
+} // namespace TestWebKitAPI
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to