#include "third_party/blink/renderer/core/script/script_loader.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
#include "services/network/public/mojom/fetch_api.mojom-shared.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/sanitize_script_errors.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/scriptable_document_parser.h"
#include "third_party/blink/renderer/core/dom/text.h"
#include "third_party/blink/renderer/core/frame/attribution_src_loader.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#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/html/html_document.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
#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/document_loader.h"
#include "third_party/blink/renderer/core/loader/fetch_priority_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/render_blocking_resource_manager.h"
#include "third_party/blink/renderer/core/loader/subresource_integrity_helper.h"
#include "third_party/blink/renderer/core/loader/url_matcher.h"
#include "third_party/blink/renderer/core/loader/web_bundle/script_web_bundle.h"
#include "third_party/blink/renderer/core/script/classic_pending_script.h"
#include "third_party/blink/renderer/core/script/classic_script.h"
#include "third_party/blink/renderer/core/script/import_map.h"
#include "third_party/blink/renderer/core/script/js_module_script.h"
#include "third_party/blink/renderer/core/script/modulator.h"
#include "third_party/blink/renderer/core/script/module_pending_script.h"
#include "third_party/blink/renderer/core/script/pending_import_map.h"
#include "third_party/blink/renderer/core/script/script.h"
#include "third_party/blink/renderer/core/script/script_element_base.h"
#include "third_party/blink/renderer/core/script/script_runner.h"
#include "third_party/blink/renderer/core/script_type_names.h"
#include "third_party/blink/renderer/core/speculation_rules/document_speculation_rules.h"
#include "third_party/blink/renderer/core/speculation_rules/speculation_rule_set.h"
#include "third_party/blink/renderer/core/speculation_rules/speculation_rules_metrics.h"
#include "third_party/blink/renderer/core/svg_names.h"
#include "third_party/blink/renderer/core/trustedtypes/trusted_types_util.h"
#include "third_party/blink/renderer/platform/bindings/parkable_string.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_client_settings_object_snapshot.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_parameters.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/subresource_integrity.h"
#include "third_party/blink/renderer/platform/network/mime/mime_type_registry.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/scheduler/public/task_attribution_tracker.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/weborigin/security_policy.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/string_hash.h"
#include "third_party/blink/renderer/platform/wtf/text/string_view.h"
namespace blink {
namespace {
scheduler::TaskAttributionInfo* GetRunningTask(ScriptState* script_state) { … }
}
ScriptLoader::ScriptLoader(ScriptElementBase* element,
const CreateElementFlags flags)
: … { … }
ScriptLoader::~ScriptLoader() { … }
void ScriptLoader::Trace(Visitor* visitor) const { … }
void ScriptLoader::DidNotifySubtreeInsertionsToDocument() { … }
void ScriptLoader::ChildrenChanged(
const ContainerNode::ChildrenChange& change) { … }
void ScriptLoader::HandleSourceAttribute(const String& source_url) { … }
void ScriptLoader::HandleAsyncAttribute() { … }
void ScriptLoader::Removed() { … }
void ScriptLoader::DocumentBaseURLChanged() { … }
namespace {
bool IsValidClassicScriptTypeAndLanguage(const String& type,
const String& language) { … }
bool IsSameSite(const KURL& url, const Document& element_document) { … }
bool IsDocumentReloadedOrFormSubmitted(const Document& element_document) { … }
bool IsEligibleCommon(const Document& element_document) { … }
bool IsEligibleForForceInOrder(const Document& element_document) { … }
bool IsEligibleForDelay(const Resource& resource,
const Document& element_document,
const ScriptElementBase& element) { … }
bool IsEligibleForLowPriorityScriptLoading(const Document& element_document,
const ScriptElementBase& element,
const KURL& url) { … }
bool IsEligibleForSelectiveInOrder(const Resource& resource,
const Document& element_document) { … }
ScriptRunner::DelayReasons DetermineDelayReasonsToWait(
ScriptRunner* script_runner,
bool is_eligible_for_delay) { … }
}
ScriptLoader::ScriptTypeAtPrepare ScriptLoader::GetScriptTypeAtPrepare(
const String& type,
const String& language) { … }
bool ScriptLoader::BlockForNoModule(ScriptTypeAtPrepare script_type,
bool nomodule) { … }
network::mojom::CredentialsMode ScriptLoader::ModuleScriptCredentialsMode(
CrossOriginAttributeValue cross_origin) { … }
PendingScript* ScriptLoader::PrepareScript(
ParserBlockingInlineOption parser_blocking_inline_option,
const TextPosition& script_start_position) { … }
ScriptSchedulingType ScriptLoader::GetScriptSchedulingTypePerSpec(
Document& element_document,
ParserBlockingInlineOption parser_blocking_inline_option) const { … }
void ScriptLoader::FetchModuleScriptTree(
const KURL& url,
ResourceFetcher* fetch_client_settings_object_fetcher,
Modulator* modulator,
const ScriptFetchOptions& options) { … }
PendingScript* ScriptLoader::TakePendingScript(
ScriptSchedulingType scheduling_type) { … }
void ScriptLoader::NotifyFinished() { … }
bool ScriptLoader::IsScriptForEventSupported() const { … }
String ScriptLoader::GetScriptText() const { … }
void ScriptLoader::AddSpeculationRuleSet(SpeculationRuleSet::Source* source) { … }
SpeculationRuleSet* ScriptLoader::RemoveSpeculationRuleSet() { … }
}