1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<!DOCTYPE HTML>
<html>
<head>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
</head>
<body onload="run()">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
async function run() {
try {
let printerList = Cc["@mozilla.org/gfx/printerlist;1"].getService(
Ci.nsIPrinterList
);
let printers = await printerList.printers;
if (printers.length == 0) {
ok(true, "There were no printers to iterate through.");
}
for (let printer of printers) {
printer.QueryInterface(Ci.nsIPrinter);
info(printer.name);
info("duplex(" + await printer.supportsDuplex + ")");
const printerInfo = await printer.printerInfo;
const settings = printerInfo.defaultSettings;
settings.QueryInterface(Ci.nsIPrintSettings);
is(typeof settings.printerName, "string", "Printer name should be a string.");
is(settings.printerName, printer.name, "Print settings' printer should match the printer that created them.");
is(typeof settings.paperId, "string", "Paper ID should never be null.");
is(typeof settings.paperWidth, "number", "Paper width should never be null.");
is(typeof settings.paperHeight, "number", "Paper height should never be null.");
if (settings.paperId != "") {
info(`Paper: ${settings.paperId}`);
info(`Size: (${settings.paperWidth} x ${settings.paperHeight})`);
ok(settings.paperWidth > 0.0, "Paper width should be greater than zero.");
ok(settings.paperHeight > 0.0, "Paper height should be greater than zero.");
}
ok(settings.marginTop >= 0.0, "Paper margins should be greater than or equal to zero.");
ok(settings.marginRight >= 0.0, "Paper margins should be greater than or equal to zero.");
ok(settings.marginBottom >= 0.0, "Paper margins should be greater than or equal to zero.");
ok(settings.marginLeft >= 0.0, "Paper margins should be greater than or equal to zero.");
is(settings.printInColor, await printer.supportsColor, "Print settings' color mode should match the printer's color support.");
ok(settings.isInitializedFromPrinter, "Print settings were initialized from printer");
ok(!settings.isInitializedFromPrefs);
}
} catch (e) {
ok(false, `Shouldn't throw: ${e}`);
console.error(e);
}
SimpleTest.finish();
}
</script>
</body>
</html>
|