mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 1931822 - [marionette] Do not always wrap errors into a WebDriver error for IPC messages. r=webdriver-reviewers,jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D229898
This commit is contained in:
parent
96445f317f
commit
37f46525ca
@ -313,8 +313,12 @@ export class MarionetteCommandsChild extends JSWindowActorChild {
|
||||
hasSerializedWindows,
|
||||
};
|
||||
} catch (e) {
|
||||
// Always wrap errors as WebDriverError
|
||||
return { error: lazy.error.wrap(e).toJSON() };
|
||||
if (lazy.error.isWebDriverError(e)) {
|
||||
// If it's a WebDriver error always serialize it because it could
|
||||
// contain objects that are not serializable by default.
|
||||
return { error: e.toJSON(), isWebDriverError: true };
|
||||
}
|
||||
return { error: e, isWebDriverError: false };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@ export class MarionetteCommandsParent extends JSWindowActorParent {
|
||||
this.#deferredDialogOpened = Promise.withResolvers();
|
||||
let {
|
||||
error,
|
||||
isWebDriverError,
|
||||
seenNodeIds,
|
||||
serializedValue: serializedResult,
|
||||
hasSerializedWindows,
|
||||
@ -78,8 +79,12 @@ export class MarionetteCommandsParent extends JSWindowActorParent {
|
||||
});
|
||||
|
||||
if (error) {
|
||||
const err = lazy.error.WebDriverError.fromJSON(error);
|
||||
this.#handleError(err, seenNodes);
|
||||
if (isWebDriverError) {
|
||||
// If it's a WebDriver error we need to deserialize it.
|
||||
error = lazy.error.WebDriverError.fromJSON(error);
|
||||
}
|
||||
|
||||
this.#handleError(error, seenNodes);
|
||||
}
|
||||
|
||||
// Update seen nodes for serialized element and shadow root nodes.
|
||||
@ -95,15 +100,15 @@ export class MarionetteCommandsParent extends JSWindowActorParent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle WebDriver error and replace error type if necessary.
|
||||
* Handle an error and replace error type if necessary.
|
||||
*
|
||||
* @param {WebDriverError} error
|
||||
* The WebDriver error to handle.
|
||||
* @param {Error} error
|
||||
* The error to handle.
|
||||
* @param {Set<string>} seenNodes
|
||||
* List of node ids already seen in this navigable.
|
||||
*
|
||||
* @throws {WebDriverError}
|
||||
* The original or replaced WebDriver error.
|
||||
* @throws {Error}
|
||||
* The original or replaced error.
|
||||
*/
|
||||
#handleError(error, seenNodes) {
|
||||
// If an element hasn't been found during deserialization check if it
|
||||
|
Loading…
Reference in New Issue
Block a user