Changeset 234680 in webkit
- Timestamp:
- Aug 7, 2018 4:54:25 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r234678 r234680 1 2018-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 1 18 2018-08-07 Rob Buis <rbuis@igalia.com> 2 19 -
trunk/Source/WebCore/ChangeLog
r234679 r234680 1 2018-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 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 1 31 2018-08-07 Alex Christensen <achristensen@webkit.org> 2 32 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r234620 r234680 10860 10860 9B417062125662B3006B28FC /* ApplyBlockElementCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplyBlockElementCommand.h; sourceTree = "<group>"; }; 10861 10861 9B417063125662B3006B28FC /* ApplyBlockElementCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplyBlockElementCommand.cpp; sourceTree = "<group>"; }; 10862 9B4376EF2117E872009D03A0 /* ThrowOnDynamicMarkupInsertionCountIncrementer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ThrowOnDynamicMarkupInsertionCountIncrementer.h; sourceTree = "<group>"; }; 10862 10863 9B50B1DC17CD4C0F0087F63C /* FormNamedItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormNamedItem.h; sourceTree = "<group>"; }; 10863 10864 9B532EA11BA928570038A827 /* SlotAssignment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SlotAssignment.cpp; sourceTree = "<group>"; }; … … 26576 26577 E4D988B517BFEB210084FB88 /* TextNodeTraversal.cpp */, 26577 26578 E4D988B317BFD1F60084FB88 /* TextNodeTraversal.h */, 26579 9B4376EF2117E872009D03A0 /* ThrowOnDynamicMarkupInsertionCountIncrementer.h */, 26578 26580 0F54DD051881D5F5003EEDBB /* Touch.h */, 26579 26581 0F54DD061881D5F5003EEDBB /* TouchEvent.h */, -
trunk/Source/WebCore/dom/Document.cpp
r234679 r234680 2610 2610 ExceptionOr<Document&> Document::openForBindings(Document* responsibleDocument, const String&, const String&) 2611 2611 { 2612 if (!isHTMLDocument() )2612 if (!isHTMLDocument() || m_throwOnDynamicMarkupInsertionCount) 2613 2613 return Exception { InvalidStateError }; 2614 2615 // FIXME: This should also throw if "document's throw-on-dynamic-markup-insertion counter is greater than 0".2616 // https://bugs.webkit.org/show_bug.cgi?id=1873192617 2614 2618 2615 open(responsibleDocument); … … 2754 2751 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-close 2755 2752 2756 if (!isHTMLDocument() )2753 if (!isHTMLDocument() || m_throwOnDynamicMarkupInsertionCount) 2757 2754 return Exception { InvalidStateError }; 2758 2759 // FIXME: This should also throw if "document's throw-on-dynamic-markup-insertion counter is greater than 0".2760 // https://bugs.webkit.org/show_bug.cgi?id=1873192761 2755 2762 2756 close(); … … 2985 2979 ExceptionOr<void> Document::write(Document* responsibleDocument, Vector<String>&& strings) 2986 2980 { 2987 if (!isHTMLDocument() )2981 if (!isHTMLDocument() || m_throwOnDynamicMarkupInsertionCount) 2988 2982 return Exception { InvalidStateError }; 2989 2990 // FIXME: This should also throw if "document's throw-on-dynamic-markup-insertion counter is greater than 0".2991 // https://bugs.webkit.org/show_bug.cgi?id=1873192992 2983 2993 2984 SegmentedString text; … … 3002 2993 ExceptionOr<void> Document::writeln(Document* responsibleDocument, Vector<String>&& strings) 3003 2994 { 3004 if (!isHTMLDocument() )2995 if (!isHTMLDocument() || m_throwOnDynamicMarkupInsertionCount) 3005 2996 return Exception { InvalidStateError }; 3006 3007 // FIXME: This should also throw if "document's throw-on-dynamic-markup-insertion counter is greater than 0".3008 // https://bugs.webkit.org/show_bug.cgi?id=1873193009 2997 3010 2998 SegmentedString text; -
trunk/Source/WebCore/dom/Document.h
r234679 r234680 1481 1481 friend class DocumentParserYieldToken; 1482 1482 friend class Node; 1483 friend class ThrowOnDynamicMarkupInsertionCountIncrementer; 1484 friend class IgnoreOpensDuringUnloadCountIncrementer; 1483 1485 friend class IgnoreDestructiveWriteCountIncrementer; 1484 friend class IgnoreOpensDuringUnloadCountIncrementer;1485 1486 1486 1487 bool shouldInheritContentSecurityPolicyFromOwner() const; … … 1855 1856 unsigned m_lastStyleUpdateSizeForTesting { 0 }; 1856 1857 1857 // https://html.spec.whatwg.org/multipage/webappapis.html#ignore-destructive-writes-counter 1858 // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#throw-on-dynamic-markup-insertion-counter 1859 unsigned m_throwOnDynamicMarkupInsertionCount { 0 }; 1860 1861 // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#ignore-opens-during-unload-counter 1862 unsigned m_ignoreOpensDuringUnloadCount { 0 }; 1863 1864 // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#ignore-destructive-writes-counter 1858 1865 unsigned m_ignoreDestructiveWriteCount { 0 }; 1859 1860 // https://html.spec.whatwg.org/multipage/webappapis.html#ignore-opens-during-unload-counter1861 unsigned m_ignoreOpensDuringUnloadCount { 0 };1862 1866 1863 1867 unsigned m_activeParserCount { 0 }; -
trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp
r234608 r234680 42 42 #include "NavigationScheduler.h" 43 43 #include "ScriptElement.h" 44 #include "ThrowOnDynamicMarkupInsertionCountIncrementer.h" 44 45 45 46 namespace WebCore { … … 211 212 // https://html.spec.whatwg.org/#create-an-element-for-the-token 212 213 { 214 // Prevent document.open/write during reactions by allocating the incrementer before the reactions stack. 215 ThrowOnDynamicMarkupInsertionCountIncrementer incrementer(*document()); 213 216 CustomElementReactionStack reactionStack(document()->execState()); 214 217 auto& elementInterface = constructionData->elementInterface.get();
Note: See TracChangeset
for help on using the changeset viewer.