Lines 29-35
a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp_sec1
|
29 |
#include "CachedModuleScriptLoader.h" |
29 |
#include "CachedModuleScriptLoader.h" |
30 |
#include "CachedScript.h" |
30 |
#include "CachedScript.h" |
31 |
#include "CachedScriptFetcher.h" |
31 |
#include "CachedScriptFetcher.h" |
32 |
#include "Document.h" |
|
|
33 |
#include "Frame.h" |
32 |
#include "Frame.h" |
34 |
#include "JSDOMBinding.h" |
33 |
#include "JSDOMBinding.h" |
35 |
#include "JSDOMPromiseDeferred.h" |
34 |
#include "JSDOMPromiseDeferred.h" |
Lines 41-46
a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp_sec2
|
41 |
#include "ScriptSourceCode.h" |
40 |
#include "ScriptSourceCode.h" |
42 |
#include "SubresourceIntegrity.h" |
41 |
#include "SubresourceIntegrity.h" |
43 |
#include "WebCoreJSClientData.h" |
42 |
#include "WebCoreJSClientData.h" |
|
|
43 |
#include "WorkerModuleScriptLoader.h" |
44 |
#include "WorkerScriptFetcher.h" |
44 |
#include <JavaScriptCore/Completion.h> |
45 |
#include <JavaScriptCore/Completion.h> |
45 |
#include <JavaScriptCore/JSInternalPromise.h> |
46 |
#include <JavaScriptCore/JSInternalPromise.h> |
46 |
#include <JavaScriptCore/JSModuleRecord.h> |
47 |
#include <JavaScriptCore/JSModuleRecord.h> |
Lines 52-59
a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp_sec3
|
52 |
|
53 |
|
53 |
namespace WebCore { |
54 |
namespace WebCore { |
54 |
|
55 |
|
55 |
ScriptModuleLoader::ScriptModuleLoader(Document& document) |
56 |
ScriptModuleLoader::ScriptModuleLoader(ScriptExecutionContext& context, OwnerType ownerType) |
56 |
: m_document(document) |
57 |
: m_context(context) |
|
|
58 |
, m_ownerType(ownerType) |
57 |
{ |
59 |
{ |
58 |
} |
60 |
} |
59 |
|
61 |
|
Lines 68-74
static bool isRootModule(JSC::JSValue importerModuleKey)
a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp_sec4
|
68 |
return importerModuleKey.isSymbol() || importerModuleKey.isUndefined(); |
70 |
return importerModuleKey.isSymbol() || importerModuleKey.isUndefined(); |
69 |
} |
71 |
} |
70 |
|
72 |
|
71 |
static Expected<URL, String> resolveModuleSpecifier(Document& document, const String& specifier, const URL& baseURL) |
73 |
static Expected<URL, String> resolveModuleSpecifier(ScriptExecutionContext& context, ScriptModuleLoader::OwnerType ownerType, const String& specifier, const URL& baseURL) |
72 |
{ |
74 |
{ |
73 |
// https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-specifier |
75 |
// https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-specifier |
74 |
|
76 |
|
Lines 79-85
static Expected<URL, String> resolveModuleSpecifier(Document& document, const St
a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp_sec5
|
79 |
if (!specifier.startsWith('/') && !specifier.startsWith("./") && !specifier.startsWith("../")) |
81 |
if (!specifier.startsWith('/') && !specifier.startsWith("./") && !specifier.startsWith("../")) |
80 |
return makeUnexpected(makeString("Module specifier, '"_s, specifier, "' does not start with \"/\", \"./\", or \"../\". Referenced from "_s, baseURL.string())); |
82 |
return makeUnexpected(makeString("Module specifier, '"_s, specifier, "' does not start with \"/\", \"./\", or \"../\". Referenced from "_s, baseURL.string())); |
81 |
|
83 |
|
82 |
auto result = document.completeURL(specifier, baseURL); |
84 |
URL result; |
|
|
85 |
if (ownerType == ScriptModuleLoader::OwnerType::Document) |
86 |
result = downcast<Document>(context).completeURL(specifier, baseURL); |
87 |
else |
88 |
result = URL(baseURL, specifier); |
89 |
|
83 |
if (!result.isValid()) |
90 |
if (!result.isValid()) |
84 |
return makeUnexpected(makeString("Module name, '"_s, result.string(), "' does not resolve to a valid URL."_s)); |
91 |
return makeUnexpected(makeString("Module name, '"_s, result.string(), "' does not resolve to a valid URL."_s)); |
85 |
return result; |
92 |
return result; |
Lines 107-113
JSC::Identifier ScriptModuleLoader::resolve(JSC::JSGlobalObject* jsGlobalObject,
a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp_sec6
|
107 |
URL baseURL = responseURLFromRequestURL(*jsGlobalObject, importerModuleKey); |
114 |
URL baseURL = responseURLFromRequestURL(*jsGlobalObject, importerModuleKey); |
108 |
RETURN_IF_EXCEPTION(scope, { }); |
115 |
RETURN_IF_EXCEPTION(scope, { }); |
109 |
|
116 |
|
110 |
auto result = resolveModuleSpecifier(m_document, specifier, baseURL); |
117 |
auto result = resolveModuleSpecifier(m_context, m_ownerType, specifier, baseURL); |
111 |
if (!result) { |
118 |
if (!result) { |
112 |
JSC::throwTypeError(jsGlobalObject, scope, result.error()); |
119 |
JSC::throwTypeError(jsGlobalObject, scope, result.error()); |
113 |
return { }; |
120 |
return { }; |
Lines 161-173
JSC::JSInternalPromise* ScriptModuleLoader::fetch(JSC::JSGlobalObject* jsGlobalO
a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp_sec7
|
161 |
if (auto* scriptFetchParameters = JSC::jsDynamicCast<JSC::JSScriptFetchParameters*>(vm, parameters)) |
168 |
if (auto* scriptFetchParameters = JSC::jsDynamicCast<JSC::JSScriptFetchParameters*>(vm, parameters)) |
162 |
topLevelFetchParameters = static_cast<ModuleFetchParameters*>(&scriptFetchParameters->parameters()); |
169 |
topLevelFetchParameters = static_cast<ModuleFetchParameters*>(&scriptFetchParameters->parameters()); |
163 |
|
170 |
|
164 |
auto loader = CachedModuleScriptLoader::create(*this, deferred.get(), *static_cast<CachedScriptFetcher*>(JSC::jsCast<JSC::JSScriptFetcher*>(scriptFetcher)->fetcher()), WTFMove(topLevelFetchParameters)); |
171 |
if (m_ownerType == OwnerType::Document) { |
165 |
m_loaders.add(loader.copyRef()); |
172 |
auto loader = CachedModuleScriptLoader::create(*this, deferred.get(), *static_cast<CachedScriptFetcher*>(JSC::jsCast<JSC::JSScriptFetcher*>(scriptFetcher)->fetcher()), WTFMove(topLevelFetchParameters)); |
166 |
if (!loader->load(m_document, completedURL)) { |
173 |
m_loaders.add(loader.copyRef()); |
167 |
loader->clearClient(); |
174 |
if (!loader->load(downcast<Document>(m_context), WTFMove(completedURL))) { |
168 |
m_loaders.remove(WTFMove(loader)); |
175 |
loader->clearClient(); |
169 |
rejectToPropagateNetworkError(deferred.get(), ModuleFetchFailureKind::WasErrored, "Importing a module script failed."_s); |
176 |
m_loaders.remove(WTFMove(loader)); |
170 |
return jsPromise; |
177 |
rejectToPropagateNetworkError(deferred.get(), ModuleFetchFailureKind::WasErrored, "Importing a module script failed."_s); |
|
|
178 |
return jsPromise; |
179 |
} |
180 |
} else { |
181 |
auto loader = WorkerModuleScriptLoader::create(*this, deferred.get(), *static_cast<WorkerScriptFetcher*>(JSC::jsCast<JSC::JSScriptFetcher*>(scriptFetcher)->fetcher()), WTFMove(topLevelFetchParameters)); |
182 |
m_loaders.add(loader.copyRef()); |
183 |
loader->load(m_context, WTFMove(completedURL)); |
171 |
} |
184 |
} |
172 |
|
185 |
|
173 |
return jsPromise; |
186 |
return jsPromise; |
Lines 176-182
JSC::JSInternalPromise* ScriptModuleLoader::fetch(JSC::JSGlobalObject* jsGlobalO
a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp_sec8
|
176 |
URL ScriptModuleLoader::moduleURL(JSC::JSGlobalObject& jsGlobalObject, JSC::JSValue moduleKeyValue) |
189 |
URL ScriptModuleLoader::moduleURL(JSC::JSGlobalObject& jsGlobalObject, JSC::JSValue moduleKeyValue) |
177 |
{ |
190 |
{ |
178 |
if (moduleKeyValue.isSymbol()) |
191 |
if (moduleKeyValue.isSymbol()) |
179 |
return m_document.url(); |
192 |
return m_context.url(); |
180 |
|
193 |
|
181 |
ASSERT(moduleKeyValue.isString()); |
194 |
ASSERT(moduleKeyValue.isString()); |
182 |
return URL(URL(), asString(moduleKeyValue)->value(&jsGlobalObject)); |
195 |
return URL(URL(), asString(moduleKeyValue)->value(&jsGlobalObject)); |
Lines 187-194
URL ScriptModuleLoader::responseURLFromRequestURL(JSC::JSGlobalObject& jsGlobalO
a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp_sec9
|
187 |
JSC::VM& vm = jsGlobalObject.vm(); |
200 |
JSC::VM& vm = jsGlobalObject.vm(); |
188 |
auto scope = DECLARE_THROW_SCOPE(vm); |
201 |
auto scope = DECLARE_THROW_SCOPE(vm); |
189 |
|
202 |
|
190 |
if (isRootModule(moduleKeyValue)) |
203 |
if (isRootModule(moduleKeyValue)) { |
191 |
return m_document.baseURL(); |
204 |
if (m_ownerType == OwnerType::Document) |
|
|
205 |
return downcast<Document>(m_context).baseURL(); |
206 |
return m_context.url(); |
207 |
} |
192 |
|
208 |
|
193 |
ASSERT(!isRootModule(moduleKeyValue)); |
209 |
ASSERT(!isRootModule(moduleKeyValue)); |
194 |
ASSERT(moduleKeyValue.isString()); |
210 |
ASSERT(moduleKeyValue.isString()); |
Lines 219-226
JSC::JSValue ScriptModuleLoader::evaluate(JSC::JSGlobalObject* jsGlobalObject, J
a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp_sec10
|
219 |
if (!sourceURL.isValid()) |
235 |
if (!sourceURL.isValid()) |
220 |
return JSC::throwTypeError(jsGlobalObject, scope, "Module key is an invalid URL."_s); |
236 |
return JSC::throwTypeError(jsGlobalObject, scope, "Module key is an invalid URL."_s); |
221 |
|
237 |
|
222 |
if (auto* frame = m_document.frame()) |
238 |
if (m_ownerType == OwnerType::Document) { |
223 |
return frame->script().evaluateModule(sourceURL, *moduleRecord); |
239 |
if (auto* frame = downcast<Document>(m_context).frame()) |
|
|
240 |
return frame->script().evaluateModule(sourceURL, *moduleRecord); |
241 |
} else { |
242 |
ASSERT(is<WorkerOrWorkletGlobalScope>(m_context)); |
243 |
if (auto* script = downcast<WorkerOrWorkletGlobalScope>(m_context).script()) |
244 |
return script->evaluateModule(*moduleRecord); |
245 |
} |
224 |
return JSC::jsUndefined(); |
246 |
return JSC::jsUndefined(); |
225 |
} |
247 |
} |
226 |
|
248 |
|
Lines 248-255
JSC::JSInternalPromise* ScriptModuleLoader::importModule(JSC::JSGlobalObject* js
a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp_sec11
|
248 |
URL baseURL; |
270 |
URL baseURL; |
249 |
RefPtr<JSC::ScriptFetcher> scriptFetcher; |
271 |
RefPtr<JSC::ScriptFetcher> scriptFetcher; |
250 |
if (sourceOrigin.isNull()) { |
272 |
if (sourceOrigin.isNull()) { |
251 |
baseURL = m_document.baseURL(); |
273 |
if (m_ownerType == OwnerType::Document) { |
252 |
scriptFetcher = CachedScriptFetcher::create(m_document.charset()); |
274 |
baseURL = downcast<Document>(m_context).baseURL(); |
|
|
275 |
scriptFetcher = CachedScriptFetcher::create(downcast<Document>(m_context).charset()); |
276 |
} else { |
277 |
baseURL = m_context.url(); |
278 |
scriptFetcher = WorkerScriptFetcher::create(FetchOptions::Credentials::SameOrigin); |
279 |
} |
253 |
} else { |
280 |
} else { |
254 |
baseURL = URL(URL(), sourceOrigin.string()); |
281 |
baseURL = URL(URL(), sourceOrigin.string()); |
255 |
if (!baseURL.isValid()) |
282 |
if (!baseURL.isValid()) |
Lines 257-270
JSC::JSInternalPromise* ScriptModuleLoader::importModule(JSC::JSGlobalObject* js
a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp_sec12
|
257 |
|
284 |
|
258 |
if (sourceOrigin.fetcher()) |
285 |
if (sourceOrigin.fetcher()) |
259 |
scriptFetcher = sourceOrigin.fetcher(); |
286 |
scriptFetcher = sourceOrigin.fetcher(); |
260 |
else |
287 |
|
261 |
scriptFetcher = CachedScriptFetcher::create(m_document.charset()); |
288 |
if (!scriptFetcher) { |
|
|
289 |
if (m_ownerType == OwnerType::Document) |
290 |
scriptFetcher = CachedScriptFetcher::create(downcast<Document>(m_context).charset()); |
291 |
else |
292 |
scriptFetcher = WorkerScriptFetcher::create(FetchOptions::Credentials::SameOrigin); |
293 |
} |
262 |
} |
294 |
} |
263 |
ASSERT(baseURL.isValid()); |
295 |
ASSERT(baseURL.isValid()); |
264 |
ASSERT(scriptFetcher); |
296 |
ASSERT(scriptFetcher); |
265 |
|
297 |
|
266 |
auto specifier = moduleName->value(jsGlobalObject); |
298 |
auto specifier = moduleName->value(jsGlobalObject); |
267 |
auto result = resolveModuleSpecifier(m_document, specifier, baseURL); |
299 |
auto result = resolveModuleSpecifier(m_context, m_ownerType, specifier, baseURL); |
268 |
if (!result) |
300 |
if (!result) |
269 |
return rejectPromise(globalObject, TypeError, result.error()); |
301 |
return rejectPromise(globalObject, TypeError, result.error()); |
270 |
|
302 |
|
Lines 288-349
JSC::JSObject* ScriptModuleLoader::createImportMetaProperties(JSC::JSGlobalObjec
a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp_sec13
|
288 |
return metaProperties; |
320 |
return metaProperties; |
289 |
} |
321 |
} |
290 |
|
322 |
|
291 |
void ScriptModuleLoader::notifyFinished(CachedModuleScriptLoader& loader, RefPtr<DeferredPromise> promise) |
323 |
void ScriptModuleLoader::notifyFinished(ModuleScriptLoader& moduleScriptLoader, URL&& sourceURL, Ref<DeferredPromise> promise) |
292 |
{ |
324 |
{ |
293 |
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script |
325 |
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script |
294 |
|
326 |
|
295 |
URL sourceURL = loader.sourceURL(); |
327 |
if (!m_loaders.remove(&moduleScriptLoader)) |
296 |
if (!m_loaders.remove(&loader)) |
|
|
297 |
return; |
328 |
return; |
298 |
loader.clearClient(); |
329 |
moduleScriptLoader.clearClient(); |
299 |
|
330 |
|
300 |
auto& cachedScript = *loader.cachedScript(); |
331 |
if (m_ownerType == OwnerType::Document) { |
|
|
332 |
auto& loader = static_cast<CachedModuleScriptLoader&>(moduleScriptLoader); |
333 |
auto& cachedScript = *loader.cachedScript(); |
301 |
|
334 |
|
302 |
if (cachedScript.resourceError().isAccessControl()) { |
335 |
if (cachedScript.resourceError().isAccessControl()) { |
303 |
promise->reject(TypeError, "Cross-origin script load denied by Cross-Origin Resource Sharing policy."_s); |
336 |
rejectToPropagateNetworkError(promise.get(), ModuleFetchFailureKind::WasErrored, "Cross-origin script load denied by Cross-Origin Resource Sharing policy."_s); |
304 |
return; |
337 |
return; |
305 |
} |
338 |
} |
306 |
|
339 |
|
307 |
if (cachedScript.errorOccurred()) { |
340 |
if (cachedScript.errorOccurred()) { |
308 |
rejectToPropagateNetworkError(*promise, ModuleFetchFailureKind::WasErrored, "Importing a module script failed."_s); |
341 |
rejectToPropagateNetworkError(promise.get(), ModuleFetchFailureKind::WasErrored, "Importing a module script failed."_s); |
309 |
return; |
342 |
return; |
310 |
} |
343 |
} |
311 |
|
344 |
|
312 |
if (cachedScript.wasCanceled()) { |
345 |
if (cachedScript.wasCanceled()) { |
313 |
rejectToPropagateNetworkError(*promise, ModuleFetchFailureKind::WasCanceled, "Importing a module script is canceled."_s); |
346 |
rejectToPropagateNetworkError(promise.get(), ModuleFetchFailureKind::WasCanceled, "Importing a module script is canceled."_s); |
314 |
return; |
347 |
return; |
315 |
} |
348 |
} |
316 |
|
349 |
|
317 |
if (!MIMETypeRegistry::isSupportedJavaScriptMIMEType(cachedScript.response().mimeType())) { |
350 |
if (!MIMETypeRegistry::isSupportedJavaScriptMIMEType(cachedScript.response().mimeType())) { |
318 |
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script |
351 |
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script |
319 |
// The result of extracting a MIME type from response's header list (ignoring parameters) is not a JavaScript MIME type. |
352 |
// The result of extracting a MIME type from response's header list (ignoring parameters) is not a JavaScript MIME type. |
320 |
// For historical reasons, fetching a classic script does not include MIME type checking. In contrast, module scripts will fail to load if they are not of a correct MIME type. |
353 |
// For historical reasons, fetching a classic script does not include MIME type checking. In contrast, module scripts will fail to load if they are not of a correct MIME type. |
321 |
promise->reject(TypeError, makeString("'", cachedScript.response().mimeType(), "' is not a valid JavaScript MIME type.")); |
354 |
promise->reject(TypeError, makeString("'", cachedScript.response().mimeType(), "' is not a valid JavaScript MIME type.")); |
322 |
return; |
355 |
return; |
323 |
} |
356 |
} |
|
|
357 |
|
358 |
if (auto* parameters = loader.parameters()) { |
359 |
if (!matchIntegrityMetadata(cachedScript, parameters->integrity())) { |
360 |
promise->reject(TypeError, makeString("Cannot load script ", integrityMismatchDescription(cachedScript, parameters->integrity()))); |
361 |
return; |
362 |
} |
363 |
} |
364 |
|
365 |
URL responseURL = cachedScript.response().url(); |
366 |
// If we do not have redirection, we must reserve the source URL's fragment explicitly here since ResourceResponse::url() is the one when we first cache it to MemoryCache. |
367 |
// FIXME: We should track fragments through redirections. |
368 |
// https://bugs.webkit.org/show_bug.cgi?id=158420 |
369 |
// https://bugs.webkit.org/show_bug.cgi?id=210490 |
370 |
if (!cachedScript.hasRedirections() && cachedScript.response().source() != ResourceResponse::Source::ServiceWorker) { |
371 |
if (sourceURL.hasFragmentIdentifier()) |
372 |
responseURL.setFragmentIdentifier(sourceURL.fragmentIdentifier()); |
373 |
} |
374 |
|
375 |
m_requestURLToResponseURLMap.add(sourceURL.string(), WTFMove(responseURL)); |
376 |
promise->resolveWithCallback([&] (JSDOMGlobalObject& jsGlobalObject) { |
377 |
return JSC::JSSourceCode::create(jsGlobalObject.vm(), |
378 |
JSC::SourceCode { ScriptSourceCode { &cachedScript, JSC::SourceProviderSourceType::Module, loader.scriptFetcher() }.jsSourceCode() }); |
379 |
}); |
380 |
} else { |
381 |
auto& loader = static_cast<WorkerModuleScriptLoader&>(moduleScriptLoader); |
382 |
auto& workerScriptLoader = loader.scriptLoader(); |
324 |
|
383 |
|
325 |
if (auto* parameters = loader.parameters()) { |
384 |
if (workerScriptLoader.failed()) { |
326 |
if (!matchIntegrityMetadata(cachedScript, parameters->integrity())) { |
385 |
if (workerScriptLoader.error().isAccessControl()) { |
327 |
promise->reject(TypeError, makeString("Cannot load script ", integrityMismatchDescription(cachedScript, parameters->integrity()))); |
386 |
rejectToPropagateNetworkError(promise.get(), ModuleFetchFailureKind::WasErrored, "Cross-origin script load denied by Cross-Origin Resource Sharing policy."_s); |
|
|
387 |
return; |
388 |
} |
389 |
|
390 |
if (workerScriptLoader.error().isCancellation()) { |
391 |
rejectToPropagateNetworkError(promise.get(), ModuleFetchFailureKind::WasCanceled, "Importing a module script is canceled."_s); |
392 |
return; |
393 |
} |
394 |
|
395 |
rejectToPropagateNetworkError(promise.get(), ModuleFetchFailureKind::WasErrored, "Importing a module script failed."_s); |
328 |
return; |
396 |
return; |
329 |
} |
397 |
} |
330 |
} |
|
|
331 |
|
398 |
|
332 |
URL responseURL = cachedScript.response().url(); |
399 |
if (!MIMETypeRegistry::isSupportedJavaScriptMIMEType(workerScriptLoader.responseMIMEType())) { |
333 |
// If we do not have redirection, we must reserve the source URL's fragment explicitly here since ResourceResponse::url() is the one when we first cache it to MemoryCache. |
400 |
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script |
334 |
// FIXME: We should track fragments through redirections. |
401 |
// The result of extracting a MIME type from response's header list (ignoring parameters) is not a JavaScript MIME type. |
335 |
// https://bugs.webkit.org/show_bug.cgi?id=158420 |
402 |
// For historical reasons, fetching a classic script does not include MIME type checking. In contrast, module scripts will fail to load if they are not of a correct MIME type. |
336 |
// https://bugs.webkit.org/show_bug.cgi?id=210490 |
403 |
promise->reject(TypeError, makeString("'", workerScriptLoader.responseMIMEType(), "' is not a valid JavaScript MIME type.")); |
337 |
if (!cachedScript.hasRedirections() && cachedScript.response().source() != ResourceResponse::Source::ServiceWorker) { |
404 |
return; |
338 |
if (sourceURL.hasFragmentIdentifier()) |
405 |
} |
339 |
responseURL.setFragmentIdentifier(sourceURL.fragmentIdentifier()); |
|
|
340 |
} |
341 |
|
406 |
|
342 |
m_requestURLToResponseURLMap.add(sourceURL.string(), WTFMove(responseURL)); |
407 |
URL responseURL = workerScriptLoader.responseURL(); |
343 |
promise->resolveWithCallback([&] (JSDOMGlobalObject& jsGlobalObject) { |
408 |
|
344 |
return JSC::JSSourceCode::create(jsGlobalObject.vm(), |
409 |
// If we do not have redirection, we must reserve the source URL's fragment explicitly here since ResourceResponse::url() is the one when we first cache it to MemoryCache. |
345 |
JSC::SourceCode { ScriptSourceCode { &cachedScript, JSC::SourceProviderSourceType::Module, loader.scriptFetcher() }.jsSourceCode() }); |
410 |
// FIXME: We should track fragments through redirections. |
346 |
}); |
411 |
// https://bugs.webkit.org/show_bug.cgi?id=158420 |
|
|
412 |
// https://bugs.webkit.org/show_bug.cgi?id=210490 |
413 |
if (!workerScriptLoader.isRedirected() && workerScriptLoader.responseSource() != ResourceResponse::Source::ServiceWorker) { |
414 |
if (sourceURL.hasFragmentIdentifier()) |
415 |
responseURL.setFragmentIdentifier(sourceURL.fragmentIdentifier()); |
416 |
} |
417 |
|
418 |
m_requestURLToResponseURLMap.add(sourceURL.string(), responseURL); |
419 |
promise->resolveWithCallback([&] (JSDOMGlobalObject& jsGlobalObject) { |
420 |
return JSC::JSSourceCode::create(jsGlobalObject.vm(), |
421 |
JSC::SourceCode { ScriptSourceCode { workerScriptLoader.script(), WTFMove(responseURL), { }, JSC::SourceProviderSourceType::Module, loader.scriptFetcher() }.jsSourceCode() }); |
422 |
}); |
423 |
} |
347 |
} |
424 |
} |
348 |
|
425 |
|
349 |
} |
426 |
} |