Unstyled XML viewer crashes when XML contains an element with id="tree"
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 2 Jun 2013 08:14:48 +0000 (08:14 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 2 Jun 2013 08:14:48 +0000 (08:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117117
<rdar://problem/13727267>

Reviewed by Darin Adler.

Source/WebCore:

Test: http/tests/xmlviewer/dumpAsText/existing-tree-element-crash.xml

* xml/XMLViewer.css: Removed the rule to hide source document, as we no longer
keep it in the tree.

* xml/XMLViewer.js:
(prepareWebKitXMLViewer): Make sourceXML a detached tree, as otherwise it can
have ID conflicts with elements we add.
(sourceXMLLoaded): Removed some commented out code. Removed code that was checking
whether an extension took over XML display, as it makes no sense to duplicate this
functionality in an extension.

LayoutTests:

* http/tests/xmlviewer/dumpAsText/existing-tree-element-crash-expected.txt: Added.
* http/tests/xmlviewer/dumpAsText/existing-tree-element-crash.xml: Added.

* xmlviewer: Removed.
* xmlviewer/extensions-api-expected.txt: Removed.
* xmlviewer/extensions-api.html: Removed.
* xmlviewer/resources: Removed.
* xmlviewer/resources/sample.xml: Removed.
The "API" no longer exists.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/xmlviewer/dumpAsText/existing-tree-element-crash-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlviewer/dumpAsText/existing-tree-element-crash.xml [new file with mode: 0644]
LayoutTests/xmlviewer/extensions-api-expected.txt [deleted file]
LayoutTests/xmlviewer/extensions-api.html [deleted file]
LayoutTests/xmlviewer/resources/sample.xml [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/xml/XMLViewer.css
Source/WebCore/xml/XMLViewer.js

index bd9ba83..08f3502 100644 (file)
@@ -1,3 +1,21 @@
+2013-06-02  Alexey Proskuryakov  <ap@apple.com>
+
+        Unstyled XML viewer crashes when XML contains an element with id="tree"
+        https://bugs.webkit.org/show_bug.cgi?id=117117
+        <rdar://problem/13727267>
+
+        Reviewed by Darin Adler.
+
+        * http/tests/xmlviewer/dumpAsText/existing-tree-element-crash-expected.txt: Added.
+        * http/tests/xmlviewer/dumpAsText/existing-tree-element-crash.xml: Added.
+
+        * xmlviewer: Removed.
+        * xmlviewer/extensions-api-expected.txt: Removed.
+        * xmlviewer/extensions-api.html: Removed.
+        * xmlviewer/resources: Removed.
+        * xmlviewer/resources/sample.xml: Removed.
+        The "API" no longer exists.
+
 2013-06-01  Chris Fleizach  <cfleizach@apple.com>
 
         WebKit ignores aria-hidden when traversing nodes for name calculation
diff --git a/LayoutTests/http/tests/xmlviewer/dumpAsText/existing-tree-element-crash-expected.txt b/LayoutTests/http/tests/xmlviewer/dumpAsText/existing-tree-element-crash-expected.txt
new file mode 100644 (file)
index 0000000..bae34f5
--- /dev/null
@@ -0,0 +1,4 @@
+This XML file does not appear to have any style information associated with it. The document tree is shown below.
+<INTERFACE>
+<OBJECT id="tree"/>
+</INTERFACE>
diff --git a/LayoutTests/http/tests/xmlviewer/dumpAsText/existing-tree-element-crash.xml b/LayoutTests/http/tests/xmlviewer/dumpAsText/existing-tree-element-crash.xml
new file mode 100644 (file)
index 0000000..471be60
--- /dev/null
@@ -0,0 +1,3 @@
+<INTERFACE>
+<OBJECT id="tree"/>
+</INTERFACE>
diff --git a/LayoutTests/xmlviewer/extensions-api-expected.txt b/LayoutTests/xmlviewer/extensions-api-expected.txt
deleted file mode 100644 (file)
index 62a433a..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-Tests extensions hooks in xml viewer.
-
-SUCCESS
diff --git a/LayoutTests/xmlviewer/extensions-api.html b/LayoutTests/xmlviewer/extensions-api.html
deleted file mode 100644 (file)
index 3866cf1..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<html>
-<head>
-    <script>
-        if (window.testRunner) {
-           testRunner.dumpAsText();
-           testRunner.setCanOpenWindows();
-           testRunner.waitUntilDone();
-        }
-
-        var xmlWindow;
-
-        function print(str)
-        {
-            document.getElementById('output').textContent = str;
-            xmlWindow.close();
-            testRunner.notifyDone();
-        }
-
-        function checkSourceXML()
-        {
-            var sourceXML = xmlWindow.document.getElementById('webkit-xml-viewer-source-xml');
-            if (sourceXML && sourceXML.firstChild.nodeName == 'root')
-                print('SUCCESS');
-            else
-                print('FAIL');
-        }
-
-        function onload()
-        {
-            xmlWindow = window.open('resources/sample.xml', "XMLViewerTestWindow");
-            xmlWindow.onAfterWebkitXMLViewerLoaded = checkSourceXML;
-        }
-
-    </script>
-</head>
-<body onload="onload();">
-    <p>Tests extensions hooks in xml viewer.</p>
-    <div id='output'></div>
-</body>
-</html>
diff --git a/LayoutTests/xmlviewer/resources/sample.xml b/LayoutTests/xmlviewer/resources/sample.xml
deleted file mode 100644 (file)
index f3f286e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-<root/>
index 0599f03..1f6799e 100644 (file)
@@ -1,3 +1,23 @@
+2013-06-02  Alexey Proskuryakov  <ap@apple.com>
+
+        Unstyled XML viewer crashes when XML contains an element with id="tree"
+        https://bugs.webkit.org/show_bug.cgi?id=117117
+        <rdar://problem/13727267>
+
+        Reviewed by Darin Adler.
+
+        Test: http/tests/xmlviewer/dumpAsText/existing-tree-element-crash.xml
+
+        * xml/XMLViewer.css: Removed the rule to hide source document, as we no longer
+        keep it in the tree.
+
+        * xml/XMLViewer.js:
+        (prepareWebKitXMLViewer): Make sourceXML a detached tree, as otherwise it can
+        have ID conflicts with elements we add.
+        (sourceXMLLoaded): Removed some commented out code. Removed code that was checking
+        whether an extension took over XML display, as it makes no sense to duplicate this
+        functionality in an extension.
+
 2013-06-01  Chris Fleizach  <cfleizach@apple.com>
 
         WebKit ignores aria-hidden when traversing nodes for name calculation
index f96b0b1..4032438 100644 (file)
@@ -43,10 +43,6 @@ div.collapsible > div.hidden {
     font-size: 13px;
 }
 
-#webkit-xml-viewer-source-xml {
-    display: none;
-}
-
 .collapsible-content {
     margin-left: 1em;
 }
index 8615984..1fda909 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -27,6 +28,7 @@
  */
 
 var nodeParentPairs = [];
+var sourceXML;
 
 // Script entry point.
 
@@ -40,9 +42,7 @@ function prepareWebKitXMLViewer(noStyleMessage)
     head.appendChild(style);
     var body = createHTMLElement('body');
     html.appendChild(body);
-    var sourceXML = createHTMLElement('div');
-    sourceXML.id = 'webkit-xml-viewer-source-xml';
-    body.appendChild(sourceXML);
+    sourceXML = createHTMLElement('div');
 
     var child;
     while (child = document.firstChild) {
@@ -69,12 +69,6 @@ function prepareWebKitXMLViewer(noStyleMessage)
 
 function sourceXMLLoaded()
 {
-    var sourceXML = document.getElementById('webkit-xml-viewer-source-xml');
-    if (!sourceXML)
-        return; // Stop if some XML tree extension is already processing this document
-    //var style = document.head.firstChild;
-    //document.head.removeChild(style);
-    //document.head.appendChild(style);
     var root = document.getElementById('tree');
 
     for (var child = sourceXML.firstChild; child; child = child.nextSibling)