Commit 56367281 authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

Reduce usage of ModuleScript::IsErrored() and HasInstantiated() in tests

IsErrored() and HasInstantiated() are to be removed because they are
removed from the HTML spec in
https://github.com/whatwg/html/pull/2991.

This CL
- Replaces IsErrored() calls in unit tests with checks for Instantiate()
  results or with HasEmptyRecord(), depending on whether instantiation errors
  or parse errors are tested, and
- Removes EXPECT_FALSE(HasInstantiated()) from ModuleMapTest.cpp, because
  instantiation is already prohibited by NOTREACHED() in
  DummyModulator::InstantiateModule().

Bug: 763597
Change-Id: I272a03f3d5ce8ddf6ea645a3d0d1a1ae7543f2be
Reviewed-on: https://chromium-review.googlesource.com/703483Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Commit-Queue: Kouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506947}
parent f67b0fc0
...@@ -215,8 +215,7 @@ TEST(DynamicModuleResolverTest, ResolveSuccess) { ...@@ -215,8 +215,7 @@ TEST(DynamicModuleResolverTest, ResolveSuccess) {
ModuleScript* module_script = ModuleScript::CreateForTest( ModuleScript* module_script = ModuleScript::CreateForTest(
modulator, record, TestDependencyURL(), "nonce", kNotParserInserted, modulator, record, TestDependencyURL(), "nonce", kNotParserInserted,
WebURLRequest::kFetchCredentialsModeOmit); WebURLRequest::kFetchCredentialsModeOmit);
record.Instantiate(scope.GetScriptState()); EXPECT_TRUE(record.Instantiate(scope.GetScriptState()).IsEmpty());
EXPECT_FALSE(module_script->IsErrored());
modulator->ResolveTreeFetch(module_script); modulator->ResolveTreeFetch(module_script);
v8::MicrotasksScope::PerformCheckpoint(scope.GetIsolate()); v8::MicrotasksScope::PerformCheckpoint(scope.GetIsolate());
...@@ -297,8 +296,7 @@ TEST(DynamicModuleResolverTest, ExceptionThrown) { ...@@ -297,8 +296,7 @@ TEST(DynamicModuleResolverTest, ExceptionThrown) {
ModuleScript* module_script = ModuleScript::CreateForTest( ModuleScript* module_script = ModuleScript::CreateForTest(
modulator, record, TestDependencyURL(), "nonce", kNotParserInserted, modulator, record, TestDependencyURL(), "nonce", kNotParserInserted,
WebURLRequest::kFetchCredentialsModeOmit); WebURLRequest::kFetchCredentialsModeOmit);
record.Instantiate(scope.GetScriptState()); EXPECT_TRUE(record.Instantiate(scope.GetScriptState()).IsEmpty());
EXPECT_FALSE(module_script->IsErrored());
modulator->ResolveTreeFetch(module_script); modulator->ResolveTreeFetch(module_script);
v8::MicrotasksScope::PerformCheckpoint(scope.GetIsolate()); v8::MicrotasksScope::PerformCheckpoint(scope.GetIsolate());
...@@ -336,8 +334,7 @@ TEST(DynamicModuleResolverTest, ResolveWithNullReferrerScriptSuccess) { ...@@ -336,8 +334,7 @@ TEST(DynamicModuleResolverTest, ResolveWithNullReferrerScriptSuccess) {
ModuleScript* module_script = ModuleScript::CreateForTest( ModuleScript* module_script = ModuleScript::CreateForTest(
modulator, record, TestDependencyURL(), "nonce", kNotParserInserted, modulator, record, TestDependencyURL(), "nonce", kNotParserInserted,
WebURLRequest::kFetchCredentialsModeOmit); WebURLRequest::kFetchCredentialsModeOmit);
record.Instantiate(scope.GetScriptState()); EXPECT_TRUE(record.Instantiate(scope.GetScriptState()).IsEmpty());
EXPECT_FALSE(module_script->IsErrored());
modulator->ResolveTreeFetch(module_script); modulator->ResolveTreeFetch(module_script);
v8::MicrotasksScope::PerformCheckpoint(scope.GetIsolate()); v8::MicrotasksScope::PerformCheckpoint(scope.GetIsolate());
......
...@@ -187,7 +187,6 @@ TEST_F(ModuleMapTest, sequentialRequests) { ...@@ -187,7 +187,6 @@ TEST_F(ModuleMapTest, sequentialRequests) {
1); 1);
EXPECT_TRUE(client->WasNotifyFinished()); EXPECT_TRUE(client->WasNotifyFinished());
EXPECT_TRUE(client->GetModuleScript()); EXPECT_TRUE(client->GetModuleScript());
EXPECT_FALSE(client->GetModuleScript()->HasInstantiated());
// Secondary request // Secondary request
TestSingleModuleClient* client2 = new TestSingleModuleClient; TestSingleModuleClient* client2 = new TestSingleModuleClient;
...@@ -205,7 +204,6 @@ TEST_F(ModuleMapTest, sequentialRequests) { ...@@ -205,7 +204,6 @@ TEST_F(ModuleMapTest, sequentialRequests) {
<< "registerModuleScript sholudn't be called in secondary request."; << "registerModuleScript sholudn't be called in secondary request.";
EXPECT_TRUE(client2->WasNotifyFinished()); EXPECT_TRUE(client2->WasNotifyFinished());
EXPECT_TRUE(client2->GetModuleScript()); EXPECT_TRUE(client2->GetModuleScript());
EXPECT_FALSE(client2->GetModuleScript()->HasInstantiated());
} }
TEST_F(ModuleMapTest, concurrentRequestsShouldJoin) { TEST_F(ModuleMapTest, concurrentRequestsShouldJoin) {
...@@ -241,10 +239,8 @@ TEST_F(ModuleMapTest, concurrentRequestsShouldJoin) { ...@@ -241,10 +239,8 @@ TEST_F(ModuleMapTest, concurrentRequestsShouldJoin) {
EXPECT_TRUE(client->WasNotifyFinished()); EXPECT_TRUE(client->WasNotifyFinished());
EXPECT_TRUE(client->GetModuleScript()); EXPECT_TRUE(client->GetModuleScript());
EXPECT_FALSE(client->GetModuleScript()->HasInstantiated());
EXPECT_TRUE(client2->WasNotifyFinished()); EXPECT_TRUE(client2->WasNotifyFinished());
EXPECT_TRUE(client2->GetModuleScript()); EXPECT_TRUE(client2->GetModuleScript());
EXPECT_FALSE(client2->GetModuleScript()->HasInstantiated());
} }
} // namespace blink } // namespace blink
...@@ -207,7 +207,7 @@ TEST_F(ModuleScriptLoaderTest, FetchDataURL) { ...@@ -207,7 +207,7 @@ TEST_F(ModuleScriptLoaderTest, FetchDataURL) {
EXPECT_TRUE(client->WasNotifyFinished()) EXPECT_TRUE(client->WasNotifyFinished())
<< "ModuleScriptLoader should finish synchronously."; << "ModuleScriptLoader should finish synchronously.";
ASSERT_TRUE(client->GetModuleScript()); ASSERT_TRUE(client->GetModuleScript());
EXPECT_FALSE(client->GetModuleScript()->IsErrored()); EXPECT_FALSE(client->GetModuleScript()->HasEmptyRecord());
} }
TEST_F(ModuleScriptLoaderTest, FetchDataURL_OnWorklet) { TEST_F(ModuleScriptLoaderTest, FetchDataURL_OnWorklet) {
...@@ -221,7 +221,7 @@ TEST_F(ModuleScriptLoaderTest, FetchDataURL_OnWorklet) { ...@@ -221,7 +221,7 @@ TEST_F(ModuleScriptLoaderTest, FetchDataURL_OnWorklet) {
EXPECT_TRUE(client1->WasNotifyFinished()); EXPECT_TRUE(client1->WasNotifyFinished());
ASSERT_TRUE(client1->GetModuleScript()); ASSERT_TRUE(client1->GetModuleScript());
EXPECT_FALSE(client1->GetModuleScript()->IsErrored()); EXPECT_FALSE(client1->GetModuleScript()->HasEmptyRecord());
// Try to fetch the same URL again in order to verify the case where // Try to fetch the same URL again in order to verify the case where
// WorkletModuleResponsesMap serves a cache. // WorkletModuleResponsesMap serves a cache.
...@@ -234,7 +234,7 @@ TEST_F(ModuleScriptLoaderTest, FetchDataURL_OnWorklet) { ...@@ -234,7 +234,7 @@ TEST_F(ModuleScriptLoaderTest, FetchDataURL_OnWorklet) {
EXPECT_TRUE(client2->WasNotifyFinished()); EXPECT_TRUE(client2->WasNotifyFinished());
ASSERT_TRUE(client2->GetModuleScript()); ASSERT_TRUE(client2->GetModuleScript());
EXPECT_FALSE(client2->GetModuleScript()->IsErrored()); EXPECT_FALSE(client2->GetModuleScript()->HasEmptyRecord());
} }
void ModuleScriptLoaderTest::TestInvalidSpecifier( void ModuleScriptLoaderTest::TestInvalidSpecifier(
...@@ -257,7 +257,7 @@ TEST_F(ModuleScriptLoaderTest, InvalidSpecifier) { ...@@ -257,7 +257,7 @@ TEST_F(ModuleScriptLoaderTest, InvalidSpecifier) {
EXPECT_TRUE(client->WasNotifyFinished()) EXPECT_TRUE(client->WasNotifyFinished())
<< "ModuleScriptLoader should finish synchronously."; << "ModuleScriptLoader should finish synchronously.";
ASSERT_TRUE(client->GetModuleScript()); ASSERT_TRUE(client->GetModuleScript());
EXPECT_TRUE(client->GetModuleScript()->IsErrored()); EXPECT_TRUE(client->GetModuleScript()->HasEmptyRecord());
} }
TEST_F(ModuleScriptLoaderTest, InvalidSpecifier_OnWorklet) { TEST_F(ModuleScriptLoaderTest, InvalidSpecifier_OnWorklet) {
...@@ -271,7 +271,7 @@ TEST_F(ModuleScriptLoaderTest, InvalidSpecifier_OnWorklet) { ...@@ -271,7 +271,7 @@ TEST_F(ModuleScriptLoaderTest, InvalidSpecifier_OnWorklet) {
EXPECT_TRUE(client->WasNotifyFinished()); EXPECT_TRUE(client->WasNotifyFinished());
ASSERT_TRUE(client->GetModuleScript()); ASSERT_TRUE(client->GetModuleScript());
EXPECT_TRUE(client->GetModuleScript()->IsErrored()); EXPECT_TRUE(client->GetModuleScript()->HasEmptyRecord());
} }
void ModuleScriptLoaderTest::TestFetchInvalidURL( void ModuleScriptLoaderTest::TestFetchInvalidURL(
......
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