Bug 1917491 - Part 3: Introduce call-like syntax for resource disposal in DisposableS...
[gecko.git] / widget / tests / taskbar_previews.xhtml
blobb220d5662b9fdaee0ce1d04c4108281f113b0d83
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 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
12 <script class="testbody" type="application/javascript">
13 <![CDATA[
14 let taskbar = Cc["@mozilla.org/windows-taskbar;1"].getService(Ci.nsIWinTaskbar);
16 function IsWin7OrHigher() {
17 try {
18 var ver = parseFloat(Services.sysinfo.getProperty("version"));
19 if (ver >= 6.1)
20 return true;
21 } catch (ex) { }
22 return false;
24 isnot(taskbar, null, "Taskbar service is defined");
25 is(taskbar.available, IsWin7OrHigher(), "Expected availability of taskbar");
27 SimpleTest.waitForExplicitFinish();
29 function stdPreviewSuite(p) {
30 p.visible = !p.visible;
31 p.visible = !p.visible;
32 p.visible = true;
33 p.invalidate();
34 p.visible = false;
37 function loaded()
39 if (!taskbar.available)
40 SimpleTest.finish();
41 let controller = {
42 width: 400,
43 height: 400,
44 thumbnailAspectRatio: 1.0,
45 get wrappedJSObject() { return this; }
47 // HACK from mconnor:
48 let win = Services.wm.getMostRecentWindow("navigator:browser");
49 let docShell = win.gBrowser.docShell;
51 let winPreview = taskbar.getTaskbarWindowPreview(docShell);
52 isnot(winPreview, null, "Window preview is not null");
53 winPreview.controller = controller;
54 let button = winPreview.getButton(0);
55 isnot(button, null, "Could get button at valid index");
56 try {
57 winPreview.getButton(-1);
58 ok(false, "Got button at negative index");
59 } catch (ex) {}
60 try {
61 winPreview.getButton(Ci.nsITaskbarWindowPreview.NUM_TOOLBAR_BUTTONS);
62 ok(false, "Got button at index that is too large");
63 } catch (ex) {}
64 button.image = null;
65 stdPreviewSuite(winPreview);
66 // Let's not perma-hide this window from the taskbar
67 winPreview.visible = true;
69 let tabP = taskbar.createTaskbarTabPreview(docShell, controller);
70 isnot(tabP, null, "Tab preview is not null");
71 is(tabP.controller.wrappedJSObject, controller, "Controllers match");
72 is(tabP.icon, null, "Default icon is null (windows default)");
73 tabP.icon = null;
74 tabP.move(null);
75 try {
76 tabP.move(tabP);
77 ok(false, "Moved a preview next to itself!");
78 } catch (ex) {}
79 stdPreviewSuite(tabP);
81 let tabP2 = taskbar.createTaskbarTabPreview(docShell, controller);
82 tabP.visible = true;
83 tabP2.visible = true;
85 isnot(tabP2, null, "2nd Tab preview is not null");
86 isnot(tabP,tabP2, "Tab previews are different");
87 tabP.active = true;
88 ok(tabP.active && !tabP2.active, "Only one tab is active (part 1)");
89 tabP2.active = true;
90 ok(!tabP.active && tabP2.active, "Only one tab is active (part 2)");
91 tabP.active = true;
92 ok(tabP.active && !tabP2.active, "Only one tab is active (part 3)");
93 tabP.active = false;
94 ok(!tabP.active && !tabP2.active, "Neither tab is active");
95 is(winPreview.active, false, "Window preview is not active");
96 tabP.active = true;
97 winPreview.active = true;
98 ok(winPreview.active && !tabP.active, "Tab preview takes activation from window");
99 tabP.active = true;
100 ok(tabP.active && !winPreview.active, "Tab preview takes activation from window");
102 tabP.visible = false;
103 tabP2.visible = false;
105 SimpleTest.finish();
108 </script>
110 <body xmlns="http://www.w3.org/1999/xhtml">
111 <p id="display"></p>
112 <div id="content" style="display: none"></div>
113 <pre id="test"></pre>
114 </body>
116 </window>