Web Automation: use a more informative key to indicate automation availability
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Apr 2019 18:38:16 +0000 (18:38 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Apr 2019 18:38:16 +0000 (18:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197377
<rdar://problem/50258069>

Reviewed by Devin Rousso.

The existing WIRAutomationEnabledKey does not encode uncertainty.
Add a new key that provides an 'Unknown' state, and prefer to use it.

Since an application's initial listing is sent from a background dispatch queue
on Cocoa platforms, this can race with main thread initialization that sets up
RemoteInspector::Client. Therefore, the initial listing may not properly represent
the client's capabilites because the client is not yet available. Allowing for
an "Unknown" state that is later upgraded to Available or Not Available makes it
possible to work around this potential race.

* inspector/remote/RemoteInspectorConstants.h:
* inspector/remote/cocoa/RemoteInspectorCocoa.mm:
(Inspector::RemoteInspector::pushListingsNow):

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

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

index 0f42be5..9dfd7d1 100644 (file)
@@ -1,3 +1,25 @@
+2019-04-30  Brian Burg  <bburg@apple.com>
+
+        Web Automation: use a more informative key to indicate automation availability
+        https://bugs.webkit.org/show_bug.cgi?id=197377
+        <rdar://problem/50258069>
+
+        Reviewed by Devin Rousso.
+
+        The existing WIRAutomationEnabledKey does not encode uncertainty.
+        Add a new key that provides an 'Unknown' state, and prefer to use it.
+
+        Since an application's initial listing is sent from a background dispatch queue
+        on Cocoa platforms, this can race with main thread initialization that sets up
+        RemoteInspector::Client. Therefore, the initial listing may not properly represent
+        the client's capabilites because the client is not yet available. Allowing for
+        an "Unknown" state that is later upgraded to Available or Not Available makes it
+        possible to work around this potential race.
+
+        * inspector/remote/RemoteInspectorConstants.h:
+        * inspector/remote/cocoa/RemoteInspectorCocoa.mm:
+        (Inspector::RemoteInspector::pushListingsNow):
+
 2019-04-30  Keith Miller  <keith_miller@apple.com>
 
         Fix failing ARM64E wasm tests
index 86bd8f7..c9ab33f 100644 (file)
@@ -68,6 +68,7 @@
 #define WIRListingMessage                       @"WIRListingMessage"
 #define WIRListingKey                           @"WIRListingKey"
 #define WIRRemoteAutomationEnabledKey           @"WIRRemoteAutomationEnabledKey"
+#define WIRAutomationAvailabilityKey            @"WIRAutomationAvailabilityKey"
 #define WIRDestinationKey                       @"WIRDestinationKey"
 #define WIRConnectionDiedMessage                @"WIRConnectionDiedMessage"
 #define WIRTypeKey                              @"WIRTypeKey"
 #define WIRTypeAutomation                       @"WIRTypeAutomation"
 #define WIRAutomaticallyPause                   @"WIRAutomaticallyPause"
 
+// Allowed values for WIRAutomationAvailabilityKey.
+#define WIRAutomationAvailabilityNotAvailable     @"WIRAutomationAvailabilityNotAvailable"
+#define WIRAutomationAvailabilityAvailable        @"WIRAutomationAvailabilityAvailable"
+#define WIRAutomationAvailabilityUnknown          @"WIRAutomationAvailabilityUnknown"
+
 #define WIRAutomaticInspectionEnabledKey           @"WIRAutomaticInspectionEnabledKey"
 #define WIRAutomaticInspectionSessionIdentifierKey @"WIRAutomaticInspectionSessionIdentifierKey"
 #define WIRAutomaticInspectionConfigurationMessage @"WIRAutomaticInspectionConfigurationMessage"
index 5bef21c..11667a8 100644 (file)
@@ -454,6 +454,14 @@ void RemoteInspector::pushListingsNow()
     RetainPtr<NSMutableDictionary> message = adoptNS([[NSMutableDictionary alloc] init]);
     [message setObject:listings.get() forKey:WIRListingKey];
 
+    if (!m_clientCapabilities)
+        [message setObject:WIRAutomationAvailabilityUnknown forKey:WIRAutomationAvailabilityKey];
+    else if (m_clientCapabilities->remoteAutomationAllowed)
+        [message setObject:WIRAutomationAvailabilityAvailable forKey:WIRAutomationAvailabilityKey];
+    else
+        [message setObject:WIRAutomationAvailabilityNotAvailable forKey:WIRAutomationAvailabilityKey];
+
+    // COMPATIBILITY(iOS 13): this key is deprecated and not used by newer versions of webinspectord.
     BOOL isAllowed = m_clientCapabilities && m_clientCapabilities->remoteAutomationAllowed;
     [message setObject:@(isAllowed) forKey:WIRRemoteAutomationEnabledKey];