Changeset 200327 in webkit


Ignore:
Timestamp:
May 2, 2016 11:19:44 AM (8 years ago)
Author:
rniwa@webkit.org
Message:

document.currentScript must be null when we're executing a script inside a shadow tree
https://bugs.webkit.org/show_bug.cgi?id=157245

Reviewed by Darin Adler.

Source/WebCore:

Fix the bug by not setting currentScript as spec'ed in HTML5 specification:
https://html.spec.whatwg.org/multipage/dom.html#dom-document-currentscript
https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-block
as of 3dc763829ca1598427b588cf08830c1e2af5a05c

New behavior matches that of Google Chrome Canary.

Test: fast/shadow-dom/Document-prototype-currentScript.html

  • dom/CurrentScriptIncrementer.h:

(WebCore::CurrentScriptIncrementer::CurrentScriptIncrementer):
(WebCore::CurrentScriptIncrementer::~CurrentScriptIncrementer):

  • dom/ScriptElement.cpp:

(WebCore::ScriptElement::executeScript):

LayoutTests:

Add a W3C style testharness.js test.

  • fast/shadow-dom/Document-prototype-currentScript-expected.txt: Added.
  • fast/shadow-dom/Document-prototype-currentScript.html: Added.
  • fast/shadow-dom/resources/Document-prototype-currentScript-helper.js: Added.
Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r200326 r200327  
     12016-05-01  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        document.currentScript must be null when we're executing a script inside a shadow tree
     4        https://bugs.webkit.org/show_bug.cgi?id=157245
     5
     6        Reviewed by Darin Adler.
     7
     8        Add a W3C style testharness.js test.
     9
     10        * fast/shadow-dom/Document-prototype-currentScript-expected.txt: Added.
     11        * fast/shadow-dom/Document-prototype-currentScript.html: Added.
     12        * fast/shadow-dom/resources/Document-prototype-currentScript-helper.js: Added.
     13
    1142016-04-29  Alex Christensen  <achristensen@webkit.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r200326 r200327  
     12016-05-01  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        document.currentScript must be null when we're executing a script inside a shadow tree
     4        https://bugs.webkit.org/show_bug.cgi?id=157245
     5
     6        Reviewed by Darin Adler.
     7
     8        Fix the bug by not setting currentScript as spec'ed in HTML5 specification:
     9        https://html.spec.whatwg.org/multipage/dom.html#dom-document-currentscript
     10        https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-block
     11        as of 3dc763829ca1598427b588cf08830c1e2af5a05c
     12
     13        New behavior matches that of Google Chrome Canary.
     14
     15        Test: fast/shadow-dom/Document-prototype-currentScript.html
     16
     17        * dom/CurrentScriptIncrementer.h:
     18        (WebCore::CurrentScriptIncrementer::CurrentScriptIncrementer):
     19        (WebCore::CurrentScriptIncrementer::~CurrentScriptIncrementer):
     20        * dom/ScriptElement.cpp:
     21        (WebCore::ScriptElement::executeScript):
     22
    1232016-04-29  Alex Christensen  <achristensen@webkit.org>
    224
  • trunk/Source/WebCore/dom/CurrentScriptIncrementer.h

    r175583 r200327  
    3838    WTF_MAKE_NONCOPYABLE(CurrentScriptIncrementer);
    3939public:
    40     CurrentScriptIncrementer(Document& document, Element* element)
     40    CurrentScriptIncrementer(Document& document, Element& element)
    4141        : m_document(document)
    42         , m_isHTMLScriptElement(is<HTMLScriptElement>(*element))
     42        , m_isHTMLScriptElementOutsideShadowTree(is<HTMLScriptElement>(element) && !element.isInShadowTree())
    4343    {
    44         if (m_isHTMLScriptElement)
    45             m_document.pushCurrentScript(downcast<HTMLScriptElement>(element));
     44        if (m_isHTMLScriptElementOutsideShadowTree)
     45            m_document.pushCurrentScript(&downcast<HTMLScriptElement>(element));
    4646    }
    4747
    4848    ~CurrentScriptIncrementer()
    4949    {
    50         if (m_isHTMLScriptElement)
     50        if (m_isHTMLScriptElementOutsideShadowTree)
    5151            m_document.popCurrentScript();
    5252    }
     
    5454private:
    5555    Document& m_document;
    56     bool m_isHTMLScriptElement;
     56    bool m_isHTMLScriptElementOutsideShadowTree;
    5757};
    5858
  • trunk/Source/WebCore/dom/ScriptElement.cpp

    r197944 r200327  
    313313    if (Frame* frame = document->frame()) {
    314314        IgnoreDestructiveWriteCountIncrementer ignoreDesctructiveWriteCountIncrementer(m_isExternalScript ? document.ptr() : nullptr);
    315         CurrentScriptIncrementer currentScriptIncrementer(document, &m_element);
     315        CurrentScriptIncrementer currentScriptIncrementer(document, m_element);
    316316
    317317        // Create a script from the script element node, using the script
Note: See TracChangeset for help on using the changeset viewer.