Bug 1198831 - Fix browser_tab_drag_drop_perwindow.js leaks by returning early in swapBrowsersAndCloseOther() when the remoteness of the given browsers differs r=jaws

This commit is contained in:
Tim Taubert
2015-09-01 17:10:18 +02:00
parent 274dc8f1d9
commit d7e65b5511
2 changed files with 9 additions and 13 deletions

View File

@@ -2470,6 +2470,13 @@
PrivateBrowsingUtils.isWindowPrivate(aOtherTab.ownerDocument.defaultView))
return;
let ourBrowser = this.getBrowserForTab(aOurTab);
let otherBrowser = aOtherTab.linkedBrowser;
// Can't swap between chrome and content processes.
if (ourBrowser.isRemoteBrowser != otherBrowser.isRemoteBrowser)
return;
// That's gBrowser for the other window, not the tab's browser!
var remoteBrowser = aOtherTab.ownerDocument.defaultView.gBrowser;
var isPending = aOtherTab.hasAttribute("pending");
@@ -2490,9 +2497,6 @@
modifiedAttrs.push("soundplaying");
}
let ourBrowser = this.getBrowserForTab(aOurTab);
let otherBrowser = aOtherTab.linkedBrowser;
// If the other tab is pending (i.e. has not been restored, yet)
// then do not switch docShells but retrieve the other tab's state
// and apply it to our tab.

View File

@@ -74,21 +74,13 @@ add_task(function* test_dragging_e10s_windows() {
null, nonRemoteWin, remoteWin);
is(effect, "none", "Should not be able to drag a non-remote tab to an e10s window");
try {
remoteWin.gBrowser.swapBrowsersAndCloseOther(remoteTab, nonRemoteTab);
ok(false, "swapBrowsersAndCloseOther should have thrown");
} catch(e) {}
remoteWin.gBrowser.swapBrowsersAndCloseOther(remoteTab, nonRemoteTab);
is(remoteWin.gBrowser.tabs.length, 2,
"Prevent moving a normal tab to a private tabbrowser");
is(nonRemoteWin.gBrowser.tabs.length, 2,
"Prevent accepting a normal tab in a private tabbrowser");
try {
nonRemoteWin.gBrowser.swapBrowsersAndCloseOther(nonRemoteTab, remoteTab);
ok(false, "swapBrowsersAndCloseOther should have thrown");
} catch(e) {}
nonRemoteWin.gBrowser.swapBrowsersAndCloseOther(nonRemoteTab, remoteTab);
is(nonRemoteWin.gBrowser.tabs.length, 2,
"Prevent moving a private tab to a normal tabbrowser");
is(remoteWin.gBrowser.tabs.length, 2,