browser/base/content/test/general/browser_tab_drag_drop_perwindow.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/base/content/test/general/browser_tab_drag_drop_perwindow.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +function test() {
     1.9 +  //initialization
    1.10 +  waitForExplicitFinish();
    1.11 +
    1.12 +  let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
    1.13 +                     getService(Ci.mozIJSSubScriptLoader);
    1.14 +  let ChromeUtils = {};
    1.15 +  scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js", ChromeUtils);
    1.16 +
    1.17 +  function testOnWindow(aIsPrivate, aCallback) {
    1.18 +    whenNewWindowLoaded({private: aIsPrivate}, function(win) {
    1.19 +      executeSoon(function() aCallback(win));
    1.20 +    });
    1.21 +  }
    1.22 +
    1.23 +  testOnWindow(false, function(aNormalWindow) {
    1.24 +    testOnWindow(true, function(aPrivateWindow) {
    1.25 +      // Open a tab in each window
    1.26 +      let normalTab = aNormalWindow.gBrowser.addTab("about:blank", {skipAnimation: true});
    1.27 +      let privateTab = aPrivateWindow.gBrowser.addTab("about:blank", {skipAnimation: true});
    1.28 +
    1.29 +      let effect = ChromeUtils.synthesizeDrop(normalTab, privateTab,
    1.30 +        [[{type: TAB_DROP_TYPE, data: normalTab}]],
    1.31 +        null, aNormalWindow, aPrivateWindow);
    1.32 +      is(effect, "none", "Should not be able to drag a normal tab to a private window");
    1.33 +
    1.34 +      effect = ChromeUtils.synthesizeDrop(privateTab, normalTab,
    1.35 +        [[{type: TAB_DROP_TYPE, data: privateTab}]],
    1.36 +        null, aPrivateWindow, aNormalWindow);
    1.37 +      is(effect, "none", "Should not be able to drag a private tab to a normal window");
    1.38 +
    1.39 +      aNormalWindow.gBrowser.swapBrowsersAndCloseOther(normalTab, privateTab);
    1.40 +      is(aNormalWindow.gBrowser.tabs.length, 2, "Prevent moving a normal tab to a private tabbrowser");
    1.41 +      is(aPrivateWindow.gBrowser.tabs.length, 2, "Prevent accepting a normal tab in a private tabbrowser");
    1.42 +
    1.43 +      aPrivateWindow.gBrowser.swapBrowsersAndCloseOther(privateTab, normalTab);
    1.44 +      is(aPrivateWindow.gBrowser.tabs.length, 2, "Prevent moving a private tab to a normal tabbrowser");
    1.45 +      is(aNormalWindow.gBrowser.tabs.length, 2, "Prevent accepting a private tab in a normal tabbrowser");
    1.46 +
    1.47 +      aNormalWindow.close();
    1.48 +      aPrivateWindow.close();
    1.49 +      finish();
    1.50 +    });
    1.51 +  });
    1.52 +}
    1.53 +

mercurial