REGRESSION(r217051): Automation sessions fail to complete bootstrap
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 May 2017 00:01:41 +0000 (00:01 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 May 2017 00:01:41 +0000 (00:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172513
<rdar://problem/32338354>

Reviewed by Joseph Pecoraro.

The changes to be more strict about typechecking messages were too strict.

* inspector/remote/cocoa/RemoteInspectorCocoa.mm:
(Inspector::RemoteInspector::receivedSetupMessage):
WIRAutomatically is an optional key in the setup message. In the relay, this key gets copied
into an NSDictionary as NSNull if the key isn't present in a forwarded command.
We need to revert NSNull values to nil, since it's valid to call [nil boolValue] but not
[[NSNull null] boolValue]. We also need to allow for nil in the typecheck for this key.

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/remote/cocoa/RemoteInspectorCocoa.mm

index c6e4a00..0231a4b 100644 (file)
@@ -1,3 +1,20 @@
+2017-05-23  Brian Burg  <bburg@apple.com>
+
+        REGRESSION(r217051): Automation sessions fail to complete bootstrap
+        https://bugs.webkit.org/show_bug.cgi?id=172513
+        <rdar://problem/32338354>
+
+        Reviewed by Joseph Pecoraro.
+
+        The changes to be more strict about typechecking messages were too strict.
+
+        * inspector/remote/cocoa/RemoteInspectorCocoa.mm:
+        (Inspector::RemoteInspector::receivedSetupMessage):
+        WIRAutomatically is an optional key in the setup message. In the relay, this key gets copied
+        into an NSDictionary as NSNull if the key isn't present in a forwarded command.
+        We need to revert NSNull values to nil, since it's valid to call [nil boolValue] but not
+        [[NSNull null] boolValue]. We also need to allow for nil in the typecheck for this key.
+
 2017-05-23  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Remove dead ENABLE(FONT_LOAD_EVENTS) code
index 58cd5cb..ca76811 100644 (file)
             return;                                       \
     } while (0);
 
+#define BAIL_IF_UNEXPECTED_TYPE_ALLOWING_NIL(expr, classExpr)   \
+    do {                                                        \
+        id value = (expr);                                      \
+        id classValue = (classExpr);                            \
+        if (value && ![value isKindOfClass:classValue])         \
+            return;                                             \
+    } while (0);
+
+#define CONVERT_NSNULL_TO_NIL(expr)          \
+    do {                                     \
+        if ([expr isEqual:[NSNull null]])    \
+            expr = nil;                      \
+    } while (0);
+
+
 namespace Inspector {
 
 static bool canAccessWebInspectorMachPort()
@@ -467,7 +482,8 @@ void RemoteInspector::receivedSetupMessage(NSDictionary *userInfo)
     BAIL_IF_UNEXPECTED_TYPE(sender, [NSString class]);
 
     NSNumber *automaticallyPauseNumber = userInfo[WIRAutomaticallyPause];
-    BAIL_IF_UNEXPECTED_TYPE(automaticallyPauseNumber, [NSNumber class]);
+    CONVERT_NSNULL_TO_NIL(automaticallyPauseNumber);
+    BAIL_IF_UNEXPECTED_TYPE_ALLOWING_NIL(automaticallyPauseNumber, [NSNumber class]);
     BOOL automaticallyPause = automaticallyPauseNumber.boolValue;
 
     unsigned targetIdentifier = targetIdentifierNumber.unsignedIntValue;