2 <?xml-stylesheet href=
"chrome://global/skin" type=
"text/css"?>
3 <?xml-stylesheet href=
"chrome://mochikit/content/tests/SimpleTest/test.css"
5 <window title=
"Taskbar Previews Test"
6 xmlns=
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
9 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
10 <script class=
"testbody" type=
"application/javascript">
12 ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm");
14 let TP = Ci.nsITaskbarProgress;
16 function IsWin7OrHigher() {
18 var sysInfo = Cc[
"@mozilla.org/system-info;1"].
19 getService(Ci.nsIPropertyBag2);
20 var ver = parseFloat(sysInfo.getProperty(
"version"));
27 function winProgress() {
28 let taskbar = Cc[
"@mozilla.org/windows-taskbar;1"];
30 ok(false,
"Taskbar service is always available");
33 taskbar = taskbar.getService(Ci.nsIWinTaskbar);
35 is(taskbar.available, IsWin7OrHigher(),
"Expected availability of taskbar");
36 if (!taskbar.available)
40 var wm = Cc[
"@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
41 let win = wm.getMostRecentWindow(
"navigator:browser");
42 let docShell = win.docShell;
44 let progress = taskbar.getTaskbarProgress(docShell);
45 isnot(progress, null,
"Progress is not null");
48 taskbar.getTaskbarProgress(null);
49 ok(false,
"Got progress for null docshell");
51 ok(true,
"Cannot get progress for null docshell");
57 function macProgress() {
58 let progress = Cc[
"@mozilla.org/widget/macdocksupport;1"];
60 ok(false,
"Should have gotten Mac progress service.");
63 return progress.getService(TP);
66 SimpleTest.waitForExplicitFinish();
70 let isWin = /Win/.test(navigator.platform);
71 let progress = isWin ? winProgress() : macProgress();
72 if (!TP || !progress) {
77 function shouldThrow(s,c,m) {
79 progress.setProgressState(s,c,m);
86 function doesntThrow(s,c,m) {
87 return !shouldThrow(s,c,m);
90 ok(doesntThrow(TP.STATE_NO_PROGRESS,
0,
0),
"No progress state can be set");
91 ok(doesntThrow(TP.STATE_INDETERMINATE,
0,
0),
"Indeterminate state can be set");
92 ok(doesntThrow(TP.STATE_NORMAL,
0,
0),
"Normal state can be set");
93 ok(doesntThrow(TP.STATE_ERROR,
0,
0),
"Error state can be set");
94 ok(doesntThrow(TP.STATE_PAUSED,
0,
0),
"Paused state can be set");
96 ok(shouldThrow(TP.STATE_NO_PROGRESS,
1,
1),
"Cannot set no progress with values");
97 ok(shouldThrow(TP.STATE_INDETERMINATE,
1,
1),
"Cannot set indeterminate with values");
99 // Technically passes since unsigned(-
1)
> 10
100 ok(shouldThrow(TP.STATE_NORMAL, -
1,
10),
"Cannot set negative progress");
101 todo(shouldThrow(TP.STATE_NORMAL,
1, -
1),
"Cannot set negative progress");
102 todo(shouldThrow(TP.STATE_NORMAL, -
1, -
1),
"Cannot set negative progress");
103 todo(shouldThrow(TP.STATE_NORMAL, -
2, -
1),
"Cannot set negative progress");
105 ok(shouldThrow(TP.STATE_NORMAL,
5,
3),
"Cannot set progress greater than max");
107 ok(doesntThrow(TP.STATE_NORMAL,
1,
5),
"Normal state can be set with values");
108 ok(doesntThrow(TP.STATE_ERROR,
3,
6),
"Error state can be set with values");
109 ok(doesntThrow(TP.STATE_PAUSED,
2,
9),
"Paused state can be set with values");
116 <body xmlns=
"http://www.w3.org/1999/xhtml">
118 <div id=
"content" style=
"display: none"></div>
119 <pre id=
"test"></pre>