Bug 1430077 - Separate clearing session state from deregistering listeners. r?whimboo
With the forthcoming window tracking changes the message listeners of
the content frame script are left listening for the duration of the
Marionette lifetime, and not for the duration of the Marionette session.
To prepare for the window tracking refactoring, we will want to
remove message listeners separately from clearing the session state.
Functionally, this patch changes nothing in Marionette for the moment,
except we send two IPC messages to the frame script instead of one.
MozReview-Commit-ID: DwVBCpvk9V9
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -2762,16 +2762,17 @@ GeckoDriver.prototype.closeChromeWindow
};
/** Delete Marionette session. */
GeckoDriver.prototype.deleteSession = function() {
if (this.curBrowser !== null) {
// frame scripts can be safely reused
Preferences.set(CONTENT_LISTENER_PREF, false);
+ globalMessageManager.broadcastAsyncMessage("Marionette:Session:Delete");
globalMessageManager.broadcastAsyncMessage("Marionette:Deregister");
for (let win of this.windows) {
if (win.messageManager) {
win.messageManager.removeDelayedFrameScript(FRAME_SCRIPT);
} else {
logger.error(
`Could not remove listener from page ${win.location.href}`);
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -553,16 +553,17 @@ function startListeners() {
addMessageListener("Marionette:isElementEnabled", isElementEnabledFn);
addMessageListener("Marionette:isElementSelected", isElementSelectedFn);
addMessageListener("Marionette:multiAction", multiActionFn);
addMessageListener("Marionette:performActions", performActionsFn);
addMessageListener("Marionette:refresh", refresh);
addMessageListener("Marionette:reftestWait", reftestWaitFn);
addMessageListener("Marionette:releaseActions", releaseActionsFn);
addMessageListener("Marionette:sendKeysToElement", sendKeysToElementFn);
+ addMessageListener("Marionette:Session:Delete", deleteSession);
addMessageListener("Marionette:singleTap", singleTapFn);
addMessageListener("Marionette:switchToFrame", switchToFrame);
addMessageListener("Marionette:switchToParentFrame", switchToParentFrame);
addMessageListener("Marionette:switchToShadowRoot", switchToShadowRootFn);
addMessageListener("Marionette:takeScreenshot", takeScreenshotFn);
addMessageListener("Marionette:waitForPageLoaded", waitForPageLoaded);
}
@@ -590,23 +591,26 @@ function deregister() {
removeMessageListener("Marionette:isElementDisplayed", isElementDisplayedFn);
removeMessageListener("Marionette:isElementEnabled", isElementEnabledFn);
removeMessageListener("Marionette:isElementSelected", isElementSelectedFn);
removeMessageListener("Marionette:multiAction", multiActionFn);
removeMessageListener("Marionette:performActions", performActionsFn);
removeMessageListener("Marionette:refresh", refresh);
removeMessageListener("Marionette:releaseActions", releaseActionsFn);
removeMessageListener("Marionette:sendKeysToElement", sendKeysToElementFn);
+ removeMessageListener("Marionette:Session:Delete", deleteSession);
removeMessageListener("Marionette:singleTap", singleTapFn);
removeMessageListener("Marionette:switchToFrame", switchToFrame);
removeMessageListener("Marionette:switchToParentFrame", switchToParentFrame);
removeMessageListener("Marionette:switchToShadowRoot", switchToShadowRootFn);
removeMessageListener("Marionette:takeScreenshot", takeScreenshotFn);
removeMessageListener("Marionette:waitForPageLoaded", waitForPageLoaded);
+}
+function deleteSession() {
seenEls.clear();
// reset container frame to the top-most frame
curContainer = {frame: content, shadowRoot: null};
curContainer.frame.focus();
legacyactions.touchIds = {};
if (action.inputStateMap !== undefined) {
action.inputStateMap.clear();
}