Title: [96127] trunk
Revision
96127
Author
commit-qu...@webkit.org
Date
2011-09-27 10:29:46 -0700 (Tue, 27 Sep 2011)

Log Message

AXObjectCache cleared unnecessarily when non-top Document is detached.
https://bugs.webkit.org/show_bug.cgi?id=68636

Patch by Dominic Mazzoni <dmazz...@google.com> on 2011-09-27
Reviewed by Chris Fleizach.

Source/WebCore:

Test: accessibility/deleting-iframe-destroys-axcache.html

* dom/Document.cpp:
(WebCore::Document::attach):
(WebCore::Document::detach):

LayoutTests:

* accessibility/deleting-iframe-destroys-axcache.html: Added.
* platform/mac/accessibility/deleting-iframe-destroys-axcache-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (96126 => 96127)


--- trunk/LayoutTests/ChangeLog	2011-09-27 17:27:12 UTC (rev 96126)
+++ trunk/LayoutTests/ChangeLog	2011-09-27 17:29:46 UTC (rev 96127)
@@ -1,3 +1,13 @@
+2011-09-27  Dominic Mazzoni  <dmazz...@google.com>
+
+        AXObjectCache cleared unnecessarily when non-top Document is detached.
+        https://bugs.webkit.org/show_bug.cgi?id=68636
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/deleting-iframe-destroys-axcache.html: Added.
+        * platform/mac/accessibility/deleting-iframe-destroys-axcache-expected.txt: Added.
+
 2011-09-26  Ryosuke Niwa  <rn...@webkit.org>
 
         dump-as-markup conversion: editing/pasteboard/merge-end-list.html and merge-end-table.html

Added: trunk/LayoutTests/accessibility/deleting-iframe-destroys-axcache.html (0 => 96127)


--- trunk/LayoutTests/accessibility/deleting-iframe-destroys-axcache.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/deleting-iframe-destroys-axcache.html	2011-09-27 17:29:46 UTC (rev 96127)
@@ -0,0 +1,107 @@
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+
+  <script>
+    if (window.layoutTestController)
+        layoutTestController.waitUntilDone();
+
+    function buildAccessibilityTree(accessibilityObject, indent) {
+        var str = "";
+        for (var i = 0; i < indent; i++)
+            str += "    ";
+        str += accessibilityObject.role;
+        str += " " + accessibilityObject.stringValue;
+
+        if (accessibilityObject.role == '')
+            str += accessibilityObject.allAttributes();
+
+        str += "\n";
+        document.getElementById("console").innerText += str;
+
+        if (accessibilityObject.stringValue.indexOf('End of test') >= 0)
+            return false;
+
+        var count = accessibilityObject.childrenCount;
+        for (var i = 0; i < count; ++i) {
+            if (!buildAccessibilityTree(accessibilityObject.childAtIndex(i), indent + 1))
+                return false;
+        }
+
+        return true;
+    }
+
+    function runTest()
+    {
+        description("This tests that deleting an iframe doesn't cause the accessibility cache to be destroyed and recreated.");
+
+        if (window.accessibilityController) {
+            window.root = accessibilityController.rootElement;
+            window.body = root.childAtIndex(0);
+            window.before = body.childAtIndex(0).childAtIndex(0);
+            window.iframe = body.childAtIndex(1).childAtIndex(0);
+            window.after = body.childAtIndex(2).childAtIndex(0);
+
+            window.frameBody = window.iframe.childAtIndex(0);
+            window.frameBodyRole = window.frameBody.role;
+            window.frameGroup = window.frameBody.childAtIndex(0);
+            window.frameGroupRole = window.frameGroup.role;
+            window.frameButton = window.frameGroup.childAtIndex(0);
+            window.frameButtonRole = window.frameButton.role;
+
+            document.getElementById("console").innerText += "\nBefore:\n";
+            buildAccessibilityTree(root, 0);
+
+            // Remove the iframe.
+            document.body.removeChild(document.getElementById("iframe"));
+
+            window.newRoot = accessibilityController.rootElement;
+            window.newBody = newRoot.childAtIndex(0);
+            window.newBefore = newBody.childAtIndex(0).childAtIndex(0);
+            window.newAfter = newBody.childAtIndex(1).childAtIndex(0);
+
+            document.getElementById("console").innerText += "\nAfter:\n";
+            buildAccessibilityTree(newRoot, 0);
+            document.getElementById("console").innerText += "\n";
+
+            // Make sure that the accessibility objects from the iframe's nodes
+            // are now invalid by checking that their role is changed - this
+            // is because they've been deleted.
+            shouldBeFalse("frameBodyRole == frameBody.role");
+            shouldBeFalse("frameGroupRole == frameGroup.role");
+            shouldBeFalse("frameButtonRole == frameButton.role");
+
+            // Make sure that the other nodes are unchanged.
+            shouldBeTrue("root.isEqual(newRoot)");
+            shouldBeTrue("body.isEqual(newBody)");
+            shouldBeTrue("before.isEqual(newBefore)");
+            shouldBeTrue("after.isEqual(newAfter)");
+        }
+
+        debug('<br /><span class="pass">TEST COMPLETE</span>');
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    }
+    
+    window.addEventListener('load', function() {
+        setTimeout(runTest, 10);
+    }, false);
+    
+  </script>
+</head>
+<body>
+
+<p>Before</p>
+
+<iframe id="iframe" src="" me</button></body>"></iframe>
+
+<p>After</p>
+
+<p>End of test</p>
+
+<p id="description"></p>
+<div id="console"></div>
+
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac/accessibility/deleting-iframe-destroys-axcache-expected.txt (0 => 96127)


--- trunk/LayoutTests/platform/mac/accessibility/deleting-iframe-destroys-axcache-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/deleting-iframe-destroys-axcache-expected.txt	2011-09-27 17:29:46 UTC (rev 96127)
@@ -0,0 +1,47 @@
+Before
+
+After
+
+End of test
+
+This tests that deleting an iframe doesn't cause the accessibility cache to be destroyed and recreated.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Before:
+AXRole: AXScrollArea 
+    AXRole: AXWebArea AXValue: 
+        AXRole: AXGroup AXValue: 
+            AXRole: AXStaticText AXValue: Before
+        AXRole: AXGroup AXValue: 
+            AXRole: AXScrollArea 
+                AXRole: AXWebArea AXValue: 
+                    AXRole: AXGroup AXValue: 
+                        AXRole: AXButton AXValue: 
+        AXRole: AXGroup AXValue: 
+            AXRole: AXStaticText AXValue: After
+        AXRole: AXGroup AXValue: 
+            AXRole: AXStaticText AXValue: End of test
+
+After:
+AXRole: AXScrollArea 
+    AXRole: AXWebArea AXValue: 
+        AXRole: AXGroup AXValue: 
+            AXRole: AXStaticText AXValue: Before
+        AXRole: AXGroup AXValue: 
+            AXRole: AXStaticText AXValue: After
+        AXRole: AXGroup AXValue: 
+            AXRole: AXStaticText AXValue: End of test
+
+PASS frameBodyRole == frameBody.role is false
+PASS frameGroupRole == frameGroup.role is false
+PASS frameButtonRole == frameButton.role is false
+PASS root.isEqual(newRoot) is true
+PASS body.isEqual(newBody) is true
+PASS before.isEqual(newBefore) is true
+PASS after.isEqual(newAfter) is true
+
+TEST COMPLETE
+

Modified: trunk/Source/WebCore/ChangeLog (96126 => 96127)


--- trunk/Source/WebCore/ChangeLog	2011-09-27 17:27:12 UTC (rev 96126)
+++ trunk/Source/WebCore/ChangeLog	2011-09-27 17:29:46 UTC (rev 96127)
@@ -1,3 +1,16 @@
+2011-09-27  Dominic Mazzoni  <dmazz...@google.com>
+
+        AXObjectCache cleared unnecessarily when non-top Document is detached.
+        https://bugs.webkit.org/show_bug.cgi?id=68636
+
+        Reviewed by Chris Fleizach.
+
+        Test: accessibility/deleting-iframe-destroys-axcache.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::attach):
+        (WebCore::Document::detach):
+
 2011-09-27  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r96108, r96111, r96113, and r96116.

Modified: trunk/Source/WebCore/dom/Document.cpp (96126 => 96127)


--- trunk/Source/WebCore/dom/Document.cpp	2011-09-27 17:27:12 UTC (rev 96126)
+++ trunk/Source/WebCore/dom/Document.cpp	2011-09-27 17:29:46 UTC (rev 96127)
@@ -1801,7 +1801,7 @@
 {
     ASSERT(!attached());
     ASSERT(!m_inPageCache);
-    ASSERT(!m_axObjectCache);
+    ASSERT(!m_axObjectCache || this != topDocument());
 
     if (!m_renderArena)
         m_renderArena = adoptPtr(new RenderArena);
@@ -1827,7 +1827,9 @@
     ASSERT(attached());
     ASSERT(!m_inPageCache);
 
-    clearAXObjectCache();
+    if (this == topDocument())
+        clearAXObjectCache();
+
     stopActiveDOMObjects();
     m_eventQueue->close();
 #if ENABLE(FULLSCREEN_API)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to