Bug 1059036 - [e10s] Undo Close Tab would not load tab contents. r=mconley
authorDavid Parks <davidp99@gmail.com>
Tue, 02 Sep 2014 11:16:13 -0700
changeset 203418 518ad95704fc2214eb2b9e5d016df007f32c9df9
parent 203417 505529c35c7f029a85629306353b88011bb2cee8
child 203419 b37bfa44405ebff9f22533974faa2e8b60892344
push id48665
push userryanvm@gmail.com
push dateWed, 03 Sep 2014 20:40:15 +0000
treeherdermozilla-inbound@0da762e6868a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1059036
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1059036 - [e10s] Undo Close Tab would not load tab contents. r=mconley Update tab index after select event during tab switch -- the event may change array indices.
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -5321,28 +5321,37 @@
 
           let toTab = this.getRelatedElement(this.childNodes[val]);
           let fromTab = this._selectedPanel ? this.getRelatedElement(this._selectedPanel)
                                             : null;
 
           let switchPromise = gBrowser._prepareForTabSwitch(toTab, fromTab);
 
           var panel = this._selectedPanel;
-          this._selectedPanel = this.childNodes[val];
+          var newPanel = this.childNodes[val];
+          this._selectedPanel = newPanel;
           if (this._selectedPanel != panel) {
             var event = document.createEvent("Events");
             event.initEvent("select", true, true);
             this.dispatchEvent(event);
           }
 
           this._selectedIndex = val;
 
           switchPromise.then(() => {
-            this.setAttribute("selectedIndex", val);
-            gBrowser._finalizeTabSwitch(toTab, fromTab);
+            // If we cannot find the tabpanel that we were trying to switch to, then
+            // it must have been removed before our Promise could be resolved. In
+            // that case, we just cancel the tab switch.
+            var updatedTabIndex = Array.indexOf(this.childNodes, newPanel);
+            if (updatedTabIndex == -1) {
+              gBrowser._cancelTabSwitch(toTab);
+            } else {
+              this.setAttribute("selectedIndex", updatedTabIndex);
+              gBrowser._finalizeTabSwitch(toTab, fromTab);
+            }
           }, () => {
             // If the promise rejected, that means we don't want to actually
             // flip the deck, so we cancel the tab switch.
             gBrowser._cancelTabSwitch(toTab);
           });
 
           return val;
         ]]>