REGRESSION(r160182): Fragment parser doesn't close a form element with a close tag
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 14 Dec 2014 10:58:56 +0000 (10:58 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 14 Dec 2014 10:58:56 +0000 (10:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=139561

Reviewed by Darin Adler.

Source/WebCore:

The bug was caused by us not setting the form pointer in insertHTMLFormElement.
Since we already avoid associating a form inside HTMLConstructionSite::createHTMLElement,
we didn't need this code at all.

Fixed the bug by partially reverting r160182.

Test: fast/dom/dom-parse-close-form.html

* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::insertHTMLFormElement):
(WebCore::HTMLConstructionSite::insideTemplateElement): Deleted.
* html/parser/HTMLConstructionSite.h:

LayoutTests:

Added a regression test.

* fast/dom/dom-parse-close-form-expected.txt: Added.
* fast/dom/dom-parse-close-form.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/dom-parse-close-form-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/dom-parse-close-form.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/parser/HTMLConstructionSite.cpp
Source/WebCore/html/parser/HTMLConstructionSite.h

index 80656e09414238d0efa36a28a47d634f9ac2dbda..d22a688ab20f918a5b22055bfe4caff7a7174a20 100644 (file)
@@ -1,3 +1,15 @@
+2014-12-14  Ryosuke Niwa  <rniwa@webkit.org>
+
+        REGRESSION(r160182): Fragment parser doesn't close a form element with a close tag
+        https://bugs.webkit.org/show_bug.cgi?id=139561
+
+        Reviewed by Darin Adler.
+
+        Added a regression test.
+
+        * fast/dom/dom-parse-close-form-expected.txt: Added.
+        * fast/dom/dom-parse-close-form.html: Added.
+
 2014-12-13  Zalan Bujtas  <zalan@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=139597
diff --git a/LayoutTests/fast/dom/dom-parse-close-form-expected.txt b/LayoutTests/fast/dom/dom-parse-close-form-expected.txt
new file mode 100644 (file)
index 0000000..84d622f
--- /dev/null
@@ -0,0 +1,10 @@
+This tests that DOMParser closes a form element when it sees its close tag.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS (new DOMParser()).parseFromString("<form></form>text", "text/html").body.innerHTML is "<form></form>text"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/dom-parse-close-form.html b/LayoutTests/fast/dom/dom-parse-close-form.html
new file mode 100644 (file)
index 0000000..4d76241
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<script>
+
+description('This tests that DOMParser closes a form element when it sees its close tag.');
+
+shouldBeEqualToString('(new DOMParser()).parseFromString("<form></form>text", "text/html").body.innerHTML', '<form></form>text');
+
+var successfullyParsed = true;
+
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index 502af2dac61953ab2b88b9d02c612cdbd7e8f437..701ab79d8c81d9b4c81ccfa59113cd9f78d6ad08 100644 (file)
@@ -1,3 +1,23 @@
+2014-12-14  Ryosuke Niwa  <rniwa@webkit.org>
+
+        REGRESSION(r160182): Fragment parser doesn't close a form element with a close tag
+        https://bugs.webkit.org/show_bug.cgi?id=139561
+
+        Reviewed by Darin Adler.
+
+        The bug was caused by us not setting the form pointer in insertHTMLFormElement.
+        Since we already avoid associating a form inside HTMLConstructionSite::createHTMLElement,
+        we didn't need this code at all.
+
+        Fixed the bug by partially reverting r160182.
+
+        Test: fast/dom/dom-parse-close-form.html
+
+        * html/parser/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::insertHTMLFormElement):
+        (WebCore::HTMLConstructionSite::insideTemplateElement): Deleted.
+        * html/parser/HTMLConstructionSite.h:
+
 2014-12-14  Andreas Kling  <akling@apple.com>
 
         Fix build even more. Not a strong performance here.
index ff4066e3ca102083fa08d285ad70d0333b0d462e..8d63b2bea08b2cb4beaf6576c012853f98fd5090 100644 (file)
@@ -459,12 +459,10 @@ void HTMLConstructionSite::insertHTMLFormElement(AtomicHTMLToken* token, bool is
 {
     RefPtr<Element> element = createHTMLElement(token);
     ASSERT(is<HTMLFormElement>(*element));
-    RefPtr<HTMLFormElement> form = static_pointer_cast<HTMLFormElement>(element.release());
-    if (!insideTemplateElement())
-        m_form = form;
-    form->setDemoted(isDemoted);
-    attachLater(currentNode(), form);
-    m_openElements.push(HTMLStackItem::create(form.release(), token));
+    m_form = static_pointer_cast<HTMLFormElement>(element.release());
+    m_form->setDemoted(isDemoted);
+    attachLater(currentNode(), m_form);
+    m_openElements.push(HTMLStackItem::create(m_form, token));
 }
 
 void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken* token)
@@ -624,11 +622,6 @@ inline Document& HTMLConstructionSite::ownerDocumentForCurrentNode()
     return currentNode()->document();
 }
 
-inline bool HTMLConstructionSite::insideTemplateElement()
-{
-    return !ownerDocumentForCurrentNode().frame();
-}
-
 PassRefPtr<Element> HTMLConstructionSite::createHTMLElement(AtomicHTMLToken* token)
 {
     QualifiedName tagName(nullAtom, token->name(), xhtmlNamespaceURI);
index ebc673eb62595cc73146820b911bbde4f40f3fa2..36adf2b2f156327d54f9ab842f7c62460effc601 100644 (file)
@@ -144,7 +144,6 @@ public:
     HTMLStackItem* currentStackItem() const { return m_openElements.topStackItem(); }
     HTMLStackItem* oneBelowTop() const { return m_openElements.oneBelowTop(); }
     Document& ownerDocumentForCurrentNode();
-    bool insideTemplateElement();
     HTMLElementStack* openElements() const { return &m_openElements; }
     HTMLFormattingElementList* activeFormattingElements() const { return &m_activeFormattingElements; }
     bool currentIsRootNode() { return m_openElements.topNode() == m_openElements.rootNode(); }