haikuwebkit/LayoutTests/js/dom/promise-rejection-might-sta...

14 lines
371 B
HTML
Raw Permalink Normal View History

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script src="script-tests/promise-rejection-might-stack-overflow.js"></script>
Add missing exception checks in ScriptModuleLoader and JSDOMPromiseDeferred. https://bugs.webkit.org/show_bug.cgi?id=221374 rdar://problem/68911404 Reviewed by Yusuke Suzuki. Based on patch by Frédéric Wang <fwang@igalia.com>. Source/WebCore: When an import call fails, ScriptModuleLoader::notifyFinished() rejects the deferred promise with either a call to DeferredPromise::reject(ExceptionCode, const String&, RejectAsHandled) or a call to rejectToPropagateNetworkError() / DeferredPromise::rejectWithCallback(). When it succeeds, it calls DeferredPromise::resolveWithPromise(). These correspond to three places where we enter the VM. Catch scopes are thus added to handle uncaught exceptions for DeferredPromise. Currently, this logic for uncaught exceptions is already duplicated at several places in the code, and is likely needed for other places too in follow-up work. This patch however covers all the rejection and resolution calls from ScriptModuleLoader. Additionally, it handles missing exception checks in ScriptModuleLoader::evaluate. Test: js/dom/modules/missing-exception-check-for-import.html * bindings/js/JSDOMPromiseDeferred.cpp: (WebCore::DeferredPromise::reject): (WebCore::DeferredPromise::handleTerminationExceptionIfNeeded): (WebCore::DeferredPromise::handleUncaughtException): * bindings/js/JSDOMPromiseDeferred.h: (WebCore::DeferredPromise::resolveWithCallback): (WebCore::DeferredPromise::rejectWithCallback): * bindings/js/ScriptModuleLoader.cpp: (WebCore::ScriptModuleLoader::evaluate): LayoutTests: Add a regression test for import('./'). Depending on the system configuration this can execute two different rejection methods from ScriptModuleLoader::notifyFinished(). In other words, we may get 2 different error messages. Hence, the test needs to allow for this variance. Additional test cases are added for rejectToPropagateNetworkError / DeferredPromise::rejectWithCallback (e.g. module file not found), for DeferredPromise::reject(ExceptionCode, const String&, RejectAsHandled) (e.g. module file does not have JavaScript MIME type) and DeferredPromise::resolveWithCallback (e.g. module import is successful). Also update promise-rejection-might-stack-overflow.html now that the stack overflow error is reported. * js/dom/modules/missing-exception-check-for-import-expected.txt: Added. * js/dom/modules/missing-exception-check-for-import.html: Added. * js/dom/promise-rejection-might-stack-overflow-expected.txt: * js/dom/promise-rejection-might-stack-overflow.html: Canonical link: https://commits.webkit.org/239067@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279170 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-23 16:25:52 +00:00
<script>
shouldHaveHadError("RangeError: Maximum call stack size exceeded.")
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>