From e5f5e2ab7e8c5e9d0b30e615dd7fdd4674b1c8f4 Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Mon, 10 Feb 2020 21:35:23 +0000 Subject: [PATCH] Bug 1610614 - Part 4: Add tests for dragging tabs between fission and non-fission windows, r=mconley Differential Revision: https://phabricator.services.mozilla.com/D61926 --HG-- extra : moz-landing-system : lando --- .../browser_tab_drag_drop_perwindow.js | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/browser/base/content/test/general/browser_tab_drag_drop_perwindow.js b/browser/base/content/test/general/browser_tab_drag_drop_perwindow.js index 98e6eb02f44d..ac4ef94d285e 100644 --- a/browser/base/content/test/general/browser_tab_drag_drop_perwindow.js +++ b/browser/base/content/test/general/browser_tab_drag_drop_perwindow.js @@ -160,6 +160,99 @@ add_task(async function test_dragging_e10s_windows() { await BrowserTestUtils.closeWindow(nonRemoteWin); }); +/** + * Tests that tabs from fission windows cannot be dragged into non-fission + * windows, and vice-versa. + */ +add_task(async function test_dragging_fission_windows() { + let fissionWin = await BrowserTestUtils.openNewBrowserWindow({ + remote: true, + fission: true, + }); + let nonFissionWin = await BrowserTestUtils.openNewBrowserWindow({ + remote: true, + fission: false, + }); + + let fissionTab = await BrowserTestUtils.openNewForegroundTab( + fissionWin.gBrowser + ); + let nonFissionTab = await BrowserTestUtils.openNewForegroundTab( + nonFissionWin.gBrowser + ); + + let effect = EventUtils.synthesizeDrop( + fissionTab, + nonFissionTab, + [[{ type: TAB_DROP_TYPE, data: fissionTab }]], + null, + fissionWin, + nonFissionWin + ); + is( + effect, + "none", + "Should not be able to drag a fission tab to a non-fission window" + ); + + effect = EventUtils.synthesizeDrop( + nonFissionTab, + fissionTab, + [[{ type: TAB_DROP_TYPE, data: nonFissionTab }]], + null, + nonFissionWin, + fissionWin + ); + is( + effect, + "none", + "Should not be able to drag a non-fission tab to an fission window" + ); + + let swapOk = fissionWin.gBrowser.swapBrowsersAndCloseOther( + fissionTab, + nonFissionTab + ); + is( + swapOk, + false, + "Returns false swapping fission tab to a non-fission tabbrowser" + ); + is( + fissionWin.gBrowser.tabs.length, + 2, + "Prevent moving a fission tab to a non-fission tabbrowser" + ); + is( + nonFissionWin.gBrowser.tabs.length, + 2, + "Prevent accepting a fission tab in a non-fission tabbrowser" + ); + + swapOk = nonFissionWin.gBrowser.swapBrowsersAndCloseOther( + nonFissionTab, + fissionTab + ); + is( + swapOk, + false, + "Returns false swapping non-fission tab to a fission tabbrowser" + ); + is( + nonFissionWin.gBrowser.tabs.length, + 2, + "Prevent moving a non-fission tab to a fission tabbrowser" + ); + is( + fissionWin.gBrowser.tabs.length, + 2, + "Prevent accepting a non-fission tab in a fission tabbrowser" + ); + + await BrowserTestUtils.closeWindow(fissionWin); + await BrowserTestUtils.closeWindow(nonFissionWin); +}); + /** * Tests that remoteness-blacklisted tabs from e10s windows can * be dragged between e10s windows.