| Differences between
and this patch
- a/Source/JavaScriptCore/ChangeLog +51 lines
Lines 1-3 a/Source/JavaScriptCore/ChangeLog_sec1
1
2021-02-12  Yusuke Suzuki  <ysuzuki@apple.com>
2
3
        JS Modules in Workers
4
        https://bugs.webkit.org/show_bug.cgi?id=164860
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * runtime/AggregateError.cpp:
9
        (JSC::AggregateError::AggregateError):
10
        * runtime/Error.cpp:
11
        (JSC::createError):
12
        (JSC::createEvalError):
13
        (JSC::createRangeError):
14
        (JSC::createReferenceError):
15
        (JSC::createSyntaxError):
16
        (JSC::createTypeError):
17
        (JSC::createURIError):
18
        (JSC::createGetterTypeError):
19
        (JSC::throwSyntaxError):
20
        * runtime/Error.h:
21
        * runtime/ErrorConstructor.cpp:
22
        (JSC::JSC_DEFINE_HOST_FUNCTION):
23
        * runtime/ErrorInstance.cpp:
24
        (JSC::ErrorInstance::ErrorInstance):
25
        (JSC::ErrorInstance::create):
26
        (JSC::ErrorInstance::sanitizedMessageString):
27
        (JSC::ErrorInstance::sanitizedNameString):
28
        (JSC::ErrorInstance::sanitizedToString):
29
        * runtime/ErrorInstance.h:
30
        (JSC::ErrorInstance::create):
31
        (JSC::ErrorInstance::errorType const):
32
        * runtime/JSGlobalObjectFunctions.cpp:
33
        (JSC::JSC_DEFINE_HOST_FUNCTION):
34
        * runtime/NativeErrorConstructor.cpp:
35
        (JSC::NativeErrorConstructor<errorType>::constructImpl):
36
        (JSC::NativeErrorConstructor<errorType>::callImpl):
37
        * runtime/NullSetterFunction.cpp:
38
        (JSC::NullSetterFunctionInternal::JSC_DEFINE_HOST_FUNCTION):
39
        * wasm/js/JSWebAssemblyCompileError.cpp:
40
        (JSC::JSWebAssemblyCompileError::JSWebAssemblyCompileError):
41
        * wasm/js/JSWebAssemblyLinkError.cpp:
42
        (JSC::JSWebAssemblyLinkError::JSWebAssemblyLinkError):
43
        * wasm/js/JSWebAssemblyRuntimeError.cpp:
44
        (JSC::JSWebAssemblyRuntimeError::JSWebAssemblyRuntimeError):
45
        * wasm/js/WebAssemblyCompileErrorConstructor.cpp:
46
        (JSC::JSC_DEFINE_HOST_FUNCTION):
47
        * wasm/js/WebAssemblyLinkErrorConstructor.cpp:
48
        (JSC::JSC_DEFINE_HOST_FUNCTION):
49
        * wasm/js/WebAssemblyRuntimeErrorConstructor.cpp:
50
        (JSC::JSC_DEFINE_HOST_FUNCTION):
51
1
2021-02-11  Nikita Vasilyev  <nvasilyev@apple.com>
52
2021-02-11  Nikita Vasilyev  <nvasilyev@apple.com>
2
53
3
        Web Inspector: "Show Extended Gridlines" option for grid overlay does not work
54
        Web Inspector: "Show Extended Gridlines" option for grid overlay does not work
- a/Source/WebCore/ChangeLog +129 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2021-02-12  Yusuke Suzuki  <ysuzuki@apple.com>
2
3
        JS Modules in Workers
4
        https://bugs.webkit.org/show_bug.cgi?id=164860
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * Headers.cmake:
9
        * Sources.txt:
10
        * WebCore.xcodeproj/project.pbxproj:
11
        * bindings/js/CachedModuleScriptLoader.cpp:
12
        (WebCore::CachedModuleScriptLoader::create):
13
        (WebCore::CachedModuleScriptLoader::CachedModuleScriptLoader):
14
        (WebCore::CachedModuleScriptLoader::load):
15
        (WebCore::CachedModuleScriptLoader::notifyFinished):
16
        * bindings/js/CachedModuleScriptLoader.h:
17
        * bindings/js/CachedScriptFetcher.cpp:
18
        (WebCore::CachedScriptFetcher::requestScriptWithCache const):
19
        * bindings/js/JSDOMExceptionHandling.cpp:
20
        (WebCore::retrieveErrorMessageWithoutName):
21
        (WebCore::createDOMException):
22
        * bindings/js/JSDOMExceptionHandling.h:
23
        * bindings/js/JSDOMGlobalObject.cpp:
24
        (WebCore::scriptModuleLoader):
25
        (WebCore::JSDOMGlobalObject::moduleLoaderResolve):
26
        (WebCore::JSDOMGlobalObject::moduleLoaderFetch):
27
        (WebCore::JSDOMGlobalObject::moduleLoaderEvaluate):
28
        (WebCore::JSDOMGlobalObject::moduleLoaderImportModule):
29
        (WebCore::JSDOMGlobalObject::moduleLoaderCreateImportMetaProperties):
30
        * bindings/js/JSDOMGlobalObject.h:
31
        * bindings/js/JSDOMWindowBase.cpp:
32
        (WebCore::JSDOMWindowBase::moduleLoaderResolve): Deleted.
33
        (WebCore::JSDOMWindowBase::moduleLoaderFetch): Deleted.
34
        (WebCore::JSDOMWindowBase::moduleLoaderEvaluate): Deleted.
35
        (WebCore::JSDOMWindowBase::moduleLoaderImportModule): Deleted.
36
        (WebCore::JSDOMWindowBase::moduleLoaderCreateImportMetaProperties): Deleted.
37
        * bindings/js/JSDOMWindowBase.h:
38
        * bindings/js/JSWorkerGlobalScopeBase.cpp:
39
        * bindings/js/JSWorkletGlobalScopeBase.cpp:
40
        * bindings/js/ModuleScriptLoader.h: Copied from Source/WebCore/workers/WorkerType.h.
41
        (WebCore::ModuleScriptLoader::clearClient):
42
        (WebCore::ModuleScriptLoader::scriptFetcher):
43
        (WebCore::ModuleScriptLoader::parameters):
44
        (WebCore::ModuleScriptLoader::ModuleScriptLoader):
45
        * bindings/js/ModuleScriptLoaderClient.h: Renamed from Source/WebCore/bindings/js/CachedModuleScriptLoaderClient.h.
46
        * bindings/js/ScriptModuleLoader.cpp:
47
        (WebCore::ScriptModuleLoader::ScriptModuleLoader):
48
        (WebCore::resolveModuleSpecifier):
49
        (WebCore::ScriptModuleLoader::resolve):
50
        (WebCore::ScriptModuleLoader::fetch):
51
        (WebCore::ScriptModuleLoader::moduleURL):
52
        (WebCore::ScriptModuleLoader::responseURLFromRequestURL):
53
        (WebCore::ScriptModuleLoader::evaluate):
54
        (WebCore::ScriptModuleLoader::importModule):
55
        (WebCore::ScriptModuleLoader::notifyFinished):
56
        * bindings/js/ScriptModuleLoader.h:
57
        * bindings/js/ScriptSourceCode.h:
58
        (WebCore::ScriptSourceCode::ScriptSourceCode):
59
        * bindings/js/WorkerModuleScriptLoader.cpp: Added.
60
        (WebCore::WorkerModuleScriptLoader::create):
61
        (WebCore::WorkerModuleScriptLoader::WorkerModuleScriptLoader):
62
        (WebCore::WorkerModuleScriptLoader::~WorkerModuleScriptLoader):
63
        (WebCore::WorkerModuleScriptLoader::load):
64
        (WebCore::WorkerModuleScriptLoader::notifyFinished):
65
        * bindings/js/WorkerModuleScriptLoader.h: Copied from Source/WebCore/workers/WorkerType.h.
66
        * bindings/js/WorkerScriptFetcher.h: Added.
67
        * dom/Document.cpp:
68
        * dom/ExceptionCode.h:
69
        * dom/LoadableModuleScript.cpp:
70
        (WebCore::LoadableModuleScript::load): Deleted.
71
        * dom/LoadableModuleScript.h:
72
        * dom/ScriptElement.cpp:
73
        (WebCore::ScriptElement::requestModuleScript):
74
        * loader/ThreadableLoader.cpp:
75
        (WebCore::ThreadableLoader::create):
76
        * loader/ThreadableLoader.h:
77
        (WebCore::ThreadableLoader::create):
78
        * workers/Worker.cpp:
79
        (WebCore::Worker::Worker):
80
        (WebCore::Worker::create):
81
        (WebCore::Worker::notifyFinished):
82
        * workers/Worker.h:
83
        * workers/Worker.idl:
84
        * workers/WorkerGlobalScope.cpp:
85
        (WebCore::WorkerGlobalScope::WorkerGlobalScope):
86
        (WebCore::WorkerGlobalScope::importScripts):
87
        * workers/WorkerGlobalScope.h:
88
        (WebCore::WorkerGlobalScope::credentials const):
89
        * workers/WorkerGlobalScopeProxy.h:
90
        * workers/WorkerMessagingProxy.cpp:
91
        (WebCore::WorkerMessagingProxy::startWorkerGlobalScope):
92
        * workers/WorkerMessagingProxy.h:
93
        * workers/WorkerOrWorkletGlobalScope.cpp:
94
        (WebCore::WorkerOrWorkletGlobalScope::WorkerOrWorkletGlobalScope):
95
        * workers/WorkerOrWorkletGlobalScope.h:
96
        (WebCore::WorkerOrWorkletGlobalScope::moduleLoader):
97
        * workers/WorkerOrWorkletScriptController.cpp:
98
        (WebCore::jsValueToModuleKey):
99
        (WebCore::WorkerOrWorkletScriptController::evaluateModule):
100
        (WebCore::WorkerOrWorkletScriptController::loadModuleSynchronously):
101
        (WebCore::WorkerOrWorkletScriptController::linkAndEvaluateModule):
102
        (WebCore::WorkerOrWorkletScriptController::loadAndEvaluateModule):
103
        * workers/WorkerOrWorkletScriptController.h:
104
        * workers/WorkerScriptLoader.cpp:
105
        (WebCore::WorkerScriptLoader::loadAsynchronously):
106
        (WebCore::WorkerScriptLoader::didReceiveResponse):
107
        * workers/WorkerScriptLoader.h:
108
        (WebCore::WorkerScriptLoader::responseSource const):
109
        (WebCore::WorkerScriptLoader::isRedirected const):
110
        * workers/WorkerThread.cpp:
111
        (WebCore::WorkerParameters::isolatedCopy const):
112
        (WebCore::WorkerThread::evaluateScriptIfNecessary):
113
        * workers/WorkerThread.h:
114
        * workers/WorkerType.h:
115
        * workers/service/ServiceWorkerContainer.h:
116
        * workers/service/ServiceWorkerJob.cpp:
117
        (WebCore::ServiceWorkerJob::fetchScriptWithContext):
118
        * workers/service/ServiceWorkerRegistrationOptions.h:
119
        * workers/service/context/ServiceWorkerThread.cpp:
120
        (WebCore::ServiceWorkerThread::ServiceWorkerThread):
121
        * workers/service/server/SWServerWorker.h:
122
        * worklets/WorkletGlobalScope.cpp:
123
        (WebCore::WorkletGlobalScope::fetchAndInvokeScript):
124
        (WebCore::WorkletGlobalScope::processNextScriptFetchJobIfNeeded): Deleted.
125
        (WebCore::WorkletGlobalScope::didReceiveResponse): Deleted.
126
        (WebCore::WorkletGlobalScope::notifyFinished): Deleted.
127
        (WebCore::WorkletGlobalScope::didCompleteScriptFetchJob): Deleted.
128
        * worklets/WorkletGlobalScope.h:
129
1
2021-02-11  Jer Noble  <jer.noble@apple.com>
130
2021-02-11  Jer Noble  <jer.noble@apple.com>
2
131
3
        Unreviewed build fix after r272758; include missing change to RuntimeEnabledFeatures.
132
        Unreviewed build fix after r272758; include missing change to RuntimeEnabledFeatures.
- a/Source/JavaScriptCore/runtime/AggregateError.cpp -1 / +1 lines
Lines 36-42 namespace JSC { a/Source/JavaScriptCore/runtime/AggregateError.cpp_sec1
36
const ClassInfo AggregateError::s_info = { "AggregateError", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(AggregateError) };
36
const ClassInfo AggregateError::s_info = { "AggregateError", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(AggregateError) };
37
37
38
AggregateError::AggregateError(VM& vm, Structure* structure)
38
AggregateError::AggregateError(VM& vm, Structure* structure)
39
    : Base(vm, structure)
39
    : Base(vm, structure, ErrorType::AggregateError)
40
{
40
{
41
}
41
}
42
42
- a/Source/JavaScriptCore/runtime/Error.cpp -9 / +14 lines
Lines 35-71 namespace JSC { a/Source/JavaScriptCore/runtime/Error.cpp_sec1
35
JSObject* createError(JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender)
35
JSObject* createError(JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender)
36
{
36
{
37
    ASSERT(!message.isEmpty());
37
    ASSERT(!message.isEmpty());
38
    return ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(), message, appender, TypeNothing, true);
38
    return ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(), message, appender, TypeNothing, ErrorType::Error, true);
39
}
39
}
40
40
41
JSObject* createEvalError(JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender)
41
JSObject* createEvalError(JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender)
42
{
42
{
43
    ASSERT(!message.isEmpty());
43
    ASSERT(!message.isEmpty());
44
    return ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(ErrorType::EvalError), message, appender, TypeNothing, true);
44
    return ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(ErrorType::EvalError), message, appender, TypeNothing, ErrorType::EvalError, true);
45
}
45
}
46
46
47
JSObject* createRangeError(JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender)
47
JSObject* createRangeError(JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender)
48
{
48
{
49
    ASSERT(!message.isEmpty());
49
    ASSERT(!message.isEmpty());
50
    return ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(ErrorType::RangeError), message, appender, TypeNothing, true);
50
    return ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(ErrorType::RangeError), message, appender, TypeNothing, ErrorType::RangeError, true);
51
}
51
}
52
52
53
JSObject* createReferenceError(JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender)
53
JSObject* createReferenceError(JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender)
54
{
54
{
55
    ASSERT(!message.isEmpty());
55
    ASSERT(!message.isEmpty());
56
    return ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(ErrorType::ReferenceError), message, appender, TypeNothing, true);
56
    return ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(ErrorType::ReferenceError), message, appender, TypeNothing, ErrorType::ReferenceError, true);
57
}
57
}
58
58
59
JSObject* createSyntaxError(JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender)
59
JSObject* createSyntaxError(JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender)
60
{
60
{
61
    ASSERT(!message.isEmpty());
61
    ASSERT(!message.isEmpty());
62
    return ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(ErrorType::SyntaxError), message, appender, TypeNothing, true);
62
    return ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(ErrorType::SyntaxError), message, appender, TypeNothing, ErrorType::SyntaxError, true);
63
}
63
}
64
64
65
JSObject* createTypeError(JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender, RuntimeType type)
65
JSObject* createTypeError(JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender, RuntimeType type)
66
{
66
{
67
    ASSERT(!message.isEmpty());
67
    ASSERT(!message.isEmpty());
68
    return ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(ErrorType::TypeError), message, appender, type, true);
68
    return ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(ErrorType::TypeError), message, appender, type, ErrorType::TypeError, true);
69
}
69
}
70
70
71
JSObject* createNotEnoughArgumentsError(JSGlobalObject* globalObject, ErrorInstance::SourceAppender appender)
71
JSObject* createNotEnoughArgumentsError(JSGlobalObject* globalObject, ErrorInstance::SourceAppender appender)
Lines 76-82 JSObject* createNotEnoughArgumentsError(JSGlobalObject* globalObject, ErrorInsta a/Source/JavaScriptCore/runtime/Error.cpp_sec2
76
JSObject* createURIError(JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender)
76
JSObject* createURIError(JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender)
77
{
77
{
78
    ASSERT(!message.isEmpty());
78
    ASSERT(!message.isEmpty());
79
    return ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(ErrorType::URIError), message, appender, TypeNothing, true);
79
    return ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(ErrorType::URIError), message, appender, TypeNothing, ErrorType::URIError, true);
80
}
80
}
81
81
82
JSObject* createError(JSGlobalObject* globalObject, ErrorType errorType, const String& message)
82
JSObject* createError(JSGlobalObject* globalObject, ErrorType errorType, const String& message)
Lines 113-119 JSObject* createError(JSGlobalObject* globalObject, ErrorTypeWithExtension error a/Source/JavaScriptCore/runtime/Error.cpp_sec3
113
JSObject* createGetterTypeError(JSGlobalObject* globalObject, const String& message)
113
JSObject* createGetterTypeError(JSGlobalObject* globalObject, const String& message)
114
{
114
{
115
    ASSERT(!message.isEmpty());
115
    ASSERT(!message.isEmpty());
116
    auto* error = ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(ErrorType::TypeError), message);
116
    auto* error = ErrorInstance::create(globalObject, globalObject->vm(), globalObject->errorStructure(ErrorType::TypeError), message, nullptr, TypeNothing, ErrorType::TypeError);
117
    error->setNativeGetterTypeError();
117
    error->setNativeGetterTypeError();
118
    return error;
118
    return error;
119
}
119
}
Lines 274-280 Exception* throwTypeError(JSGlobalObject* globalObject, ThrowScope& scope, const a/Source/JavaScriptCore/runtime/Error.cpp_sec4
274
274
275
Exception* throwSyntaxError(JSGlobalObject* globalObject, ThrowScope& scope)
275
Exception* throwSyntaxError(JSGlobalObject* globalObject, ThrowScope& scope)
276
{
276
{
277
    return throwException(globalObject, scope, createSyntaxError(globalObject, "Syntax error"_s));
277
    return throwException(globalObject, scope, createSyntaxError(globalObject));
278
}
278
}
279
279
280
Exception* throwSyntaxError(JSGlobalObject* globalObject, ThrowScope& scope, const String& message)
280
Exception* throwSyntaxError(JSGlobalObject* globalObject, ThrowScope& scope, const String& message)
Lines 317-322 JSObject* createSyntaxError(JSGlobalObject* globalObject, const String& message) a/Source/JavaScriptCore/runtime/Error.cpp_sec5
317
    return createSyntaxError(globalObject, message, nullptr);
317
    return createSyntaxError(globalObject, message, nullptr);
318
}
318
}
319
319
320
JSObject* createSyntaxError(JSGlobalObject* globalObject)
321
{
322
    return createSyntaxError(globalObject, "Syntax error"_s, nullptr);
323
}
324
320
JSObject* createTypeError(JSGlobalObject* globalObject)
325
JSObject* createTypeError(JSGlobalObject* globalObject)
321
{
326
{
322
    return createTypeError(globalObject, "Type error"_s);
327
    return createTypeError(globalObject, "Type error"_s);
- a/Source/JavaScriptCore/runtime/Error.h +1 lines
Lines 55-60 JS_EXPORT_PRIVATE JSObject* createEvalError(JSGlobalObject*, const String&); a/Source/JavaScriptCore/runtime/Error.h_sec1
55
JS_EXPORT_PRIVATE JSObject* createRangeError(JSGlobalObject*, const String&);
55
JS_EXPORT_PRIVATE JSObject* createRangeError(JSGlobalObject*, const String&);
56
JS_EXPORT_PRIVATE JSObject* createReferenceError(JSGlobalObject*, const String&);
56
JS_EXPORT_PRIVATE JSObject* createReferenceError(JSGlobalObject*, const String&);
57
JS_EXPORT_PRIVATE JSObject* createSyntaxError(JSGlobalObject*, const String&);
57
JS_EXPORT_PRIVATE JSObject* createSyntaxError(JSGlobalObject*, const String&);
58
JS_EXPORT_PRIVATE JSObject* createSyntaxError(JSGlobalObject*);
58
JS_EXPORT_PRIVATE JSObject* createTypeError(JSGlobalObject*);
59
JS_EXPORT_PRIVATE JSObject* createTypeError(JSGlobalObject*);
59
JS_EXPORT_PRIVATE JSObject* createTypeError(JSGlobalObject*, const String&);
60
JS_EXPORT_PRIVATE JSObject* createTypeError(JSGlobalObject*, const String&);
60
JS_EXPORT_PRIVATE JSObject* createNotEnoughArgumentsError(JSGlobalObject*);
61
JS_EXPORT_PRIVATE JSObject* createNotEnoughArgumentsError(JSGlobalObject*);
- a/Source/JavaScriptCore/runtime/ErrorConstructor.cpp -2 / +2 lines
Lines 60-73 JSC_DEFINE_HOST_FUNCTION(constructErrorConstructor, (JSGlobalObject* globalObjec a/Source/JavaScriptCore/runtime/ErrorConstructor.cpp_sec1
60
        : InternalFunction::createSubclassStructure(globalObject, newTarget, getFunctionRealm(vm, newTarget)->errorStructure());
60
        : InternalFunction::createSubclassStructure(globalObject, newTarget, getFunctionRealm(vm, newTarget)->errorStructure());
61
    RETURN_IF_EXCEPTION(scope, { });
61
    RETURN_IF_EXCEPTION(scope, { });
62
62
63
    RELEASE_AND_RETURN(scope, JSValue::encode(ErrorInstance::create(globalObject, errorStructure, message, nullptr, TypeNothing, false)));
63
    RELEASE_AND_RETURN(scope, JSValue::encode(ErrorInstance::create(globalObject, errorStructure, message, nullptr, TypeNothing, ErrorType::Error, false)));
64
}
64
}
65
65
66
JSC_DEFINE_HOST_FUNCTION(callErrorConstructor, (JSGlobalObject* globalObject, CallFrame* callFrame))
66
JSC_DEFINE_HOST_FUNCTION(callErrorConstructor, (JSGlobalObject* globalObject, CallFrame* callFrame))
67
{
67
{
68
    JSValue message = callFrame->argument(0);
68
    JSValue message = callFrame->argument(0);
69
    Structure* errorStructure = globalObject->errorStructure();
69
    Structure* errorStructure = globalObject->errorStructure();
70
    return JSValue::encode(ErrorInstance::create(globalObject, errorStructure, message, nullptr, TypeNothing, false));
70
    return JSValue::encode(ErrorInstance::create(globalObject, errorStructure, message, nullptr, TypeNothing, ErrorType::Error, false));
71
}
71
}
72
72
73
bool ErrorConstructor::put(JSCell* cell, JSGlobalObject* globalObject, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
73
bool ErrorConstructor::put(JSCell* cell, JSGlobalObject* globalObject, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
- a/Source/JavaScriptCore/runtime/ErrorInstance.cpp -23 / +40 lines
Lines 34-51 namespace JSC { a/Source/JavaScriptCore/runtime/ErrorInstance.cpp_sec1
34
34
35
const ClassInfo ErrorInstance::s_info = { "Error", &JSNonFinalObject::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ErrorInstance) };
35
const ClassInfo ErrorInstance::s_info = { "Error", &JSNonFinalObject::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(ErrorInstance) };
36
36
37
ErrorInstance::ErrorInstance(VM& vm, Structure* structure)
37
ErrorInstance::ErrorInstance(VM& vm, Structure* structure, ErrorType errorType)
38
    : Base(vm, structure)
38
    : Base(vm, structure)
39
    , m_errorType(errorType)
40
    , m_stackOverflowError(false)
41
    , m_outOfMemoryError(false)
42
    , m_errorInfoMaterialized(false)
43
    , m_nativeGetterTypeError(false)
39
{
44
{
40
}
45
}
41
46
42
ErrorInstance* ErrorInstance::create(JSGlobalObject* globalObject, Structure* structure, JSValue message, SourceAppender appender, RuntimeType type, bool useCurrentFrame)
47
ErrorInstance* ErrorInstance::create(JSGlobalObject* globalObject, Structure* structure, JSValue message, SourceAppender appender, RuntimeType type, ErrorType errorType, bool useCurrentFrame)
43
{
48
{
44
    VM& vm = globalObject->vm();
49
    VM& vm = globalObject->vm();
45
    auto scope = DECLARE_THROW_SCOPE(vm);
50
    auto scope = DECLARE_THROW_SCOPE(vm);
46
    String messageString = message.isUndefined() ? String() : message.toWTFString(globalObject);
51
    String messageString = message.isUndefined() ? String() : message.toWTFString(globalObject);
47
    RETURN_IF_EXCEPTION(scope, nullptr);
52
    RETURN_IF_EXCEPTION(scope, nullptr);
48
    return create(globalObject, vm, structure, messageString, appender, type, useCurrentFrame);
53
    return create(globalObject, vm, structure, messageString, appender, type, errorType, useCurrentFrame);
49
}
54
}
50
55
51
static String appendSourceToErrorMessage(CallFrame* callFrame, ErrorInstance* exception, BytecodeIndex bytecodeIndex, const String& message)
56
static String appendSourceToErrorMessage(CallFrame* callFrame, ErrorInstance* exception, BytecodeIndex bytecodeIndex, const String& message)
Lines 131-137 void ErrorInstance::finishCreation(VM& vm, JSGlobalObject* globalObject, const S a/Source/JavaScriptCore/runtime/ErrorInstance.cpp_sec2
131
// Based on ErrorPrototype's errorProtoFuncToString(), but is modified to
136
// Based on ErrorPrototype's errorProtoFuncToString(), but is modified to
132
// have no observable side effects to the user (i.e. does not call proxies,
137
// have no observable side effects to the user (i.e. does not call proxies,
133
// and getters).
138
// and getters).
134
String ErrorInstance::sanitizedToString(JSGlobalObject* globalObject)
139
String ErrorInstance::sanitizedMessageString(JSGlobalObject* globalObject)
140
{
141
    VM& vm = globalObject->vm();
142
    auto scope = DECLARE_THROW_SCOPE(vm);
143
    Integrity::auditStructureID(vm, structureID());
144
145
    JSValue messageValue;
146
    auto messagePropertName = vm.propertyNames->message;
147
    PropertySlot messageSlot(this, PropertySlot::InternalMethodType::VMInquiry, &vm);
148
    if (JSObject::getOwnPropertySlot(this, globalObject, messagePropertName, messageSlot) && messageSlot.isValue())
149
        messageValue = messageSlot.getValue(globalObject, messagePropertName);
150
    scope.assertNoException();
151
152
    if (!messageValue)
153
        return String();
154
    RELEASE_AND_RETURN(scope, messageValue.toWTFString(globalObject));
155
}
156
157
String ErrorInstance::sanitizedNameString(JSGlobalObject* globalObject)
135
{
158
{
136
    VM& vm = globalObject->vm();
159
    VM& vm = globalObject->vm();
137
    auto scope = DECLARE_THROW_SCOPE(vm);
160
    auto scope = DECLARE_THROW_SCOPE(vm);
Lines 157-184 String ErrorInstance::sanitizedToString(JSGlobalObject* globalObject) a/Source/JavaScriptCore/runtime/ErrorInstance.cpp_sec3
157
    }
180
    }
158
    scope.assertNoException();
181
    scope.assertNoException();
159
182
160
    String nameString;
161
    if (!nameValue)
183
    if (!nameValue)
162
        nameString = "Error"_s;
184
        return "Error"_s;
163
    else {
185
    RELEASE_AND_RETURN(scope, nameValue.toWTFString(globalObject));
164
        nameString = nameValue.toWTFString(globalObject);
186
}
165
        RETURN_IF_EXCEPTION(scope, String());
166
    }
167
187
168
    JSValue messageValue;
188
String ErrorInstance::sanitizedToString(JSGlobalObject* globalObject)
169
    auto messagePropertName = vm.propertyNames->message;
189
{
170
    PropertySlot messageSlot(this, PropertySlot::InternalMethodType::VMInquiry, &vm);
190
    VM& vm = globalObject->vm();
171
    if (JSObject::getOwnPropertySlot(this, globalObject, messagePropertName, messageSlot) && messageSlot.isValue())
191
    auto scope = DECLARE_THROW_SCOPE(vm);
172
        messageValue = messageSlot.getValue(globalObject, messagePropertName);
192
    Integrity::auditStructureID(vm, structureID());
173
    scope.assertNoException();
174
193
175
    String messageString;
194
    String nameString = sanitizedNameString(globalObject);
176
    if (!messageValue)
195
    RETURN_IF_EXCEPTION(scope, String());
177
        messageString = String();
196
178
    else {
197
    String messageString = sanitizedMessageString(globalObject);
179
        messageString = messageValue.toWTFString(globalObject);
198
    RETURN_IF_EXCEPTION(scope, String());
180
        RETURN_IF_EXCEPTION(scope, String());
181
    }
182
199
183
    if (!nameString.length())
200
    if (!nameString.length())
184
        return messageString;
201
        return messageString;
- a/Source/JavaScriptCore/runtime/ErrorInstance.h -8 / +13 lines
Lines 20-25 a/Source/JavaScriptCore/runtime/ErrorInstance.h_sec1
20
20
21
#pragma once
21
#pragma once
22
22
23
#include "ErrorType.h"
23
#include "JSObject.h"
24
#include "JSObject.h"
24
#include "RuntimeType.h"
25
#include "RuntimeType.h"
25
#include "StackFrame.h"
26
#include "StackFrame.h"
Lines 53-66 class ErrorInstance : public JSNonFinalObject { a/Source/JavaScriptCore/runtime/ErrorInstance.h_sec2
53
        return Structure::create(vm, globalObject, prototype, TypeInfo(ErrorInstanceType, StructureFlags), info());
54
        return Structure::create(vm, globalObject, prototype, TypeInfo(ErrorInstanceType, StructureFlags), info());
54
    }
55
    }
55
56
56
    static ErrorInstance* create(JSGlobalObject* globalObject, VM& vm, Structure* structure, const String& message, SourceAppender appender = nullptr, RuntimeType type = TypeNothing, bool useCurrentFrame = true)
57
    static ErrorInstance* create(JSGlobalObject* globalObject, VM& vm, Structure* structure, const String& message, SourceAppender appender = nullptr, RuntimeType type = TypeNothing, ErrorType errorType = ErrorType::Error, bool useCurrentFrame = true)
57
    {
58
    {
58
        ErrorInstance* instance = new (NotNull, allocateCell<ErrorInstance>(vm.heap)) ErrorInstance(vm, structure);
59
        ErrorInstance* instance = new (NotNull, allocateCell<ErrorInstance>(vm.heap)) ErrorInstance(vm, structure, errorType);
59
        instance->finishCreation(vm, globalObject, message, appender, type, useCurrentFrame);
60
        instance->finishCreation(vm, globalObject, message, appender, type, useCurrentFrame);
60
        return instance;
61
        return instance;
61
    }
62
    }
62
63
63
    static ErrorInstance* create(JSGlobalObject*, Structure*, JSValue message, SourceAppender = nullptr, RuntimeType = TypeNothing, bool useCurrentFrame = true);
64
    static ErrorInstance* create(JSGlobalObject*, Structure*, JSValue message, SourceAppender = nullptr, RuntimeType = TypeNothing, ErrorType = ErrorType::Error, bool useCurrentFrame = true);
64
65
65
    bool hasSourceAppender() const { return !!m_sourceAppender; }
66
    bool hasSourceAppender() const { return !!m_sourceAppender; }
66
    SourceAppender sourceAppender() const { return m_sourceAppender; }
67
    SourceAppender sourceAppender() const { return m_sourceAppender; }
Lines 70-75 class ErrorInstance : public JSNonFinalObject { a/Source/JavaScriptCore/runtime/ErrorInstance.h_sec3
70
    RuntimeType runtimeTypeForCause() const { return m_runtimeTypeForCause; }
71
    RuntimeType runtimeTypeForCause() const { return m_runtimeTypeForCause; }
71
    void clearRuntimeTypeForCause() { m_runtimeTypeForCause = TypeNothing; }
72
    void clearRuntimeTypeForCause() { m_runtimeTypeForCause = TypeNothing; }
72
73
74
    ErrorType errorType() const { return m_errorType; }
73
    void setStackOverflowError() { m_stackOverflowError = true; }
75
    void setStackOverflowError() { m_stackOverflowError = true; }
74
    bool isStackOverflowError() const { return m_stackOverflowError; }
76
    bool isStackOverflowError() const { return m_stackOverflowError; }
75
    void setOutOfMemoryError() { m_outOfMemoryError = true; }
77
    void setOutOfMemoryError() { m_outOfMemoryError = true; }
Lines 79-84 class ErrorInstance : public JSNonFinalObject { a/Source/JavaScriptCore/runtime/ErrorInstance.h_sec4
79
    bool isNativeGetterTypeError() const { return m_nativeGetterTypeError; }
81
    bool isNativeGetterTypeError() const { return m_nativeGetterTypeError; }
80
82
81
    JS_EXPORT_PRIVATE String sanitizedToString(JSGlobalObject*);
83
    JS_EXPORT_PRIVATE String sanitizedToString(JSGlobalObject*);
84
    JS_EXPORT_PRIVATE String sanitizedMessageString(JSGlobalObject*);
85
    JS_EXPORT_PRIVATE String sanitizedNameString(JSGlobalObject*);
82
    
86
    
83
    Vector<StackFrame>* stackTrace() { return m_stackTrace.get(); }
87
    Vector<StackFrame>* stackTrace() { return m_stackTrace.get(); }
84
88
Lines 88-94 class ErrorInstance : public JSNonFinalObject { a/Source/JavaScriptCore/runtime/ErrorInstance.h_sec5
88
    void finalizeUnconditionally(VM&);
92
    void finalizeUnconditionally(VM&);
89
93
90
protected:
94
protected:
91
    explicit ErrorInstance(VM&, Structure*);
95
    explicit ErrorInstance(VM&, Structure*, ErrorType);
92
96
93
    void finishCreation(VM&, JSGlobalObject*, const String&, SourceAppender = nullptr, RuntimeType = TypeNothing, bool useCurrentFrame = true);
97
    void finishCreation(VM&, JSGlobalObject*, const String&, SourceAppender = nullptr, RuntimeType = TypeNothing, bool useCurrentFrame = true);
94
98
Lines 108-117 class ErrorInstance : public JSNonFinalObject { a/Source/JavaScriptCore/runtime/ErrorInstance.h_sec6
108
    String m_sourceURL;
112
    String m_sourceURL;
109
    String m_stackString;
113
    String m_stackString;
110
    RuntimeType m_runtimeTypeForCause { TypeNothing };
114
    RuntimeType m_runtimeTypeForCause { TypeNothing };
111
    bool m_stackOverflowError { false };
115
    ErrorType m_errorType { ErrorType::Error };
112
    bool m_outOfMemoryError { false };
116
    bool m_stackOverflowError : 1;
113
    bool m_errorInfoMaterialized { false };
117
    bool m_outOfMemoryError : 1;
114
    bool m_nativeGetterTypeError { false };
118
    bool m_errorInfoMaterialized : 1;
119
    bool m_nativeGetterTypeError : 1;
115
};
120
};
116
121
117
} // namespace JSC
122
} // namespace JSC
- a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp -1 / +1 lines
Lines 694-700 JSC_DEFINE_HOST_FUNCTION(globalFuncThrowTypeErrorArgumentsCalleeAndCaller, (JSGl a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp_sec1
694
JSC_DEFINE_HOST_FUNCTION(globalFuncMakeTypeError, (JSGlobalObject* globalObject, CallFrame* callFrame))
694
JSC_DEFINE_HOST_FUNCTION(globalFuncMakeTypeError, (JSGlobalObject* globalObject, CallFrame* callFrame))
695
{
695
{
696
    Structure* errorStructure = globalObject->errorStructure(ErrorType::TypeError);
696
    Structure* errorStructure = globalObject->errorStructure(ErrorType::TypeError);
697
    return JSValue::encode(ErrorInstance::create(globalObject, errorStructure, callFrame->argument(0), nullptr, TypeNothing, false));
697
    return JSValue::encode(ErrorInstance::create(globalObject, errorStructure, callFrame->argument(0), nullptr, TypeNothing, ErrorType::TypeError, false));
698
}
698
}
699
699
700
JSC_DEFINE_HOST_FUNCTION(globalFuncProtoGetter, (JSGlobalObject* globalObject, CallFrame* callFrame))
700
JSC_DEFINE_HOST_FUNCTION(globalFuncProtoGetter, (JSGlobalObject* globalObject, CallFrame* callFrame))
- a/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp -2 / +2 lines
Lines 58-64 inline EncodedJSValue NativeErrorConstructor<errorType>::constructImpl(JSGlobalO a/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp_sec1
58
    RETURN_IF_EXCEPTION(scope, { });
58
    RETURN_IF_EXCEPTION(scope, { });
59
    ASSERT(errorStructure);
59
    ASSERT(errorStructure);
60
60
61
    RELEASE_AND_RETURN(scope, JSValue::encode(ErrorInstance::create(globalObject, errorStructure, message, nullptr, TypeNothing, false)));
61
    RELEASE_AND_RETURN(scope, JSValue::encode(ErrorInstance::create(globalObject, errorStructure, message, nullptr, TypeNothing, errorType, false)));
62
}
62
}
63
63
64
template<ErrorType errorType>
64
template<ErrorType errorType>
Lines 66-72 inline EncodedJSValue NativeErrorConstructor<errorType>::callImpl(JSGlobalObject a/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp_sec2
66
{
66
{
67
    JSValue message = callFrame->argument(0);
67
    JSValue message = callFrame->argument(0);
68
    Structure* errorStructure = globalObject->errorStructure(errorType);
68
    Structure* errorStructure = globalObject->errorStructure(errorType);
69
    return JSValue::encode(ErrorInstance::create(globalObject, errorStructure, message, nullptr, TypeNothing, false));
69
    return JSValue::encode(ErrorInstance::create(globalObject, errorStructure, message, nullptr, TypeNothing, errorType, false));
70
}
70
}
71
71
72
JSC_DEFINE_HOST_FUNCTION(callEvalError, (JSGlobalObject* globalObject, CallFrame* callFrame))
72
JSC_DEFINE_HOST_FUNCTION(callEvalError, (JSGlobalObject* globalObject, CallFrame* callFrame))
- a/Source/JavaScriptCore/runtime/NullSetterFunction.cpp -1 / +1 lines
Lines 94-100 JSC_DEFINE_HOST_FUNCTION(callThrowError, (JSGlobalObject* globalObject, CallFram a/Source/JavaScriptCore/runtime/NullSetterFunction.cpp_sec1
94
    auto scope = DECLARE_THROW_SCOPE(vm);
94
    auto scope = DECLARE_THROW_SCOPE(vm);
95
    // This function is only called from IC. And we do not want to include this frame in Error's stack.
95
    // This function is only called from IC. And we do not want to include this frame in Error's stack.
96
    constexpr bool useCurrentFrame = false;
96
    constexpr bool useCurrentFrame = false;
97
    throwException(globalObject, scope, ErrorInstance::create(globalObject, vm, globalObject->errorStructure(ErrorType::TypeError), ReadonlyPropertyWriteError, nullptr, TypeNothing, useCurrentFrame));
97
    throwException(globalObject, scope, ErrorInstance::create(globalObject, vm, globalObject->errorStructure(ErrorType::TypeError), ReadonlyPropertyWriteError, nullptr, TypeNothing, ErrorType::TypeError, useCurrentFrame));
98
    return { };
98
    return { };
99
}
99
}
100
100
- a/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp -1 / +1 lines
Lines 41-47 JSWebAssemblyCompileError* JSWebAssemblyCompileError::create(JSGlobalObject* glo a/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp_sec1
41
}
41
}
42
42
43
JSWebAssemblyCompileError::JSWebAssemblyCompileError(VM& vm, Structure* structure)
43
JSWebAssemblyCompileError::JSWebAssemblyCompileError(VM& vm, Structure* structure)
44
    : Base(vm, structure)
44
    : Base(vm, structure, ErrorType::Error)
45
{
45
{
46
}
46
}
47
47
- a/Source/JavaScriptCore/wasm/js/JSWebAssemblyLinkError.cpp -1 / +1 lines
Lines 41-47 JSWebAssemblyLinkError* JSWebAssemblyLinkError::create(JSGlobalObject* globalObj a/Source/JavaScriptCore/wasm/js/JSWebAssemblyLinkError.cpp_sec1
41
}
41
}
42
42
43
JSWebAssemblyLinkError::JSWebAssemblyLinkError(VM& vm, Structure* structure)
43
JSWebAssemblyLinkError::JSWebAssemblyLinkError(VM& vm, Structure* structure)
44
    : Base(vm, structure)
44
    : Base(vm, structure, ErrorType::Error)
45
{
45
{
46
}
46
}
47
47
- a/Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.cpp -1 / +1 lines
Lines 41-47 JSWebAssemblyRuntimeError* JSWebAssemblyRuntimeError::create(JSGlobalObject* glo a/Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.cpp_sec1
41
}
41
}
42
42
43
JSWebAssemblyRuntimeError::JSWebAssemblyRuntimeError(VM& vm, Structure* structure)
43
JSWebAssemblyRuntimeError::JSWebAssemblyRuntimeError(VM& vm, Structure* structure)
44
    : Base(vm, structure)
44
    : Base(vm, structure, ErrorType::Error)
45
{
45
{
46
}
46
}
47
47
- a/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp -1 / +1 lines
Lines 65-71 JSC_DEFINE_HOST_FUNCTION(callJSWebAssemblyCompileError, (JSGlobalObject* globalO a/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp_sec1
65
{
65
{
66
    JSValue message = callFrame->argument(0);
66
    JSValue message = callFrame->argument(0);
67
    Structure* errorStructure = globalObject->webAssemblyCompileErrorStructure();
67
    Structure* errorStructure = globalObject->webAssemblyCompileErrorStructure();
68
    return JSValue::encode(ErrorInstance::create(globalObject, errorStructure, message, nullptr, TypeNothing, false));
68
    return JSValue::encode(ErrorInstance::create(globalObject, errorStructure, message, nullptr, TypeNothing, ErrorType::Error, false));
69
}
69
}
70
70
71
WebAssemblyCompileErrorConstructor* WebAssemblyCompileErrorConstructor::create(VM& vm, Structure* structure, WebAssemblyCompileErrorPrototype* thisPrototype)
71
WebAssemblyCompileErrorConstructor* WebAssemblyCompileErrorConstructor::create(VM& vm, Structure* structure, WebAssemblyCompileErrorPrototype* thisPrototype)
- a/Source/JavaScriptCore/wasm/js/WebAssemblyLinkErrorConstructor.cpp -1 / +1 lines
Lines 65-71 JSC_DEFINE_HOST_FUNCTION(callJSWebAssemblyLinkError, (JSGlobalObject* globalObje a/Source/JavaScriptCore/wasm/js/WebAssemblyLinkErrorConstructor.cpp_sec1
65
{
65
{
66
    JSValue message = callFrame->argument(0);
66
    JSValue message = callFrame->argument(0);
67
    Structure* errorStructure = globalObject->webAssemblyLinkErrorStructure();
67
    Structure* errorStructure = globalObject->webAssemblyLinkErrorStructure();
68
    return JSValue::encode(ErrorInstance::create(globalObject, errorStructure, message, nullptr, TypeNothing, false));
68
    return JSValue::encode(ErrorInstance::create(globalObject, errorStructure, message, nullptr, TypeNothing, ErrorType::Error, false));
69
}
69
}
70
70
71
WebAssemblyLinkErrorConstructor* WebAssemblyLinkErrorConstructor::create(VM& vm, Structure* structure, WebAssemblyLinkErrorPrototype* thisPrototype)
71
WebAssemblyLinkErrorConstructor* WebAssemblyLinkErrorConstructor::create(VM& vm, Structure* structure, WebAssemblyLinkErrorPrototype* thisPrototype)
- a/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp -1 / +1 lines
Lines 67-73 JSC_DEFINE_HOST_FUNCTION(callJSWebAssemblyRuntimeError, (JSGlobalObject* globalO a/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp_sec1
67
{
67
{
68
    JSValue message = callFrame->argument(0);
68
    JSValue message = callFrame->argument(0);
69
    Structure* errorStructure = globalObject->webAssemblyRuntimeErrorStructure();
69
    Structure* errorStructure = globalObject->webAssemblyRuntimeErrorStructure();
70
    return JSValue::encode(ErrorInstance::create(globalObject, errorStructure, message, nullptr, TypeNothing, false));
70
    return JSValue::encode(ErrorInstance::create(globalObject, errorStructure, message, nullptr, TypeNothing, ErrorType::Error, false));
71
}
71
}
72
72
73
WebAssemblyRuntimeErrorConstructor* WebAssemblyRuntimeErrorConstructor::create(VM& vm, Structure* structure, WebAssemblyRuntimeErrorPrototype* thisPrototype)
73
WebAssemblyRuntimeErrorConstructor* WebAssemblyRuntimeErrorConstructor::create(VM& vm, Structure* structure, WebAssemblyRuntimeErrorPrototype* thisPrototype)
- a/Source/WebCore/Headers.cmake +2 lines
Lines 30-35 set(WebCore_PRIVATE_FRAMEWORK_HEADERS a/Source/WebCore/Headers.cmake_sec1
30
30
31
    Modules/fetch/FetchBodyConsumer.h
31
    Modules/fetch/FetchBodyConsumer.h
32
    Modules/fetch/FetchBodySource.h
32
    Modules/fetch/FetchBodySource.h
33
    Modules/fetch/FetchRequestCredentials.h
33
    Modules/fetch/FetchHeaders.h
34
    Modules/fetch/FetchHeaders.h
34
    Modules/fetch/FetchIdentifier.h
35
    Modules/fetch/FetchIdentifier.h
35
    Modules/fetch/FetchLoader.h
36
    Modules/fetch/FetchLoader.h
Lines 287-292 set(WebCore_PRIVATE_FRAMEWORK_HEADERS a/Source/WebCore/Headers.cmake_sec2
287
    bindings/js/WebCoreJITOperations.h
288
    bindings/js/WebCoreJITOperations.h
288
    bindings/js/WebCoreTypedArrayController.h
289
    bindings/js/WebCoreTypedArrayController.h
289
    bindings/js/WindowProxy.h
290
    bindings/js/WindowProxy.h
291
    bindings/js/WorkerScriptFetcher.h
290
292
291
    bridge/Bridge.h
293
    bridge/Bridge.h
292
    bridge/IdentifierRep.h
294
    bridge/IdentifierRep.h
- a/Source/WebCore/Sources.txt +1 lines
Lines 639-644 bindings/js/StructuredClone.cpp a/Source/WebCore/Sources.txt_sec1
639
bindings/js/WebCoreJITOperations.cpp
639
bindings/js/WebCoreJITOperations.cpp
640
bindings/js/WebCoreJSClientData.cpp
640
bindings/js/WebCoreJSClientData.cpp
641
bindings/js/WebCoreTypedArrayController.cpp
641
bindings/js/WebCoreTypedArrayController.cpp
642
bindings/js/WorkerModuleScriptLoader.cpp
642
bindings/js/WindowProxy.cpp
643
bindings/js/WindowProxy.cpp
643
bindings/js/WritableStream.cpp
644
bindings/js/WritableStream.cpp
644
bridge/IdentifierRep.cpp
645
bridge/IdentifierRep.cpp
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj -4 / +18 lines
Lines 5069-5083 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
5069
		E30592641E27A3AD00D57C98 /* InlineClassicScript.h in Headers */ = {isa = PBXBuildFile; fileRef = E30592621E27A38C00D57C98 /* InlineClassicScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
5069
		E30592641E27A3AD00D57C98 /* InlineClassicScript.h in Headers */ = {isa = PBXBuildFile; fileRef = E30592621E27A38C00D57C98 /* InlineClassicScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
5070
		E30592681E27A3D100D57C98 /* CachedScriptFetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = E30592661E27A3C600D57C98 /* CachedScriptFetcher.h */; settings = {ATTRIBUTES = (Private, ); }; };
5070
		E30592681E27A3D100D57C98 /* CachedScriptFetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = E30592661E27A3C600D57C98 /* CachedScriptFetcher.h */; settings = {ATTRIBUTES = (Private, ); }; };
5071
		E307DED01D81E4C700141CAF /* CachedModuleScriptLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = E307DEC71D81E44800141CAF /* CachedModuleScriptLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
5071
		E307DED01D81E4C700141CAF /* CachedModuleScriptLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = E307DEC71D81E44800141CAF /* CachedModuleScriptLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
5072
		E307DED11D81E4CB00141CAF /* CachedModuleScriptLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E307DEC81D81E44800141CAF /* CachedModuleScriptLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
5073
		E307DED51D81E4F200141CAF /* LoadableModuleScript.h in Headers */ = {isa = PBXBuildFile; fileRef = E307DED31D81E4ED00141CAF /* LoadableModuleScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
5072
		E307DED51D81E4F200141CAF /* LoadableModuleScript.h in Headers */ = {isa = PBXBuildFile; fileRef = E307DED31D81E4ED00141CAF /* LoadableModuleScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
5074
		E3150EA71DA7219300194012 /* DOMJITHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = E3150EA51DA7218D00194012 /* DOMJITHelpers.h */; };
5073
		E3150EA71DA7219300194012 /* DOMJITHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = E3150EA51DA7218D00194012 /* DOMJITHelpers.h */; };
5075
		E3201C1A1F8E82130076A032 /* ModuleFetchParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = E38D06091F8E811900649CF2 /* ModuleFetchParameters.h */; settings = {ATTRIBUTES = (Private, ); }; };
5074
		E3201C1A1F8E82130076A032 /* ModuleFetchParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = E38D06091F8E811900649CF2 /* ModuleFetchParameters.h */; settings = {ATTRIBUTES = (Private, ); }; };
5076
		E323CFFA1E5AF6AF00F0B4A0 /* JSDOMConvertPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = E323CFF91E5AF6A500F0B4A0 /* JSDOMConvertPromise.h */; settings = {ATTRIBUTES = (Private, ); }; };
5075
		E323CFFA1E5AF6AF00F0B4A0 /* JSDOMConvertPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = E323CFF91E5AF6A500F0B4A0 /* JSDOMConvertPromise.h */; settings = {ATTRIBUTES = (Private, ); }; };
5076
		E3432DE425D377E30058E612 /* WorkerModuleScriptLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = E3432DE025D377E20058E612 /* WorkerModuleScriptLoader.h */; };
5077
		E347E5FA25D4F00000F17A5C /* WorkerScriptFetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = E347E5F825D4F00000F17A5C /* WorkerScriptFetcher.h */; settings = {ATTRIBUTES = (Private, ); }; };
5078
		E35188B425D387CF00A77AF3 /* ModuleScriptLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E35188B325D387CF00A77AF3 /* ModuleScriptLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
5077
		E3565B7B1DC2D6C900217DBD /* JSEventCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = E34EE49F1DC2D57500EAA9D3 /* JSEventCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
5079
		E3565B7B1DC2D6C900217DBD /* JSEventCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = E34EE49F1DC2D57500EAA9D3 /* JSEventCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
5078
		E35802B61DC8435D00A9773C /* DOMJITIDLTypeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = E35802B51DC8435800A9773C /* DOMJITIDLTypeFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
5080
		E35802B61DC8435D00A9773C /* DOMJITIDLTypeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = E35802B51DC8435800A9773C /* DOMJITIDLTypeFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
5079
		E3582C282527F66900D1B790 /* WebCoreJITOperations.h in Headers */ = {isa = PBXBuildFile; fileRef = E3582C262527F66800D1B790 /* WebCoreJITOperations.h */; settings = {ATTRIBUTES = (Private, ); }; };
5081
		E3582C282527F66900D1B790 /* WebCoreJITOperations.h in Headers */ = {isa = PBXBuildFile; fileRef = E3582C262527F66800D1B790 /* WebCoreJITOperations.h */; settings = {ATTRIBUTES = (Private, ); }; };
5080
		E35B907F23F60A50000011FF /* LocalizedDeviceModel.h in Headers */ = {isa = PBXBuildFile; fileRef = E35B907C23F60677000011FF /* LocalizedDeviceModel.h */; settings = {ATTRIBUTES = (Private, ); }; };
5082
		E35B907F23F60A50000011FF /* LocalizedDeviceModel.h in Headers */ = {isa = PBXBuildFile; fileRef = E35B907C23F60677000011FF /* LocalizedDeviceModel.h */; settings = {ATTRIBUTES = (Private, ); }; };
5083
		E364321C25D37A6700F90E2A /* ModuleScriptLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = E364321A25D37A6600F90E2A /* ModuleScriptLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
5081
		E377FE4D1DADE16500CDD025 /* NodeConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = E3D049931DADC04500718F3C /* NodeConstants.h */; settings = {ATTRIBUTES = (Private, ); }; };
5084
		E377FE4D1DADE16500CDD025 /* NodeConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = E3D049931DADC04500718F3C /* NodeConstants.h */; settings = {ATTRIBUTES = (Private, ); }; };
5082
		E37C86501EB63E3F0087C6CA /* JSDOMPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = E37C864F1EB63E2D0087C6CA /* JSDOMPromise.h */; settings = {ATTRIBUTES = (Private, ); }; };
5085
		E37C86501EB63E3F0087C6CA /* JSDOMPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = E37C864F1EB63E2D0087C6CA /* JSDOMPromise.h */; settings = {ATTRIBUTES = (Private, ); }; };
5083
		E39628BF2395728F00658ECD /* DeviceOrientationUpdateProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = E39628BD2395728E00658ECD /* DeviceOrientationUpdateProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
5086
		E39628BF2395728F00658ECD /* DeviceOrientationUpdateProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = E39628BD2395728E00658ECD /* DeviceOrientationUpdateProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
Lines 16195-16201 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
16195
		E30592661E27A3C600D57C98 /* CachedScriptFetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedScriptFetcher.h; sourceTree = "<group>"; };
16198
		E30592661E27A3C600D57C98 /* CachedScriptFetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedScriptFetcher.h; sourceTree = "<group>"; };
16196
		E307DEC61D81E44800141CAF /* CachedModuleScriptLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedModuleScriptLoader.cpp; sourceTree = "<group>"; };
16199
		E307DEC61D81E44800141CAF /* CachedModuleScriptLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedModuleScriptLoader.cpp; sourceTree = "<group>"; };
16197
		E307DEC71D81E44800141CAF /* CachedModuleScriptLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedModuleScriptLoader.h; sourceTree = "<group>"; };
16200
		E307DEC71D81E44800141CAF /* CachedModuleScriptLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedModuleScriptLoader.h; sourceTree = "<group>"; };
16198
		E307DEC81D81E44800141CAF /* CachedModuleScriptLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedModuleScriptLoaderClient.h; sourceTree = "<group>"; };
16199
		E307DED21D81E4ED00141CAF /* LoadableModuleScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadableModuleScript.cpp; sourceTree = "<group>"; };
16201
		E307DED21D81E4ED00141CAF /* LoadableModuleScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadableModuleScript.cpp; sourceTree = "<group>"; };
16200
		E307DED31D81E4ED00141CAF /* LoadableModuleScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadableModuleScript.h; sourceTree = "<group>"; };
16202
		E307DED31D81E4ED00141CAF /* LoadableModuleScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadableModuleScript.h; sourceTree = "<group>"; };
16201
		E3150EA51DA7218D00194012 /* DOMJITHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITHelpers.h; sourceTree = "<group>"; };
16203
		E3150EA51DA7218D00194012 /* DOMJITHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITHelpers.h; sourceTree = "<group>"; };
Lines 16208-16219 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
16208
		E329276322543F5900308A9A /* TypedOMCSSUnitValue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TypedOMCSSUnitValue.cpp; sourceTree = "<group>"; };
16210
		E329276322543F5900308A9A /* TypedOMCSSUnitValue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TypedOMCSSUnitValue.cpp; sourceTree = "<group>"; };
16209
		E329276622543FDE00308A9A /* DOMRectReadOnly.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DOMRectReadOnly.cpp; sourceTree = "<group>"; };
16211
		E329276622543FDE00308A9A /* DOMRectReadOnly.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DOMRectReadOnly.cpp; sourceTree = "<group>"; };
16210
		E334825E1DC93AA0009C9544 /* DOMJITAbstractHeapRepository.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DOMJITAbstractHeapRepository.h; path = DerivedSources/WebCore/DOMJITAbstractHeapRepository.h; sourceTree = BUILT_PRODUCTS_DIR; };
16212
		E334825E1DC93AA0009C9544 /* DOMJITAbstractHeapRepository.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DOMJITAbstractHeapRepository.h; path = DerivedSources/WebCore/DOMJITAbstractHeapRepository.h; sourceTree = BUILT_PRODUCTS_DIR; };
16213
		E3432DE025D377E20058E612 /* WorkerModuleScriptLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerModuleScriptLoader.h; sourceTree = "<group>"; };
16214
		E3432DE325D377E30058E612 /* WorkerModuleScriptLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerModuleScriptLoader.cpp; sourceTree = "<group>"; };
16215
		E347E5F825D4F00000F17A5C /* WorkerScriptFetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerScriptFetcher.h; sourceTree = "<group>"; };
16211
		E34EE49F1DC2D57500EAA9D3 /* JSEventCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEventCustom.h; sourceTree = "<group>"; };
16216
		E34EE49F1DC2D57500EAA9D3 /* JSEventCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEventCustom.h; sourceTree = "<group>"; };
16217
		E35188B325D387CF00A77AF3 /* ModuleScriptLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModuleScriptLoaderClient.h; sourceTree = "<group>"; };
16212
		E35802B51DC8435800A9773C /* DOMJITIDLTypeFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITIDLTypeFilter.h; sourceTree = "<group>"; };
16218
		E35802B51DC8435800A9773C /* DOMJITIDLTypeFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITIDLTypeFilter.h; sourceTree = "<group>"; };
16213
		E3582C242527F66800D1B790 /* WebCoreJITOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreJITOperations.cpp; sourceTree = "<group>"; };
16219
		E3582C242527F66800D1B790 /* WebCoreJITOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreJITOperations.cpp; sourceTree = "<group>"; };
16214
		E3582C262527F66800D1B790 /* WebCoreJITOperations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreJITOperations.h; sourceTree = "<group>"; };
16220
		E3582C262527F66800D1B790 /* WebCoreJITOperations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreJITOperations.h; sourceTree = "<group>"; };
16215
		E35B907C23F60677000011FF /* LocalizedDeviceModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalizedDeviceModel.h; sourceTree = "<group>"; };
16221
		E35B907C23F60677000011FF /* LocalizedDeviceModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalizedDeviceModel.h; sourceTree = "<group>"; };
16216
		E35B907E23F60677000011FF /* LocalizedDeviceModel.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalizedDeviceModel.mm; sourceTree = "<group>"; };
16222
		E35B907E23F60677000011FF /* LocalizedDeviceModel.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalizedDeviceModel.mm; sourceTree = "<group>"; };
16223
		E364321A25D37A6600F90E2A /* ModuleScriptLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModuleScriptLoader.h; sourceTree = "<group>"; };
16217
		E37C864F1EB63E2D0087C6CA /* JSDOMPromise.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMPromise.h; sourceTree = "<group>"; };
16224
		E37C864F1EB63E2D0087C6CA /* JSDOMPromise.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMPromise.h; sourceTree = "<group>"; };
16218
		E38838941BAD145F00D62EE3 /* ScriptModuleLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptModuleLoader.cpp; sourceTree = "<group>"; };
16225
		E38838941BAD145F00D62EE3 /* ScriptModuleLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptModuleLoader.cpp; sourceTree = "<group>"; };
16219
		E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptModuleLoader.h; sourceTree = "<group>"; };
16226
		E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptModuleLoader.h; sourceTree = "<group>"; };
Lines 27009-27015 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
27009
				2DFA488E1DB541C200362B99 /* BufferSource.h */,
27016
				2DFA488E1DB541C200362B99 /* BufferSource.h */,
27010
				E307DEC61D81E44800141CAF /* CachedModuleScriptLoader.cpp */,
27017
				E307DEC61D81E44800141CAF /* CachedModuleScriptLoader.cpp */,
27011
				E307DEC71D81E44800141CAF /* CachedModuleScriptLoader.h */,
27018
				E307DEC71D81E44800141CAF /* CachedModuleScriptLoader.h */,
27012
				E307DEC81D81E44800141CAF /* CachedModuleScriptLoaderClient.h */,
27013
				E30592651E27A3C600D57C98 /* CachedScriptFetcher.cpp */,
27019
				E30592651E27A3C600D57C98 /* CachedScriptFetcher.cpp */,
27014
				E30592661E27A3C600D57C98 /* CachedScriptFetcher.h */,
27020
				E30592661E27A3C600D57C98 /* CachedScriptFetcher.h */,
27015
				BCD533630ED6848900887468 /* CachedScriptSourceProvider.h */,
27021
				BCD533630ED6848900887468 /* CachedScriptSourceProvider.h */,
Lines 27083-27088 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec5
27083
				4BDEA32D218034050052DFCD /* JSWorkletGlobalScopeBase.cpp */,
27089
				4BDEA32D218034050052DFCD /* JSWorkletGlobalScopeBase.cpp */,
27084
				4BDEA32B218033EB0052DFCD /* JSWorkletGlobalScopeBase.h */,
27090
				4BDEA32B218033EB0052DFCD /* JSWorkletGlobalScopeBase.h */,
27085
				709A01FD1E3D0BCC006B0D4C /* ModuleFetchFailureKind.h */,
27091
				709A01FD1E3D0BCC006B0D4C /* ModuleFetchFailureKind.h */,
27092
				E364321A25D37A6600F90E2A /* ModuleScriptLoader.h */,
27093
				E35188B325D387CF00A77AF3 /* ModuleScriptLoaderClient.h */,
27086
				41B459ED1F55EBC70000F6FD /* ReadableStream.cpp */,
27094
				41B459ED1F55EBC70000F6FD /* ReadableStream.cpp */,
27087
				41B459DA1F4CADB90000F6FD /* ReadableStream.h */,
27095
				41B459DA1F4CADB90000F6FD /* ReadableStream.h */,
27088
				418C395E1C8F0AAB0051C8A3 /* ReadableStreamDefaultController.cpp */,
27096
				418C395E1C8F0AAB0051C8A3 /* ReadableStreamDefaultController.cpp */,
Lines 27114-27119 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec6
27114
				0F099D0717B968A100FF84B9 /* WebCoreTypedArrayController.h */,
27122
				0F099D0717B968A100FF84B9 /* WebCoreTypedArrayController.h */,
27115
				463521AC2081090E00C28922 /* WindowProxy.cpp */,
27123
				463521AC2081090E00C28922 /* WindowProxy.cpp */,
27116
				463521AA2081090B00C28922 /* WindowProxy.h */,
27124
				463521AA2081090B00C28922 /* WindowProxy.h */,
27125
				E3432DE325D377E30058E612 /* WorkerModuleScriptLoader.cpp */,
27126
				E3432DE025D377E20058E612 /* WorkerModuleScriptLoader.h */,
27127
				E347E5F825D4F00000F17A5C /* WorkerScriptFetcher.h */,
27117
				41418A0325643E1200363417 /* WritableStream.cpp */,
27128
				41418A0325643E1200363417 /* WritableStream.cpp */,
27118
				41418A0425643E1300363417 /* WritableStream.h */,
27129
				41418A0425643E1300363417 /* WritableStream.h */,
27119
			);
27130
			);
Lines 31387-31393 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec7
31387
				BCB16C1C0979C3BD00467741 /* CachedImage.h in Headers */,
31398
				BCB16C1C0979C3BD00467741 /* CachedImage.h in Headers */,
31388
				319FBD5F15D2F464009640A6 /* CachedImageClient.h in Headers */,
31399
				319FBD5F15D2F464009640A6 /* CachedImageClient.h in Headers */,
31389
				E307DED01D81E4C700141CAF /* CachedModuleScriptLoader.h in Headers */,
31400
				E307DED01D81E4C700141CAF /* CachedModuleScriptLoader.h in Headers */,
31390
				E307DED11D81E4CB00141CAF /* CachedModuleScriptLoaderClient.h in Headers */,
31391
				510184690B08602A004A825F /* CachedPage.h in Headers */,
31401
				510184690B08602A004A825F /* CachedPage.h in Headers */,
31392
				D0EDA775143E303C0028E383 /* CachedRawResource.h in Headers */,
31402
				D0EDA775143E303C0028E383 /* CachedRawResource.h in Headers */,
31393
				E1B533491717DEE300F205F9 /* CachedRawResourceClient.h in Headers */,
31403
				E1B533491717DEE300F205F9 /* CachedRawResourceClient.h in Headers */,
Lines 33862-33867 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec8
33862
				C6D74AD509AA282E000B0A52 /* ModifySelectionListLevel.h in Headers */,
33872
				C6D74AD509AA282E000B0A52 /* ModifySelectionListLevel.h in Headers */,
33863
				709A01FE1E3D0BDD006B0D4C /* ModuleFetchFailureKind.h in Headers */,
33873
				709A01FE1E3D0BDD006B0D4C /* ModuleFetchFailureKind.h in Headers */,
33864
				E3201C1A1F8E82130076A032 /* ModuleFetchParameters.h in Headers */,
33874
				E3201C1A1F8E82130076A032 /* ModuleFetchParameters.h in Headers */,
33875
				E364321C25D37A6700F90E2A /* ModuleScriptLoader.h in Headers */,
33876
				E35188B425D387CF00A77AF3 /* ModuleScriptLoaderClient.h in Headers */,
33865
				F55B3DC61251F12D003EF269 /* MonthInputType.h in Headers */,
33877
				F55B3DC61251F12D003EF269 /* MonthInputType.h in Headers */,
33866
				E39628C12395743100658ECD /* MotionManagerClient.h in Headers */,
33878
				E39628C12395743100658ECD /* MotionManagerClient.h in Headers */,
33867
				85031B460A44EFC700F992E0 /* MouseEvent.h in Headers */,
33879
				85031B460A44EFC700F992E0 /* MouseEvent.h in Headers */,
Lines 35512-35517 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec9
35512
				18F831B80FD48C7800D8C56B /* WorkerLoaderProxy.h in Headers */,
35524
				18F831B80FD48C7800D8C56B /* WorkerLoaderProxy.h in Headers */,
35513
				2E43464D0F546A8200B0F1BA /* WorkerLocation.h in Headers */,
35525
				2E43464D0F546A8200B0F1BA /* WorkerLocation.h in Headers */,
35514
				2E4346500F546A8200B0F1BA /* WorkerMessagingProxy.h in Headers */,
35526
				2E4346500F546A8200B0F1BA /* WorkerMessagingProxy.h in Headers */,
35527
				E3432DE425D377E30058E612 /* WorkerModuleScriptLoader.h in Headers */,
35515
				E1271A0B0EEEC77A00F61213 /* WorkerNavigator.h in Headers */,
35528
				E1271A0B0EEEC77A00F61213 /* WorkerNavigator.h in Headers */,
35516
				A5CB05251FB51F3A00089B97 /* WorkerNetworkAgent.h in Headers */,
35529
				A5CB05251FB51F3A00089B97 /* WorkerNetworkAgent.h in Headers */,
35517
				2E4346510F546A8200B0F1BA /* WorkerObjectProxy.h in Headers */,
35530
				2E4346510F546A8200B0F1BA /* WorkerObjectProxy.h in Headers */,
Lines 35521-35526 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec10
35521
				416E29A6102FA962007FC14E /* WorkerReportingProxy.h in Headers */,
35534
				416E29A6102FA962007FC14E /* WorkerReportingProxy.h in Headers */,
35522
				2E4346530F546A8200B0F1BA /* WorkerRunLoop.h in Headers */,
35535
				2E4346530F546A8200B0F1BA /* WorkerRunLoop.h in Headers */,
35523
				A5B81CCF1FAA44DE0037D1E6 /* WorkerRuntimeAgent.h in Headers */,
35536
				A5B81CCF1FAA44DE0037D1E6 /* WorkerRuntimeAgent.h in Headers */,
35537
				E347E5FA25D4F00000F17A5C /* WorkerScriptFetcher.h in Headers */,
35524
				A7D6B3490F61104500B79FD1 /* WorkerScriptLoader.h in Headers */,
35538
				A7D6B3490F61104500B79FD1 /* WorkerScriptLoader.h in Headers */,
35525
				2EA768040FE7126400AB9C8A /* WorkerScriptLoaderClient.h in Headers */,
35539
				2EA768040FE7126400AB9C8A /* WorkerScriptLoaderClient.h in Headers */,
35526
				2E4346550F546A8200B0F1BA /* WorkerThread.h in Headers */,
35540
				2E4346550F546A8200B0F1BA /* WorkerThread.h in Headers */,
- a/Source/WebCore/bindings/js/CachedModuleScriptLoader.cpp -10 / +8 lines
Lines 40-55 a/Source/WebCore/bindings/js/CachedModuleScriptLoader.cpp_sec1
40
40
41
namespace WebCore {
41
namespace WebCore {
42
42
43
Ref<CachedModuleScriptLoader> CachedModuleScriptLoader::create(CachedModuleScriptLoaderClient& client, DeferredPromise& promise, CachedScriptFetcher& scriptFetcher, RefPtr<ModuleFetchParameters>&& parameters)
43
Ref<CachedModuleScriptLoader> CachedModuleScriptLoader::create(ModuleScriptLoaderClient& client, DeferredPromise& promise, CachedScriptFetcher& scriptFetcher, RefPtr<ModuleFetchParameters>&& parameters)
44
{
44
{
45
    return adoptRef(*new CachedModuleScriptLoader(client, promise, scriptFetcher, WTFMove(parameters)));
45
    return adoptRef(*new CachedModuleScriptLoader(client, promise, scriptFetcher, WTFMove(parameters)));
46
}
46
}
47
47
48
CachedModuleScriptLoader::CachedModuleScriptLoader(CachedModuleScriptLoaderClient& client, DeferredPromise& promise, CachedScriptFetcher& scriptFetcher, RefPtr<ModuleFetchParameters>&& parameters)
48
CachedModuleScriptLoader::CachedModuleScriptLoader(ModuleScriptLoaderClient& client, DeferredPromise& promise, CachedScriptFetcher& scriptFetcher, RefPtr<ModuleFetchParameters>&& parameters)
49
    : m_client(&client)
49
    : ModuleScriptLoader(client, promise, scriptFetcher, WTFMove(parameters))
50
    , m_promise(&promise)
51
    , m_scriptFetcher(scriptFetcher)
52
    , m_parameters(WTFMove(parameters))
53
{
50
{
54
}
51
}
55
52
Lines 61-74 CachedModuleScriptLoader::~CachedModuleScriptLoader() a/Source/WebCore/bindings/js/CachedModuleScriptLoader.cpp_sec2
61
    }
58
    }
62
}
59
}
63
60
64
bool CachedModuleScriptLoader::load(Document& document, const URL& sourceURL)
61
bool CachedModuleScriptLoader::load(Document& document, URL&& sourceURL)
65
{
62
{
63
    ASSERT(m_promise);
66
    ASSERT(!m_cachedScript);
64
    ASSERT(!m_cachedScript);
67
    String integrity = m_parameters ? m_parameters->integrity() : String { };
65
    String integrity = m_parameters ? m_parameters->integrity() : String { };
68
    m_cachedScript = m_scriptFetcher->requestModuleScript(document, sourceURL, WTFMove(integrity));
66
    m_cachedScript = scriptFetcher().requestModuleScript(document, sourceURL, WTFMove(integrity));
69
    if (!m_cachedScript)
67
    if (!m_cachedScript)
70
        return false;
68
        return false;
71
    m_sourceURL = sourceURL;
69
    m_sourceURL = WTFMove(sourceURL);
72
70
73
    // If the content is already cached, this immediately calls notifyFinished.
71
    // If the content is already cached, this immediately calls notifyFinished.
74
    m_cachedScript->addClient(*this);
72
    m_cachedScript->addClient(*this);
Lines 83-89 void CachedModuleScriptLoader::notifyFinished(CachedResource& resource, const Ne a/Source/WebCore/bindings/js/CachedModuleScriptLoader.cpp_sec3
83
81
84
    Ref<CachedModuleScriptLoader> protectedThis(*this);
82
    Ref<CachedModuleScriptLoader> protectedThis(*this);
85
    if (m_client)
83
    if (m_client)
86
        m_client->notifyFinished(*this, WTFMove(m_promise));
84
        m_client->notifyFinished(*this, WTFMove(m_sourceURL), m_promise.releaseNonNull());
87
85
88
    // Remove the client after calling notifyFinished to keep the data buffer in
86
    // Remove the client after calling notifyFinished to keep the data buffer in
89
    // CachedResource alive while notifyFinished processes the resource.
87
    // CachedResource alive while notifyFinished processes the resource.
- a/Source/WebCore/bindings/js/CachedModuleScriptLoader.h -19 / +8 lines
Lines 27-32 a/Source/WebCore/bindings/js/CachedModuleScriptLoader.h_sec1
27
27
28
#include "CachedResourceClient.h"
28
#include "CachedResourceClient.h"
29
#include "CachedResourceHandle.h"
29
#include "CachedResourceHandle.h"
30
#include "CachedScriptFetcher.h"
31
#include "ModuleScriptLoader.h"
30
#include <wtf/Ref.h>
32
#include <wtf/Ref.h>
31
#include <wtf/RefCounted.h>
33
#include <wtf/RefCounted.h>
32
#include <wtf/RefPtr.h>
34
#include <wtf/RefPtr.h>
Lines 34-75 a/Source/WebCore/bindings/js/CachedModuleScriptLoader.h_sec2
34
36
35
namespace WebCore {
37
namespace WebCore {
36
38
37
class CachedModuleScriptLoaderClient;
39
class ModuleScriptLoaderClient;
38
class CachedScript;
40
class CachedScript;
39
class CachedScriptFetcher;
40
class DeferredPromise;
41
class DeferredPromise;
41
class Document;
42
class Document;
42
class JSDOMGlobalObject;
43
class JSDOMGlobalObject;
43
class ModuleFetchParameters;
44
class ModuleFetchParameters;
44
45
45
class CachedModuleScriptLoader final : public RefCounted<CachedModuleScriptLoader>, private CachedResourceClient {
46
class CachedModuleScriptLoader final : public ModuleScriptLoader, private CachedResourceClient {
46
public:
47
public:
47
    static Ref<CachedModuleScriptLoader> create(CachedModuleScriptLoaderClient&, DeferredPromise&, CachedScriptFetcher&, RefPtr<ModuleFetchParameters>&&);
48
    static Ref<CachedModuleScriptLoader> create(ModuleScriptLoaderClient&, DeferredPromise&, CachedScriptFetcher&, RefPtr<ModuleFetchParameters>&&);
48
49
49
    virtual ~CachedModuleScriptLoader();
50
    virtual ~CachedModuleScriptLoader();
50
51
51
    bool load(Document&, const URL& sourceURL);
52
    bool load(Document&, URL&& sourceURL);
52
53
53
    CachedScriptFetcher& scriptFetcher() { return m_scriptFetcher.get(); }
54
    CachedScript* cachedScript() { return m_cachedScript.get(); }
54
    CachedScript* cachedScript() { return m_cachedScript.get(); }
55
    ModuleFetchParameters* parameters() { return m_parameters.get(); }
55
    CachedScriptFetcher& scriptFetcher() { return static_cast<CachedScriptFetcher&>(ModuleScriptLoader::scriptFetcher()); }
56
    const URL& sourceURL() const { return m_sourceURL; }
57
58
    void clearClient()
59
    {
60
        ASSERT(m_client);
61
        m_client = nullptr;
62
    }
63
56
64
private:
57
private:
65
    CachedModuleScriptLoader(CachedModuleScriptLoaderClient&, DeferredPromise&, CachedScriptFetcher&, RefPtr<ModuleFetchParameters>&&);
58
    CachedModuleScriptLoader(ModuleScriptLoaderClient&, DeferredPromise&, CachedScriptFetcher&, RefPtr<ModuleFetchParameters>&&);
66
59
67
    void notifyFinished(CachedResource&, const NetworkLoadMetrics&) final;
60
    void notifyFinished(CachedResource&, const NetworkLoadMetrics&) final;
68
61
69
    CachedModuleScriptLoaderClient* m_client { nullptr };
70
    RefPtr<DeferredPromise> m_promise;
71
    Ref<CachedScriptFetcher> m_scriptFetcher;
72
    RefPtr<ModuleFetchParameters> m_parameters;
73
    CachedResourceHandle<CachedScript> m_cachedScript;
62
    CachedResourceHandle<CachedScript> m_cachedScript;
74
    URL m_sourceURL;
63
    URL m_sourceURL;
75
};
64
};
- a/Source/WebCore/bindings/js/CachedModuleScriptLoaderClient.h -40 lines
Lines 1-40 a/Source/WebCore/bindings/js/CachedModuleScriptLoaderClient.h_sec1
1
/*
2
 * Copyright (C) 2016 Apple, Inc. All Rights Reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
namespace WebCore {
29
30
class CachedModuleScriptLoader;
31
class DeferredPromise;
32
33
class CachedModuleScriptLoaderClient {
34
public:
35
    virtual ~CachedModuleScriptLoaderClient() = default;
36
37
    virtual void notifyFinished(CachedModuleScriptLoader&, RefPtr<DeferredPromise>) = 0;
38
};
39
40
}
- a/Source/WebCore/bindings/js/CachedScriptFetcher.cpp +2 lines
Lines 32-37 a/Source/WebCore/bindings/js/CachedScriptFetcher.cpp_sec1
32
#include "CrossOriginAccessControl.h"
32
#include "CrossOriginAccessControl.h"
33
#include "Document.h"
33
#include "Document.h"
34
#include "Settings.h"
34
#include "Settings.h"
35
#include "WorkerOrWorkletGlobalScope.h"
35
36
36
namespace WebCore {
37
namespace WebCore {
37
38
Lines 47-52 CachedResourceHandle<CachedScript> CachedScriptFetcher::requestModuleScript(Docu a/Source/WebCore/bindings/js/CachedScriptFetcher.cpp_sec2
47
48
48
CachedResourceHandle<CachedScript> CachedScriptFetcher::requestScriptWithCache(Document& document, const URL& sourceURL, const String& crossOriginMode, String&& integrity, Optional<ResourceLoadPriority> resourceLoadPriority) const
49
CachedResourceHandle<CachedScript> CachedScriptFetcher::requestScriptWithCache(Document& document, const URL& sourceURL, const String& crossOriginMode, String&& integrity, Optional<ResourceLoadPriority> resourceLoadPriority) const
49
{
50
{
51
    // Without scripting, there is no way to start Workers.
50
    if (!document.settings().isScriptEnabled())
52
    if (!document.settings().isScriptEnabled())
51
        return nullptr;
53
        return nullptr;
52
54
- a/Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp -16 / +44 lines
Lines 52-57 void reportException(JSGlobalObject* lexicalGlobalObject, JSValue exceptionValue a/Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp_sec1
52
    reportException(lexicalGlobalObject, exception, cachedScript);
52
    reportException(lexicalGlobalObject, exception, cachedScript);
53
}
53
}
54
54
55
String retrieveErrorMessageWithoutName(JSGlobalObject& lexicalGlobalObject, VM& vm, JSValue exception, CatchScope& catchScope)
56
{
57
    // FIXME: <http://webkit.org/b/115087> Web Inspector: WebCore::reportException should not evaluate JavaScript handling exceptions
58
    // If this is a custom exception object, call toString on it to try and get a nice string representation for the exception.
59
    String errorMessage;
60
    if (auto* error = jsDynamicCast<ErrorInstance*>(vm, exception))
61
        errorMessage = error->sanitizedMessageString(&lexicalGlobalObject);
62
    else if (auto* error = jsDynamicCast<JSDOMException*>(vm, exception))
63
        errorMessage = error->wrapped().message();
64
    else
65
        errorMessage = exception.toWTFString(&lexicalGlobalObject);
66
67
    // We need to clear any new exception that may be thrown in the toString() call above.
68
    // reportException() is not supposed to be making new exceptions.
69
    catchScope.clearException();
70
    vm.clearLastException();
71
    return errorMessage;
72
}
73
55
String retrieveErrorMessage(JSGlobalObject& lexicalGlobalObject, VM& vm, JSValue exception, CatchScope& catchScope)
74
String retrieveErrorMessage(JSGlobalObject& lexicalGlobalObject, VM& vm, JSValue exception, CatchScope& catchScope)
56
{
75
{
57
    // FIXME: <http://webkit.org/b/115087> Web Inspector: WebCore::reportException should not evaluate JavaScript handling exceptions
76
    // FIXME: <http://webkit.org/b/115087> Web Inspector: WebCore::reportException should not evaluate JavaScript handling exceptions
Lines 121-156 void reportCurrentException(JSGlobalObject* lexicalGlobalObject) a/Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp_sec2
121
140
122
JSValue createDOMException(JSGlobalObject* lexicalGlobalObject, ExceptionCode ec, const String& message)
141
JSValue createDOMException(JSGlobalObject* lexicalGlobalObject, ExceptionCode ec, const String& message)
123
{
142
{
124
    if (ec == ExistingExceptionError)
143
    switch (ec) {
144
    case ExistingExceptionError:
125
        return jsUndefined();
145
        return jsUndefined();
126
146
127
    // FIXME: Handle other WebIDL exception types.
147
    // FIXME: Handle other WebIDL exception types.
128
    if (ec == TypeError) {
148
    case TypeError:
129
        if (message.isEmpty())
149
        if (message.isEmpty())
130
            return createTypeError(lexicalGlobalObject);
150
            return createTypeError(lexicalGlobalObject);
131
        return createTypeError(lexicalGlobalObject, message);
151
        return createTypeError(lexicalGlobalObject, message);
132
    }
133
152
134
    if (ec == RangeError) {
153
    case RangeError:
135
        if (message.isEmpty())
154
        if (message.isEmpty())
136
            return createRangeError(lexicalGlobalObject, "Bad value"_s);
155
            return createRangeError(lexicalGlobalObject, "Bad value"_s);
137
        return createRangeError(lexicalGlobalObject, message);
156
        return createRangeError(lexicalGlobalObject, message);
138
    }
139
157
140
    if (ec == StackOverflowError)
158
    case JSSyntaxError:
159
        if (message.isEmpty())
160
            return createSyntaxError(lexicalGlobalObject);
161
        return createSyntaxError(lexicalGlobalObject, message);
162
163
    case StackOverflowError:
141
        return createStackOverflowError(lexicalGlobalObject);
164
        return createStackOverflowError(lexicalGlobalObject);
142
    if (ec == OutOfMemoryError)
165
166
    case OutOfMemoryError:
143
        return createOutOfMemoryError(lexicalGlobalObject);
167
        return createOutOfMemoryError(lexicalGlobalObject);
144
168
145
    // FIXME: All callers to createDOMException need to pass in the correct global object.
169
    default: {
146
    // For now, we're going to assume the lexicalGlobalObject. Which is wrong in cases like this:
170
        // FIXME: All callers to createDOMException need to pass in the correct global object.
147
    // frames[0].document.createElement(null, null); // throws an exception which should have the subframe's prototypes.
171
        // For now, we're going to assume the lexicalGlobalObject. Which is wrong in cases like this:
148
    JSDOMGlobalObject* globalObject = deprecatedGlobalObjectForPrototype(lexicalGlobalObject);
172
        // frames[0].document.createElement(null, null); // throws an exception which should have the subframe's prototypes.
149
    JSValue errorObject = toJS(lexicalGlobalObject, globalObject, DOMException::create(ec, message));
173
        JSDOMGlobalObject* globalObject = deprecatedGlobalObjectForPrototype(lexicalGlobalObject);
150
    
174
        JSValue errorObject = toJS(lexicalGlobalObject, globalObject, DOMException::create(ec, message));
151
    ASSERT(errorObject);
175
152
    addErrorInfo(lexicalGlobalObject, asObject(errorObject), true);
176
        ASSERT(errorObject);
153
    return errorObject;
177
        addErrorInfo(lexicalGlobalObject, asObject(errorObject), true);
178
        return errorObject;
179
    }
180
    }
181
    return { };
154
}
182
}
155
183
156
JSValue createDOMException(JSGlobalObject& lexicalGlobalObject, Exception&& exception)
184
JSValue createDOMException(JSGlobalObject& lexicalGlobalObject, Exception&& exception)
- a/Source/WebCore/bindings/js/JSDOMExceptionHandling.h +1 lines
Lines 65-70 WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::JSGloba a/Source/WebCore/bindings/js/JSDOMExceptionHandling.h_sec1
65
WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise&, const char* interfaceName, const char* operationName);
65
WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise&, const char* interfaceName, const char* operationName);
66
WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::JSGlobalObject&, const char* interfaceName, const char* operationName);
66
WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::JSGlobalObject&, const char* interfaceName, const char* operationName);
67
67
68
String retrieveErrorMessageWithoutName(JSC::JSGlobalObject&, JSC::VM&, JSC::JSValue exception, JSC::CatchScope&);
68
String retrieveErrorMessage(JSC::JSGlobalObject&, JSC::VM&, JSC::JSValue exception, JSC::CatchScope&);
69
String retrieveErrorMessage(JSC::JSGlobalObject&, JSC::VM&, JSC::JSValue exception, JSC::CatchScope&);
69
WEBCORE_EXPORT void reportException(JSC::JSGlobalObject*, JSC::JSValue exception, CachedScript* = nullptr);
70
WEBCORE_EXPORT void reportException(JSC::JSGlobalObject*, JSC::JSValue exception, CachedScript* = nullptr);
70
WEBCORE_EXPORT void reportException(JSC::JSGlobalObject*, JSC::Exception*, CachedScript* = nullptr, ExceptionDetails* = nullptr);
71
WEBCORE_EXPORT void reportException(JSC::JSGlobalObject*, JSC::Exception*, CachedScript* = nullptr, ExceptionDetails* = nullptr);
- a/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp +74 lines
Lines 47-52 a/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp_sec1
47
#include "JSWorkletGlobalScope.h"
47
#include "JSWorkletGlobalScope.h"
48
#include "RejectedPromiseTracker.h"
48
#include "RejectedPromiseTracker.h"
49
#include "RuntimeEnabledFeatures.h"
49
#include "RuntimeEnabledFeatures.h"
50
#include "ScriptModuleLoader.h"
50
#include "StructuredClone.h"
51
#include "StructuredClone.h"
51
#include "WebCoreJSClientData.h"
52
#include "WebCoreJSClientData.h"
52
#include "WorkerGlobalScope.h"
53
#include "WorkerGlobalScope.h"
Lines 422-427 JSC::JSPromise* JSDOMGlobalObject::instantiateStreaming(JSC::JSGlobalObject* glo a/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp_sec2
422
}
423
}
423
#endif
424
#endif
424
425
426
static ScriptModuleLoader* scriptModuleLoader(JSDOMGlobalObject* globalObject)
427
{
428
    VM& vm = globalObject->vm();
429
    if (globalObject->inherits<JSDOMWindowBase>(vm)) {
430
        if (auto document = jsCast<const JSDOMWindowBase*>(globalObject)->wrapped().document())
431
            return &document->moduleLoader();
432
        return nullptr;
433
    }
434
    if (globalObject->inherits<JSRemoteDOMWindowBase>(vm))
435
        return nullptr;
436
    if (globalObject->inherits<JSWorkerGlobalScopeBase>(vm))
437
        return &jsCast<const JSWorkerGlobalScopeBase*>(globalObject)->wrapped().moduleLoader();
438
    if (globalObject->inherits<JSWorkletGlobalScopeBase>(vm))
439
        return &jsCast<const JSWorkletGlobalScopeBase*>(globalObject)->wrapped().moduleLoader();
440
#if ENABLE(INDEXED_DATABASE)
441
    if (globalObject->inherits<JSIDBSerializationGlobalObject>(vm))
442
        return nullptr;
443
#endif
444
    dataLog("Unexpected global object: ", JSValue(globalObject), "\n");
445
    RELEASE_ASSERT_NOT_REACHED();
446
    return nullptr;
447
}
448
449
JSC::Identifier JSDOMGlobalObject::moduleLoaderResolve(JSC::JSGlobalObject* globalObject, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleName, JSC::JSValue importerModuleKey, JSC::JSValue scriptFetcher)
450
{
451
    JSDOMGlobalObject* thisObject = JSC::jsCast<JSDOMGlobalObject*>(globalObject);
452
    if (auto* loader = scriptModuleLoader(thisObject))
453
        return loader->resolve(globalObject, moduleLoader, moduleName, importerModuleKey, scriptFetcher);
454
    return { };
455
}
456
457
JSC::JSInternalPromise* JSDOMGlobalObject::moduleLoaderFetch(JSC::JSGlobalObject* globalObject, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleKey, JSC::JSValue parameters, JSC::JSValue scriptFetcher)
458
{
459
    VM& vm = globalObject->vm();
460
    auto scope = DECLARE_THROW_SCOPE(vm);
461
    JSDOMGlobalObject* thisObject = JSC::jsCast<JSDOMGlobalObject*>(globalObject);
462
    if (auto* loader = scriptModuleLoader(thisObject))
463
        RELEASE_AND_RETURN(scope, loader->fetch(globalObject, moduleLoader, moduleKey, parameters, scriptFetcher));
464
    JSC::JSInternalPromise* promise = JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure());
465
    scope.release();
466
    promise->reject(globalObject, jsUndefined());
467
    return promise;
468
}
469
470
JSC::JSValue JSDOMGlobalObject::moduleLoaderEvaluate(JSC::JSGlobalObject* globalObject, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleKey, JSC::JSValue moduleRecord, JSC::JSValue scriptFetcher)
471
{
472
    JSDOMGlobalObject* thisObject = JSC::jsCast<JSDOMGlobalObject*>(globalObject);
473
    if (auto* loader = scriptModuleLoader(thisObject))
474
        return loader->evaluate(globalObject, moduleLoader, moduleKey, moduleRecord, scriptFetcher);
475
    return JSC::jsUndefined();
476
}
477
478
JSC::JSInternalPromise* JSDOMGlobalObject::moduleLoaderImportModule(JSC::JSGlobalObject* globalObject, JSC::JSModuleLoader* moduleLoader, JSC::JSString* moduleName, JSC::JSValue parameters, const JSC::SourceOrigin& sourceOrigin)
479
{
480
    VM& vm = globalObject->vm();
481
    auto scope = DECLARE_THROW_SCOPE(vm);
482
    JSDOMGlobalObject* thisObject = JSC::jsCast<JSDOMGlobalObject*>(globalObject);
483
    if (auto* loader = scriptModuleLoader(thisObject))
484
        RELEASE_AND_RETURN(scope, loader->importModule(globalObject, moduleLoader, moduleName, parameters, sourceOrigin));
485
    JSC::JSInternalPromise* promise = JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure());
486
    scope.release();
487
    promise->reject(globalObject, jsUndefined());
488
    return promise;
489
}
490
491
JSC::JSObject* JSDOMGlobalObject::moduleLoaderCreateImportMetaProperties(JSC::JSGlobalObject* globalObject, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleKey, JSC::JSModuleRecord* moduleRecord, JSC::JSValue scriptFetcher)
492
{
493
    JSDOMGlobalObject* thisObject = JSC::jsCast<JSDOMGlobalObject*>(globalObject);
494
    if (auto* loader = scriptModuleLoader(thisObject))
495
        return loader->createImportMetaProperties(globalObject, moduleLoader, moduleKey, moduleRecord, scriptFetcher);
496
    return constructEmptyObject(globalObject->vm(), globalObject->nullPrototypeObjectStructure());
497
}
498
425
JSDOMGlobalObject& callerGlobalObject(JSGlobalObject& lexicalGlobalObject, CallFrame& callFrame)
499
JSDOMGlobalObject& callerGlobalObject(JSGlobalObject& lexicalGlobalObject, CallFrame& callFrame)
426
{
500
{
427
    class GetCallerGlobalObjectFunctor {
501
    class GetCallerGlobalObjectFunctor {
- a/Source/WebCore/bindings/js/JSDOMGlobalObject.h +6 lines
Lines 105-110 class WEBCORE_EXPORT JSDOMGlobalObject : public JSC::JSGlobalObject { a/Source/WebCore/bindings/js/JSDOMGlobalObject.h_sec1
105
    static JSC::JSPromise* instantiateStreaming(JSC::JSGlobalObject*, JSC::JSValue, JSC::JSObject*);
105
    static JSC::JSPromise* instantiateStreaming(JSC::JSGlobalObject*, JSC::JSValue, JSC::JSObject*);
106
#endif
106
#endif
107
107
108
    static JSC::Identifier moduleLoaderResolve(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue);
109
    static JSC::JSInternalPromise* moduleLoaderFetch(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue);
110
    static JSC::JSValue moduleLoaderEvaluate(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue);
111
    static JSC::JSInternalPromise* moduleLoaderImportModule(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSString*, JSC::JSValue, const JSC::SourceOrigin&);
112
    static JSC::JSObject* moduleLoaderCreateImportMetaProperties(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSModuleRecord*, JSC::JSValue);
113
108
    JSDOMStructureMap m_structures;
114
    JSDOMStructureMap m_structures;
109
    JSDOMConstructorMap m_constructors;
115
    JSDOMConstructorMap m_constructors;
110
    DOMGuardedObjectSet m_guardedObjects;
116
    DOMGuardedObjectSet m_guardedObjects;
- a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp -50 lines
Lines 339-392 void JSDOMWindowBase::fireFrameClearedWatchpointsForWindow(DOMWindow* window) a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp_sec1
339
    }
339
    }
340
}
340
}
341
341
342
JSC::Identifier JSDOMWindowBase::moduleLoaderResolve(JSC::JSGlobalObject* globalObject, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleName, JSC::JSValue importerModuleKey, JSC::JSValue scriptFetcher)
343
{
344
    JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
345
    if (RefPtr<Document> document = thisObject->wrapped().document())
346
        return document->moduleLoader().resolve(globalObject, moduleLoader, moduleName, importerModuleKey, scriptFetcher);
347
    return { };
348
}
349
350
JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderFetch(JSC::JSGlobalObject* globalObject, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleKey, JSC::JSValue parameters, JSC::JSValue scriptFetcher)
351
{
352
    VM& vm = globalObject->vm();
353
    auto scope = DECLARE_THROW_SCOPE(vm);
354
    JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
355
    if (RefPtr<Document> document = thisObject->wrapped().document())
356
        RELEASE_AND_RETURN(scope, document->moduleLoader().fetch(globalObject, moduleLoader, moduleKey, parameters, scriptFetcher));
357
    JSC::JSInternalPromise* promise = JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure());
358
    scope.release();
359
    promise->reject(globalObject, jsUndefined());
360
    return promise;
361
}
362
363
JSC::JSValue JSDOMWindowBase::moduleLoaderEvaluate(JSC::JSGlobalObject* globalObject, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleKey, JSC::JSValue moduleRecord, JSC::JSValue scriptFetcher)
364
{
365
    JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
366
    if (RefPtr<Document> document = thisObject->wrapped().document())
367
        return document->moduleLoader().evaluate(globalObject, moduleLoader, moduleKey, moduleRecord, scriptFetcher);
368
    return JSC::jsUndefined();
369
}
370
371
JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderImportModule(JSC::JSGlobalObject* globalObject, JSC::JSModuleLoader* moduleLoader, JSC::JSString* moduleName, JSC::JSValue parameters, const JSC::SourceOrigin& sourceOrigin)
372
{
373
    VM& vm = globalObject->vm();
374
    auto scope = DECLARE_THROW_SCOPE(vm);
375
    JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
376
    if (RefPtr<Document> document = thisObject->wrapped().document())
377
        RELEASE_AND_RETURN(scope, document->moduleLoader().importModule(globalObject, moduleLoader, moduleName, parameters, sourceOrigin));
378
    JSC::JSInternalPromise* promise = JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure());
379
    scope.release();
380
    promise->reject(globalObject, jsUndefined());
381
    return promise;
382
}
383
384
JSC::JSObject* JSDOMWindowBase::moduleLoaderCreateImportMetaProperties(JSC::JSGlobalObject* globalObject, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleKey, JSC::JSModuleRecord* moduleRecord, JSC::JSValue scriptFetcher)
385
{
386
    JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
387
    if (RefPtr<Document> document = thisObject->wrapped().document())
388
        return document->moduleLoader().createImportMetaProperties(globalObject, moduleLoader, moduleKey, moduleRecord, scriptFetcher);
389
    return constructEmptyObject(globalObject->vm(), globalObject->nullPrototypeObjectStructure());
390
}
391
392
} // namespace WebCore
342
} // namespace WebCore
- a/Source/WebCore/bindings/js/JSDOMWindowBase.h -6 lines
Lines 99-110 class WEBCORE_EXPORT JSDOMWindowBase : public JSDOMGlobalObject { a/Source/WebCore/bindings/js/JSDOMWindowBase.h_sec1
99
private:
99
private:
100
    using ResponseCallback = WTF::Function<void(const char*, size_t)>;
100
    using ResponseCallback = WTF::Function<void(const char*, size_t)>;
101
101
102
    static JSC::Identifier moduleLoaderResolve(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue);
103
    static JSC::JSInternalPromise* moduleLoaderFetch(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue);
104
    static JSC::JSValue moduleLoaderEvaluate(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue);
105
    static JSC::JSInternalPromise* moduleLoaderImportModule(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSString*, JSC::JSValue, const JSC::SourceOrigin&);
106
    static JSC::JSObject* moduleLoaderCreateImportMetaProperties(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSModuleRecord*, JSC::JSValue);
107
108
    RefPtr<DOMWindow> m_wrapped;
102
    RefPtr<DOMWindow> m_wrapped;
109
    RefPtr<Event> m_currentEvent;
103
    RefPtr<Event> m_currentEvent;
110
};
104
};
- a/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp -5 / +5 lines
Lines 59-69 const GlobalObjectMethodTable JSWorkerGlobalScopeBase::s_globalObjectMethodTable a/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp_sec1
59
    &javaScriptRuntimeFlags,
59
    &javaScriptRuntimeFlags,
60
    &queueMicrotaskToEventLoop,
60
    &queueMicrotaskToEventLoop,
61
    &shouldInterruptScriptBeforeTimeout,
61
    &shouldInterruptScriptBeforeTimeout,
62
    nullptr, // moduleLoaderImportModule
62
    &moduleLoaderImportModule,
63
    nullptr, // moduleLoaderResolve
63
    &moduleLoaderResolve,
64
    nullptr, // moduleLoaderFetch
64
    &moduleLoaderFetch,
65
    nullptr, // moduleLoaderCreateImportMetaProperties
65
    &moduleLoaderCreateImportMetaProperties,
66
    nullptr, // moduleLoaderEvaluate
66
    &moduleLoaderEvaluate,
67
    &promiseRejectionTracker,
67
    &promiseRejectionTracker,
68
    &reportUncaughtExceptionAtEventLoop,
68
    &reportUncaughtExceptionAtEventLoop,
69
    &currentScriptExecutionOwner,
69
    &currentScriptExecutionOwner,
- a/Source/WebCore/bindings/js/JSWorkletGlobalScopeBase.cpp -5 / +5 lines
Lines 49-59 const GlobalObjectMethodTable JSWorkletGlobalScopeBase::s_globalObjectMethodTabl a/Source/WebCore/bindings/js/JSWorkletGlobalScopeBase.cpp_sec1
49
    &javaScriptRuntimeFlags,
49
    &javaScriptRuntimeFlags,
50
    nullptr, // queueMicrotaskToEventLoop
50
    nullptr, // queueMicrotaskToEventLoop
51
    &shouldInterruptScriptBeforeTimeout,
51
    &shouldInterruptScriptBeforeTimeout,
52
    nullptr, // moduleLoaderImportModule
52
    &moduleLoaderImportModule,
53
    nullptr, // moduleLoaderResolve
53
    &moduleLoaderResolve,
54
    nullptr, // moduleLoaderFetch
54
    &moduleLoaderFetch,
55
    nullptr, // moduleLoaderCreateImportMetaProperties
55
    &moduleLoaderCreateImportMetaProperties,
56
    nullptr, // moduleLoaderEvaluate
56
    &moduleLoaderEvaluate,
57
    &promiseRejectionTracker,
57
    &promiseRejectionTracker,
58
    &reportUncaughtExceptionAtEventLoop,
58
    &reportUncaughtExceptionAtEventLoop,
59
    &currentScriptExecutionOwner,
59
    &currentScriptExecutionOwner,
- a/Source/WebCore/bindings/js/ModuleScriptLoader.h +65 lines
Line 0 a/Source/WebCore/bindings/js/ModuleScriptLoader.h_sec1
1
/*
2
 * Copyright (C) 2021 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#include "JSDOMPromiseDeferred.h"
29
#include "ModuleFetchParameters.h"
30
#include <JavaScriptCore/ScriptFetcher.h>
31
#include <wtf/RefCounted.h>
32
33
namespace WebCore {
34
35
class ModuleScriptLoaderClient;
36
37
class ModuleScriptLoader : public RefCounted<ModuleScriptLoader> {
38
public:
39
    virtual ~ModuleScriptLoader() = default;
40
41
    void clearClient()
42
    {
43
        ASSERT(m_client);
44
        m_client = nullptr;
45
    }
46
47
    JSC::ScriptFetcher& scriptFetcher() { return m_scriptFetcher.get(); }
48
    ModuleFetchParameters* parameters() { return m_parameters.get(); }
49
50
protected:
51
    ModuleScriptLoader(ModuleScriptLoaderClient& client, DeferredPromise& promise, JSC::ScriptFetcher& scriptFetcher, RefPtr<ModuleFetchParameters>&& parameters)
52
        : m_client(&client)
53
        , m_promise(&promise)
54
        , m_scriptFetcher(scriptFetcher)
55
        , m_parameters(WTFMove(parameters))
56
    {
57
    }
58
59
    ModuleScriptLoaderClient* m_client;
60
    RefPtr<DeferredPromise> m_promise;
61
    Ref<JSC::ScriptFetcher> m_scriptFetcher;
62
    RefPtr<ModuleFetchParameters> m_parameters;
63
};
64
65
} // namespace WebCore
- a/Source/WebCore/bindings/js/ModuleScriptLoaderClient.h +40 lines
Line 0 a/Source/WebCore/bindings/js/ModuleScriptLoaderClient.h_sec1
1
/*
2
 * Copyright (C) 2021 Apple, Inc. All Rights Reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
namespace WebCore {
29
30
class ModuleScriptLoader;
31
class DeferredPromise;
32
33
class ModuleScriptLoaderClient {
34
public:
35
    virtual ~ModuleScriptLoaderClient() = default;
36
37
    virtual void notifyFinished(ModuleScriptLoader&, URL&&, Ref<DeferredPromise>) = 0;
38
};
39
40
}
- a/Source/WebCore/bindings/js/ScriptModuleLoader.cpp -65 / +142 lines
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
}
- a/Source/WebCore/bindings/js/ScriptModuleLoader.h -9 / +12 lines
Lines 25-32 a/Source/WebCore/bindings/js/ScriptModuleLoader.h_sec1
25
25
26
#pragma once
26
#pragma once
27
27
28
#include "CachedModuleScriptLoader.h"
28
#include "ModuleScriptLoader.h"
29
#include "CachedModuleScriptLoaderClient.h"
29
#include "ModuleScriptLoaderClient.h"
30
#include <JavaScriptCore/JSCJSValue.h>
30
#include <JavaScriptCore/JSCJSValue.h>
31
#include <wtf/HashSet.h>
31
#include <wtf/HashSet.h>
32
#include <wtf/Noncopyable.h>
32
#include <wtf/Noncopyable.h>
Lines 45-60 class SourceOrigin; a/Source/WebCore/bindings/js/ScriptModuleLoader.h_sec2
45
45
46
namespace WebCore {
46
namespace WebCore {
47
47
48
class Document;
49
class JSDOMGlobalObject;
48
class JSDOMGlobalObject;
49
class ScriptExecutionContext;
50
50
51
class ScriptModuleLoader final : private CachedModuleScriptLoaderClient {
51
class ScriptModuleLoader final : private ModuleScriptLoaderClient {
52
    WTF_MAKE_NONCOPYABLE(ScriptModuleLoader); WTF_MAKE_FAST_ALLOCATED;
52
    WTF_MAKE_NONCOPYABLE(ScriptModuleLoader); WTF_MAKE_FAST_ALLOCATED;
53
public:
53
public:
54
    explicit ScriptModuleLoader(Document&);
54
    enum class OwnerType : uint8_t { Document, WorkerOrWorklet };
55
    explicit ScriptModuleLoader(ScriptExecutionContext&, OwnerType);
55
    ~ScriptModuleLoader();
56
    ~ScriptModuleLoader();
56
57
57
    Document& document() { return m_document; }
58
    ScriptExecutionContext& context() { return m_context; }
58
59
59
    JSC::Identifier resolve(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue moduleName, JSC::JSValue importerModuleKey, JSC::JSValue scriptFetcher);
60
    JSC::Identifier resolve(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue moduleName, JSC::JSValue importerModuleKey, JSC::JSValue scriptFetcher);
60
    JSC::JSInternalPromise* fetch(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue moduleKey, JSC::JSValue parameters, JSC::JSValue scriptFetcher);
61
    JSC::JSInternalPromise* fetch(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue moduleKey, JSC::JSValue parameters, JSC::JSValue scriptFetcher);
Lines 63-75 class ScriptModuleLoader final : private CachedModuleScriptLoaderClient { a/Source/WebCore/bindings/js/ScriptModuleLoader.h_sec3
63
    JSC::JSObject* createImportMetaProperties(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSModuleRecord*, JSC::JSValue);
64
    JSC::JSObject* createImportMetaProperties(JSC::JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSModuleRecord*, JSC::JSValue);
64
65
65
private:
66
private:
66
    void notifyFinished(CachedModuleScriptLoader&, RefPtr<DeferredPromise>) final;
67
    void notifyFinished(ModuleScriptLoader&, URL&&, Ref<DeferredPromise>) final;
68
67
    URL moduleURL(JSC::JSGlobalObject&, JSC::JSValue);
69
    URL moduleURL(JSC::JSGlobalObject&, JSC::JSValue);
68
    URL responseURLFromRequestURL(JSC::JSGlobalObject&, JSC::JSValue);
70
    URL responseURLFromRequestURL(JSC::JSGlobalObject&, JSC::JSValue);
69
71
70
    Document& m_document;
72
    ScriptExecutionContext& m_context;
71
    HashMap<String, URL> m_requestURLToResponseURLMap;
73
    HashMap<String, URL> m_requestURLToResponseURLMap;
72
    HashSet<Ref<CachedModuleScriptLoader>> m_loaders;
74
    HashSet<Ref<ModuleScriptLoader>> m_loaders;
75
    OwnerType m_ownerType;
73
};
76
};
74
77
75
} // namespace WebCore
78
} // namespace WebCore
- a/Source/WebCore/bindings/js/ScriptSourceCode.h -1 / +1 lines
Lines 57-63 class ScriptSourceCode { a/Source/WebCore/bindings/js/ScriptSourceCode.h_sec1
57
    {
57
    {
58
    }
58
    }
59
59
60
    ScriptSourceCode(const String& source, URL&& url, const TextPosition& startPosition, JSC::SourceProviderSourceType sourceType, Ref<CachedScriptFetcher>&& scriptFetcher)
60
    ScriptSourceCode(const String& source, URL&& url, const TextPosition& startPosition, JSC::SourceProviderSourceType sourceType, Ref<JSC::ScriptFetcher>&& scriptFetcher)
61
        : m_provider(JSC::StringSourceProvider::create(source, JSC::SourceOrigin { url, WTFMove(scriptFetcher) }, url.string(), startPosition, sourceType))
61
        : m_provider(JSC::StringSourceProvider::create(source, JSC::SourceOrigin { url, WTFMove(scriptFetcher) }, url.string(), startPosition, sourceType))
62
        , m_code(m_provider.copyRef(), startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt())
62
        , m_code(m_provider.copyRef(), startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt())
63
    {
63
    {
- a/Source/WebCore/bindings/js/WorkerModuleScriptLoader.cpp +87 lines
Line 0 a/Source/WebCore/bindings/js/WorkerModuleScriptLoader.cpp_sec1
1
/*
2
 * Copyright (C) 2021 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "WorkerModuleScriptLoader.h"
28
29
#include "CachedScriptFetcher.h"
30
#include "DOMWrapperWorld.h"
31
#include "Frame.h"
32
#include "JSDOMBinding.h"
33
#include "JSDOMPromiseDeferred.h"
34
#include "ModuleFetchParameters.h"
35
#include "ResourceLoaderOptions.h"
36
#include "ScriptController.h"
37
#include "ScriptModuleLoader.h"
38
#include "ScriptSourceCode.h"
39
#include "WorkerScriptFetcher.h"
40
#include "WorkerScriptLoader.h"
41
42
namespace WebCore {
43
44
Ref<WorkerModuleScriptLoader> WorkerModuleScriptLoader::create(ModuleScriptLoaderClient& client, DeferredPromise& promise, WorkerScriptFetcher& scriptFetcher, RefPtr<ModuleFetchParameters>&& parameters)
45
{
46
    return adoptRef(*new WorkerModuleScriptLoader(client, promise, scriptFetcher, WTFMove(parameters)));
47
}
48
49
WorkerModuleScriptLoader::WorkerModuleScriptLoader(ModuleScriptLoaderClient& client, DeferredPromise& promise, WorkerScriptFetcher& scriptFetcher, RefPtr<ModuleFetchParameters>&& parameters)
50
    : ModuleScriptLoader(client, promise, scriptFetcher, WTFMove(parameters))
51
    , m_scriptLoader(WorkerScriptLoader::create())
52
{
53
}
54
55
WorkerModuleScriptLoader::~WorkerModuleScriptLoader()
56
{
57
    m_scriptLoader->cancel();
58
}
59
60
bool WorkerModuleScriptLoader::load(ScriptExecutionContext& context, URL&& sourceURL)
61
{
62
    m_sourceURL = WTFMove(sourceURL);
63
64
    ResourceRequest request { m_sourceURL };
65
66
    FetchOptions fetchOptions;
67
    fetchOptions.mode = FetchOptions::Mode::Cors;
68
    fetchOptions.cache = FetchOptions::Cache::Default;
69
    fetchOptions.redirect = FetchOptions::Redirect::Follow;
70
    fetchOptions.credentials = static_cast<WorkerScriptFetcher&>(scriptFetcher()).credentials();
71
    auto contentSecurityPolicyEnforcement = context.shouldBypassMainWorldContentSecurityPolicy() ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceChildSrcDirective;
72
73
    String taskMode = "loadModulesInWorkerOrWorkletMode"_s;
74
    m_scriptLoader->loadAsynchronously(context, WTFMove(request), WTFMove(fetchOptions), contentSecurityPolicyEnforcement, ServiceWorkersMode::All, *this, WTFMove(taskMode));
75
    return true;
76
}
77
78
void WorkerModuleScriptLoader::notifyFinished()
79
{
80
    ASSERT(m_promise);
81
82
    auto protectedThis = makeRef(*this);
83
    if (m_client)
84
        m_client->notifyFinished(*this, WTFMove(m_sourceURL), m_promise.releaseNonNull());
85
}
86
87
}
- a/Source/WebCore/bindings/js/WorkerModuleScriptLoader.h +64 lines
Line 0 a/Source/WebCore/bindings/js/WorkerModuleScriptLoader.h_sec1
1
/*
2
 * Copyright (C) 2021 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#include "ModuleScriptLoader.h"
29
#include "WorkerScriptLoaderClient.h"
30
#include <wtf/Ref.h>
31
#include <wtf/RefCounted.h>
32
#include <wtf/RefPtr.h>
33
#include <wtf/URL.h>
34
35
namespace WebCore {
36
37
class DeferredPromise;
38
class JSDOMGlobalObject;
39
class ModuleFetchParameters;
40
class ScriptExecutionContext;
41
class ModuleScriptLoaderClient;
42
class WorkerScriptLoader;
43
44
class WorkerModuleScriptLoader final : public ModuleScriptLoader, private WorkerScriptLoaderClient {
45
public:
46
    static Ref<WorkerModuleScriptLoader> create(ModuleScriptLoaderClient&, DeferredPromise&, WorkerScriptFetcher&, RefPtr<ModuleFetchParameters>&&);
47
48
    virtual ~WorkerModuleScriptLoader();
49
50
    bool load(ScriptExecutionContext&, URL&& sourceURL);
51
52
    WorkerScriptLoader& scriptLoader() { return m_scriptLoader.get(); }
53
54
private:
55
    WorkerModuleScriptLoader(ModuleScriptLoaderClient&, DeferredPromise&, WorkerScriptFetcher&, RefPtr<ModuleFetchParameters>&&);
56
57
    void didReceiveResponse(unsigned long, const ResourceResponse&) final { }
58
    void notifyFinished() final;
59
60
    Ref<WorkerScriptLoader> m_scriptLoader;
61
    URL m_sourceURL;
62
};
63
64
} // namespace WebCore
- a/Source/WebCore/bindings/js/WorkerScriptFetcher.h +84 lines
Line 0 a/Source/WebCore/bindings/js/WorkerScriptFetcher.h_sec1
1
/*
2
 * Copyright (C) 2021 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#include "LoadableScript.h"
29
#include <JavaScriptCore/ScriptFetcher.h>
30
#include <wtf/Optional.h>
31
#include <wtf/text/WTFString.h>
32
33
namespace WebCore {
34
35
class CachedScript;
36
class Document;
37
38
class WorkerScriptFetcher final : public JSC::ScriptFetcher {
39
public:
40
    static Ref<WorkerScriptFetcher> create(FetchOptions::Credentials credentials)
41
    {
42
        return adoptRef(*new WorkerScriptFetcher(credentials));
43
    }
44
45
    FetchOptions::Credentials credentials() const { return m_credentials; }
46
47
    void notifyLoadCompleted(UniquedStringImpl& moduleKey)
48
    {
49
        m_moduleKey = &moduleKey;
50
        m_isLoaded = true;
51
    }
52
53
    void notifyLoadFailed(LoadableScript::Error&& error)
54
    {
55
        m_error = WTFMove(error);
56
        m_isLoaded = true;
57
    }
58
59
    void notifyLoadWasCanceled()
60
    {
61
        m_wasCanceled = true;
62
        m_isLoaded = true;
63
    }
64
65
    bool isLoaded() const { return m_isLoaded; }
66
    Optional<LoadableScript::Error> error() const { return m_error; }
67
    bool wasCanceled() const { return m_wasCanceled; }
68
    UniquedStringImpl* moduleKey() const { return m_moduleKey.get(); }
69
70
protected:
71
    WorkerScriptFetcher(FetchOptions::Credentials credentials)
72
        : m_credentials(credentials)
73
    {
74
    }
75
76
private:
77
    FetchOptions::Credentials m_credentials;
78
    RefPtr<UniquedStringImpl> m_moduleKey;
79
    Optional<LoadableScript::Error> m_error;
80
    bool m_wasCanceled { false };
81
    bool m_isLoaded { false };
82
};
83
84
} // namespace WebCore
- a/Source/WebCore/dom/Document.cpp -1 / +1 lines
Lines 615-621 Document::Document(Frame* frame, const Settings& settings, const URL& url, Docum a/Source/WebCore/dom/Document.cpp_sec1
615
    , m_documentCreationTime(MonotonicTime::now())
615
    , m_documentCreationTime(MonotonicTime::now())
616
#endif
616
#endif
617
    , m_scriptRunner(makeUnique<ScriptRunner>(*this))
617
    , m_scriptRunner(makeUnique<ScriptRunner>(*this))
618
    , m_moduleLoader(makeUnique<ScriptModuleLoader>(*this))
618
    , m_moduleLoader(makeUnique<ScriptModuleLoader>(*this, ScriptModuleLoader::OwnerType::Document))
619
#if ENABLE(XSLT)
619
#if ENABLE(XSLT)
620
    , m_applyPendingXSLTransformsTimer(*this, &Document::applyPendingXSLTransformsTimerFired)
620
    , m_applyPendingXSLTransformsTimer(*this, &Document::applyPendingXSLTransformsTimerFired)
621
#endif
621
#endif
- a/Source/WebCore/dom/ExceptionCode.h +2 lines
Lines 61-66 enum ExceptionCode { a/Source/WebCore/dom/ExceptionCode.h_sec1
61
    // Simple exceptions (https://heycam.github.io/webidl/#idl-exceptions).
61
    // Simple exceptions (https://heycam.github.io/webidl/#idl-exceptions).
62
    RangeError,
62
    RangeError,
63
    TypeError,
63
    TypeError,
64
    JSSyntaxError, // Different from DOM SYNTAX_ERR.
64
65
65
    // Non-standard error.
66
    // Non-standard error.
66
    StackOverflowError,
67
    StackOverflowError,
Lines 111-116 template<> struct EnumTraits<WebCore::ExceptionCode> { a/Source/WebCore/dom/ExceptionCode.h_sec2
111
    WebCore::ExceptionCode::NotAllowedError,
112
    WebCore::ExceptionCode::NotAllowedError,
112
    WebCore::ExceptionCode::RangeError,
113
    WebCore::ExceptionCode::RangeError,
113
    WebCore::ExceptionCode::TypeError,
114
    WebCore::ExceptionCode::TypeError,
115
    WebCore::ExceptionCode::JSSyntaxError,
114
    WebCore::ExceptionCode::StackOverflowError,
116
    WebCore::ExceptionCode::StackOverflowError,
115
    WebCore::ExceptionCode::ExistingExceptionError
117
    WebCore::ExceptionCode::ExistingExceptionError
116
    >;
118
    >;
- a/Source/WebCore/dom/LoadableModuleScript.cpp -12 lines
Lines 88-103 void LoadableModuleScript::execute(ScriptElement& scriptElement) a/Source/WebCore/dom/LoadableModuleScript.cpp_sec1
88
    scriptElement.executeModuleScript(*this);
88
    scriptElement.executeModuleScript(*this);
89
}
89
}
90
90
91
void LoadableModuleScript::load(Document& document, const URL& rootURL)
92
{
93
    if (auto* frame = document.frame())
94
        frame->script().loadModuleScript(*this, rootURL.string(), m_parameters.copyRef());
95
}
96
97
void LoadableModuleScript::load(Document& document, const ScriptSourceCode& sourceCode)
98
{
99
    if (auto* frame = document.frame())
100
        frame->script().loadModuleScript(*this, sourceCode);
101
}
102
103
}
91
}
- a/Source/WebCore/dom/LoadableModuleScript.h -3 / +2 lines
Lines 50-64 class LoadableModuleScript final : public LoadableScript { a/Source/WebCore/dom/LoadableModuleScript.h_sec1
50
50
51
    void setError(Error&&);
51
    void setError(Error&&);
52
52
53
    void load(Document&, const URL& rootURL);
54
    void load(Document&, const ScriptSourceCode&);
55
56
    void notifyLoadCompleted(UniquedStringImpl&);
53
    void notifyLoadCompleted(UniquedStringImpl&);
57
    void notifyLoadFailed(LoadableScript::Error&&);
54
    void notifyLoadFailed(LoadableScript::Error&&);
58
    void notifyLoadWasCanceled();
55
    void notifyLoadWasCanceled();
59
56
60
    UniquedStringImpl* moduleKey() const { return m_moduleKey.get(); }
57
    UniquedStringImpl* moduleKey() const { return m_moduleKey.get(); }
61
58
59
    ModuleFetchParameters& parameters() { return m_parameters.get(); }
60
62
private:
61
private:
63
    LoadableModuleScript(const String& nonce, const String& integrity, ReferrerPolicy, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree);
62
    LoadableModuleScript(const String& nonce, const String& integrity, ReferrerPolicy, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree);
64
63
- a/Source/WebCore/dom/ScriptElement.cpp -2 / +7 lines
Lines 42-47 a/Source/WebCore/dom/ScriptElement.cpp_sec1
42
#include "LoadableClassicScript.h"
42
#include "LoadableClassicScript.h"
43
#include "LoadableModuleScript.h"
43
#include "LoadableModuleScript.h"
44
#include "MIMETypeRegistry.h"
44
#include "MIMETypeRegistry.h"
45
#include "ModuleFetchParameters.h"
45
#include "PendingScript.h"
46
#include "PendingScript.h"
46
#include "RuntimeApplicationChecks.h"
47
#include "RuntimeApplicationChecks.h"
47
#include "SVGScriptElement.h"
48
#include "SVGScriptElement.h"
Lines 351-358 bool ScriptElement::requestModuleScript(const TextPosition& scriptStartPosition) a/Source/WebCore/dom/ScriptElement.cpp_sec2
351
            scriptCharset(),
352
            scriptCharset(),
352
            m_element.localName(),
353
            m_element.localName(),
353
            m_element.isInUserAgentShadowTree());
354
            m_element.isInUserAgentShadowTree());
354
        script->load(m_element.document(), moduleScriptRootURL);
355
        m_loadableScript = WTFMove(script);
355
        m_loadableScript = WTFMove(script);
356
        if (auto* frame = m_element.document().frame()) {
357
            auto& script = downcast<LoadableModuleScript>(*m_loadableScript.get());
358
            frame->script().loadModuleScript(script, moduleScriptRootURL.string(), makeRef(script.parameters()));
359
        }
356
        return true;
360
        return true;
357
    }
361
    }
358
362
Lines 367-374 bool ScriptElement::requestModuleScript(const TextPosition& scriptStartPosition) a/Source/WebCore/dom/ScriptElement.cpp_sec3
367
    if (!contentSecurityPolicy.allowInlineScript(m_element.document().url().string(), m_startLineNumber, sourceCode.source().toStringWithoutCopying(), hasKnownNonce))
371
    if (!contentSecurityPolicy.allowInlineScript(m_element.document().url().string(), m_startLineNumber, sourceCode.source().toStringWithoutCopying(), hasKnownNonce))
368
        return false;
372
        return false;
369
373
370
    script->load(m_element.document(), sourceCode);
371
    m_loadableScript = WTFMove(script);
374
    m_loadableScript = WTFMove(script);
375
    if (auto* frame = m_element.document().frame())
376
        frame->script().loadModuleScript(downcast<LoadableModuleScript>(*m_loadableScript.get()), sourceCode);
372
    return true;
377
    return true;
373
}
378
}
374
379
- a/Source/WebCore/loader/ThreadableLoader.cpp -2 / +2 lines
Lines 101-110 ThreadableLoaderOptions ThreadableLoaderOptions::isolatedCopy() const a/Source/WebCore/loader/ThreadableLoader.cpp_sec1
101
}
101
}
102
102
103
103
104
RefPtr<ThreadableLoader> ThreadableLoader::create(ScriptExecutionContext& context, ThreadableLoaderClient& client, ResourceRequest&& request, const ThreadableLoaderOptions& options, String&& referrer)
104
RefPtr<ThreadableLoader> ThreadableLoader::create(ScriptExecutionContext& context, ThreadableLoaderClient& client, ResourceRequest&& request, const ThreadableLoaderOptions& options, String&& referrer, String&& taskMode)
105
{
105
{
106
    if (is<WorkerGlobalScope>(context) || (is<WorkletGlobalScope>(context) && downcast<WorkletGlobalScope>(context).workerOrWorkletThread()))
106
    if (is<WorkerGlobalScope>(context) || (is<WorkletGlobalScope>(context) && downcast<WorkletGlobalScope>(context).workerOrWorkletThread()))
107
        return WorkerThreadableLoader::create(static_cast<WorkerOrWorkletGlobalScope&>(context), client, WorkerRunLoop::defaultMode(), WTFMove(request), options, WTFMove(referrer));
107
        return WorkerThreadableLoader::create(static_cast<WorkerOrWorkletGlobalScope&>(context), client, WTFMove(taskMode), WTFMove(request), options, WTFMove(referrer));
108
108
109
    Document* document = nullptr;
109
    Document* document = nullptr;
110
    if (is<WorkletGlobalScope>(context))
110
    if (is<WorkletGlobalScope>(context))
- a/Source/WebCore/loader/ThreadableLoader.h -1 / +1 lines
Lines 74-80 namespace WebCore { a/Source/WebCore/loader/ThreadableLoader.h_sec1
74
        WTF_MAKE_NONCOPYABLE(ThreadableLoader);
74
        WTF_MAKE_NONCOPYABLE(ThreadableLoader);
75
    public:
75
    public:
76
        static void loadResourceSynchronously(ScriptExecutionContext&, ResourceRequest&&, ThreadableLoaderClient&, const ThreadableLoaderOptions&);
76
        static void loadResourceSynchronously(ScriptExecutionContext&, ResourceRequest&&, ThreadableLoaderClient&, const ThreadableLoaderOptions&);
77
        static RefPtr<ThreadableLoader> create(ScriptExecutionContext&, ThreadableLoaderClient&, ResourceRequest&&, const ThreadableLoaderOptions&, String&& referrer = String());
77
        static RefPtr<ThreadableLoader> create(ScriptExecutionContext&, ThreadableLoaderClient&, ResourceRequest&&, const ThreadableLoaderOptions&, String&& referrer = String(), String&& taskMode = { });
78
78
79
        virtual void computeIsDone() = 0;
79
        virtual void computeIsDone() = 0;
80
        virtual void cancel() = 0;
80
        virtual void cancel() = 0;
- a/Source/WebCore/workers/Worker.cpp -2 / +15 lines
Lines 74-79 inline Worker::Worker(ScriptExecutionContext& context, JSC::RuntimeFlags runtime a/Source/WebCore/workers/Worker.cpp_sec1
74
    , m_identifier("worker:" + Inspector::IdentifiersFactory::createIdentifier())
74
    , m_identifier("worker:" + Inspector::IdentifiersFactory::createIdentifier())
75
    , m_contextProxy(WorkerGlobalScopeProxy::create(*this))
75
    , m_contextProxy(WorkerGlobalScopeProxy::create(*this))
76
    , m_runtimeFlags(runtimeFlags)
76
    , m_runtimeFlags(runtimeFlags)
77
    , m_type(options.type)
78
    , m_credentials(options.credentials)
77
{
79
{
78
    static bool addedListener;
80
    static bool addedListener;
79
    if (!addedListener) {
81
    if (!addedListener) {
Lines 117-126 ExceptionOr<Ref<Worker>> Worker::create(ScriptExecutionContext& context, JSC::Ru a/Source/WebCore/workers/Worker.cpp_sec2
117
119
118
    FetchOptions fetchOptions;
120
    FetchOptions fetchOptions;
119
    fetchOptions.mode = FetchOptions::Mode::SameOrigin;
121
    fetchOptions.mode = FetchOptions::Mode::SameOrigin;
122
    if (worker->m_type == WorkerType::Module)
123
        fetchOptions.credentials = worker->m_credentials;
124
    else
125
        fetchOptions.credentials = FetchOptions::Credentials::SameOrigin;
120
    fetchOptions.cache = FetchOptions::Cache::Default;
126
    fetchOptions.cache = FetchOptions::Cache::Default;
121
    fetchOptions.redirect = FetchOptions::Redirect::Follow;
127
    fetchOptions.redirect = FetchOptions::Redirect::Follow;
122
    fetchOptions.destination = FetchOptions::Destination::Worker;
128
    fetchOptions.destination = FetchOptions::Destination::Worker;
123
    worker->m_scriptLoader->loadAsynchronously(context, WTFMove(request), WTFMove(fetchOptions), contentSecurityPolicyEnforcement, ServiceWorkersMode::All, worker);
129
    worker->m_scriptLoader->loadAsynchronously(context, WTFMove(request), WTFMove(fetchOptions), contentSecurityPolicyEnforcement, ServiceWorkersMode::All, worker.get(), WorkerRunLoop::defaultMode());
130
124
    return worker;
131
    return worker;
125
}
132
}
126
133
Lines 219-225 void Worker::notifyFinished() a/Source/WebCore/workers/Worker.cpp_sec3
219
    ReferrerPolicy referrerPolicy = ReferrerPolicy::EmptyString;
226
    ReferrerPolicy referrerPolicy = ReferrerPolicy::EmptyString;
220
    if (auto policy = parseReferrerPolicy(m_scriptLoader->referrerPolicy(), ReferrerPolicySource::HTTPHeader))
227
    if (auto policy = parseReferrerPolicy(m_scriptLoader->referrerPolicy(), ReferrerPolicySource::HTTPHeader))
221
        referrerPolicy = *policy;
228
        referrerPolicy = *policy;
222
    m_contextProxy.startWorkerGlobalScope(m_scriptLoader->url(), m_name, context->userAgent(m_scriptLoader->url()), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_workerCreationTime, referrerPolicy, m_runtimeFlags);
229
230
    URL responseURL = m_scriptLoader->responseURL();
231
    if (!m_scriptLoader->isRedirected() && m_scriptLoader->responseSource() != ResourceResponse::Source::ServiceWorker) {
232
        if (m_scriptLoader->url().hasFragmentIdentifier())
233
            responseURL.setFragmentIdentifier(m_scriptLoader->url().fragmentIdentifier());
234
    }
235
    m_contextProxy.startWorkerGlobalScope(responseURL, m_name, context->userAgent(responseURL), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_workerCreationTime, referrerPolicy, m_type, m_credentials, m_runtimeFlags);
223
    InspectorInstrumentation::scriptImported(*context, m_scriptLoader->identifier(), m_scriptLoader->script());
236
    InspectorInstrumentation::scriptImported(*context, m_scriptLoader->identifier(), m_scriptLoader->script());
224
}
237
}
225
238
- a/Source/WebCore/workers/Worker.h +8 lines
Lines 29-37 a/Source/WebCore/workers/Worker.h_sec1
29
#include "ActiveDOMObject.h"
29
#include "ActiveDOMObject.h"
30
#include "ContentSecurityPolicyResponseHeaders.h"
30
#include "ContentSecurityPolicyResponseHeaders.h"
31
#include "EventTarget.h"
31
#include "EventTarget.h"
32
#include "FetchRequestCredentials.h"
32
#include "MessagePort.h"
33
#include "MessagePort.h"
33
#include "PostMessageOptions.h"
34
#include "PostMessageOptions.h"
34
#include "WorkerScriptLoaderClient.h"
35
#include "WorkerScriptLoaderClient.h"
36
#include "WorkerType.h"
35
#include <JavaScriptCore/RuntimeFlags.h>
37
#include <JavaScriptCore/RuntimeFlags.h>
36
#include <wtf/MonotonicTime.h>
38
#include <wtf/MonotonicTime.h>
37
#include <wtf/Optional.h>
39
#include <wtf/Optional.h>
Lines 55-60 class Worker final : public AbstractWorker, public ActiveDOMObject, private Work a/Source/WebCore/workers/Worker.h_sec2
55
    WTF_MAKE_ISO_ALLOCATED(Worker);
57
    WTF_MAKE_ISO_ALLOCATED(Worker);
56
public:
58
public:
57
    struct Options {
59
    struct Options {
60
        WorkerType type;
61
        FetchRequestCredentials credentials;
58
        String name;
62
        String name;
59
    };
63
    };
60
    static ExceptionOr<Ref<Worker>> create(ScriptExecutionContext&, JSC::RuntimeFlags, const String& url, const Options&);
64
    static ExceptionOr<Ref<Worker>> create(ScriptExecutionContext&, JSC::RuntimeFlags, const String& url, const Options&);
Lines 79-84 class Worker final : public AbstractWorker, public ActiveDOMObject, private Work a/Source/WebCore/workers/Worker.h_sec3
79
    void postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&&);
83
    void postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&&);
80
#endif
84
#endif
81
85
86
    WorkerType type() const { return m_type; }
87
82
private:
88
private:
83
    explicit Worker(ScriptExecutionContext&, JSC::RuntimeFlags, const Options&);
89
    explicit Worker(ScriptExecutionContext&, JSC::RuntimeFlags, const Options&);
84
90
Lines 112-117 class Worker final : public AbstractWorker, public ActiveDOMObject, private Work a/Source/WebCore/workers/Worker.h_sec4
112
#if ENABLE(WEB_RTC)
118
#if ENABLE(WEB_RTC)
113
    HashSet<String> m_transformers;
119
    HashSet<String> m_transformers;
114
#endif
120
#endif
121
    WorkerType m_type { WorkerType::Classic };
122
    FetchRequestCredentials m_credentials { FetchRequestCredentials::SameOrigin };
115
};
123
};
116
124
117
} // namespace WebCore
125
} // namespace WebCore
- a/Source/WebCore/workers/Worker.idl +2 lines
Lines 38-43 a/Source/WebCore/workers/Worker.idl_sec1
38
};
38
};
39
39
40
dictionary WorkerOptions {
40
dictionary WorkerOptions {
41
    WorkerType type = "classic";
42
    FetchRequestCredentials credentials = "same-origin"; // credentials is only used if type is "module"
41
    DOMString name = "";
43
    DOMString name = "";
42
};
44
};
43
45
- a/Source/WebCore/workers/WorkerGlobalScope.cpp +7 lines
Lines 74-79 WorkerGlobalScope::WorkerGlobalScope(WorkerThreadType type, const WorkerParamete a/Source/WebCore/workers/WorkerGlobalScope.cpp_sec1
74
    , m_performance(Performance::create(this, params.timeOrigin))
74
    , m_performance(Performance::create(this, params.timeOrigin))
75
    , m_referrerPolicy(params.referrerPolicy)
75
    , m_referrerPolicy(params.referrerPolicy)
76
    , m_settingsValues(params.settingsValues)
76
    , m_settingsValues(params.settingsValues)
77
    , m_workerType(params.workerType)
78
    , m_credentials(params.credentials)
77
{
79
{
78
#if !ENABLE(INDEXED_DATABASE)
80
#if !ENABLE(INDEXED_DATABASE)
79
    UNUSED_PARAM(connectionProxy);
81
    UNUSED_PARAM(connectionProxy);
Lines 274-279 ExceptionOr<void> WorkerGlobalScope::importScripts(const Vector<String>& urls) a/Source/WebCore/workers/WorkerGlobalScope.cpp_sec2
274
{
276
{
275
    ASSERT(contentSecurityPolicy());
277
    ASSERT(contentSecurityPolicy());
276
278
279
    // https://html.spec.whatwg.org/multipage/workers.html#importing-scripts-and-libraries
280
    // 1. If worker global scope's type is "module", throw a TypeError exception.
281
    if (m_workerType == WorkerType::Module)
282
        return Exception { TypeError, "importScripts cannot be used if woerker type is \"module\""_s };
283
277
    Vector<URL> completedURLs;
284
    Vector<URL> completedURLs;
278
    completedURLs.reserveInitialCapacity(urls.size());
285
    completedURLs.reserveInitialCapacity(urls.size());
279
    for (auto& entry : urls) {
286
    for (auto& entry : urls) {
- a/Source/WebCore/workers/WorkerGlobalScope.h -2 / +4 lines
Lines 123-128 class WorkerGlobalScope : public Supplementable<WorkerGlobalScope>, public Base6 a/Source/WebCore/workers/WorkerGlobalScope.h_sec1
123
123
124
    const Settings::Values& settingsValues() const final { return m_settingsValues; }
124
    const Settings::Values& settingsValues() const final { return m_settingsValues; }
125
125
126
    FetchOptions::Credentials credentials() const { return m_credentials; }
127
126
protected:
128
protected:
127
    WorkerGlobalScope(WorkerThreadType, const WorkerParameters&, Ref<SecurityOrigin>&&, WorkerThread&, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);
129
    WorkerGlobalScope(WorkerThreadType, const WorkerParameters&, Ref<SecurityOrigin>&&, WorkerThread&, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);
128
130
Lines 163-170 class WorkerGlobalScope : public Supplementable<WorkerGlobalScope>, public Base6 a/Source/WebCore/workers/WorkerGlobalScope.h_sec2
163
    mutable RefPtr<WorkerLocation> m_location;
165
    mutable RefPtr<WorkerLocation> m_location;
164
    mutable RefPtr<WorkerNavigator> m_navigator;
166
    mutable RefPtr<WorkerNavigator> m_navigator;
165
167
166
    std::unique_ptr<WorkerOrWorkletScriptController> m_script;
167
168
    bool m_isOnline;
168
    bool m_isOnline;
169
    bool m_shouldBypassMainWorldContentSecurityPolicy;
169
    bool m_shouldBypassMainWorldContentSecurityPolicy;
170
170
Lines 187-192 class WorkerGlobalScope : public Supplementable<WorkerGlobalScope>, public Base6 a/Source/WebCore/workers/WorkerGlobalScope.h_sec3
187
    std::unique_ptr<CSSValuePool> m_cssValuePool;
187
    std::unique_ptr<CSSValuePool> m_cssValuePool;
188
    ReferrerPolicy m_referrerPolicy;
188
    ReferrerPolicy m_referrerPolicy;
189
    Settings::Values m_settingsValues;
189
    Settings::Values m_settingsValues;
190
    WorkerType m_workerType;
191
    FetchOptions::Credentials m_credentials;
190
};
192
};
191
193
192
} // namespace WebCore
194
} // namespace WebCore
- a/Source/WebCore/workers/WorkerGlobalScopeProxy.h -1 / +1 lines
Lines 48-54 class WorkerGlobalScopeProxy { a/Source/WebCore/workers/WorkerGlobalScopeProxy.h_sec1
48
public:
48
public:
49
    static WorkerGlobalScopeProxy& create(Worker&);
49
    static WorkerGlobalScopeProxy& create(Worker&);
50
50
51
    virtual void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, ReferrerPolicy, JSC::RuntimeFlags) = 0;
51
    virtual void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, ReferrerPolicy, WorkerType, FetchRequestCredentials, JSC::RuntimeFlags) = 0;
52
    virtual void terminateWorkerGlobalScope() = 0;
52
    virtual void terminateWorkerGlobalScope() = 0;
53
    virtual void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) = 0;
53
    virtual void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) = 0;
54
    virtual void postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&&) = 0;
54
    virtual void postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&&) = 0;
- a/Source/WebCore/workers/WorkerMessagingProxy.cpp -2 / +2 lines
Lines 73-79 WorkerMessagingProxy::~WorkerMessagingProxy() a/Source/WebCore/workers/WorkerMessagingProxy.cpp_sec1
73
        || (is<WorkerGlobalScope>(*m_scriptExecutionContext) && downcast<WorkerGlobalScope>(*m_scriptExecutionContext).thread().thread() == &Thread::current()));
73
        || (is<WorkerGlobalScope>(*m_scriptExecutionContext) && downcast<WorkerGlobalScope>(*m_scriptExecutionContext).thread().thread() == &Thread::current()));
74
}
74
}
75
75
76
void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, ReferrerPolicy referrerPolicy, JSC::RuntimeFlags runtimeFlags)
76
void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, ReferrerPolicy referrerPolicy, WorkerType workerType, FetchRequestCredentials credentials, JSC::RuntimeFlags runtimeFlags)
77
{
77
{
78
    // FIXME: This need to be revisited when we support nested worker one day
78
    // FIXME: This need to be revisited when we support nested worker one day
79
    ASSERT(m_scriptExecutionContext);
79
    ASSERT(m_scriptExecutionContext);
Lines 89-95 void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const St a/Source/WebCore/workers/WorkerMessagingProxy.cpp_sec2
89
89
90
    SocketProvider* socketProvider = document.socketProvider();
90
    SocketProvider* socketProvider = document.socketProvider();
91
91
92
    WorkerParameters params = { scriptURL, name, identifier, userAgent, isOnline, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, timeOrigin, referrerPolicy, document.settingsValues() };
92
    WorkerParameters params = { scriptURL, name, identifier, userAgent, isOnline, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, timeOrigin, referrerPolicy, workerType, credentials, document.settingsValues() };
93
    auto thread = DedicatedWorkerThread::create(params, sourceCode, *this, *this, *this, startMode, document.topOrigin(), proxy, socketProvider, runtimeFlags);
93
    auto thread = DedicatedWorkerThread::create(params, sourceCode, *this, *this, *this, startMode, document.topOrigin(), proxy, socketProvider, runtimeFlags);
94
94
95
    workerThreadCreated(thread.get());
95
    workerThreadCreated(thread.get());
- a/Source/WebCore/workers/WorkerMessagingProxy.h -1 / +1 lines
Lines 50-56 class WorkerMessagingProxy final : public ThreadSafeRefCounted<WorkerMessagingPr a/Source/WebCore/workers/WorkerMessagingProxy.h_sec1
50
private:
50
private:
51
    // Implementations of WorkerGlobalScopeProxy.
51
    // Implementations of WorkerGlobalScopeProxy.
52
    // (Only use these functions in the worker object thread.)
52
    // (Only use these functions in the worker object thread.)
53
    void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, ReferrerPolicy, JSC::RuntimeFlags) final;
53
    void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, ReferrerPolicy, WorkerType, FetchRequestCredentials, JSC::RuntimeFlags) final;
54
    void terminateWorkerGlobalScope() final;
54
    void terminateWorkerGlobalScope() final;
55
    void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) final;
55
    void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) final;
56
    void postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&&) final;
56
    void postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&&) final;
- a/Source/WebCore/workers/WorkerOrWorkletGlobalScope.cpp +2 lines
Lines 26-31 a/Source/WebCore/workers/WorkerOrWorkletGlobalScope.cpp_sec1
26
#include "config.h"
26
#include "config.h"
27
#include "WorkerOrWorkletGlobalScope.h"
27
#include "WorkerOrWorkletGlobalScope.h"
28
28
29
#include "ScriptModuleLoader.h"
29
#include "WorkerEventLoop.h"
30
#include "WorkerEventLoop.h"
30
#include "WorkerInspectorController.h"
31
#include "WorkerInspectorController.h"
31
#include "WorkerOrWorkletScriptController.h"
32
#include "WorkerOrWorkletScriptController.h"
Lines 39-44 WTF_MAKE_ISO_ALLOCATED_IMPL(WorkerOrWorkletGlobalScope); a/Source/WebCore/workers/WorkerOrWorkletGlobalScope.cpp_sec2
39
40
40
WorkerOrWorkletGlobalScope::WorkerOrWorkletGlobalScope(WorkerThreadType type, Ref<JSC::VM>&& vm, WorkerOrWorkletThread* thread)
41
WorkerOrWorkletGlobalScope::WorkerOrWorkletGlobalScope(WorkerThreadType type, Ref<JSC::VM>&& vm, WorkerOrWorkletThread* thread)
41
    : m_script(makeUnique<WorkerOrWorkletScriptController>(type, WTFMove(vm), this))
42
    : m_script(makeUnique<WorkerOrWorkletScriptController>(type, WTFMove(vm), this))
43
    , m_moduleLoader(makeUnique<ScriptModuleLoader>(*this, ScriptModuleLoader::OwnerType::WorkerOrWorklet))
42
    , m_thread(thread)
44
    , m_thread(thread)
43
    , m_inspectorController(makeUnique<WorkerInspectorController>(*this))
45
    , m_inspectorController(makeUnique<WorkerInspectorController>(*this))
44
{
46
{
- a/Source/WebCore/workers/WorkerOrWorkletGlobalScope.h +4 lines
Lines 32-37 a/Source/WebCore/workers/WorkerOrWorkletGlobalScope.h_sec1
32
namespace WebCore {
32
namespace WebCore {
33
33
34
class EventLoopTaskGroup;
34
class EventLoopTaskGroup;
35
class ScriptModuleLoader;
35
class WorkerEventLoop;
36
class WorkerEventLoop;
36
class WorkerInspectorController;
37
class WorkerInspectorController;
37
class WorkerOrWorkletScriptController;
38
class WorkerOrWorkletScriptController;
Lines 54-59 class WorkerOrWorkletGlobalScope : public ScriptExecutionContext, public RefCoun a/Source/WebCore/workers/WorkerOrWorkletGlobalScope.h_sec2
54
55
55
    unsigned long createUniqueIdentifier() { return m_uniqueIdentifier++; }
56
    unsigned long createUniqueIdentifier() { return m_uniqueIdentifier++; }
56
57
58
    ScriptModuleLoader& moduleLoader() { return *m_moduleLoader; }
59
57
    // ScriptExecutionContext.
60
    // ScriptExecutionContext.
58
    EventLoopTaskGroup& eventLoop() final;
61
    EventLoopTaskGroup& eventLoop() final;
59
    bool isContextThread() const final;
62
    bool isContextThread() const final;
Lines 88-93 class WorkerOrWorkletGlobalScope : public ScriptExecutionContext, public RefCoun a/Source/WebCore/workers/WorkerOrWorkletGlobalScope.h_sec3
88
    void derefEventTarget() final { deref(); }
91
    void derefEventTarget() final { deref(); }
89
92
90
    std::unique_ptr<WorkerOrWorkletScriptController> m_script;
93
    std::unique_ptr<WorkerOrWorkletScriptController> m_script;
94
    std::unique_ptr<ScriptModuleLoader> m_moduleLoader;
91
    WorkerOrWorkletThread* m_thread;
95
    WorkerOrWorkletThread* m_thread;
92
    RefPtr<WorkerEventLoop> m_eventLoop;
96
    RefPtr<WorkerEventLoop> m_eventLoop;
93
    std::unique_ptr<EventLoopTaskGroup> m_defaultTaskGroup;
97
    std::unique_ptr<EventLoopTaskGroup> m_defaultTaskGroup;
- a/Source/WebCore/workers/WorkerOrWorkletScriptController.cpp +247 lines
Lines 35-49 a/Source/WebCore/workers/WorkerOrWorkletScriptController.cpp_sec1
35
#include "JSExecState.h"
35
#include "JSExecState.h"
36
#include "JSPaintWorkletGlobalScope.h"
36
#include "JSPaintWorkletGlobalScope.h"
37
#include "JSServiceWorkerGlobalScope.h"
37
#include "JSServiceWorkerGlobalScope.h"
38
#include "ModuleFetchFailureKind.h"
39
#include "ModuleFetchParameters.h"
38
#include "ScriptSourceCode.h"
40
#include "ScriptSourceCode.h"
39
#include "WebCoreJSClientData.h"
41
#include "WebCoreJSClientData.h"
40
#include "WorkerConsoleClient.h"
42
#include "WorkerConsoleClient.h"
43
#include "WorkerScriptFetcher.h"
41
#include <JavaScriptCore/Completion.h>
44
#include <JavaScriptCore/Completion.h>
42
#include <JavaScriptCore/DeferredWorkTimer.h>
45
#include <JavaScriptCore/DeferredWorkTimer.h>
43
#include <JavaScriptCore/Exception.h>
46
#include <JavaScriptCore/Exception.h>
44
#include <JavaScriptCore/ExceptionHelpers.h>
47
#include <JavaScriptCore/ExceptionHelpers.h>
45
#include <JavaScriptCore/GCActivityCallback.h>
48
#include <JavaScriptCore/GCActivityCallback.h>
49
#include <JavaScriptCore/JSInternalPromise.h>
46
#include <JavaScriptCore/JSLock.h>
50
#include <JavaScriptCore/JSLock.h>
51
#include <JavaScriptCore/JSModuleRecord.h>
52
#include <JavaScriptCore/JSNativeStdFunction.h>
53
#include <JavaScriptCore/JSScriptFetchParameters.h>
54
#include <JavaScriptCore/JSScriptFetcher.h>
47
#include <JavaScriptCore/StrongInlines.h>
55
#include <JavaScriptCore/StrongInlines.h>
48
56
49
namespace WebCore {
57
namespace WebCore {
Lines 228-233 void WorkerOrWorkletScriptController::evaluate(const ScriptSourceCode& sourceCod a/Source/WebCore/workers/WorkerOrWorkletScriptController.cpp_sec2
228
    }
236
    }
229
}
237
}
230
238
239
static Identifier jsValueToModuleKey(JSGlobalObject* lexicalGlobalObject, JSValue value)
240
{
241
    if (value.isSymbol())
242
        return Identifier::fromUid(jsCast<Symbol*>(value)->privateName());
243
    ASSERT(value.isString());
244
    return asString(value)->toIdentifier(lexicalGlobalObject);
245
}
246
247
JSC::JSValue WorkerOrWorkletScriptController::evaluateModule(JSC::JSModuleRecord& moduleRecord)
248
{
249
    auto& globalObject = *m_globalScopeWrapper.get();
250
    VM& vm = globalObject.vm();
251
    JSLockHolder lock { vm };
252
    return moduleRecord.evaluate(&globalObject);
253
}
254
255
MessageQueueWaitResult WorkerOrWorkletScriptController::loadModuleSynchronously(WorkerScriptFetcher& scriptFetcher, const ScriptSourceCode& sourceCode)
256
{
257
    if (isExecutionForbidden())
258
        return MessageQueueTerminated;
259
260
    initScriptIfNeeded();
261
262
    auto& globalObject = *m_globalScopeWrapper.get();
263
    VM& vm = globalObject.vm();
264
    JSLockHolder lock { vm };
265
266
    auto protector = makeRef(scriptFetcher);
267
    {
268
        auto& promise = JSExecState::loadModule(globalObject, sourceCode.jsSourceCode(), JSC::JSScriptFetcher::create(vm, { &scriptFetcher }));
269
270
        auto& fulfillHandler = *JSNativeStdFunction::create(vm, &globalObject, 1, String(), [protector](JSGlobalObject* globalObject, CallFrame* callFrame) -> JSC::EncodedJSValue {
271
            VM& vm = globalObject->vm();
272
            JSLockHolder lock { vm };
273
            auto scope = DECLARE_THROW_SCOPE(vm);
274
            Identifier moduleKey = jsValueToModuleKey(globalObject, callFrame->argument(0));
275
            RETURN_IF_EXCEPTION(scope, { });
276
            protector->notifyLoadCompleted(*moduleKey.impl());
277
            return JSValue::encode(jsUndefined());
278
        });
279
280
        auto& rejectHandler = *JSNativeStdFunction::create(vm, &globalObject, 1, String(), [protector](JSGlobalObject* globalObject, CallFrame* callFrame) {
281
            VM& vm = globalObject->vm();
282
            JSLockHolder lock { vm };
283
            JSValue errorValue = callFrame->argument(0);
284
            if (errorValue.isObject()) {
285
                auto* object = JSC::asObject(errorValue);
286
                if (JSValue failureKindValue = object->getDirect(vm, static_cast<JSVMClientData&>(*vm.clientData).builtinNames().failureKindPrivateName())) {
287
                    // This is host propagated error in the module loader pipeline.
288
                    switch (static_cast<ModuleFetchFailureKind>(failureKindValue.asInt32())) {
289
                    case ModuleFetchFailureKind::WasErrored:
290
                        protector->notifyLoadFailed(LoadableScript::Error {
291
                            LoadableScript::ErrorType::CachedScript,
292
                            WTF::nullopt
293
                        });
294
                        break;
295
                    case ModuleFetchFailureKind::WasCanceled:
296
                        protector->notifyLoadWasCanceled();
297
                        break;
298
                    }
299
                    return JSValue::encode(jsUndefined());
300
                }
301
            }
302
303
            auto scope = DECLARE_CATCH_SCOPE(vm);
304
            protector->notifyLoadFailed(LoadableScript::Error {
305
                LoadableScript::ErrorType::CachedScript,
306
                LoadableScript::ConsoleMessage {
307
                    MessageSource::JS,
308
                    MessageLevel::Error,
309
                    retrieveErrorMessage(*globalObject, vm, errorValue, scope),
310
                }
311
            });
312
            return JSValue::encode(jsUndefined());
313
        });
314
315
        promise.then(&globalObject, &fulfillHandler, &rejectHandler);
316
    }
317
    m_globalScope->eventLoop().performMicrotaskCheckpoint();
318
319
    // Drive RunLoop until we get either of "Worker is terminated", "Loading is done", or "Loading is failed".
320
    WorkerRunLoop& runLoop = m_globalScope->workerOrWorkletThread()->runLoop();
321
322
    // We do not want to receive messages that are not related to asynchronous resource loading.
323
    // Otherwise, a worker discards some messages from the main thread here in a racy way.
324
    // For example, the main thread can postMessage just after creating a Worker. In that case, postMessage's
325
    // task is queued in WorkerRunLoop before start running module scripts. This task should not be discarded
326
    // in the following driving of the RunLoop which mainly attempt to collect initial load of module scripts.
327
    String taskMode = "loadModulesInWorkerOrWorkletMode"_s;
328
    MessageQueueWaitResult result = MessageQueueMessageReceived;
329
    while ((!protector->isLoaded() && !protector->wasCanceled()) && result != MessageQueueTerminated) {
330
        result = runLoop.runInMode(m_globalScope, taskMode);
331
        if (result != MessageQueueTerminated)
332
            m_globalScope->eventLoop().performMicrotaskCheckpoint();
333
    }
334
335
    return result;
336
}
337
338
void WorkerOrWorkletScriptController::linkAndEvaluateModule(WorkerScriptFetcher& scriptFetcher, const ScriptSourceCode& sourceCode, String* returnedExceptionMessage)
339
{
340
    if (isExecutionForbidden())
341
        return;
342
343
    initScriptIfNeeded();
344
345
    auto& globalObject = *m_globalScopeWrapper.get();
346
    VM& vm = globalObject.vm();
347
    JSLockHolder lock { vm };
348
349
    NakedPtr<JSC::Exception> returnedException;
350
    JSExecState::linkAndEvaluateModule(globalObject, Identifier::fromUid(vm, scriptFetcher.moduleKey()), jsUndefined(), returnedException);
351
    if ((returnedException && isTerminatedExecutionException(vm, returnedException)) || isTerminatingExecution()) {
352
        forbidExecution();
353
        return;
354
    }
355
356
    if (returnedException) {
357
        if (m_globalScope->canIncludeErrorDetails(sourceCode.cachedScript(), sourceCode.url().string())) {
358
            // FIXME: It's not great that this can run arbitrary code to string-ify the value of the exception.
359
            // Do we need to do anything to handle that properly, if it, say, raises another exception?
360
            if (returnedExceptionMessage)
361
                *returnedExceptionMessage = returnedException->value().toWTFString(&globalObject);
362
        } else {
363
            // Overwrite the detailed error with a generic error.
364
            String genericErrorMessage { "Script error."_s };
365
            if (returnedExceptionMessage)
366
                *returnedExceptionMessage = genericErrorMessage;
367
        }
368
    }
369
}
370
371
void WorkerOrWorkletScriptController::loadAndEvaluateModule(const URL& moduleURL, FetchOptions::Credentials credentials, CompletionHandler<void(Optional<Exception>&&)>&& completionHandler)
372
{
373
    if (isExecutionForbidden()) {
374
        completionHandler(Exception { NotAllowedError });
375
        return;
376
    }
377
378
    initScriptIfNeeded();
379
380
    auto& globalObject = *m_globalScopeWrapper.get();
381
    VM& vm = globalObject.vm();
382
    JSLockHolder lock { vm };
383
384
    auto scriptFetcher = WorkerScriptFetcher::create(credentials);
385
    {
386
        auto& promise = JSExecState::loadModule(globalObject, moduleURL.string(), jsUndefined(), JSC::JSScriptFetcher::create(vm, { scriptFetcher.ptr() }));
387
388
        auto task = createSharedTask<void(Optional<Exception>&&)>([completionHandler = WTFMove(completionHandler)](Optional<Exception>&& exception) mutable {
389
            completionHandler(WTFMove(exception));
390
        });
391
392
        auto& fulfillHandler = *JSNativeStdFunction::create(vm, &globalObject, 1, String(), [task, scriptFetcher](JSGlobalObject* globalObject, CallFrame* callFrame) -> JSC::EncodedJSValue {
393
            // task->run(WTF::nullopt);
394
            VM& vm = globalObject->vm();
395
            JSLockHolder lock { vm };
396
            auto scope = DECLARE_THROW_SCOPE(vm);
397
398
            Identifier moduleKey = jsValueToModuleKey(globalObject, callFrame->argument(0));
399
            RETURN_IF_EXCEPTION(scope, { });
400
            scriptFetcher->notifyLoadCompleted(*moduleKey.impl());
401
402
            auto* context = downcast<WorkerOrWorkletGlobalScope>(jsCast<JSDOMGlobalObject*>(globalObject)->scriptExecutionContext());
403
            if (!context || !context->script()) {
404
                task->run(WTF::nullopt);
405
                return JSValue::encode(jsUndefined());
406
            }
407
408
            NakedPtr<JSC::Exception> returnedException;
409
            JSExecState::linkAndEvaluateModule(*globalObject, moduleKey, jsUndefined(), returnedException);
410
            if ((returnedException && isTerminatedExecutionException(vm, returnedException)) || context->script()->isTerminatingExecution()) {
411
                if (context->script())
412
                    context->script()->forbidExecution();
413
                task->run(WTF::nullopt);
414
                return JSValue::encode(jsUndefined());
415
            }
416
417
            if (returnedException) {
418
                String message;
419
                if (context->canIncludeErrorDetails(nullptr, moduleKey.string())) {
420
                    // FIXME: It's not great that this can run arbitrary code to string-ify the value of the exception.
421
                    // Do we need to do anything to handle that properly, if it, say, raises another exception?
422
                    message = returnedException->value().toWTFString(globalObject);
423
                } else {
424
                    // Overwrite the detailed error with a generic error.
425
                    message = "Script error."_s;
426
                }
427
                context->reportException(message, { }, { }, { }, { }, { });
428
            }
429
430
            task->run(WTF::nullopt);
431
            return JSValue::encode(jsUndefined());
432
        });
433
434
        auto& rejectHandler = *JSNativeStdFunction::create(vm, &globalObject, 1, String(), [task](JSGlobalObject* globalObject, CallFrame* callFrame) {
435
            VM& vm = globalObject->vm();
436
            JSLockHolder lock { vm };
437
            JSValue errorValue = callFrame->argument(0);
438
            if (errorValue.isObject()) {
439
                auto* object = JSC::asObject(errorValue);
440
                if (object->getDirect(vm, static_cast<JSVMClientData&>(*vm.clientData).builtinNames().failureKindPrivateName())) {
441
                    auto catchScope = DECLARE_CATCH_SCOPE(vm);
442
                    String message = retrieveErrorMessageWithoutName(*globalObject, vm, object, catchScope);
443
                    task->run(Exception { AbortError, message });
444
                    return JSValue::encode(jsUndefined());
445
                }
446
                if (object->inherits<ErrorInstance>(vm)) {
447
                    auto* error = jsCast<ErrorInstance*>(object);
448
                    switch (error->errorType()) {
449
                    case ErrorType::TypeError: {
450
                        auto catchScope = DECLARE_CATCH_SCOPE(vm);
451
                        String message = retrieveErrorMessageWithoutName(*globalObject, vm, error, catchScope);
452
                        task->run(Exception { TypeError, message });
453
                        return JSValue::encode(jsUndefined());
454
                    }
455
                    case ErrorType::SyntaxError: {
456
                        auto catchScope = DECLARE_CATCH_SCOPE(vm);
457
                        String message = retrieveErrorMessageWithoutName(*globalObject, vm, error, catchScope);
458
                        task->run(Exception { JSSyntaxError, message });
459
                        return JSValue::encode(jsUndefined());
460
                    }
461
                    default:
462
                        break;
463
                    }
464
                }
465
            }
466
467
            auto catchScope = DECLARE_CATCH_SCOPE(vm);
468
            String message = retrieveErrorMessageWithoutName(*globalObject, vm, errorValue, catchScope);
469
            task->run(Exception { AbortError, message });
470
            return JSValue::encode(jsUndefined());
471
        });
472
473
        promise.then(&globalObject, &fulfillHandler, &rejectHandler);
474
    }
475
    m_globalScope->eventLoop().performMicrotaskCheckpoint();
476
}
477
231
template<typename JSGlobalScopePrototype, typename JSGlobalScope, typename GlobalScope>
478
template<typename JSGlobalScopePrototype, typename JSGlobalScope, typename GlobalScope>
232
void WorkerOrWorkletScriptController::initScriptWithSubclass()
479
void WorkerOrWorkletScriptController::initScriptWithSubclass()
233
{
480
{
- a/Source/WebCore/workers/WorkerOrWorkletScriptController.h +10 lines
Lines 31-36 a/Source/WebCore/workers/WorkerOrWorkletScriptController.h_sec1
31
#include <JavaScriptCore/JSRunLoopTimer.h>
31
#include <JavaScriptCore/JSRunLoopTimer.h>
32
#include <wtf/Forward.h>
32
#include <wtf/Forward.h>
33
#include <wtf/Lock.h>
33
#include <wtf/Lock.h>
34
#include <wtf/MessageQueue.h>
34
#include <wtf/NakedPtr.h>
35
#include <wtf/NakedPtr.h>
35
36
36
namespace JSC {
37
namespace JSC {
Lines 44-52 class JSGlobalObject; a/Source/WebCore/workers/WorkerOrWorkletScriptController.h_sec2
44
namespace WebCore {
45
namespace WebCore {
45
46
46
class JSDOMGlobalObject;
47
class JSDOMGlobalObject;
48
class LoadableModuleScript;
47
class ScriptSourceCode;
49
class ScriptSourceCode;
48
class WorkerConsoleClient;
50
class WorkerConsoleClient;
49
class WorkerOrWorkletGlobalScope;
51
class WorkerOrWorkletGlobalScope;
52
class WorkerScriptFetcher;
50
53
51
class WorkerOrWorkletScriptController {
54
class WorkerOrWorkletScriptController {
52
    WTF_MAKE_NONCOPYABLE(WorkerOrWorkletScriptController);
55
    WTF_MAKE_NONCOPYABLE(WorkerOrWorkletScriptController);
Lines 94-99 class WorkerOrWorkletScriptController { a/Source/WebCore/workers/WorkerOrWorkletScriptController.h_sec3
94
    void evaluate(const ScriptSourceCode&, String* returnedExceptionMessage = nullptr);
97
    void evaluate(const ScriptSourceCode&, String* returnedExceptionMessage = nullptr);
95
    void evaluate(const ScriptSourceCode&, NakedPtr<JSC::Exception>& returnedException, String* returnedExceptionMessage = nullptr);
98
    void evaluate(const ScriptSourceCode&, NakedPtr<JSC::Exception>& returnedException, String* returnedExceptionMessage = nullptr);
96
99
100
    JSC::JSValue evaluateModule(JSC::JSModuleRecord&);
101
102
    void linkAndEvaluateModule(WorkerScriptFetcher&, const ScriptSourceCode&, String* returnedExceptionMessage = nullptr);
103
    MessageQueueWaitResult loadModuleSynchronously(WorkerScriptFetcher&, const ScriptSourceCode&);
104
105
    void loadAndEvaluateModule(const URL& moduleURL, FetchOptions::Credentials, CompletionHandler<void(Optional<Exception>&&)>&&);
106
97
protected:
107
protected:
98
    WorkerOrWorkletGlobalScope* globalScope() const { return m_globalScope; }
108
    WorkerOrWorkletGlobalScope* globalScope() const { return m_globalScope; }
99
109
- a/Source/WebCore/workers/WorkerScriptLoader.cpp -4 / +4 lines
Lines 107-113 Optional<Exception> WorkerScriptLoader::loadSynchronously(ScriptExecutionContext a/Source/WebCore/workers/WorkerScriptLoader.cpp_sec1
107
    return WTF::nullopt;
107
    return WTF::nullopt;
108
}
108
}
109
109
110
void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext& scriptExecutionContext, ResourceRequest&& scriptRequest, FetchOptions&& fetchOptions, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, ServiceWorkersMode serviceWorkerMode, WorkerScriptLoaderClient& client)
110
void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext& scriptExecutionContext, ResourceRequest&& scriptRequest, FetchOptions&& fetchOptions, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, ServiceWorkersMode serviceWorkerMode, WorkerScriptLoaderClient& client, String&& taskMode)
111
{
111
{
112
    m_client = &client;
112
    m_client = &client;
113
    m_url = scriptRequest.url();
113
    m_url = scriptRequest.url();
Lines 123-130 void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext& scriptExecut a/Source/WebCore/workers/WorkerScriptLoader.cpp_sec2
123
    ASSERT(fetchOptions.mode == FetchOptions::Mode::SameOrigin || (fetchOptions.destination != FetchOptions::Destination::Serviceworker && fetchOptions.destination != FetchOptions::Destination::Worker));
123
    ASSERT(fetchOptions.mode == FetchOptions::Mode::SameOrigin || (fetchOptions.destination != FetchOptions::Destination::Serviceworker && fetchOptions.destination != FetchOptions::Destination::Worker));
124
124
125
    ThreadableLoaderOptions options { WTFMove(fetchOptions) };
125
    ThreadableLoaderOptions options { WTFMove(fetchOptions) };
126
    // FIXME: We should add an option to set credential mode.
127
    options.credentials = FetchOptions::Credentials::SameOrigin;
128
    options.sendLoadCallbacks = SendCallbackPolicy::SendCallbacks;
126
    options.sendLoadCallbacks = SendCallbackPolicy::SendCallbacks;
129
    options.contentSecurityPolicyEnforcement = contentSecurityPolicyEnforcement;
127
    options.contentSecurityPolicyEnforcement = contentSecurityPolicyEnforcement;
130
    if (fetchOptions.destination == FetchOptions::Destination::Serviceworker)
128
    if (fetchOptions.destination == FetchOptions::Destination::Serviceworker)
Lines 143-149 void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext& scriptExecut a/Source/WebCore/workers/WorkerScriptLoader.cpp_sec3
143
141
144
    // During create, callbacks may happen which remove the last reference to this object.
142
    // During create, callbacks may happen which remove the last reference to this object.
145
    Ref<WorkerScriptLoader> protectedThis(*this);
143
    Ref<WorkerScriptLoader> protectedThis(*this);
146
    m_threadableLoader = ThreadableLoader::create(scriptExecutionContext, *this, WTFMove(*request), options);
144
    m_threadableLoader = ThreadableLoader::create(scriptExecutionContext, *this, WTFMove(*request), options, { }, WTFMove(taskMode));
147
}
145
}
148
146
149
const URL& WorkerScriptLoader::responseURL() const
147
const URL& WorkerScriptLoader::responseURL() const
Lines 190-195 void WorkerScriptLoader::didReceiveResponse(unsigned long identifier, const Reso a/Source/WebCore/workers/WorkerScriptLoader.cpp_sec4
190
    m_certificateInfo = response.certificateInfo() ? *response.certificateInfo() : CertificateInfo();
188
    m_certificateInfo = response.certificateInfo() ? *response.certificateInfo() : CertificateInfo();
191
    m_responseMIMEType = response.mimeType();
189
    m_responseMIMEType = response.mimeType();
192
    m_responseEncoding = response.textEncodingName();
190
    m_responseEncoding = response.textEncodingName();
191
    m_responseSource = response.source();
192
    m_isRedirected = response.isRedirected();
193
    m_contentSecurityPolicy = ContentSecurityPolicyResponseHeaders { response };
193
    m_contentSecurityPolicy = ContentSecurityPolicyResponseHeaders { response };
194
    m_referrerPolicy = response.httpHeaderField(HTTPHeaderName::ReferrerPolicy);
194
    m_referrerPolicy = response.httpHeaderField(HTTPHeaderName::ReferrerPolicy);
195
    if (m_client)
195
    if (m_client)
- a/Source/WebCore/workers/WorkerScriptLoader.h -2 / +6 lines
Lines 31-36 a/Source/WebCore/workers/WorkerScriptLoader.h_sec1
31
#include "FetchOptions.h"
31
#include "FetchOptions.h"
32
#include "ResourceError.h"
32
#include "ResourceError.h"
33
#include "ResourceRequest.h"
33
#include "ResourceRequest.h"
34
#include "ResourceResponse.h"
34
#include "ThreadableLoader.h"
35
#include "ThreadableLoader.h"
35
#include "ThreadableLoaderClient.h"
36
#include "ThreadableLoaderClient.h"
36
#include <memory>
37
#include <memory>
Lines 43-49 a/Source/WebCore/workers/WorkerScriptLoader.h_sec2
43
namespace WebCore {
44
namespace WebCore {
44
45
45
class Exception;
46
class Exception;
46
class ResourceResponse;
47
class ScriptExecutionContext;
47
class ScriptExecutionContext;
48
class TextResourceDecoder;
48
class TextResourceDecoder;
49
class WorkerScriptLoaderClient;
49
class WorkerScriptLoaderClient;
Lines 58-64 class WorkerScriptLoader : public RefCounted<WorkerScriptLoader>, public Threada a/Source/WebCore/workers/WorkerScriptLoader.h_sec3
58
    }
58
    }
59
59
60
    Optional<Exception> loadSynchronously(ScriptExecutionContext*, const URL&, FetchOptions::Mode, FetchOptions::Cache, ContentSecurityPolicyEnforcement, const String& initiatorIdentifier);
60
    Optional<Exception> loadSynchronously(ScriptExecutionContext*, const URL&, FetchOptions::Mode, FetchOptions::Cache, ContentSecurityPolicyEnforcement, const String& initiatorIdentifier);
61
    void loadAsynchronously(ScriptExecutionContext&, ResourceRequest&&, FetchOptions&&, ContentSecurityPolicyEnforcement, ServiceWorkersMode, WorkerScriptLoaderClient&);
61
    void loadAsynchronously(ScriptExecutionContext&, ResourceRequest&&, FetchOptions&&, ContentSecurityPolicyEnforcement, ServiceWorkersMode, WorkerScriptLoaderClient&, String&& taskMode);
62
62
63
    void notifyError();
63
    void notifyError();
64
64
Lines 67-72 class WorkerScriptLoader : public RefCounted<WorkerScriptLoader>, public Threada a/Source/WebCore/workers/WorkerScriptLoader.h_sec4
67
    const String& referrerPolicy() const { return m_referrerPolicy; }
67
    const String& referrerPolicy() const { return m_referrerPolicy; }
68
    const URL& url() const { return m_url; }
68
    const URL& url() const { return m_url; }
69
    const URL& responseURL() const;
69
    const URL& responseURL() const;
70
    ResourceResponse::Source responseSource() const { return m_responseSource; }
71
    bool isRedirected() const { return m_isRedirected; }
70
    const CertificateInfo& certificateInfo() const { return m_certificateInfo; }
72
    const CertificateInfo& certificateInfo() const { return m_certificateInfo; }
71
    const String& responseMIMEType() const { return m_responseMIMEType; }
73
    const String& responseMIMEType() const { return m_responseMIMEType; }
72
    bool failed() const { return m_failed; }
74
    bool failed() const { return m_failed; }
Lines 107-112 class WorkerScriptLoader : public RefCounted<WorkerScriptLoader>, public Threada a/Source/WebCore/workers/WorkerScriptLoader.h_sec5
107
    unsigned long m_identifier { 0 };
109
    unsigned long m_identifier { 0 };
108
    bool m_failed { false };
110
    bool m_failed { false };
109
    bool m_finishing { false };
111
    bool m_finishing { false };
112
    bool m_isRedirected { false };
113
    ResourceResponse::Source m_responseSource { ResourceResponse::Source::Unknown };
110
    ResourceError m_error;
114
    ResourceError m_error;
111
};
115
};
112
116
- a/Source/WebCore/workers/WorkerThread.cpp -3 / +29 lines
Lines 32-37 a/Source/WebCore/workers/WorkerThread.cpp_sec1
32
#include "SecurityOrigin.h"
32
#include "SecurityOrigin.h"
33
#include "SocketProvider.h"
33
#include "SocketProvider.h"
34
#include "WorkerGlobalScope.h"
34
#include "WorkerGlobalScope.h"
35
#include "WorkerScriptFetcher.h"
36
#include <JavaScriptCore/ScriptCallStack.h>
35
#include <wtf/Threading.h>
37
#include <wtf/Threading.h>
36
38
37
namespace WebCore {
39
namespace WebCore {
Lines 55-60 WorkerParameters WorkerParameters::isolatedCopy() const a/Source/WebCore/workers/WorkerThread.cpp_sec2
55
        shouldBypassMainWorldContentSecurityPolicy,
57
        shouldBypassMainWorldContentSecurityPolicy,
56
        timeOrigin,
58
        timeOrigin,
57
        referrerPolicy,
59
        referrerPolicy,
60
        workerType,
61
        credentials,
58
        settingsValues.isolatedCopy()
62
        settingsValues.isolatedCopy()
59
    };
63
    };
60
}
64
}
Lines 123-131 bool WorkerThread::shouldWaitForWebInspectorOnStartup() const a/Source/WebCore/workers/WorkerThread.cpp_sec3
123
127
124
void WorkerThread::evaluateScriptIfNecessary(String& exceptionMessage)
128
void WorkerThread::evaluateScriptIfNecessary(String& exceptionMessage)
125
{
129
{
126
    globalScope()->script()->evaluate(ScriptSourceCode(m_startupData->sourceCode, URL(m_startupData->params.scriptURL)), &exceptionMessage);
130
    // We are currently holding only the initial script code. If the WorkerType is Module, we should fetch the entire graph before executing the rest of this.
127
131
    // We invoke module loader as if we are executing inline module script tag in Document.
128
    finishedEvaluatingScript();
132
133
    if (m_startupData->params.workerType == WorkerType::Classic) {
134
        globalScope()->script()->evaluate(ScriptSourceCode(m_startupData->sourceCode, URL(m_startupData->params.scriptURL)), &exceptionMessage);
135
        finishedEvaluatingScript();
136
    } else {
137
        // FIXME fix initiator name.
138
        ScriptSourceCode sourceCode(m_startupData->sourceCode, URL(m_startupData->params.scriptURL), { }, JSC::SourceProviderSourceType::Module);
139
        auto scriptFetcher = WorkerScriptFetcher::create(globalScope()->credentials());
140
        MessageQueueWaitResult result = globalScope()->script()->loadModuleSynchronously(scriptFetcher.get(), sourceCode);
141
        if (result != MessageQueueTerminated) {
142
            if (Optional<LoadableScript::Error> error = scriptFetcher->error()) {
143
                if (Optional<LoadableScript::ConsoleMessage> message = error->consoleMessage)
144
                    exceptionMessage = message->message;
145
                else
146
                    exceptionMessage = "Importing a module script failed."_s;
147
                globalScope()->reportException(exceptionMessage, { }, { }, { }, { }, { });
148
            } else if (!scriptFetcher->wasCanceled()) {
149
                // Evaluate.
150
                globalScope()->script()->linkAndEvaluateModule(scriptFetcher.get(), sourceCode, &exceptionMessage);
151
                finishedEvaluatingScript();
152
            }
153
        }
154
    }
129
155
130
    // Free the startup data to cause its member variable deref's happen on the worker's thread (since
156
    // Free the startup data to cause its member variable deref's happen on the worker's thread (since
131
    // all ref/derefs of these objects are happening on the thread at this point). Note that
157
    // all ref/derefs of these objects are happening on the thread at this point). Note that
- a/Source/WebCore/workers/WorkerThread.h +5 lines
Lines 26-32 a/Source/WebCore/workers/WorkerThread.h_sec1
26
#pragma once
26
#pragma once
27
27
28
#include "ContentSecurityPolicyResponseHeaders.h"
28
#include "ContentSecurityPolicyResponseHeaders.h"
29
#include "FetchRequestCredentials.h"
29
#include "WorkerOrWorkletThread.h"
30
#include "WorkerOrWorkletThread.h"
31
#include "WorkerRunLoop.h"
32
#include "WorkerType.h"
30
#include <JavaScriptCore/RuntimeFlags.h>
33
#include <JavaScriptCore/RuntimeFlags.h>
31
#include <memory>
34
#include <memory>
32
#include <wtf/URL.h>
35
#include <wtf/URL.h>
Lines 63-68 struct WorkerParameters { a/Source/WebCore/workers/WorkerThread.h_sec2
63
    bool shouldBypassMainWorldContentSecurityPolicy;
66
    bool shouldBypassMainWorldContentSecurityPolicy;
64
    MonotonicTime timeOrigin;
67
    MonotonicTime timeOrigin;
65
    ReferrerPolicy referrerPolicy;
68
    ReferrerPolicy referrerPolicy;
69
    WorkerType workerType;
70
    FetchRequestCredentials credentials;
66
    Settings::Values settingsValues;
71
    Settings::Values settingsValues;
67
72
68
    WorkerParameters isolatedCopy() const;
73
    WorkerParameters isolatedCopy() const;
- a/Source/WebCore/workers/WorkerType.h -1 / +1 lines
Lines 27-33 a/Source/WebCore/workers/WorkerType.h_sec1
27
27
28
namespace WebCore {
28
namespace WebCore {
29
29
30
enum class WorkerType {
30
enum class WorkerType : uint8_t {
31
    Classic,
31
    Classic,
32
    Module,
32
    Module,
33
};
33
};
- a/Source/WebCore/workers/service/ServiceWorkerContainer.h -1 / +1 lines
Lines 47-53 class NavigatorBase; a/Source/WebCore/workers/service/ServiceWorkerContainer.h_sec1
47
class ServiceWorker;
47
class ServiceWorker;
48
48
49
enum class ServiceWorkerUpdateViaCache : uint8_t;
49
enum class ServiceWorkerUpdateViaCache : uint8_t;
50
enum class WorkerType;
50
enum class WorkerType : uint8_t;
51
51
52
template<typename IDLType> class DOMPromiseProxy;
52
template<typename IDLType> class DOMPromiseProxy;
53
53
- a/Source/WebCore/workers/service/ServiceWorkerJob.cpp -1 / +2 lines
Lines 110-116 void ServiceWorkerJob::fetchScriptWithContext(ScriptExecutionContext& context, F a/Source/WebCore/workers/service/ServiceWorkerJob.cpp_sec1
110
    options.cache = cachePolicy;
110
    options.cache = cachePolicy;
111
    options.redirect = FetchOptions::Redirect::Error;
111
    options.redirect = FetchOptions::Redirect::Error;
112
    options.destination = FetchOptions::Destination::Serviceworker;
112
    options.destination = FetchOptions::Destination::Serviceworker;
113
    m_scriptLoader->loadAsynchronously(context, WTFMove(request), WTFMove(options), ContentSecurityPolicyEnforcement::DoNotEnforce, ServiceWorkersMode::None, *this);
113
    options.credentials = FetchOptions::Credentials::SameOrigin;
114
    m_scriptLoader->loadAsynchronously(context, WTFMove(request), WTFMove(options), ContentSecurityPolicyEnforcement::DoNotEnforce, ServiceWorkersMode::None, *this, WorkerRunLoop::defaultMode());
114
}
115
}
115
116
116
ResourceError ServiceWorkerJob::validateServiceWorkerResponse(const ServiceWorkerJobData& jobData, const ResourceResponse& response)
117
ResourceError ServiceWorkerJob::validateServiceWorkerResponse(const ServiceWorkerJobData& jobData, const ResourceResponse& response)
- a/Source/WebCore/workers/service/ServiceWorkerRegistrationOptions.h -1 / +1 lines
Lines 32-38 a/Source/WebCore/workers/service/ServiceWorkerRegistrationOptions.h_sec1
32
namespace WebCore {
32
namespace WebCore {
33
33
34
enum class ServiceWorkerUpdateViaCache : uint8_t;
34
enum class ServiceWorkerUpdateViaCache : uint8_t;
35
enum class WorkerType;
35
enum class WorkerType : uint8_t;
36
36
37
struct ServiceWorkerRegistrationOptions {
37
struct ServiceWorkerRegistrationOptions {
38
    String scope;
38
    String scope;
- a/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp -1 / +2 lines
Lines 73-80 class DummyServiceWorkerThreadProxy : public WorkerObjectProxy { a/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp_sec1
73
// FIXME: Use a valid WorkerObjectProxy
73
// FIXME: Use a valid WorkerObjectProxy
74
// FIXME: Use valid runtime flags
74
// FIXME: Use valid runtime flags
75
75
76
// FIXME: Use a valid WorkerType and Credentails for module service workers.
76
ServiceWorkerThread::ServiceWorkerThread(const ServiceWorkerContextData& data, String&& userAgent, const Settings::Values& settingsValues, WorkerLoaderProxy& loaderProxy, WorkerDebuggerProxy& debuggerProxy, IDBClient::IDBConnectionProxy* idbConnectionProxy, SocketProvider* socketProvider)
77
ServiceWorkerThread::ServiceWorkerThread(const ServiceWorkerContextData& data, String&& userAgent, const Settings::Values& settingsValues, WorkerLoaderProxy& loaderProxy, WorkerDebuggerProxy& debuggerProxy, IDBClient::IDBConnectionProxy* idbConnectionProxy, SocketProvider* socketProvider)
77
    : WorkerThread({ data.scriptURL, emptyString(), "serviceworker:" + Inspector::IdentifiersFactory::createIdentifier(), WTFMove(userAgent), platformStrategies()->loaderStrategy()->isOnLine(), data.contentSecurityPolicy, false, MonotonicTime::now(), { }, settingsValues }, data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, data.registration.key.topOrigin().securityOrigin().get(), idbConnectionProxy, socketProvider, JSC::RuntimeFlags::createAllEnabled())
78
    : WorkerThread({ data.scriptURL, emptyString(), "serviceworker:" + Inspector::IdentifiersFactory::createIdentifier(), WTFMove(userAgent), platformStrategies()->loaderStrategy()->isOnLine(), data.contentSecurityPolicy, false, MonotonicTime::now(), { }, WorkerType::Classic, FetchRequestCredentials::SameOrigin, settingsValues }, data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, data.registration.key.topOrigin().securityOrigin().get(), idbConnectionProxy, socketProvider, JSC::RuntimeFlags::createAllEnabled())
78
    , m_data(data.isolatedCopy())
79
    , m_data(data.isolatedCopy())
79
    , m_workerObjectProxy(DummyServiceWorkerThreadProxy::shared())
80
    , m_workerObjectProxy(DummyServiceWorkerThreadProxy::shared())
80
    , m_heartBeatTimeout(SWContextManager::singleton().connection()->shouldUseShortTimeout() ? heartBeatTimeoutForTest : heartBeatTimeout)
81
    , m_heartBeatTimeout(SWContextManager::singleton().connection()->shouldUseShortTimeout() ? heartBeatTimeoutForTest : heartBeatTimeout)
- a/Source/WebCore/workers/service/server/SWServerWorker.h -1 / +1 lines
Lines 50-56 struct ServiceWorkerClientIdentifier; a/Source/WebCore/workers/service/server/SWServerWorker.h_sec1
50
struct ServiceWorkerClientQueryOptions;
50
struct ServiceWorkerClientQueryOptions;
51
struct ServiceWorkerContextData;
51
struct ServiceWorkerContextData;
52
struct ServiceWorkerJobDataIdentifier;
52
struct ServiceWorkerJobDataIdentifier;
53
enum class WorkerType;
53
enum class WorkerType : uint8_t;
54
54
55
class SWServerWorker : public RefCounted<SWServerWorker> {
55
class SWServerWorker : public RefCounted<SWServerWorker> {
56
public:
56
public:
- a/Source/WebCore/worklets/WorkletGlobalScope.cpp -66 / +1 lines
Lines 158-229 ReferrerPolicy WorkletGlobalScope::referrerPolicy() const a/Source/WebCore/worklets/WorkletGlobalScope.cpp_sec1
158
void WorkletGlobalScope::fetchAndInvokeScript(const URL& moduleURL, FetchRequestCredentials credentials, CompletionHandler<void(Optional<Exception>&&)>&& completionHandler)
158
void WorkletGlobalScope::fetchAndInvokeScript(const URL& moduleURL, FetchRequestCredentials credentials, CompletionHandler<void(Optional<Exception>&&)>&& completionHandler)
159
{
159
{
160
    ASSERT(!isMainThread());
160
    ASSERT(!isMainThread());
161
    m_scriptFetchJobs.append({ moduleURL, credentials, WTFMove(completionHandler) });
161
    script()->loadAndEvaluateModule(moduleURL, credentials, WTFMove(completionHandler));
162
    processNextScriptFetchJobIfNeeded();
163
}
164
165
void WorkletGlobalScope::processNextScriptFetchJobIfNeeded()
166
{
167
    if (m_scriptFetchJobs.isEmpty() || m_scriptLoader)
168
        return;
169
170
    auto& scriptFetchJob = m_scriptFetchJobs.first();
171
172
    ResourceRequest request { scriptFetchJob.moduleURL };
173
174
    FetchOptions fetchOptions;
175
    fetchOptions.mode = FetchOptions::Mode::Cors;
176
    fetchOptions.cache = FetchOptions::Cache::Default;
177
    fetchOptions.redirect = FetchOptions::Redirect::Follow;
178
    fetchOptions.credentials = scriptFetchJob.credentials;
179
#if ENABLE(WEB_AUDIO)
180
    if (isAudioWorkletGlobalScope())
181
        fetchOptions.destination = FetchOptions::Destination::Audioworklet;
182
#endif
183
#if ENABLE(CSS_PAINTING_API)
184
    if (isPaintWorkletGlobalScope())
185
        fetchOptions.destination = FetchOptions::Destination::Paintworklet;
186
#endif
187
188
    auto contentSecurityPolicyEnforcement = shouldBypassMainWorldContentSecurityPolicy() ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceChildSrcDirective;
189
190
    m_scriptLoader = WorkerScriptLoader::create();
191
    m_scriptLoader->loadAsynchronously(*this, WTFMove(request), WTFMove(fetchOptions), contentSecurityPolicyEnforcement, ServiceWorkersMode::All, *this);
192
}
193
194
void WorkletGlobalScope::didReceiveResponse(unsigned long, const ResourceResponse&)
195
{
196
}
197
198
void WorkletGlobalScope::notifyFinished()
199
{
200
    auto completedJob = m_scriptFetchJobs.takeFirst();
201
202
    if (m_scriptLoader->failed()) {
203
        didCompleteScriptFetchJob(WTFMove(completedJob), Exception { AbortError, makeString("Failed to fetch module, error: ", m_scriptLoader->error().localizedDescription()) });
204
        return;
205
    }
206
207
    // FIXME: This should really be run as a module script but we don't support this in workers yet.
208
    URL moduleURL(m_scriptLoader->responseURL());
209
    auto addResult = m_evaluatedModules.add(moduleURL);
210
    if (addResult.isNewEntry) {
211
        NakedPtr<JSC::Exception> exception;
212
        script()->evaluate(ScriptSourceCode(m_scriptLoader->script(), WTFMove(moduleURL)), exception);
213
        if (exception)
214
            script()->setException(exception);
215
    }
216
217
    didCompleteScriptFetchJob(WTFMove(completedJob), { });
218
}
219
220
void WorkletGlobalScope::didCompleteScriptFetchJob(ScriptFetchJob&& job, Optional<Exception> result)
221
{
222
    m_scriptLoader = nullptr;
223
224
    job.completionHandler(WTFMove(result));
225
226
    processNextScriptFetchJobIfNeeded();
227
}
162
}
228
163
229
MessagePortChannelProvider& WorkletGlobalScope::messagePortChannelProvider()
164
MessagePortChannelProvider& WorkletGlobalScope::messagePortChannelProvider()
- a/Source/WebCore/worklets/WorkletGlobalScope.h -18 / +1 lines
Lines 33-39 a/Source/WebCore/worklets/WorkletGlobalScope.h_sec1
33
#include "ScriptSourceCode.h"
33
#include "ScriptSourceCode.h"
34
#include "WorkerOrWorkletGlobalScope.h"
34
#include "WorkerOrWorkletGlobalScope.h"
35
#include "WorkerOrWorkletScriptController.h"
35
#include "WorkerOrWorkletScriptController.h"
36
#include "WorkerScriptLoaderClient.h"
37
#include <JavaScriptCore/ConsoleMessage.h>
36
#include <JavaScriptCore/ConsoleMessage.h>
38
#include <JavaScriptCore/RuntimeFlags.h>
37
#include <JavaScriptCore/RuntimeFlags.h>
39
#include <wtf/CompletionHandler.h>
38
#include <wtf/CompletionHandler.h>
Lines 54-60 struct WorkletParameters; a/Source/WebCore/worklets/WorkletGlobalScope.h_sec2
54
enum WorkletGlobalScopeIdentifierType { };
53
enum WorkletGlobalScopeIdentifierType { };
55
using WorkletGlobalScopeIdentifier = ObjectIdentifier<WorkletGlobalScopeIdentifierType>;
54
using WorkletGlobalScopeIdentifier = ObjectIdentifier<WorkletGlobalScopeIdentifierType>;
56
55
57
class WorkletGlobalScope : public WorkerOrWorkletGlobalScope, public WorkerScriptLoaderClient {
56
class WorkletGlobalScope : public WorkerOrWorkletGlobalScope {
58
    WTF_MAKE_ISO_ALLOCATED(WorkletGlobalScope);
57
    WTF_MAKE_ISO_ALLOCATED(WorkletGlobalScope);
59
public:
58
public:
60
    virtual ~WorkletGlobalScope();
59
    virtual ~WorkletGlobalScope();
Lines 111-120 class WorkletGlobalScope : public WorkerOrWorkletGlobalScope, public WorkerScrip a/Source/WebCore/worklets/WorkletGlobalScope.h_sec3
111
    void addMessage(MessageSource, MessageLevel, const String&, const String&, unsigned, unsigned, RefPtr<Inspector::ScriptCallStack>&&, JSC::JSGlobalObject*, unsigned long) final;
110
    void addMessage(MessageSource, MessageLevel, const String&, const String&, unsigned, unsigned, RefPtr<Inspector::ScriptCallStack>&&, JSC::JSGlobalObject*, unsigned long) final;
112
    void addConsoleMessage(MessageSource, MessageLevel, const String&, unsigned long) final;
111
    void addConsoleMessage(MessageSource, MessageLevel, const String&, unsigned long) final;
113
112
114
    // WorkerScriptLoaderClient.
115
    void didReceiveResponse(unsigned long identifier, const ResourceResponse&) final;
116
    void notifyFinished() final;
117
118
    EventTarget* errorEventTarget() final { return this; }
113
    EventTarget* errorEventTarget() final { return this; }
119
114
120
#if ENABLE(WEB_CRYPTO)
115
#if ENABLE(WEB_CRYPTO)
Lines 125-139 class WorkletGlobalScope : public WorkerOrWorkletGlobalScope, public WorkerScrip a/Source/WebCore/worklets/WorkletGlobalScope.h_sec4
125
    String userAgent(const URL&) const final;
120
    String userAgent(const URL&) const final;
126
    const Settings::Values& settingsValues() const final { return m_settingsValues; }
121
    const Settings::Values& settingsValues() const final { return m_settingsValues; }
127
122
128
    struct ScriptFetchJob {
129
        URL moduleURL;
130
        FetchRequestCredentials credentials;
131
        CompletionHandler<void(Optional<Exception>&&)> completionHandler;
132
    };
133
134
    void processNextScriptFetchJobIfNeeded();
135
    void didCompleteScriptFetchJob(ScriptFetchJob&&, Optional<Exception>);
136
137
    WeakPtr<Document> m_document;
123
    WeakPtr<Document> m_document;
138
124
139
    Ref<SecurityOrigin> m_topOrigin;
125
    Ref<SecurityOrigin> m_topOrigin;
Lines 144-152 class WorkletGlobalScope : public WorkerOrWorkletGlobalScope, public WorkerScrip a/Source/WebCore/worklets/WorkletGlobalScope.h_sec5
144
130
145
    std::unique_ptr<WorkerMessagePortChannelProvider> m_messagePortChannelProvider;
131
    std::unique_ptr<WorkerMessagePortChannelProvider> m_messagePortChannelProvider;
146
132
147
    RefPtr<WorkerScriptLoader> m_scriptLoader;
148
    Deque<ScriptFetchJob> m_scriptFetchJobs;
149
    HashSet<URL> m_evaluatedModules;
150
    Settings::Values m_settingsValues;
133
    Settings::Values m_settingsValues;
151
};
134
};
152
135
- a/LayoutTests/ChangeLog +13 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2021-02-12  Yusuke Suzuki  <ysuzuki@apple.com>
2
3
        JS Modules in Workers
4
        https://bugs.webkit.org/show_bug.cgi?id=164860
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * TestExpectations:
9
        * http/tests/security/contentSecurityPolicy/1.1/module-scriptnonce-redirect-expected.txt:
10
        * http/tests/subresource-integrity/sri-module-expected.txt:
11
        * webaudio/audioworklet-addModule-failure-expected.txt:
12
        * webaudio/worklet-crash-expected.txt:
13
1
2021-02-11  Alex Christensen  <achristensen@webkit.org>
14
2021-02-11  Alex Christensen  <achristensen@webkit.org>
2
15
3
        REGRESSION(r272293) WebGL 1.0.2 test expectations say HTTPS
16
        REGRESSION(r272293) WebGL 1.0.2 test expectations say HTTPS
- a/LayoutTests/imported/w3c/ChangeLog +39 lines
Lines 1-3 a/LayoutTests/imported/w3c/ChangeLog_sec1
1
2021-02-12  Yusuke Suzuki  <ysuzuki@apple.com>
2
3
        JS Modules in Workers
4
        https://bugs.webkit.org/show_bug.cgi?id=164860
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.tentative.any.worker-expected.txt:
9
        * web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/checkpoint-after-workerglobalscope-onerror-module-expected.txt:
10
        * web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/alpha/base-url-worker-importScripts-expected.txt:
11
        * web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/alpha/base-url-worker.sub-expected.txt:
12
        * web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker-expected.txt:
13
        * web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker-expected.txt:
14
        * web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker-expected.txt:
15
        * web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-worker-expected.txt:
16
        * web-platform-tests/service-workers/service-worker/import-module-scripts.https-expected.txt:
17
        * web-platform-tests/workers/baseurl/alpha/import-in-moduleworker-expected.txt:
18
        * web-platform-tests/workers/baseurl/alpha/importScripts-in-worker-expected.txt:
19
        * web-platform-tests/workers/baseurl/alpha/xhr-in-moduleworker-expected.txt:
20
        * web-platform-tests/workers/baseurl/alpha/xhr-in-worker-expected.txt:
21
        * web-platform-tests/workers/constructors/Worker/same-origin-expected.txt:
22
        * web-platform-tests/workers/interfaces/WorkerGlobalScope/location/redirect-expected.txt:
23
        * web-platform-tests/workers/interfaces/WorkerGlobalScope/location/redirect-module-expected.txt:
24
        * web-platform-tests/workers/modules/dedicated-worker-import-blob-url.any-expected.txt:
25
        * web-platform-tests/workers/modules/dedicated-worker-import-csp-expected.txt:
26
        * web-platform-tests/workers/modules/dedicated-worker-import-failure-expected.txt:
27
        * web-platform-tests/workers/modules/dedicated-worker-import-meta-expected.txt:
28
        * web-platform-tests/workers/modules/dedicated-worker-import-meta.html:
29
        * web-platform-tests/workers/modules/dedicated-worker-import-referrer-expected.txt:
30
        * web-platform-tests/workers/modules/dedicated-worker-import.any-expected.txt:
31
        * web-platform-tests/workers/modules/dedicated-worker-options-type-expected.txt:
32
        * web-platform-tests/workers/modules/dedicated-worker-parse-error-failure-expected.txt:
33
        * web-platform-tests/workers/name-property-expected.txt:
34
        * web-platform-tests/worklets/audio-worklet-credentials.https-expected.txt:
35
        * web-platform-tests/worklets/audio-worklet-csp.https-expected.txt:
36
        * web-platform-tests/worklets/audio-worklet-import.https-expected.txt:
37
        * web-platform-tests/worklets/audio-worklet-referrer.https-expected.txt:
38
        * web-platform-tests/xhr/open-url-redirected-worker-origin-expected.txt:
39
1
2021-02-11  Said Abou-Hallawa  <said@apple.com>
40
2021-02-11  Said Abou-Hallawa  <said@apple.com>
2
41
3
        Unreviewed, reverting r270578.
42
        Unreviewed, reverting r270578.
- a/LayoutTests/TestExpectations -2 lines
Lines 640-646 fast/dom/connected-subframe-counter-overflow.html [ Slow ] a/LayoutTests/TestExpectations_sec1
640
[ Debug ] http/tests/workers/worker-messageport-2.html [ Slow ]
640
[ Debug ] http/tests/workers/worker-messageport-2.html [ Slow ]
641
641
642
# Skip workers tests that are timing out or are SharedWorker related only
642
# Skip workers tests that are timing out or are SharedWorker related only
643
imported/w3c/web-platform-tests/workers/constructors/Worker/same-origin.html [ Skip ]
644
imported/w3c/web-platform-tests/workers/data-url-shared.html [ Skip ]
643
imported/w3c/web-platform-tests/workers/data-url-shared.html [ Skip ]
645
imported/w3c/web-platform-tests/workers/examples/onconnect.any.html [ Skip ]
644
imported/w3c/web-platform-tests/workers/examples/onconnect.any.html [ Skip ]
646
imported/w3c/web-platform-tests/workers/examples/onconnect.any.worker.html [ Skip ]
645
imported/w3c/web-platform-tests/workers/examples/onconnect.any.worker.html [ Skip ]
Lines 663-669 imported/w3c/web-platform-tests/workers/SharedWorker-replace-EventHandler.any.ht a/LayoutTests/TestExpectations_sec2
663
imported/w3c/web-platform-tests/workers/SharedWorker-replace-EventHandler.any.worker.html [ Skip ]
662
imported/w3c/web-platform-tests/workers/SharedWorker-replace-EventHandler.any.worker.html [ Skip ]
664
imported/w3c/web-platform-tests/workers/SharedWorker-script-error.html [ Skip ]
663
imported/w3c/web-platform-tests/workers/SharedWorker-script-error.html [ Skip ]
665
imported/w3c/web-platform-tests/workers/SharedWorker-simple.html [ Skip ]
664
imported/w3c/web-platform-tests/workers/SharedWorker-simple.html [ Skip ]
666
imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-referrer.html [ Skip ]
667
imported/w3c/web-platform-tests/workers/modules/dedicated-worker-options-credentials.html [ Skip ]
665
imported/w3c/web-platform-tests/workers/modules/dedicated-worker-options-credentials.html [ Skip ]
668
666
669
imported/w3c/web-platform-tests/workers/constructors/SharedWorker [ Skip ]
667
imported/w3c/web-platform-tests/workers/constructors/SharedWorker [ Skip ]
- a/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/module-scriptnonce-redirect-expected.txt -1 lines
Lines 1-3 a/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/module-scriptnonce-redirect-expected.txt_sec1
1
CONSOLE MESSAGE: Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
1
CONSOLE MESSAGE: Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
2
CONSOLE MESSAGE: TypeError: Cross-origin script load denied by Cross-Origin Resource Sharing policy.
3
This tests whether a deferred script load caused by a redirect is properly allowed by a nonce.
2
This tests whether a deferred script load caused by a redirect is properly allowed by a nonce.
- a/LayoutTests/http/tests/subresource-integrity/sri-module-expected.txt -1 lines
Lines 3-9 CONSOLE MESSAGE: TypeError: Cannot load script http://127.0.0.1:8000/subresource a/LayoutTests/http/tests/subresource-integrity/sri-module-expected.txt_sec1
3
CONSOLE MESSAGE: TypeError: Cannot load script http://localhost:8000/subresource-integrity/resources/crossorigin-anon-script-module.js. Failed integrity metadata check. Content length: 37, Expected content length: 37, Expected metadata: sha256-deadbeefcSLlbFZCj1OACLxTxVck2TOrBTEdUbwz1yU=
3
CONSOLE MESSAGE: TypeError: Cannot load script http://localhost:8000/subresource-integrity/resources/crossorigin-anon-script-module.js. Failed integrity metadata check. Content length: 37, Expected content length: 37, Expected metadata: sha256-deadbeefcSLlbFZCj1OACLxTxVck2TOrBTEdUbwz1yU=
4
CONSOLE MESSAGE: TypeError: Cannot load script http://localhost:8000/subresource-integrity/resources/crossorigin-creds-script-module.js. Failed integrity metadata check. Content length: 38, Expected content length: 38, Expected metadata: sha256-deadbeef2S+pTRZgiw3DWrhC6JLDlt2zRyGpwH7unU8=
4
CONSOLE MESSAGE: TypeError: Cannot load script http://localhost:8000/subresource-integrity/resources/crossorigin-creds-script-module.js. Failed integrity metadata check. Content length: 38, Expected content length: 38, Expected metadata: sha256-deadbeef2S+pTRZgiw3DWrhC6JLDlt2zRyGpwH7unU8=
5
CONSOLE MESSAGE: Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
5
CONSOLE MESSAGE: Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
6
CONSOLE MESSAGE: TypeError: Cross-origin script load denied by Cross-Origin Resource Sharing policy.
7
CONSOLE MESSAGE: TypeError: Cannot load script http://127.0.0.1:8000/subresource-integrity/resources/matching-digest-module.js. Failed integrity metadata check. Content length: 29, Expected content length: 29, Expected metadata: sha256-cWh9nPfm7_mRbKhzarnRYlsJWz5XTNcsqPFzKEx+zSU=
6
CONSOLE MESSAGE: TypeError: Cannot load script http://127.0.0.1:8000/subresource-integrity/resources/matching-digest-module.js. Failed integrity metadata check. Content length: 29, Expected content length: 29, Expected metadata: sha256-cWh9nPfm7_mRbKhzarnRYlsJWz5XTNcsqPFzKEx+zSU=
8
CONSOLE MESSAGE: TypeError: Cannot load script http://127.0.0.1:8000/subresource-integrity/resources/matching-digest-module.js. Failed integrity metadata check. Content length: 29, Expected content length: 29, Expected metadata: sha256-U9WYDtBWkcHx13+9UKk/3Q5eoqDc4YGxYb07EPWzb9e=?foo=bar?spam=eggs
7
CONSOLE MESSAGE: TypeError: Cannot load script http://127.0.0.1:8000/subresource-integrity/resources/matching-digest-module.js. Failed integrity metadata check. Content length: 29, Expected content length: 29, Expected metadata: sha256-U9WYDtBWkcHx13+9UKk/3Q5eoqDc4YGxYb07EPWzb9e=?foo=bar?spam=eggs
9
8
- a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.tentative.any.worker-expected.txt -5 / +5 lines
Lines 1-7 a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.tentative.any.worker-expected.txt_sec1
1
1
2
FAIL Non-object: null promise_test: Unhandled rejection with value: object "Error: Could not import the module './null.json'."
2
FAIL Non-object: null promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
3
FAIL Non-object: true promise_test: Unhandled rejection with value: object "Error: Could not import the module './true.json'."
3
FAIL Non-object: true promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
4
FAIL Non-object: false promise_test: Unhandled rejection with value: object "Error: Could not import the module './false.json'."
4
FAIL Non-object: false promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
5
FAIL Non-object: string promise_test: Unhandled rejection with value: object "Error: Could not import the module './string.json'."
5
FAIL Non-object: string promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
6
FAIL Non-object: array promise_test: Unhandled rejection with value: object "Error: Could not import the module './array.json'."
6
FAIL Non-object: array promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
7
7
- a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/checkpoint-after-workerglobalscope-onerror-module-expected.txt -2 / +2 lines
Lines 1-4 a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/checkpoint-after-workerglobalscope-onerror-module-expected.txt_sec1
1
1
2
Harness Error (TIMEOUT), message = null
2
FAIL Promise resolved during #report-the-error assert_array_equals: lengths differ, expected array ["handler 1", "handler 2", "handler 1 promise", "handler 2 promise"] length 4, got [] length 0
3
3
PASS Promise resolved during event handlers other than error
4
4
- a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/alpha/base-url-worker-importScripts-expected.txt -4 / +4 lines
Lines 1-6 a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/alpha/base-url-worker-importScripts-expected.txt_sec1
1
1
2
FAIL Relative URL-like from same-origin importScripts() promise_test: Unhandled rejection with value: object "Error: Could not import the module './import.js?pipe=header(Access-Control-Allow-Origin,*)&label=relative-cross-origin importScripts()'."
2
PASS Relative URL-like from same-origin importScripts()
3
FAIL Absolute URL-like from same-origin importScripts() promise_test: Unhandled rejection with value: object "Error: Could not import the module 'http://127.0.0.1:8800/html/semantics/scripting-1/the-script-element/module/dynamic-import/gamma/import.js?pipe=header(Access-Control-Allow-Origin,*)&label=absolute-cross-origin importScripts()'."
3
PASS Absolute URL-like from same-origin importScripts()
4
PASS Relative URL-like from cross-origin importScripts()
4
FAIL Relative URL-like from cross-origin importScripts() assert_equals: Relative URL-like specifier resolution should fail expected "(unreached)" but got "gamma/import.js"
5
FAIL Absolute URL-like from cross-origin importScripts() promise_test: Unhandled rejection with value: object "Error: Could not import the module 'http://127.0.0.1:8800/html/semantics/scripting-1/the-script-element/module/dynamic-import/gamma/import.js?pipe=header(Access-Control-Allow-Origin,*)&label=absolute-cross-origin importScripts()'."
5
PASS Absolute URL-like from cross-origin importScripts()
6
6
- a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/alpha/base-url-worker.sub-expected.txt -2 / +2 lines
Lines 1-4 a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/alpha/base-url-worker.sub-expected.txt_sec1
1
1
2
FAIL Relative URL-like from worker top-level script promise_test: Unhandled rejection with value: object "Error: Could not import the module './import.js?pipe=header(Access-Control-Allow-Origin,*)&label=relative-worker top-level script'."
2
PASS Relative URL-like from worker top-level script
3
FAIL Absolute URL-like from worker top-level script promise_test: Unhandled rejection with value: object "Error: Could not import the module 'http://127.0.0.1:8800/html/semantics/scripting-1/the-script-element/module/dynamic-import/gamma/import.js?pipe=header(Access-Control-Allow-Origin,*)&label=absolute-worker top-level script'."
3
PASS Absolute URL-like from worker top-level script
4
4
- a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker-expected.txt -2 / +1 lines
Lines 1-4 a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker-expected.txt_sec1
1
1
2
Harness Error (TIMEOUT), message = null
2
PASS Test evaluation order of modules
3
4
3
- a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker-expected.txt -2 / +1 lines
Lines 1-4 a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker-expected.txt_sec1
1
1
2
Harness Error (TIMEOUT), message = null
2
FAIL Test evaluation order of modules assert_array_equals: lengths differ, expected array ["step-1-1", "step-1-2", "global-error", "error", "microtask"] length 5, got ["step-1-1", "step-1-2", "microtask"] length 3
3
4
3
- a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker-expected.txt -2 / +1 lines
Lines 1-4 a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker-expected.txt_sec1
1
1
2
Harness Error (TIMEOUT), message = null
2
FAIL Test evaluation order of modules assert_array_equals: lengths differ, expected array ["step-2.2-1", "step-2.2-2", "global-error", "error", "microtask-2.2"] length 5, got ["step-2.2-1", "step-2.2-2", "microtask-2.2"] length 3
3
4
3
- a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-worker-expected.txt -2 / +1 lines
Lines 1-4 a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-worker-expected.txt_sec1
1
1
2
Harness Error (TIMEOUT), message = null
2
PASS Test evaluation order of modules
3
4
3
- a/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/import-module-scripts.https-expected.txt -4 / +4 lines
Lines 2-9 a/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/import-module-scripts.https-expected.txt_sec1
2
FAIL Static import. promise_test: Unhandled rejection with value: object "TypeError: SyntaxError: Unexpected token '*'. import call expects exactly one argument."
2
FAIL Static import. promise_test: Unhandled rejection with value: object "TypeError: SyntaxError: Unexpected token '*'. import call expects exactly one argument."
3
FAIL Nested static import. promise_test: Unhandled rejection with value: object "TypeError: SyntaxError: Unexpected token '*'. import call expects exactly one argument."
3
FAIL Nested static import. promise_test: Unhandled rejection with value: object "TypeError: SyntaxError: Unexpected token '*'. import call expects exactly one argument."
4
FAIL Static import and then dynamic import. promise_test: Unhandled rejection with value: object "TypeError: SyntaxError: Unexpected token '*'. import call expects exactly one argument."
4
FAIL Static import and then dynamic import. promise_test: Unhandled rejection with value: object "TypeError: SyntaxError: Unexpected token '*'. import call expects exactly one argument."
5
FAIL Dynamic import. assert_array_equals: value is "Failed to do dynamic import: Error: Could not import the module './export-on-load-script.js'.", expected array
5
PASS Dynamic import.
6
FAIL Nested dynamic import. assert_array_equals: value is "Failed to do dynamic import: Error: Could not import the module './export-on-dynamic-import-script.js'.", expected array
6
PASS Nested dynamic import.
7
FAIL Dynamic import and then static import. assert_array_equals: value is "Failed to do dynamic import: Error: Could not import the module './export-on-static-import-script.js'.", expected array
7
PASS Dynamic import and then static import.
8
FAIL eval(import()). assert_array_equals: value is "Failed to do dynamic import: Error: Could not import the module './export-on-load-script.js'.", expected array
8
PASS eval(import()).
9
9
- a/LayoutTests/imported/w3c/web-platform-tests/workers/baseurl/alpha/import-in-moduleworker-expected.txt -2 / +1 lines
Lines 1-4 a/LayoutTests/imported/w3c/web-platform-tests/workers/baseurl/alpha/import-in-moduleworker-expected.txt_sec1
1
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'r'. import call expects exactly one argument.
2
1
3
FAIL Base URL in module dedicated workers: import assert_unreached: Got error event Reached unreachable code
2
PASS Base URL in module dedicated workers: import
4
3
- a/LayoutTests/imported/w3c/web-platform-tests/workers/baseurl/alpha/importScripts-in-worker-expected.txt -1 / +1 lines
Lines 1-3 a/LayoutTests/imported/w3c/web-platform-tests/workers/baseurl/alpha/importScripts-in-worker-expected.txt_sec1
1
1
2
FAIL importScripts assert_equals: expected "gamma/script.js" but got "beta/script.js"
2
PASS importScripts
3
3
- a/LayoutTests/imported/w3c/web-platform-tests/workers/baseurl/alpha/xhr-in-moduleworker-expected.txt -1 / +1 lines
Lines 1-3 a/LayoutTests/imported/w3c/web-platform-tests/workers/baseurl/alpha/xhr-in-moduleworker-expected.txt_sec1
1
1
2
FAIL Base URL in module dedicated workers: XHR assert_equals: expected "gamma\n" but got "beta\n"
2
PASS Base URL in module dedicated workers: XHR
3
3
- a/LayoutTests/imported/w3c/web-platform-tests/workers/baseurl/alpha/xhr-in-worker-expected.txt -1 / +1 lines
Lines 1-3 a/LayoutTests/imported/w3c/web-platform-tests/workers/baseurl/alpha/xhr-in-worker-expected.txt_sec1
1
1
2
FAIL xhr-worker assert_equals: expected "gamma\n" but got "beta\n"
2
PASS xhr-worker
3
3
- a/LayoutTests/imported/w3c/web-platform-tests/workers/constructors/Worker/same-origin-expected.txt -9 / +7 lines
Lines 1-13 a/LayoutTests/imported/w3c/web-platform-tests/workers/constructors/Worker/same-origin-expected.txt_sec1
1
1
2
Harness Error (TIMEOUT), message = null
3
4
PASS unsupported_scheme
2
PASS unsupported_scheme
5
FAIL data_url The operation is insecure.
3
FAIL data_url The operation is insecure.
6
TIMEOUT about_blank Test timed out
4
PASS about_blank
7
TIMEOUT example_invalid Test timed out
5
PASS example_invalid
8
TIMEOUT port_81 Test timed out
6
PASS port_81
9
TIMEOUT https_port_80 Test timed out
7
PASS https_port_80
10
TIMEOUT https_port_8000 Test timed out
8
PASS https_port_8000
11
TIMEOUT http_post_8012 Test timed out
9
PASS http_post_8012
12
TIMEOUT javascript_url Test timed out
10
PASS javascript_url
13
11
- a/LayoutTests/imported/w3c/web-platform-tests/workers/interfaces/WorkerGlobalScope/location/redirect-expected.txt -1 / +1 lines
Lines 1-3 a/LayoutTests/imported/w3c/web-platform-tests/workers/interfaces/WorkerGlobalScope/location/redirect-expected.txt_sec1
1
1
2
FAIL WorkerLocation with redirects: classic dedicated workers assert_equals: expected "http://localhost:8800/workers/interfaces/WorkerGlobalScope/location/post-location-members.js?a" but got "http://localhost:8800/workers/interfaces/WorkerGlobalScope/location/helper-redirect.py?fail"
2
PASS WorkerLocation with redirects: classic dedicated workers
3
3
- a/LayoutTests/imported/w3c/web-platform-tests/workers/interfaces/WorkerGlobalScope/location/redirect-module-expected.txt -1 / +1 lines
Lines 1-3 a/LayoutTests/imported/w3c/web-platform-tests/workers/interfaces/WorkerGlobalScope/location/redirect-module-expected.txt_sec1
1
1
2
FAIL WorkerLocation with redirects: module dedicated workers assert_equals: expected "http://localhost:8800/workers/interfaces/WorkerGlobalScope/location/post-location-members.js?a" but got "http://localhost:8800/workers/interfaces/WorkerGlobalScope/location/helper-redirect.py?fail"
2
PASS WorkerLocation with redirects: module dedicated workers
3
3
- a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-blob-url.any-expected.txt -16 / +7 lines
Lines 1-18 a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-blob-url.any-expected.txt_sec1
1
CONSOLE MESSAGE: SyntaxError: Unexpected string literal "http://localhost:8800/workers/modules/resources/static-import-worker.js". import call expects exactly one argument.
2
CONSOLE MESSAGE: SyntaxError: Unexpected string literal "http://localhost:8800/workers/modules/resources/nested-static-import-worker.js". import call expects exactly one argument.
3
CONSOLE MESSAGE: SyntaxError: Unexpected string literal "http://localhost:8800/workers/modules/resources/static-import-and-then-dynamic-import-worker.js". import call expects exactly one argument.
4
CONSOLE MESSAGE: SyntaxError: Unexpected string literal "http://localhost:8800/workers/modules/resources/dynamic-import-worker.js". import call expects exactly one argument.
5
CONSOLE MESSAGE: SyntaxError: Unexpected string literal "http://localhost:8800/workers/modules/resources/nested-dynamic-import-worker.js". import call expects exactly one argument.
6
CONSOLE MESSAGE: SyntaxError: Unexpected string literal "http://localhost:8800/workers/modules/resources/dynamic-import-and-then-static-import-worker.js". import call expects exactly one argument.
7
CONSOLE MESSAGE: SyntaxError: Unexpected string literal "http://localhost:8800/workers/modules/resources/eval-dynamic-import-worker.js". import call expects exactly one argument.
8
1
9
Harness Error (FAIL), message = SyntaxError: Unexpected string literal "http://localhost:8800/workers/modules/resources/dynamic-import-and-then-static-import-worker.js". import call expects exactly one argument.
2
PASS Static import.
10
3
PASS Nested static import.
11
FAIL Static import. promise_test: Unhandled rejection with value: "SyntaxError: Unexpected string literal \"http://localhost:8800/workers/modules/resources/static-import-worker.js\". import call expects exactly one argument."
4
PASS Static import and then dynamic import.
12
FAIL Nested static import. promise_test: Unhandled rejection with value: "SyntaxError: Unexpected string literal \"http://localhost:8800/workers/modules/resources/nested-static-import-worker.js\". import call expects exactly one argument."
5
PASS Dynamic import.
13
FAIL Static import and then dynamic import. promise_test: Unhandled rejection with value: "SyntaxError: Unexpected string literal \"http://localhost:8800/workers/modules/resources/static-import-and-then-dynamic-import-worker.js\". import call expects exactly one argument."
6
PASS Nested dynamic import.
14
FAIL Dynamic import. promise_test: Unhandled rejection with value: "SyntaxError: Unexpected string literal \"http://localhost:8800/workers/modules/resources/dynamic-import-worker.js\". import call expects exactly one argument."
7
PASS Dynamic import and then static import.
15
FAIL Nested dynamic import. promise_test: Unhandled rejection with value: "SyntaxError: Unexpected string literal \"http://localhost:8800/workers/modules/resources/nested-dynamic-import-worker.js\". import call expects exactly one argument."
8
PASS eval(import()).
16
FAIL Dynamic import and then static import. promise_test: Unhandled rejection with value: "SyntaxError: Unexpected string literal \"http://localhost:8800/workers/modules/resources/dynamic-import-and-then-static-import-worker.js\". import call expects exactly one argument."
17
FAIL eval(import()). promise_test: Unhandled rejection with value: "SyntaxError: Unexpected string literal \"http://localhost:8800/workers/modules/resources/eval-dynamic-import-worker.js\". import call expects exactly one argument."
18
9
- a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-csp-expected.txt +9 lines
Lines 1-13 a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-csp-expected.txt_sec1
1
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
1
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
2
2
3
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-on-load-script.js
3
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
4
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
4
5
6
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-on-load-script.js
7
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-on-load-script.js
8
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-on-load-script.js
5
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
9
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
6
10
11
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-on-load-script.js
7
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
12
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
8
13
14
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-on-load-script.js
15
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-on-load-script.js
16
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-on-load-script.js
9
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
17
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
10
18
19
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-on-load-script.js
11
20
12
PASS worker-src 'self' directive should disallow cross origin static import.
21
PASS worker-src 'self' directive should disallow cross origin static import.
13
FAIL worker-src * directive should allow cross origin static import. assert_array_equals: expected property 0 to be "export-on-load-script.js" but got "ERROR" (expected array ["export-on-load-script.js"] got ["ERROR"])
22
FAIL worker-src * directive should allow cross origin static import. assert_array_equals: expected property 0 to be "export-on-load-script.js" but got "ERROR" (expected array ["export-on-load-script.js"] got ["ERROR"])
- a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-failure-expected.txt -3 / +3 lines
Lines 1-9 a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-failure-expected.txt_sec1
1
CONSOLE MESSAGE: SyntaxError: Unexpected string literal './non-existent-script.js'. import call expects exactly one argument.
1
CONSOLE MESSAGE: Importing a module script failed.
2
2
3
FAIL importScripts() on module worker should throw an exception. assert_equals: expected "TypeError" but got "LOADED"
3
PASS importScripts() on module worker should throw an exception.
4
PASS Worker construction for non-existent script should dispatch an ErrorEvent.
4
PASS Worker construction for non-existent script should dispatch an ErrorEvent.
5
PASS Static import for non-existent script should dispatch an ErrorEvent.
5
PASS Static import for non-existent script should dispatch an ErrorEvent.
6
FAIL Dynamic import for non-existent script should throw an exception. assert_equals: expected "TypeError" but got "Error"
6
PASS Dynamic import for non-existent script should throw an exception.
7
PASS Worker construction for an invalid URL should throw an exception.
7
PASS Worker construction for an invalid URL should throw an exception.
8
PASS Worker construction for a file URL should throw an exception.
8
PASS Worker construction for a file URL should throw an exception.
9
9
- a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-meta-expected.txt -6 / +3 lines
Lines 1-8 a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-meta-expected.txt_sec1
1
CONSOLE MESSAGE: SyntaxError: import.meta is only valid inside modules.
2
1
3
Harness Error (FAIL), message = SyntaxError: import.meta is only valid inside modules.
2
PASS Test import.meta.url on the top-level module script.
4
3
PASS Test import.meta.url on the imported module script.
5
FAIL Test import.meta.url on the top-level module script. promise_test: Unhandled rejection with value: "SyntaxError: import.meta is only valid inside modules."
4
PASS Test import.meta.url on the imported module script with a fragment.
6
FAIL Test import.meta.url on the imported module script. assert_true: expected true got false
7
FAIL Test import.meta.url on the imported module script with a fragment. assert_true: expected true got false
8
5
- a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-meta.html -1 / +1 lines
Lines 53-59 a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-meta.html_sec1
53
        worker.postMessage('./' + script_url + '#1');
53
        worker.postMessage('./' + script_url + '#1');
54
        return new Promise(resolve => worker.onmessage = resolve);
54
        return new Promise(resolve => worker.onmessage = resolve);
55
      })
55
      })
56
      .then(msg_event => assert_true(msg_event.data.endsWith(script_url)));
56
      .then(msg_event => assert_true(msg_event.data.endsWith(script_url + '#1')));
57
}, 'Test import.meta.url on the imported module script with a fragment.');
57
}, 'Test import.meta.url on the imported module script with a fragment.');
58
58
59
</script>
59
</script>
- a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-referrer-expected.txt -11 / +15 lines
Lines 1-19 a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import-referrer-expected.txt_sec1
1
1
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-referrer-checker.py
2
Harness Error (TIMEOUT), message = null
2
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-referrer-checker.py
3
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-referrer-checker.py
4
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-referrer-checker.py
5
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-referrer-checker.py
6
Blocked access to external URL https://www1.localhost:9443/workers/modules/resources/export-referrer-checker.py
3
7
4
PASS Same-origin top-level module script loading with "no-referrer" referrer policy
8
PASS Same-origin top-level module script loading with "no-referrer" referrer policy
5
PASS Same-origin top-level module script loading with "origin" referrer policy
9
PASS Same-origin top-level module script loading with "origin" referrer policy
6
PASS Same-origin top-level module script loading with "same-origin" referrer policy
10
PASS Same-origin top-level module script loading with "same-origin" referrer policy
7
FAIL Same-origin static import with "no-referrer" referrer policy. promise_test: Unhandled rejection with value: object "TypeError: Type error"
11
PASS Same-origin static import with "no-referrer" referrer policy.
8
FAIL Same-origin static import with "origin" referrer policy. promise_test: Unhandled rejection with value: object "TypeError: Type error"
12
PASS Same-origin static import with "origin" referrer policy.
9
FAIL Same-origin static import with "same-origin" referrer policy. promise_test: Unhandled rejection with value: object "TypeError: Type error"
13
PASS Same-origin static import with "same-origin" referrer policy.
10
FAIL Cross-origin static import with "no-referrer" referrer policy. promise_test: Unhandled rejection with value: object "TypeError: Type error"
14
FAIL Cross-origin static import with "no-referrer" referrer policy. promise_test: Unhandled rejection with value: object "TypeError: Type error"
11
FAIL Cross-origin static import with "origin" referrer policy. promise_test: Unhandled rejection with value: object "TypeError: Type error"
15
FAIL Cross-origin static import with "origin" referrer policy. promise_test: Unhandled rejection with value: object "TypeError: Type error"
12
FAIL Cross-origin static import with "same-origin" referrer policy. promise_test: Unhandled rejection with value: object "TypeError: Type error"
16
FAIL Cross-origin static import with "same-origin" referrer policy. promise_test: Unhandled rejection with value: object "TypeError: Type error"
13
TIMEOUT Same-origin dynamic import with "no-referrer" referrer policy. Test timed out
17
FAIL Same-origin dynamic import with "no-referrer" referrer policy. assert_equals: expected "" but got "http://localhost:8800/workers/modules/resources/dynamic-import-same-origin-referrer-checker-worker.js"
14
NOTRUN Same-origin dynamic import with "origin" referrer policy.
18
FAIL Same-origin dynamic import with "origin" referrer policy. assert_equals: expected "http://localhost:8800/" but got "http://localhost:8800/workers/modules/resources/dynamic-import-same-origin-referrer-checker-worker.js"
15
NOTRUN Same-origin dynamic import with "same-origin" referrer policy.
19
PASS Same-origin dynamic import with "same-origin" referrer policy.
16
NOTRUN Cross-origin dynamic import with "no-referrer" referrer policy.
20
FAIL Cross-origin dynamic import with "no-referrer" referrer policy. promise_test: Unhandled rejection with value: object "TypeError: Type error"
17
NOTRUN Cross-origin dynamic import with "origin" referrer policy.
21
FAIL Cross-origin dynamic import with "origin" referrer policy. promise_test: Unhandled rejection with value: object "TypeError: Type error"
18
NOTRUN Cross-origin dynamic import with "same-origin" referrer policy.
22
FAIL Cross-origin dynamic import with "same-origin" referrer policy. promise_test: Unhandled rejection with value: object "TypeError: Type error"
19
23
- a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import.any-expected.txt -12 / +7 lines
Lines 1-14 a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-import.any-expected.txt_sec1
1
CONSOLE MESSAGE: SyntaxError: Unexpected token '*'. import call expects exactly one argument.
2
CONSOLE MESSAGE: SyntaxError: Unexpected token '*'. import call expects exactly one argument.
3
CONSOLE MESSAGE: SyntaxError: Unexpected token '*'. import call expects exactly one argument.
4
1
5
Harness Error (FAIL), message = SyntaxError: Unexpected token '*'. import call expects exactly one argument.
2
PASS Static import.
6
3
PASS Nested static import.
7
FAIL Static import. promise_test: Unhandled rejection with value: "SyntaxError: Unexpected token '*'. import call expects exactly one argument."
4
PASS Static import and then dynamic import.
8
FAIL Nested static import. promise_test: Unhandled rejection with value: "SyntaxError: Unexpected token '*'. import call expects exactly one argument."
5
PASS Dynamic import.
9
FAIL Static import and then dynamic import. promise_test: Unhandled rejection with value: "SyntaxError: Unexpected token '*'. import call expects exactly one argument."
6
PASS Nested dynamic import.
10
FAIL Dynamic import. assert_array_equals: value is "Failed to do dynamic import: Error: Could not import the module './export-on-load-script.js'.", expected array
7
PASS Dynamic import and then static import.
11
FAIL Nested dynamic import. assert_array_equals: value is "Failed to do dynamic import: Error: Could not import the module './export-on-dynamic-import-script.js'.", expected array
8
PASS eval(import()).
12
FAIL Dynamic import and then static import. assert_array_equals: value is "Failed to do dynamic import: Error: Could not import the module './export-on-static-import-script.js'.", expected array
13
FAIL eval(import()). assert_array_equals: value is "Failed to do dynamic import: Error: Could not import the module './export-on-load-script.js'.", expected array
14
9
- a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-options-type-expected.txt -7 / +2 lines
Lines 2-12 a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-options-type-expected.txt_sec1
2
PASS Test worker construction with the default worker type.
2
PASS Test worker construction with the default worker type.
3
PASS Test worker construction with the "classic" worker type.
3
PASS Test worker construction with the "classic" worker type.
4
PASS Test worker construction with the "module" worker type.
4
PASS Test worker construction with the "module" worker type.
5
FAIL Test worker construction with an empty worker type. assert_throws_js: Worker construction with an empty type should throw an exception function "() => {
5
PASS Test worker construction with an empty worker type.
6
        new Worker('resources/post-message-on-load-worker.js', { type: '' });
6
PASS Test worker construction with an unknown worker type.
7
      }" did not throw
8
FAIL Test worker construction with an unknown worker type. assert_throws_js: Worker construction with an unknown type should throw an exception function "() => {
9
        new Worker('resources/post-message-on-load-worker.js',
10
                   { type: 'unknown' });
11
      }" did not throw
12
7
- a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-parse-error-failure-expected.txt -5 / +12 lines
Lines 1-7 a/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-parse-error-failure-expected.txt_sec1
1
CONSOLE MESSAGE: SyntaxError: Unexpected token '*'. import call expects exactly one argument.
1
CONSOLE MESSAGE: SyntaxError: Unexpected token ';'
2
CONSOLE MESSAGE: SyntaxError: Unexpected token ';'
2
3
3
Harness Error (FAIL), message = Error: assert_implements: Static import must be supported on module dedicated worker to run this test. undefined
4
FAIL Module worker construction for script with syntax error should dispatch an event named error. assert_equals: expected function "function Event() {
4
5
    [native code]
5
NOTRUN Module worker construction for script with syntax error should dispatch an event named error.
6
}" but got function "function ErrorEvent() {
6
NOTRUN Static import on module worker for script with syntax error should dispatch an event named error.
7
    [native code]
8
}"
9
FAIL Static import on module worker for script with syntax error should dispatch an event named error. assert_equals: expected function "function Event() {
10
    [native code]
11
}" but got function "function ErrorEvent() {
12
    [native code]
13
}"
7
14
- a/LayoutTests/imported/w3c/web-platform-tests/workers/name-property-expected.txt -2 / +3 lines
Lines 1-7 a/LayoutTests/imported/w3c/web-platform-tests/workers/name-property-expected.txt_sec1
1
CONSOLE MESSAGE: Unhandled Promise Rejection: ReferenceError: Can't find variable: SharedWorker
1
CONSOLE MESSAGE: Unhandled Promise Rejection: ReferenceError: Can't find variable: SharedWorker
2
2
3
FAIL Test the name property of shared and dedicated workers via the name constructor option Can't find variable: SharedWorker
3
Harness Error (FAIL), message = Unhandled rejection: Can't find variable: SharedWorker
4
PASS Declaring name as an accidental global must not cause a harness error for DedicatedWorkerGlobalScope
4
5
PASS name property value for DedicatedWorkerGlobalScope
5
PASS name property value for DedicatedWorkerGlobalScope
6
PASS name property is replaceable for DedicatedWorkerGlobalScope
6
PASS name property is replaceable for DedicatedWorkerGlobalScope
7
PASS Declaring name as an accidental global must not cause a harness error for DedicatedWorkerGlobalScope
7
8
- a/LayoutTests/imported/w3c/web-platform-tests/worklets/audio-worklet-credentials.https-expected.txt -5 / +5 lines
Lines 1-11 a/LayoutTests/imported/w3c/web-platform-tests/worklets/audio-worklet-credentials.https-expected.txt_sec1
1
CONSOLE MESSAGE: Origin https://localhost:9443 is not allowed by Access-Control-Allow-Origin.
1
CONSOLE MESSAGE: Origin https://localhost:9443 is not allowed by Access-Control-Allow-Origin.
2
2
3
FAIL Importing a same-origin script with the default WorkletOptions should send the credentials promise_test: Unhandled rejection with value: object "AbortError: Failed to fetch module, error: Response is not 2xx"
3
FAIL Importing a same-origin script with the default WorkletOptions should send the credentials promise_test: Unhandled rejection with value: object "AbortError: Importing a module script failed."
4
PASS Importing a remote-origin script with the default WorkletOptions should not send the credentials
4
PASS Importing a remote-origin script with the default WorkletOptions should not send the credentials
5
FAIL Importing a same-origin script with credentials=omit should not send the credentials promise_test: Unhandled rejection with value: object "AbortError: Failed to fetch module, error: Response is not 2xx"
5
FAIL Importing a same-origin script with credentials=omit should not send the credentials promise_test: Unhandled rejection with value: object "AbortError: Importing a module script failed."
6
PASS Importing a remote-origin script with credentials=omit should not send the credentials
6
PASS Importing a remote-origin script with credentials=omit should not send the credentials
7
FAIL Importing a same-origin script with credentials=same-origin should send the credentials promise_test: Unhandled rejection with value: object "AbortError: Failed to fetch module, error: Response is not 2xx"
7
FAIL Importing a same-origin script with credentials=same-origin should send the credentials promise_test: Unhandled rejection with value: object "AbortError: Importing a module script failed."
8
PASS Importing a remote-origin script with credentials=same-origin should not send the credentials
8
PASS Importing a remote-origin script with credentials=same-origin should not send the credentials
9
FAIL Importing a same-origin script with credentials=include should send the credentials promise_test: Unhandled rejection with value: object "AbortError: Failed to fetch module, error: Response is not 2xx"
9
FAIL Importing a same-origin script with credentials=include should send the credentials promise_test: Unhandled rejection with value: object "AbortError: Importing a module script failed."
10
FAIL Importing a remote-origin script with credentials=include should send the credentials promise_test: Unhandled rejection with value: object "AbortError: Failed to fetch module, error: Origin https://localhost:9443 is not allowed by Access-Control-Allow-Origin."
10
FAIL Importing a remote-origin script with credentials=include should send the credentials promise_test: Unhandled rejection with value: object "AbortError: Cross-origin script load denied by Cross-Origin Resource Sharing policy."
11
11
- a/LayoutTests/imported/w3c/web-platform-tests/worklets/audio-worklet-csp.https-expected.txt -10 / +22 lines
Lines 1-40 a/LayoutTests/imported/w3c/web-platform-tests/worklets/audio-worklet-csp.https-expected.txt_sec1
1
Blocked access to external URL https://www1.localhost:9443/worklets/resources/empty-worklet-script-with-cors-header.js
2
Blocked access to external URL https://www1.localhost:9443/worklets/resources/empty-worklet-script-with-cors-header.js
3
Blocked access to external URL https://www1.localhost:9443/worklets/resources/empty-worklet-script-with-cors-header.js
4
Blocked access to external URL https://www1.localhost:9443/worklets/resources/empty-worklet-script-with-cors-header.js
5
Blocked access to external URL https://www1.localhost:9443/worklets/resources/empty-worklet-script-with-cors-header.js
6
Blocked access to external URL https://www1.localhost:9443/worklets/resources/empty-worklet-script-with-cors-header.js
1
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
7
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
2
8
3
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
9
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
4
10
11
Blocked access to external URL https://www1.localhost:9443/worklets/resources/empty-worklet-script-with-cors-header.js
5
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
12
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
6
13
7
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
14
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
8
15
9
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
16
CONSOLE MESSAGE: Unrecognized Content-Security-Policy directive 'worker-src'.
10
17
18
Blocked access to external URL https://www1.localhost:9443/worklets/resources/empty-worklet-script-with-cors-header.js
11
CONSOLE MESSAGE: [blocked] The page at https://localhost:9443/worklets/resources/addmodule-window.html was not allowed to display insecure content from http://localhost:8800/worklets/resources/empty-worklet-script-with-cors-header.js.
19
CONSOLE MESSAGE: [blocked] The page at https://localhost:9443/worklets/resources/addmodule-window.html was not allowed to display insecure content from http://localhost:8800/worklets/resources/empty-worklet-script-with-cors-header.js.
12
20
13
CONSOLE MESSAGE: [blocked] The page at https://localhost:9443/worklets/resources/addmodule-window.html was not allowed to display insecure content from http://localhost:8800/worklets/resources/empty-worklet-script-with-cors-header.js.
21
CONSOLE MESSAGE: [blocked] The page at https://localhost:9443/worklets/resources/addmodule-window.html was not allowed to display insecure content from http://localhost:8800/worklets/resources/empty-worklet-script-with-cors-header.js.
14
22
23
CONSOLE MESSAGE: [blocked] The page at https://localhost:9443/worklets/resources/addmodule-window.html was not allowed to display insecure content from http://localhost:9443/worklets/resources/empty-worklet-script-with-cors-header.js.
24
25
CONSOLE MESSAGE: [blocked] The page at https://localhost:9443/worklets/resources/addmodule-window.html was not allowed to display insecure content from http://localhost:9443/worklets/resources/empty-worklet-script-with-cors-header.js.
26
15
27
16
FAIL A remote-origin worklet should be blocked by the script-src 'self' directive. assert_equals: expected "REJECTED" but got "RESOLVED"
28
FAIL A remote-origin worklet should be blocked by the script-src 'self' directive. assert_equals: expected "REJECTED" but got "RESOLVED"
17
FAIL A same-origin worklet importing a remote-origin script should be blocked by the script-src 'self' directive. assert_equals: expected "REJECTED" but got "RESOLVED"
29
PASS A same-origin worklet importing a remote-origin script should be blocked by the script-src 'self' directive.
18
FAIL A remote-origin worklet importing a remote-origin script should be blocked by the script-src 'self' directive. assert_equals: expected "REJECTED" but got "RESOLVED"
30
FAIL A remote-origin worklet importing a remote-origin script should be blocked by the script-src 'self' directive. assert_equals: expected "REJECTED" but got "RESOLVED"
19
FAIL A remote-origin-redirected worklet should be blocked by the script-src 'self' directive. assert_equals: expected "REJECTED" but got "RESOLVED"
31
FAIL A remote-origin-redirected worklet should be blocked by the script-src 'self' directive. assert_equals: expected "REJECTED" but got "RESOLVED"
20
FAIL A same-origin worklet importing a remote-origin-redirected script should be blocked by the script-src 'self' directive. assert_equals: expected "REJECTED" but got "RESOLVED"
32
PASS A same-origin worklet importing a remote-origin-redirected script should be blocked by the script-src 'self' directive.
21
PASS A remote-origin worklet should not be blocked because the script-src directive specifying the origin allows it.
33
PASS A remote-origin worklet should not be blocked because the script-src directive specifying the origin allows it.
22
PASS A same-origin worklet importing a remote-origin script should not be blocked because the script-src directive specifying the origin allows it.
34
FAIL A same-origin worklet importing a remote-origin script should not be blocked because the script-src directive specifying the origin allows it. assert_equals: expected "RESOLVED" but got "REJECTED"
23
PASS A remote-origin worklet importing a remote-origin script should not be blocked because the script-src directive specifying the origin allows it.
35
PASS A remote-origin worklet importing a remote-origin script should not be blocked because the script-src directive specifying the origin allows it.
24
PASS A remote-origin-redirected worklet should not be blocked because the script-src directive specifying the origin allows it.
36
PASS A remote-origin-redirected worklet should not be blocked because the script-src directive specifying the origin allows it.
25
PASS A same-origin worklet importing a remote-origin-redirected script should not be blocked because the script-src directive specifying the origin allows it.
37
FAIL A same-origin worklet importing a remote-origin-redirected script should not be blocked because the script-src directive specifying the origin allows it. assert_equals: expected "RESOLVED" but got "REJECTED"
26
PASS A remote-origin worklet should not be blocked because the script-src * directive allows it.
38
PASS A remote-origin worklet should not be blocked because the script-src * directive allows it.
27
PASS A same-origin worklet importing a remote-origin script should not be blocked because the script-src * directive allows it.
39
FAIL A same-origin worklet importing a remote-origin script should not be blocked because the script-src * directive allows it. assert_equals: expected "RESOLVED" but got "REJECTED"
28
PASS A remote-origin worklet importing a remote-origin script should not be blocked because the script-src * directive allows it.
40
PASS A remote-origin worklet importing a remote-origin script should not be blocked because the script-src * directive allows it.
29
PASS A remote-origin-redirected worklet should not be blocked because the script-src * directive allows it.
41
PASS A remote-origin-redirected worklet should not be blocked because the script-src * directive allows it.
30
PASS A same-origin worklet importing a remote-origin-redirected script should not be blocked because the script-src * directive allows it.
42
FAIL A same-origin worklet importing a remote-origin-redirected script should not be blocked because the script-src * directive allows it. assert_equals: expected "RESOLVED" but got "REJECTED"
31
PASS A remote-origin worklet should not be blocked by the worker-src directive because worklets obey the script-src directive.
43
PASS A remote-origin worklet should not be blocked by the worker-src directive because worklets obey the script-src directive.
32
PASS A same-origin worklet importing a remote-origin script should not be blocked by the worker-src directive because worklets obey the script-src directive.
44
FAIL A same-origin worklet importing a remote-origin script should not be blocked by the worker-src directive because worklets obey the script-src directive. assert_equals: expected "RESOLVED" but got "REJECTED"
33
PASS A remote-origin worklet importing a remote-origin script should not be blocked by the worker-src directive because worklets obey the script-src directive.
45
PASS A remote-origin worklet importing a remote-origin script should not be blocked by the worker-src directive because worklets obey the script-src directive.
34
PASS A remote-origin-redirected worklet should not be blocked by the worker-src directive because worklets obey the script-src directive.
46
PASS A remote-origin-redirected worklet should not be blocked by the worker-src directive because worklets obey the script-src directive.
35
PASS A same-origin worklet importing a remote-origin-redirected script should not be blocked by the worker-src directive because worklets obey the script-src directive.
47
FAIL A same-origin worklet importing a remote-origin-redirected script should not be blocked by the worker-src directive because worklets obey the script-src directive. assert_equals: expected "RESOLVED" but got "REJECTED"
36
PASS An insecure-origin worklet should be blocked because of mixed contents.
48
PASS An insecure-origin worklet should be blocked because of mixed contents.
37
PASS An insecure-origin-redirected worklet should be blocked because of mixed contents.
49
PASS An insecure-origin-redirected worklet should be blocked because of mixed contents.
38
FAIL A same-origin worklet importing an insecure-origin script should be blocked because of mixed contents. assert_equals: expected "REJECTED" but got "RESOLVED"
50
PASS A same-origin worklet importing an insecure-origin script should be blocked because of mixed contents.
39
FAIL A same-origin worklet importing an insecure-origin-redirected script should be blocked because of mixed contents. assert_equals: expected "REJECTED" but got "RESOLVED"
51
PASS A same-origin worklet importing an insecure-origin-redirected script should be blocked because of mixed contents.
40
52
- a/LayoutTests/imported/w3c/web-platform-tests/worklets/audio-worklet-import.https-expected.txt -3 / +3 lines
Lines 16-22 PASS Importing a cross origin resource with the Access-Control-Allow-Origin head a/LayoutTests/imported/w3c/web-platform-tests/worklets/audio-worklet-import.https-expected.txt_sec1
16
PASS Importing a cross origin resource without the Access-Control-Allow-Origin header should reject the given promise
16
PASS Importing a cross origin resource without the Access-Control-Allow-Origin header should reject the given promise
17
PASS Importing a cross-origin-redirected resource with the Access-Control-Allow-Origin header should resolve the given promise
17
PASS Importing a cross-origin-redirected resource with the Access-Control-Allow-Origin header should resolve the given promise
18
PASS Importing a cross-origin-redirected resource without the Access-Control-Allow-Origin header should reject the given promise
18
PASS Importing a cross-origin-redirected resource without the Access-Control-Allow-Origin header should reject the given promise
19
FAIL Importing a script that has a syntax error should reject the given promise. assert_unreached: Should have rejected: undefined Reached unreachable code
19
PASS Importing a script that has a syntax error should reject the given promise.
20
FAIL Importing a nested script that has a syntax error should reject the given promise. assert_unreached: Should have rejected: undefined Reached unreachable code
20
PASS Importing a nested script that has a syntax error should reject the given promise.
21
FAIL Importing a script that imports an invalid identifier should reject the given promise. assert_unreached: Should have rejected: undefined Reached unreachable code
21
PASS Importing a script that imports an invalid identifier should reject the given promise.
22
22
- a/LayoutTests/imported/w3c/web-platform-tests/worklets/audio-worklet-referrer.https-expected.txt -8 / +13 lines
Lines 1-3 a/LayoutTests/imported/w3c/web-platform-tests/worklets/audio-worklet-referrer.https-expected.txt_sec1
1
Blocked access to external URL https://www1.localhost:9443/worklets/resources/referrer-checker.py?referrer_policy=no-referrer&expected_referrer=
2
Blocked access to external URL https://www1.localhost:9443/worklets/resources/referrer-checker.py?referrer_policy=origin&expected_referrer=https://localhost:9443/
3
CONSOLE MESSAGE: Origin https://localhost:9443 is not allowed by Access-Control-Allow-Origin.
4
Blocked access to external URL https://www1.localhost:9443/worklets/resources/referrer-checker.py?referrer_policy=same-origin&expected_referrer=
5
CONSOLE MESSAGE: Origin https://localhost:9443 is not allowed by Access-Control-Allow-Origin.
1
6
2
PASS Importing a same-origin script from a page that has "no-referrer" referrer policy should not send referrer.
7
PASS Importing a same-origin script from a page that has "no-referrer" referrer policy should not send referrer.
3
PASS Importing a remote-origin script from a page that has "no-referrer" referrer policy should not send referrer.
8
PASS Importing a remote-origin script from a page that has "no-referrer" referrer policy should not send referrer.
Lines 6-20 PASS Importing a remote-origin script from a page that has "origin" referrer pol a/LayoutTests/imported/w3c/web-platform-tests/worklets/audio-worklet-referrer.https-expected.txt_sec2
6
PASS Importing a same-origin script from a page that has "same-origin" referrer policy should send referrer.
11
PASS Importing a same-origin script from a page that has "same-origin" referrer policy should send referrer.
7
PASS Importing a remote-origin script from a page that has "same-origin" referrer policy should not send referrer.
12
PASS Importing a remote-origin script from a page that has "same-origin" referrer policy should not send referrer.
8
PASS Importing a same-origin script from a same-origin worklet script that has "no-referrer" referrer policy should not send referrer.
13
PASS Importing a same-origin script from a same-origin worklet script that has "no-referrer" referrer policy should not send referrer.
9
PASS Importing a remote-origin script from a same-origin worklet script that has "no-referrer" referrer policy should not send referrer.
14
FAIL Importing a remote-origin script from a same-origin worklet script that has "no-referrer" referrer policy should not send referrer. assert_equals: expected "RESOLVED" but got "Cross-origin script load denied by Cross-Origin Resource Sharing policy."
10
PASS Importing a same-origin script from a remote-origin worklet script that has "no-referrer" referrer policy should not send referrer.
15
PASS Importing a same-origin script from a remote-origin worklet script that has "no-referrer" referrer policy should not send referrer.
11
PASS Importing a remote-origin script from a remote-origin worklet script that has "no-referrer" referrer policy should not send referrer.
16
PASS Importing a remote-origin script from a remote-origin worklet script that has "no-referrer" referrer policy should not send referrer.
12
PASS Importing a same-origin script from a same-origin worklet script that has "origin" referrer policy should send referrer.
17
PASS Importing a same-origin script from a same-origin worklet script that has "origin" referrer policy should send referrer.
13
PASS Importing a remote-origin script from a same-origin worklet script that has "origin" referrer policy should send referrer.
18
FAIL Importing a remote-origin script from a same-origin worklet script that has "origin" referrer policy should send referrer. assert_equals: expected "RESOLVED" but got "Cross-origin script load denied by Cross-Origin Resource Sharing policy."
14
PASS Importing a same-origin script from a remote-origin worklet script that has "origin" referrer policy should send referrer.
19
FAIL Importing a same-origin script from a remote-origin worklet script that has "origin" referrer policy should send referrer. assert_equals: expected "RESOLVED" but got "Importing a module script failed."
15
PASS Importing a remote-origin script from a remote-origin worklet script that has "origin" referrer policy should send referrer.
20
FAIL Importing a remote-origin script from a remote-origin worklet script that has "origin" referrer policy should send referrer. assert_equals: expected "RESOLVED" but got "Cross-origin script load denied by Cross-Origin Resource Sharing policy."
16
PASS Importing a same-origin script from a same-origin worklet script that has "same-origin" referrer policy should send referrer.
21
FAIL Importing a same-origin script from a same-origin worklet script that has "same-origin" referrer policy should send referrer. assert_equals: expected "RESOLVED" but got "Importing a module script failed."
17
PASS Importing a remote-origin script from a same-origin worklet script that has "same-origin" referrer policy should not send referrer.
22
FAIL Importing a remote-origin script from a same-origin worklet script that has "same-origin" referrer policy should not send referrer. assert_equals: expected "RESOLVED" but got "Cross-origin script load denied by Cross-Origin Resource Sharing policy."
18
PASS Importing a same-origin script from a remote-origin worklet script that has "same-origin" referrer policy should not send referrer.
23
FAIL Importing a same-origin script from a remote-origin worklet script that has "same-origin" referrer policy should not send referrer. assert_equals: expected "RESOLVED" but got "Importing a module script failed."
19
PASS Importing a remote-origin script from a remote-origin worklet script that has "same-origin" referrer policy should send referrer.
24
FAIL Importing a remote-origin script from a remote-origin worklet script that has "same-origin" referrer policy should send referrer. assert_equals: expected "RESOLVED" but got "Cross-origin script load denied by Cross-Origin Resource Sharing policy."
20
25
- a/LayoutTests/imported/w3c/web-platform-tests/xhr/open-url-redirected-worker-origin-expected.txt -1 / +1 lines
Lines 1-6 a/LayoutTests/imported/w3c/web-platform-tests/xhr/open-url-redirected-worker-origin-expected.txt_sec1
1
Blocked access to external URL http://www2.localhost:8800/xhr/resources/inspect-headers.py?filter_name=origin&cors
1
Blocked access to external URL http://www2.localhost:8800/xhr/resources/inspect-headers.py?filter_name=origin&cors
2
2
3
FAIL Referer header assert_equals: expected "Referer: http://localhost:8800/xhr/resources/workerxhr-origin-referrer.js\n" but got "Referer: http://localhost:8800/xhr/resources/redirect.py?location=workerxhr-origin-referrer.js\n"
3
PASS Referer header
4
FAIL Origin header assert_equals: expected "Origin: http://localhost:8800\n" but got ""
4
FAIL Origin header assert_equals: expected "Origin: http://localhost:8800\n" but got ""
5
PASS Request URL test
5
PASS Request URL test
6
6
- a/LayoutTests/webaudio/audioworklet-addModule-failure-expected.txt -1 / +1 lines
Lines 4-10 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE a/LayoutTests/webaudio/audioworklet-addModule-failure-expected.txt_sec1
4
4
5
5
6
PASS context.audioWorklet.addModule(invalidURL); rejected promise  with SyntaxError: Module URL is invalid.
6
PASS context.audioWorklet.addModule(invalidURL); rejected promise  with SyntaxError: Module URL is invalid.
7
PASS context.audioWorklet.addModule('doesnotExist.js'); rejected promise  with AbortError: Failed to fetch module, error: The requested URL was not found on this server..
7
PASS context.audioWorklet.addModule('doesnotExist.js'); rejected promise  with AbortError: Importing a module script failed..
8
PASS successfullyParsed is true
8
PASS successfullyParsed is true
9
9
10
TEST COMPLETE
10
TEST COMPLETE
- a/LayoutTests/webaudio/worklet-crash-expected.txt +1 lines
Line 1 a/LayoutTests/webaudio/worklet-crash-expected.txt_sec1
1
CONSOLE MESSAGE: TypeError: 'text/html' is not a valid JavaScript MIME type.
1
This test passes if it does not crash.
2
This test passes if it does not crash.

Return to Bug 164860