Changeset 262125 in webkit


Ignore:
Timestamp:
May 25, 2020 7:47:51 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Use child text content when determining whether to bail early in running a script
https://bugs.webkit.org/show_bug.cgi?id=182695

Patch by Rob Buis <rbuis@igalia.com> on 2020-05-25
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Update improved test results.

  • web-platform-tests/html/semantics/scripting-1/the-script-element/emptyish-script-elements-expected.txt:

Source/WebCore:

Check that the text content is not empty instead of just checking
for the first child [1].

Behavior matches Chrome and Firefox.

[1] https://html.spec.whatwg.org/#prepare-a-script step 5 and 6

Test: web-platform-tests/html/semantics/scripting-1/the-script-element/emptyish-script-elements.html

  • dom/ScriptElement.cpp:

(WebCore::ScriptElement::prepareScript):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r262124 r262125  
     12020-05-25  Rob Buis  <rbuis@igalia.com>
     2
     3        Use child text content when determining whether to bail early in running a script
     4        https://bugs.webkit.org/show_bug.cgi?id=182695
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Update improved test results.
     9
     10        * web-platform-tests/html/semantics/scripting-1/the-script-element/emptyish-script-elements-expected.txt:
     11
    1122020-05-22  Sergio Villar Senin  <svillar@igalia.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/emptyish-script-elements-expected.txt

    r249886 r262125  
    22PASS A script with no children bails early, before setting already-started, so can be executed when adding text
    33PASS A script with a whitespace child executes, setting already-started, so adding text is a no-op
    4 FAIL A script with an empty element inserted bails early, before setting already-started, so can be executed when adding text assert_true: expected true got undefined
    5 FAIL A script with an empty text node inserted bails early, before setting already-started, so can be executed when adding text assert_true: expected true got undefined
     4PASS A script with an empty element inserted bails early, before setting already-started, so can be executed when adding text
     5PASS A script with an empty text node inserted bails early, before setting already-started, so can be executed when adding text
    66PASS A script with a text child inserted executes, setting already-started, so adding text is a no-op
    7 FAIL A script with a comment child inserted bails early, before setting already-started, so can be executed when adding text assert_true: expected true got undefined
    8 FAIL A script with an element containing text inserted bails early, before setting already-started, so can be executed when adding text assert_true: expected true got undefined
     7PASS A script with a comment child inserted bails early, before setting already-started, so can be executed when adding text
     8PASS A script with an element containing text inserted bails early, before setting already-started, so can be executed when adding text
    99
  • trunk/Source/WebCore/ChangeLog

    r262124 r262125  
     12020-05-25  Rob Buis  <rbuis@igalia.com>
     2
     3        Use child text content when determining whether to bail early in running a script
     4        https://bugs.webkit.org/show_bug.cgi?id=182695
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Check that the text content is not empty instead of just checking
     9        for the first child [1].
     10
     11        Behavior matches Chrome and Firefox.
     12
     13        [1] https://html.spec.whatwg.org/#prepare-a-script step 5 and 6
     14
     15        Test: web-platform-tests/html/semantics/scripting-1/the-script-element/emptyish-script-elements.html
     16
     17        * dom/ScriptElement.cpp:
     18        (WebCore::ScriptElement::prepareScript):
     19
    1202020-05-22  Sergio Villar Senin  <svillar@igalia.com>
    221
  • trunk/Source/WebCore/dom/ScriptElement.cpp

    r260709 r262125  
    182182        m_forceAsync = true;
    183183
    184     // FIXME: HTML5 spec says we should check that all children are either comments or empty text nodes.
    185     if (!hasSourceAttribute() && !m_element.firstChild())
     184    auto sourceText = scriptContent();
     185    if (!hasSourceAttribute() && sourceText.isEmpty())
    186186        return false;
    187187
     
    267267        ASSERT(scriptType == ScriptType::Classic);
    268268        TextPosition position = document.isInDocumentWrite() ? TextPosition() : scriptStartPosition;
    269         executeClassicScript(ScriptSourceCode(scriptContent(), URL(document.url()), position, JSC::SourceProviderSourceType::Program, InlineClassicScript::create(*this)));
     269        executeClassicScript(ScriptSourceCode(sourceText, URL(document.url()), position, JSC::SourceProviderSourceType::Program, InlineClassicScript::create(*this)));
    270270    }
    271271
Note: See TracChangeset for help on using the changeset viewer.