tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_get_printer_orientation.html (1562B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
      5 </head>
      6 <body onload="run()">
      7 <script>
      8 
      9 SimpleTest.waitForExplicitFinish();
     10 
     11 async function run() {
     12  try {
     13    let printerList = Cc["@mozilla.org/gfx/printerlist;1"].getService(
     14      Ci.nsIPrinterList
     15    );
     16    var settingsSvc = Cc["@mozilla.org/gfx/printsettings-service;1"].getService(
     17      Ci.nsIPrintSettingsService
     18    );
     19 
     20    let printers = await printerList.printers;
     21    for (let printer of printers) {
     22      printer.QueryInterface(Ci.nsIPrinter);
     23      let printerInfo = await printer.printerInfo;
     24 
     25      // Look up the printer's defaultSettings:
     26      let defaultSettings = printerInfo.defaultSettings;
     27 
     28      // Let the printer impose its defaults onto a fresh settings object:
     29      let freshSettings = settingsSvc.createNewPrintSettings();
     30      printerList.initPrintSettingsFromPrinter(printer.name, freshSettings);
     31 
     32      // Make sure they agree on the default orientation:
     33      is(freshSettings.orientation, defaultSettings.orientation,
     34         "initPrintSettingsFromPrinter should produce the same orientation " +
     35         "as the printer's defaultSettings");
     36    }
     37 
     38    // This ok() just lets us avoid failure-due-to-no-tests-being-run, on
     39    // devices that have no printers available & hence skip the loop above:
     40    ok(true, "Finished traversing printers.");
     41  } catch (e) {
     42    ok(false, `Error thrown while retrieving printer info: ${e}.`);
     43    console.error(e);
     44  }
     45  SimpleTest.finish();
     46 }
     47 
     48 </script>
     49 </body>
     50 </html>