tor-browser

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

test_device.html (2305B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 Bug 895360 - [app manager] Device meta data actor
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Mozilla Bug</title>
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     10  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
     11 </head>
     12 <body>
     13 <pre id="test">
     14 <script>
     15 "use strict";
     16 
     17 window.onload = function() {
     18  const {require} = ChromeUtils.importESModule("resource://devtools/shared/loader/Loader.sys.mjs");
     19  const {DevToolsClient} = require("devtools/client/devtools-client");
     20  const {DevToolsServer} = require("devtools/server/devtools-server");
     21 
     22  SimpleTest.waitForExplicitFinish();
     23 
     24  DevToolsServer.init();
     25  DevToolsServer.registerAllActors();
     26 
     27  const client = new DevToolsClient(DevToolsServer.connectPipe());
     28  client.connect().then(function onConnect() {
     29    return client.mainRoot.getFront("device");
     30  }).then(function(d) {
     31    let desc;
     32    const appInfo = Services.appinfo;
     33    const utils = window.windowUtils;
     34 
     35    const localDesc = {
     36      appid: appInfo.ID,
     37      vendor: appInfo.vendor,
     38      name: appInfo.name,
     39      version: appInfo.version,
     40      appbuildid: appInfo.appBuildID,
     41      platformbuildid: appInfo.platformBuildID,
     42      platformversion: appInfo.platformVersion,
     43      geckobuildid: appInfo.platformBuildID,
     44      geckoversion: appInfo.platformVersion,
     45      useragent: window.navigator.userAgent,
     46      locale: Services.locale.appLocaleAsBCP47,
     47      os: appInfo.OS,
     48      processor: appInfo.XPCOMABI.split("-")[0],
     49      compiler: appInfo.XPCOMABI.split("-")[1],
     50      dpi: utils.displayDPI,
     51      width: window.screen.width,
     52      height: window.screen.height,
     53    };
     54 
     55    function checkValues() {
     56      for (const key in localDesc) {
     57        is(desc[key], localDesc[key], "valid field (" + key + ")");
     58      }
     59 
     60      const currProfD = Services.dirsvc.get("ProfD", Ci.nsIFile);
     61      const profileDir = currProfD.path;
     62      ok(profileDir.includes(!!desc.profile.length && desc.profile),
     63         "valid profile name");
     64 
     65      client.close().then(() => {
     66        DevToolsServer.destroy();
     67        SimpleTest.finish();
     68      });
     69    }
     70 
     71    d.getDescription().then(function(v) {
     72      desc = v;
     73    }).then(checkValues);
     74  });
     75 };
     76 </script>
     77 </pre>
     78 </body>
     79 </html>