Bug 1247687 - Handle cancellation of long running modules; r=jonco

This is a slightly annoying thing that can happen. When we abruptly cancel (such as an infinitely
running script being forcibly terminated) we will be in a state where the EvaluateModule call will
finish _after_ the loader is destroyed. So, instead we track if there has been a forcible
cancelation, and exit early.

Depends on D155690

Differential Revision: https://phabricator.services.mozilla.com/D155568
This commit is contained in:
Yulia Startsev
2022-12-20 20:56:14 +00:00
parent f2cb5a7872
commit c87a9fe8f0
2 changed files with 13 additions and 1 deletions

View File

@@ -1213,6 +1213,11 @@ nsresult ModuleLoaderBase::EvaluateModuleInContext(
// unless the user cancels execution.
MOZ_ASSERT_IF(ok, !JS_IsExceptionPending(aCx));
// For long running scripts, the request may be cancelled abruptly.
if (request->IsCanceled() || !mLoader) {
return NS_ERROR_ABORT;
}
if (!ok) {
LOG(("ScriptLoadRequest (%p): evaluation failed", aRequest));
// For a dynamic import, the promise is rejected. Otherwise an error is