blob: 13d32c15b18daae27055feecdebcf4196d7a5b25 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
from firefox_puppeteer.base import BaseLib
class AppInfo(BaseLib):
"""This class provides access to various attributes of AppInfo.
For more details on AppInfo, visit:
https://developer.mozilla.org/en-US/docs/Mozilla/QA/Mozmill_tests/Shared_Modules/UtilsAPI/appInfo
"""
def __getattr__(self, attr):
with self.marionette.using_context('chrome'):
value = self.marionette.execute_script("""
Components.utils.import("resource://gre/modules/Services.jsm");
return Services.appinfo[arguments[0]];
""", script_args=[attr])
if value is not None:
return value
else:
raise AttributeError('{} has no attribute {}'.format(self.__class__.__name__,
attr))
@property
def locale(self):
with self.marionette.using_context('chrome'):
return self.marionette.execute_script("""
return Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIXULChromeRegistry)
.getSelectedLocale("global");
""")
@property
def user_agent(self):
with self.marionette.using_context('chrome'):
return self.marionette.execute_script("""
return Components.classes["@mozilla.org/network/protocol;1?name=http"]
.getService(Components.interfaces.nsIHttpProtocolHandler)
.userAgent;
""")
|