Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Unified Diff: third_party/WebKit/Source/core/html/parser/HTMLConstructionSite.cpp

Issue 1814853003: Track whether an element was inserted via document.write (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on #384935 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/parser/HTMLConstructionSite.cpp
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLConstructionSite.cpp b/third_party/WebKit/Source/core/html/parser/HTMLConstructionSite.cpp
index 2d9123887d8a670585479a129d2f14055cd6ceca..6813d68246d487453e5437400c15ef27ae78271a 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLConstructionSite.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLConstructionSite.cpp
@@ -652,9 +652,22 @@ void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken* token)
// For createContextualFragment, the specifications say to mark it parser-inserted and already-started and later unmark them.
// However, we short circuit that logic to avoid the subtree traversal to find script elements since scripts can never see
// those flags or effects thereof.
- const bool parserInserted = m_parserContentPolicy != AllowScriptingContentAndDoNotMarkAlreadyStarted;
- const bool alreadyStarted = m_isParsingFragment && parserInserted;
- RawPtr<HTMLScriptElement> element = HTMLScriptElement::create(ownerDocumentForCurrentNode(), parserInserted, alreadyStarted);
+ int constructionFlags = DefaultContext;
+ if (m_parserContentPolicy != AllowScriptingContentAndDoNotMarkAlreadyStarted) {
+ constructionFlags |= ParserInserted;
+ }
+ if (m_isParsingFragment && (constructionFlags & ParserInserted)) {
+ constructionFlags |= AlreadyStarted;
+ }
+ // TODO(csharrison): This logic only works if the tokenizer/parser was not
Bryan McQuade 2016/04/04 21:43:57 can we open a crbug for this and include a link to
+ // blocked waiting for scripts when the element was inserted. This usually
+ // fails for instance, on second document.write if a script writes twice in
+ // a row. To fix this, the parser might have to keep track of raw string
+ // position.
+ if (ownerDocumentForCurrentNode().isInDocumentWrite()) {
+ constructionFlags |= CreatedDuringDocumentWrite;
+ }
+ RawPtr<HTMLScriptElement> element = HTMLScriptElement::create(ownerDocumentForCurrentNode(), constructionFlags);
setAttributes(element.get(), token, m_parserContentPolicy);
if (scriptingContentIsAllowed(m_parserContentPolicy))
attachLater(currentNode(), element);

Powered by Google App Engine
This is Rietveld 408576698