Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE HTML>
<html>
<head>
</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>