Commit 68ebd178 authored by Camillo Bruni's avatar Camillo Bruni Committed by Chromium LUCI CQ

[blink] Prepare module script compilation for streaming

- Use ModuleScriptCreationParams as main parameter for module
  compilation
- Add streaming members to ModuleScriptCreationParams, currently
  unused and cleared on crossing thread boundaries

This CL prepares ModuleScriptCreationParams for passing on the
ScriptStreamer from the ScriptResource to compilation in
V8ScriptRunner::CompileModule.

Bug: 1061857, 1154943
Change-Id: Ie0bc25fac1f5841766392ff435a690eed9bc8813
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2547682
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: default avatarHiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833404}
parent 2db922f5
......@@ -10,6 +10,7 @@
#include "third_party/blink/renderer/bindings/core/v8/referrer_script_info.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_script_runner.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/script/modulator.h"
#include "third_party/blink/renderer/core/script/module_record_resolver.h"
......@@ -46,14 +47,12 @@ void ModuleRecordProduceCacheData::Trace(Visitor* visitor) const {
v8::Local<v8::Module> ModuleRecord::Compile(
v8::Isolate* isolate,
const String& source,
const KURL& source_url,
const ModuleScriptCreationParams& params,
const KURL& base_url,
const ScriptFetchOptions& options,
const TextPosition& text_position,
ExceptionState& exception_state,
mojom::blink::V8CacheOptions v8_cache_options,
SingleCachedMetadataHandler* cache_handler,
ScriptSourceLocationType source_location_type,
ModuleRecordProduceCacheData** out_produce_cache_data) {
v8::TryCatch try_catch(isolate);
......@@ -71,12 +70,12 @@ v8::Local<v8::Module> ModuleRecord::Compile(
V8CodeCache::ProduceCacheOptions produce_cache_options;
v8::ScriptCompiler::NoCacheReason no_cache_reason;
std::tie(compile_options, produce_cache_options, no_cache_reason) =
V8CodeCache::GetCompileOptions(v8_cache_options, cache_handler,
source.length(), source_location_type);
V8CodeCache::GetCompileOptions(v8_cache_options, params.CacheHandler(),
params.GetSourceText().length(),
source_location_type);
if (!V8ScriptRunner::CompileModule(
isolate, source, cache_handler, source_url, text_position,
compile_options, no_cache_reason,
isolate, params, text_position, compile_options, no_cache_reason,
ReferrerScriptInfo(base_url, options,
ReferrerScriptInfo::BaseUrlSource::kOther))
.ToLocal(&module)) {
......@@ -89,7 +88,7 @@ v8::Local<v8::Module> ModuleRecord::Compile(
if (out_produce_cache_data) {
*out_produce_cache_data =
MakeGarbageCollected<ModuleRecordProduceCacheData>(
isolate, cache_handler, produce_cache_options, module);
isolate, params.CacheHandler(), produce_cache_options, module);
}
return module;
......
......@@ -22,6 +22,7 @@ namespace blink {
class ExceptionState;
class KURL;
class ModuleScriptCreationParams;
class ScriptFetchOptions;
class ScriptState;
class ScriptValue;
......@@ -63,14 +64,12 @@ class CORE_EXPORT ModuleRecord final {
public:
static v8::Local<v8::Module> Compile(
v8::Isolate*,
const String& source,
const KURL& source_url,
const ModuleScriptCreationParams& params,
const KURL& base_url,
const ScriptFetchOptions&,
const TextPosition&,
ExceptionState&,
mojom::blink::V8CacheOptions = mojom::blink::V8CacheOptions::kDefault,
SingleCachedMetadataHandler* = nullptr,
ScriptSourceLocationType source_location_type =
ScriptSourceLocationType::kInternal,
ModuleRecordProduceCacheData** out_produce_cache_data = nullptr);
......
......@@ -44,6 +44,7 @@
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/inspector/inspector_trace_events.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/script/modulator.h"
#include "third_party/blink/renderer/core/script/module_script.h"
......@@ -247,13 +248,12 @@ v8::MaybeLocal<v8::Script> V8ScriptRunner::CompileScript(
v8::MaybeLocal<v8::Module> V8ScriptRunner::CompileModule(
v8::Isolate* isolate,
const String& source_text,
SingleCachedMetadataHandler* cache_handler,
const String& file_name,
const ModuleScriptCreationParams& params,
const TextPosition& start_position,
v8::ScriptCompiler::CompileOptions compile_options,
v8::ScriptCompiler::NoCacheReason no_cache_reason,
const ReferrerScriptInfo& referrer_info) {
const String file_name = params.SourceURL();
constexpr const char* kTraceEventCategoryGroup = "v8,devtools.timeline";
TRACE_EVENT_BEGIN1(kTraceEventCategoryGroup, "v8.compileModule", "fileName",
file_name.Utf8());
......@@ -271,7 +271,8 @@ v8::MaybeLocal<v8::Module> V8ScriptRunner::CompileModule(
true, // is_module
referrer_info.ToV8HostDefinedOptions(isolate));
v8::Local<v8::String> code = V8String(isolate, source_text);
// TODO(crbug.com/1061857): Finalize module streaming here.
v8::Local<v8::String> code = V8String(isolate, params.GetSourceText());
v8::MaybeLocal<v8::Module> script;
inspector_compile_script_event::V8CacheResult cache_result;
......@@ -287,6 +288,7 @@ v8::MaybeLocal<v8::Module> V8ScriptRunner::CompileModule(
case v8::ScriptCompiler::kConsumeCodeCache: {
// Compile a script, and consume a V8 cache that was generated previously.
SingleCachedMetadataHandler* cache_handler = params.CacheHandler();
DCHECK(cache_handler);
v8::ScriptCompiler::CachedData* cached_data =
V8CodeCache::CreateCachedData(cache_handler);
......
......@@ -40,15 +40,15 @@ class TextPosition;
namespace blink {
class ScriptEvaluationResult;
class ExecutionContext;
class KURL;
class ModuleScript;
class ModuleScriptCreationParams;
class ReferrerScriptInfo;
class ScriptEvaluationResult;
class ScriptFetchOptions;
class ScriptSourceCode;
class ScriptState;
class SingleCachedMetadataHandler;
class CORE_EXPORT V8ScriptRunner final {
STATIC_ONLY(V8ScriptRunner);
......@@ -114,9 +114,7 @@ class CORE_EXPORT V8ScriptRunner final {
const ReferrerScriptInfo&);
static v8::MaybeLocal<v8::Module> CompileModule(
v8::Isolate*,
const String& source,
SingleCachedMetadataHandler*,
const String& file_name,
const ModuleScriptCreationParams&,
const WTF::TextPosition&,
v8::ScriptCompiler::CompileOptions,
v8::ScriptCompiler::NoCacheReason,
......
......@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/core/loader/modulescript/document_module_script_fetcher.h"
#include "third_party/blink/public/mojom/script/script_type.mojom-blink-forward.h"
#include "third_party/blink/renderer/bindings/core/v8/script_streamer.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/loader/resource/script_resource.h"
#include "third_party/blink/renderer/platform/bindings/parkable_string.h"
......@@ -26,7 +27,7 @@ void DocumentModuleScriptFetcher::Fetch(
DCHECK(fetch_client_settings_object_fetcher);
DCHECK(!client_);
client_ = client;
// TODO(crbug.com/1061857): Enable streaming.
ScriptResource::Fetch(fetch_params, fetch_client_settings_object_fetcher,
this, ScriptResource::kNoStreaming);
}
......@@ -43,11 +44,12 @@ void DocumentModuleScriptFetcher::NotifyFinished(Resource* resource) {
client_->NotifyFetchFinished(base::nullopt, error_messages);
return;
}
// TODO(crbug.com/1061857): Pass ScriptStreamer to the client here.
ModuleScriptCreationParams params(
script_resource->GetResponse().CurrentRequestUrl(), module_type,
script_resource->SourceText(), script_resource->CacheHandler(),
script_resource->GetResourceRequest().GetCredentialsMode());
script_resource->GetResourceRequest().GetCredentialsMode(), nullptr,
ScriptStreamer::NotStreamingReason::kStreamingDisabled);
client_->NotifyFetchFinished(params, error_messages);
}
......
......@@ -7,6 +7,8 @@
#include "base/optional.h"
#include "third_party/blink/public/platform/web_url_request.h"
#include "third_party/blink/renderer/bindings/core/v8/script_streamer.h"
#include "third_party/blink/renderer/core/script/modulator.h"
#include "third_party/blink/renderer/platform/bindings/parkable_string.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/loader/fetch/cached_metadata_handler.h"
......@@ -24,18 +26,27 @@ class ModuleScriptCreationParams {
public:
ModuleScriptCreationParams(
const KURL& response_url,
const KURL& source_url,
const ModuleScriptCreationParams::ModuleType module_type,
const ParkableString& source_text,
SingleCachedMetadataHandler* cache_handler,
network::mojom::CredentialsMode credentials_mode)
: response_url_(response_url),
network::mojom::CredentialsMode credentials_mode,
ScriptStreamer* script_streamer = nullptr,
ScriptStreamer::NotStreamingReason not_streaming_reason =
ScriptStreamer::NotStreamingReason::kStreamingDisabled)
: source_url_(source_url),
module_type_(module_type),
is_isolated_(false),
source_text_(source_text),
isolated_source_text_(),
cache_handler_(cache_handler),
credentials_mode_(credentials_mode) {}
credentials_mode_(credentials_mode),
script_streamer_(script_streamer),
not_streaming_reason_(not_streaming_reason) {
DCHECK_EQ(
!script_streamer,
not_streaming_reason != ScriptStreamer::NotStreamingReason::kInvalid);
}
~ModuleScriptCreationParams() = default;
......@@ -43,8 +54,7 @@ class ModuleScriptCreationParams {
String isolated_source_text =
isolated_source_text_ ? isolated_source_text_.IsolatedCopy()
: GetSourceText().ToString().IsolatedCopy();
return ModuleScriptCreationParams(GetResponseUrl().Copy(), module_type_,
return ModuleScriptCreationParams(SourceURL().Copy(), module_type_,
isolated_source_text,
GetFetchCredentialsMode());
}
......@@ -53,7 +63,8 @@ class ModuleScriptCreationParams {
return module_type_;
}
const KURL& GetResponseUrl() const { return response_url_; }
const KURL& SourceURL() const { return source_url_; }
const ParkableString& GetSourceText() const {
if (is_isolated_) {
source_text_ = ParkableString(isolated_source_text_.ReleaseImpl());
......@@ -62,30 +73,46 @@ class ModuleScriptCreationParams {
}
return source_text_;
}
// TODO(crbug.com/1154943): Make this non-const.
void ClearSourceText() const {
source_text_ = ParkableString();
isolated_source_text_ = String();
is_isolated_ = false;
}
SingleCachedMetadataHandler* CacheHandler() const { return cache_handler_; }
network::mojom::CredentialsMode GetFetchCredentialsMode() const {
return credentials_mode_;
}
bool IsSafeToSendToAnotherThread() const {
return response_url_.IsSafeToSendToAnotherThread() && is_isolated_;
return source_url_.IsSafeToSendToAnotherThread() && is_isolated_;
}
private:
// Creates an isolated copy.
ModuleScriptCreationParams(
const KURL& response_url,
const KURL& source_url,
const ModuleScriptCreationParams::ModuleType& module_type,
const String& isolated_source_text,
network::mojom::CredentialsMode credentials_mode)
: response_url_(response_url),
: source_url_(source_url),
module_type_(module_type),
is_isolated_(true),
source_text_(),
isolated_source_text_(isolated_source_text),
credentials_mode_(credentials_mode) {}
const KURL response_url_;
credentials_mode_(credentials_mode),
// The ScriptStreamer is intentionally cleared since it cannot be passed
// across threads. This only disables script streaming on worklet
// top-level scripts where the ModuleScriptCreationParams is
// passed across threads.
script_streamer_(nullptr),
not_streaming_reason_(
ScriptStreamer::NotStreamingReason::kStreamingDisabled) {}
const KURL source_url_;
const ModuleType module_type_;
// Mutable because an isolated copy can become bound to a thread when
......@@ -98,14 +125,18 @@ class ModuleScriptCreationParams {
Persistent<SingleCachedMetadataHandler> cache_handler_;
const network::mojom::CredentialsMode credentials_mode_;
// |script_streamer_| is cleared when crossing thread boundaries.
Persistent<ScriptStreamer> script_streamer_;
const ScriptStreamer::NotStreamingReason not_streaming_reason_;
};
} // namespace blink
namespace WTF {
// Creates a deep copy because |response_url_| and |source_text_| are not
// cross-thread-transfer-safe.
// Creates a deep copy because |source_url_|, |source_text_| and
// |script_streamer_| are not cross-thread-transfer-safe.
template <>
struct CrossThreadCopier<blink::ModuleScriptCreationParams> {
static blink::ModuleScriptCreationParams Copy(
......
......@@ -271,9 +271,8 @@ void ModuleScriptLoader::NotifyFetchFinished(
// a module script given source text, module map settings object,
// response's url, and options." [spec text]
module_script_ = JSModuleScript::Create(
params->GetSourceText(), params->CacheHandler(),
ScriptSourceLocationType::kExternalFile, modulator_,
params->GetResponseUrl(), params->GetResponseUrl(), options_);
params.value(), params->SourceURL() /* base URL */,
ScriptSourceLocationType::kExternalFile, modulator_, options_);
break;
}
......
......@@ -5,8 +5,12 @@
#include "third_party/blink/renderer/core/script/js_module_script.h"
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h"
#include "third_party/blink/renderer/core/script/modulator.h"
#include "third_party/blink/renderer/core/script/module_record_resolver.h"
#include "third_party/blink/renderer/platform/bindings/parkable_string.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "v8/include/v8.h"
namespace blink {
......@@ -14,19 +18,16 @@ namespace blink {
// <specdef
// href="https://html.spec.whatwg.org/C/#creating-a-javascript-module-script">
JSModuleScript* JSModuleScript::Create(
const ParkableString& original_source_text,
SingleCachedMetadataHandler* cache_handler,
const ModuleScriptCreationParams& params,
const KURL& base_url,
ScriptSourceLocationType source_location_type,
Modulator* modulator,
const KURL& source_url,
const KURL& base_url,
const ScriptFetchOptions& options,
const TextPosition& start_position) {
// <spec step="1">If scripting is disabled for settings's responsible browsing
// context, then set source to the empty string.</spec>
ParkableString source_text;
if (!modulator->IsScriptingDisabled())
source_text = original_source_text;
if (modulator->IsScriptingDisabled())
params.ClearSourceText();
// <spec step="2">Let script be a new module script that this algorithm will
// subsequently initialize.</spec>
......@@ -45,10 +46,10 @@ JSModuleScript* JSModuleScript::Create(
ModuleRecordProduceCacheData* produce_cache_data = nullptr;
v8::Local<v8::Module> result = ModuleRecord::Compile(
isolate, source_text.ToString(), source_url, base_url, options,
start_position, exception_state, modulator->GetV8CacheOptions(),
cache_handler, source_location_type, &produce_cache_data);
v8::Local<v8::Module> result =
ModuleRecord::Compile(isolate, params, base_url, options, start_position,
exception_state, modulator->GetV8CacheOptions(),
source_location_type, &produce_cache_data);
// CreateInternal processes Steps 4 and 8-10.
//
......@@ -56,9 +57,9 @@ JSModuleScript* JSModuleScript::Create(
// Steps 8-13 before Step 6. In a case that compile failed, we will
// immediately turn the script into errored state. Thus the members will not
// be used for the speced algorithms, but may be used from inspector.
JSModuleScript* script =
CreateInternal(source_text.length(), modulator, result, source_url,
base_url, options, start_position, produce_cache_data);
JSModuleScript* script = CreateInternal(
params.GetSourceText().length(), modulator, result, params.SourceURL(),
base_url, options, start_position, produce_cache_data);
// <spec step="8">If result is a list of errors, then:</spec>
if (exception_state.HadException()) {
......
......@@ -5,20 +5,19 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_SCRIPT_JS_MODULE_SCRIPT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_SCRIPT_JS_MODULE_SCRIPT_H_
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/script/modulator.h"
#include "third_party/blink/renderer/core/script/module_script.h"
#include "third_party/blink/renderer/platform/bindings/name_client.h"
#include "third_party/blink/renderer/platform/bindings/parkable_string.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/weborigin/kurl_hash.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/platform/wtf/text/text_position.h"
namespace blink {
class KURL;
class Modulator;
class ModuleScriptCreationParams;
// JSModuleScript is a model object for the "JavaScript module script" spec
// concept. https://html.spec.whatwg.org/C/#javascript-module-script
class CORE_EXPORT JSModuleScript final : public ModuleScript,
......@@ -26,12 +25,10 @@ class CORE_EXPORT JSModuleScript final : public ModuleScript,
public:
// https://html.spec.whatwg.org/C/#creating-a-javascript-module-script
static JSModuleScript* Create(
const ParkableString& source_text,
SingleCachedMetadataHandler*,
const ModuleScriptCreationParams& params,
const KURL& base_url,
ScriptSourceLocationType,
Modulator*,
const KURL& source_url,
const KURL& base_url,
const ScriptFetchOptions&,
const TextPosition& start_position = TextPosition::MinimumPosition());
......
......@@ -8,6 +8,7 @@
#include "base/macros.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/bindings/core/v8/module_record.h"
#include "third_party/blink/renderer/bindings/core/v8/script_evaluation_result.h"
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
......
......@@ -11,6 +11,7 @@
#include "third_party/blink/renderer/bindings/core/v8/script_source_code.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h"
#include "third_party/blink/renderer/core/script/classic_script.h"
#include "third_party/blink/renderer/core/script/js_module_script.h"
#include "third_party/blink/renderer/core/script/value_wrapper_synthetic_module_script.h"
......@@ -80,11 +81,14 @@ class ModuleScriptTest : public ::testing::Test, public ParametrizedModuleTest {
Modulator* modulator,
const String& source_text,
SingleCachedMetadataHandler* cache_handler) {
return JSModuleScript::Create(
ModuleScriptCreationParams params(
KURL("https://fox.url/script.js"),
ModuleScriptCreationParams::ModuleType::kJavaScriptModule,
ParkableString(source_text.IsolatedCopy().ReleaseImpl()), cache_handler,
ScriptSourceLocationType::kExternalFile, modulator,
KURL("https://fox.url/script.js"), KURL("https://fox.url/"),
ScriptFetchOptions());
network::mojom::CredentialsMode::kOmit);
return JSModuleScript::Create(params, KURL("https://fox.url/"),
ScriptSourceLocationType::kExternalFile,
modulator, ScriptFetchOptions());
}
static ValueWrapperSyntheticModuleScript*
......
......@@ -25,6 +25,7 @@
#include "third_party/blink/renderer/core/script/script_loader.h"
#include "base/feature_list.h"
#include "services/network/public/mojom/fetch_api.mojom-shared.h"
#include "third_party/blink/public/common/feature_policy/feature_policy.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/feature_policy/feature_policy_feature.mojom-blink.h"
......@@ -44,6 +45,7 @@
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/loader/importance_attribute.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_script_fetch_request.h"
#include "third_party/blink/renderer/core/loader/subresource_integrity_helper.h"
#include "third_party/blink/renderer/core/script/classic_pending_script.h"
......@@ -706,10 +708,15 @@ bool ScriptLoader::PrepareScript(const TextPosition& script_start_position,
// <spec label="fetch-an-inline-module-script-graph" step="1">Let script
// be the result of creating a JavaScript module script using source
// text, settings object, base URL, and options.</spec>
ModuleScript* module_script =
JSModuleScript::Create(ParkableString(source_text.Impl()), nullptr,
ScriptSourceLocationType::kInline, modulator,
source_url, base_url, options, position);
ModuleScriptCreationParams params(
source_url,
ModuleScriptCreationParams::ModuleType::kJavaScriptModule,
ParkableString(source_text.Impl()), nullptr,
options.CredentialsMode());
ModuleScript* module_script = JSModuleScript::Create(
params, base_url, ScriptSourceLocationType::kInline, modulator,
options, position);
// <spec label="fetch-an-inline-module-script-graph" step="2">If script
// is null, asynchronously complete this algorithm with null, and abort
......
......@@ -39,8 +39,8 @@ ValueWrapperSyntheticModuleScript::CreateCSSWrapperSyntheticModuleScript(
v8::Local<v8::Value> error = V8ThrowException::CreateTypeError(
isolate, "Cannot create CSS Module in non-document context");
return ValueWrapperSyntheticModuleScript::CreateWithError(
v8::Local<v8::Value>(), settings_object, params->GetResponseUrl(),
KURL(), ScriptFetchOptions(), error);
v8::Local<v8::Value>(), settings_object, params->SourceURL(), KURL(),
ScriptFetchOptions(), error);
}
CSSStyleSheetInit* init = CSSStyleSheetInit::Create();
CSSStyleSheet* style_sheet =
......@@ -49,20 +49,20 @@ ValueWrapperSyntheticModuleScript::CreateCSSWrapperSyntheticModuleScript(
v8::Local<v8::Value> error = exception_state.GetException();
exception_state.ClearException();
return ValueWrapperSyntheticModuleScript::CreateWithError(
v8::Local<v8::Value>(), settings_object, params->GetResponseUrl(),
KURL(), ScriptFetchOptions(), error);
v8::Local<v8::Value>(), settings_object, params->SourceURL(), KURL(),
ScriptFetchOptions(), error);
}
style_sheet->replaceSync(params->GetSourceText().ToString(), exception_state);
if (exception_state.HadException()) {
v8::Local<v8::Value> error = exception_state.GetException();
exception_state.ClearException();
return ValueWrapperSyntheticModuleScript::CreateWithError(
v8::Local<v8::Value>(), settings_object, params->GetResponseUrl(),
KURL(), ScriptFetchOptions(), error);
v8::Local<v8::Value>(), settings_object, params->SourceURL(), KURL(),
ScriptFetchOptions(), error);
}
v8::Local<v8::Value> v8_value_stylesheet = ToV8(style_sheet, script_state);
return ValueWrapperSyntheticModuleScript::CreateWithDefaultExport(
v8_value_stylesheet, settings_object, params->GetResponseUrl(), KURL(),
v8_value_stylesheet, settings_object, params->SourceURL(), KURL(),
ScriptFetchOptions());
}
......@@ -77,7 +77,7 @@ ValueWrapperSyntheticModuleScript::CreateJSONWrapperSyntheticModuleScript(
v8::Isolate* isolate = context->GetIsolate();
v8::TryCatch try_catch(isolate);
v8::Local<v8::String> original_json =
V8String(isolate, params->GetSourceText().ToString());
V8String(isolate, params->GetSourceText());
v8::Local<v8::Value> parsed_json;
ExceptionState exception_state(isolate, ExceptionState::kExecutionContext,
"ModuleScriptLoader",
......@@ -101,11 +101,11 @@ ValueWrapperSyntheticModuleScript::CreateJSONWrapperSyntheticModuleScript(
v8::Local<v8::Value> error = exception_state.GetException();
exception_state.ClearException();
return ValueWrapperSyntheticModuleScript::CreateWithError(
parsed_json, settings_object, params->GetResponseUrl(), KURL(),
parsed_json, settings_object, params->SourceURL(), KURL(),
ScriptFetchOptions(), error);
} else {
return ValueWrapperSyntheticModuleScript::CreateWithDefaultExport(
parsed_json, settings_object, params->GetResponseUrl(), KURL(),
parsed_json, settings_object, params->SourceURL(), KURL(),
ScriptFetchOptions());
}
}
......
......@@ -26,7 +26,11 @@ v8::Local<v8::Module> ModuleTestBase::CompileModule(
String source,
const KURL& url,
ExceptionState& exception_state) {
return ModuleRecord::Compile(isolate, source, url, url, ScriptFetchOptions(),
ModuleScriptCreationParams params(
url, ModuleScriptCreationParams::ModuleType::kJavaScriptModule,
ParkableString(source.Impl()), nullptr,
network::mojom::CredentialsMode::kOmit);
return ModuleRecord::Compile(isolate, params, url, ScriptFetchOptions(),
TextPosition::MinimumPosition(),
exception_state);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment