| |
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
| |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
| |
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| |
4 |
| |
5 function test() { |
| |
6 //initialization |
| |
7 waitForExplicitFinish(); |
| |
8 |
| |
9 let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. |
| |
10 getService(Ci.mozIJSSubScriptLoader); |
| |
11 let ChromeUtils = {}; |
| |
12 scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js", ChromeUtils); |
| |
13 |
| |
14 function testOnWindow(aIsPrivate, aCallback) { |
| |
15 whenNewWindowLoaded({private: aIsPrivate}, function(win) { |
| |
16 executeSoon(function() aCallback(win)); |
| |
17 }); |
| |
18 } |
| |
19 |
| |
20 testOnWindow(false, function(aNormalWindow) { |
| |
21 testOnWindow(true, function(aPrivateWindow) { |
| |
22 // Open a tab in each window |
| |
23 let normalTab = aNormalWindow.gBrowser.addTab("about:blank", {skipAnimation: true}); |
| |
24 let privateTab = aPrivateWindow.gBrowser.addTab("about:blank", {skipAnimation: true}); |
| |
25 |
| |
26 let effect = ChromeUtils.synthesizeDrop(normalTab, privateTab, |
| |
27 [[{type: TAB_DROP_TYPE, data: normalTab}]], |
| |
28 null, aNormalWindow, aPrivateWindow); |
| |
29 is(effect, "none", "Should not be able to drag a normal tab to a private window"); |
| |
30 |
| |
31 effect = ChromeUtils.synthesizeDrop(privateTab, normalTab, |
| |
32 [[{type: TAB_DROP_TYPE, data: privateTab}]], |
| |
33 null, aPrivateWindow, aNormalWindow); |
| |
34 is(effect, "none", "Should not be able to drag a private tab to a normal window"); |
| |
35 |
| |
36 aNormalWindow.gBrowser.swapBrowsersAndCloseOther(normalTab, privateTab); |
| |
37 is(aNormalWindow.gBrowser.tabs.length, 2, "Prevent moving a normal tab to a private tabbrowser"); |
| |
38 is(aPrivateWindow.gBrowser.tabs.length, 2, "Prevent accepting a normal tab in a private tabbrowser"); |
| |
39 |
| |
40 aPrivateWindow.gBrowser.swapBrowsersAndCloseOther(privateTab, normalTab); |
| |
41 is(aPrivateWindow.gBrowser.tabs.length, 2, "Prevent moving a private tab to a normal tabbrowser"); |
| |
42 is(aNormalWindow.gBrowser.tabs.length, 2, "Prevent accepting a private tab in a normal tabbrowser"); |
| |
43 |
| |
44 aNormalWindow.close(); |
| |
45 aPrivateWindow.close(); |
| |
46 finish(); |
| |
47 }); |
| |
48 }); |
| |
49 } |
| |
50 |