Changeset 234669 in webkit


Ignore:
Timestamp:
Aug 7, 2018 2:13:07 PM (6 years ago)
Author:
rniwa@webkit.org
Message:

document.open and document.write must throw while the HTML parser is synchronously constructing a custom element
https://bugs.webkit.org/show_bug.cgi?id=187319
<rdar://problem/42843012>

Reviewed by Frédéric Wang.

Source/WebCore:

Make document.open, document.write, document.writeln, and document.close throw InvalidStateError during
a synchronous custom element construction as specified:
https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token
https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#throw-on-dynamic-markup-insertion-counter

Tests: fast/custom-elements/throw-on-dynamic-markup-insertion-counter-construct.html

fast/custom-elements/throw-on-dynamic-markup-insertion-counter-reactions.html

  • WebCore.xcodeproj/project.pbxproj:
  • dom/Document.cpp:

(WebCore::Document::openForBindings): Throw InvalidStateError when m_throwOnDynamicMarkupInsertionCount is non-zero.
(WebCore::Document::closeForBindings): Ditto.
(WebCore::Document::write): Ditto.
(WebCore::Document::writeln): Ditto.

  • dom/Document.h: Re-ordered the related instance variables in the order they appear in the spec, and updated spec URLs.
  • dom/ThrowOnDynamicMarkupInsertionCountIncrementer.h: Added.

(WebCore::ThrowOnDynamicMarkupInsertionCountIncrementer): Added.
(WebCore::ThrowOnDynamicMarkupInsertionCountIncrementer::ThrowOnDynamicMarkupInsertionCountIncrementer):
(WebCore::ThrowOnDynamicMarkupInsertionCountIncrementer::~ThrowOnDynamicMarkupInsertionCountIncrementer):

  • html/parser/HTMLDocumentParser.cpp:

(WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder): Instantiate ThrowOnDynamicMarkupInsertionCountIncrementer.

LayoutTests:

Added W3C style testharness.js tests. The WPT test added by https://github.com/web-platform-tests/wpt/pull/12037
doesn't test nearly as many edge cases.

  • fast/custom-elements/resources/navigation-destination.html: Added.
  • fast/custom-elements/throw-on-dynamic-markup-insertion-counter-construct-expected.txt: Added.
  • fast/custom-elements/throw-on-dynamic-markup-insertion-counter-construct.html: Added.
  • fast/custom-elements/throw-on-dynamic-markup-insertion-counter-reactions-expected.txt: Added.
  • fast/custom-elements/throw-on-dynamic-markup-insertion-counter-reactions.html: Added.
Location:
trunk
Files:
5 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r234661 r234669  
     12018-08-07  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        document.open and document.write must throw while the HTML parser is synchronously constructing a custom element
     4        https://bugs.webkit.org/show_bug.cgi?id=187319
     5        <rdar://problem/42843012>
     6
     7        Reviewed by Frédéric Wang.
     8
     9        Added W3C style testharness.js tests. The WPT test added by https://github.com/web-platform-tests/wpt/pull/12037
     10        doesn't test nearly as many edge cases.
     11
     12        * fast/custom-elements/resources/navigation-destination.html: Added.
     13        * fast/custom-elements/throw-on-dynamic-markup-insertion-counter-construct-expected.txt: Added.
     14        * fast/custom-elements/throw-on-dynamic-markup-insertion-counter-construct.html: Added.
     15        * fast/custom-elements/throw-on-dynamic-markup-insertion-counter-reactions-expected.txt: Added.
     16        * fast/custom-elements/throw-on-dynamic-markup-insertion-counter-reactions.html: Added.
     17
    1182018-08-07  Wenson Hsieh  <wenson_hsieh@apple.com>
    219
  • trunk/Source/WebCore/ChangeLog

    r234659 r234669  
     12018-08-06  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        document.open and document.write must throw while the HTML parser is synchronously constructing a custom element
     4        https://bugs.webkit.org/show_bug.cgi?id=187319
     5        <rdar://problem/42843012>
     6
     7        Reviewed by Frédéric Wang.
     8
     9        Make document.open, document.write, document.writeln, and document.close throw InvalidStateError during
     10        a synchronous custom element construction as specified:
     11        https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token
     12        https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#throw-on-dynamic-markup-insertion-counter
     13
     14        Tests: fast/custom-elements/throw-on-dynamic-markup-insertion-counter-construct.html
     15               fast/custom-elements/throw-on-dynamic-markup-insertion-counter-reactions.html
     16
     17        * WebCore.xcodeproj/project.pbxproj:
     18        * dom/Document.cpp:
     19        (WebCore::Document::openForBindings): Throw InvalidStateError when m_throwOnDynamicMarkupInsertionCount is non-zero.
     20        (WebCore::Document::closeForBindings): Ditto.
     21        (WebCore::Document::write): Ditto.
     22        (WebCore::Document::writeln): Ditto.
     23        * dom/Document.h: Re-ordered the related instance variables in the order they appear in the spec, and updated spec URLs.
     24        * dom/ThrowOnDynamicMarkupInsertionCountIncrementer.h: Added.
     25        (WebCore::ThrowOnDynamicMarkupInsertionCountIncrementer): Added.
     26        (WebCore::ThrowOnDynamicMarkupInsertionCountIncrementer::ThrowOnDynamicMarkupInsertionCountIncrementer):
     27        (WebCore::ThrowOnDynamicMarkupInsertionCountIncrementer::~ThrowOnDynamicMarkupInsertionCountIncrementer):
     28        * html/parser/HTMLDocumentParser.cpp:
     29        (WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder): Instantiate ThrowOnDynamicMarkupInsertionCountIncrementer.
     30
    1312018-08-07  Ryan Haddad  <ryanhaddad@apple.com>
    232
Note: See TracChangeset for help on using the changeset viewer.