<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[244212] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/244212">244212</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2019-04-12 01:46:57 -0700 (Fri, 12 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK] REGRESSION(<a href="http://trac.webkit.org/projects/webkit/changeset/243860">r243860</a>): Many tests failing
https://bugs.webkit.org/show_bug.cgi?id=196791

Reviewed by Joanmarie Diggs.

Source/WebKit:

Calling updateAccessibilityTree() on document loaded was causing a re-layout because of the backing store update
that confused all those tests. We shouldn't need to update the accessibility tree on document load, it should
happen automatically when root object is attached/detached. This patch emits children-changed::add when the root
object wrapper is attached and children-changed::remove when the root object is detached. That way ATs are
notified of the changes in the accessibility tree.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidFinishDocumentLoad): Remove call to WebPage::updateAccessibilityTree().
* WebProcess/WebPage/WebPage.h: Remove updateAccessibilityTree().
* WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp:
(coreRootObjectWrapperDetachedCallback): Emit children-changed::remove.
(rootWebAreaWrapper): Helper to get the root WebArea wrapper.
(accessibilityRootObjectWrapper): Set the parent here when root object is created and emit children-changed::add.
(webkitWebPageAccessibilityObjectRefChild): Dot no set the parent here, it's now set when the root object is created.
* WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.h: Remove webkitWebPageAccessibilityObjectRefresh().
* WebProcess/WebPage/gtk/WebPageGtk.cpp:

Tools:

Rework the accessibility unit test to use DBus for the communication with the server. This way we can load
multiple documents and check that accessibility hierarchy is updated after a navigation.

* TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp:
(loadChangedCallback):
* TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp:
(AccessibilityTest::AccessibilityTest):
(AccessibilityTest::~AccessibilityTest):
(AccessibilityTest::loadHTMLAndWaitUntilFinished):
(AccessibilityTest::findTestServerApplication):
(AccessibilityTest::findDocumentWeb):
(AccessibilityTest::findRootObject):
(AccessibilityTest::waitUntilChildrenRemoved):
(AccessibilityTest::ensureProxy):
(testAtspiBasicHierarchy):
(beforeAll):
(afterAll):

LayoutTests:

Remove expectations for tests that pass now.

* platform/gtk/TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformgtkTestExpectations">trunk/LayoutTests/platform/gtk/TestExpectations</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebFrameLoaderClientcpp">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPageh">trunk/Source/WebKit/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageatkWebKitWebPageAccessibilityObjectcpp">trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageatkWebKitWebPageAccessibilityObjecth">trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPagegtkWebPageGtkcpp">trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtkAccessibilityTestServercpp">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitGtkTestWebKitAccessibilitycpp">trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (244211 => 244212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-04-12 06:35:17 UTC (rev 244211)
+++ trunk/LayoutTests/ChangeLog 2019-04-12 08:46:57 UTC (rev 244212)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2019-04-11  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] REGRESSION(r243860): Many tests failing
+        https://bugs.webkit.org/show_bug.cgi?id=196791
+
+        Reviewed by Joanmarie Diggs.
+
+        Remove expectations for tests that pass now.
+
+        * platform/gtk/TestExpectations:
+
</ins><span class="cx"> 2019-04-11  Megan Gardner  <megan_gardner@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Fix flaky LayoutTests/fast/events/autoscroll-when-input-is-offscreen.html
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/gtk/TestExpectations (244211 => 244212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/TestExpectations  2019-04-12 06:35:17 UTC (rev 244211)
+++ trunk/LayoutTests/platform/gtk/TestExpectations     2019-04-12 08:46:57 UTC (rev 244212)
</span><span class="lines">@@ -1893,7 +1893,7 @@
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/181030 wasm/iframe-postmessage.html [ Pass Failure ]
</span><span class="cx"> webkit.org/b/179948 [ Release ] fast/hidpi/filters-reference.html [ Pass ImageOnlyFailure ]
</span><del>-webkit.org/b/196791 webkit.org/b/181031 fast/frames/crash-when-iframe-is-remove-in-eventhandler.html [ Pass Crash Failure ]
</del><ins>+webkit.org/b/181031 fast/frames/crash-when-iframe-is-remove-in-eventhandler.html [ Pass Crash ]
</ins><span class="cx"> 
</span><span class="cx"> webkit.org/b/181528 http/tests/cache/memory-cache-pruning.html [ Pass Crash ]
</span><span class="cx"> 
</span><span class="lines">@@ -3817,49 +3817,6 @@
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/196541 editing/pasteboard/paste-content-with-overflow-auto-parent-across-origin.html [ Failure ]
</span><span class="cx"> 
</span><del>-webkit.org/b/196791 tables/mozilla/dom/deleteCol1.html [ Failure ]
-webkit.org/b/196791 tables/mozilla/dom/deleteCol2.html [ Failure ]
-webkit.org/b/196791 tables/mozilla/dom/deleteCol3.html [ Failure ]
-webkit.org/b/196791 tables/mozilla/dom/deleteColGroup1.html [ Failure ]
-webkit.org/b/196791 tables/mozilla/dom/deleteColGroup2.html [ Failure ]
-webkit.org/b/196791 tables/mozilla/dom/insertColGroups1.html [ Failure ]
-webkit.org/b/196791 tables/mozilla/dom/insertColGroups2.html [ Failure ]
-webkit.org/b/196791 tables/mozilla/dom/insertCols1.html [ Failure ]
-webkit.org/b/196791 tables/mozilla/dom/insertCols2.html [ Failure ]
-webkit.org/b/196791 tables/mozilla/dom/insertCols3.html [ Failure ]
-webkit.org/b/196791 tables/mozilla/dom/insertCols4.html [ Failure ]
-webkit.org/b/196791 tables/mozilla/dom/insertCols5.html [ Failure ]
-webkit.org/b/196791 svg/hixie/text/003.html [ Failure ]
-webkit.org/b/196791 svg/custom/linking-uri-01-b.svg [ Failure ]
-webkit.org/b/196791 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-width-1000px.html [ Failure ]
-webkit.org/b/196791 fast/text/international/bidi-listbox-atsui.html [ Failure ]
-webkit.org/b/196791 fast/text/international/bidi-innertext.html [ Failure ]
-webkit.org/b/196791 fast/text/international/bidi-L2-run-reordering.html [ Failure ]
-webkit.org/b/196791 fast/scrolling/scroll-animator-select-list-events.html [ Failure ]
-webkit.org/b/196791 fast/scrolling/scroll-animator-overlay-scrollbars-hovered.html [ Failure ]
-webkit.org/b/196791 fast/scrolling/scroll-animator-overlay-scrollbars-clicked.html [ Failure ]
-webkit.org/b/196791 fast/scrolling/scroll-animator-basic-events.html [ Failure ]
-webkit.org/b/196791 fast/frames/inline-object-inside-frameset.html [ Failure ]
-webkit.org/b/196791 fast/forms/visual-hebrew-text-field.html [ Failure ]
-webkit.org/b/196791 fast/forms/select-visual-hebrew.html [ Failure ]
-webkit.org/b/196791 fast/forms/form-submission-crash-3.html [ Failure ]
-webkit.org/b/196791 compositing/backing/backing-store-attachment-empty-keyframe.html [ Failure ]
-webkit.org/b/196791 fast/images/animated-gif-no-layout.html [ Failure ]
-webkit.org/b/196791 http/tests/incremental/stylesheet-body-incremental-rendering.html [ Failure ]
-webkit.org/b/196791 http/tests/webfont/font-loading-system-fallback-visibility-FontRanges.html [ Failure ]
-webkit.org/b/196791 mathml/scripts-removeChild.html [ Failure ]
-webkit.org/b/196791 mathml/presentation/attributes-accent-accentunder-dynamic.html [ Failure ]
-webkit.org/b/196791 mathml/presentation/menclose-notation-attribute-add.html [ Failure ]
-webkit.org/b/196791 mathml/presentation/menclose-notation-attribute-change-value.html [ Failure ]
-webkit.org/b/196791 mathml/presentation/menclose-notation-attribute-remove.html [ Failure ]
-webkit.org/b/196791 mathml/presentation/mo-form-dynamic.html [ Failure ]
-webkit.org/b/196791 mathml/presentation/mpadded-dynamic.html [ Failure ]
-webkit.org/b/196791 mathml/presentation/stretchy-minsize-maxsize-dynamic.html [ Failure ]
-webkit.org/b/196791 svg/custom/textPath-change-id-pattern.svg [ Failure ]
-webkit.org/b/196791 svg/custom/textPath-change-id.svg [ Failure ]
-webkit.org/b/196791 svg/custom/textPath-insert-path-pattern.svg [ Failure ]
-webkit.org/b/196791 svg/custom/textPath-insert-path.svg [ Failure ]
-
</del><span class="cx"> #////////////////////////////////////////////////////////////////////////////////////////
</span><span class="cx"> # End of non-crashing, non-flaky tests failing
</span><span class="cx"> #////////////////////////////////////////////////////////////////////////////////////////
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (244211 => 244212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-04-12 06:35:17 UTC (rev 244211)
+++ trunk/Source/WebKit/ChangeLog       2019-04-12 08:46:57 UTC (rev 244212)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2019-04-11  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] REGRESSION(r243860): Many tests failing
+        https://bugs.webkit.org/show_bug.cgi?id=196791
+
+        Reviewed by Joanmarie Diggs.
+
+        Calling updateAccessibilityTree() on document loaded was causing a re-layout because of the backing store update
+        that confused all those tests. We shouldn't need to update the accessibility tree on document load, it should
+        happen automatically when root object is attached/detached. This patch emits children-changed::add when the root
+        object wrapper is attached and children-changed::remove when the root object is detached. That way ATs are
+        notified of the changes in the accessibility tree.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::dispatchDidFinishDocumentLoad): Remove call to WebPage::updateAccessibilityTree().
+        * WebProcess/WebPage/WebPage.h: Remove updateAccessibilityTree().
+        * WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp:
+        (coreRootObjectWrapperDetachedCallback): Emit children-changed::remove.
+        (rootWebAreaWrapper): Helper to get the root WebArea wrapper.
+        (accessibilityRootObjectWrapper): Set the parent here when root object is created and emit children-changed::add.
+        (webkitWebPageAccessibilityObjectRefChild): Dot no set the parent here, it's now set when the root object is created.
+        * WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.h: Remove webkitWebPageAccessibilityObjectRefresh().
+        * WebProcess/WebPage/gtk/WebPageGtk.cpp:
+
</ins><span class="cx"> 2019-04-11  Megan Gardner  <megan_gardner@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Update 'Save Image' to more clear instructions
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebFrameLoaderClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (244211 => 244212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp   2019-04-12 06:35:17 UTC (rev 244211)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp      2019-04-12 08:46:57 UTC (rev 244212)
</span><span class="lines">@@ -599,11 +599,6 @@
</span><span class="cx"> 
</span><span class="cx">     // Notify the UIProcess.
</span><span class="cx">     webPage->send(Messages::WebPageProxy::DidFinishDocumentLoadForFrame(m_frame->frameID(), navigationID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
</span><del>-
-#if HAVE(ACCESSIBILITY) && PLATFORM(GTK)
-    // Ensure the accessibility hierarchy is updated.
-    webPage->updateAccessibilityTree();
-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebFrameLoaderClient::dispatchDidFinishLoad()
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (244211 => 244212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-04-12 06:35:17 UTC (rev 244211)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h    2019-04-12 08:46:57 UTC (rev 244212)
</span><span class="lines">@@ -805,10 +805,6 @@
</span><span class="cx">     void replaceSelectionWithPasteboardData(const Vector<String>& types, const IPC::DataReference&);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if HAVE(ACCESSIBILITY) && PLATFORM(GTK)
-    void updateAccessibilityTree();
-#endif
-
</del><span class="cx">     void setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length, bool suppressUnderline);
</span><span class="cx">     bool hasCompositionForTesting();
</span><span class="cx">     void confirmCompositionForTesting(const String& compositionString);
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageatkWebKitWebPageAccessibilityObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp (244211 => 244212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp  2019-04-12 06:35:17 UTC (rev 244211)
+++ trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.cpp     2019-04-12 08:46:57 UTC (rev 244212)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include "WebPage.h"
</span><span class="cx"> #include <WebCore/AXObjectCache.h>
</span><ins>+#include <WebCore/AccessibilityScrollView.h>
</ins><span class="cx"> #include <WebCore/Document.h>
</span><span class="cx"> #include <WebCore/Frame.h>
</span><span class="cx"> #include <WebCore/Page.h>
</span><span class="lines">@@ -44,6 +45,25 @@
</span><span class="cx"> 
</span><span class="cx"> WEBKIT_DEFINE_TYPE(WebKitWebPageAccessibilityObject, webkit_web_page_accessibility_object, ATK_TYPE_PLUG)
</span><span class="cx"> 
</span><ins>+static void coreRootObjectWrapperDetachedCallback(AtkObject* wrapper, const char*, gboolean value, AtkObject* atkObject)
+{
+    if (!value)
+        return;
+
+    g_signal_emit_by_name(atkObject, "children-changed::remove", 0, wrapper);
+}
+
+static AccessibilityObjectWrapper* rootWebAreaWrapper(AccessibilityObject& rootObject)
+{
+    if (!rootObject.isAccessibilityScrollView())
+        return nullptr;
+
+    if (auto* webAreaObject = downcast<AccessibilityScrollView>(rootObject).webAreaObject())
+        return webAreaObject->wrapper();
+
+    return nullptr;
+}
+
</ins><span class="cx"> static AtkObject* accessibilityRootObjectWrapper(AtkObject* atkObject)
</span><span class="cx"> {
</span><span class="cx">     if (!AXObjectCache::accessibilityEnabled())
</span><span class="lines">@@ -69,7 +89,21 @@
</span><span class="cx">     if (!coreRootObject)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    return ATK_OBJECT(coreRootObject->wrapper());
</del><ins>+    auto* wrapper = ATK_OBJECT(coreRootObject->wrapper());
+    if (!wrapper)
+        return nullptr;
+
+    if (atk_object_peek_parent(wrapper) != ATK_OBJECT(accessible)) {
+        atk_object_set_parent(wrapper, ATK_OBJECT(accessible));
+        g_signal_emit_by_name(accessible, "children-changed::add", 0, wrapper);
+
+        if (auto* webAreaWrapper = rootWebAreaWrapper(*coreRootObject)) {
+            g_signal_connect_object(webAreaWrapper, "state-change::defunct",
+                G_CALLBACK(coreRootObjectWrapperDetachedCallback), accessible, static_cast<GConnectFlags>(0));
+        }
+    }
+
+    return wrapper;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void webkitWebPageAccessibilityObjectInitialize(AtkObject* atkObject, gpointer data)
</span><span class="lines">@@ -98,14 +132,10 @@
</span><span class="cx">     if (index && index != 1)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    AtkObject* rootObject = accessibilityRootObjectWrapper(atkObject);
-    if (!rootObject)
-        return nullptr;
</del><ins>+    if (auto* rootObjectWrapper = accessibilityRootObjectWrapper(atkObject))
+        return ATK_OBJECT(g_object_ref(rootObjectWrapper));
</ins><span class="cx"> 
</span><del>-    atk_object_set_parent(rootObject, atkObject);
-    g_object_ref(rootObject);
-
-    return rootObject;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void webkit_web_page_accessibility_object_class_init(WebKitWebPageAccessibilityObjectClass* klass)
</span><span class="lines">@@ -127,13 +157,4 @@
</span><span class="cx">     return object;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void webkitWebPageAccessibilityObjectRefresh(WebKitWebPageAccessibilityObject* accessible)
-{
-    // We just need to ensure that there's a connection in the ATK
-    // world between this accessibility object and the AtkObject of
-    // the accessibility object for the root of the DOM tree.
-    if (auto* rootObject = accessibilityRootObjectWrapper(ATK_OBJECT(accessible)))
-        atk_object_set_parent(rootObject, ATK_OBJECT(accessible));
-}
-
</del><span class="cx"> #endif // HAVE(ACCESSIBILITY)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageatkWebKitWebPageAccessibilityObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.h (244211 => 244212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.h    2019-04-12 06:35:17 UTC (rev 244211)
+++ trunk/Source/WebKit/WebProcess/WebPage/atk/WebKitWebPageAccessibilityObject.h       2019-04-12 08:46:57 UTC (rev 244212)
</span><span class="lines">@@ -60,8 +60,6 @@
</span><span class="cx"> 
</span><span class="cx"> AtkObject* webkitWebPageAccessibilityObjectNew(WebKit::WebPage*);
</span><span class="cx"> 
</span><del>-void webkitWebPageAccessibilityObjectRefresh(WebKitWebPageAccessibilityObject*);
-
</del><span class="cx"> G_END_DECLS
</span><span class="cx"> 
</span><span class="cx"> #endif // HAVE(ACCESSIBILITY)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPagegtkWebPageGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp (244211 => 244212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp        2019-04-12 06:35:17 UTC (rev 244211)
+++ trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp   2019-04-12 08:46:57 UTC (rev 244212)
</span><span class="lines">@@ -111,16 +111,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if HAVE(ACCESSIBILITY)
-void WebPage::updateAccessibilityTree()
-{
-    if (!m_accessibilityObject)
-        return;
-
-    webkitWebPageAccessibilityObjectRefresh(WEBKIT_WEB_PAGE_ACCESSIBILITY_OBJECT(m_accessibilityObject.get()));
-}
-#endif
-
</del><span class="cx"> bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent)
</span><span class="cx"> {
</span><span class="cx">     if (keyboardEvent.type() != WebEvent::KeyDown && keyboardEvent.type() != WebEvent::RawKeyDown)
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (244211 => 244212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2019-04-12 06:35:17 UTC (rev 244211)
+++ trunk/Tools/ChangeLog       2019-04-12 08:46:57 UTC (rev 244212)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2019-04-11  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] REGRESSION(r243860): Many tests failing
+        https://bugs.webkit.org/show_bug.cgi?id=196791
+
+        Reviewed by Joanmarie Diggs.
+
+        Rework the accessibility unit test to use DBus for the communication with the server. This way we can load
+        multiple documents and check that accessibility hierarchy is updated after a navigation.
+
+        * TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp:
+        (loadChangedCallback):
+        * TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp:
+        (AccessibilityTest::AccessibilityTest):
+        (AccessibilityTest::~AccessibilityTest):
+        (AccessibilityTest::loadHTMLAndWaitUntilFinished):
+        (AccessibilityTest::findTestServerApplication):
+        (AccessibilityTest::findDocumentWeb):
+        (AccessibilityTest::findRootObject):
+        (AccessibilityTest::waitUntilChildrenRemoved):
+        (AccessibilityTest::ensureProxy):
+        (testAtspiBasicHierarchy):
+        (beforeAll):
+        (afterAll):
+
</ins><span class="cx"> 2019-04-11  Aakash Jain  <aakash_jain@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [ews-build] Handle bug titles with unicode characters
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitGtkAccessibilityTestServercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp (244211 => 244212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp    2019-04-12 06:35:17 UTC (rev 244211)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp       2019-04-12 08:46:57 UTC (rev 244212)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2012 Igalia S.L.
</del><ins>+ * Copyright (C) 2012, 2019 Igalia S.L.
</ins><span class="cx">  *
</span><span class="cx">  * This library is free software; you can redistribute it and/or
</span><span class="cx">  * modify it under the terms of the GNU Lesser General Public
</span><span class="lines">@@ -22,13 +22,46 @@
</span><span class="cx"> #include <gtk/gtk.h>
</span><span class="cx"> #include <webkit2/webkit2.h>
</span><span class="cx"> 
</span><del>-static void loadChangedCallback(WebKitWebView*, WebKitLoadEvent loadEvent, gpointer)
</del><ins>+static const char introspectionXML[] =
+    "<node>"
+    " <interface name='org.webkit.gtk.AccessibilityTest'>"
+    "  <method name='LoadHTML'>"
+    "   <arg type='s' name='html' direction='in'/>"
+    "   <arg type='s' name='baseURI' direction='in'/>"
+    "  </method>"
+    " </interface>"
+    "</node>";
+
+static void loadChangedCallback(WebKitWebView* webView, WebKitLoadEvent loadEvent, GDBusMethodInvocation* invocation)
</ins><span class="cx"> {
</span><del>-    // Send a message to the parent process when we're ready.
-    if (loadEvent == WEBKIT_LOAD_FINISHED)
-        g_print("OK");
</del><ins>+    if (loadEvent != WEBKIT_LOAD_FINISHED)
+        return;
+
+    g_signal_handlers_disconnect_by_func(webView, reinterpret_cast<void*>(loadChangedCallback), invocation);
+    g_dbus_method_invocation_return_value(invocation, nullptr);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static const GDBusInterfaceVTable interfaceVirtualTable = {
+    // methodCall
+    [](GDBusConnection* connection, const char* sender, const char* objectPath, const char* interfaceName, const char* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData) {
+        if (g_strcmp0(interfaceName, "org.webkit.gtk.AccessibilityTest"))
+            return;
+
+        auto* webView = WEBKIT_WEB_VIEW(userData);
+
+        if (!g_strcmp0(methodName, "LoadHTML")) {
+            const char* html;
+            const char* baseURI;
+            g_variant_get(parameters, "(&s&s)", &html, &baseURI);
+            g_signal_connect(webView, "load-changed", G_CALLBACK(loadChangedCallback), invocation);
+            webkit_web_view_load_html(webView, html, baseURI && *baseURI ? baseURI : nullptr);
+        }
+    },
+    nullptr,
+    nullptr,
+    { 0, }
+};
+
</ins><span class="cx"> int main(int argc, char** argv)
</span><span class="cx"> {
</span><span class="cx">     // Make sure that the ATK bridge is loaded.
</span><span class="lines">@@ -36,23 +69,22 @@
</span><span class="cx"> 
</span><span class="cx">     gtk_init(&argc, &argv);
</span><span class="cx"> 
</span><del>-    WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
-    webkit_web_view_load_html(webView,
-        "<html>"
-        "  <body>"
-        "   <h1>This is a test</h1>"
-        "   <p>This is a paragraph with some plain text.</p>"
-        "   <p>This paragraph contains <a href=\"http://www.webkitgtk.org\">a link</a> in the middle.</p>"
-        "  </body>"
-        "</html>",
-        0);
</del><ins>+    GtkWidget* webView = webkit_web_view_new();
</ins><span class="cx"> 
</span><span class="cx">     GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
</span><ins>+    g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), nullptr);
</ins><span class="cx">     gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(webView));
</span><span class="cx">     gtk_widget_show_all(window);
</span><span class="cx"> 
</span><del>-    g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), 0);
-    g_signal_connect(webView, "load-changed", G_CALLBACK(loadChangedCallback), 0);
</del><ins>+    g_bus_own_name(G_BUS_TYPE_SESSION, "org.webkit.gtk.AccessibilityTest", G_BUS_NAME_OWNER_FLAGS_NONE,
+        [](GDBusConnection* connection, const char* name, gpointer userData) {
+            static GDBusNodeInfo *introspectionData = nullptr;
+            if (!introspectionData)
+                introspectionData = g_dbus_node_info_new_for_xml(introspectionXML, nullptr);
</ins><span class="cx"> 
</span><ins>+            g_dbus_connection_register_object(connection, "/org/webkit/gtk/AccessibilityTest", introspectionData->interfaces[0],
+                &interfaceVirtualTable, userData, nullptr, nullptr);
+        }, nullptr, nullptr, webView, nullptr);
+
</ins><span class="cx">     gtk_main();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitGtkTestWebKitAccessibilitycpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp (244211 => 244212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp    2019-04-12 06:35:17 UTC (rev 244211)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp       2019-04-12 08:46:57 UTC (rev 244212)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2012 Igalia S.L.
</del><ins>+ * Copyright (C) 2012, 2019 Igalia S.L.
</ins><span class="cx">  *
</span><span class="cx">  * This library is free software; you can redistribute it and/or
</span><span class="cx">  * modify it under the terms of the GNU Lesser General Public
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> 
</span><span class="cx"> #include "TestMain.h"
</span><del>-#include "WebViewTest.h"
</del><ins>+#include "WebKitTestBus.h"
</ins><span class="cx"> 
</span><span class="cx"> // The libatspi headers don't use G_BEGIN_DECLS
</span><span class="cx"> extern "C" {
</span><span class="lines">@@ -27,197 +27,203 @@
</span><span class="cx"> #include <atspi/atspi.h>
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#include <errno.h>
-#include <fcntl.h>
-#include <glib.h>
-#include <signal.h>
-#include <unistd.h>
-#include <wtf/glib/GRefPtr.h>
-#include <wtf/glib/GUniquePtr.h>
</del><ins>+static WebKitTestBus* bus;
</ins><span class="cx"> 
</span><del>-// Name of the test server application creating the webView object.
-static const char* kTestServerAppName = "AccessibilityTestServer";
</del><ins>+class AccessibilityTest : public Test {
+public:
+    MAKE_GLIB_TEST_FIXTURE(AccessibilityTest);
</ins><span class="cx"> 
</span><del>-// Max seconds to wait for the test server before inspecting it.
-static const int kMaxWaitForChild = 5;
</del><ins>+    AccessibilityTest()
+    {
+        GUniquePtr<char> testServerPath(g_build_filename(WEBKIT_EXEC_PATH, "TestWebKitAPI", "WebKit2Gtk", "AccessibilityTestServer", nullptr));
+        char* args[2];
+        args[0] = testServerPath.get();
+        args[1] = nullptr;
</ins><span class="cx"> 
</span><del>-// The PID for the test server running, so we can kill it if needed.
-static GPid kChildProcessPid = 0;
</del><ins>+        g_assert_true(g_spawn_async(nullptr, args, nullptr, G_SPAWN_DEFAULT, nullptr, nullptr, &m_childProcessID, nullptr));
+    }
</ins><span class="cx"> 
</span><del>-// Whether the child has replied and it's ready.
-static bool kChildIsReady = false;
</del><ins>+    ~AccessibilityTest()
+    {
+        if (m_childProcessID) {
+            g_spawn_close_pid(m_childProcessID);
+            kill(m_childProcessID, SIGTERM);
+        }
+    }
</ins><span class="cx"> 
</span><del>-static void stopTestServer()
-{
-    // Do nothing if there's no server running.
-    if (!kChildProcessPid)
-        return;
</del><ins>+    void loadHTMLAndWaitUntilFinished(const char* html, const char* baseURI)
+    {
+        ensureProxy();
</ins><span class="cx"> 
</span><del>-    g_spawn_close_pid(kChildProcessPid);
-    kill(kChildProcessPid, SIGTERM);
-    kChildProcessPid = 0;
-}
</del><ins>+        GUniqueOutPtr<GError> error;
+        GRefPtr<GVariant> result = adoptGRef(g_dbus_proxy_call_sync(m_proxy.get(), "LoadHTML",
+            g_variant_new("(ss)", html, baseURI ? baseURI : ""), G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &error.outPtr()));
+        g_assert_no_error(error.get());
+    }
</ins><span class="cx"> 
</span><del>-static void sigAbortHandler(int sigNum)
-{
-    // Just stop the test server if SIGABRT was received.
-    stopTestServer();
-}
</del><ins>+    GRefPtr<AtspiAccessible> findTestServerApplication()
+    {
+        // Only one desktop is supported by ATSPI at the moment.
+        GRefPtr<AtspiAccessible> desktop = adoptGRef(atspi_get_desktop(0));
</ins><span class="cx"> 
</span><del>-static gpointer testServerMonitorThreadFunc(gpointer)
-{
-    // Wait for the specified timeout to happen.
-    g_usleep(kMaxWaitForChild * G_USEC_PER_SEC);
</del><ins>+        int childCount = atspi_accessible_get_child_count(desktop.get(), nullptr);
+        for (int i = 0; i < childCount; ++i) {
+            GRefPtr<AtspiAccessible> current = adoptGRef(atspi_accessible_get_child_at_index(desktop.get(), i, nullptr));
+            if (!g_strcmp0(atspi_accessible_get_name(current.get(), nullptr), "AccessibilityTestServer"))
+                return current;
+        }
</ins><span class="cx"> 
</span><del>-    // Kill the child process if not ready yet.
-    if (!kChildIsReady)
-        stopTestServer();
</del><ins>+        return 0;
+    }
</ins><span class="cx"> 
</span><del>-    g_thread_exit(0);
-    return 0;
-}
</del><ins>+    GRefPtr<AtspiAccessible> findDocumentWeb(AtspiAccessible* accessible)
+    {
+        int childCount = atspi_accessible_get_child_count(accessible, nullptr);
+        for (int i = 0; i < childCount; ++i) {
+            GRefPtr<AtspiAccessible> child = adoptGRef(atspi_accessible_get_child_at_index(accessible, i, nullptr));
+            if (atspi_accessible_get_role(child.get(), nullptr) == ATSPI_ROLE_DOCUMENT_WEB)
+                return child;
</ins><span class="cx"> 
</span><del>-static void startTestServerMonitor()
-{
-    kChildIsReady = false;
-    g_thread_new("TestServerMonitor", testServerMonitorThreadFunc, 0);
-}
</del><ins>+            if (auto documentWeb = findDocumentWeb(child.get()))
+                return documentWeb;
+        }
+        return nullptr;
+    }
</ins><span class="cx"> 
</span><del>-static void startTestServer()
-{
-    // Prepare argv[] for spawning the server process.
-    GUniquePtr<char> testServerPath(g_build_filename(WEBKIT_EXEC_PATH, "TestWebKitAPI", "WebKit2Gtk", kTestServerAppName, nullptr));
</del><ins>+    GRefPtr<AtspiAccessible> findRootObject(AtspiAccessible* application)
+    {
+        // Find the document web, its parent is the scroll view (WebCore root object) and its parent is
+        // the GtkPlug (WebProcess root element).
+        auto documentWeb = findDocumentWeb(application);
+        if (!documentWeb)
+            return nullptr;
</ins><span class="cx"> 
</span><del>-    char* testServerArgv[2];
-    testServerArgv[0] = testServerPath.get();
-    testServerArgv[1] = 0;
</del><ins>+        auto parent = adoptGRef(atspi_accessible_get_parent(documentWeb.get(), nullptr));
+        return parent ? adoptGRef(atspi_accessible_get_parent(parent.get(), nullptr)) : nullptr;
+    }
</ins><span class="cx"> 
</span><del>-    // Spawn the server, getting its stdout file descriptor to set a
-    // communication channel, so we know when it's ready.
-    int childStdout = 0;
-    if (!g_spawn_async_with_pipes(0, testServerArgv, 0, static_cast<GSpawnFlags>(0), 0, 0, &kChildProcessPid, 0, &childStdout, 0, 0)) {
-        close(childStdout);
-        return;
</del><ins>+    void waitUntilChildrenRemoved(AtspiAccessible* accessible)
+    {
+        m_eventSource = accessible;
+        GRefPtr<AtspiEventListener> listener = adoptGRef(atspi_event_listener_new(
+            [](AtspiEvent* event, gpointer userData) {
+                auto* test = static_cast<AccessibilityTest*>(userData);
+                if (event->source == test->m_eventSource)
+                    g_main_loop_quit(test->m_mainLoop.get());
+        }, this, nullptr));
+        atspi_event_listener_register(listener.get(), "object:children-changed:remove", nullptr);
+        g_main_loop_run(m_mainLoop.get());
+        m_eventSource = nullptr;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // Start monitoring the test server (in a separate thread) to
-    // ensure we don't block on the child process more than a timeout.
-    startTestServerMonitor();
</del><ins>+private:
+    void ensureProxy()
+    {
+        if (m_proxy)
+            return;
</ins><span class="cx"> 
</span><del>-    char msg[2];
-    GIOChannel* ioChannel = g_io_channel_unix_new(childStdout);
-    if (g_io_channel_read_chars(ioChannel, msg, 2, 0, 0) == G_IO_STATUS_NORMAL) {
-        // Check whether the server sent a message saying it's ready
-        // and store the result globally, so the monitor can see it.
-        kChildIsReady = msg[0] == 'O' && msg[1] == 'K';
</del><ins>+        m_mainLoop = adoptGRef(g_main_loop_new(nullptr, FALSE));
+        m_proxy = adoptGRef(bus->createProxy("org.webkit.gtk.AccessibilityTest", "/org/webkit/gtk/AccessibilityTest", "org.webkit.gtk.AccessibilityTest", m_mainLoop.get()));
</ins><span class="cx">     }
</span><del>-    g_io_channel_unref(ioChannel);
-    close(childStdout);
</del><span class="cx"> 
</span><del>-    // The timeout was reached and the server is not ready yet, so
-    // stop it inmediately, and let the unit tests fail.
-    if (!kChildIsReady)
-        stopTestServer();
-}
</del><ins>+    GPid m_childProcessID { 0 };
+    GRefPtr<GDBusProxy> m_proxy;
+    GRefPtr<GMainLoop> m_mainLoop;
+    AtspiAccessible* m_eventSource { nullptr };
+};
</ins><span class="cx"> 
</span><del>-static void checkAtspiAccessible(AtspiAccessible* accessible, const char* targetName, AtspiRole targetRole)
</del><ins>+static void testAtspiBasicHierarchy(AccessibilityTest* test, gconstpointer)
</ins><span class="cx"> {
</span><del>-    g_assert_true(ATSPI_IS_ACCESSIBLE(accessible));
</del><ins>+    test->loadHTMLAndWaitUntilFinished(
+        "<html>"
+        "  <body>"
+        "   <h1>This is a test</h1>"
+        "   <p>This is a paragraph with some plain text.</p>"
+        "   <p>This paragraph contains <a href=\"http://www.webkitgtk.org\">a link</a> in the middle.</p>"
+        "  </body>"
+        "</html>",
+        nullptr);
</ins><span class="cx"> 
</span><del>-    GUniquePtr<char> name(atspi_accessible_get_name(accessible, 0));
-    g_assert_cmpstr(targetName, ==, name.get());
-    g_assert_cmpint(targetRole, ==, atspi_accessible_get_role(accessible, 0));
-}
</del><ins>+    auto testServerApp = test->findTestServerApplication();
+    g_assert_true(ATSPI_IS_ACCESSIBLE(testServerApp.get()));
+    GUniquePtr<char> name(atspi_accessible_get_name(testServerApp.get(), nullptr));
+    g_assert_cmpstr(name.get(), ==, "AccessibilityTestServer");
+    g_assert_cmpint(atspi_accessible_get_role(testServerApp.get(), nullptr), ==, ATSPI_ROLE_APPLICATION);
</ins><span class="cx"> 
</span><del>-static GRefPtr<AtspiAccessible> findTestServerApplication()
-{
-    // Only one desktop is supported by ATSPI at the moment.
-    GRefPtr<AtspiAccessible> desktop = adoptGRef(atspi_get_desktop(0));
</del><ins>+    auto rootObject = test->findRootObject(testServerApp.get());
+    g_assert_true(ATSPI_IS_ACCESSIBLE(rootObject.get()));
+    g_assert_cmpint(atspi_accessible_get_role(rootObject.get(), nullptr), ==, ATSPI_ROLE_FILLER);
</ins><span class="cx"> 
</span><del>-    // Look for the server application in the list of apps.
-    GRefPtr<AtspiAccessible> current;
-    int childCount = atspi_accessible_get_child_count(desktop.get(), 0);
-    for (int i = 0; i < childCount; i++) {
-        current = adoptGRef(atspi_accessible_get_child_at_index(desktop.get(), i, 0));
-        if (!g_strcmp0(atspi_accessible_get_name(current.get(), 0), kTestServerAppName))
-            return current;
-    }
</del><ins>+    auto scrollView = adoptGRef(atspi_accessible_get_child_at_index(rootObject.get(), 0, nullptr));
+    g_assert_true(ATSPI_IS_ACCESSIBLE(scrollView.get()));
+    g_assert_cmpint(atspi_accessible_get_role(scrollView.get(), nullptr), ==, ATSPI_ROLE_SCROLL_PANE);
</ins><span class="cx"> 
</span><del>-    return 0;
-}
</del><ins>+    auto documentWeb = adoptGRef(atspi_accessible_get_child_at_index(scrollView.get(), 0, nullptr));
+    g_assert_true(ATSPI_IS_ACCESSIBLE(documentWeb.get()));
+    g_assert_cmpint(atspi_accessible_get_role(documentWeb.get(), nullptr), ==, ATSPI_ROLE_DOCUMENT_WEB);
</ins><span class="cx"> 
</span><del>-static void testAtspiBasicHierarchy(WebViewTest* test, gconstpointer)
-{
-    // The test server's accessibility object (UI Process).
-    GRefPtr<AtspiAccessible> testServerApp = findTestServerApplication();
-    g_assert_true(ATSPI_IS_ACCESSIBLE(testServerApp.get()));
-    checkAtspiAccessible(testServerApp.get(), "AccessibilityTestServer", ATSPI_ROLE_APPLICATION);
</del><ins>+    auto h1 = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 0, nullptr));
+    g_assert_true(ATSPI_IS_ACCESSIBLE(h1.get()));
+    name.reset(atspi_accessible_get_name(h1.get(), nullptr));
+    g_assert_cmpstr(name.get(), ==, "This is a test");
+    g_assert_cmpint(atspi_accessible_get_role(h1.get(), nullptr), ==, ATSPI_ROLE_HEADING);
</ins><span class="cx"> 
</span><del>-    // The main window's accessibility object (UI Process).
-    GRefPtr<AtspiAccessible> currentParent = testServerApp;
-    GRefPtr<AtspiAccessible> currentChild = adoptGRef(atspi_accessible_get_child_at_index(currentParent.get(), 0, 0));
-    g_assert_true(ATSPI_IS_ACCESSIBLE(currentChild.get()));
-    checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_FRAME);
</del><ins>+    auto p1 = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 1, nullptr));
+    g_assert_true(ATSPI_IS_ACCESSIBLE(p1.get()));
+    g_assert_cmpint(atspi_accessible_get_role(p1.get(), nullptr), ==, ATSPI_ROLE_PARAGRAPH);
</ins><span class="cx"> 
</span><del>-    // The WebView's accessibility object (UI Process).
-    currentParent = currentChild;
-    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
-    g_assert_true(ATSPI_IS_ACCESSIBLE(currentChild.get()));
-    checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_FILLER);
</del><ins>+    auto p2 = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 2, nullptr));
+    g_assert_true(ATSPI_IS_ACCESSIBLE(p2.get()));
+    g_assert_cmpint(atspi_accessible_get_role(p2.get(), nullptr), ==, ATSPI_ROLE_PARAGRAPH);
</ins><span class="cx"> 
</span><del>-    // The WebPage's accessibility object (Web Process).
-    currentParent = currentChild;
-    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
-    g_assert_true(ATSPI_IS_ACCESSIBLE(currentChild.get()));
-    checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_FILLER);
</del><ins>+    auto link = adoptGRef(atspi_accessible_get_child_at_index(p2.get(), 0, nullptr));
+    g_assert_true(ATSPI_IS_ACCESSIBLE(link.get()));
+    name.reset(atspi_accessible_get_name(link.get(), nullptr));
+    g_assert_cmpstr(name.get(), ==, "a link");
+    g_assert_cmpint(atspi_accessible_get_role(link.get(), nullptr), ==, ATSPI_ROLE_LINK);
</ins><span class="cx"> 
</span><del>-    // HTML root element's accessible element (Web Process).
-    currentParent = currentChild;
-    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
-    g_assert_true(ATSPI_IS_ACCESSIBLE(currentChild.get()));
</del><ins>+    test->loadHTMLAndWaitUntilFinished(
+        "<html>"
+        "  <body>"
+        "   <h1>This is another test</h1>"
+        "   <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3AYWDTMVwnSZnwAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAFklEQVQI12P8z8DAwMDAxMDAwMDAAAANHQEDK+mmyAAAAABJRU5ErkJggg=='/>"
+        "  </body>"
+        "</html>",
+        nullptr);
</ins><span class="cx"> 
</span><del>-    // HTML body's accessible element (Web Process).
-    currentParent = currentChild;
-    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
-    g_assert_true(ATSPI_IS_ACCESSIBLE(currentChild.get()));
-    checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_DOCUMENT_WEB);
</del><ins>+    // Check that children-changed::remove is emitted on the root object on navigation,
+    // and the a11y hierarchy is updated.
+    test->waitUntilChildrenRemoved(rootObject.get());
</ins><span class="cx"> 
</span><del>-    // HTML H1's accessible element (Web Process).
-    currentParent = currentChild;
-    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
-    g_assert_true(ATSPI_IS_ACCESSIBLE(currentChild.get()));
-    checkAtspiAccessible(currentChild.get(), "This is a test", ATSPI_ROLE_HEADING);
</del><ins>+    documentWeb = test->findDocumentWeb(testServerApp.get());
+    g_assert_true(ATSPI_IS_ACCESSIBLE(documentWeb.get()));
+    g_assert_cmpint(atspi_accessible_get_role(documentWeb.get(), nullptr), ==, ATSPI_ROLE_DOCUMENT_WEB);
</ins><span class="cx"> 
</span><del>-    // HTML first paragraph's accessible element (Web Process).
-    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 1, 0);
-    g_assert_true(ATSPI_IS_ACCESSIBLE(currentChild.get()));
-    checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_PARAGRAPH);
</del><ins>+    h1 = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 0, nullptr));
+    g_assert_true(ATSPI_IS_ACCESSIBLE(h1.get()));
+    name.reset(atspi_accessible_get_name(h1.get(), nullptr));
+    g_assert_cmpstr(name.get(), ==, "This is another test");
+    g_assert_cmpint(atspi_accessible_get_role(h1.get(), nullptr), ==, ATSPI_ROLE_HEADING);
</ins><span class="cx"> 
</span><del>-    // HTML second paragraph's accessible element (Web Process).
-    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 2, 0);
-    g_assert_true(ATSPI_IS_ACCESSIBLE(currentChild.get()));
-    checkAtspiAccessible(currentChild.get(), "", ATSPI_ROLE_PARAGRAPH);
</del><ins>+    auto section = adoptGRef(atspi_accessible_get_child_at_index(documentWeb.get(), 1, nullptr));
+    g_assert_true(ATSPI_IS_ACCESSIBLE(section.get()));
+    g_assert_cmpint(atspi_accessible_get_role(section.get(), nullptr), ==, ATSPI_ROLE_SECTION);
</ins><span class="cx"> 
</span><del>-    // HTML link's accessible element (Web Process).
-    currentParent = currentChild;
-    currentChild = atspi_accessible_get_child_at_index(currentParent.get(), 0, 0);
-    g_assert_true(ATSPI_IS_ACCESSIBLE(currentChild.get()));
-    checkAtspiAccessible(currentChild.get(), "a link", ATSPI_ROLE_LINK);
</del><ins>+    auto img = adoptGRef(atspi_accessible_get_child_at_index(section.get(), 0, nullptr));
+    g_assert_true(ATSPI_IS_ACCESSIBLE(img.get()));
+    g_assert_cmpint(atspi_accessible_get_role(img.get(), nullptr), ==, ATSPI_ROLE_IMAGE);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void beforeAll()
</span><span class="cx"> {
</span><del>-    // We install a handler to ensure that we kill the child process
-    // if the parent dies because of whatever the reason is.
-    signal(SIGABRT, sigAbortHandler);
</del><ins>+    bus = new WebKitTestBus();
+    if (!bus->run())
+        return;
</ins><span class="cx"> 
</span><del>-    // Start the accessibility test server and load the tests.
-    startTestServer();
-    WebViewTest::add("WebKitAccessibility", "atspi-basic-hierarchy", testAtspiBasicHierarchy);
</del><ins>+    AccessibilityTest::add("WebKitAccessibility", "atspi-basic-hierarchy", testAtspiBasicHierarchy);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void afterAll()
</span><span class="cx"> {
</span><del>-    // Ensure we stop the server.
-    stopTestServer();
</del><ins>+    delete bus;
</ins><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>