tor-browser

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

xpccomponents.idl (32091B)


      1 /* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #include "nsISupports.idl"
      7 
      8 %{C++
      9 #include "jspubtd.h"
     10 %}
     11 
     12 interface xpcIJSWeakReference;
     13 interface nsIClassInfo;
     14 interface nsICommandParams;
     15 interface nsIComponentManager;
     16 interface nsICycleCollectorListener;
     17 interface nsIDocumentEncoder;
     18 interface nsIEditorSpellCheck;
     19 interface nsIFile;
     20 interface nsILoadContext;
     21 interface nsIPersistentProperties;
     22 interface nsIURI;
     23 interface nsIPrincipal;
     24 interface nsIStackFrame;
     25 webidl Element;
     26 
     27 /**
     28 * interface of Components.interfaces
     29 * (interesting stuff only reflected into JavaScript)
     30 */
     31 [scriptable, builtinclass, uuid(b8c31bba-79db-4a1d-930d-4cdd68713f9e)]
     32 interface nsIXPCComponents_Interfaces : nsISupports
     33 {
     34 };
     35 
     36 /**
     37 * interface of Components.classes
     38 * (interesting stuff only reflected into JavaScript)
     39 */
     40 [scriptable, builtinclass, uuid(978ff520-d26c-11d2-9842-006008962422)]
     41 interface nsIXPCComponents_Classes : nsISupports
     42 {
     43 };
     44 
     45 /**
     46 * interface of Components.results
     47 * (interesting stuff only reflected into JavaScript)
     48 */
     49 [scriptable, builtinclass, uuid(2fc229a0-5860-11d3-9899-006008962422)]
     50 interface nsIXPCComponents_Results : nsISupports
     51 {
     52 };
     53 
     54 /**
     55 * interface of Components.ID
     56 * (interesting stuff only reflected into JavaScript)
     57 */
     58 [scriptable, builtinclass, uuid(7994a6e0-e028-11d3-8f5d-0010a4e73d9a)]
     59 interface nsIXPCComponents_ID : nsISupports
     60 {
     61 };
     62 
     63 /**
     64 * interface of Components.Exception
     65 * (interesting stuff only reflected into JavaScript)
     66 */
     67 [scriptable, builtinclass, uuid(5bf039c0-e028-11d3-8f5d-0010a4e73d9a)]
     68 interface nsIXPCComponents_Exception : nsISupports
     69 {
     70 };
     71 
     72 /**
     73 * interface of Components.Constructor
     74 * (interesting stuff only reflected into JavaScript)
     75 */
     76 [scriptable, builtinclass, uuid(88655640-e028-11d3-8f5d-0010a4e73d9a)]
     77 interface nsIXPCComponents_Constructor : nsISupports
     78 {
     79 };
     80 
     81 /**
     82 * interface of object returned by Components.utils.Sandbox.
     83 */
     84 [scriptable, builtinclass, uuid(4f8ae0dc-d266-4a32-875b-6a9de71a8ce9)]
     85 interface nsIXPCComponents_utils_Sandbox : nsISupports
     86 {
     87 };
     88 
     89 /**
     90 * interface for callback to be passed to Cu.schedulePreciseGC
     91 */
     92 [scriptable, function, uuid(71000535-b0fd-44d1-8ce0-909760e3953c)]
     93 interface nsIScheduledGCCallback : nsISupports
     94 {
     95    void callback();
     96 };
     97 
     98 /**
     99 * interface of Components.utils
    100 */
    101 [scriptable, builtinclass, uuid(86003fe3-ee9a-4620-91dc-eef8b1e58815)]
    102 interface nsIXPCComponents_Utils : nsISupports
    103 {
    104    /*
    105     * Prints the provided message to stderr.
    106     */
    107    void printStderr(in AUTF8String message);
    108 
    109    /*
    110     * reportError is designed to be called from JavaScript only.
    111     *
    112     * It will report a JS Error object to the JS console, and return. It
    113     * is meant for use in exception handler blocks which want to "eat"
    114     * an exception, but still want to report it to the console.
    115     *
    116     * It must be called with one param, usually an object which was caught by
    117     * an exception handler.  If it is not a JS error object, the parameter
    118     * is converted to a string and reported as a new error.
    119     *
    120     * If called with two parameters, and the first parameter is not an
    121     * object, the second parameter is used as the stack for the error report.
    122     */
    123    [implicit_jscontext]
    124    void reportError(in jsval error, [optional] in jsval stack);
    125 
    126 
    127    /**
    128     * Cu.Sandbox is used to create a sandbox object
    129     *
    130     *     let sandbox = Cu.Sandbox(principal[, options]);
    131     *
    132     * Using new Cu.Sandbox(...) to create a sandbox has the same effect as
    133     * calling Cu.Sandbox(...) without new.
    134     *
    135     * In JS, Cu.Sandbox uses the following parameters:
    136     *
    137     * @param {Principal} principal
    138     *        The security principal defined for a sandbox determines what code
    139     *        running in that sandbox will be allowed to do. The principal may be one
    140     *        of four types: the system principal, a content principal, an expanded
    141     *        principal or a null principal. Depending on the principal type,
    142     *        this argument can be a nsIPrincipal, a Window, a String, an Array
    143     *        or null. See below.
    144     *          A content principal can be provided by passing a nsIPrincipal, a
    145     *        DOM Window, or a string URI (not recommended).
    146     *          An expanded (or extended) principal is an array of principals,
    147     *        where each item can be either a nsIPrincipal, a DOM window or a
    148     *        string URI.
    149     *          A null principal can either be specified by passing `null` or
    150     *        created explicitly with `Cc["@mozilla.org/nullprincipal;1"].createInstance(Ci.nsIPrincipal);`
    151     * @param {Object} options
    152     *        Optional parameters, valid properties are:
    153     *        - allowWaivers: {Boolean} Allows the caller to waive Xrays, in case
    154     *          Xrays were used. Defaults to true.
    155     *        - discardSource: {Boolean} For certain globals, we know enough about
    156     *          the code that will run in them that we can discard script source
    157     *          entirely. A discarded source will be re-read when stringifying
    158     *          functions.
    159     *            Defaults to false.
    160     *        - forceSecureContext: {Boolean} Determines whether content windows and
    161     *          workers are marked as "Secure Context"s. If principal is the system
    162     *          principal, the value is forced to true. Otherwise defaults to false.
    163     *        - freshCompartment: {Boolean} Whether the sandbox should be created
    164     *          using a new compartment. Defaults to false.
    165     *        - freshZone: {Boolean} if true creates a new GC region separate from
    166     *          both the calling context's and the sandbox prototype's region.
    167     *            Defaults to false.
    168     *        - invisibleToDebugger: {Boolean} Whether this sandbox and its scripts
    169     *          can be accessed by the JavaScript Debugger.
    170     *            Defaults to false.
    171     *        - isWebExtensionContentScript: {Boolean} Whether this sandbox
    172     *          corresponds to a WebExtension content script, and should receive
    173     *          various bits of special compatibility behavior.
    174     *            Defaults to false.
    175     *        - metadata: {Object} Object to use as the metadata for the sandbox. See
    176     *          setSandboxMetadata.
    177     *        - originAttributes: {Object} Dictionary of origin attributes to use if
    178     *          the principal was provided as a string.
    179     *        - sameZoneAs: {Object} Javascript Object in whose garbage collection
    180     *          region the sandbox should be created. This helps to improve memory
    181     *          usage by allowing sandboxes to be discarded when that zone goes away.
    182     *          It also improves performance and memory usage by allowing strings
    183     *          to be passed between the compartments without copying or using
    184     *          wrappers.
    185     *            Content scripts should pass the window they're running in as this
    186     *          parameter, in order to ensure that the script is cleaned up at the
    187     *          same time as the content itself.
    188     *        - sandboxContentSecurityPolicy: {String} The Content Security Policy
    189     *          to apply in this sandbox. This can be used to restrict eval
    190     *          (e.g. "script-src 'self'"). It does not apply to DOM methods
    191     *          that were retrieved from objects outside the sandbox.
    192     *          This is only implemented for Expanded Principals; if desired for
    193     *          other principals, bug 1548468 must be resolved first.
    194     *          When not specified, the default CSP is used (usually no CSP).
    195     *        - sandboxName: {String} Identifies the sandbox in about:memory. This
    196     *          property is optional, but very useful for tracking memory usage. A
    197     *          recommended value for this property is an absolute path to the script
    198     *          responsible for creating the sandbox. If you don't specify a sandbox
    199     *          name it will default to the caller's filename.
    200     *        - sandboxPrototype: {Object} Prototype object for the sandbox. The
    201     *          sandbox will inherit the contents of this object if it's provided.
    202     *          Passing a content window object, setting wantXrays:true (default) and
    203     *          using an extended principal provides a clean, isolated execution
    204     *          environment in which javascript code that needs Web APIs (such as
    205     *          accessing the window's DOM) can be executed without interference from
    206     *          untrusted content code.
    207     *        - userContextId: {Number} The id of the user context this sandbox is
    208     *          inside. Defaults to 0.
    209     *        - wantComponents: {Boolean} Indicates whether the Components object is
    210     *          available or not in the sandbox. If the sandbox interacts with
    211     *          untrusted content this should be set to false when possible to
    212     *          further reduce possible attack surface.
    213     *            Defaults to true.
    214     *        - wantExportHelpers: {Boolean} if true, then createObjectIn(),
    215     *          evalInWindow(), and exportFunction() are available in the sandbox.
    216     *            Defaults to false.
    217     *        - wantGlobalProperties: {Array<String>} Each string is the name of an
    218     *          object that you want to make available as a global to code running in
    219     *          the sandbox. Possible values: Blob, ChromeUtils, CSS, CSSRule,
    220     *          Directory, DOMParser, Element, Event, File, FileReader, FormData,
    221     *          InspectorCSSParser, InspectorUtils, MessageChannel, Node, NodeFilter,
    222                PromiseDebugging, TextDecoder, TextEncoder, URL, URLSearchParams,
    223                XMLHttpRequest, XMLSerializer, atob, btoa, caches, crypto, fetch,
    224                indexedDB, rtcIdentityProvider
    225     *        - wantXrays: {Boolean} Whether the sandbox wants Xray vision with
    226     *          respect to same-origin objects outside the sandbox.
    227     *            Note that wantXrays is essentially deprecated. The preferred method
    228     *          of handling this now is to give the sandbox an expanded principal
    229     *          which inherits from the principal of the content compartment the
    230     *          sandbox will interact with. That lets the sandbox see the content
    231     *          compartment through X-ray wrappers, and gives any object passed from
    232     *          the sandbox to the content compartment opaque security wrappers unless
    233     *          export helpers are explicitly used.
    234     *            "Xray vision" is exactly the same Xray behavior that script always
    235     *          gets, by default, when working with DOM objects across origin
    236     *          boundaries. This is primarily visible for chrome code accessing
    237     *          content. However, it also occurs during cross-origin access between
    238     *          two content pages, since each page sees a "vanilla" view of the
    239     *          other. The protection is bidirectional: the caller sees the bonafide
    240     *          DOM objects without being confused by sneakily-redefined properties,
    241     *          and the target receives appropriate privacy from having its expandos
    242     *          inspected by untrusted callers. In situations where only
    243     *          unidirectional protection is needed, callers have the option to waive
    244     *          the X-ray behavior using wrappedJSObject or XPCNativeWrapper.unwrap().
    245     *            In general, when accessing same-origin content, script gets a
    246     *          Transparent wrapper rather than an Xray wrapper. However, sandboxes
    247     *          are often used when chrome wants to run script as another origin,
    248     *          possibly to interact with the page. In this case, same-origin Xrays
    249     *          are desirable, and wantXrays should be set to true.
    250     *            Defaults to true.
    251     */
    252    readonly attribute nsIXPCComponents_utils_Sandbox Sandbox;
    253 
    254    /*
    255     * evalInSandbox is designed to be called from JavaScript only.
    256     *
    257     * evalInSandbox evaluates the provided source string in the given sandbox.
    258     * It returns the result of the evaluation to the caller.
    259     *
    260     * var s = new C.u.Sandbox("http://www.mozilla.org");
    261     * var res = C.u.evalInSandbox("var five = 5; 2 + five", s);
    262     * var outerFive = s.five;
    263     * s.seven = res;
    264     * var thirtyFive = C.u.evalInSandbox("five * seven", s);
    265     */
    266    [implicit_jscontext,optional_argc]
    267    jsval evalInSandbox(in AString source, in jsval sandbox,
    268                        [optional] in jsval version,
    269                        [optional] in AUTF8String filename,
    270                        [optional] in long lineNo,
    271                        [optional] in boolean enforceFilenameRestrictions);
    272 
    273    /*
    274     * Get the sandbox for running JS-implemented UA widgets (video controls etc.),
    275     * hosted inside UA-created Shadow DOM.
    276     */
    277    [implicit_jscontext]
    278    jsval getUAWidgetScope(in nsIPrincipal principal);
    279 
    280    /*
    281     * getSandboxMetadata is designed to be called from JavaScript only.
    282     *
    283     * getSandboxMetadata retrieves the metadata associated with
    284     * a sandbox object. It will return undefined if there
    285     * is no metadata attached to the sandbox.
    286     *
    287     * var s = C.u.Sandbox(..., { metadata: "metadata" });
    288     * var metadata = C.u.getSandboxMetadata(s);
    289     */
    290    [implicit_jscontext]
    291    jsval getSandboxMetadata(in jsval sandbox);
    292 
    293    /*
    294     * setSandboxMetadata is designed to be called from JavaScript only.
    295     *
    296     * setSandboxMetadata sets the metadata associated with
    297     * a sandbox object.
    298     *
    299     * Note that the metadata object will be copied before being used.
    300     * The copy will be performed using the structured clone algorithm.
    301     * Note that this algorithm does not support reflectors and
    302     * it will throw if it encounters them.
    303     */
    304    [implicit_jscontext]
    305    void setSandboxMetadata(in jsval sandbox, in jsval metadata);
    306 
    307    /*
    308     * setSandboxLocaleOverride is designed to be called from JavaScript only.
    309     *
    310     * setSandboxLocaleOverride sets the locale override to the realm
    311     * of the sandbox.
    312     */
    313    [implicit_jscontext]
    314    void setSandboxLocaleOverride(in jsval sandbox, in string locale);
    315 
    316    /*
    317     * setSandboxTimezoneOverride is designed to be called from JavaScript only.
    318     *
    319     * setSandboxTimezoneOverride sets the timezone override to the realm
    320     * of the sandbox.
    321     */
    322    [implicit_jscontext]
    323    void setSandboxTimezoneOverride(in jsval sandbox, in string timezone);
    324 
    325    /**
    326     * Returns true if the ESM is loaded into the system global previously via
    327     * the ChromeUtils.importESModule method etc. Returns false otherwise.
    328     */
    329    boolean isESModuleLoaded(in AUTF8String aResourceURI);
    330 
    331    /*
    332     * Imports global properties (like DOM constructors) into the scope, defining
    333     * them on the caller's global. aPropertyList should be an array of property
    334     * names.
    335     *
    336     * See xpc::GlobalProperties::Parse for the current list of supported
    337     * properties.
    338     */
    339    [implicit_jscontext]
    340    void importGlobalProperties(in jsval aPropertyList);
    341 
    342    /*
    343     * To be called from JS only.
    344     *
    345     * Return a weak reference for the given JS object.
    346     */
    347    [implicit_jscontext]
    348    xpcIJSWeakReference getWeakReference(in jsval obj);
    349 
    350    /*
    351     * To be called from JS only.
    352     *
    353     * Force an immediate garbage collection cycle.
    354     */
    355    [implicit_jscontext]
    356    void forceGC();
    357 
    358    /*
    359     * To be called from JS only.
    360     *
    361     * Force an immediate cycle collection cycle.
    362     */
    363    void forceCC([optional] in nsICycleCollectorListener aListener);
    364 
    365    /*
    366     * To be called from JS only.  C++ callers should use the
    367     * nsCycleCollector_createLogger() function instead.
    368     *
    369     * Create an instance of the built-in cycle collector logger object.
    370     */
    371    nsICycleCollectorListener createCCLogger();
    372 
    373    /*
    374     * To be called from JS only.
    375     *
    376     * If any incremental CC is in progress, finish it. For testing.
    377     */
    378    void finishCC();
    379 
    380    /*
    381     * To be called from JS only.
    382     *
    383     * Do some cycle collector work, with the given work budget.
    384     * The cost of calling Traverse() on a single object is set as 1.
    385     * For testing.
    386     */
    387    void ccSlice(in long long budget);
    388 
    389    /*
    390     * To be called from JS only.
    391     *
    392     * Return the longest cycle collector slice time since the last
    393     * time clearMaxCCTime() was called.
    394     */
    395    long getMaxCCSliceTimeSinceClear();
    396 
    397    /*
    398     * To be called from JS only.
    399     *
    400     * Reset the internal max slice time value used for
    401     * getMaxCCSliceTimeSinceClear().
    402     */
    403    void clearMaxCCTime();
    404 
    405    /*
    406     * To be called from JS only.
    407     *
    408     * Force an immediate shrinking garbage collection cycle.
    409     */
    410    [implicit_jscontext]
    411    void forceShrinkingGC();
    412 
    413    /*
    414     * Schedule a garbage collection cycle for a point in the future when no JS
    415     * is running. Call the provided function once this has occurred.
    416     */
    417    void schedulePreciseGC(in nsIScheduledGCCallback callback);
    418 
    419    /*
    420     * Schedule a shrinking garbage collection cycle for a point in the future
    421     * when no JS is running. Call the provided function once this has occured.
    422     */
    423    void schedulePreciseShrinkingGC(in nsIScheduledGCCallback callback);
    424 
    425    /*
    426     * In a debug build, unlink any ghost windows. This is only for debugging
    427     * leaks, and can cause bad things to happen if called.
    428     */
    429    void unlinkGhostWindows();
    430 
    431    /*
    432     * In an NS_FREE_PERMANENT_DATA build, intentionally leak a C++ object. This
    433     * is needed to test leak checking.
    434     */
    435    void intentionallyLeak();
    436 
    437    [implicit_jscontext]
    438    jsval getJSTestingFunctions();
    439 
    440    /**
    441     * Returns an object containing `filename` and `lineNumber` properties
    442     * describing the source location of the given function.
    443     */
    444    [implicit_jscontext]
    445    jsval getFunctionSourceLocation(in jsval func);
    446 
    447    /*
    448     * To be called from JS only.
    449     *
    450     * Call 'func', using the provided stack as the async stack responsible
    451     * for the call, and propagate its return value or the exception it throws.
    452     * The function is called with no arguments, and 'this' is 'undefined'.
    453     *
    454     * The code in the function will see the given stack frame as the
    455     * asyncCaller of its own stack frame, instead of the current caller.
    456     */
    457    [implicit_jscontext]
    458    jsval callFunctionWithAsyncStack(in jsval func, in nsIStackFrame stack,
    459                                     in AString asyncCause);
    460 
    461    /*
    462     * To be called from JS only.
    463     *
    464     * Returns the global object with which the given object is associated.
    465     *
    466     * @param obj The JavaScript object whose global is to be gotten.
    467     * @return the corresponding global.
    468     */
    469    [implicit_jscontext]
    470    jsval getGlobalForObject(in jsval obj);
    471 
    472    /*
    473     * To be called from JS only.
    474     *
    475     * Returns the true if the object is a (scripted) proxy.
    476     * NOTE: Security wrappers are unwrapped first before the check.
    477     */
    478    [implicit_jscontext]
    479    boolean isProxy(in jsval vobject);
    480 
    481    /*
    482     * To be called from JS only.
    483     *
    484     * Instead of simply wrapping a function into another compartment,
    485     * this helper function creates a native function in the target
    486     * compartment and forwards the call to the original function.
    487     * That call will be different than a regular JS function call in
    488     * that, the |this| is left unbound, and all the non-native JS
    489     * object arguments will be cloned using the structured clone
    490     * algorithm.
    491     * The return value is the new forwarder function, wrapped into
    492     * the caller's compartment.
    493     * The 3rd argument is an optional options object:
    494     * - defineAs: the name of the property that will
    495     *             be set on the target scope, with
    496     *             the forwarder function as the value.
    497     */
    498    [implicit_jscontext]
    499    jsval exportFunction(in jsval vfunction, in jsval vscope, [optional] in jsval voptions);
    500 
    501    /*
    502     * To be called from JS only.
    503     *
    504     * Returns an object created in |vobj|'s compartment.
    505     * If defineAs property on the options object is a non-null ID,
    506     * the new object will be added to vobj as a property. Also, the
    507     * returned new object is always automatically waived (see waiveXrays).
    508     */
    509    [implicit_jscontext]
    510    jsval createObjectIn(in jsval vobj, [optional] in jsval voptions);
    511 
    512    /*
    513     * To be called from JS only.
    514     *
    515     * Ensures that all functions come from vobj's scope (and aren't cross
    516     * compartment wrappers).
    517     */
    518    [implicit_jscontext]
    519    void makeObjectPropsNormal(in jsval vobj);
    520 
    521    /**
    522     * Determines whether this object is backed by a DeadObjectProxy.
    523     *
    524     * Dead-wrapper objects hold no other objects alive (they have no outgoing
    525     * reference edges) and will throw if you touch them (e.g. by
    526     * reading/writing a property).
    527     */
    528    boolean isDeadWrapper(in jsval obj);
    529 
    530    /**
    531     * Determines whether this value is a remote object proxy, such as
    532     * RemoteWindowProxy or RemoteLocationProxy, for an out-of-process frame.
    533     *
    534     * Remote object proxies do not grant chrome callers the same exemptions
    535     * to the same-origin-policy that in-process wrappers typically do, so
    536     * this can be used to determine whether access to cross-origin proxies is
    537     * safe:
    538     *
    539     *   if (!Cu.isRemoteProxy(frame.contentWindow)) {
    540     *     frame.contentWindow.doCrossOriginThing();
    541     *   }
    542     */
    543    boolean isRemoteProxy(in jsval val);
    544 
    545    /*
    546     * To be called from JS only. This is for Gecko internal use only, and may
    547     * disappear at any moment.
    548     *
    549     * Forces a recomputation of all wrappers in and out of the compartment
    550     * containing |vobj|. If |vobj| is not an object, all wrappers system-wide
    551     * are recomputed.
    552     */
    553    [implicit_jscontext]
    554    void recomputeWrappers([optional] in jsval vobj);
    555 
    556    /*
    557     * To be called from JS only. This is for Gecko internal use only, and may
    558     * disappear at any moment.
    559     *
    560     * Enables Xray vision for same-compartment access for the compartment
    561     * indicated by |vscope|. All outgoing wrappers are recomputed.
    562     *
    563     * This must not be called on chrome (system-principal) scopes.
    564     */
    565    [implicit_jscontext]
    566    void setWantXrays(in jsval vscope);
    567 
    568    /*
    569     * Dispatches a runnable to the current/main thread. If |scope| is passed,
    570     * the runnable will be dispatch in the compartment of |scope|, which
    571     * affects which error reporter gets called.
    572     */
    573    [implicit_jscontext]
    574    void dispatch(in jsval runnable, [optional] in jsval scope);
    575 
    576    // Returns true if we're running in automation and certain security
    577    // restrictions can be eased.
    578    readonly attribute boolean isInAutomation;
    579 
    580    // Called by automated tests to exit immediately after we are done getting
    581    // test results.
    582    void exitIfInAutomation();
    583 
    584    void crashIfNotInAutomation();
    585 
    586    [implicit_jscontext]
    587    void setGCZeal(in long zeal);
    588 
    589    [implicit_jscontext]
    590    void nukeSandbox(in jsval obj);
    591 
    592    /*
    593     * API to dynamically block script for a given global. This takes effect
    594     * immediately, unlike other APIs that only affect newly-created globals.
    595     *
    596     * The machinery here maintains a counter, and allows script only if each
    597     * call to blockScriptForGlobal() has been matched with a call to
    598     * unblockScriptForGlobal(). The caller _must_ make sure never to call
    599     * unblock() more times than it calls block(), since that could potentially
    600     * interfere with another consumer's script blocking.
    601     */
    602 
    603    [implicit_jscontext]
    604    void blockScriptForGlobal(in jsval global);
    605 
    606    [implicit_jscontext]
    607    void unblockScriptForGlobal(in jsval global);
    608 
    609    /**
    610     * Check whether the given object is an opaque wrapper (PermissiveXrayOpaque).
    611     */
    612    boolean isOpaqueWrapper(in jsval obj);
    613 
    614    /**
    615     * Check whether the given object is an XrayWrapper.
    616     */
    617    boolean isXrayWrapper(in jsval obj);
    618 
    619    /**
    620     * Waive Xray on a given value. Identity op for primitives.
    621     */
    622    [implicit_jscontext]
    623    jsval waiveXrays(in jsval aVal);
    624 
    625    /**
    626     * Strip off Xray waivers on a given value. Identity op for primitives.
    627     */
    628    [implicit_jscontext]
    629    jsval unwaiveXrays(in jsval aVal);
    630 
    631    /**
    632     * Gets the name of the JSClass of the object.
    633     *
    634     * if |aUnwrap| is true, all wrappers are unwrapped first. Unless you're
    635     * specifically trying to detect whether the object is a proxy, this is
    636     * probably what you want.
    637     */
    638    [implicit_jscontext]
    639    string getClassName(in jsval aObj, in boolean aUnwrap);
    640 
    641    /**
    642     * Gets the incument global for the execution of this function. For internal
    643     * and testing use only.
    644     *
    645     * If |callback| is passed, it is invoked with the incumbent global as its
    646     * sole argument. This allows the incumbent global to be measured in callback
    647     * environments with no scripted frames on the stack.
    648     */
    649    [implicit_jscontext]
    650    jsval getIncumbentGlobal([optional] in jsval callback);
    651 
    652    /**
    653     * Returns a name for the given function or object which is useful for
    654     * debugging. It will be very similar to the name displayed in call
    655     * stacks.
    656 
    657     * Objects which contain a single enumerable property which is a function
    658     * will generate a name based on that function. Any other non-function
    659     * objects will return "nonfunction".
    660     */
    661    [implicit_jscontext]
    662    ACString getDebugName(in jsval obj);
    663 
    664    /**
    665      * Retrieve the last time, in microseconds since epoch, that a given
    666      * watchdog-related event occured.
    667      *
    668      * Valid categories:
    669      *   "ContextStateChange"      - Context switching between active and inactive states
    670      *   "WatchdogWakeup"          - Watchdog waking up from sleeping
    671      *   "WatchdogHibernateStart"  - Watchdog begins hibernating
    672      *   "WatchdogHibernateStop"   - Watchdog stops hibernating
    673      */
    674    PRTime getWatchdogTimestamp(in AString aCategory);
    675 
    676    [implicit_jscontext]
    677    jsval getJSEngineTelemetryValue();
    678 
    679    /*
    680     * Clone an object into a scope.
    681     * The 3rd argument is an optional options object:
    682     * - cloneFunctions: boolean. If true, functions in the value are
    683     *   wrapped in a function forwarder that appears to be a native function in
    684     *   the content scope. Defaults to false.
    685     * - wrapReflectors: boolean. If true, DOM objects are passed through the
    686     *   clone directly with cross-compartment wrappers. Otherwise, the clone
    687     *   fails when such an object is encountered. Defaults to false.
    688     */
    689    [implicit_jscontext]
    690    jsval cloneInto(in jsval value, in jsval scope, [optional] in jsval options);
    691 
    692    /*
    693     * When C++-Implemented code does security checks, it can generally query
    694     * the subject principal (i.e. the principal of the most-recently-executed
    695     * script) in order to determine the responsible party. However, when an API
    696     * is implemented in JS, this doesn't work - the most-recently-executed
    697     * script is always the System-Principaled API implementation. So we need
    698     * another mechanism.
    699     *
    700     * Hence the notion of the "WebIDL Caller". If the current Entry Script on
    701     * the Script Settings Stack represents the invocation of JS-implemented
    702     * WebIDL, this API returns the principal of the caller at the time
    703     * of invocation. Otherwise (i.e. outside of JS-implemented WebIDL), this
    704     * function throws. If it throws, you probably shouldn't be using it.
    705     */
    706    nsIPrincipal getWebIDLCallerPrincipal();
    707 
    708    /*
    709     * Gets the principal of a script object, after unwrapping any cross-
    710     * compartment wrappers.
    711     */
    712    [implicit_jscontext]
    713    nsIPrincipal getObjectPrincipal(in jsval obj);
    714 
    715    /*
    716     * Gets the URI or identifier string associated with an object's
    717     * realm (the same one used by the memory reporter machinery).
    718     *
    719     * Unwraps cross-compartment wrappers first.
    720     *
    721     * The string formats and values may change at any time. Do not depend on
    722     * this from addon code.
    723     */
    724    [implicit_jscontext]
    725    ACString getRealmLocation(in jsval obj);
    726 
    727    /*
    728     * Reads the given file and returns its contents. If called during early
    729     * startup, the file will be pre-read on a background thread during profile
    730     * startup so its contents will be available the next time they're read.
    731     *
    732     * The file must be a text file encoded in UTF-8. Otherwise the result is
    733     * undefined.
    734     */
    735    AUTF8String readUTF8File(in nsIFile file);
    736 
    737    /*
    738     * Reads the given local file URL and returns its contents. This has the
    739     * same semantics of readUTF8File.
    740     * Only supports file URLs or URLs that point into one of the omnijars.
    741     */
    742    AUTF8String readUTF8URI(in nsIURI url);
    743 
    744    /* Create a spellchecker object. */
    745    nsIEditorSpellCheck createSpellChecker();
    746 
    747    /* Create a commandline object.
    748     *
    749     * @return a new `nsICommandLine` instance.
    750     *
    751     * @param args
    752     *   The arguments of the command line, not including the app/program itself.
    753     * @param workingDir
    754     *   An optional working directory for the command line.
    755     * @param state
    756     *   The command line's state, one of `nsICommandLine.STATE_INITIAL_LAUNCH`,
    757     *   `nsICommandLine.STATE_REMOTE_AUTO`, or
    758     *   `nsICommandLine.STATE_REMOTE_EXPLICIT`.
    759     */
    760    nsISupports createCommandLine(in Array<ACString> args,
    761                                  in nsIFile workingDir,
    762                                  in unsigned long state);
    763 
    764    /* Create a command params object. */
    765    nsICommandParams createCommandParams();
    766 
    767    /* Create a loadcontext object. */
    768    nsILoadContext createLoadContext();
    769 
    770    /* Create a private loadcontext object. */
    771    nsILoadContext createPrivateLoadContext();
    772 
    773    /* Create a persistent property object. */
    774    nsIPersistentProperties createPersistentProperties();
    775 
    776    /* Create a document encoder object. */
    777    nsIDocumentEncoder createDocumentEncoder(in string contentType);
    778 
    779    /* Create an HTML copy encoder object. */
    780    nsIDocumentEncoder createHTMLCopyEncoder();
    781 
    782    // Array of the URI of ESM loaded. This attribute is for startup testing
    783    // purposes. This is not expected to be used for production code.
    784    readonly attribute Array<ACString> loadedESModules;
    785 
    786    // This function will only return useful values if the
    787    // "browser.startup.record" preference was true at the time the JS file
    788    // was loaded.
    789    ACString getModuleImportStack(in AUTF8String aLocation);
    790 };
    791 
    792 /**
    793 * Interface for the 'Components' object.
    794 */
    795 
    796 [scriptable, builtinclass, uuid(aa28aaf6-70ce-4b03-9514-afe43c7dfda8)]
    797 interface nsIXPCComponents : nsISupports
    798 {
    799    readonly attribute nsIXPCComponents_Interfaces      interfaces;
    800    readonly attribute nsIXPCComponents_Results         results;
    801 
    802    boolean isSuccessCode(in nsresult result);
    803 
    804    readonly attribute nsIXPCComponents_Classes         classes;
    805    // Will return null if there is no JS stack right now.
    806    readonly attribute nsIStackFrame                    stack;
    807    readonly attribute nsIComponentManager              manager;
    808    readonly attribute nsIXPCComponents_Utils           utils;
    809 
    810    readonly attribute nsIXPCComponents_ID              ID;
    811    readonly attribute nsIXPCComponents_Exception       Exception;
    812    readonly attribute nsIXPCComponents_Constructor     Constructor;
    813 
    814    [implicit_jscontext]
    815    // A javascript component can set |returnCode| to specify an nsresult to
    816    // be returned without throwing an exception.
    817    attribute jsval                                     returnCode;
    818 };