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);
is(typeof(printer.name), 'string', "Printer name should be a string.");
isnot(printer.name, "", "Printer name should never be empty.");
info(printer.name);
info("duplex(" + printer.supportsDuplex + ")");
let printerInfo = await printer.printerInfo;
for (let paper of printerInfo.paperList) {
paper.QueryInterface(Ci.nsIPaper);
info(`${paper.name}: ${paper.width}x${paper.height}`);
is(typeof(paper.name), 'string', "Paper name should be a string.");
isnot(paper.name, "", "Paper name should never be empty.");
is(typeof(paper.width), 'number', "Paper width should be a number.");
ok(paper.width > 0.0, "Paper width should be greater than zero.");
is(typeof(paper.height), 'number', "Paper height should be a number.");
ok(paper.height > 0.0, "Paper height should be greater than zero.");
let margin = await paper.unwriteableMargin;
margin.QueryInterface(Ci.nsIPaperMargin);
info(`with margin: ${margin.top} ${margin.right} ${margin.bottom} ${margin.left}`);
is(typeof(margin.top), 'number', "Paper unwriteable margin top should be a number.");
is(typeof(margin.right), 'number', "Paper unwriteable margin right should be a number.");
is(typeof(margin.bottom), 'number', "Paper unwriteable margin bottom should be a number.");
is(typeof(margin.left), 'number', "Paper unwriteable margin left should be a number.");
ok(margin.top >= 0.0, "Paper unwriteable margin top should be greater than or equal to zero.");
ok(margin.right >= 0.0, "Paper unwriteable margin right should be greater than or equal to zero.");
ok(margin.bottom >= 0.0, "Paper unwriteable bottom right should be greater than or equal to zero.");
ok(margin.left >= 0.0, "Paper unwriteable margin left should be greater than or equal to zero.");
}
}
} catch (e) {
ok(false, `Shouldn't throw: ${e}`);
console.error(e);
}
SimpleTest.finish();
}
</script>
</body>
</html>