Bug 1430077 - Correct safety checks on Marionette:Register reply. r?whimboo
sendSyncMessage returns an array of replies from the frame message
manager, each item being the return value from each message listener
that handles the message.
In testing/marionette/driver.js there are two handlers for
Marionette:Register, but it is not predictable at the moment when
both or either one of them is triggered. We would, however, always
expect a response, which means the reply array should never be empty.
MozReview-Commit-ID: 5F8YfKO8jBU
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -453,20 +453,22 @@ function registerSelf() {
curContainer = {
frame: content,
shadowRoot: null,
};
legacyactions.mouseEventsOnly = false;
action.inputStateMap = new Map();
action.inputsToCancel = [];
- // register will have the ID and a boolean describing if this is the
- // main process or not
- let register = sendSyncMessage("Marionette:Register", {outerWindowID});
- if (register[0].outerWindowID === outerWindowID) {
+ let reply = sendSyncMessage("Marionette:Register", {outerWindowID});
+ if (reply.length == 0) {
+ logger.error("No reply from Marionette:Register");
+ }
+
+ if (reply[0].outerWindowID === outerWindowID) {
startListeners();
sendAsyncMessage("Marionette:ListenersAttached", {outerWindowID});
}
}
// Eventually we will not have a closure for every single command,
// but use a generic dispatch for all listener commands.
//