Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: third_party/WebKit/Source/core/loader/modulescript/ModuleScriptLoaderTest.cpp

Issue 2796653003: Move ScriptState::forWorld/ScriptState::forMainWorld (Part 2) (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ModuleScriptLoader.h" 5 #include "core/loader/modulescript/ModuleScriptLoader.h"
6 6
7 #include "bindings/core/v8/V8Binding.h"
7 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
8 #include "core/dom/Modulator.h" 9 #include "core/dom/Modulator.h"
9 #include "core/dom/ModuleScript.h" 10 #include "core/dom/ModuleScript.h"
10 #include "core/loader/modulescript/ModuleScriptFetchRequest.h" 11 #include "core/loader/modulescript/ModuleScriptFetchRequest.h"
11 #include "core/loader/modulescript/ModuleScriptLoaderClient.h" 12 #include "core/loader/modulescript/ModuleScriptLoaderClient.h"
12 #include "core/loader/modulescript/ModuleScriptLoaderRegistry.h" 13 #include "core/loader/modulescript/ModuleScriptLoaderRegistry.h"
13 #include "core/testing/DummyModulator.h" 14 #include "core/testing/DummyModulator.h"
14 #include "core/testing/DummyPageHolder.h" 15 #include "core/testing/DummyPageHolder.h"
15 #include "platform/heap/Handle.h" 16 #include "platform/heap/Handle.h"
16 #include "platform/loader/fetch/ResourceFetcher.h" 17 #include "platform/loader/fetch/ResourceFetcher.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 Persistent<Modulator> m_modulator; 101 Persistent<Modulator> m_modulator;
101 }; 102 };
102 103
103 void ModuleScriptLoaderTest::SetUp() { 104 void ModuleScriptLoaderTest::SetUp() {
104 m_platform->advanceClockSeconds(1.); // For non-zero DocumentParserTimings 105 m_platform->advanceClockSeconds(1.); // For non-zero DocumentParserTimings
105 m_dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); 106 m_dummyPageHolder = DummyPageHolder::create(IntSize(500, 500));
106 document().setURL(KURL(KURL(), "https://example.test")); 107 document().setURL(KURL(KURL(), "https://example.test"));
107 m_fetcher = ResourceFetcher::create( 108 m_fetcher = ResourceFetcher::create(
108 MockFetchContext::create(MockFetchContext::kShouldLoadNewResource)); 109 MockFetchContext::create(MockFetchContext::kShouldLoadNewResource));
109 m_modulator = new ModuleScriptLoaderTestModulator( 110 m_modulator = new ModuleScriptLoaderTestModulator(
110 ScriptState::forMainWorld(&frame()), document().getSecurityOrigin()); 111 toScriptStateForMainWorld(&frame()), document().getSecurityOrigin());
111 } 112 }
112 113
113 TEST_F(ModuleScriptLoaderTest, fetchDataURL) { 114 TEST_F(ModuleScriptLoaderTest, fetchDataURL) {
114 ModuleScriptLoaderRegistry* registry = ModuleScriptLoaderRegistry::create(); 115 ModuleScriptLoaderRegistry* registry = ModuleScriptLoaderRegistry::create();
115 KURL url(KURL(), "data:text/javascript,export default 'grapes';"); 116 KURL url(KURL(), "data:text/javascript,export default 'grapes';");
116 ModuleScriptFetchRequest moduleRequest( 117 ModuleScriptFetchRequest moduleRequest(
117 url, String(), ParserInserted, WebURLRequest::FetchCredentialsModeOmit); 118 url, String(), ParserInserted, WebURLRequest::FetchCredentialsModeOmit);
118 TestModuleScriptLoaderClient* client = new TestModuleScriptLoaderClient; 119 TestModuleScriptLoaderClient* client = new TestModuleScriptLoaderClient;
119 registry->fetch(moduleRequest, ModuleGraphLevel::TopLevelModuleFetch, 120 registry->fetch(moduleRequest, ModuleGraphLevel::TopLevelModuleFetch,
120 modulator(), fetcher(), client); 121 modulator(), fetcher(), client);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 156
156 EXPECT_FALSE(client->wasNotifyFinished()) 157 EXPECT_FALSE(client->wasNotifyFinished())
157 << "ModuleScriptLoader unexpectedly finished synchronously."; 158 << "ModuleScriptLoader unexpectedly finished synchronously.";
158 m_platform->getURLLoaderMockFactory()->serveAsynchronousRequests(); 159 m_platform->getURLLoaderMockFactory()->serveAsynchronousRequests();
159 160
160 EXPECT_TRUE(client->wasNotifyFinished()); 161 EXPECT_TRUE(client->wasNotifyFinished());
161 EXPECT_FALSE(client->moduleScript()); 162 EXPECT_FALSE(client->moduleScript());
162 } 163 }
163 164
164 } // namespace blink 165 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698