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

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: Created 4 years, 9 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 cc5344d24e8ff07e7371e4340fbfbfc544fc5005..40cf78811c80de51a07504e3d886bf9c766bcc12 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLConstructionSite.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLConstructionSite.cpp
@@ -652,7 +652,13 @@ void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken* token)
// those flags or effects thereof.
const bool parserInserted = m_parserContentPolicy != AllowScriptingContentAndDoNotMarkAlreadyStarted;
const bool alreadyStarted = m_isParsingFragment && parserInserted;
- RefPtrWillBeRawPtr<HTMLScriptElement> element = HTMLScriptElement::create(ownerDocumentForCurrentNode(), parserInserted, alreadyStarted);
+ // TODO(csharrison): This logic only works if the tokenizer/parser was not
+ // 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.
+ const bool createdDuringDocumentWrite = ownerDocumentForCurrentNode().isInDocumentWrite();
+ RefPtrWillBeRawPtr<HTMLScriptElement> element = HTMLScriptElement::create(ownerDocumentForCurrentNode(), parserInserted, alreadyStarted, createdDuringDocumentWrite);
kouhei (in TOK) 2016/03/18 02:24:26 I think this is ok in this CL, but I'd appreciate
Charlie Harrison 2016/03/18 14:10:47 I'll do this refactor in this CL, but I'm hitting
kouhei (in TOK) 2016/03/22 04:18:39 See make_element_factory.py https://code.google.co
setAttributes(element.get(), token, m_parserContentPolicy);
if (scriptingContentIsAllowed(m_parserContentPolicy))
attachLater(currentNode(), element);

Powered by Google App Engine
This is Rietveld 408576698