| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/loader/modulescript/ModuleTreeLinker.h" | 5 #include "core/loader/modulescript/ModuleTreeLinker.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptModule.h" | 7 #include "bindings/core/v8/ScriptModule.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "bindings/core/v8/V8BindingForCore.h" | 9 #include "bindings/core/v8/V8BindingForCore.h" |
| 10 #include "bindings/core/v8/V8BindingForTesting.h" | 10 #include "bindings/core/v8/V8BindingForTesting.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 for (const auto& request : dependency_module_requests) { | 69 for (const auto& request : dependency_module_requests) { |
| 70 source_text.Append("import '"); | 70 source_text.Append("import '"); |
| 71 source_text.Append(request); | 71 source_text.Append(request); |
| 72 source_text.Append("';\n"); | 72 source_text.Append("';\n"); |
| 73 } | 73 } |
| 74 source_text.Append("export default 'grapes';"); | 74 source_text.Append("export default 'grapes';"); |
| 75 | 75 |
| 76 ScriptModule script_module = ScriptModule::Compile( | 76 ScriptModule script_module = ScriptModule::Compile( |
| 77 script_state_->GetIsolate(), source_text.ToString(), url.GetString(), | 77 script_state_->GetIsolate(), source_text.ToString(), url.GetString(), |
| 78 kSharableCrossOrigin); | 78 kSharableCrossOrigin); |
| 79 ModuleScript* module_script = | 79 ModuleScript* module_script = ModuleScript::CreateForTest( |
| 80 ModuleScript::Create(this, script_module, url, "", kParserInserted, | 80 this, script_module, url, "", kParserInserted, |
| 81 WebURLRequest::kFetchCredentialsModeOmit); | 81 WebURLRequest::kFetchCredentialsModeOmit); |
| 82 auto result_request = dependency_module_requests_map_.insert( | 82 auto result_request = dependency_module_requests_map_.insert( |
| 83 script_module, dependency_module_requests); | 83 script_module, dependency_module_requests); |
| 84 EXPECT_TRUE(result_request.is_new_entry); | 84 EXPECT_TRUE(result_request.is_new_entry); |
| 85 auto result_map = module_map_.insert(url, module_script); | 85 auto result_map = module_map_.insert(url, module_script); |
| 86 EXPECT_TRUE(result_map.is_new_entry); | 86 EXPECT_TRUE(result_map.is_new_entry); |
| 87 | 87 |
| 88 EXPECT_EQ(url, pending_request_url_); | 88 EXPECT_EQ(url, pending_request_url_); |
| 89 EXPECT_TRUE(pending_client_); | 89 EXPECT_TRUE(pending_client_); |
| 90 pending_client_->NotifyModuleLoadFinished(module_script); | 90 pending_client_->NotifyModuleLoadFinished(module_script); |
| 91 pending_client_.Clear(); | 91 pending_client_.Clear(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 114 pending_client->NotifyModuleTreeLoadFinished(nullptr); | 114 pending_client->NotifyModuleTreeLoadFinished(nullptr); |
| 115 return; | 115 return; |
| 116 } | 116 } |
| 117 EXPECT_EQ(ResolveResult::kSuccess, result); | 117 EXPECT_EQ(ResolveResult::kSuccess, result); |
| 118 | 118 |
| 119 ScriptState::Scope scope(script_state_.Get()); | 119 ScriptState::Scope scope(script_state_.Get()); |
| 120 | 120 |
| 121 ScriptModule script_module = ScriptModule::Compile( | 121 ScriptModule script_module = ScriptModule::Compile( |
| 122 script_state_->GetIsolate(), "export default 'pineapples';", | 122 script_state_->GetIsolate(), "export default 'pineapples';", |
| 123 url.GetString(), kSharableCrossOrigin); | 123 url.GetString(), kSharableCrossOrigin); |
| 124 ModuleScript* module_script = | 124 ModuleScript* module_script = ModuleScript::CreateForTest( |
| 125 ModuleScript::Create(this, script_module, url, "", kParserInserted, | 125 this, script_module, url, "", kParserInserted, |
| 126 WebURLRequest::kFetchCredentialsModeOmit); | 126 WebURLRequest::kFetchCredentialsModeOmit); |
| 127 auto result_map = module_map_.insert(url, module_script); | 127 auto result_map = module_map_.insert(url, module_script); |
| 128 EXPECT_TRUE(result_map.is_new_entry); | 128 EXPECT_TRUE(result_map.is_new_entry); |
| 129 | 129 |
| 130 pending_client->NotifyModuleTreeLoadFinished(module_script); | 130 pending_client->NotifyModuleTreeLoadFinished(module_script); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void SetInstantiateShouldFail(bool b) { instantiate_should_fail_ = b; } | 133 void SetInstantiateShouldFail(bool b) { instantiate_should_fail_ = b; } |
| 134 | 134 |
| 135 private: | 135 private: |
| 136 // Implements Modulator: | 136 // Implements Modulator: |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 GetModulator()->ResolveDependentTreeFetch( | 442 GetModulator()->ResolveDependentTreeFetch( |
| 443 url_dep2, ModuleTreeLinkerTestModulator::ResolveResult::kSuccess); | 443 url_dep2, ModuleTreeLinkerTestModulator::ResolveResult::kSuccess); |
| 444 | 444 |
| 445 EXPECT_TRUE(client->WasNotifyFinished()); | 445 EXPECT_TRUE(client->WasNotifyFinished()); |
| 446 ASSERT_TRUE(client->GetModuleScript()); | 446 ASSERT_TRUE(client->GetModuleScript()); |
| 447 EXPECT_EQ(client->GetModuleScript()->InstantiationState(), | 447 EXPECT_EQ(client->GetModuleScript()->InstantiationState(), |
| 448 ModuleInstantiationState::kInstantiated); | 448 ModuleInstantiationState::kInstantiated); |
| 449 } | 449 } |
| 450 | 450 |
| 451 } // namespace blink | 451 } // namespace blink |
| OLD | NEW |