Modified: trunk/Source/WebCore/ChangeLog (253812 => 253813)
--- trunk/Source/WebCore/ChangeLog 2019-12-20 11:52:09 UTC (rev 253812)
+++ trunk/Source/WebCore/ChangeLog 2019-12-20 13:15:24 UTC (rev 253813)
@@ -1,5 +1,19 @@
2019-12-20 youenn fablet <[email protected]>
+ DOMPromise::whenPromiseIsSettled is asserting in service worker
+ https://bugs.webkit.org/show_bug.cgi?id=205440
+
+ Reviewed by Chris Dumez.
+
+ The promise.get(@then) is sometimes throwing an exception probably due to service worker being stopped.
+ We need to catch the JS exception and exit early if the getter fails.
+ Covered by existing service worker tests in debug mode.
+
+ * bindings/js/JSDOMPromise.cpp:
+ (WebCore::DOMPromise::whenPromiseIsSettled):
+
+2019-12-20 youenn fablet <[email protected]>
+
Make ServiceWorker::postMessage use the exec state from the JS binding layer
https://bugs.webkit.org/show_bug.cgi?id=205395
Modified: trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp (253812 => 253813)
--- trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp 2019-12-20 11:52:09 UTC (rev 253812)
+++ trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp 2019-12-20 13:15:24 UTC (rev 253813)
@@ -38,20 +38,6 @@
namespace WebCore {
-static inline JSC::JSValue callFunction(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue jsFunction, JSC::JSValue thisValue, const JSC::ArgList& arguments)
-{
- VM& vm = lexicalGlobalObject.vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
- JSC::CallData callData;
- auto callType = JSC::getCallData(vm, jsFunction, callData);
- ASSERT(callType != JSC::CallType::None);
- auto result = call(&lexicalGlobalObject, jsFunction, callType, callData, thisValue, arguments);
-
- EXCEPTION_ASSERT_UNUSED(scope, !scope.exception() || isTerminatedExecutionException(lexicalGlobalObject.vm(), scope.exception()));
-
- return result;
-}
-
void DOMPromise::whenSettled(std::function<void()>&& callback)
{
whenPromiseIsSettled(globalObject(), promise(), WTFMove(callback));
@@ -67,14 +53,26 @@
return JSC::JSValue::encode(JSC::jsUndefined());
});
+ auto scope = DECLARE_THROW_SCOPE(vm);
const JSC::Identifier& privateName = vm.propertyNames->builtinNames().thenPrivateName();
auto thenFunction = promise->get(&lexicalGlobalObject, privateName);
+
+ EXCEPTION_ASSERT(!scope.exception() || isTerminatedExecutionException(lexicalGlobalObject.vm(), scope.exception()));
+ if (scope.exception())
+ return;
+
ASSERT(thenFunction.isFunction(vm));
JSC::MarkedArgumentBuffer arguments;
arguments.append(handler);
arguments.append(handler);
- callFunction(lexicalGlobalObject, thenFunction, promise, arguments);
+
+ JSC::CallData callData;
+ auto callType = JSC::getCallData(vm, thenFunction, callData);
+ ASSERT(callType != JSC::CallType::None);
+ call(&lexicalGlobalObject, thenFunction, callType, callData, promise, arguments);
+
+ EXCEPTION_ASSERT(!scope.exception() || isTerminatedExecutionException(lexicalGlobalObject.vm(), scope.exception()));
}
JSC::JSValue DOMPromise::result() const