diff options
Diffstat (limited to 'layout/base/tests/chrome/test_printer_default_settings.html')
-rw-r--r-- | layout/base/tests/chrome/test_printer_default_settings.html | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/layout/base/tests/chrome/test_printer_default_settings.html b/layout/base/tests/chrome/test_printer_default_settings.html new file mode 100644 index 0000000000..a37a1db070 --- /dev/null +++ b/layout/base/tests/chrome/test_printer_default_settings.html @@ -0,0 +1,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}`); + Cu.reportError(e); + } + SimpleTest.finish(); +} + +</script> +</body> +</html> |