michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function test() { michael@0: //initialization michael@0: waitForExplicitFinish(); michael@0: michael@0: let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. michael@0: getService(Ci.mozIJSSubScriptLoader); michael@0: let ChromeUtils = {}; michael@0: scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js", ChromeUtils); michael@0: michael@0: function testOnWindow(aIsPrivate, aCallback) { michael@0: whenNewWindowLoaded({private: aIsPrivate}, function(win) { michael@0: executeSoon(function() aCallback(win)); michael@0: }); michael@0: } michael@0: michael@0: testOnWindow(false, function(aNormalWindow) { michael@0: testOnWindow(true, function(aPrivateWindow) { michael@0: // Open a tab in each window michael@0: let normalTab = aNormalWindow.gBrowser.addTab("about:blank", {skipAnimation: true}); michael@0: let privateTab = aPrivateWindow.gBrowser.addTab("about:blank", {skipAnimation: true}); michael@0: michael@0: let effect = ChromeUtils.synthesizeDrop(normalTab, privateTab, michael@0: [[{type: TAB_DROP_TYPE, data: normalTab}]], michael@0: null, aNormalWindow, aPrivateWindow); michael@0: is(effect, "none", "Should not be able to drag a normal tab to a private window"); michael@0: michael@0: effect = ChromeUtils.synthesizeDrop(privateTab, normalTab, michael@0: [[{type: TAB_DROP_TYPE, data: privateTab}]], michael@0: null, aPrivateWindow, aNormalWindow); michael@0: is(effect, "none", "Should not be able to drag a private tab to a normal window"); michael@0: michael@0: aNormalWindow.gBrowser.swapBrowsersAndCloseOther(normalTab, privateTab); michael@0: is(aNormalWindow.gBrowser.tabs.length, 2, "Prevent moving a normal tab to a private tabbrowser"); michael@0: is(aPrivateWindow.gBrowser.tabs.length, 2, "Prevent accepting a normal tab in a private tabbrowser"); michael@0: michael@0: aPrivateWindow.gBrowser.swapBrowsersAndCloseOther(privateTab, normalTab); michael@0: is(aPrivateWindow.gBrowser.tabs.length, 2, "Prevent moving a private tab to a normal tabbrowser"); michael@0: is(aNormalWindow.gBrowser.tabs.length, 2, "Prevent accepting a private tab in a normal tabbrowser"); michael@0: michael@0: aNormalWindow.close(); michael@0: aPrivateWindow.close(); michael@0: finish(); michael@0: }); michael@0: }); michael@0: } michael@0: