toolkit/devtools/server/tests/mochitest/test_device.html

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:2b08125c29c5
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 type="application/javascript" 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
16 window.onload = function() {
17 var Cu = Components.utils;
18 var Cc = Components.classes;
19 var Ci = Components.interfaces;
20
21 Cu.import("resource://gre/modules/PermissionsTable.jsm");
22 Cu.import("resource://gre/modules/devtools/Loader.jsm");
23 Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
24 Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
25 Cu.import("resource://gre/modules/Services.jsm");
26
27 SimpleTest.waitForExplicitFinish();
28
29 var {getDeviceFront} = devtools.require("devtools/server/actors/device");
30
31 DebuggerServer.init(function () { return true; });
32 DebuggerServer.addBrowserActors();
33
34 var client = new DebuggerClient(DebuggerServer.connectPipe());
35 client.connect(function onConnect() {
36 client.listTabs(function onListTabs(aResponse) {
37 var d = getDeviceFront(client, aResponse);
38
39 var desc, permissions;
40 var appInfo = Services.appinfo;
41 var utils = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
42
43
44 var localDesc = {
45 appid: appInfo.ID,
46 vendor: appInfo.vendor,
47 name: appInfo.name,
48 version: appInfo.version,
49 appbuildid: appInfo.appBuildID,
50 platformbuildid: appInfo.platformBuildID,
51 platformversion: appInfo.platformVersion,
52 geckobuildid: appInfo.platformBuildID,
53 geckoversion: appInfo.platformVersion,
54 useragent: window.navigator.userAgent,
55 locale: Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIXULChromeRegistry).getSelectedLocale("global"),
56 os: appInfo.OS,
57 processor: appInfo.XPCOMABI.split("-")[0],
58 compiler: appInfo.XPCOMABI.split("-")[1],
59 dpi: utils.displayDPI,
60 width: window.screen.width,
61 height: window.screen.height
62 }
63
64 function checkValues() {
65 for (var key in localDesc) {
66 is(desc[key], localDesc[key], "valid field (" + key + ")");
67 }
68
69 var currProfD = Services.dirsvc.get("ProfD", Ci.nsIFile);
70 var profileDir = currProfD.path;
71 ok(profileDir.indexOf(desc.profile.length > 0 && desc.profile) != -1, "valid profile name");
72
73 var a = JSON.stringify(PermissionsTable);
74 var b = JSON.stringify(permissions.rawPermissionsTable);
75
76 is(a, b, "Permissions Tables is valid");
77
78 client.close(() => {
79 DebuggerServer.destroy();
80 SimpleTest.finish()
81 });
82 }
83
84
85 d.getDescription().then((v) => desc = v)
86 .then(() => d.getRawPermissionsTable())
87 .then((json) => permissions = json)
88 .then(checkValues);
89
90 });
91 });
92
93 }
94 </script>
95 </pre>
96 </body>
97 </html>

mercurial