⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 112023 in webkit


Ignore:
Timestamp:
Mar 24, 2012, 9:24:36 PM (15 years ago)
Author:
jpfau@apple.com
Message:

XML error document creation should not fire mutation events
​https://bugs.webkit.org/show_bug.cgi?id=80765

Reviewed by Adam Barth.

Source/WebCore:

Broke two tests that expected the old behavior, which have now been updated.

  • xml/XMLErrors.cpp:

(WebCore::createXHTMLParserErrorHeader):
(WebCore::XMLErrors::insertErrorMessageBlock):

LayoutTests:

Fixed tests that relied on old behavior.

  • fast/css/stylesheet-candidate-nodes-crash-expected.txt:
  • fast/css/stylesheet-candidate-nodes-crash.xhtml:
  • fast/dom/xml-parser-error-message-crash-expected.txt:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r112022 r112023  
     12012-03-24  Jeffrey Pfau  <jpfau@apple.com>
     2
     3        XML error document creation should not fire mutation events
     4        https://bugs.webkit.org/show_bug.cgi?id=80765
     5
     6        Reviewed by Adam Barth.
     7
     8        Fixed tests that relied on old behavior.
     9
     10        * fast/css/stylesheet-candidate-nodes-crash-expected.txt:
     11        * fast/css/stylesheet-candidate-nodes-crash.xhtml:
     12        * fast/dom/xml-parser-error-message-crash-expected.txt:
     13
    1142012-03-24  Florin Malita  <fmalita@google.com>
    215
  • trunk/LayoutTests/fast/css/stylesheet-candidate-nodes-crash-expected.txt

    r77262 r112023  
    1 This page contains the following errors:
    2 
    3 error on line 29 at column 9: Comment not terminated
    4 error on line 32 at column 1: Comment not terminated
    5 Below is a rendering of the page up to the first error.
    6 
    71PASS
  • trunk/LayoutTests/fast/css/stylesheet-candidate-nodes-crash.xhtml

    r77262 r112023  
    88                    layoutTestController.waitUntilDone();
    99                }
    10                
     10
    1111                function runTest()
    1212                {
    1313                    document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'style')[0];
    14                     if (document.body)
     14                    if (document.body) {
    1515                        document.body.innerHTML = "PASS";
    16                    
    17                     if (window.layoutTestController)
    18                         layoutTestController.notifyDone();
     16                        if (window.layoutTestController)
     17                            layoutTestController.notifyDone();
     18                    }
    1919                }
    2020            </script>
    2121            <svg:style>
    2222                <xht:caption>
    23                     <xht:iframe onload="runTest();"></xht:iframe>             
     23                    <xht:iframe onload="runTest();"></xht:iframe>
    2424                    <style></style>
    2525                </xht:caption>
  • trunk/LayoutTests/fast/dom/xml-parser-error-message-crash-expected.txt

    r87737 r112023  
    1 PASS
     1This page contains the following errors:
     2
     3error on line 14 at column 1: Extra content at the end of the document
     4Below is a rendering of the page up to the first error.
     5
     6
  • trunk/Source/WebCore/ChangeLog

    r112022 r112023  
     12012-03-24  Jeffrey Pfau  <jpfau@apple.com>
     2
     3        XML error document creation should not fire mutation events
     4        https://bugs.webkit.org/show_bug.cgi?id=80765
     5
     6        Reviewed by Adam Barth.
     7
     8        Broke two tests that expected the old behavior, which have now been updated.
     9
     10        * xml/XMLErrors.cpp:
     11        (WebCore::createXHTMLParserErrorHeader):
     12        (WebCore::XMLErrors::insertErrorMessageBlock):
     13
    1142012-03-24  Florin Malita  <fmalita@google.com>
    215
  • trunk/Source/WebCore/xml/XMLErrors.cpp

    r95901 r112023  
    8888}
    8989
    90 static inline RefPtr<Element> createXHTMLParserErrorHeader(Document* doc, const String& errorMessages)
     90static inline PassRefPtr<Element> createXHTMLParserErrorHeader(Document* doc, const String& errorMessages)
    9191{
    92     RefPtr<Element> reportElement = doc->createElement(QualifiedName(nullAtom, "parsererror", xhtmlNamespaceURI), false);
    93     reportElement->setAttribute(styleAttr, "display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black");
     92    RefPtr<Element> reportElement = doc->createElement(QualifiedName(nullAtom, "parsererror", xhtmlNamespaceURI), true);
    9493
    95     ExceptionCode ec = 0;
    96     RefPtr<Element> h3 = doc->createElement(h3Tag, false);
    97     reportElement->appendChild(h3.get(), ec);
    98     h3->appendChild(doc->createTextNode("This page contains the following errors:"), ec);
     94    OwnPtr<AttributeVector> reportAttributes = AttributeVector::create();
     95    reportAttributes->append(Attribute::create(styleAttr, "display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black"));
     96    reportElement->parserSetAttributes(reportAttributes.release(), FragmentScriptingNotAllowed);
    9997
    100     RefPtr<Element> fixed = doc->createElement(divTag, false);
    101     reportElement->appendChild(fixed.get(), ec);
    102     fixed->setAttribute(styleAttr, "font-family:monospace;font-size:12px");
    103     fixed->appendChild(doc->createTextNode(errorMessages), ec);
     98    RefPtr<Element> h3 = doc->createElement(h3Tag, true);
     99    reportElement->parserAddChild(h3.get());
     100    h3->parserAddChild(doc->createTextNode("This page contains the following errors:"));
    104101
    105     h3 = doc->createElement(h3Tag, false);
    106     reportElement->appendChild(h3.get(), ec);
    107     h3->appendChild(doc->createTextNode("Below is a rendering of the page up to the first error."), ec);
     102    RefPtr<Element> fixed = doc->createElement(divTag, true);
     103    OwnPtr<AttributeVector> fixedAttributes = AttributeVector::create();
     104    fixedAttributes->append(Attribute::create(styleAttr, "font-family:monospace;font-size:12px"));
     105    fixed->parserSetAttributes(fixedAttributes.release(), FragmentScriptingNotAllowed);
     106    reportElement->parserAddChild(fixed.get());
    108107
    109     return reportElement;
     108    fixed->parserAddChild(doc->createTextNode(errorMessages));
     109
     110    h3 = doc->createElement(h3Tag, true);
     111    reportElement->parserAddChild(h3.get());
     112    h3->parserAddChild(doc->createTextNode("Below is a rendering of the page up to the first error."));
     113
     114    return reportElement.release();
    110115}
    111116
    … …  
    117122
    118123    // Create elements for display
    119     ExceptionCode ec = 0;
    120124    RefPtr<Element> documentElement = m_document->documentElement();
    121125    if (!documentElement) {
    122         RefPtr<Element> rootElement = m_document->createElement(htmlTag, false);
    123         m_document->appendChild(rootElement, ec);
    124         RefPtr<Element> body = m_document->createElement(bodyTag, false);
    125         rootElement->appendChild(body, ec);
     126        RefPtr<Element> rootElement = m_document->createElement(htmlTag, true);
     127        RefPtr<Element> body = m_document->createElement(bodyTag, true);
     128        rootElement->parserAddChild(body);
     129        m_document->parserAddChild(rootElement);
     130        if (m_document->attached() && !rootElement->attached())
     131            rootElement->attach();
    126132        documentElement = body.get();
    127133    }
    128134#if ENABLE(SVG)
    129135    else if (documentElement->namespaceURI() == SVGNames::svgNamespaceURI) {
    130         RefPtr<Element> rootElement = m_document->createElement(htmlTag, false);
    131         RefPtr<Element> body = m_document->createElement(bodyTag, false);
    132         rootElement->appendChild(body, ec);
    133         body->appendChild(documentElement, ec);
    134         m_document->appendChild(rootElement.get(), ec);
     136        RefPtr<Element> rootElement = m_document->createElement(htmlTag, true);
     137        RefPtr<Element> body = m_document->createElement(bodyTag, true);
     138        rootElement->parserAddChild(body);
     139
     140        documentElement->parentNode()->parserRemoveChild(documentElement.get());
     141        if (documentElement->attached())
     142            documentElement->detach();
     143
     144        body->parserAddChild(documentElement);
     145        m_document->parserAddChild(rootElement.get());
     146
     147        if (m_document->attached()) {
     148            // rootElement shouldn't be attached right now, but in some cases might be.
     149            // See https://bugs.webkit.org/show_bug.cgi?id=81985
     150            rootElement->reattach();
     151        }
     152
    135153        documentElement = body.get();
    136154    }
    137155#endif
     156
    138157    String errorMessages = m_errorMessages.toString();
    139158    RefPtr<Element> reportElement = createXHTMLParserErrorHeader(m_document, errorMessages);
    140     documentElement->insertBefore(reportElement, documentElement->firstChild(), ec);
     159
    141160#if ENABLE(XSLT)
    142161    if (m_document->transformSourceDocument()) {
    143         RefPtr<Element> paragraph = m_document->createElement(pTag, false);
    144         paragraph->setAttribute(styleAttr, "white-space: normal");
    145         paragraph->appendChild(m_document->createTextNode("This document was created as the result of an XSL transformation. The line and column numbers given are from the transformed result."), ec);
    146         reportElement->appendChild(paragraph.release(), ec);
     162        OwnPtr<AttributeVector> attributes = AttributeVector::create();
     163        attributes->append(Attribute::create(styleAttr, "white-space: normal"));
     164        RefPtr<Element> paragraph = m_document->createElement(pTag, true);
     165        paragraph->parserSetAttributes(attributes.release(), FragmentScriptingNotAllowed);
     166        paragraph->parserAddChild(m_document->createTextNode("This document was created as the result of an XSL transformation. The line and column numbers given are from the transformed result."));
     167        reportElement->parserAddChild(paragraph.release());
    147168    }
    148169#endif
     170
     171    Node* firstChild = documentElement->firstChild();
     172    if (firstChild)
     173        documentElement->parserInsertBefore(reportElement, documentElement->firstChild());
     174    else
     175        documentElement->parserAddChild(reportElement);
     176
     177    if (documentElement->attached() && !reportElement->attached())
     178        reportElement->attach();
     179
    149180    m_document->updateStyleIfNeeded();
    150181}
Note: See TracChangeset for help on using the changeset viewer.