Index: third_party/WebKit/Source/core/html/parser/HTMLParserScriptRunner.cpp |
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLParserScriptRunner.cpp b/third_party/WebKit/Source/core/html/parser/HTMLParserScriptRunner.cpp |
index 97ff8b8be96b60927798001d7d76a6b247d34599..ec40bbaef322f0299f39ab588815737f3adf5ef7 100644 |
--- a/third_party/WebKit/Source/core/html/parser/HTMLParserScriptRunner.cpp |
+++ b/third_party/WebKit/Source/core/html/parser/HTMLParserScriptRunner.cpp |
@@ -31,6 +31,7 @@ |
#include "bindings/core/v8/ScriptSourceCode.h" |
#include "bindings/core/v8/V8BindingForCore.h" |
#include "bindings/core/v8/V8PerIsolateData.h" |
+#include "core/dom/ClassicPendingScript.h" |
#include "core/dom/ClassicScript.h" |
#include "core/dom/DocumentParserTiming.h" |
#include "core/dom/Element.h" |
@@ -48,7 +49,6 @@ |
#include "platform/WebFrameScheduler.h" |
#include "platform/instrumentation/tracing/TraceEvent.h" |
#include "platform/instrumentation/tracing/TracedValue.h" |
-#include "platform/loader/fetch/MemoryCache.h" |
#include "public/platform/Platform.h" |
namespace blink { |
@@ -335,9 +335,12 @@ void HTMLParserScriptRunner::PossiblyFetchBlockedDocWriteScript( |
if (!script_loader || !script_loader->DisallowedFetchForDocWrittenScript()) |
return; |
+ // We don't allow document.write() and its intervention with module scripts. |
+ CHECK_EQ(pending_script->GetScriptType(), ScriptType::kClassic); |
+ |
if (!pending_script->ErrorOccurred()) { |
- EmitWarningForDocWriteScripts( |
- pending_script->GetResource()->Url().GetString(), *document_); |
+ EmitWarningForDocWriteScripts(pending_script->Url().GetString(), |
+ *document_); |
return; |
} |
@@ -345,13 +348,12 @@ void HTMLParserScriptRunner::PossiblyFetchBlockedDocWriteScript( |
// ERR_CACHE_MISS but other errors are rare with |
// WebCachePolicy::ReturnCacheDataDontLoad. |
- EmitErrorForDocWriteScripts(pending_script->GetResource()->Url().GetString(), |
- *document_); |
+ EmitErrorForDocWriteScripts(pending_script->Url().GetString(), *document_); |
TextPosition starting_position = ParserBlockingScript()->StartingPosition(); |
bool is_parser_inserted = script_loader->IsParserInserted(); |
// Remove this resource entry from memory cache as the new request |
// should not join onto this existing entry. |
- GetMemoryCache()->Remove(pending_script->GetResource()); |
+ pending_script->RemoveFromMemoryCache(); |
FetchBlockedDocWriteScript(element, is_parser_inserted, starting_position); |
} |
@@ -363,7 +365,7 @@ void HTMLParserScriptRunner::PendingScriptFinished( |
// script execution to signal an abrupt stop (e.g., window.close().) |
// |
// The parser is unprepared to be told, and doesn't need to be. |
- if (IsExecutingScript() && pending_script->GetResource()->WasCanceled()) { |
+ if (IsExecutingScript() && pending_script->WasCanceled()) { |
pending_script->Dispose(); |
if (pending_script == ParserBlockingScript()) { |
@@ -505,7 +507,7 @@ bool HTMLParserScriptRunner::ExecuteScriptsWaitingForParsing() { |
while (!scripts_to_execute_after_parsing_.IsEmpty()) { |
DCHECK(!IsExecutingScript()); |
DCHECK(!HasParserBlockingScript()); |
- DCHECK(scripts_to_execute_after_parsing_.front()->GetResource()); |
+ DCHECK(scripts_to_execute_after_parsing_.front()->IsExternal()); |
// 1. "Spin the event loop until the first script in the list of scripts |
// that will execute when the document has finished parsing |
@@ -551,7 +553,7 @@ void HTMLParserScriptRunner::RequestParsingBlockingScript(Element* element) { |
if (!ParserBlockingScript()) |
return; |
- DCHECK(ParserBlockingScript()->GetResource()); |
+ DCHECK(ParserBlockingScript()->IsExternal()); |
// We only care about a load callback if resource is not already in the cache. |
// Callers will attempt to run the m_parserBlockingScript if possible before |
@@ -574,7 +576,7 @@ void HTMLParserScriptRunner::RequestDeferredScript(Element* element) { |
ScriptStreamer::kDeferred); |
} |
- DCHECK(pending_script->GetResource()); |
+ DCHECK(pending_script->IsExternal()); |
// "Add the element to the end of the list of scripts that will execute |
// when the document has finished parsing associated with the Document |
@@ -644,7 +646,7 @@ void HTMLParserScriptRunner::ProcessScriptElementInternal( |
// (There can only be one such script per Document at a time.)" |
CHECK(!parser_blocking_script_); |
parser_blocking_script_ = |
- PendingScript::Create(element, script_start_position); |
+ ClassicPendingScript::Create(element, script_start_position); |
} else { |
// 6th Clause of Step 23. |
// "Immediately execute the script block, |