| Differences between
and this patch
- a/Source/JavaScriptCore/ChangeLog +29 lines
Lines 1-5 a/Source/JavaScriptCore/ChangeLog_sec1
1
2017-01-11  Yusuke Suzuki  <utatane.tea@gmail.com>
1
2017-01-11  Yusuke Suzuki  <utatane.tea@gmail.com>
2
2
3
        Support for promise rejection events (unhandledrejection)
4
        https://bugs.webkit.org/show_bug.cgi?id=150358
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Patch by Joseph Pecoraro and Yusuke Suzuki.
9
10
        * builtins/BuiltinNames.h:
11
        * builtins/PromiseOperations.js:
12
        (globalPrivate.rejectPromise):
13
        (globalPrivate.initializePromise):
14
        * builtins/PromisePrototype.js:
15
        (then):
16
        * bytecode/BytecodeIntrinsicRegistry.cpp:
17
        (JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
18
        * bytecode/BytecodeIntrinsicRegistry.h:
19
        * jsc.cpp:
20
        * runtime/JSGlobalObject.cpp:
21
        (JSC::JSGlobalObject::init):
22
        * runtime/JSGlobalObject.h:
23
        * runtime/JSGlobalObjectFunctions.cpp:
24
        (JSC::globalFuncHostPromiseRejectionTracker):
25
        * runtime/JSGlobalObjectFunctions.h:
26
        * runtime/JSPromise.cpp:
27
        (JSC::JSPromise::isHandled):
28
        * runtime/JSPromise.h:
29
30
2017-01-11  Yusuke Suzuki  <utatane.tea@gmail.com>
31
3
        Decouple module loading initiator from ScriptElement
32
        Decouple module loading initiator from ScriptElement
4
        https://bugs.webkit.org/show_bug.cgi?id=166888
33
        https://bugs.webkit.org/show_bug.cgi?id=166888
5
34
- a/Source/WebCore/ChangeLog +65 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2017-01-11  Yusuke Suzuki  <utatane.tea@gmail.com>
2
3
        Support for promise rejection events (unhandledrejection)
4
        https://bugs.webkit.org/show_bug.cgi?id=150358
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Tests: js/dom/unhandled-promise-rejection-basic.html
9
               js/dom/unhandled-promise-rejection-console-report.html
10
               js/dom/unhandled-promise-rejection-handle-during-event.html
11
               js/dom/unhandled-promise-rejection-handle-in-handler.html
12
               js/dom/unhandled-promise-rejection-handle.html
13
               js/dom/unhandled-promise-rejection-order.html
14
15
        Patch by Joseph Pecoraro and Yusuke Suzuki.
16
17
        * CMakeLists.txt:
18
        * DerivedSources.cpp:
19
        * DerivedSources.make:
20
        * WebCore.xcodeproj/project.pbxproj:
21
        * bindings/js/JSDOMConvert.h:
22
        (WebCore::Converter<IDLPromise<T>>::convert):
23
        (WebCore::JSConverter<IDLPromise<T>>::convert):
24
        * bindings/js/JSDOMWindowBase.cpp:
25
        (WebCore::JSDOMWindowBase::promiseRejectionTracker):
26
        * bindings/js/JSDOMWindowBase.h:
27
        * bindings/js/JSMainThreadExecState.cpp:
28
        (WebCore::JSMainThreadExecState::didLeaveScriptContext):
29
        * bindings/js/JSMainThreadExecState.h:
30
        (WebCore::JSMainThreadExecState::~JSMainThreadExecState):
31
        * bindings/js/JSWorkerGlobalScopeBase.cpp:
32
        * bindings/scripts/CodeGenerator.pm:
33
        (IsPromiseType):
34
        * bindings/scripts/CodeGeneratorJS.pm:
35
        (AddToIncludesForIDLType):
36
        (GetBaseIDLType):
37
        * dom/DOMAllInOne.cpp:
38
        * dom/EventNames.h:
39
        * dom/EventNames.in:
40
        * dom/GlobalEventHandlers.idl:
41
        * dom/PromiseRejectionEvent.cpp: Added.
42
        (WebCore::PromiseRejectionEvent::PromiseRejectionEvent):
43
        (WebCore::PromiseRejectionEvent::~PromiseRejectionEvent):
44
        * dom/PromiseRejectionEvent.h: Added.
45
        * dom/PromiseRejectionEvent.idl: Added.
46
        * dom/RejectedPromiseTracker.cpp: Added.
47
        (WebCore::RejectedPromise::RejectedPromise):
48
        (WebCore::RejectedPromise::promise):
49
        (WebCore::RejectedPromise::callStack):
50
        (WebCore::RejectedPromiseTracker::RejectedPromiseTracker):
51
        (WebCore::RejectedPromiseTracker::~RejectedPromiseTracker):
52
        (WebCore::createScriptCallStackFromReason):
53
        (WebCore::RejectedPromiseTracker::promiseRejected):
54
        (WebCore::RejectedPromiseTracker::promiseHandled):
55
        (WebCore::RejectedPromiseTracker::processQueueSoon):
56
        (WebCore::RejectedPromiseTracker::reportUnhandledRejection):
57
        (WebCore::RejectedPromiseTracker::reportRejectionHandled):
58
        * dom/RejectedPromiseTracker.h: Added.
59
        * dom/ScriptExecutionContext.cpp:
60
        (WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
61
        (WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
62
        * dom/ScriptExecutionContext.h:
63
        (WebCore::ScriptExecutionContext::ensureRejectedPromiseTracker):
64
        * workers/WorkerGlobalScope.idl:
65
1
2017-01-11  Ryan Haddad  <ryanhaddad@apple.com>
66
2017-01-11  Ryan Haddad  <ryanhaddad@apple.com>
2
67
3
        Attempt to fix the Windows build after r210588.
68
        Attempt to fix the Windows build after r210588.
- a/Source/JavaScriptCore/builtins/BuiltinNames.h +2 lines
Lines 83-89 namespace JSC { a/Source/JavaScriptCore/builtins/BuiltinNames.h_sec1
83
    macro(getTemplateObject) \
83
    macro(getTemplateObject) \
84
    macro(templateRegistryKey) \
84
    macro(templateRegistryKey) \
85
    macro(enqueueJob) \
85
    macro(enqueueJob) \
86
    macro(hostPromiseRejectionTracker) \
86
    macro(promiseState) \
87
    macro(promiseState) \
88
    macro(promiseIsHandled) \
87
    macro(promiseReactions) \
89
    macro(promiseReactions) \
88
    macro(promiseResult) \
90
    macro(promiseResult) \
89
    macro(onFulfilled) \
91
    macro(onFulfilled) \
- a/Source/JavaScriptCore/builtins/PromiseOperations.js +4 lines
Lines 105-110 function rejectPromise(promise, reason) a/Source/JavaScriptCore/builtins/PromiseOperations.js_sec1
105
105
106
    @InspectorInstrumentation.promiseRejected(promise, reason, reactions);
106
    @InspectorInstrumentation.promiseRejected(promise, reason, reactions);
107
107
108
    if (!promise.@promiseIsHandled)
109
        @hostPromiseRejectionTracker(promise, @promiseRejectionReject);
110
108
    @triggerPromiseReactions(@promiseStateRejected, reactions, reason);
111
    @triggerPromiseReactions(@promiseStateRejected, reactions, reason);
109
}
112
}
110
113
Lines 212-217 function initializePromise(executor) a/Source/JavaScriptCore/builtins/PromiseOperations.js_sec2
212
215
213
    this.@promiseState = @promiseStatePending;
216
    this.@promiseState = @promiseStatePending;
214
    this.@promiseReactions = [];
217
    this.@promiseReactions = [];
218
    this.@promiseIsHandled = false;
215
219
216
    var resolvingFunctions = @createResolvingFunctions(this);
220
    var resolvingFunctions = @createResolvingFunctions(this);
217
    try {
221
    try {
- a/Source/JavaScriptCore/builtins/PromisePrototype.js -1 / +6 lines
Lines 52-59 function then(onFulfilled, onRejected) a/Source/JavaScriptCore/builtins/PromisePrototype.js_sec1
52
    var state = this.@promiseState;
52
    var state = this.@promiseState;
53
    if (state === @promiseStatePending)
53
    if (state === @promiseStatePending)
54
        @putByValDirect(this.@promiseReactions, this.@promiseReactions.length, reaction);
54
        @putByValDirect(this.@promiseReactions, this.@promiseReactions.length, reaction);
55
    else
55
    else {
56
        if (state === @promiseStateRejected && !this.@promiseIsHandled)
57
            @hostPromiseRejectionTracker(this, @promiseRejectionHandle);
56
        @enqueueJob(@promiseReactionJob, [state, reaction, this.@promiseResult]);
58
        @enqueueJob(@promiseReactionJob, [state, reaction, this.@promiseResult]);
59
    }
60
61
    this.@promiseIsHandled = true;
57
62
58
    return resultCapability.@promise;
63
    return resultCapability.@promise;
59
}
64
}
- a/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp +3 lines
Lines 32-37 a/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp_sec1
32
#include "BytecodeGenerator.h"
32
#include "BytecodeGenerator.h"
33
#include "JSCJSValueInlines.h"
33
#include "JSCJSValueInlines.h"
34
#include "JSGeneratorFunction.h"
34
#include "JSGeneratorFunction.h"
35
#include "JSGlobalObject.h"
35
#include "JSModuleLoader.h"
36
#include "JSModuleLoader.h"
36
#include "JSPromise.h"
37
#include "JSPromise.h"
37
#include "Nodes.h"
38
#include "Nodes.h"
Lines 60-65 BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry(VM& vm) a/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp_sec2
60
    m_ModuleSatisfy.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Satisfy)));
61
    m_ModuleSatisfy.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Satisfy)));
61
    m_ModuleLink.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Link)));
62
    m_ModuleLink.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Link)));
62
    m_ModuleReady.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Ready)));
63
    m_ModuleReady.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Ready)));
64
    m_promiseRejectionReject.set(m_vm, jsNumber(static_cast<unsigned>(JSPromiseRejectionOperation::Reject)));
65
    m_promiseRejectionHandle.set(m_vm, jsNumber(static_cast<unsigned>(JSPromiseRejectionOperation::Handle)));
63
    m_promiseStatePending.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Pending)));
66
    m_promiseStatePending.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Pending)));
64
    m_promiseStateFulfilled.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Fulfilled)));
67
    m_promiseStateFulfilled.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Fulfilled)));
65
    m_promiseStateRejected.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Rejected)));
68
    m_promiseStateRejected.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Rejected)));
- a/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h +2 lines
Lines 72-77 class Identifier; a/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h_sec1
72
    macro(ModuleSatisfy) \
72
    macro(ModuleSatisfy) \
73
    macro(ModuleLink) \
73
    macro(ModuleLink) \
74
    macro(ModuleReady) \
74
    macro(ModuleReady) \
75
    macro(promiseRejectionReject) \
76
    macro(promiseRejectionHandle) \
75
    macro(promiseStatePending) \
77
    macro(promiseStatePending) \
76
    macro(promiseStateFulfilled) \
78
    macro(promiseStateFulfilled) \
77
    macro(promiseStateRejected) \
79
    macro(promiseStateRejected) \
- a/Source/JavaScriptCore/jsc.cpp -4 / +5 lines
Lines 1290-1303 const GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = { a/Source/JavaScriptCore/jsc.cpp_sec1
1290
    &supportsRichSourceInfo,
1290
    &supportsRichSourceInfo,
1291
    &shouldInterruptScript,
1291
    &shouldInterruptScript,
1292
    &javaScriptRuntimeFlags,
1292
    &javaScriptRuntimeFlags,
1293
    nullptr,
1293
    nullptr, // queueTaskToEventLoop
1294
    &shouldInterruptScriptBeforeTimeout,
1294
    &shouldInterruptScriptBeforeTimeout,
1295
    &moduleLoaderImportModule,
1295
    &moduleLoaderImportModule,
1296
    &moduleLoaderResolve,
1296
    &moduleLoaderResolve,
1297
    &moduleLoaderFetch,
1297
    &moduleLoaderFetch,
1298
    nullptr,
1298
    nullptr, // moduleLoaderInstantiate
1299
    nullptr,
1299
    nullptr, // moduleLoaderEvaluate
1300
    nullptr
1300
    nullptr, // promiseRejectionTracker
1301
    nullptr, // defaultLanguage
1301
};
1302
};
1302
1303
1303
GlobalObject::GlobalObject(VM& vm, Structure* structure)
1304
GlobalObject::GlobalObject(VM& vm, Structure* structure)
- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp -7 / +9 lines
Lines 250-263 const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp_sec1
250
    &supportsRichSourceInfo,
250
    &supportsRichSourceInfo,
251
    &shouldInterruptScript,
251
    &shouldInterruptScript,
252
    &javaScriptRuntimeFlags,
252
    &javaScriptRuntimeFlags,
253
    nullptr,
253
    nullptr, // queueTaskToEventLoop
254
    &shouldInterruptScriptBeforeTimeout,
254
    &shouldInterruptScriptBeforeTimeout,
255
    nullptr,
255
    nullptr, // moduleLoaderImportModule
256
    nullptr,
256
    nullptr, // moduleLoaderResolve
257
    nullptr,
257
    nullptr, // moduleLoaderFetch
258
    nullptr,
258
    nullptr, // moduleLoaderInstantiate
259
    nullptr,
259
    nullptr, // moduleLoaderEvaluate
260
    nullptr
260
    nullptr, // promiseRejectionTracker
261
    nullptr, // defaultLanguage
261
};
262
};
262
263
263
/* Source for JSGlobalObject.lut.h
264
/* Source for JSGlobalObject.lut.h
Lines 822-827 putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp_sec2
822
        GlobalPropertyInfo(vm.propertyNames->builtinNames().MapIteratorPrivateName(), JSFunction::create(vm, this, 1, String(), privateFuncMapIterator), DontEnum | DontDelete | ReadOnly),
823
        GlobalPropertyInfo(vm.propertyNames->builtinNames().MapIteratorPrivateName(), JSFunction::create(vm, this, 1, String(), privateFuncMapIterator), DontEnum | DontDelete | ReadOnly),
823
        GlobalPropertyInfo(vm.propertyNames->builtinNames().mapIteratorNextPrivateName(), JSFunction::create(vm, this, 0, String(), privateFuncMapIteratorNext), DontEnum | DontDelete | ReadOnly),
824
        GlobalPropertyInfo(vm.propertyNames->builtinNames().mapIteratorNextPrivateName(), JSFunction::create(vm, this, 0, String(), privateFuncMapIteratorNext), DontEnum | DontDelete | ReadOnly),
824
825
826
        GlobalPropertyInfo(vm.propertyNames->builtinNames().hostPromiseRejectionTrackerPrivateName(), JSFunction::create(vm, this, 2, String(), globalFuncHostPromiseRejectionTracker), DontEnum | DontDelete | ReadOnly),
825
        GlobalPropertyInfo(vm.propertyNames->builtinNames().InspectorInstrumentationPrivateName(), InspectorInstrumentationObject::create(vm, this, InspectorInstrumentationObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum | DontDelete | ReadOnly),
827
        GlobalPropertyInfo(vm.propertyNames->builtinNames().InspectorInstrumentationPrivateName(), InspectorInstrumentationObject::create(vm, this, InspectorInstrumentationObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum | DontDelete | ReadOnly),
826
        GlobalPropertyInfo(vm.propertyNames->builtinNames().MapPrivateName(), mapConstructor, DontEnum | DontDelete | ReadOnly),
828
        GlobalPropertyInfo(vm.propertyNames->builtinNames().MapPrivateName(), mapConstructor, DontEnum | DontDelete | ReadOnly),
827
        GlobalPropertyInfo(vm.propertyNames->builtinNames().thisTimeValuePrivateName(), privateFuncThisTimeValue, DontEnum | DontDelete | ReadOnly),
829
        GlobalPropertyInfo(vm.propertyNames->builtinNames().thisTimeValuePrivateName(), privateFuncThisTimeValue, DontEnum | DontDelete | ReadOnly),
- a/Source/JavaScriptCore/runtime/JSGlobalObject.h -5 / +7 lines
Lines 162-172 FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE) a/Source/JavaScriptCore/runtime/JSGlobalObject.h_sec1
162
162
163
#undef DECLARE_SIMPLE_BUILTIN_TYPE
163
#undef DECLARE_SIMPLE_BUILTIN_TYPE
164
164
165
class JSInternalPromise;
165
enum class JSPromiseRejectionOperation : unsigned {
166
class InternalPromisePrototype;
166
    Reject, // When a promise is rejected without any handlers.
167
class InternalPromiseConstructor;
167
    Handle, // When a handler is added to a rejected promise for the first time.
168
168
};
169
typedef Vector<ExecState*, 16> ExecStateStack;
170
169
171
struct GlobalObjectMethodTable {
170
struct GlobalObjectMethodTable {
172
    typedef bool (*SupportsRichSourceInfoFunctionPtr)(const JSGlobalObject*);
171
    typedef bool (*SupportsRichSourceInfoFunctionPtr)(const JSGlobalObject*);
Lines 199-204 struct GlobalObjectMethodTable { a/Source/JavaScriptCore/runtime/JSGlobalObject.h_sec2
199
    typedef JSValue (*ModuleLoaderEvaluatePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue, JSValue);
198
    typedef JSValue (*ModuleLoaderEvaluatePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue, JSValue);
200
    ModuleLoaderEvaluatePtr moduleLoaderEvaluate;
199
    ModuleLoaderEvaluatePtr moduleLoaderEvaluate;
201
200
201
    typedef void (*PromiseRejectionTrackerPtr)(JSGlobalObject*, ExecState*, JSPromise*, JSPromiseRejectionOperation);
202
    PromiseRejectionTrackerPtr promiseRejectionTracker;
203
202
    typedef String (*DefaultLanguageFunctionPtr)();
204
    typedef String (*DefaultLanguageFunctionPtr)();
203
    DefaultLanguageFunctionPtr defaultLanguage;
205
    DefaultLanguageFunctionPtr defaultLanguage;
204
};
206
};
- a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp -2 / +25 lines
Lines 30-49 a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp_sec1
30
#include "Exception.h"
30
#include "Exception.h"
31
#include "IndirectEvalExecutable.h"
31
#include "IndirectEvalExecutable.h"
32
#include "Interpreter.h"
32
#include "Interpreter.h"
33
#include "JSCInlines.h"
33
#include "JSFunction.h"
34
#include "JSFunction.h"
34
#include "JSGlobalObject.h"
35
#include "JSGlobalObject.h"
35
#include "JSInternalPromise.h"
36
#include "JSInternalPromise.h"
36
#include "JSModuleLoader.h"
37
#include "JSModuleLoader.h"
38
#include "JSPromise.h"
37
#include "JSPromiseDeferred.h"
39
#include "JSPromiseDeferred.h"
38
#include "JSString.h"
40
#include "JSString.h"
39
#include "JSStringBuilder.h"
41
#include "JSStringBuilder.h"
40
#include "Lexer.h"
42
#include "Lexer.h"
41
#include "LiteralParser.h"
43
#include "LiteralParser.h"
42
#include "Nodes.h"
44
#include "Nodes.h"
43
#include "JSCInlines.h"
44
#include "Parser.h"
45
#include "Parser.h"
45
#include "StackVisitor.h"
46
#include "StackVisitor.h"
46
#include <wtf/dtoa.h>
47
#include <stdio.h>
47
#include <stdio.h>
48
#include <stdlib.h>
48
#include <stdlib.h>
49
#include <wtf/ASCIICType.h>
49
#include <wtf/ASCIICType.h>
Lines 51-56 a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp_sec2
51
#include <wtf/HexNumber.h>
51
#include <wtf/HexNumber.h>
52
#include <wtf/MathExtras.h>
52
#include <wtf/MathExtras.h>
53
#include <wtf/StringExtras.h>
53
#include <wtf/StringExtras.h>
54
#include <wtf/dtoa.h>
54
#include <wtf/text/StringBuilder.h>
55
#include <wtf/text/StringBuilder.h>
55
#include <wtf/unicode/UTF8.h>
56
#include <wtf/unicode/UTF8.h>
56
57
Lines 922-927 EncodedJSValue JSC_HOST_CALL globalFuncProtoSetter(ExecState* exec) a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp_sec3
922
    thisObject->setPrototype(vm, exec, value, shouldThrowIfCantSet);
923
    thisObject->setPrototype(vm, exec, value, shouldThrowIfCantSet);
923
    return JSValue::encode(jsUndefined());
924
    return JSValue::encode(jsUndefined());
924
}
925
}
926
927
EncodedJSValue JSC_HOST_CALL globalFuncHostPromiseRejectionTracker(ExecState* exec)
928
{
929
    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
930
    VM& vm = globalObject->vm();
931
    auto scope = DECLARE_THROW_SCOPE(vm);
932
933
    if (!globalObject->globalObjectMethodTable()->promiseRejectionTracker)
934
        return JSValue::encode(jsUndefined());
935
936
    JSPromise* promise = jsCast<JSPromise*>(exec->argument(0));
937
    JSValue operationValue = exec->argument(1);
938
939
    ASSERT(operationValue.isNumber());
940
    auto operation = static_cast<JSPromiseRejectionOperation>(operationValue.toUInt32(exec));
941
    RETURN_IF_EXCEPTION(scope, encodedJSValue());
942
943
    globalObject->globalObjectMethodTable()->promiseRejectionTracker(globalObject, exec, promise, operation);
944
    RETURN_IF_EXCEPTION(scope, encodedJSValue());
945
946
    return JSValue::encode(jsUndefined());
947
}
925
    
948
    
926
EncodedJSValue JSC_HOST_CALL globalFuncBuiltinLog(ExecState* exec)
949
EncodedJSValue JSC_HOST_CALL globalFuncBuiltinLog(ExecState* exec)
927
{
950
{
- a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h +1 lines
Lines 49-54 EncodedJSValue JSC_HOST_CALL globalFuncThrowTypeError(ExecState*); a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h_sec1
49
EncodedJSValue JSC_HOST_CALL globalFuncThrowTypeErrorArgumentsCalleeAndCaller(ExecState*);
49
EncodedJSValue JSC_HOST_CALL globalFuncThrowTypeErrorArgumentsCalleeAndCaller(ExecState*);
50
EncodedJSValue JSC_HOST_CALL globalFuncProtoGetter(ExecState*);
50
EncodedJSValue JSC_HOST_CALL globalFuncProtoGetter(ExecState*);
51
EncodedJSValue JSC_HOST_CALL globalFuncProtoSetter(ExecState*);
51
EncodedJSValue JSC_HOST_CALL globalFuncProtoSetter(ExecState*);
52
EncodedJSValue JSC_HOST_CALL globalFuncHostPromiseRejectionTracker(ExecState*);
52
EncodedJSValue JSC_HOST_CALL globalFuncBuiltinLog(ExecState*);
53
EncodedJSValue JSC_HOST_CALL globalFuncBuiltinLog(ExecState*);
53
EncodedJSValue JSC_HOST_CALL globalFuncImportModule(ExecState*);
54
EncodedJSValue JSC_HOST_CALL globalFuncImportModule(ExecState*);
54
55
- a/Source/JavaScriptCore/runtime/JSPromise.cpp +7 lines
Lines 85-88 JSValue JSPromise::result(VM& vm) const a/Source/JavaScriptCore/runtime/JSPromise.cpp_sec1
85
    return getDirect(vm, vm.propertyNames->builtinNames().promiseResultPrivateName());
85
    return getDirect(vm, vm.propertyNames->builtinNames().promiseResultPrivateName());
86
}
86
}
87
87
88
bool JSPromise::isHandled(VM& vm) const
89
{
90
    JSValue value = getDirect(vm, vm.propertyNames->builtinNames().promiseIsHandledPrivateName());
91
    ASSERT(value.isBoolean());
92
    return value.asBoolean();
93
}
94
88
} // namespace JSC
95
} // namespace JSC
- a/Source/JavaScriptCore/runtime/JSPromise.h -1 / +2 lines
Lines 45-51 class JSPromise : public JSNonFinalObject { a/Source/JavaScriptCore/runtime/JSPromise.h_sec1
45
    };
45
    };
46
46
47
    Status status(VM&) const;
47
    Status status(VM&) const;
48
    JSValue result(VM&) const;
48
    JS_EXPORT_PRIVATE JSValue result(VM&) const;
49
    JS_EXPORT_PRIVATE bool isHandled(VM&) const;
49
50
50
    // Initialize the promise with the executor.
51
    // Initialize the promise with the executor.
51
    // This may raise a JS exception.
52
    // This may raise a JS exception.
- a/Source/WebCore/CMakeLists.txt +3 lines
Lines 439-444 set(WebCore_NON_SVG_IDL_FILES a/Source/WebCore/CMakeLists.txt_sec1
439
    dom/PopStateEvent.idl
439
    dom/PopStateEvent.idl
440
    dom/ProcessingInstruction.idl
440
    dom/ProcessingInstruction.idl
441
    dom/ProgressEvent.idl
441
    dom/ProgressEvent.idl
442
    dom/PromiseRejectionEvent.idl
442
    dom/Range.idl
443
    dom/Range.idl
443
    dom/RequestAnimationFrameCallback.idl
444
    dom/RequestAnimationFrameCallback.idl
444
    dom/SecurityPolicyViolationEvent.idl
445
    dom/SecurityPolicyViolationEvent.idl
Lines 1477-1486 set(WebCore_SOURCES a/Source/WebCore/CMakeLists.txt_sec2
1477
    dom/PositionIterator.cpp
1478
    dom/PositionIterator.cpp
1478
    dom/ProcessingInstruction.cpp
1479
    dom/ProcessingInstruction.cpp
1479
    dom/ProgressEvent.cpp
1480
    dom/ProgressEvent.cpp
1481
    dom/PromiseRejectionEvent.cpp
1480
    dom/PseudoElement.cpp
1482
    dom/PseudoElement.cpp
1481
    dom/QualifiedName.cpp
1483
    dom/QualifiedName.cpp
1482
    dom/RadioButtonGroups.cpp
1484
    dom/RadioButtonGroups.cpp
1483
    dom/Range.cpp
1485
    dom/Range.cpp
1486
    dom/RejectedPromiseTracker.cpp
1484
    dom/ScopedEventQueue.cpp
1487
    dom/ScopedEventQueue.cpp
1485
    dom/ScriptElement.cpp
1488
    dom/ScriptElement.cpp
1486
    dom/ScriptExecutionContext.cpp
1489
    dom/ScriptExecutionContext.cpp
- a/Source/WebCore/DerivedSources.cpp +1 lines
Lines 383-388 a/Source/WebCore/DerivedSources.cpp_sec1
383
#include "JSPositionOptions.cpp"
383
#include "JSPositionOptions.cpp"
384
#include "JSProcessingInstruction.cpp"
384
#include "JSProcessingInstruction.cpp"
385
#include "JSProgressEvent.cpp"
385
#include "JSProgressEvent.cpp"
386
#include "JSPromiseRejectionEvent.cpp"
386
#include "JSRadioNodeList.cpp"
387
#include "JSRadioNodeList.cpp"
387
#include "JSRange.cpp"
388
#include "JSRange.cpp"
388
#include "JSReadableByteStreamController.cpp"
389
#include "JSReadableByteStreamController.cpp"
- a/Source/WebCore/DerivedSources.make -1 / +1 lines
Lines 375-381 JS_BINDING_IDLS = \ a/Source/WebCore/DerivedSources.make_sec1
375
    $(WebCore)/dom/PopStateEvent.idl \
375
    $(WebCore)/dom/PopStateEvent.idl \
376
    $(WebCore)/dom/ProcessingInstruction.idl \
376
    $(WebCore)/dom/ProcessingInstruction.idl \
377
    $(WebCore)/dom/ProgressEvent.idl \
377
    $(WebCore)/dom/ProgressEvent.idl \
378
    $(WebCore)/dom/ProgressEvent.idl \
378
    $(WebCore)/dom/PromiseRejectionEvent.idl \
379
    $(WebCore)/dom/Range.idl \
379
    $(WebCore)/dom/Range.idl \
380
    $(WebCore)/dom/RequestAnimationFrameCallback.idl \
380
    $(WebCore)/dom/RequestAnimationFrameCallback.idl \
381
    $(WebCore)/dom/SecurityPolicyViolationEvent.idl \
381
    $(WebCore)/dom/SecurityPolicyViolationEvent.idl \
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +26 lines
Lines 4010-4015 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
4010
		A56C5B9B189F34570082D13C /* WebConsoleAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = A56C5B99189F34570082D13C /* WebConsoleAgent.h */; };
4010
		A56C5B9B189F34570082D13C /* WebConsoleAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = A56C5B99189F34570082D13C /* WebConsoleAgent.h */; };
4011
		A5732B0A136A161D005C8D7C /* DateComponents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5732B08136A161D005C8D7C /* DateComponents.cpp */; };
4011
		A5732B0A136A161D005C8D7C /* DateComponents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5732B08136A161D005C8D7C /* DateComponents.cpp */; };
4012
		A5732B0B136A161D005C8D7C /* DateComponents.h in Headers */ = {isa = PBXBuildFile; fileRef = A5732B09136A161D005C8D7C /* DateComponents.h */; settings = {ATTRIBUTES = (Private, ); }; };
4012
		A5732B0B136A161D005C8D7C /* DateComponents.h in Headers */ = {isa = PBXBuildFile; fileRef = A5732B09136A161D005C8D7C /* DateComponents.h */; settings = {ATTRIBUTES = (Private, ); }; };
4013
		A578F4351DE00EEB003DFC6A /* PromiseRejectionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A578F4331DE00ED6003DFC6A /* PromiseRejectionEvent.h */; };
4014
		A578F4361DE00EED003DFC6A /* PromiseRejectionEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A578F4321DE00ED6003DFC6A /* PromiseRejectionEvent.cpp */; };
4015
		A578F43B1DE01421003DFC6A /* JSPromiseRejectionEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A578F4391DE013FB003DFC6A /* JSPromiseRejectionEvent.cpp */; };
4016
		A578F43C1DE01423003DFC6A /* JSPromiseRejectionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A578F43A1DE013FB003DFC6A /* JSPromiseRejectionEvent.h */; };
4017
		A578F43F1DE0B630003DFC6A /* RejectedPromiseTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = A578F43E1DE0B62B003DFC6A /* RejectedPromiseTracker.h */; settings = {ATTRIBUTES = (Private, ); }; };
4018
		A578F4401DE0B634003DFC6A /* RejectedPromiseTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A578F43D1DE0B62B003DFC6A /* RejectedPromiseTracker.cpp */; };
4013
		A57FD71B1DB9423E006AE24B /* WorkerRuntimeAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A57FD7191DB94236006AE24B /* WorkerRuntimeAgent.cpp */; };
4019
		A57FD71B1DB9423E006AE24B /* WorkerRuntimeAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A57FD7191DB94236006AE24B /* WorkerRuntimeAgent.cpp */; };
4014
		A57FD71C1DB9423E006AE24B /* WorkerRuntimeAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = A57FD71A1DB94236006AE24B /* WorkerRuntimeAgent.h */; };
4020
		A57FD71C1DB9423E006AE24B /* WorkerRuntimeAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = A57FD71A1DB94236006AE24B /* WorkerRuntimeAgent.h */; };
4015
		A5840E1C187B74D500843B10 /* InspectorInstrumentationCookie.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5840E1A187B74D500843B10 /* InspectorInstrumentationCookie.cpp */; };
4021
		A5840E1C187B74D500843B10 /* InspectorInstrumentationCookie.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5840E1A187B74D500843B10 /* InspectorInstrumentationCookie.cpp */; };
Lines 11680-11685 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
11680
		A56C5B99189F34570082D13C /* WebConsoleAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebConsoleAgent.h; sourceTree = "<group>"; };
11686
		A56C5B99189F34570082D13C /* WebConsoleAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebConsoleAgent.h; sourceTree = "<group>"; };
11681
		A5732B08136A161D005C8D7C /* DateComponents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DateComponents.cpp; sourceTree = "<group>"; };
11687
		A5732B08136A161D005C8D7C /* DateComponents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DateComponents.cpp; sourceTree = "<group>"; };
11682
		A5732B09136A161D005C8D7C /* DateComponents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DateComponents.h; sourceTree = "<group>"; };
11688
		A5732B09136A161D005C8D7C /* DateComponents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DateComponents.h; sourceTree = "<group>"; };
11689
		A578F4321DE00ED6003DFC6A /* PromiseRejectionEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PromiseRejectionEvent.cpp; sourceTree = "<group>"; };
11690
		A578F4331DE00ED6003DFC6A /* PromiseRejectionEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PromiseRejectionEvent.h; sourceTree = "<group>"; };
11691
		A578F4341DE00ED6003DFC6A /* PromiseRejectionEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PromiseRejectionEvent.idl; sourceTree = "<group>"; };
11692
		A578F4391DE013FB003DFC6A /* JSPromiseRejectionEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPromiseRejectionEvent.cpp; sourceTree = "<group>"; };
11693
		A578F43A1DE013FB003DFC6A /* JSPromiseRejectionEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPromiseRejectionEvent.h; sourceTree = "<group>"; };
11694
		A578F43D1DE0B62B003DFC6A /* RejectedPromiseTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RejectedPromiseTracker.cpp; sourceTree = "<group>"; };
11695
		A578F43E1DE0B62B003DFC6A /* RejectedPromiseTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RejectedPromiseTracker.h; sourceTree = "<group>"; };
11683
		A57FD7191DB94236006AE24B /* WorkerRuntimeAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerRuntimeAgent.cpp; sourceTree = "<group>"; };
11696
		A57FD7191DB94236006AE24B /* WorkerRuntimeAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerRuntimeAgent.cpp; sourceTree = "<group>"; };
11684
		A57FD71A1DB94236006AE24B /* WorkerRuntimeAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerRuntimeAgent.h; sourceTree = "<group>"; };
11697
		A57FD71A1DB94236006AE24B /* WorkerRuntimeAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerRuntimeAgent.h; sourceTree = "<group>"; };
11685
		A5840E1A187B74D500843B10 /* InspectorInstrumentationCookie.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorInstrumentationCookie.cpp; sourceTree = "<group>"; };
11698
		A5840E1A187B74D500843B10 /* InspectorInstrumentationCookie.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorInstrumentationCookie.cpp; sourceTree = "<group>"; };
Lines 20697-20702 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
20697
				E1284BAF10449FFA00EAEB52 /* JSPageTransitionEvent.h */,
20710
				E1284BAF10449FFA00EAEB52 /* JSPageTransitionEvent.h */,
20698
				5189F01B10B37BD900F3C739 /* JSPopStateEvent.cpp */,
20711
				5189F01B10B37BD900F3C739 /* JSPopStateEvent.cpp */,
20699
				5189F01C10B37BD900F3C739 /* JSPopStateEvent.h */,
20712
				5189F01C10B37BD900F3C739 /* JSPopStateEvent.h */,
20713
				A578F4391DE013FB003DFC6A /* JSPromiseRejectionEvent.cpp */,
20714
				A578F43A1DE013FB003DFC6A /* JSPromiseRejectionEvent.h */,
20700
				CED06ACE1C77754800FDFAF1 /* JSSecurityPolicyViolationEvent.cpp */,
20715
				CED06ACE1C77754800FDFAF1 /* JSSecurityPolicyViolationEvent.cpp */,
20701
				CED06ACF1C77754800FDFAF1 /* JSSecurityPolicyViolationEvent.h */,
20716
				CED06ACF1C77754800FDFAF1 /* JSSecurityPolicyViolationEvent.h */,
20702
				A86629CE09DA2B47009633A7 /* JSStaticRange.cpp */,
20717
				A86629CE09DA2B47009633A7 /* JSStaticRange.cpp */,
Lines 24283-24288 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
24283
				E4B41E010CBF8EAA00AF2ECE /* ProgressEvent.cpp */,
24298
				E4B41E010CBF8EAA00AF2ECE /* ProgressEvent.cpp */,
24284
				E4B41E020CBF8EAA00AF2ECE /* ProgressEvent.h */,
24299
				E4B41E020CBF8EAA00AF2ECE /* ProgressEvent.h */,
24285
				E4B41E030CBF8EAA00AF2ECE /* ProgressEvent.idl */,
24300
				E4B41E030CBF8EAA00AF2ECE /* ProgressEvent.idl */,
24301
				A578F4321DE00ED6003DFC6A /* PromiseRejectionEvent.cpp */,
24302
				A578F4331DE00ED6003DFC6A /* PromiseRejectionEvent.h */,
24303
				A578F4341DE00ED6003DFC6A /* PromiseRejectionEvent.idl */,
24286
				FF945EC9161F7F3600971BC8 /* PseudoElement.cpp */,
24304
				FF945EC9161F7F3600971BC8 /* PseudoElement.cpp */,
24287
				FF945ECA161F7F3600971BC8 /* PseudoElement.h */,
24305
				FF945ECA161F7F3600971BC8 /* PseudoElement.h */,
24288
				550A0BC7085F6039007353D6 /* QualifiedName.cpp */,
24306
				550A0BC7085F6039007353D6 /* QualifiedName.cpp */,
Lines 24295-24300 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec5
24295
				93D9D53B0DA27E180077216C /* RangeBoundaryPoint.h */,
24313
				93D9D53B0DA27E180077216C /* RangeBoundaryPoint.h */,
24296
				A84D827B11D333ED00972990 /* RawDataDocumentParser.h */,
24314
				A84D827B11D333ED00972990 /* RawDataDocumentParser.h */,
24297
				85031B360A44EFC700F992E0 /* RegisteredEventListener.h */,
24315
				85031B360A44EFC700F992E0 /* RegisteredEventListener.h */,
24316
				A578F43D1DE0B62B003DFC6A /* RejectedPromiseTracker.cpp */,
24317
				A578F43E1DE0B62B003DFC6A /* RejectedPromiseTracker.h */,
24298
				A76E5F7E135E0DCF00A69837 /* RenderedDocumentMarker.h */,
24318
				A76E5F7E135E0DCF00A69837 /* RenderedDocumentMarker.h */,
24299
				4998AEC413F9D0EA0090B1AA /* RequestAnimationFrameCallback.h */,
24319
				4998AEC413F9D0EA0090B1AA /* RequestAnimationFrameCallback.h */,
24300
				4998AEC513F9D0EA0090B1AA /* RequestAnimationFrameCallback.idl */,
24320
				4998AEC513F9D0EA0090B1AA /* RequestAnimationFrameCallback.idl */,
Lines 25285-25290 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec6
25285
				BC772B3C0C4EA91E0083285F /* CSSHelper.h in Headers */,
25305
				BC772B3C0C4EA91E0083285F /* CSSHelper.h in Headers */,
25286
				BC23EE920DAED2BC009FDC91 /* CSSImageGeneratorValue.h in Headers */,
25306
				BC23EE920DAED2BC009FDC91 /* CSSImageGeneratorValue.h in Headers */,
25287
				9393E600151A99F200066F06 /* CSSImageSetValue.h in Headers */,
25307
				9393E600151A99F200066F06 /* CSSImageSetValue.h in Headers */,
25308
				A578F4351DE00EEB003DFC6A /* PromiseRejectionEvent.h in Headers */,
25288
				A80E6CFA0A1989CA007FB8C5 /* CSSImageValue.h in Headers */,
25309
				A80E6CFA0A1989CA007FB8C5 /* CSSImageValue.h in Headers */,
25289
				A80E6CF60A1989CA007FB8C5 /* CSSImportRule.h in Headers */,
25310
				A80E6CF60A1989CA007FB8C5 /* CSSImportRule.h in Headers */,
25290
				A80E6D010A1989CA007FB8C5 /* CSSInheritedValue.h in Headers */,
25311
				A80E6D010A1989CA007FB8C5 /* CSSInheritedValue.h in Headers */,
Lines 25462-25467 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec7
25462
				86D982F7125C154000AD9E3D /* DocumentTiming.h in Headers */,
25483
				86D982F7125C154000AD9E3D /* DocumentTiming.h in Headers */,
25463
				A8185F3909765766005826D9 /* DocumentType.h in Headers */,
25484
				A8185F3909765766005826D9 /* DocumentType.h in Headers */,
25464
				973889A1116EA9DC00ADF313 /* DocumentWriter.h in Headers */,
25485
				973889A1116EA9DC00ADF313 /* DocumentWriter.h in Headers */,
25486
				A578F43C1DE01423003DFC6A /* JSPromiseRejectionEvent.h in Headers */,
25465
				1A8F6BC30DB55CDC001DB794 /* DOMApplicationCache.h in Headers */,
25487
				1A8F6BC30DB55CDC001DB794 /* DOMApplicationCache.h in Headers */,
25466
				B56576E817DA94E200A56BDC /* DOMConstructorWithDocument.h in Headers */,
25488
				B56576E817DA94E200A56BDC /* DOMConstructorWithDocument.h in Headers */,
25467
				BC60D6E90D28D83400B9918F /* DOMCoreException.h in Headers */,
25489
				BC60D6E90D28D83400B9918F /* DOMCoreException.h in Headers */,
Lines 27129-27134 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec8
27129
				499B3EC5128CCC4700E726C2 /* PlatformCALayer.h in Headers */,
27151
				499B3EC5128CCC4700E726C2 /* PlatformCALayer.h in Headers */,
27130
				493E5E0912D6420500020081 /* PlatformCALayerClient.h in Headers */,
27152
				493E5E0912D6420500020081 /* PlatformCALayerClient.h in Headers */,
27131
				2D70BA1318074DDF0001908A /* PlatformCALayerCocoa.h in Headers */,
27153
				2D70BA1318074DDF0001908A /* PlatformCALayerCocoa.h in Headers */,
27154
				A578F43F1DE0B630003DFC6A /* RejectedPromiseTracker.h in Headers */,
27132
				A14978711ABAF3A500CEF7E4 /* PlatformContentFilter.h in Headers */,
27155
				A14978711ABAF3A500CEF7E4 /* PlatformContentFilter.h in Headers */,
27133
				E1424C8A164B3B4E00F32D40 /* PlatformCookieJar.h in Headers */,
27156
				E1424C8A164B3B4E00F32D40 /* PlatformCookieJar.h in Headers */,
27134
				BC5C762B1497FE1400BC4775 /* PlatformEvent.h in Headers */,
27157
				BC5C762B1497FE1400BC4775 /* PlatformEvent.h in Headers */,
Lines 29818-29823 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec9
29818
				BC946346107A934B00857193 /* JSBeforeLoadEvent.cpp in Sources */,
29841
				BC946346107A934B00857193 /* JSBeforeLoadEvent.cpp in Sources */,
29819
				70F546E8B8B5D7DC54EE144E /* JSBeforeUnloadEvent.cpp in Sources */,
29842
				70F546E8B8B5D7DC54EE144E /* JSBeforeUnloadEvent.cpp in Sources */,
29820
				FDF09DC81399B62200688E5B /* JSBiquadFilterNode.cpp in Sources */,
29843
				FDF09DC81399B62200688E5B /* JSBiquadFilterNode.cpp in Sources */,
29844
				A578F43B1DE01421003DFC6A /* JSPromiseRejectionEvent.cpp in Sources */,
29821
				2E2D99CD10E2BBDA00496337 /* JSBlob.cpp in Sources */,
29845
				2E2D99CD10E2BBDA00496337 /* JSBlob.cpp in Sources */,
29822
				8931DE5B14C44C44000DC9D2 /* JSBlobCustom.cpp in Sources */,
29846
				8931DE5B14C44C44000DC9D2 /* JSBlobCustom.cpp in Sources */,
29823
				7C77C3DB1DEF86D700A50BFA /* JSBlobLineEndings.cpp in Sources */,
29847
				7C77C3DB1DEF86D700A50BFA /* JSBlobLineEndings.cpp in Sources */,
Lines 30642-30647 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec10
30642
				2D9BF7471DBFDC49007A7D99 /* MediaKeyMessageEvent.cpp in Sources */,
30666
				2D9BF7471DBFDC49007A7D99 /* MediaKeyMessageEvent.cpp in Sources */,
30643
				2D9BF7461DBFDC47007A7D99 /* MediaKeys.cpp in Sources */,
30667
				2D9BF7461DBFDC47007A7D99 /* MediaKeys.cpp in Sources */,
30644
				2D9BF7451DBFDC44007A7D99 /* MediaKeySession.cpp in Sources */,
30668
				2D9BF7451DBFDC44007A7D99 /* MediaKeySession.cpp in Sources */,
30669
				A578F4401DE0B634003DFC6A /* RejectedPromiseTracker.cpp in Sources */,
30645
				2D9BF7441DBFDC41007A7D99 /* MediaKeyStatusMap.cpp in Sources */,
30670
				2D9BF7441DBFDC41007A7D99 /* MediaKeyStatusMap.cpp in Sources */,
30646
				2D9BF7431DBFDC3E007A7D99 /* MediaKeySystemAccess.cpp in Sources */,
30671
				2D9BF7431DBFDC3E007A7D99 /* MediaKeySystemAccess.cpp in Sources */,
30647
				A8EA80090A19516E00A8EF5F /* MediaList.cpp in Sources */,
30672
				A8EA80090A19516E00A8EF5F /* MediaList.cpp in Sources */,
Lines 31856-31861 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec11
31856
				93309E23099E64920056E581 /* WrapContentsInDummySpanCommand.cpp in Sources */,
31881
				93309E23099E64920056E581 /* WrapContentsInDummySpanCommand.cpp in Sources */,
31857
				A833C7CC0A2CF07400D57664 /* XLinkNames.cpp in Sources */,
31882
				A833C7CC0A2CF07400D57664 /* XLinkNames.cpp in Sources */,
31858
				00B9318713BA8DB30035A948 /* XMLDocumentParser.cpp in Sources */,
31883
				00B9318713BA8DB30035A948 /* XMLDocumentParser.cpp in Sources */,
31884
				A578F4361DE00EED003DFC6A /* PromiseRejectionEvent.cpp in Sources */,
31859
				00B9318913BA8DBC0035A948 /* XMLDocumentParserLibxml2.cpp in Sources */,
31885
				00B9318913BA8DBC0035A948 /* XMLDocumentParserLibxml2.cpp in Sources */,
31860
				00B9318B13BA8DC90035A948 /* XMLDocumentParserScope.cpp in Sources */,
31886
				00B9318B13BA8DC90035A948 /* XMLDocumentParserScope.cpp in Sources */,
31861
				59C28045138DC2410079B7E2 /* XMLErrors.cpp in Sources */,
31887
				59C28045138DC2410079B7E2 /* XMLErrors.cpp in Sources */,
- a/Source/WebCore/bindings/js/JSDOMConvert.h +26 lines
Lines 1315-1320 template<typename K, typename V> struct JSConverter<IDLRecord<K, V>> { a/Source/WebCore/bindings/js/JSDOMConvert.h_sec1
1315
};
1315
};
1316
1316
1317
// MARK: -
1317
// MARK: -
1318
// MARK: Promise type
1319
1320
// FIXME: Implement IDLPromise<> conversions based on https://heycam.github.io/webidl/#es-promise.
1321
// https://bugs.webkit.org/show_bug.cgi?id=166752
1322
template<typename T> struct Converter<IDLPromise<T>> : DefaultConverter<IDLPromise<T>> {
1323
    using ReturnType = JSC::JSValue;
1324
1325
    static JSC::JSValue convert(JSC::ExecState&, JSC::JSValue value)
1326
    {
1327
        return value;
1328
    }
1329
};
1330
1331
template<typename T> struct JSConverter<IDLPromise<T>> {
1332
    using Type = JSC::JSValue;
1333
1334
    static constexpr bool needsState = false;
1335
    static constexpr bool needsGlobalObject = false;
1336
1337
    static JSC::JSValue convert(JSC::JSValue value)
1338
    {
1339
        return value;
1340
    }
1341
};
1342
1343
// MARK: -
1318
// MARK: Dictionary type
1344
// MARK: Dictionary type
1319
1345
1320
template<typename T> struct Converter<IDLDictionary<T>> : DefaultConverter<IDLDictionary<T>> {
1346
template<typename T> struct Converter<IDLDictionary<T>> : DefaultConverter<IDLDictionary<T>> {
- a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp -3 / +29 lines
Lines 37-42 a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp_sec1
37
#include "Language.h"
37
#include "Language.h"
38
#include "Logging.h"
38
#include "Logging.h"
39
#include "Page.h"
39
#include "Page.h"
40
#include "RejectedPromiseTracker.h"
40
#include "RuntimeApplicationChecks.h"
41
#include "RuntimeApplicationChecks.h"
41
#include "ScriptController.h"
42
#include "ScriptController.h"
42
#include "ScriptModuleLoader.h"
43
#include "ScriptModuleLoader.h"
Lines 44-49 a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp_sec2
44
#include "Settings.h"
45
#include "Settings.h"
45
#include "WebCoreJSClientData.h"
46
#include "WebCoreJSClientData.h"
46
#include <heap/StrongInlines.h>
47
#include <heap/StrongInlines.h>
48
#include <runtime/JSInternalPromise.h>
47
#include <runtime/JSInternalPromiseDeferred.h>
49
#include <runtime/JSInternalPromiseDeferred.h>
48
#include <runtime/Microtask.h>
50
#include <runtime/Microtask.h>
49
#include <wtf/MainThread.h>
51
#include <wtf/MainThread.h>
Lines 64-74 const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp_sec3
64
    &javaScriptRuntimeFlags,
66
    &javaScriptRuntimeFlags,
65
    &queueTaskToEventLoop,
67
    &queueTaskToEventLoop,
66
    &shouldInterruptScriptBeforeTimeout,
68
    &shouldInterruptScriptBeforeTimeout,
67
    nullptr,
69
    nullptr, // moduleLoaderImportModule
68
    &moduleLoaderResolve,
70
    &moduleLoaderResolve,
69
    &moduleLoaderFetch,
71
    &moduleLoaderFetch,
70
    nullptr,
72
    nullptr, // moduleLoaderInstantiate
71
    &moduleLoaderEvaluate,
73
    &moduleLoaderEvaluate,
74
    &promiseRejectionTracker,
72
    &defaultLanguage
75
    &defaultLanguage
73
};
76
};
74
77
Lines 304-310 void JSDOMWindowBase::fireFrameClearedWatchpointsForWindow(DOMWindow* window) a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp_sec4
304
    }
307
    }
305
}
308
}
306
309
307
308
JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderResolve(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleName, JSC::JSValue importerModuleKey, JSC::JSValue scriptFetcher)
310
JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderResolve(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleName, JSC::JSValue importerModuleKey, JSC::JSValue scriptFetcher)
309
{
311
{
310
    JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
312
    JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
Lines 331-334 JSC::JSValue JSDOMWindowBase::moduleLoaderEvaluate(JSC::JSGlobalObject* globalOb a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp_sec5
331
    return JSC::jsUndefined();
333
    return JSC::jsUndefined();
332
}
334
}
333
335
336
void JSDOMWindowBase::promiseRejectionTracker(JSGlobalObject* globalObject, ExecState* exec, JSPromise* promise, JSPromiseRejectionOperation operation)
337
{
338
    auto* context = JSC::jsCast<JSDOMWindowBase*>(globalObject)->scriptExecutionContext();
339
    if (!context)
340
        return;
341
342
    // The state of InternalPromise is hidden in the browser side.
343
    if (JSC::jsDynamicCast<JSC::JSInternalPromise*>(promise))
344
        return;
345
346
    // FIXME: Cross origin check.
347
    auto sourceOrigin = exec->callerSourceOrigin();
348
    UNUSED_PARAM(sourceOrigin);
349
350
    switch (operation) {
351
    case JSPromiseRejectionOperation::Reject:
352
        context->ensureRejectedPromiseTracker().promiseRejected(*exec, promise);
353
        break;
354
    case JSPromiseRejectionOperation::Handle:
355
        context->ensureRejectedPromiseTracker().promiseHandled(*exec, promise);
356
        break;
357
    }
358
}
359
334
} // namespace WebCore
360
} // namespace WebCore
- a/Source/WebCore/bindings/js/JSDOMWindowBase.h +1 lines
Lines 79-84 namespace WebCore { a/Source/WebCore/bindings/js/JSDOMWindowBase.h_sec1
79
        static JSC::JSInternalPromise* moduleLoaderResolve(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue);
79
        static JSC::JSInternalPromise* moduleLoaderResolve(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue);
80
        static JSC::JSInternalPromise* moduleLoaderFetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue);
80
        static JSC::JSInternalPromise* moduleLoaderFetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue);
81
        static JSC::JSValue moduleLoaderEvaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue);
81
        static JSC::JSValue moduleLoaderEvaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue);
82
        static void promiseRejectionTracker(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSPromise*, JSC::JSPromiseRejectionOperation);
82
83
83
        RefPtr<DOMWindow> m_wrapped;
84
        RefPtr<DOMWindow> m_wrapped;
84
        JSDOMWindowShell* m_shell;
85
        JSDOMWindowShell* m_shell;
- a/Source/WebCore/bindings/js/JSMainThreadExecState.cpp -1 / +4 lines
Lines 28-41 a/Source/WebCore/bindings/js/JSMainThreadExecState.cpp_sec1
28
28
29
#include "Microtasks.h"
29
#include "Microtasks.h"
30
#include "MutationObserver.h"
30
#include "MutationObserver.h"
31
#include "ScriptExecutionContext.h"
32
#include "ScriptState.h"
31
33
32
namespace WebCore {
34
namespace WebCore {
33
35
34
JSC::ExecState* JSMainThreadExecState::s_mainThreadState = 0;
36
JSC::ExecState* JSMainThreadExecState::s_mainThreadState = 0;
35
37
36
void JSMainThreadExecState::didLeaveScriptContext()
38
void JSMainThreadExecState::didLeaveScriptContext(JSC::ExecState* exec)
37
{
39
{
38
    MicrotaskQueue::mainThreadQueue().performMicrotaskCheckpoint();
40
    MicrotaskQueue::mainThreadQueue().performMicrotaskCheckpoint();
41
    scriptExecutionContextFromExecState(exec)->ensureRejectedPromiseTracker().processQueueSoon();
39
}
42
}
40
43
41
JSC::JSValue functionCallHandlerFromAnyThread(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, NakedPtr<JSC::Exception>& returnedException)
44
JSC::JSValue functionCallHandlerFromAnyThread(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, NakedPtr<JSC::Exception>& returnedException)
- a/Source/WebCore/bindings/js/JSMainThreadExecState.h -2 / +3 lines
Lines 139-150 class JSMainThreadExecState { a/Source/WebCore/bindings/js/JSMainThreadExecState.h_sec1
139
        ASSERT(isMainThread());
139
        ASSERT(isMainThread());
140
        ASSERT_UNUSED(scope, !scope.exception());
140
        ASSERT_UNUSED(scope, !scope.exception());
141
141
142
        JSC::ExecState* state = s_mainThreadState;
142
        bool didExitJavaScript = s_mainThreadState && !m_previousState;
143
        bool didExitJavaScript = s_mainThreadState && !m_previousState;
143
144
144
        s_mainThreadState = m_previousState;
145
        s_mainThreadState = m_previousState;
145
146
146
        if (didExitJavaScript)
147
        if (didExitJavaScript)
147
            didLeaveScriptContext();
148
            didLeaveScriptContext(state);
148
    }
149
    }
149
150
150
    template<typename Type, Type jsType, typename DataType> static InspectorInstrumentationCookie instrumentFunctionInternal(ScriptExecutionContext*, Type, const DataType&);
151
    template<typename Type, Type jsType, typename DataType> static InspectorInstrumentationCookie instrumentFunctionInternal(ScriptExecutionContext*, Type, const DataType&);
Lines 153-159 class JSMainThreadExecState { a/Source/WebCore/bindings/js/JSMainThreadExecState.h_sec2
153
    JSC::ExecState* m_previousState;
154
    JSC::ExecState* m_previousState;
154
    JSC::JSLockHolder m_lock;
155
    JSC::JSLockHolder m_lock;
155
156
156
    static void didLeaveScriptContext();
157
    static void didLeaveScriptContext(JSC::ExecState*);
157
};
158
};
158
159
159
// Null state prevents origin security checks.
160
// Null state prevents origin security checks.
- a/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp -5 / +5 lines
Lines 53-63 const GlobalObjectMethodTable JSWorkerGlobalScopeBase::s_globalObjectMethodTable a/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp_sec1
53
    &javaScriptRuntimeFlags,
53
    &javaScriptRuntimeFlags,
54
    &queueTaskToEventLoop,
54
    &queueTaskToEventLoop,
55
    &shouldInterruptScriptBeforeTimeout,
55
    &shouldInterruptScriptBeforeTimeout,
56
    nullptr,
56
    nullptr, // moduleLoaderResolve
57
    nullptr,
57
    nullptr, // moduleLoaderFetch
58
    nullptr,
58
    nullptr, // moduleLoaderInstantiate
59
    nullptr,
59
    nullptr, // moduleLoaderEvaluate
60
    nullptr,
60
    nullptr, // promiseRejectionTracker
61
    &defaultLanguage
61
    &defaultLanguage
62
};
62
};
63
63
- a/Source/WebCore/bindings/scripts/CodeGenerator.pm +9 lines
Lines 677-682 sub IsRecordType a/Source/WebCore/bindings/scripts/CodeGenerator.pm_sec1
677
    return $type->name eq "record";
677
    return $type->name eq "record";
678
}
678
}
679
679
680
sub IsPromiseType
681
{
682
    my ($object, $type) = @_;
683
684
    assert("Not a type") if ref($type) ne "IDLType";
685
686
    return $type->name eq "Promise";
687
}
688
680
# These match WK_lcfirst and WK_ucfirst defined in builtins_generator.py.
689
# These match WK_lcfirst and WK_ucfirst defined in builtins_generator.py.
681
# Uppercase the first letter while respecting WebKit style guidelines.
690
# Uppercase the first letter while respecting WebKit style guidelines.
682
# E.g., xmlEncoding becomes XMLEncoding, but xmlllang becomes Xmllang.
691
# E.g., xmlEncoding becomes XMLEncoding, but xmlllang becomes Xmllang.
- a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm +7 lines
Lines 303-308 sub AddToIncludesForIDLType a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm_sec1
303
        return;
303
        return;
304
    }
304
    }
305
305
306
    if ($codeGenerator->IsPromiseType($type)) {
307
        AddToIncludes("JSDOMPromise.h", $includesRef, $conditional);
308
        AddToIncludesForIDLType(@{$type->subtypes}[0], $includesRef, $conditional);
309
        return;
310
    }
311
306
    if ($codeGenerator->IsWrapperType($type) || $codeGenerator->IsExternalDictionaryType($type) || $codeGenerator->IsExternalEnumType($type) || $type->name eq "EventListener") {
312
    if ($codeGenerator->IsWrapperType($type) || $codeGenerator->IsExternalDictionaryType($type) || $codeGenerator->IsExternalEnumType($type) || $type->name eq "EventListener") {
307
        AddToIncludes("JS" . $type->name . ".h", $includesRef, $conditional);
313
        AddToIncludes("JS" . $type->name . ".h", $includesRef, $conditional);
308
        return;
314
        return;
Lines 5126-5131 sub GetBaseIDLType a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm_sec2
5126
    return "IDLSequence<" . GetIDLType($interface, @{$type->subtypes}[0]) . ">" if $codeGenerator->IsSequenceType($type);
5132
    return "IDLSequence<" . GetIDLType($interface, @{$type->subtypes}[0]) . ">" if $codeGenerator->IsSequenceType($type);
5127
    return "IDLFrozenArray<" . GetIDLType($interface, @{$type->subtypes}[0]) . ">" if $codeGenerator->IsFrozenArrayType($type);
5133
    return "IDLFrozenArray<" . GetIDLType($interface, @{$type->subtypes}[0]) . ">" if $codeGenerator->IsFrozenArrayType($type);
5128
    return "IDLRecord<" . GetIDLType($interface, @{$type->subtypes}[0]) . ", " . GetIDLType($interface, @{$type->subtypes}[1]) . ">" if $codeGenerator->IsRecordType($type);
5134
    return "IDLRecord<" . GetIDLType($interface, @{$type->subtypes}[0]) . ", " . GetIDLType($interface, @{$type->subtypes}[1]) . ">" if $codeGenerator->IsRecordType($type);
5135
    return "IDLPromise<" . GetIDLType($interface, @{$type->subtypes}[0]) . ">" if $codeGenerator->IsPromiseType($type);
5129
    return "IDLUnion<" . join(", ", GetIDLUnionMemberTypes($interface, $type)) . ">" if $type->isUnion;
5136
    return "IDLUnion<" . join(", ", GetIDLUnionMemberTypes($interface, $type)) . ">" if $type->isUnion;
5130
    return "IDLCallbackFunction<" . GetCallbackClassName($type->name) . ">" if $codeGenerator->IsCallbackFunction($type);
5137
    return "IDLCallbackFunction<" . GetCallbackClassName($type->name) . ">" if $codeGenerator->IsCallbackFunction($type);
5131
    return "IDLCallbackInterface<" . GetCallbackClassName($type->name) . ">" if $codeGenerator->IsCallbackInterface($type);
5138
    return "IDLCallbackInterface<" . GetCallbackClassName($type->name) . ">" if $codeGenerator->IsCallbackInterface($type);
- a/Source/WebCore/dom/DOMAllInOne.cpp +1 lines
Lines 126-131 a/Source/WebCore/dom/DOMAllInOne.cpp_sec1
126
// #include "QualifiedName.cpp"
126
// #include "QualifiedName.cpp"
127
#include "RadioButtonGroups.cpp"
127
#include "RadioButtonGroups.cpp"
128
#include "Range.cpp"
128
#include "Range.cpp"
129
#include "RejectedPromiseTracker.cpp"
129
#include "ScopedEventQueue.cpp"
130
#include "ScopedEventQueue.cpp"
130
#include "ScriptElement.cpp"
131
#include "ScriptElement.cpp"
131
#include "ScriptExecutionContext.cpp"
132
#include "ScriptExecutionContext.cpp"
- a/Source/WebCore/dom/EventNames.h +2 lines
Lines 180-185 namespace WebCore { a/Source/WebCore/dom/EventNames.h_sec1
180
    macro(progress) \
180
    macro(progress) \
181
    macro(ratechange) \
181
    macro(ratechange) \
182
    macro(readystatechange) \
182
    macro(readystatechange) \
183
    macro(rejectionhandled) \
183
    macro(removesourcebuffer) \
184
    macro(removesourcebuffer) \
184
    macro(removestream) \
185
    macro(removestream) \
185
    macro(removetrack) \
186
    macro(removetrack) \
Lines 228-233 namespace WebCore { a/Source/WebCore/dom/EventNames.h_sec2
228
    macro(touchstart) \
229
    macro(touchstart) \
229
    macro(track) \
230
    macro(track) \
230
    macro(transitionend) \
231
    macro(transitionend) \
232
    macro(unhandledrejection) \
231
    macro(unload) \
233
    macro(unload) \
232
    macro(unmute) \
234
    macro(unmute) \
233
    macro(update) \
235
    macro(update) \
- a/Source/WebCore/dom/EventNames.in +1 lines
Lines 26-31 OverflowEvent a/Source/WebCore/dom/EventNames.in_sec1
26
PageTransitionEvent
26
PageTransitionEvent
27
PopStateEvent
27
PopStateEvent
28
ProgressEvent
28
ProgressEvent
29
PromiseRejectionEvent
29
TextEvent
30
TextEvent
30
TransitionEvent
31
TransitionEvent
31
UIEvent
32
UIEvent
- a/Source/WebCore/dom/GlobalEventHandlers.idl +2 lines
Lines 79-84 a/Source/WebCore/dom/GlobalEventHandlers.idl_sec1
79
    attribute EventHandler onplaying;
79
    attribute EventHandler onplaying;
80
    attribute EventHandler onprogress;
80
    attribute EventHandler onprogress;
81
    attribute EventHandler onratechange;
81
    attribute EventHandler onratechange;
82
    attribute EventHandler onrejectionhandled;
82
    attribute EventHandler onreset;
83
    attribute EventHandler onreset;
83
    attribute EventHandler onresize;
84
    attribute EventHandler onresize;
84
    attribute EventHandler onscroll;
85
    attribute EventHandler onscroll;
Lines 92-97 a/Source/WebCore/dom/GlobalEventHandlers.idl_sec2
92
    attribute EventHandler onsuspend;
93
    attribute EventHandler onsuspend;
93
    attribute EventHandler ontimeupdate;
94
    attribute EventHandler ontimeupdate;
94
    attribute EventHandler ontoggle;
95
    attribute EventHandler ontoggle;
96
    attribute EventHandler onunhandledrejection;
95
    attribute EventHandler onvolumechange;
97
    attribute EventHandler onvolumechange;
96
    attribute EventHandler onwaiting;
98
    attribute EventHandler onwaiting;
97
99
- a/Source/WebCore/dom/PromiseRejectionEvent.cpp +48 lines
Line 0 a/Source/WebCore/dom/PromiseRejectionEvent.cpp_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
#include "config.h"
27
#include "PromiseRejectionEvent.h"
28
29
#include "DOMWrapperWorld.h"
30
#include <heap/HeapInlines.h>
31
#include <heap/StrongInlines.h>
32
33
using namespace JSC;
34
35
namespace WebCore {
36
37
PromiseRejectionEvent::PromiseRejectionEvent(ExecState& state, const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
38
    : Event(type, initializer, isTrusted)
39
    , m_promise(state.vm(), initializer.promise)
40
    , m_reason(state.vm(), initializer.reason)
41
{
42
}
43
44
PromiseRejectionEvent::~PromiseRejectionEvent()
45
{
46
}
47
48
} // namespace WebCore
- a/Source/WebCore/dom/PromiseRejectionEvent.h +59 lines
Line 0 a/Source/WebCore/dom/PromiseRejectionEvent.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
#include "Event.h"
29
#include <heap/Strong.h>
30
31
namespace WebCore {
32
33
class PromiseRejectionEvent final : public Event {
34
public:
35
    struct Init : EventInit {
36
        JSC::JSValue promise;
37
        JSC::JSValue reason;
38
    };
39
40
    static Ref<PromiseRejectionEvent> create(JSC::ExecState& state, const AtomicString& type, const Init& initializer, IsTrusted isTrusted = IsTrusted::No)
41
    {
42
        return adoptRef(*new PromiseRejectionEvent(state, type, initializer, isTrusted));
43
    }
44
45
    virtual ~PromiseRejectionEvent();
46
47
    JSC::JSValue promise() const { return m_promise.get(); }
48
    JSC::JSValue reason() const { return m_reason.get(); }
49
50
    EventInterface eventInterface() const override { return PromiseRejectionEventInterfaceType; }
51
52
private:
53
    PromiseRejectionEvent(JSC::ExecState&, const AtomicString&, const Init&, IsTrusted);
54
55
    JSC::Strong<JSC::Unknown> m_promise;
56
    JSC::Strong<JSC::Unknown> m_reason;
57
};
58
59
} // namespace WebCore
- a/Source/WebCore/dom/PromiseRejectionEvent.idl +38 lines
Line 0 a/Source/WebCore/dom/PromiseRejectionEvent.idl_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
[
27
    Constructor(DOMString type, PromiseRejectionEventInit eventInitDict),
28
    ConstructorCallWith=ScriptState,
29
    Exposed=(Window,Worker),
30
] interface PromiseRejectionEvent : Event {
31
    readonly attribute Promise<any> promise;
32
    readonly attribute any reason;
33
};
34
35
dictionary PromiseRejectionEventInit : EventInit {
36
    required Promise<any> promise;
37
    any reason;
38
};
- a/Source/WebCore/dom/RejectedPromiseTracker.cpp +188 lines
Line 0 a/Source/WebCore/dom/RejectedPromiseTracker.cpp_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
18
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#include "config.h"
28
#include "RejectedPromiseTracker.h"
29
30
#include "EventNames.h"
31
#include "EventTarget.h"
32
#include "PromiseRejectionEvent.h"
33
#include "ScriptExecutionContext.h"
34
#include <heap/HeapInlines.h>
35
#include <heap/Strong.h>
36
#include <heap/StrongInlines.h>
37
#include <heap/Weak.h>
38
#include <heap/WeakInlines.h>
39
#include <inspector/ScriptCallStack.h>
40
#include <inspector/ScriptCallStackFactory.h>
41
#include <runtime/Exception.h>
42
#include <runtime/JSCJSValueInlines.h>
43
#include <runtime/JSGlobalObject.h>
44
#include <runtime/JSPromise.h>
45
#include <runtime/WeakGCMapInlines.h>
46
47
using namespace JSC;
48
using namespace Inspector;
49
50
namespace WebCore {
51
52
class RejectedPromise {
53
    WTF_MAKE_NONCOPYABLE(RejectedPromise);
54
public:
55
    RejectedPromise(JSPromise* promise, Ref<ScriptCallStack>&& stack)
56
        : m_stack(WTFMove(stack))
57
    {
58
        m_strongPromise.set(promise->globalObject()->vm(), promise);
59
    }
60
61
    RejectedPromise(RejectedPromise&&) = default;
62
63
    JSPromise* promise()
64
    {
65
        return m_strongPromise.get();
66
    }
67
68
    ScriptCallStack& callStack()
69
    {
70
        return m_stack.get();
71
    }
72
73
private:
74
    Strong<JSPromise> m_strongPromise;
75
    Ref<ScriptCallStack> m_stack;
76
};
77
78
79
RejectedPromiseTracker::RejectedPromiseTracker(ScriptExecutionContext& context, JSC::VM& vm)
80
    : m_context(context)
81
    , m_outstandingRejectedPromises(vm)
82
{
83
}
84
85
RejectedPromiseTracker::~RejectedPromiseTracker()
86
{
87
}
88
89
static Ref<ScriptCallStack> createScriptCallStackFromReason(ExecState& state, JSValue reason)
90
{
91
    if (auto* exception = jsDynamicCast<JSC::Exception*>(reason))
92
        return createScriptCallStackFromException(&state, exception, ScriptCallStack::maxCallStackSizeToCapture);
93
    return createScriptCallStack(&state, ScriptCallStack::maxCallStackSizeToCapture);
94
}
95
96
void RejectedPromiseTracker::promiseRejected(ExecState& state, JSPromise* promise)
97
{
98
    // https://html.spec.whatwg.org/multipage/webappapis.html#the-hostpromiserejectiontracker-implementation
99
100
    JSValue reason = promise->result(state.vm());
101
    m_aboutToBeNotifiedRejectedPromises.append(RejectedPromise { promise, createScriptCallStackFromReason(state, reason) });
102
}
103
104
void RejectedPromiseTracker::promiseHandled(ExecState& state, JSPromise* promise)
105
{
106
    // https://html.spec.whatwg.org/multipage/webappapis.html#the-hostpromiserejectiontracker-implementation
107
108
    bool removed = m_aboutToBeNotifiedRejectedPromises.removeFirstMatching([&] (RejectedPromise& rejectedPromise) {
109
        return rejectedPromise.promise() == promise;
110
    });
111
    if (removed)
112
        return;
113
114
    if (!m_outstandingRejectedPromises.remove(promise))
115
        return;
116
    m_context.postTask([this, promise = Strong<JSPromise>(state.vm(), promise)] (ScriptExecutionContext& context) {
117
        reportRejectionHandled(context, *promise.get());
118
    });
119
}
120
121
void RejectedPromiseTracker::processQueueSoon()
122
{
123
    // https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
124
125
    if (m_aboutToBeNotifiedRejectedPromises.isEmpty())
126
        return;
127
128
    Vector<RejectedPromise> items;
129
    items.swap(m_aboutToBeNotifiedRejectedPromises);
130
131
    m_context.postTask([this, items = WTFMove(items)] (ScriptExecutionContext& context) mutable {
132
        for (auto& rejectedPromise : items)
133
            reportUnhandledRejection(context, rejectedPromise);
134
    });
135
}
136
137
void RejectedPromiseTracker::reportUnhandledRejection(ScriptExecutionContext& context, RejectedPromise& rejectedPromise)
138
{
139
    // https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
140
141
    VM& vm = context.vm();
142
    JSC::JSLockHolder lock(vm);
143
144
    ExecState* exec = context.execState();
145
146
    auto* promise = rejectedPromise.promise();
147
    ASSERT(promise);
148
149
    if (promise->isHandled(vm))
150
        return;
151
152
    PromiseRejectionEvent::Init initializer;
153
    initializer.cancelable = true;
154
    initializer.promise = promise;
155
    initializer.reason = promise->result(vm);
156
157
    auto event = PromiseRejectionEvent::create(*exec, eventNames().unhandledrejectionEvent, initializer);
158
    auto target = context.errorEventTarget();
159
    bool needsDefaultAction = target->dispatchEvent(event);
160
161
    if (needsDefaultAction)
162
        context.reportUnhandledPromiseRejection(rejectedPromise.promise(), rejectedPromise.callStack());
163
164
    if (!promise->isHandled(vm))
165
        m_outstandingRejectedPromises.set(promise, promise);
166
}
167
168
void RejectedPromiseTracker::reportRejectionHandled(ScriptExecutionContext& context, JSPromise& promise)
169
{
170
    // https://html.spec.whatwg.org/multipage/webappapis.html#the-hostpromiserejectiontracker-implementation
171
172
    VM& vm = context.vm();
173
    JSC::JSLockHolder lock(vm);
174
175
    ExecState* exec = context.execState();
176
177
178
    PromiseRejectionEvent::Init initializer;
179
    initializer.cancelable = false;
180
    initializer.promise = &promise;
181
    initializer.reason = promise.result(exec->vm());
182
183
    auto event = PromiseRejectionEvent::create(*exec, eventNames().rejectionhandledEvent, initializer);
184
    auto target = context.errorEventTarget();
185
    target->dispatchEvent(event);
186
}
187
188
} // namespace WebCore
- a/Source/WebCore/dom/RejectedPromiseTracker.h +64 lines
Line 0 a/Source/WebCore/dom/RejectedPromiseTracker.h_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
18
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#pragma once
28
29
#include <runtime/JSPromise.h>
30
#include <runtime/WeakGCMap.h>
31
#include <wtf/Forward.h>
32
#include <wtf/Noncopyable.h>
33
#include <wtf/Vector.h>
34
35
namespace JSC {
36
class VM;
37
}
38
39
namespace WebCore {
40
41
class RejectedPromise;
42
class ScriptExecutionContext;
43
44
class RejectedPromiseTracker {
45
    WTF_MAKE_NONCOPYABLE(RejectedPromiseTracker);
46
public:
47
    explicit RejectedPromiseTracker(ScriptExecutionContext&, JSC::VM&);
48
    ~RejectedPromiseTracker();
49
50
    void promiseRejected(JSC::ExecState&, JSC::JSPromise*);
51
    void promiseHandled(JSC::ExecState&, JSC::JSPromise*);
52
53
    void processQueueSoon();
54
55
private:
56
    void reportUnhandledRejection(ScriptExecutionContext&, RejectedPromise&);
57
    void reportRejectionHandled(ScriptExecutionContext&, JSC::JSPromise&);
58
59
    ScriptExecutionContext& m_context;
60
    Vector<RejectedPromise> m_aboutToBeNotifiedRejectedPromises;
61
    JSC::WeakGCMap<JSC::JSPromise*, JSC::JSPromise> m_outstandingRejectedPromises;
62
};
63
64
} // namespace WebCore
- a/Source/WebCore/dom/ScriptExecutionContext.cpp +31 lines
Lines 46-51 a/Source/WebCore/dom/ScriptExecutionContext.cpp_sec1
46
#include <heap/StrongInlines.h>
46
#include <heap/StrongInlines.h>
47
#include <inspector/ScriptCallStack.h>
47
#include <inspector/ScriptCallStack.h>
48
#include <runtime/Exception.h>
48
#include <runtime/Exception.h>
49
#include <runtime/JSPromise.h>
49
#include <wtf/MainThread.h>
50
#include <wtf/MainThread.h>
50
#include <wtf/Ref.h>
51
#include <wtf/Ref.h>
51
52
Lines 379-384 void ScriptExecutionContext::reportException(const String& errorMessage, int lin a/Source/WebCore/dom/ScriptExecutionContext.cpp_sec2
379
        logExceptionToConsole(exception->m_errorMessage, exception->m_sourceURL, exception->m_lineNumber, exception->m_columnNumber, WTFMove(exception->m_callStack));
380
        logExceptionToConsole(exception->m_errorMessage, exception->m_sourceURL, exception->m_lineNumber, exception->m_columnNumber, WTFMove(exception->m_callStack));
380
}
381
}
381
382
383
void ScriptExecutionContext::reportUnhandledPromiseRejection(JSC::JSPromise* promise, Inspector::ScriptCallStack& callStack)
384
{
385
    auto scope = DECLARE_CATCH_SCOPE(vm());
386
387
    int lineNumber = 0;
388
    int columnNumber = 0;
389
    String sourceURL;
390
391
    JSC::JSValue result = promise->result(vm());
392
    String resultMessage = retrieveErrorMessage(*execState(), vm(), result, scope);
393
    String errorMessage = makeString("Unhandled Promise Rejection: ", resultMessage);
394
    if (const ScriptCallFrame* callFrame = callStack.firstNonNativeCallFrame()) {
395
        lineNumber = callFrame->lineNumber();
396
        columnNumber = callFrame->columnNumber();
397
        sourceURL = callFrame->sourceURL();
398
    }
399
400
    logExceptionToConsole(errorMessage, sourceURL, lineNumber, columnNumber, &callStack);
401
}
402
382
void ScriptExecutionContext::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, JSC::ExecState* state, unsigned long requestIdentifier)
403
void ScriptExecutionContext::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, JSC::ExecState* state, unsigned long requestIdentifier)
383
{
404
{
384
    addMessage(source, level, message, sourceURL, lineNumber, columnNumber, 0, state, requestIdentifier);
405
    addMessage(source, level, message, sourceURL, lineNumber, columnNumber, 0, state, requestIdentifier);
Lines 465-470 JSC::VM& ScriptExecutionContext::vm() a/Source/WebCore/dom/ScriptExecutionContext.cpp_sec3
465
    return downcast<WorkerGlobalScope>(*this).script()->vm();
486
    return downcast<WorkerGlobalScope>(*this).script()->vm();
466
}
487
}
467
488
489
RejectedPromiseTracker& ScriptExecutionContext::ensureRejectedPromiseTrackerSlow()
490
{
491
    // ScriptExecutionContext::vm() in Worker is only available after WorkerGlobalScope initialization is done.
492
    // When initializing ScriptExecutionContext, vm() is not ready.
493
494
    ASSERT(!m_rejectedPromiseTracker);
495
    m_rejectedPromiseTracker = std::make_unique<RejectedPromiseTracker>(*this, vm());
496
    return *m_rejectedPromiseTracker.get();
497
}
498
468
void ScriptExecutionContext::setDatabaseContext(DatabaseContext* databaseContext)
499
void ScriptExecutionContext::setDatabaseContext(DatabaseContext* databaseContext)
469
{
500
{
470
    m_databaseContext = databaseContext;
501
    m_databaseContext = databaseContext;
- a/Source/WebCore/dom/ScriptExecutionContext.h -3 / +15 lines
Lines 29-34 a/Source/WebCore/dom/ScriptExecutionContext.h_sec1
29
29
30
#include "ActiveDOMObject.h"
30
#include "ActiveDOMObject.h"
31
#include "DOMTimer.h"
31
#include "DOMTimer.h"
32
#include "RejectedPromiseTracker.h"
32
#include "SecurityContext.h"
33
#include "SecurityContext.h"
33
#include "Supplementable.h"
34
#include "Supplementable.h"
34
#include <heap/HandleTypes.h>
35
#include <heap/HandleTypes.h>
Lines 94-99 class ScriptExecutionContext : public SecurityContext { a/Source/WebCore/dom/ScriptExecutionContext.h_sec2
94
95
95
    bool sanitizeScriptError(String& errorMessage, int& lineNumber, int& columnNumber, String& sourceURL, JSC::Strong<JSC::Unknown>& error, CachedScript* = nullptr);
96
    bool sanitizeScriptError(String& errorMessage, int& lineNumber, int& columnNumber, String& sourceURL, JSC::Strong<JSC::Unknown>& error, CachedScript* = nullptr);
96
    void reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, JSC::Exception*, RefPtr<Inspector::ScriptCallStack>&&, CachedScript* = nullptr);
97
    void reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, JSC::Exception*, RefPtr<Inspector::ScriptCallStack>&&, CachedScript* = nullptr);
98
    void reportUnhandledPromiseRejection(JSC::JSPromise*, Inspector::ScriptCallStack&);
97
99
98
    void addConsoleMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0);
100
    void addConsoleMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0);
99
    virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) = 0;
101
    virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) = 0;
Lines 187-194 class ScriptExecutionContext : public SecurityContext { a/Source/WebCore/dom/ScriptExecutionContext.h_sec3
187
    void removeTimeout(int timeoutId) { m_timeouts.remove(timeoutId); }
189
    void removeTimeout(int timeoutId) { m_timeouts.remove(timeoutId); }
188
    DOMTimer* findTimeout(int timeoutId) { return m_timeouts.get(timeoutId); }
190
    DOMTimer* findTimeout(int timeoutId) { return m_timeouts.get(timeoutId); }
189
191
190
    WEBCORE_EXPORT JSC::VM& vm();
191
192
    // Interval is in seconds.
192
    // Interval is in seconds.
193
    void adjustMinimumTimerInterval(std::chrono::milliseconds oldMinimumTimerInterval);
193
    void adjustMinimumTimerInterval(std::chrono::milliseconds oldMinimumTimerInterval);
194
    virtual std::chrono::milliseconds minimumTimerInterval() const;
194
    virtual std::chrono::milliseconds minimumTimerInterval() const;
Lines 197-202 class ScriptExecutionContext : public SecurityContext { a/Source/WebCore/dom/ScriptExecutionContext.h_sec4
197
    virtual std::chrono::milliseconds timerAlignmentInterval(bool hasReachedMaxNestingLevel) const;
197
    virtual std::chrono::milliseconds timerAlignmentInterval(bool hasReachedMaxNestingLevel) const;
198
198
199
    virtual EventQueue& eventQueue() const = 0;
199
    virtual EventQueue& eventQueue() const = 0;
200
    virtual EventTarget* errorEventTarget() = 0;
200
201
201
    DatabaseContext* databaseContext() { return m_databaseContext.get(); }
202
    DatabaseContext* databaseContext() { return m_databaseContext.get(); }
202
    void setDatabaseContext(DatabaseContext*);
203
    void setDatabaseContext(DatabaseContext*);
Lines 209-214 class ScriptExecutionContext : public SecurityContext { a/Source/WebCore/dom/ScriptExecutionContext.h_sec5
209
    int timerNestingLevel() const { return m_timerNestingLevel; }
210
    int timerNestingLevel() const { return m_timerNestingLevel; }
210
    void setTimerNestingLevel(int timerNestingLevel) { m_timerNestingLevel = timerNestingLevel; }
211
    void setTimerNestingLevel(int timerNestingLevel) { m_timerNestingLevel = timerNestingLevel; }
211
212
213
    RejectedPromiseTracker& ensureRejectedPromiseTracker()
214
    {
215
        if (m_rejectedPromiseTracker)
216
            return *m_rejectedPromiseTracker.get();
217
        return ensureRejectedPromiseTrackerSlow();
218
    }
219
220
    WEBCORE_EXPORT JSC::VM& vm();
212
    JSC::ExecState* execState();
221
    JSC::ExecState* execState();
213
222
214
protected:
223
protected:
Lines 228-240 class ScriptExecutionContext : public SecurityContext { a/Source/WebCore/dom/ScriptExecutionContext.h_sec6
228
237
229
private:
238
private:
230
    virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<Inspector::ScriptCallStack>&&, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0) = 0;
239
    virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<Inspector::ScriptCallStack>&&, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0) = 0;
231
    virtual EventTarget* errorEventTarget() = 0;
232
    virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, RefPtr<Inspector::ScriptCallStack>&&) = 0;
240
    virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, RefPtr<Inspector::ScriptCallStack>&&) = 0;
233
    bool dispatchErrorEvent(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, JSC::Exception*, CachedScript*);
241
    bool dispatchErrorEvent(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, JSC::Exception*, CachedScript*);
234
242
235
    virtual void refScriptExecutionContext() = 0;
243
    virtual void refScriptExecutionContext() = 0;
236
    virtual void derefScriptExecutionContext() = 0;
244
    virtual void derefScriptExecutionContext() = 0;
237
245
246
    RejectedPromiseTracker& ensureRejectedPromiseTrackerSlow();
247
238
    void checkConsistency() const;
248
    void checkConsistency() const;
239
249
240
    HashSet<MessagePort*> m_messagePorts;
250
    HashSet<MessagePort*> m_messagePorts;
Lines 248-253 class ScriptExecutionContext : public SecurityContext { a/Source/WebCore/dom/ScriptExecutionContext.h_sec7
248
    struct PendingException;
258
    struct PendingException;
249
    std::unique_ptr<Vector<std::unique_ptr<PendingException>>> m_pendingExceptions;
259
    std::unique_ptr<Vector<std::unique_ptr<PendingException>>> m_pendingExceptions;
250
260
261
    std::unique_ptr<RejectedPromiseTracker> m_rejectedPromiseTracker;
262
251
    bool m_activeDOMObjectsAreSuspended { false };
263
    bool m_activeDOMObjectsAreSuspended { false };
252
    ActiveDOMObject::ReasonForSuspension m_reasonForSuspendingActiveDOMObjects { static_cast<ActiveDOMObject::ReasonForSuspension>(-1) };
264
    ActiveDOMObject::ReasonForSuspension m_reasonForSuspendingActiveDOMObjects { static_cast<ActiveDOMObject::ReasonForSuspension>(-1) };
253
    bool m_activeDOMObjectsAreStopped { false };
265
    bool m_activeDOMObjectsAreStopped { false };
- a/Source/WebCore/workers/WorkerGlobalScope.idl +2 lines
Lines 37-42 a/Source/WebCore/workers/WorkerGlobalScope.idl_sec1
37
    attribute EventHandler onerror;
37
    attribute EventHandler onerror;
38
    attribute EventHandler onoffline;
38
    attribute EventHandler onoffline;
39
    attribute EventHandler ononline;
39
    attribute EventHandler ononline;
40
    attribute EventHandler onrejectionhandled;
41
    attribute EventHandler onunhandledrejection;
40
42
41
    // WorkerUtils
43
    // WorkerUtils
42
44
- a/LayoutTests/ChangeLog +19 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2017-01-11  Yusuke Suzuki  <utatane.tea@gmail.com>
2
3
        Support for promise rejection events (unhandledrejection)
4
        https://bugs.webkit.org/show_bug.cgi?id=150358
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * js/dom/unhandled-promise-rejection-basic-expected.txt: Added.
9
        * js/dom/unhandled-promise-rejection-basic.html: Added.
10
        * js/dom/unhandled-promise-rejection-console-report-expected.txt: Added.
11
        * js/dom/unhandled-promise-rejection-console-report.html: Added.
12
        * js/dom/unhandled-promise-rejection-handle-during-event-expected.txt: Added.
13
        * js/dom/unhandled-promise-rejection-handle-during-event.html: Added.
14
        * js/dom/unhandled-promise-rejection-handle-in-handler-expected.txt: Added.
15
        * js/dom/unhandled-promise-rejection-handle-in-handler.html: Added.
16
        * js/dom/unhandled-promise-rejection-handle.html: Added.
17
        * js/dom/unhandled-promise-rejection-order-expected.txt: Added.
18
        * js/dom/unhandled-promise-rejection-order.html: Added.
19
1
2017-01-11  Chris Dumez  <cdumez@apple.com>
20
2017-01-11  Chris Dumez  <cdumez@apple.com>
2
21
3
        [iOS][WK2] KeyboardEvent.key always returns an empty string
22
        [iOS][WK2] KeyboardEvent.key always returns an empty string
- a/LayoutTests/js/dom/unhandled-promise-rejection-basic-expected.txt +12 lines
Line 0 a/LayoutTests/js/dom/unhandled-promise-rejection-basic-expected.txt_sec1
1
Test unhandled promise rejection event.
2
3
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4
5
PASS error.type is "unhandledrejection"
6
PASS error.cancelable is true
7
PASS error.promise is promise
8
PASS error.reason is "ERROR"
9
PASS successfullyParsed is true
10
11
TEST COMPLETE
12
- a/LayoutTests/js/dom/unhandled-promise-rejection-basic.html +31 lines
Line 0 a/LayoutTests/js/dom/unhandled-promise-rejection-basic.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script src="../../resources/js-test-pre.js"></script>
5
</head>
6
<body>
7
<div id="description"></div>
8
<div id="console"></div>
9
<script>
10
description('Test unhandled promise rejection event.');
11
12
window.jsTestIsAsync = true;
13
14
window.error = null;
15
window.promise = null;
16
window.onunhandledrejection = function (e) {
17
    error = e;
18
    shouldBe(`error.type`, `"unhandledrejection"`);
19
    shouldBe(`error.cancelable`, `true`);
20
    shouldBe(`error.promise`, `promise`);
21
    shouldBe(`error.reason`, `"ERROR"`);
22
    finishJSTest();
23
    return false;
24
};
25
26
window.promise = Promise.reject("ERROR");
27
28
</script>
29
<script src="../../resources/js-test-post.js"></script>
30
</body>
31
</html>
- a/LayoutTests/js/dom/unhandled-promise-rejection-console-report-expected.txt +11 lines
Line 0 a/LayoutTests/js/dom/unhandled-promise-rejection-console-report-expected.txt_sec1
1
CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: 0
2
CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: 1
3
CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: 2
4
Test unhandled promise rejection event.
5
6
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
7
8
PASS successfullyParsed is true
9
10
TEST COMPLETE
11
- a/LayoutTests/js/dom/unhandled-promise-rejection-console-report.html +23 lines
Line 0 a/LayoutTests/js/dom/unhandled-promise-rejection-console-report.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script src="../../resources/js-test-pre.js"></script>
5
</head>
6
<body>
7
<div id="description"></div>
8
<div id="console"></div>
9
<script>
10
description('Test unhandled promise rejection event.');
11
12
window.jsTestIsAsync = true;
13
14
window.promise = [];
15
for (var i = 0; i < 3; ++i)
16
    window.promise[i] = Promise.reject(i);
17
18
setTimeout(function () { finishJSTest(); }, 100);
19
20
</script>
21
<script src="../../resources/js-test-post.js"></script>
22
</body>
23
</html>
- a/LayoutTests/js/dom/unhandled-promise-rejection-handle-during-event-expected.txt +12 lines
Line 0 a/LayoutTests/js/dom/unhandled-promise-rejection-handle-during-event-expected.txt_sec1
1
Test unhandled promise rejection event.
2
3
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4
5
PASS error.type is "unhandledrejection"
6
PASS error.cancelable is true
7
PASS error.promise is promise[0]
8
PASS error.reason is 0
9
PASS successfullyParsed is true
10
11
TEST COMPLETE
12
- a/LayoutTests/js/dom/unhandled-promise-rejection-handle-during-event.html +36 lines
Line 0 a/LayoutTests/js/dom/unhandled-promise-rejection-handle-during-event.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script src="../../resources/js-test-pre.js"></script>
5
</head>
6
<body>
7
<div id="description"></div>
8
<div id="console"></div>
9
<script>
10
description('Test unhandled promise rejection event.');
11
12
window.jsTestIsAsync = true;
13
14
window.error = null;
15
window.promise = [];
16
window.onunhandledrejection = function (e) {
17
    error = e;
18
19
    shouldBe(`error.type`, `"unhandledrejection"`);
20
    shouldBe(`error.cancelable`, `true`);
21
    shouldBe(`error.promise`, `promise[0]`);
22
    shouldBe(`error.reason`, `0`);
23
24
    promise[1].catch(function () { });
25
    promise[2].catch(function () { });
26
    setTimeout(function () { finishJSTest(); });
27
    return false;
28
};
29
30
for (var i = 0; i < 3; ++i)
31
    window.promise[i] = Promise.reject(i);
32
33
</script>
34
<script src="../../resources/js-test-post.js"></script>
35
</body>
36
</html>
- a/LayoutTests/js/dom/unhandled-promise-rejection-handle-in-handler-expected.txt +13 lines
Line 0 a/LayoutTests/js/dom/unhandled-promise-rejection-handle-in-handler-expected.txt_sec1
1
Test rejection handled event.
2
3
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4
5
PASS error.type is "unhandledrejection"
6
PASS error.cancelable is true
7
PASS error.promise is promise
8
PASS error.reason is "ERROR"
9
PASS reason is "ERROR"
10
PASS successfullyParsed is true
11
12
TEST COMPLETE
13
- a/LayoutTests/js/dom/unhandled-promise-rejection-handle-in-handler.html +44 lines
Line 0 a/LayoutTests/js/dom/unhandled-promise-rejection-handle-in-handler.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script src="../../resources/js-test-pre.js"></script>
5
</head>
6
<body>
7
<div id="description"></div>
8
<div id="console"></div>
9
<script>
10
description('Test rejection handled event.');
11
12
window.jsTestIsAsync = true;
13
14
window.error = null;
15
window.promise = null;
16
window.reason = null;
17
18
window.onunhandledrejection = function (e) {
19
    error = e;
20
    shouldBe(`error.type`, `"unhandledrejection"`);
21
    shouldBe(`error.cancelable`, `true`);
22
    shouldBe(`error.promise`, `promise`);
23
    shouldBe(`error.reason`, `"ERROR"`);
24
    promise.catch(function (r) {
25
        window.reason = r;
26
        shouldBe(`reason`, `"ERROR"`);
27
    });
28
29
    setTimeout(function () {
30
        finishJSTest();
31
    }, 100);
32
    return false;
33
};
34
35
window.onrejectionhandled = function (e) {
36
    testFailed(`rejectionhandled is fired.`);
37
};
38
39
window.promise = Promise.reject("ERROR");
40
41
</script>
42
<script src="../../resources/js-test-post.js"></script>
43
</body>
44
</html>
- a/LayoutTests/js/dom/unhandled-promise-rejection-handle.html +48 lines
Line 0 a/LayoutTests/js/dom/unhandled-promise-rejection-handle.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script src="../../resources/js-test-pre.js"></script>
5
</head>
6
<body>
7
<div id="description"></div>
8
<div id="console"></div>
9
<script>
10
description('Test rejection handled event.');
11
12
window.jsTestIsAsync = true;
13
14
window.error = null;
15
window.handled = null;
16
window.promise = null;
17
window.reason = null;
18
19
window.onunhandledrejection = function (e) {
20
    error = e;
21
    shouldBe(`error.type`, `"unhandledrejection"`);
22
    shouldBe(`error.cancelable`, `true`);
23
    shouldBe(`error.promise`, `promise`);
24
    shouldBe(`error.reason`, `"ERROR"`);
25
    setTimeout(function () {
26
        promise.catch(function (r) {
27
            window.reason = r;
28
            shouldBe(`reason`, `"ERROR"`);
29
        });
30
    }, 0);
31
    return false;
32
};
33
34
window.onrejectionhandled = function (e) {
35
    window.handled = e;
36
    shouldBe(`handled.type`, `"rejectionhandled"`);
37
    shouldBe(`handled.cancelable`, `false`);
38
    shouldBe(`handled.promise`, `promise`);
39
    shouldBe(`handled.reason`, `"ERROR"`);
40
    finishJSTest();
41
};
42
43
window.promise = Promise.reject("ERROR");
44
45
</script>
46
<script src="../../resources/js-test-post.js"></script>
47
</body>
48
</html>
- a/LayoutTests/js/dom/unhandled-promise-rejection-order-expected.txt +20 lines
Line 0 a/LayoutTests/js/dom/unhandled-promise-rejection-order-expected.txt_sec1
1
Test unhandled promise rejection event.
2
3
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4
5
PASS error.type is "unhandledrejection"
6
PASS error.cancelable is true
7
PASS error.promise is promise[0]
8
PASS error.reason is 0
9
PASS error.type is "unhandledrejection"
10
PASS error.cancelable is true
11
PASS error.promise is promise[1]
12
PASS error.reason is 1
13
PASS error.type is "unhandledrejection"
14
PASS error.cancelable is true
15
PASS error.promise is promise[2]
16
PASS error.reason is 2
17
PASS successfullyParsed is true
18
19
TEST COMPLETE
20
- a/LayoutTests/js/dom/unhandled-promise-rejection-order.html +38 lines
Line 0 a/LayoutTests/js/dom/unhandled-promise-rejection-order.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script src="../../resources/js-test-pre.js"></script>
5
</head>
6
<body>
7
<div id="description"></div>
8
<div id="console"></div>
9
<script>
10
description('Test unhandled promise rejection event.');
11
12
window.jsTestIsAsync = true;
13
14
window.error = null;
15
window.promise = [];
16
window.count = 0;
17
window.index = 0;
18
window.onunhandledrejection = function (e) {
19
    error = e;
20
    index = count++;
21
22
    shouldBe(`error.type`, `"unhandledrejection"`);
23
    shouldBe(`error.cancelable`, `true`);
24
    shouldBe(`error.promise`, `promise[${index}]`);
25
    shouldBe(`error.reason`, `${index}`);
26
27
    if (count === 3)
28
        finishJSTest();
29
    return false;
30
};
31
32
for (var i = 0; i < 3; ++i)
33
    window.promise[i] = Promise.reject(i);
34
35
</script>
36
<script src="../../resources/js-test-post.js"></script>
37
</body>
38
</html>

Return to Bug 150358