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 let TP = Ci.nsITaskbarProgress;
14 function IsWin7OrHigher() {
16 var ver = parseFloat(Services.sysinfo.getProperty(
"version"));
23 function winProgress() {
24 let taskbar = Cc[
"@mozilla.org/windows-taskbar;1"];
26 ok(false,
"Taskbar service is always available");
29 taskbar = taskbar.getService(Ci.nsIWinTaskbar);
31 is(taskbar.available, IsWin7OrHigher(),
"Expected availability of taskbar");
32 if (!taskbar.available)
36 let win = Services.wm.getMostRecentWindow(
"navigator:browser");
37 let docShell = win.docShell;
39 let progress = taskbar.getTaskbarProgress(docShell);
40 isnot(progress, null,
"Progress is not null");
43 taskbar.getTaskbarProgress(null);
44 ok(false,
"Got progress for null docshell");
46 ok(true,
"Cannot get progress for null docshell");
52 function macProgress() {
53 let progress = Cc[
"@mozilla.org/widget/macdocksupport;1"];
55 ok(false,
"Should have gotten Mac progress service.");
58 return progress.getService(TP);
61 SimpleTest.waitForExplicitFinish();
65 let isWin = /Win/.test(navigator.platform);
66 let progress = isWin ? winProgress() : macProgress();
67 if (!TP || !progress) {
72 function shouldThrow(s,c,m) {
74 progress.setProgressState(s,c,m);
81 function doesntThrow(s,c,m) {
82 return !shouldThrow(s,c,m);
85 ok(doesntThrow(TP.STATE_NO_PROGRESS,
0,
0),
"No progress state can be set");
86 ok(doesntThrow(TP.STATE_INDETERMINATE,
0,
0),
"Indeterminate state can be set");
87 ok(doesntThrow(TP.STATE_NORMAL,
0,
0),
"Normal state can be set");
88 ok(doesntThrow(TP.STATE_ERROR,
0,
0),
"Error state can be set");
89 ok(doesntThrow(TP.STATE_PAUSED,
0,
0),
"Paused state can be set");
91 ok(shouldThrow(TP.STATE_NO_PROGRESS,
1,
1),
"Cannot set no progress with values");
92 ok(shouldThrow(TP.STATE_INDETERMINATE,
1,
1),
"Cannot set indeterminate with values");
94 // Technically passes since unsigned(-
1)
> 10
95 ok(shouldThrow(TP.STATE_NORMAL, -
1,
10),
"Cannot set negative progress");
96 todo(shouldThrow(TP.STATE_NORMAL,
1, -
1),
"Cannot set negative progress");
97 todo(shouldThrow(TP.STATE_NORMAL, -
1, -
1),
"Cannot set negative progress");
98 todo(shouldThrow(TP.STATE_NORMAL, -
2, -
1),
"Cannot set negative progress");
100 ok(shouldThrow(TP.STATE_NORMAL,
5,
3),
"Cannot set progress greater than max");
102 ok(doesntThrow(TP.STATE_NORMAL,
1,
5),
"Normal state can be set with values");
103 ok(doesntThrow(TP.STATE_ERROR,
3,
6),
"Error state can be set with values");
104 ok(doesntThrow(TP.STATE_PAUSED,
2,
9),
"Paused state can be set with values");
111 <body xmlns=
"http://www.w3.org/1999/xhtml">
113 <div id=
"content" style=
"display: none"></div>
114 <pre id=
"test"></pre>