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 type=
"application/javascript"
10 src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
11 <script class=
"testbody" type=
"application/javascript">
13 let Cc = Components.classes;
14 let Ci = Components.interfaces;
15 let Cu = Components.utils;
16 Cu.import(
"resource://gre/modules/XPCOMUtils.jsm");
18 let TP = Ci.nsITaskbarProgress;
20 function winProgress() {
21 let taskbar = Cc[
"@mozilla.org/windows-taskbar;1"];
24 taskbar = taskbar.getService(Ci.nsIWinTaskbar);
25 if (!taskbar.available)
29 var wm = Cc[
"@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
30 let win = wm.getMostRecentWindow(
"navigator:browser");
31 let docShell = win.gBrowser.docShell;
33 let progress = taskbar.getTaskbarProgress(docShell);
34 isnot(progress, null,
"Progress is not null");
37 taskbar.getTaskbarProgress(null);
38 ok(false,
"Got progress for null docshell");
40 ok(true,
"Cannot get progress for null docshell");
46 function macProgress() {
47 let progress = Cc[
"@mozilla.org/widget/macdocksupport;1"];
50 return progress.getService(TP);
53 SimpleTest.waitForExplicitFinish();
57 let progress = winProgress() || macProgress();
61 function shouldThrow(s,c,m) {
63 progress.setProgressState(s,c,m);
70 function doesntThrow(s,c,m) !shouldThrow(s,c,m)
72 ok(doesntThrow(TP.STATE_NO_PROGRESS,
0,
0),
"No progress state can be set");
73 ok(doesntThrow(TP.STATE_INDETERMINATE,
0,
0),
"Indeterminate state can be set");
74 ok(doesntThrow(TP.STATE_NORMAL,
0,
0),
"Normal state can be set");
75 ok(doesntThrow(TP.STATE_ERROR,
0,
0),
"Error state can be set");
76 ok(doesntThrow(TP.STATE_PAUSED,
0,
0),
"Paused state can be set");
78 ok(shouldThrow(TP.STATE_NO_PROGRESS,
1,
1),
"Cannot set no progress with values");
79 ok(shouldThrow(TP.STATE_INDETERMINATE,
1,
1),
"Cannot set indeterminate with values");
81 // Technically passes since unsigned(-
1)
> 10
82 ok(shouldThrow(TP.STATE_NORMAL, -
1,
10),
"Cannot set negative progress");
83 todo(shouldThrow(TP.STATE_NORMAL,
1, -
1),
"Cannot set negative progress");
84 todo(shouldThrow(TP.STATE_NORMAL, -
1, -
1),
"Cannot set negative progress");
85 todo(shouldThrow(TP.STATE_NORMAL, -
2, -
1),
"Cannot set negative progress");
87 ok(shouldThrow(TP.STATE_NORMAL,
5,
3),
"Cannot set progress greater than max");
89 ok(doesntThrow(TP.STATE_NORMAL,
1,
5),
"Normal state can be set with values");
90 ok(doesntThrow(TP.STATE_ERROR,
3,
6),
"Error state can be set with values");
91 ok(doesntThrow(TP.STATE_PAUSED,
2,
9),
"Paused state can be set with values");
98 <body xmlns=
"http://www.w3.org/1999/xhtml">
100 <div id=
"content" style=
"display: none"></div>
101 <pre id=
"test"></pre>