summaryrefslogtreecommitdiffstats
path: root/layout/base/tests/chrome/test_get_printer_paper_sizes.html
diff options
context:
space:
mode:
Diffstat (limited to 'layout/base/tests/chrome/test_get_printer_paper_sizes.html')
-rw-r--r--layout/base/tests/chrome/test_get_printer_paper_sizes.html69
1 files changed, 69 insertions, 0 deletions
diff --git a/layout/base/tests/chrome/test_get_printer_paper_sizes.html b/layout/base/tests/chrome/test_get_printer_paper_sizes.html
new file mode 100644
index 0000000000..4ebe462ac6
--- /dev/null
+++ b/layout/base/tests/chrome/test_get_printer_paper_sizes.html
@@ -0,0 +1,69 @@
+<!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);
+ 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>