diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index 98066ec5a06f..64fdbc3ab31f 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -1331,6 +1331,9 @@ var BrowserApp = { this._tabs[i] = this._tabs[i + step]; } this._tabs[toPosition] = movedTab; + + let evt = new UIEvent("TabMove", {"bubbles":true, "cancellable":false, "view":window, "detail":fromPosition}); + this.tabs[toPosition].browser.dispatchEvent(evt); }, // Use this method to select a tab from JS. This method sends a message diff --git a/mobile/android/components/SessionStore.js b/mobile/android/components/SessionStore.js index c09a8a25116f..e3b612820ce0 100644 --- a/mobile/android/components/SessionStore.js +++ b/mobile/android/components/SessionStore.js @@ -453,6 +453,12 @@ SessionStore.prototype = { this.onTabSelect(window, browser); break; } + case "TabMove": { + let browser = aEvent.target; + log("TabMove for tab " + window.BrowserApp.getTabForBrowser(browser).id); + this.onTabMove(); + break; + } case "DOMTitleChanged": { // Use DOMTitleChanged to detect page loads over alternatives. // onLocationChange happens too early, so we don't have the page title @@ -570,6 +576,7 @@ SessionStore.prototype = { browsers.addEventListener("TabOpen", this, true); browsers.addEventListener("TabClose", this, true); browsers.addEventListener("TabSelect", this, true); + browsers.addEventListener("TabMove", this, true); browsers.addEventListener("TabPreZombify", this, true); browsers.addEventListener("TabPostZombify", this, true); }, @@ -584,6 +591,7 @@ SessionStore.prototype = { browsers.removeEventListener("TabOpen", this, true); browsers.removeEventListener("TabClose", this, true); browsers.removeEventListener("TabSelect", this, true); + browsers.removeEventListener("TabMove", this, true); browsers.removeEventListener("TabPreZombify", this, true); browsers.removeEventListener("TabPostZombify", this, true); @@ -825,6 +833,17 @@ SessionStore.prototype = { log("restoring zombie tab " + aTab.id); }, + onTabMove: function ss_onTabMove() { + if (this._loadState != STATE_RUNNING) { + return; + } + + // The long press that initiated the move canceled any close undo option that may have been + // present. + this._lastClosedTabIndex = -1; + this.saveStateDelayed(); + }, + onTabInput: function ss_onTabInput(aWindow, aBrowser) { // If this browser belongs to a zombie tab or the initial restore hasn't yet finished, // skip any session save activity.