Changeset 208660 in webkit
- Timestamp:
- Nov 12, 2016 6:43:37 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r208609 r208660 1 2016-11-12 Ryosuke Niwa <rniwa@webkit.org> 2 3 document.currentScript should be null when running a script inside a shadow tree 4 https://bugs.webkit.org/show_bug.cgi?id=164693 5 6 Reviewed by Yusuke Suzuki. 7 8 Rebaselined the imported test now that there are no errors. 9 10 * web-platform-tests/shadow-dom/Document-prototype-currentScript-expected.txt: 11 1 12 2016-11-11 Brady Eidson <beidson@apple.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-currentScript-expected.txt
r206463 r208660 1 CONSOLE MESSAGE: line 2422: Error: assert_equals: expected null but got Element node <script id="outerScriptElement">2 3 var outerScriptElement ...4 CONSOLE MESSAGE: line 2422: Error: assert_equals: expected null but got Element node <script id="outerScriptElement">5 6 var outerScriptElement ...7 8 Harness Error (FAIL), message = Error: assert_equals: expected null but got Element node <script id="outerScriptElement">9 10 var outerScriptElement ...11 1 12 2 PASS document.currentScript must not to be set to a script element in a shadow tree in open mode -
trunk/Source/WebCore/ChangeLog
r208659 r208660 1 2016-11-12 Ryosuke Niwa <rniwa@webkit.org> 2 3 document.currentScript should be null when running a script inside a shadow tree 4 https://bugs.webkit.org/show_bug.cgi?id=164693 5 6 Reviewed by Yusuke Suzuki. 7 8 Fixed the bug that we were returning the old or outer script element in document.currentScript 9 while executing a script element inside a shadow tree. Return null instead. 10 11 New behavior matches the latest HTML5 specification: 12 https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-block 13 where it says for the classic script type, "if the script element's root is not a shadow root, then set 14 the script element's node document's currentScript attribute to the script element. Otherwise, set it to null." 15 16 No new tests. imported/w3c/web-platform-tests/shadow-dom/Document-prototype-currentScript.html covers it. 17 18 * dom/CurrentScriptIncrementer.h: 19 (WebCore::CurrentScriptIncrementer::CurrentScriptIncrementer): Push nullptr when the script element 20 is inside a shadow tree. 21 (WebCore::CurrentScriptIncrementer::~CurrentScriptIncrementer): Changed to use an early exit. 22 * dom/Document.cpp: 23 (WebCore::Document::pushCurrentScript): Removed the assertion since the argument can now be nullptr. 24 1 25 2016-11-12 Darin Adler <darin@apple.com> 2 26 -
trunk/Source/WebCore/dom/CurrentScriptIncrementer.h
r208179 r208660 39 39 CurrentScriptIncrementer(Document& document, Element& element) 40 40 : m_document(document) 41 , m_isHTMLScriptElement OutsideShadowTree(is<HTMLScriptElement>(element) && !element.isInShadowTree())41 , m_isHTMLScriptElement(is<HTMLScriptElement>(element)) 42 42 { 43 if (m_isHTMLScriptElementOutsideShadowTree) 44 m_document.pushCurrentScript(&downcast<HTMLScriptElement>(element)); 43 if (!m_isHTMLScriptElement) 44 return; 45 auto& scriptElement = downcast<HTMLScriptElement>(element); 46 m_document.pushCurrentScript(scriptElement.isInShadowTree() ? nullptr : &scriptElement); 45 47 } 46 48 47 49 ~CurrentScriptIncrementer() 48 50 { 49 if (m_isHTMLScriptElementOutsideShadowTree) 50 m_document.popCurrentScript(); 51 if (!m_isHTMLScriptElement) 52 return; 53 m_document.popCurrentScript(); 51 54 } 52 55 53 56 private: 54 57 Document& m_document; 55 bool m_isHTMLScriptElement OutsideShadowTree;58 bool m_isHTMLScriptElement; 56 59 }; 57 60 -
trunk/Source/WebCore/dom/Document.cpp
r208630 r208660 4785 4785 void Document::pushCurrentScript(HTMLScriptElement* newCurrentScript) 4786 4786 { 4787 ASSERT(newCurrentScript);4788 4787 m_currentScriptStack.append(newCurrentScript); 4789 4788 }
Note: See TracChangeset
for help on using the changeset viewer.