Title: [244791] trunk/Source/_javascript_Core
Revision
244791
Author
bb...@apple.com
Date
2019-04-30 11:38:16 -0700 (Tue, 30 Apr 2019)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (244790 => 244791)


--- trunk/Source/_javascript_Core/ChangeLog	2019-04-30 18:35:03 UTC (rev 244790)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-04-30 18:38:16 UTC (rev 244791)
@@ -1,3 +1,25 @@
+2019-04-30  Brian Burg  <bb...@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_mil...@apple.com>
 
         Fix failing ARM64E wasm tests

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorConstants.h (244790 => 244791)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorConstants.h	2019-04-30 18:35:03 UTC (rev 244790)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorConstants.h	2019-04-30 18:38:16 UTC (rev 244791)
@@ -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"
@@ -77,6 +78,11 @@
 #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"

Modified: trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm (244790 => 244791)


--- trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm	2019-04-30 18:35:03 UTC (rev 244790)
+++ trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm	2019-04-30 18:38:16 UTC (rev 244791)
@@ -454,6 +454,14 @@
     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];
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to