Diff
Modified: trunk/LayoutTests/ChangeLog (244311 => 244312)
--- trunk/LayoutTests/ChangeLog 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/LayoutTests/ChangeLog 2019-04-16 00:02:32 UTC (rev 244312)
@@ -1,3 +1,14 @@
+2019-04-15 Devin Rousso <[email protected]>
+
+ Web Inspector: fake value descriptors for promises add a catch handler, preventing "rejectionhandled" events from being fired
+ https://bugs.webkit.org/show_bug.cgi?id=196484
+ <rdar://problem/49114725>
+
+ Reviewed by Joseph Pecoraro.
+
+ * inspector/runtime/promise-native-getter.html: Added.
+ * inspector/runtime/promise-native-getter-expected.txt: Added.
+
2019-04-15 Shawn Roberts <[email protected]>
storage/indexeddb/modern/gc-closes-database-private.html is a flaky timeout
Added: trunk/LayoutTests/inspector/runtime/promise-native-getter-expected.txt (0 => 244312)
--- trunk/LayoutTests/inspector/runtime/promise-native-getter-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/runtime/promise-native-getter-expected.txt 2019-04-16 00:02:32 UTC (rev 244312)
@@ -0,0 +1,5 @@
+CONSOLE MESSAGE: line 8: unhandledrejection - "test"
+CONSOLE MESSAGE: Unhandled Promise Rejection: test
+CONSOLE MESSAGE: line 20: caught - "test"
+CONSOLE MESSAGE: line 12: rejectionhandled - "test"
+Tests that the injected script only `.then()`s promises if they are returned by native getters.
Added: trunk/LayoutTests/inspector/runtime/promise-native-getter.html (0 => 244312)
--- trunk/LayoutTests/inspector/runtime/promise-native-getter.html (rev 0)
+++ trunk/LayoutTests/inspector/runtime/promise-native-getter.html 2019-04-16 00:02:32 UTC (rev 244312)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function createUnhandledPromise() {
+ window.addEventListener("unhandledrejection", (event) => {
+ console.log("unhandledrejection - " + JSON.stringify(event.reason));
+ });
+
+ window.addEventListener("rejectionhandled", (event) => {
+ console.log("rejectionhandled - " + JSON.stringify(event.reason));
+ TestPage.dispatchEventToFrontend("rejectionhandled");
+ });
+
+ let promise = Promise.reject("test");
+
+ setTimeout(() => {
+ promise.catch((value) => {
+ console.log("caught - " + JSON.stringify(value));
+ });
+ }, 5);
+}
+
+function test()
+{
+ ProtocolTest.awaitEvent("rejectionhandled")
+ .then(() => {
+ ProtocolTest.completeTest();
+ });
+
+ ProtocolTest.evaluateInPage(`createUnhandledPromise()`)
+ .catch((e) => {
+ ProtocolTest.fail(e);
+ });
+}
+</script>
+</head>
+<body _onload_="runTest()">
+ <p>Tests that the injected script only `.then()`s promises if they are returned by native getters.</p>
+</body>
+</html>
Modified: trunk/Source/_javascript_Core/ChangeLog (244311 => 244312)
--- trunk/Source/_javascript_Core/ChangeLog 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-04-16 00:02:32 UTC (rev 244312)
@@ -1,3 +1,37 @@
+2019-04-15 Devin Rousso <[email protected]>
+
+ Web Inspector: fake value descriptors for promises add a catch handler, preventing "rejectionhandled" events from being fired
+ https://bugs.webkit.org/show_bug.cgi?id=196484
+ <rdar://problem/49114725>
+
+ Reviewed by Joseph Pecoraro.
+
+ Only add a catch handler when the promise is reachable via a native getter and is known to
+ have rejected. A non-rejected promise doesn't need a catch handler, and any promise that
+ isn't reachable via a getter won't actually be reached, as `InjectedScript` doesn't call any
+ functions, instead only getting the function object itself.
+
+ * inspector/InjectedScriptSource.js:
+ (InjectedScript.prototype._propertyDescriptors.createFakeValueDescriptor):
+
+ * inspector/JSInjectedScriptHost.h:
+ * inspector/JSInjectedScriptHost.cpp:
+ (Inspector::JSInjectedScriptHost::isPromiseRejectedWithNativeGetterTypeError): Added.
+ * inspector/JSInjectedScriptHostPrototype.cpp:
+ (Inspector::JSInjectedScriptHostPrototype::finishCreation):
+ (Inspector::jsInjectedScriptHostPrototypeFunctionIsPromiseRejectedWithNativeGetterTypeError): Added.
+
+ * runtime/ErrorInstance.h:
+ (JSC::ErrorInstance::setNativeGetterTypeError): Added.
+ (JSC::ErrorInstance::isNativeGetterTypeError const): Added.
+
+ * runtime/Error.h:
+ (JSC::throwVMGetterTypeError): Added.
+ * runtime/Error.cpp:
+ (JSC::createGetterTypeError): Added.
+ (JSC::throwGetterTypeError): Added.
+ (JSC::throwDOMAttributeGetterTypeError):
+
2019-04-15 Robin Morisset <[email protected]>
B3::Value should have different kinds of adjacency lists
Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js (244311 => 244312)
--- trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js 2019-04-16 00:02:32 UTC (rev 244312)
@@ -653,7 +653,7 @@
if (symbol)
fakeDescriptor.symbol = symbol;
// Silence any possible unhandledrejection exceptions created from accessing a native accessor with a wrong this object.
- if (fakeDescriptor.value instanceof Promise)
+ if (fakeDescriptor.value instanceof Promise && InjectedScriptHost.isPromiseRejectedWithNativeGetterTypeError(fakeDescriptor.value))
fakeDescriptor.value.catch(function(){});
return fakeDescriptor;
} catch (e) {
Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp (244311 => 244312)
--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp 2019-04-16 00:02:32 UTC (rev 244312)
@@ -142,6 +142,21 @@
return jsBoolean(impl().isHTMLAllCollection(vm, value));
}
+JSValue JSInjectedScriptHost::isPromiseRejectedWithNativeGetterTypeError(ExecState* exec)
+{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto* promise = jsDynamicCast<JSPromise*>(vm, exec->argument(0));
+ if (!promise || promise->status(vm) != JSPromise::Status::Rejected)
+ return throwTypeError(exec, scope, "InjectedScriptHost.isPromiseRejectedWithNativeGetterTypeError first argument must be a rejected Promise."_s);
+
+ bool result = false;
+ if (auto* errorInstance = jsDynamicCast<ErrorInstance*>(vm, promise->result(vm)))
+ result = errorInstance->isNativeGetterTypeError();
+ return jsBoolean(result);
+}
+
JSValue JSInjectedScriptHost::subtype(ExecState* exec)
{
VM& vm = exec->vm();
Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.h (244311 => 244312)
--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.h 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.h 2019-04-16 00:02:32 UTC (rev 244312)
@@ -62,6 +62,7 @@
JSC::JSValue evaluateWithScopeExtension(JSC::ExecState*);
JSC::JSValue internalConstructorName(JSC::ExecState*);
JSC::JSValue isHTMLAllCollection(JSC::ExecState*);
+ JSC::JSValue isPromiseRejectedWithNativeGetterTypeError(JSC::ExecState*);
JSC::JSValue subtype(JSC::ExecState*);
JSC::JSValue functionDetails(JSC::ExecState*);
JSC::JSValue getInternalProperties(JSC::ExecState*);
Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHostPrototype.cpp (244311 => 244312)
--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHostPrototype.cpp 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHostPrototype.cpp 2019-04-16 00:02:32 UTC (rev 244312)
@@ -43,6 +43,7 @@
static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionGetInternalProperties(ExecState*);
static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionInternalConstructorName(ExecState*);
static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection(ExecState*);
+static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIsPromiseRejectedWithNativeGetterTypeError(ExecState*);
static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionProxyTargetValue(ExecState*);
static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapSize(ExecState*);
static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapEntries(ExecState*);
@@ -67,6 +68,7 @@
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("getInternalProperties", jsInjectedScriptHostPrototypeFunctionGetInternalProperties, static_cast<unsigned>(PropertyAttribute::DontEnum), 1);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("internalConstructorName", jsInjectedScriptHostPrototypeFunctionInternalConstructorName, static_cast<unsigned>(PropertyAttribute::DontEnum), 1);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("isHTMLAllCollection", jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection, static_cast<unsigned>(PropertyAttribute::DontEnum), 1);
+ JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("isPromiseRejectedWithNativeGetterTypeError", jsInjectedScriptHostPrototypeFunctionIsPromiseRejectedWithNativeGetterTypeError, static_cast<unsigned>(PropertyAttribute::DontEnum), 1);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("proxyTargetValue", jsInjectedScriptHostPrototypeFunctionProxyTargetValue, static_cast<unsigned>(PropertyAttribute::DontEnum), 1);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("weakMapSize", jsInjectedScriptHostPrototypeFunctionWeakMapSize, static_cast<unsigned>(PropertyAttribute::DontEnum), 1);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("weakMapEntries", jsInjectedScriptHostPrototypeFunctionWeakMapEntries, static_cast<unsigned>(PropertyAttribute::DontEnum), 1);
@@ -118,6 +120,19 @@
return JSValue::encode(castedThis->isHTMLAllCollection(exec));
}
+EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIsPromiseRejectedWithNativeGetterTypeError(ExecState* exec)
+{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ JSValue thisValue = exec->thisValue();
+ JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(vm, thisValue);
+ if (!castedThis)
+ return throwVMTypeError(exec, scope);
+
+ return JSValue::encode(castedThis->isPromiseRejectedWithNativeGetterTypeError(exec));
+}
+
EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionProxyTargetValue(ExecState* exec)
{
VM& vm = exec->vm();
Modified: trunk/Source/_javascript_Core/runtime/Error.cpp (244311 => 244312)
--- trunk/Source/_javascript_Core/runtime/Error.cpp 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/Source/_javascript_Core/runtime/Error.cpp 2019-04-16 00:02:32 UTC (rev 244312)
@@ -123,6 +123,15 @@
return nullptr;
}
+JSObject* createGetterTypeError(ExecState* exec, const String& message)
+{
+ ASSERT(!message.isEmpty());
+ JSGlobalObject* globalObject = exec->lexicalGlobalObject();
+ auto* error = ErrorInstance::create(exec, globalObject->vm(), globalObject->errorStructure(ErrorType::TypeError), message);
+ error->setNativeGetterTypeError();
+ return error;
+}
+
class FindFirstCallerFrameWithCodeblockFunctor {
public:
FindFirstCallerFrameWithCodeblockFunctor(CallFrame* startCallFrame)
@@ -290,9 +299,14 @@
return throwException(exec, scope, createSyntaxError(exec, message));
}
+Exception* throwGetterTypeError(ExecState* exec, ThrowScope& scope, const String& message)
+{
+ return throwException(exec, scope, createGetterTypeError(exec, message));
+}
+
JSValue throwDOMAttributeGetterTypeError(ExecState* exec, ThrowScope& scope, const ClassInfo* classInfo, PropertyName propertyName)
{
- return throwTypeError(exec, scope, makeString("The ", classInfo->className, '.', String(propertyName.uid()), " getter can only be used on instances of ", classInfo->className));
+ return throwGetterTypeError(exec, scope, makeString("The ", classInfo->className, '.', String(propertyName.uid()), " getter can only be used on instances of ", classInfo->className));
}
JSObject* createError(ExecState* exec, const String& message)
Modified: trunk/Source/_javascript_Core/runtime/Error.h (244311 => 244312)
--- trunk/Source/_javascript_Core/runtime/Error.h 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/Source/_javascript_Core/runtime/Error.h 2019-04-16 00:02:32 UTC (rev 244312)
@@ -67,6 +67,8 @@
JS_EXPORT_PRIVATE JSObject* createError(ExecState*, ErrorType, const String&);
+JSObject* createGetterTypeError(ExecState*, const String&);
+
std::unique_ptr<Vector<StackFrame>> getStackTrace(ExecState*, VM&, JSObject*, bool useCurrentFrame);
void getBytecodeOffset(ExecState*, VM&, Vector<StackFrame>*, CallFrame*&, unsigned& bytecodeOffset);
bool getLineColumnAndSource(Vector<StackFrame>* stackTrace, unsigned& line, unsigned& column, String& sourceURL);
@@ -84,6 +86,8 @@
JS_EXPORT_PRIVATE Exception* throwSyntaxError(ExecState*, ThrowScope&);
JS_EXPORT_PRIVATE Exception* throwSyntaxError(ExecState*, ThrowScope&, const String& errorMessage);
inline Exception* throwRangeError(ExecState* state, ThrowScope& scope, const String& errorMessage) { return throwException(state, scope, createRangeError(state, errorMessage)); }
+
+JS_EXPORT_PRIVATE Exception* throwGetterTypeError(ExecState*, ThrowScope&, const String& errorMessage);
JS_EXPORT_PRIVATE JSValue throwDOMAttributeGetterTypeError(ExecState*, ThrowScope&, const ClassInfo*, PropertyName);
// Convenience wrappers, wrap result as an EncodedJSValue.
@@ -94,6 +98,7 @@
inline EncodedJSValue throwVMTypeError(ExecState* exec, ThrowScope& scope, ASCIILiteral errorMessage) { return JSValue::encode(throwTypeError(exec, scope, errorMessage)); }
inline EncodedJSValue throwVMTypeError(ExecState* exec, ThrowScope& scope, const String& errorMessage) { return JSValue::encode(throwTypeError(exec, scope, errorMessage)); }
inline EncodedJSValue throwVMRangeError(ExecState* state, ThrowScope& scope, const String& errorMessage) { return JSValue::encode(throwRangeError(state, scope, errorMessage)); }
+inline EncodedJSValue throwVMGetterTypeError(ExecState* exec, ThrowScope& scope, const String& errorMessage) { return JSValue::encode(throwGetterTypeError(exec, scope, errorMessage)); }
inline EncodedJSValue throwVMDOMAttributeGetterTypeError(ExecState* state, ThrowScope& scope, const ClassInfo* classInfo, PropertyName propertyName) { return JSValue::encode(throwDOMAttributeGetterTypeError(state, scope, classInfo, propertyName)); }
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/ErrorInstance.h (244311 => 244312)
--- trunk/Source/_javascript_Core/runtime/ErrorInstance.h 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/Source/_javascript_Core/runtime/ErrorInstance.h 2019-04-16 00:02:32 UTC (rev 244312)
@@ -65,6 +65,9 @@
void setOutOfMemoryError() { m_outOfMemoryError = true; }
bool isOutOfMemoryError() const { return m_outOfMemoryError; }
+ void setNativeGetterTypeError() { m_nativeGetterTypeError = true; }
+ bool isNativeGetterTypeError() const { return m_nativeGetterTypeError; }
+
JS_EXPORT_PRIVATE String sanitizedToString(ExecState*);
Vector<StackFrame>* stackTrace() { return m_stackTrace.get(); }
@@ -105,6 +108,7 @@
bool m_stackOverflowError { false };
bool m_outOfMemoryError { false };
bool m_errorInfoMaterialized { false };
+ bool m_nativeGetterTypeError { false };
};
} // namespace JSC
Modified: trunk/Source/WebCore/ChangeLog (244311 => 244312)
--- trunk/Source/WebCore/ChangeLog 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/Source/WebCore/ChangeLog 2019-04-16 00:02:32 UTC (rev 244312)
@@ -1,3 +1,31 @@
+2019-04-15 Devin Rousso <[email protected]>
+
+ Web Inspector: fake value descriptors for promises add a catch handler, preventing "rejectionhandled" events from being fired
+ https://bugs.webkit.org/show_bug.cgi?id=196484
+ <rdar://problem/49114725>
+
+ Reviewed by Joseph Pecoraro.
+
+ Test: inspector/runtime/promise-native-getter.html
+
+ Mark errors created from getters as being `isNativeGetterTypeError`.
+
+ * bindings/js/JSDOMExceptionHandling.cpp:
+ (WebCore::throwGetterTypeError):
+ (WebCore::rejectPromiseWithGetterTypeError):
+ (WebCore::rejectPromiseWithThisTypeError):
+
+ * bindings/js/JSDOMGlobalObject.cpp:
+ (WebCore::makeGetterTypeErrorForBuiltins):
+
+ * bindings/js/JSDOMPromiseDeferred.h:
+ * bindings/js/JSDOMPromiseDeferred.cpp:
+ (WebCore::createRejectedPromiseWithTypeError):
+
+ * Modules/streams/WritableStream.js:
+ (getter.closed):
+ (getter.ready):
+
2019-04-15 Jer Noble <[email protected]>
Add a DiagnosticLogging method taking an arbitrary dictionary of values.
Modified: trunk/Source/WebCore/Modules/streams/WritableStream.js (244311 => 244312)
--- trunk/Source/WebCore/Modules/streams/WritableStream.js 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/Source/WebCore/Modules/streams/WritableStream.js 2019-04-16 00:02:32 UTC (rev 244312)
@@ -154,7 +154,7 @@
"use strict";
if (!@isWritableStream(this))
- return @Promise.@reject(@makeTypeError("The WritableStream.closed getter can only be used on instances of WritableStream"));
+ return @Promise.@reject(@makeGetterTypeError("WritableStream", "closed"));
return @getByIdDirectPrivate(this, "closedPromiseCapability").@promise;
}
@@ -165,7 +165,7 @@
"use strict";
if (!@isWritableStream(this))
- return @Promise.@reject(@makeTypeError("The WritableStream.ready getter can only be used on instances of WritableStream"));
+ return @Promise.@reject(@makeGetterTypeError("WritableStream", "ready"));
return @getByIdDirectPrivate(this, "readyPromiseCapability").@promise;
}
Modified: trunk/Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp (244311 => 244312)
--- trunk/Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp 2019-04-16 00:02:32 UTC (rev 244312)
@@ -270,12 +270,12 @@
JSC::EncodedJSValue throwGetterTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName, const char* attributeName)
{
- return throwVMTypeError(&state, scope, makeGetterTypeErrorMessage(interfaceName, attributeName));
+ return throwVMGetterTypeError(&state, scope, makeGetterTypeErrorMessage(interfaceName, attributeName));
}
JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::ExecState& state, const char* interfaceName, const char* attributeName)
{
- return createRejectedPromiseWithTypeError(state, makeGetterTypeErrorMessage(interfaceName, attributeName));
+ return createRejectedPromiseWithTypeError(state, makeGetterTypeErrorMessage(interfaceName, attributeName), RejectedPromiseWithTypeErrorCause::NativeGetter);
}
bool throwSetterTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName, const char* attributeName)
@@ -302,7 +302,7 @@
JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::ExecState& state, const char* interfaceName, const char* methodName)
{
- return createRejectedPromiseWithTypeError(state, makeThisTypeErrorMessage(interfaceName, methodName));
+ return createRejectedPromiseWithTypeError(state, makeThisTypeErrorMessage(interfaceName, methodName), RejectedPromiseWithTypeErrorCause::InvalidThis);
}
void throwDOMSyntaxError(JSC::ExecState& state, JSC::ThrowScope& scope, ASCIILiteral message)
Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp (244311 => 244312)
--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp 2019-04-16 00:02:32 UTC (rev 244312)
@@ -100,7 +100,10 @@
scope.assertNoException();
auto attributeName = execState->uncheckedArgument(1).getString(execState);
scope.assertNoException();
- return JSValue::encode(createTypeError(execState, makeGetterTypeErrorMessage(interfaceName.utf8().data(), attributeName.utf8().data())));
+
+ auto error = static_cast<ErrorInstance*>(createTypeError(execState, makeGetterTypeErrorMessage(interfaceName.utf8().data(), attributeName.utf8().data())));
+ error->setNativeGetterTypeError();
+ return JSValue::encode(error);
}
#if ENABLE(STREAMS_API)
Modified: trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.cpp (244311 => 244312)
--- trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.cpp 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.cpp 2019-04-16 00:02:32 UTC (rev 244312)
@@ -197,7 +197,7 @@
return DeferredPromise::create(domWindow, *deferred);
}
-JSC::EncodedJSValue createRejectedPromiseWithTypeError(JSC::ExecState& state, const String& errorMessage)
+JSC::EncodedJSValue createRejectedPromiseWithTypeError(JSC::ExecState& state, const String& errorMessage, RejectedPromiseWithTypeErrorCause cause)
{
ASSERT(state.lexicalGlobalObject());
auto& globalObject = *state.lexicalGlobalObject();
@@ -204,7 +204,9 @@
auto promiseConstructor = globalObject.promiseConstructor();
auto rejectFunction = promiseConstructor->get(&state, state.vm().propertyNames->builtinNames().rejectPrivateName());
- auto rejectionValue = createTypeError(&state, errorMessage);
+ auto* rejectionValue = static_cast<ErrorInstance*>(createTypeError(&state, errorMessage));
+ if (cause == RejectedPromiseWithTypeErrorCause::NativeGetter)
+ rejectionValue->setNativeGetterTypeError();
CallData callData;
auto callType = getCallData(state.vm(), rejectFunction, callData);
Modified: trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h (244311 => 244312)
--- trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h 2019-04-16 00:00:58 UTC (rev 244311)
+++ trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h 2019-04-16 00:02:32 UTC (rev 244312)
@@ -257,8 +257,10 @@
void fulfillPromiseWithArrayBuffer(Ref<DeferredPromise>&&, ArrayBuffer*);
void fulfillPromiseWithArrayBuffer(Ref<DeferredPromise>&&, const void*, size_t);
WEBCORE_EXPORT void rejectPromiseWithExceptionIfAny(JSC::ExecState&, JSDOMGlobalObject&, JSC::JSPromiseDeferred&);
-JSC::EncodedJSValue createRejectedPromiseWithTypeError(JSC::ExecState&, const String&);
+enum class RejectedPromiseWithTypeErrorCause { NativeGetter, InvalidThis };
+JSC::EncodedJSValue createRejectedPromiseWithTypeError(JSC::ExecState&, const String&, RejectedPromiseWithTypeErrorCause);
+
using PromiseFunction = void(JSC::ExecState&, Ref<DeferredPromise>&&);
enum class PromiseExecutionScope { WindowOnly, WindowOrWorker };