summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/loader/modulescript/module_tree_linker_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/loader/modulescript/module_tree_linker_test.cc')
-rw-r--r--chromium/third_party/blink/renderer/core/loader/modulescript/module_tree_linker_test.cc78
1 files changed, 43 insertions, 35 deletions
diff --git a/chromium/third_party/blink/renderer/core/loader/modulescript/module_tree_linker_test.cc b/chromium/third_party/blink/renderer/core/loader/modulescript/module_tree_linker_test.cc
index 740d58e07ce..b0c1f9aad10 100644
--- a/chromium/third_party/blink/renderer/core/loader/modulescript/module_tree_linker_test.cc
+++ b/chromium/third_party/blink/renderer/core/loader/modulescript/module_tree_linker_test.cc
@@ -14,11 +14,13 @@
#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/dom/document.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/modulescript/module_tree_linker_registry.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/testing/dummy_modulator.h"
+#include "third_party/blink/renderer/core/testing/module_test_base.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h"
@@ -58,7 +60,7 @@ class TestModuleTreeClient final : public ModuleTreeClient {
class ModuleTreeLinkerTestModulator final : public DummyModulator {
public:
- ModuleTreeLinkerTestModulator(ScriptState* script_state)
+ explicit ModuleTreeLinkerTestModulator(ScriptState* script_state)
: script_state_(script_state) {}
~ModuleTreeLinkerTestModulator() override = default;
@@ -81,10 +83,8 @@ class ModuleTreeLinkerTestModulator final : public DummyModulator {
}
source_text.Append("export default 'grapes';");
- v8::Local<v8::Module> module_record = ModuleRecord::Compile(
- script_state_->GetIsolate(), source_text.ToString(), url, url,
- ScriptFetchOptions(), TextPosition::MinimumPosition(),
- ASSERT_NO_EXCEPTION);
+ v8::Local<v8::Module> module_record = ModuleTestBase::CompileModule(
+ script_state_->GetIsolate(), source_text.ToString(), url);
auto* module_script =
JSModuleScript::CreateForTest(this, module_record, url);
@@ -129,7 +129,7 @@ class ModuleTreeLinkerTestModulator final : public DummyModulator {
String* failure_reason) final {
return KURL(base_url, module_request);
}
- void ClearIsAcquiringImportMaps() final {}
+ void SetAcquiringImportMapsState(AcquiringImportMapsState) final {}
void FetchSingle(const ModuleScriptFetchRequest& request,
ResourceFetcher*,
@@ -140,7 +140,8 @@ class ModuleTreeLinkerTestModulator final : public DummyModulator {
pending_clients_.Set(request.Url(), client);
}
- ModuleScript* GetFetchedModuleScript(const KURL& url) override {
+ ModuleScript* GetFetchedModuleScript(const KURL& url,
+ ModuleType module_type) override {
const auto& it = module_map_.find(url);
if (it == module_map_.end())
return nullptr;
@@ -207,10 +208,11 @@ TEST_F(ModuleTreeLinkerTest, FetchTreeNoDeps) {
KURL url("http://example.com/root.js");
TestModuleTreeClient* client = MakeGarbageCollected<TestModuleTreeClient>();
- ModuleTreeLinker::Fetch(
- url, GetDocument().Fetcher(), mojom::blink::RequestContextType::SCRIPT,
- network::mojom::RequestDestination::kScript, ScriptFetchOptions(),
- GetModulator(), ModuleScriptCustomFetchType::kNone, registry, client);
+ ModuleTreeLinker::Fetch(url, ModuleType::kJavaScript, GetDocument().Fetcher(),
+ mojom::blink::RequestContextType::SCRIPT,
+ network::mojom::RequestDestination::kScript,
+ ScriptFetchOptions(), GetModulator(),
+ ModuleScriptCustomFetchType::kNone, registry, client);
EXPECT_FALSE(client->WasNotifyFinished())
<< "ModuleTreeLinker should always finish asynchronously.";
@@ -230,10 +232,11 @@ TEST_F(ModuleTreeLinkerTest, FetchTreeInstantiationFailure) {
KURL url("http://example.com/root.js");
TestModuleTreeClient* client = MakeGarbageCollected<TestModuleTreeClient>();
- ModuleTreeLinker::Fetch(
- url, GetDocument().Fetcher(), mojom::blink::RequestContextType::SCRIPT,
- network::mojom::RequestDestination::kScript, ScriptFetchOptions(),
- GetModulator(), ModuleScriptCustomFetchType::kNone, registry, client);
+ ModuleTreeLinker::Fetch(url, ModuleType::kJavaScript, GetDocument().Fetcher(),
+ mojom::blink::RequestContextType::SCRIPT,
+ network::mojom::RequestDestination::kScript,
+ ScriptFetchOptions(), GetModulator(),
+ ModuleScriptCustomFetchType::kNone, registry, client);
EXPECT_FALSE(client->WasNotifyFinished())
<< "ModuleTreeLinker should always finish asynchronously.";
@@ -257,10 +260,11 @@ TEST_F(ModuleTreeLinkerTest, FetchTreeWithSingleDependency) {
KURL url("http://example.com/root.js");
TestModuleTreeClient* client = MakeGarbageCollected<TestModuleTreeClient>();
- ModuleTreeLinker::Fetch(
- url, GetDocument().Fetcher(), mojom::blink::RequestContextType::SCRIPT,
- network::mojom::RequestDestination::kScript, ScriptFetchOptions(),
- GetModulator(), ModuleScriptCustomFetchType::kNone, registry, client);
+ ModuleTreeLinker::Fetch(url, ModuleType::kJavaScript, GetDocument().Fetcher(),
+ mojom::blink::RequestContextType::SCRIPT,
+ network::mojom::RequestDestination::kScript,
+ ScriptFetchOptions(), GetModulator(),
+ ModuleScriptCustomFetchType::kNone, registry, client);
EXPECT_FALSE(client->WasNotifyFinished())
<< "ModuleTreeLinker should always finish asynchronously.";
@@ -285,10 +289,11 @@ TEST_F(ModuleTreeLinkerTest, FetchTreeWith3Deps) {
KURL url("http://example.com/root.js");
TestModuleTreeClient* client = MakeGarbageCollected<TestModuleTreeClient>();
- ModuleTreeLinker::Fetch(
- url, GetDocument().Fetcher(), mojom::blink::RequestContextType::SCRIPT,
- network::mojom::RequestDestination::kScript, ScriptFetchOptions(),
- GetModulator(), ModuleScriptCustomFetchType::kNone, registry, client);
+ ModuleTreeLinker::Fetch(url, ModuleType::kJavaScript, GetDocument().Fetcher(),
+ mojom::blink::RequestContextType::SCRIPT,
+ network::mojom::RequestDestination::kScript,
+ ScriptFetchOptions(), GetModulator(),
+ ModuleScriptCustomFetchType::kNone, registry, client);
EXPECT_FALSE(client->WasNotifyFinished())
<< "ModuleTreeLinker should always finish asynchronously.";
@@ -326,10 +331,11 @@ TEST_F(ModuleTreeLinkerTest, FetchTreeWith3Deps1Fail) {
KURL url("http://example.com/root.js");
TestModuleTreeClient* client = MakeGarbageCollected<TestModuleTreeClient>();
- ModuleTreeLinker::Fetch(
- url, GetDocument().Fetcher(), mojom::blink::RequestContextType::SCRIPT,
- network::mojom::RequestDestination::kScript, ScriptFetchOptions(),
- GetModulator(), ModuleScriptCustomFetchType::kNone, registry, client);
+ ModuleTreeLinker::Fetch(url, ModuleType::kJavaScript, GetDocument().Fetcher(),
+ mojom::blink::RequestContextType::SCRIPT,
+ network::mojom::RequestDestination::kScript,
+ ScriptFetchOptions(), GetModulator(),
+ ModuleScriptCustomFetchType::kNone, registry, client);
EXPECT_FALSE(client->WasNotifyFinished())
<< "ModuleTreeLinker should always finish asynchronously.";
@@ -386,10 +392,11 @@ TEST_F(ModuleTreeLinkerTest, FetchDependencyTree) {
KURL url("http://example.com/depth1.js");
TestModuleTreeClient* client = MakeGarbageCollected<TestModuleTreeClient>();
- ModuleTreeLinker::Fetch(
- url, GetDocument().Fetcher(), mojom::blink::RequestContextType::SCRIPT,
- network::mojom::RequestDestination::kScript, ScriptFetchOptions(),
- GetModulator(), ModuleScriptCustomFetchType::kNone, registry, client);
+ ModuleTreeLinker::Fetch(url, ModuleType::kJavaScript, GetDocument().Fetcher(),
+ mojom::blink::RequestContextType::SCRIPT,
+ network::mojom::RequestDestination::kScript,
+ ScriptFetchOptions(), GetModulator(),
+ ModuleScriptCustomFetchType::kNone, registry, client);
EXPECT_FALSE(client->WasNotifyFinished())
<< "ModuleTreeLinker should always finish asynchronously.";
@@ -413,10 +420,11 @@ TEST_F(ModuleTreeLinkerTest, FetchDependencyOfCyclicGraph) {
KURL url("http://example.com/a.js");
TestModuleTreeClient* client = MakeGarbageCollected<TestModuleTreeClient>();
- ModuleTreeLinker::Fetch(
- url, GetDocument().Fetcher(), mojom::blink::RequestContextType::SCRIPT,
- network::mojom::RequestDestination::kScript, ScriptFetchOptions(),
- GetModulator(), ModuleScriptCustomFetchType::kNone, registry, client);
+ ModuleTreeLinker::Fetch(url, ModuleType::kJavaScript, GetDocument().Fetcher(),
+ mojom::blink::RequestContextType::SCRIPT,
+ network::mojom::RequestDestination::kScript,
+ ScriptFetchOptions(), GetModulator(),
+ ModuleScriptCustomFetchType::kNone, registry, client);
EXPECT_FALSE(client->WasNotifyFinished())
<< "ModuleTreeLinker should always finish asynchronously.";