コード例 #1
0
def build_quick_xpcom(method, interface, traverser):
    """A shortcut to quickly build XPCOM objects on the fly."""
    constructor = xpcom_const(method, pretraversed=True)
    interface_obj = traverser._build_global(name=method, entity={"xpcom_map": lambda: INTERFACES[interface]})
    object = constructor(None, [interface_obj], traverser)
    if isinstance(object, JSWrapper):
        object = object.value
    return object
コード例 #2
0
         u"sin": {"return": python_wrap(math.sin, [("num", 0)])},
         u"sqrt": {"return": python_wrap(math.sqrt, [("num", 1)])},
         u"tan": {"return": python_wrap(math.tan, [("num", 0)])},
     }
 },
 u"netscape": {
     "value": {u"security": {"value": {u"PrivilegeManager": {"value": {u"enablePrivilege": {"dangerous": True}}}}}}
 },
 u"navigator": {"value": {u"wifi": {"dangerous": True}, u"geolocation": {"dangerous": True}}},
 u"Components": {
     "readonly": True,
     "value": {
         u"classes": {
             "xpcom_wildcard": True,
             "value": {
                 u"createInstance": {"return": xpcom_const("createInstance")},
                 u"getService": {"return": xpcom_const("getService")},
             },
         },
         "utils": {
             "value": {
                 u"evalInSandbox": {"dangerous": True},
                 u"import": {
                     "dangerous": lambda a, t, e: a and _get_as_str(t(a[0]).get_literal_value()).count("ctypes.jsm")
                 },
             }
         },
         u"interfaces": {
             "value": {
                 u"nsIXMLHttpRequest": {"xpcom_map": lambda: GLOBAL_ENTITIES["XMLHttpRequest"]},
                 u"nsIAccessibleRetrieval": {"xpcom_map": lambda: INTERFACES["nsIAccessibleRetrieval"]},