[Cocoa] WKRemoteObjectInterface fails with doubles, NSNull, and empty NSStrings
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Feb 2014 21:21:49 +0000 (21:21 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Feb 2014 21:21:49 +0000 (21:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=128268

Reviewed by Anders Carlsson.

* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
(-[WKRemoteObjectDecoder decodeBytesForKey:returnedLength:]): When returning nullptr, also
set the length out parameter to 0.

* Shared/API/Cocoa/WKRemoteObjectInterface.mm:
(propertyListClasses): Added NSNull.

* Shared/UserData.cpp:
(WebKit::UserData::encode): Encode the Double type.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm
Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectInterface.mm
Source/WebKit2/Shared/UserData.cpp

index 23bc27c..7630153 100644 (file)
@@ -1,3 +1,20 @@
+2014-02-05  Dan Bernstein  <mitz@apple.com>
+
+        [Cocoa] WKRemoteObjectInterface fails with doubles, NSNull, and empty NSStrings
+        https://bugs.webkit.org/show_bug.cgi?id=128268
+
+        Reviewed by Anders Carlsson.
+
+        * Shared/API/Cocoa/WKRemoteObjectCoder.mm:
+        (-[WKRemoteObjectDecoder decodeBytesForKey:returnedLength:]): When returning nullptr, also
+        set the length out parameter to 0.
+
+        * Shared/API/Cocoa/WKRemoteObjectInterface.mm:
+        (propertyListClasses): Added NSNull.
+
+        * Shared/UserData.cpp:
+        (WebKit::UserData::encode): Encode the Double type.
+
 2014-02-05  Jer Noble  <jer.noble@apple.com>
 
         [WK2] [iOS] No video on embedded YouTube
index 95725eb..dfd7211 100644 (file)
@@ -554,8 +554,10 @@ static id decodeObject(WKRemoteObjectDecoder *decoder, const ImmutableDictionary
 - (const uint8_t *)decodeBytesForKey:(NSString *)key returnedLength:(NSUInteger *)length
 {
     auto* data = _currentDictionary->get<API::Data>(escapeKey(key));
-    if (!data || !data->size())
+    if (!data || !data->size()) {
+        *length = 0;
         return nullptr;
+    }
 
     *length = data->size();
     return data->bytes();
index 350d117..21e196c 100644 (file)
@@ -55,7 +55,7 @@ static bool isContainerClass(Class objectClass)
 static NSSet *propertyListClasses()
 {
     // FIXME: Add more property list classes if needed.
-    static NSSet *propertyListClasses = [[NSSet alloc] initWithObjects:[NSArray class], [NSDictionary class], [NSNumber class], [NSString class], nil];
+    static NSSet *propertyListClasses = [[NSSet alloc] initWithObjects:[NSArray class], [NSDictionary class], [NSNull class], [NSNumber class], [NSString class], nil];
 
     return propertyListClasses;
 }
index 5e78b09..7c5dba6 100644 (file)
@@ -138,6 +138,10 @@ void UserData::encode(IPC::ArgumentEncoder& encoder, const API::Object& object)
         break;
     }
 
+    case API::Object::Type::Double:
+        static_cast<const API::Double&>(object).encode(encoder);
+        break;
+
     case API::Object::Type::Error:
         static_cast<const API::Error&>(object).encode(encoder);
         break;