Changeset 210767 in webkit


Ignore:
Timestamp:
Jan 14, 2017 9:35:56 AM (7 years ago)
Author:
Chris Dumez
Message:

Align the innerText setter with the HTML spec and Gecko
https://bugs.webkit.org/show_bug.cgi?id=160971

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebaseline several W3C tests now that more checks are passing.

  • web-platform-tests/domparsing/createContextualFragment-expected.txt:
  • web-platform-tests/innerText/setter-expected.txt:

Source/WebCore:

Align the innerText setter and createContextualFragment() with the
HTML specification and Gecko. In particular, they no longer throw
when the context element is a void element. This behavior was there
to match an old IE behavior but Edge dropped this behavior.

Test: fast/dom/br-set-outerText.html

  • dom/Element.cpp:
  • dom/Element.h:
  • editing/markup.cpp:

(WebCore::createContextualFragment):

  • html/HTMLElement.cpp:

(WebCore::HTMLElement::setInnerText):
(WebCore::HTMLElement::setOuterText):

LayoutTests:

Add test coverage for outerText, which is non-standard.

  • fast/dom/br-set-outerText-expected.txt: Added.
  • fast/dom/br-set-outerText.html: Added.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r210754 r210767  
     12017-01-14  Chris Dumez  <cdumez@apple.com>
     2
     3        Align the innerText setter with the HTML spec and Gecko
     4        https://bugs.webkit.org/show_bug.cgi?id=160971
     5
     6        Reviewed by Alex Christensen.
     7
     8        Add test coverage for outerText, which is non-standard.
     9
     10        * fast/dom/br-set-outerText-expected.txt: Added.
     11        * fast/dom/br-set-outerText.html: Added.
     12
    1132017-01-13  Ryan Haddad  <ryanhaddad@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r210751 r210767  
     12017-01-14  Chris Dumez  <cdumez@apple.com>
     2
     3        Align the innerText setter with the HTML spec and Gecko
     4        https://bugs.webkit.org/show_bug.cgi?id=160971
     5
     6        Reviewed by Alex Christensen.
     7
     8        Rebaseline several W3C tests now that more checks are passing.
     9
     10        * web-platform-tests/domparsing/createContextualFragment-expected.txt:
     11        * web-platform-tests/innerText/setter-expected.txt:
     12
    1132017-01-13  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/domparsing/createContextualFragment-expected.txt

    r210749 r210767  
    55PASS Don't auto-create <body> when applied to <html>
    66PASS <script>s should be run when appended to the document (but not before)
    7 FAIL createContextualFragment should work even when the context is <area> The operation is not supported.
    8 FAIL createContextualFragment should work even when the context is <base> The operation is not supported.
    9 FAIL createContextualFragment should work even when the context is <basefont> The operation is not supported.
     7PASS createContextualFragment should work even when the context is <area>
     8PASS createContextualFragment should work even when the context is <base>
     9PASS createContextualFragment should work even when the context is <basefont>
    1010PASS createContextualFragment should work even when the context is <bgsound>
    11 FAIL createContextualFragment should work even when the context is <br> The operation is not supported.
    12 FAIL createContextualFragment should work even when the context is <col> The operation is not supported.
    13 FAIL createContextualFragment should work even when the context is <embed> The operation is not supported.
    14 FAIL createContextualFragment should work even when the context is <frame> The operation is not supported.
    15 FAIL createContextualFragment should work even when the context is <hr> The operation is not supported.
    16 FAIL createContextualFragment should work even when the context is <img> The operation is not supported.
    17 FAIL createContextualFragment should work even when the context is <input> The operation is not supported.
     11PASS createContextualFragment should work even when the context is <br>
     12PASS createContextualFragment should work even when the context is <col>
     13PASS createContextualFragment should work even when the context is <embed>
     14PASS createContextualFragment should work even when the context is <frame>
     15PASS createContextualFragment should work even when the context is <hr>
     16PASS createContextualFragment should work even when the context is <img>
     17PASS createContextualFragment should work even when the context is <input>
    1818PASS createContextualFragment should work even when the context is <keygen>
    19 FAIL createContextualFragment should work even when the context is <link> The operation is not supported.
    20 FAIL createContextualFragment should work even when the context is <meta> The operation is not supported.
    21 FAIL createContextualFragment should work even when the context is <param> The operation is not supported.
    22 FAIL createContextualFragment should work even when the context is <source> The operation is not supported.
     19PASS createContextualFragment should work even when the context is <link>
     20PASS createContextualFragment should work even when the context is <meta>
     21PASS createContextualFragment should work even when the context is <param>
     22PASS createContextualFragment should work even when the context is <source>
    2323PASS createContextualFragment should work even when the context is <track>
    24 FAIL createContextualFragment should work even when the context is <wbr> The operation is not supported.
     24PASS createContextualFragment should work even when the context is <wbr>
    2525PASS createContextualFragment should work even when the context is <menuitem>
    26 FAIL createContextualFragment should work even when the context is <image> The operation is not supported.
     26PASS createContextualFragment should work even when the context is <image>
    2727PASS <html> and <body> must work the same, 1
    2828PASS <html> and <body> must work the same, 2
  • trunk/LayoutTests/imported/w3c/web-platform-tests/innerText/setter-expected.txt

    r210751 r210767  
     1abc
    12
    23PASS Simplest possible test
     
    2728PASS Assigning null
    2829PASS Assigning undefined
    29 FAIL innerText on <area> element The object can not be modified.
    30 FAIL innerText on <base> element The object can not be modified.
    31 FAIL innerText on <basefont> element The object can not be modified.
     30PASS innerText on <area> element
     31PASS innerText on <base> element
     32PASS innerText on <basefont> element
    3233PASS innerText on <bgsound> element
    33 FAIL innerText on <br> element The object can not be modified.
    34 FAIL innerText on <col> element The object can not be modified.
    35 FAIL innerText on <embed> element The object can not be modified.
    36 FAIL innerText on <frame> element The object can not be modified.
    37 FAIL innerText on <hr> element The object can not be modified.
    38 FAIL innerText on <image> element The object can not be modified.
    39 FAIL innerText on <img> element The object can not be modified.
    40 FAIL innerText on <input> element The object can not be modified.
     34PASS innerText on <br> element
     35PASS innerText on <col> element
     36PASS innerText on <embed> element
     37PASS innerText on <frame> element
     38PASS innerText on <hr> element
     39PASS innerText on <image> element
     40PASS innerText on <img> element
     41PASS innerText on <input> element
    4142PASS innerText on <keygen> element
    42 FAIL innerText on <link> element The object can not be modified.
     43PASS innerText on <link> element
    4344PASS innerText on <menuitem> element
    44 FAIL innerText on <meta> element The object can not be modified.
    45 FAIL innerText on <param> element The object can not be modified.
    46 FAIL innerText on <source> element The object can not be modified.
     45PASS innerText on <meta> element
     46PASS innerText on <param> element
     47PASS innerText on <source> element
    4748PASS innerText on <track> element
    48 FAIL innerText on <wbr> element The object can not be modified.
    49 FAIL innerText on <colgroup> element The object can not be modified.
    50 FAIL innerText on <frameset> element The object can not be modified.
    51 FAIL innerText on <head> element The object can not be modified.
    52 FAIL innerText on <html> element The object can not be modified.
    53 FAIL innerText on <table> element The object can not be modified.
    54 FAIL innerText on <tbody> element The object can not be modified.
    55 FAIL innerText on <tfoot> element The object can not be modified.
    56 FAIL innerText on <thead> element The object can not be modified.
    57 FAIL innerText on <tr> element The object can not be modified.
     49PASS innerText on <wbr> element
     50PASS innerText on <colgroup> element
     51PASS innerText on <frameset> element
     52PASS innerText on <head> element
     53PASS innerText on <html> element
     54PASS innerText on <table> element
     55PASS innerText on <tbody> element
     56PASS innerText on <tfoot> element
     57PASS innerText on <thead> element
     58PASS innerText on <tr> element
    5859
  • trunk/Source/WebCore/ChangeLog

    r210763 r210767  
     12017-01-14  Chris Dumez  <cdumez@apple.com>
     2
     3        Align the innerText setter with the HTML spec and Gecko
     4        https://bugs.webkit.org/show_bug.cgi?id=160971
     5
     6        Reviewed by Alex Christensen.
     7
     8        Align the innerText setter and createContextualFragment() with the
     9        HTML specification and Gecko. In particular, they no longer throw
     10        when the context element is a void element. This behavior was there
     11        to match an old IE behavior but Edge dropped this behavior.
     12
     13        Test: fast/dom/br-set-outerText.html
     14
     15        * dom/Element.cpp:
     16        * dom/Element.h:
     17        * editing/markup.cpp:
     18        (WebCore::createContextualFragment):
     19        * html/HTMLElement.cpp:
     20        (WebCore::HTMLElement::setInnerText):
     21        (WebCore::HTMLElement::setOuterText):
     22
    1232017-01-13  Joseph Pecoraro  <pecoraro@apple.com>
    224
  • trunk/Source/WebCore/dom/Element.cpp

    r210284 r210767  
    35793579}
    35803580
    3581 bool Element::ieForbidsInsertHTML() const
    3582 {
    3583     // FIXME: Supposedly IE disallows setting innerHTML, outerHTML
    3584     // and createContextualFragment on these tags. We have no tests to
    3585     // verify this however, so this list could be totally wrong.
    3586     // This list was moved from the previous endTagRequirement() implementation.
    3587     // This is also called from editing and assumed to be the list of tags
    3588     // for which no end tag should be serialized. It's unclear if the list for
    3589     // IE compat and the list for serialization sanity are the same.
    3590     if (hasTagName(areaTag)
    3591         || hasTagName(baseTag)
    3592         || hasTagName(basefontTag)
    3593         || hasTagName(brTag)
    3594         || hasTagName(colTag)
    3595         || hasTagName(embedTag)
    3596         || hasTagName(frameTag)
    3597         || hasTagName(hrTag)
    3598         || hasTagName(imageTag)
    3599         || hasTagName(imgTag)
    3600         || hasTagName(inputTag)
    3601         || hasTagName(linkTag)
    3602         || hasTagName(metaTag)
    3603         || hasTagName(paramTag)
    3604         || hasTagName(sourceTag)
    3605         || hasTagName(wbrTag))
    3606         return true;
    3607     // FIXME: I'm not sure why dashboard mode would want to change the
    3608     // serialization of <canvas>, that seems like a bad idea.
    3609 #if ENABLE(DASHBOARD_SUPPORT)
    3610     if (hasTagName(canvasTag)) {
    3611         Settings* settings = document().settings();
    3612         if (settings && settings->usesDashboardBackwardCompatibilityMode())
    3613             return true;
    3614     }
    3615 #endif
    3616     return false;
    3617 }
    3618 
    36193581ExceptionOr<Node*> Element::insertAdjacent(const String& where, Ref<Node>&& newChild)
    36203582{
  • trunk/Source/WebCore/dom/Element.h

    r210029 r210767  
    314314    WEBCORE_EXPORT ExceptionOr<void> insertAdjacentText(const String& where, const String& text);
    315315
    316     bool ieForbidsInsertHTML() const;
    317 
    318316    const RenderStyle* computedStyle(PseudoId = NOPSEUDO) override;
    319317
  • trunk/Source/WebCore/editing/markup.cpp

    r208839 r210767  
    950950ExceptionOr<Ref<DocumentFragment>> createContextualFragment(Element& element, const String& markup, ParserContentPolicy parserContentPolicy)
    951951{
    952     if (element.ieForbidsInsertHTML())
    953         return Exception { NOT_SUPPORTED_ERR };
    954 
    955     if (element.hasTagName(colTag) || element.hasTagName(colgroupTag) || element.hasTagName(framesetTag)
    956         || element.hasTagName(headTag) || element.hasTagName(styleTag) || element.hasTagName(titleTag))
    957         return Exception { NOT_SUPPORTED_ERR };
    958 
    959952    auto result = createFragmentForInnerOuterHTML(element, markup, parserContentPolicy);
    960953    if (result.hasException())
  • trunk/Source/WebCore/html/HTMLElement.cpp

    r210319 r210767  
    471471}
    472472
    473 static inline bool shouldProhibitSetInnerOuterText(const HTMLElement& element)
    474 {
    475     return element.hasTagName(colTag)
    476         || element.hasTagName(colgroupTag)
    477         || element.hasTagName(framesetTag)
    478         || element.hasTagName(headTag)
    479         || element.hasTagName(htmlTag)
    480         || element.hasTagName(tableTag)
    481         || element.hasTagName(tbodyTag)
    482         || element.hasTagName(tfootTag)
    483         || element.hasTagName(theadTag)
    484         || element.hasTagName(trTag);
    485 }
    486 
    487473// Returns the conforming 'dir' value associated with the state the attribute is in (in its canonical case), if any,
    488474// or the empty string if the attribute is in a state that has no associated keyword value or if the attribute is
     
    515501ExceptionOr<void> HTMLElement::setInnerText(const String& text)
    516502{
    517     if (ieForbidsInsertHTML())
    518         return Exception { NO_MODIFICATION_ALLOWED_ERR };
    519     if (shouldProhibitSetInnerOuterText(*this))
    520         return Exception { NO_MODIFICATION_ALLOWED_ERR };
    521 
    522503    // FIXME: This doesn't take whitespace collapsing into account at all.
    523504
     
    552533ExceptionOr<void> HTMLElement::setOuterText(const String& text)
    553534{
    554     if (ieForbidsInsertHTML())
    555         return Exception { NO_MODIFICATION_ALLOWED_ERR };
    556     if (shouldProhibitSetInnerOuterText(*this))
    557         return Exception { NO_MODIFICATION_ALLOWED_ERR };
    558 
    559535    RefPtr<ContainerNode> parent = parentNode();
    560536    if (!parent)
Note: See TracChangeset for help on using the changeset viewer.