AX: Provide a way to run tests in isolated tree mode
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Mar 2020 18:34:55 +0000 (18:34 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Mar 2020 18:34:55 +0000 (18:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=208629
<rdar://problem/60075583>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Now that we have a way to run this with tests, we don't need to allow usage for an unknown client.

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::clientSupportsIsolatedTree):

Tools:

Provide the ability to run tests for accessibility in the isolated tree mode.
This sends a flag over to the injected bundle which calls the right HIServices override so that
the system thinks it is in isolated mode.

* Scripts/compare-webkit-configurations:
(flag_for_comparison):
* Scripts/webkitpy/layout_tests/run_webkit_tests.py:
(parse_args):
* Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
(parse_args):
* Scripts/webkitpy/port/driver.py:
(Driver.cmd_line):
* WebKitTestRunner/InjectedBundle/AccessibilityController.cpp:
(WTR::AccessibilityController::AccessibilityController):
(WTR::AccessibilityController::setAccessibilityIsolatedTreeMode):
(WTR::AccessibilityController::updateIsolatedTreeMode):
(WTR::AccessibilityController::executeOnAXThreadIfPossible):
* WebKitTestRunner/InjectedBundle/AccessibilityController.h:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessageToPage):
(WTR::InjectedBundle::beginTesting):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/Options.cpp:
(WTR::handleOptionAccessibilityIsolatedTreeMode):
(WTR::OptionsHandler::OptionsHandler):
* WebKitTestRunner/Options.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::initialize):
(WTR::TestController::resetPreferencesToConsistentValues):
(WTR::TestController::resetStateToConsistentValues):
* WebKitTestRunner/TestController.h:
(WTR::TestController::accessibilityIsolatedTreeMode const):

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AXObjectCache.cpp
Tools/ChangeLog
Tools/Scripts/compare-webkit-configurations
Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py
Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py
Tools/Scripts/webkitpy/port/driver.py
Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp
Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.h
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
Tools/WebKitTestRunner/Options.cpp
Tools/WebKitTestRunner/Options.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h

index f435c95..b5a2e4d 100644 (file)
@@ -1,3 +1,16 @@
+2020-03-07  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Provide a way to run tests in isolated tree mode
+        https://bugs.webkit.org/show_bug.cgi?id=208629
+        <rdar://problem/60075583>
+
+        Reviewed by Ryosuke Niwa.
+
+        Now that we have a way to run this with tests, we don't need to allow usage for an unknown client.
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::clientSupportsIsolatedTree):
+
 2020-03-07  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][IFC] Use start-aligned horizontal adjustment when justify is not eligible.
index 7aeb9e3..b63ac94 100644 (file)
@@ -721,10 +721,7 @@ bool AXObjectCache::clientSupportsIsolatedTree()
     if (!RuntimeEnabledFeatures::sharedFeatures().isAccessibilityIsolatedTreeEnabled())
         return false;
 
-    AXClientType type = _AXGetClientForCurrentRequestUntrusted();
-    // FIXME: Remove unknown client before setting isAccessibilityIsolatedTreeEnabled initial value = true.
-    return type == kAXClientTypeVoiceOver
-        || type == kAXClientTypeUnknown;
+    return _AXGetClientForCurrentRequestUntrusted() == kAXClientTypeVoiceOver;
 }
 #endif
 
index 7ddd523..9334455 100644 (file)
@@ -1,3 +1,44 @@
+2020-03-07  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Provide a way to run tests in isolated tree mode
+        https://bugs.webkit.org/show_bug.cgi?id=208629
+        <rdar://problem/60075583>
+
+        Reviewed by Ryosuke Niwa.
+
+        Provide the ability to run tests for accessibility in the isolated tree mode.
+        This sends a flag over to the injected bundle which calls the right HIServices override so that
+        the system thinks it is in isolated mode.
+
+        * Scripts/compare-webkit-configurations:
+        (flag_for_comparison):
+        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
+        (parse_args):
+        * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
+        (parse_args):
+        * Scripts/webkitpy/port/driver.py:
+        (Driver.cmd_line):
+        * WebKitTestRunner/InjectedBundle/AccessibilityController.cpp:
+        (WTR::AccessibilityController::AccessibilityController):
+        (WTR::AccessibilityController::setAccessibilityIsolatedTreeMode):
+        (WTR::AccessibilityController::updateIsolatedTreeMode):
+        (WTR::AccessibilityController::executeOnAXThreadIfPossible):
+        * WebKitTestRunner/InjectedBundle/AccessibilityController.h:
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::didReceiveMessageToPage):
+        (WTR::InjectedBundle::beginTesting):
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+        * WebKitTestRunner/Options.cpp:
+        (WTR::handleOptionAccessibilityIsolatedTreeMode):
+        (WTR::OptionsHandler::OptionsHandler):
+        * WebKitTestRunner/Options.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::initialize):
+        (WTR::TestController::resetPreferencesToConsistentValues):
+        (WTR::TestController::resetStateToConsistentValues):
+        * WebKitTestRunner/TestController.h:
+        (WTR::TestController::accessibilityIsolatedTreeMode const):
+
 2020-03-06  Per Arne Vollan  <pvollan@apple.com>
 
         [Cocoa] Re-enable CFPrefs direct mode
index 71f4357..008924c 100755 (executable)
@@ -58,6 +58,8 @@ def main():
 def flag_for_comparison(comparison_name):
     if comparison_name == "remote-layer-tree":
         return "--remote-layer-tree"
+    if comparison_name == "accessibility-isolated-tree":
+        return "--accessibility-isolated-tree"
     if comparison_name == "accelerated-drawing":
         return "--accelerated-drawing"
     if comparison_name == "webkit2":
index 3654d4e..932cdc9 100755 (executable)
@@ -302,6 +302,7 @@ def parse_args(args):
             help='"xvfb": Use a virtualized X11 server. "xorg": Use the current X11 session. '
                  '"weston": Use a virtualized Weston server. "wayland": Use the current wayland session.'),
         optparse.make_option("--world-leaks", action="store_true", default=False, help="Check for world leaks (currently, only documents). Differs from --leaks in that this uses internal instrumentation, rather than external tools."),
+        optparse.make_option("--accessibility-isolated-tree", action="store_true", default=False, help="Runs tests in accessibility isolated tree mode."),
     ]))
 
     option_group_definitions.append(("iOS Options", [
index 542d937..30802bd 100644 (file)
@@ -60,6 +60,9 @@ def parse_args(extra_args=None, tests_included=False, new_results=False, print_n
     if not '--world-leaks' in extra_args:
         args.append('--world-leaks')
 
+    if not '--accessibility-isolated-tree' in extra_args:
+        args.append('--accessibility-isolated-tree')
+
     args.extend(extra_args)
     if not tests_included:
         # We use the glob to test that globbing works.
index 5e33e98..8b8abbe 100644 (file)
@@ -520,6 +520,8 @@ class Driver(object):
             cmd.append('--no-timeout')
         if self._port.get_option('show_touches'):
             cmd.append('--show-touches')
+        if self._port.get_option('accessibility_isolated_tree'):
+            cmd.append('--accessibility-isolated-tree')
 
         for allowed_host in self._port.allowed_hosts():
             cmd.append('--allowed-host')
index 68d9958..81a4c10 100644 (file)
@@ -32,7 +32,9 @@
 #include "InjectedBundle.h"
 #include "InjectedBundlePage.h"
 #include "JSAccessibilityController.h"
-
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+#include <pal/spi/mac/HIServicesSPI.h>
+#endif
 #include <WebKit/WKBundle.h>
 #include <WebKit/WKBundlePage.h>
 #include <WebKit/WKBundlePagePrivate.h>
@@ -46,15 +48,27 @@ Ref<AccessibilityController> AccessibilityController::create()
 
 AccessibilityController::AccessibilityController()
 {
-#if PLATFORM(MAC)
-    m_useAXThread = WKAccessibilityCanUseSecondaryAXThread(InjectedBundle::singleton().page()->page());
-#endif
 }
 
 AccessibilityController::~AccessibilityController()
 {
 }
 
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+void AccessibilityController::setAccessibilityIsolatedTreeMode(bool flag)
+{
+    m_accessibilityIsolatedTreeMode = flag;
+    updateIsolatedTreeMode();
+}
+
+void AccessibilityController::updateIsolatedTreeMode()
+{
+    // Override to set identifier to VoiceOver so that requests are handled in isolated mode.
+    _AXSetClientIdentificationOverride(m_accessibilityIsolatedTreeMode ? kAXClientTypeVoiceOver : kAXClientTypeNoActiveRequestFound);
+    m_useMockAXThread = WKAccessibilityCanUseSecondaryAXThread(InjectedBundle::singleton().page()->page());
+}
+#endif
+
 void AccessibilityController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
 {
     setProperty(context, windowObject, "accessibilityController", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
@@ -93,7 +107,8 @@ Ref<AccessibilityUIElement> AccessibilityController::focusedElement()
 
 void AccessibilityController::executeOnAXThreadIfPossible(Function<void()>&& function)
 {
-    if (m_useAXThread) {
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    if (m_useMockAXThread) {
         AXThread::dispatch([&function, this] {
             function();
             m_semaphore.signal();
@@ -106,6 +121,7 @@ void AccessibilityController::executeOnAXThreadIfPossible(Function<void()>&& fun
         CFRunLoopRunInMode(kCFRunLoopDefaultMode, .25, false);
         m_semaphore.wait();
     } else
+#endif
         function();
 }
 #endif
index ea4ca28..a5d58ec 100644 (file)
@@ -51,6 +51,10 @@ public:
     // Enhanced accessibility.
     void enableEnhancedAccessibility(bool);
     bool enhancedAccessibilityEnabled();
+
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    void setAccessibilityIsolatedTreeMode(bool);
+#endif
     
     JSRetainPtr<JSStringRef> platformName();
 
@@ -91,12 +95,15 @@ private:
     RefPtr<AccessibilityNotificationHandler> m_globalNotificationHandler;
 #endif
 
-#if PLATFORM(COCOA)
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    void updateIsolatedTreeMode();
+    
     // _AXUIElementUseSecondaryAXThread and _AXUIElementRequestServicedBySecondaryAXThread
     // do not work for WebKitTestRunner since this is calling directly into
     // WebCore/accessibility via JavaScript without going through HIServices.
     // Thus to simulate the behavior of HIServices, AccessibilityController is spawning a secondary thread to service the JavaScript requests.
-    bool m_useAXThread { false };
+    bool m_useMockAXThread { false };
+    bool m_accessibilityIsolatedTreeMode { false };
     BinarySemaphore m_semaphore;
 #endif
 };
index 770fe18..00c9e75 100644 (file)
@@ -242,6 +242,11 @@ void InjectedBundle::didReceiveMessageToPage(WKBundlePageRef page, WKStringRef m
         if (shouldGC)
             WKBundleGarbageCollectJavaScriptObjects(m_bundle);
 
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+        WKRetainPtr<WKStringRef> axIsolatedModeKey = adoptWK(WKStringCreateWithUTF8CString("AccessibilityIsolatedTree"));
+        m_accessibilityIsolatedTreeMode = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, axIsolatedModeKey.get())));
+#endif
+        
         WKRetainPtr<WKStringRef> allowedHostsKey = adoptWK(WKStringCreateWithUTF8CString("AllowedHosts"));
         WKTypeRef allowedHostsValue = WKDictionaryGetItemForKey(messageBodyDictionary, allowedHostsKey.get());
         if (allowedHostsValue && WKGetTypeID(allowedHostsValue) == WKArrayGetTypeID()) {
@@ -557,6 +562,9 @@ void InjectedBundle::beginTesting(WKDictionaryRef settings, BegingTestingMode te
     m_textInputController = TextInputController::create();
 #if HAVE(ACCESSIBILITY)
     m_accessibilityController = AccessibilityController::create();
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    m_accessibilityController->setAccessibilityIsolatedTreeMode(m_accessibilityIsolatedTreeMode);
+#endif
 #endif
 
     // Don't change experimental or internal features here; those should be set in TestController::resetPreferencesToConsistentValues().
index d384d4d..b760143 100644 (file)
@@ -197,6 +197,7 @@ private:
     bool m_useWorkQueue { false };
     bool m_pixelResultIsPending { false };
     bool m_dumpJSConsoleLogInStdErr { false };
+    bool m_accessibilityIsolatedTreeMode { false };
 
     WTF::Seconds m_timeout;
 
index 5ae77d6..b6df35b 100644 (file)
@@ -99,6 +99,14 @@ static bool handleOptionAllowAnyHTTPSCertificateForAllowedHosts(Options& options
     return true;
 }
 
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+static bool handleOptionAccessibilityIsolatedTreeMode(Options& options, const char*, const char*)
+{
+    options.accessibilityIsolatedTreeMode = true;
+    return true;
+}
+#endif
+
 static bool handleOptionAllowedHost(Options& options, const char*, const char* host)
 {
     options.allowedHosts.insert(host);
@@ -154,7 +162,10 @@ OptionsHandler::OptionsHandler(Options& o)
     optionList.append(Option("--world-leaks", "Check for leaks of world objects (currently, documents)", handleOptionCheckForWorldLeaks));
     optionList.append(Option("--experimental-feature", "Enable experimental feature", handleOptionExperimentalFeature, true));
     optionList.append(Option("--internal-feature", "Enable internal feature", handleOptionInternalFeature, true));
-
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    optionList.append(Option("--accessibility-isolated-tree", "Enable accessibility isolated tree mode for tests", handleOptionAccessibilityIsolatedTreeMode));
+#endif
+    
     optionList.append(Option(0, 0, handleOptionUnmatched));
 }
 
index a56bfbc..c39cfad 100644 (file)
@@ -52,6 +52,9 @@ struct Options {
     bool shouldShowTouches { false };
     bool checkForWorldLeaks { false };
     bool allowAnyHTTPSCertificateForAllowedHosts { false };
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    bool accessibilityIsolatedTreeMode { false };
+#endif
     std::vector<std::string> paths;
     std::set<std::string> allowedHosts;
     HashMap<String, bool> internalFeatures;
index aef96b7..4dac2e6 100644 (file)
@@ -476,7 +476,9 @@ void TestController::initialize(int argc, const char* argv[])
     m_allowAnyHTTPSCertificateForAllowedHosts = options.allowAnyHTTPSCertificateForAllowedHosts;
     m_internalFeatures = options.internalFeatures;
     m_experimentalFeatures = options.experimentalFeatures;
-
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    m_accessibilityIsolatedTreeMode = options.accessibilityIsolatedTreeMode;
+#endif
     m_usingServerMode = (m_paths.size() == 1 && m_paths[0] == "-");
     if (m_usingServerMode)
         m_printSeparators = true;
@@ -961,6 +963,10 @@ void TestController::resetPreferencesToConsistentValues(const TestOptions& optio
 
     WKPreferencesSetShouldUseServiceWorkerShortTimeout(preferences, options.contextOptions.useServiceWorkerShortTimeout);
 
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    WKPreferencesSetIsAccessibilityIsolatedTreeEnabled(preferences, accessibilityIsolatedTreeMode());
+#endif
+    
     platformResetPreferencesToConsistentValues();
 }
 
@@ -991,6 +997,12 @@ bool TestController::resetStateToConsistentValues(const TestOptions& options, Re
     }
     WKDictionarySetItem(resetMessageBody.get(), allowedHostsKey.get(), allowedHostsValue.get());
 
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    WKRetainPtr<WKStringRef> axIsolatedModeKey = adoptWK(WKStringCreateWithUTF8CString("AccessibilityIsolatedTree"));
+    WKRetainPtr<WKBooleanRef> axIsolatedModeValue = adoptWK(WKBooleanCreate(m_accessibilityIsolatedTreeMode));
+    WKDictionarySetItem(resetMessageBody.get(), axIsolatedModeKey.get(), axIsolatedModeValue.get());
+#endif
+    
     if (options.jscOptions.length()) {
         WKRetainPtr<WKStringRef> jscOptionsKey = adoptWK(WKStringCreateWithUTF8CString("JSCOptions"));
         WKRetainPtr<WKStringRef> jscOptionsValue = adoptWK(WKStringCreateWithUTF8CString(options.jscOptions.c_str()));
index f3aa88a..078991b 100644 (file)
@@ -133,6 +133,10 @@ public:
 
     void simulateWebNotificationClick(uint64_t notificationID);
 
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    bool accessibilityIsolatedTreeMode() const { return m_accessibilityIsolatedTreeMode; }
+#endif
+    
     // Geolocation.
     void setGeolocationPermission(bool);
     void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, bool providesFloorLevel, double floorLevel);
@@ -597,6 +601,10 @@ private:
 
     bool m_allowAnyHTTPSCertificateForAllowedHosts { false };
 
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    bool m_accessibilityIsolatedTreeMode { false };
+#endif
+    
     bool m_shouldDecideNavigationPolicyAfterDelay { false };
     bool m_shouldDecideResponsePolicyAfterDelay { false };