Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
4 type="text/css"?>
5 <window title="Taskbar Previews Test"
6 xmlns:html="http://www.w3.org/1999/xhtml"
7 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
8 onload="loaded();">
10 <title>Previews - yeah!</title>
11 <script type="application/javascript"
12 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
13 <script class="testbody" type="application/javascript">
14 <![CDATA[
15 let Cc = Components.classes;
16 let Ci = Components.interfaces;
17 let Cu = Components.utils;
18 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
20 let taskbar = Cc["@mozilla.org/windows-taskbar;1"].getService(Ci.nsIWinTaskbar);
22 function IsWin7OrHigher() {
23 try {
24 var sysInfo = Cc["@mozilla.org/system-info;1"].
25 getService(Ci.nsIPropertyBag2);
26 var ver = parseFloat(sysInfo.getProperty("version"));
27 if (ver >= 6.1)
28 return true;
29 } catch (ex) { }
30 return false;
31 }
32 isnot(taskbar, null, "Taskbar service is defined");
33 is(taskbar.available, IsWin7OrHigher(), "Expected availability of taskbar");
35 SimpleTest.waitForExplicitFinish();
37 function stdPreviewSuite(p) {
38 p.visible = !p.visible;
39 p.visible = !p.visible;
40 p.visible = true;
41 p.invalidate();
42 p.visible = false;
43 }
45 function loaded()
46 {
47 if (!taskbar.available)
48 SimpleTest.finish();
49 let controller = {
50 width: 400,
51 height: 400,
52 thumbnailAspectRatio: 1.0,
53 drawThumbnail: function () { return false; },
54 drawPreview: function () { return false; },
55 get wrappedJSObject() { return this; }
56 }
57 // HACK from mconnor:
58 var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
59 let win = wm.getMostRecentWindow("navigator:browser");
60 let docShell = win.gBrowser.docShell;
62 let winPreview = taskbar.getTaskbarWindowPreview(docShell);
63 isnot(winPreview, null, "Window preview is not null");
64 winPreview.controller = controller;
65 let button = winPreview.getButton(0);
66 isnot(button, null, "Could get button at valid index");
67 try {
68 winPreview.getButton(-1);
69 ok(false, "Got button at negative index");
70 } catch (ex) {}
71 try {
72 winPreview.getButton(Ci.nsITaskbarWindowPreview.NUM_TOOLBAR_BUTTONS);
73 ok(false, "Got button at index that is too large");
74 } catch (ex) {}
75 button.image = null;
76 stdPreviewSuite(winPreview);
77 // Let's not perma-hide this window from the taskbar
78 winPreview.visible = true;
80 let tabP = taskbar.createTaskbarTabPreview(docShell, controller);
81 isnot(tabP, null, "Tab preview is not null");
82 is(tabP.controller.wrappedJSObject, controller, "Controllers match");
83 is(tabP.icon, null, "Default icon is null (windows default)");
84 tabP.icon = null;
85 tabP.move(null);
86 try {
87 tabP.move(tabP);
88 ok(false, "Moved a preview next to itself!");
89 } catch (ex) {}
90 stdPreviewSuite(tabP);
92 let tabP2 = taskbar.createTaskbarTabPreview(docShell, controller);
93 tabP.visible = true;
94 tabP2.visible = true;
96 isnot(tabP2, null, "2nd Tab preview is not null");
97 isnot(tabP,tabP2, "Tab previews are different");
98 tabP.active = true;
99 ok(tabP.active && !tabP2.active, "Only one tab is active (part 1)");
100 tabP2.active = true;
101 ok(!tabP.active && tabP2.active, "Only one tab is active (part 2)");
102 tabP.active = true;
103 ok(tabP.active && !tabP2.active, "Only one tab is active (part 3)");
104 tabP.active = false;
105 ok(!tabP.active && !tabP2.active, "Neither tab is active");
106 is(winPreview.active, false, "Window preview is not active");
107 tabP.active = true;
108 winPreview.active = true;
109 ok(winPreview.active && !tabP.active, "Tab preview takes activation from window");
110 tabP.active = true;
111 ok(tabP.active && !winPreview.active, "Tab preview takes activation from window");
113 tabP.visible = false;
114 tabP2.visible = false;
116 SimpleTest.finish();
117 }
118 ]]>
119 </script>
121 <body xmlns="http://www.w3.org/1999/xhtml">
122 <p id="display"></p>
123 <div id="content" style="display: none"></div>
124 <pre id="test"></pre>
125 </body>
127 </window>