Bug 1829630 - [bidi] Throw explicit error for missing stacks in script module r=webdriver-reviewers,Sasha

Depends on D176353

Differential Revision: https://phabricator.services.mozilla.com/D176354
This commit is contained in:
Julian Descottes 2023-04-27 16:53:29 +00:00
parent 93f5685ca6
commit 111dd3a198

View file

@ -66,8 +66,18 @@ class ScriptModule extends WindowGlobalBiDiModule {
#buildExceptionDetails(exception, stack, realm, resultOwnership, options) {
exception = this.#toRawObject(exception);
const frames = lazy.getFramesFromStack(stack) || [];
// A stacktrace is mandatory to build exception details and a missing stack
// means we encountered an unexpected issue. Throw with an explicit error.
if (!stack) {
throw new Error(
`Missing stack, unable to build exceptionDetails for exception: ${lazy.stringify(
exception
)}`
);
}
const frames = lazy.getFramesFromStack(stack) || [];
const callFrames = frames
// Remove chrome/internal frames
.filter(frame => !lazy.isChromeFrame(frame))