tor-browser

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

ChromeUtils.webidl (41492B)


      1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      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 file,
      4 * You can obtain one at http://mozilla.org/MPL/2.0/.
      5 */
      6 
      7 interface imgIContainer;
      8 interface nsIContentParentKeepAlive;
      9 interface nsIDOMProcessChild;
     10 interface nsIDOMProcessParent;
     11 interface nsIRFPTargetSetIDL;
     12 interface Principal;
     13 
     14 /**
     15 * An optimized QueryInterface method, generated by generateQI.
     16 *
     17 * For JS callers, this behaves like a normal QueryInterface function. When
     18 * called with a supported interface, it returns its `this` object. When
     19 * called with an unsupported interface, it throws NS_ERROR_NO_INTERFACE.
     20 *
     21 * C++ callers use a fast path, and never call the JSAPI or WebIDL methods of
     22 * this object.
     23 */
     24 [ChromeOnly, Exposed=Window]
     25 interface MozQueryInterface {
     26  [Throws]
     27  legacycaller any (any aIID);
     28 };
     29 
     30 /**
     31 * Options for a marker created with the addProfilerMarker method.
     32 * All fields are optional.
     33 */
     34 dictionary ProfilerMarkerOptions {
     35  // A timestamp from `ChromeUtils.now()` to use as the start time of the marker.
     36  // If no start time is provided, the marker will have no duration.
     37  double startTime = 0;
     38 
     39  // If captureStack is true, a profiler stack will be captured and associated
     40  // with the marker.
     41  boolean captureStack = false;
     42 
     43  // Markers are created by default in the JavaScript category, but this can be
     44  // overridden.
     45  // Examples of correct values: "JavaScript", "Test", "Other", ...
     46  // See ProfilingCategoryList.h for the complete list of valid values.
     47  // Using an unrecognized value will set the category to "Other".
     48  ByteString category = "JavaScript";
     49 
     50  // Inner window ID to use for the marker. If the global object is a window,
     51  // the inner window id of the marker will be set automatically.
     52  // If a marker that relates to a specific window is added from a JS module,
     53  // setting the inner window id will allow the profiler to show which window
     54  // the marker applies to.
     55  unsigned long long innerWindowId = 0;
     56 };
     57 
     58 dictionary InteractionData {
     59  unsigned long interactionCount = 0;
     60  unsigned long interactionTimeInMilliseconds = 0;
     61  unsigned long scrollingDistanceInPixels = 0;
     62 };
     63 
     64 /**
     65 * Confidence value of credit card fields. This is used by the native
     66 * Fathom Credit Card model to return the score to JS.
     67 */
     68 dictionary FormAutofillConfidences {
     69  double ccNumber = 0;
     70  double ccName = 0;
     71 };
     72 
     73 enum ResourceCacheType {
     74  "stylesheet",
     75  "script",
     76  "image",
     77 };
     78 
     79 enum ResourceCacheTarget {
     80  "chrome",
     81  "content",
     82 };
     83 
     84 dictionary ClearResourceCacheOptions {
     85  // If specified clear only those types of resources.
     86  // If not specified, clears all types.
     87  sequence<ResourceCacheType> types;
     88 
     89  // If specified, clear only the specified target, either chrome or content.
     90  // If not specified, clears both chrome and content.
     91  //
     92  // Exclusive with principal, schemelessSite, and url.
     93  ResourceCacheTarget target;
     94 
     95  // If specified, filters by principal.
     96  //
     97  // Exclusive with target, schemelessSite, and url.
     98  Principal principal;
     99 
    100  // If specified, filters by site, and needs to provide a pattern.
    101  //
    102  // Exclusive with target, principal, and url.
    103  UTF8String schemelessSite;
    104 
    105  // If specified with schemelessSite, filter by origin attributes.
    106  OriginAttributesPatternDictionary pattern = {};
    107 
    108  // If specified, clear the cache for the url
    109  //
    110  // Exclusive with target, principal, and schemelessSite.
    111  UTF8String url;
    112 };
    113 
    114 /**
    115 * A collection of static utility methods that are only exposed to system code.
    116 * This is exposed in all the system globals where we can expose stuff by
    117 * default, so should only include methods that are **thread-safe**.
    118 */
    119 [ChromeOnly, Exposed=(Window,Worker)]
    120 namespace ChromeUtils {
    121  /**
    122   * Get the |NodeId| for the given JS Object.
    123   * |NodeId| is the identifier of |JS::ubi::Node|.
    124   */
    125  NodeId getObjectNodeId(object obj);
    126 
    127  /**
    128   * Serialize a snapshot of the heap graph, as seen by |JS::ubi::Node| and
    129   * restricted by |boundaries|, and write it to the provided file path.
    130   *
    131   * @param boundaries        The portion of the heap graph to write.
    132   *
    133   * @returns                 The path to the file the heap snapshot was written
    134   *                          to. This is guaranteed to be within the temp
    135   *                          directory and its file name will match the regexp
    136   *                          `\d+(\-\d+)?\.fxsnapshot`.
    137   */
    138  [Throws]
    139  DOMString saveHeapSnapshot(optional HeapSnapshotBoundaries boundaries = {});
    140 
    141  /**
    142   * This is the same as saveHeapSnapshot, but with a different return value.
    143   *
    144   * @returns                 The snapshot ID of the file. This is the file name
    145   *                          without the temp directory or the trailing
    146   *                          `.fxsnapshot`.
    147   */
    148  [Throws]
    149  DOMString saveHeapSnapshotGetId(optional HeapSnapshotBoundaries boundaries = {});
    150 
    151  /**
    152   * Deserialize a core dump into a HeapSnapshot.
    153   *
    154   * @param filePath          The file path to read the heap snapshot from.
    155   */
    156  [Throws, NewObject]
    157  HeapSnapshot readHeapSnapshot(DOMString filePath);
    158 
    159  /**
    160   * Efficient way to know if DevTools are active in the current process.
    161   *
    162   * This doesn't help know what particular context is being debugged,
    163   * but can help strip off code entirely when DevTools aren't used at all.
    164   *
    165   * BrowsingContext.isWatchedByDevTools is a more precise way to know
    166   * when one precise tab is being debugged.
    167   */
    168  boolean isDevToolsOpened();
    169 
    170  /**
    171   * API exposed to DevTools JS code in order to know when devtools are being active in the current process.
    172   *
    173   * This API counts the number of calls to these methods, allowing to track many DevTools instances.
    174   */
    175  undefined notifyDevToolsOpened();
    176  undefined notifyDevToolsClosed();
    177 
    178 
    179  /**
    180   * Return the keys in a weak map.  This operation is
    181   * non-deterministic because it is affected by the scheduling of the
    182   * garbage collector and the cycle collector.
    183   *
    184   * @param aMap weak map or other JavaScript value
    185   * @returns If aMap is a weak map object, return the keys of the weak
    186   *          map as an array.  Otherwise, return undefined.
    187   */
    188  [Throws, NewObject]
    189  any nondeterministicGetWeakMapKeys(any map);
    190 
    191  /**
    192   * Return the keys in a weak set.  This operation is
    193   * non-deterministic because it is affected by the scheduling of the
    194   * garbage collector and the cycle collector.
    195   *
    196   * @param aSet weak set or other JavaScript value
    197   * @returns If aSet is a weak set object, return the keys of the weak
    198   *          set as an array.  Otherwise, return undefined.
    199   */
    200  [Throws, NewObject]
    201  any nondeterministicGetWeakSetKeys(any aSet);
    202 
    203  /**
    204   * Converts a buffer to a Base64 URL-encoded string per RFC 4648.
    205   *
    206   * @param source The buffer to encode.
    207   * @param options Additional encoding options.
    208   * @returns The encoded string.
    209   */
    210  [Throws]
    211  ByteString base64URLEncode(BufferSource source,
    212                             Base64URLEncodeOptions options);
    213 
    214  /**
    215   * Decodes a Base64 URL-encoded string per RFC 4648.
    216   *
    217   * @param string The string to decode.
    218   * @param options Additional decoding options.
    219   * @returns The decoded buffer.
    220   */
    221  [Throws, NewObject]
    222  ArrayBuffer base64URLDecode(ByteString string,
    223                              Base64URLDecodeOptions options);
    224 
    225  /**
    226   * Cause the current process to fatally crash unless the given condition is
    227   * true. This is similar to MOZ_RELEASE_ASSERT in C++ code.
    228   *
    229   * WARNING: This message is included publicly in the crash report, and must
    230   * not contain private information.
    231   *
    232   * Crash report will be augmented with the current JS stack information.
    233   */
    234  undefined releaseAssert(boolean condition,
    235                          optional DOMString message = "<no message>");
    236 
    237 #ifdef NIGHTLY_BUILD
    238 
    239  /**
    240   * If the chrome code has thrown a JavaScript Dev Error
    241   * in the current JSRuntime. the first such error, or `undefined`
    242   * otherwise.
    243   *
    244   * A JavaScript Dev Error is an exception thrown by JavaScript
    245   * code that matches both conditions:
    246   * - it was thrown by chrome code;
    247   * - it is either a `ReferenceError`, a `TypeError` or a `SyntaxError`.
    248   *
    249   * Such errors are stored regardless of whether they have been
    250   * caught.
    251   *
    252   * This mechanism is designed to help ensure that the code of
    253   * Firefox is free from Dev Errors, even if they are accidentally
    254   * caught by clients.
    255   *
    256   * The object returned is not an exception. It has fields:
    257   * - DOMString stack
    258   * - DOMString filename
    259   * - DOMString lineNumber
    260   * - DOMString message
    261   */
    262  [Throws]
    263  readonly attribute any recentJSDevError;
    264 
    265  /**
    266   * Reset `recentJSDevError` to `undefined` for the current JSRuntime.
    267   */
    268  undefined clearRecentJSDevError();
    269 #endif // NIGHTLY_BUILD
    270 
    271  /**
    272   * Clears the entire resource cache (stylesheets, JavaScripts, and images).
    273   */
    274  [Throws]
    275  undefined clearResourceCache(optional ClearResourceCacheOptions options = {});
    276 
    277  /**
    278   * Invalidates the resource cache which supports invalidation.
    279   *
    280   * In contrast to the clearResourceCache, this doesn't immediately clear
    281   * the cache.  It can validate the cache entry on the next request and
    282   * revive if the cache is confirmed to be still valid.
    283   *
    284   * Currently only JavaScripts supports.
    285   */
    286  [Throws]
    287  undefined invalidateResourceCache();
    288 
    289  /**
    290   * Clears the bfcache (backward-forward cache)
    291   */
    292  [Throws]
    293  undefined clearBfcacheByPrincipal(Principal principal);
    294 
    295  /**
    296   * Clears the Messaging Layer Security state by schemeless site.
    297   * This includes associated state-partitioned cache.
    298   */
    299  [Throws]
    300  undefined clearMessagingLayerSecurityStateBySite(UTF8String schemelessSite, optional OriginAttributesPatternDictionary pattern = {});
    301 
    302  /**
    303   * Clears the Messaging Layer Security state by principal.
    304   */
    305  [Throws]
    306  undefined clearMessagingLayerSecurityStateByPrincipal(Principal principal);
    307 
    308  /**
    309   * Clears all Messaging Layer Security related state across domains
    310   */
    311  [Throws]
    312  undefined clearMessagingLayerSecurityState();
    313 
    314  /**
    315   * If the profiler is currently running and recording the current thread,
    316   * add a marker for the current thread. No-op otherwise.
    317   *
    318   * @param name              The name of the marker.
    319   * @param options           Either a timestamp from `ChromeUtils.now()` to use as
    320   *                          the start time of the marker, or a ProfilerMarkerOptions
    321   *                          object that can contain startTime, captureStack or
    322   *                          category fields. If this parameter is omitted, the marker
    323   *                          will have no duration.
    324   * @param text              Text to associate with the marker.
    325   */
    326  undefined addProfilerMarker(UTF8String name,
    327                              optional (ProfilerMarkerOptions or double) options = {},
    328                              optional UTF8String text);
    329 
    330  /**
    331   * Return the symbolic name of any given XPCOM error code (nsresult):
    332   * "NS_OK", "NS_ERROR_FAILURE",...
    333   */
    334  UTF8String getXPCOMErrorName(unsigned long aErrorCode);
    335 
    336  /**
    337   * Return a fractional number representing the current time (in milliseconds from the Epoch).
    338   * Should be JS_Now()/1000 so that it can be compared to Date.now in Javascript.
    339   */
    340  double dateNow();
    341 
    342  /**
    343   * Return a fractional number of milliseconds from process startup,
    344   * measured with a monotonic clock. This provides a unified timing source
    345   * that works in all JavaScript contexts and can be used with addProfilerMarker.
    346   */
    347  double now();
    348 
    349  /**
    350   * Defines a getter on a specified object that will be created upon first
    351   * use.
    352   *
    353   * The first time the property is accessed, |aLambda| is called, and the
    354   * property is replaced with the return value.
    355   *
    356   * The property is defined on `this` value used to access the getter. This
    357   * means that if you define the lazy getter on a prototype, the lambda will
    358   * be called every time the property is accessed on a new instance.
    359   *
    360   * The property doesn't have setter, and the property cannot be overwritten
    361   * by simple assignment.
    362   *
    363   * @param aTarget
    364   *        The object to define the lazy getter on.
    365   * @param aName
    366   *        The name of the getter to define on aTarget.
    367   * @param aLambda
    368   *        A function that returns what the getter should return.  This will
    369   *        only ever be called once.
    370   */
    371  [Throws]
    372  undefined defineLazyGetter(object aTarget, any aName, object aLambda);
    373 
    374 
    375 #ifdef XP_UNIX
    376  /**
    377   * Return platform-specific libc constants, such as errno values.
    378   */
    379  LibcConstants getLibcConstants();
    380 #endif
    381 
    382 #ifdef MOZ_WMF_CDM
    383  /**
    384   * Returns the information about all Media Foundation based content decryption
    385   * modules, which would include key system names and their capabilities.
    386   */
    387  [NewObject]
    388  Promise<sequence<CDMInformation>> getWMFContentDecryptionModuleInformation();
    389 #endif
    390 
    391  /**
    392   * Returns the information about the GMP based content decryption
    393   * modules, which would include key system names and their capabilities.
    394   */
    395  [NewObject]
    396  Promise<sequence<CDMInformation>> getGMPContentDecryptionModuleInformation();
    397 
    398  /**
    399   * Synchronously loads and evaluates the JS module source located at
    400   * 'aResourceURI'.
    401   *
    402   * @param aResourceURI A resource:// URI string to load the module from.
    403   * @param aOption An option to specify where to load the module into.
    404   * @returns the module's namespace object.
    405   *
    406   * The implementation maintains a hash of aResourceURI->global obj.
    407   * Subsequent invocations of import with 'aResourceURI' pointing to
    408   * the same file will not cause the module to be re-evaluated.
    409   *
    410   * In worker threads, aOption is required and only { global: "current" } and
    411   * { global: "contextual" } are supported.
    412   *
    413   * In DevTools distinct global, aOptions.global is reuiqred.
    414   */
    415  [Throws]
    416  object importESModule(DOMString aResourceURI,
    417                        optional ImportESModuleOptionsDictionary aOptions = {});
    418 
    419  /**
    420   * Defines properties on the given target which lazily imports a ES module
    421   * when accessed.
    422   *
    423   * See defineLazyGetter for the characteristics of the lazy getter.
    424   *
    425   * In contrast to defineLazyGetter, the properties defined by this API
    426   * has setter, and the properties can be overwritten with simple assignment.
    427   * The new property value is always defined on the `this` object that the
    428   * setter is called with.
    429   *
    430   * @param aTarget The target object on which to define the property.
    431   * @param aModules An object with a property for each module property to be
    432   *                 imported, where the property name is the name of the
    433   *                 imported symbol and the value is the module URI.
    434   * @param aOptions An option to specify where to load the module into.
    435   *
    436   * In worker threads, aOptions is required and only { global: "current" } and
    437   * { global: "contextual" } are supported.
    438   *
    439   * In DevTools distinct global, aOptions.global is required.
    440   */
    441  [Throws]
    442  undefined defineESModuleGetters(object aTarget, object aModules,
    443                                  optional ImportESModuleOptionsDictionary aOptions = {});
    444 
    445  /**
    446   * Returns whether |str| is a valid JS identifier
    447   */
    448  boolean isJSIdentifier(DOMString str);
    449 
    450  /**
    451   * Given an URI string, replaces html whitespace with the relevant
    452   * url-encoded characters, so that it can be used as part of a srcset without
    453   * changing its meaning.
    454   */
    455  UTF8String encodeURIForSrcset(UTF8String uri);
    456 
    457  /**
    458   * Returns, in bytes, a platform-normalized estimate of the process's private physical memory usage.
    459   * Any error when calling the underlying platform-specific API will be thrown.
    460   */
    461  [Throws]
    462  readonly attribute unsigned long long currentProcessMemoryUsage;
    463 
    464  /**
    465   * Return the number of milliseconds of CPU time used since process start.
    466   * Any error when calling the underlying platform-specific API will be thrown.
    467   */
    468  [Throws]
    469  readonly attribute unsigned long long cpuTimeSinceProcessStart;
    470 
    471  /**
    472   * IF YOU ADD NEW METHODS HERE, MAKE SURE THEY ARE THREAD-SAFE.
    473   */
    474 };
    475 
    476 /**
    477 * Additional ChromeUtils methods that are _not_ thread-safe, and hence not
    478 * exposed in workers.
    479 */
    480 [Exposed=Window]
    481 partial namespace ChromeUtils {
    482  /**
    483   * A helper that converts OriginAttributesDictionary to a opaque suffix string.
    484   *
    485   * @param originAttrs       The originAttributes from the caller.
    486   */
    487  ByteString
    488  originAttributesToSuffix(optional OriginAttributesDictionary originAttrs = {});
    489 
    490  /**
    491   * Returns true if the members of |originAttrs| match the provided members
    492   * of |pattern|.
    493   *
    494   * @param originAttrs       The originAttributes under consideration.
    495   * @param pattern           The pattern to use for matching.
    496   */
    497  boolean
    498  originAttributesMatchPattern(optional OriginAttributesDictionary originAttrs = {},
    499                               optional OriginAttributesPatternDictionary pattern = {});
    500 
    501  /**
    502   * Returns an OriginAttributesDictionary with values from the |origin| suffix
    503   * and unspecified attributes added and assigned default values.
    504   *
    505   * @param origin            The origin URI to create from.
    506   * @returns                 An OriginAttributesDictionary with values from
    507   *                          the origin suffix and unspecified attributes
    508   *                          added and assigned default values.
    509   */
    510  [Throws]
    511  OriginAttributesDictionary
    512  createOriginAttributesFromOrigin(DOMString origin);
    513 
    514  /**
    515   * Returns an OriginAttributesDictionary with values from the origin |suffix|
    516   * and unspecified attributes added and assigned default values.
    517   *
    518   * @param suffix            The origin suffix to create from.
    519   * @returns                 An OriginAttributesDictionary with values from
    520   *                          the origin suffix and unspecified attributes
    521   *                          added and assigned default values.
    522   */
    523  [Throws]
    524  OriginAttributesDictionary
    525  CreateOriginAttributesFromOriginSuffix(DOMString suffix);
    526 
    527  /**
    528   * Returns an OriginAttributesDictionary that is a copy of |originAttrs| with
    529   * unspecified attributes added and assigned default values.
    530   *
    531   * @param originAttrs       The origin attributes to copy.
    532   * @returns                 An OriginAttributesDictionary copy of |originAttrs|
    533   *                          with unspecified attributes added and assigned
    534   *                          default values.
    535   */
    536  OriginAttributesDictionary
    537  fillNonDefaultOriginAttributes(optional OriginAttributesDictionary originAttrs = {});
    538 
    539  /**
    540   * Returns true if the 2 OriginAttributes are equal.
    541   */
    542  boolean
    543  isOriginAttributesEqual(optional OriginAttributesDictionary aA = {},
    544                          optional OriginAttributesDictionary aB = {});
    545 
    546  /**
    547   * Returns the base domain portion of a given partitionKey.
    548   * Returns the empty string for an empty partitionKey.
    549   * Throws for invalid partition keys.
    550   */
    551  [Throws]
    552  DOMString
    553  getBaseDomainFromPartitionKey(DOMString partitionKey);
    554 
    555  /**
    556   * Returns the partitionKey for a given subresourceURL given its top-level URL
    557   * and whether or not it is in a foreign context.
    558   *
    559   * The function will treat the topLevelURL as a first party and construct the
    560   * partitionKey according to the scheme, site and port in the URL. It will also
    561   * include information about the subresource and whether or not this is a foreign
    562   * request in the partition key.
    563   *
    564   * Throws for invalid urls, if the Third Party Service is unavailable, or if the
    565   * combination of inputs is impossible.
    566   */
    567  [Throws]
    568  DOMString
    569  getPartitionKeyFromURL(DOMString topLevelUrl, DOMString subresourceUrl, optional boolean foreignContext);
    570 
    571  /**
    572   * Loads and compiles the script at the given URL and returns an object
    573   * which may be used to execute it repeatedly, in different globals, without
    574   * re-parsing.
    575   */
    576  [NewObject]
    577  Promise<PrecompiledScript>
    578  compileScript(DOMString url, optional CompileScriptOptionsDictionary options = {});
    579 
    580  /**
    581   * Returns an optimized QueryInterface method which, when called from
    582   * JavaScript, acts as an ordinary QueryInterface function call, and when
    583   * called from XPConnect, circumvents JSAPI entirely.
    584   *
    585   * The list of interfaces may include a mix of JS ID objects and interface
    586   * name strings.
    587   *
    588   * nsISupports is implicitly supported, and must not be included in the
    589   * interface list.
    590   */
    591  [Affects=Nothing, NewObject]
    592  MozQueryInterface generateQI(sequence<any> interfaces);
    593 
    594  /**
    595   * Waive Xray on a given value. Identity op for primitives.
    596   */
    597  [Throws]
    598  any waiveXrays(any val);
    599 
    600  /**
    601   * Strip off Xray waivers on a given value. Identity op for primitives.
    602   */
    603  [Throws]
    604  any unwaiveXrays(any val);
    605 
    606  /**
    607   * Gets the name of the JSClass of the object.
    608   *
    609   * if |unwrap| is true, all wrappers are unwrapped first. Unless you're
    610   * specifically trying to detect whether the object is a proxy, this is
    611   * probably what you want.
    612   */
    613  DOMString getClassName(object obj, optional boolean unwrap = true);
    614 
    615  /**
    616   * Returns whether the object is a DOM object.
    617   *
    618   * if |unwrap| is true, all wrappers are unwrapped first. Unless you're
    619   * specifically trying to detect whether the object is a proxy, this is
    620   * probably what you want.
    621   */
    622  boolean isDOMObject(object obj, optional boolean unwrap = true);
    623 
    624  /**
    625   * Returns whether |str| follows the Date Time String Format.
    626   */
    627  boolean isISOStyleDate(UTF8String str);
    628 
    629  /**
    630   * Clones the properties of the given object into a new object in the given
    631   * target compartment (or the caller compartment if no target is provided).
    632   * Property values themeselves are not cloned.
    633   *
    634   * Ignores non-enumerable properties, properties on prototypes, and properties
    635   * with getters or setters.
    636   */
    637  [Throws]
    638  object shallowClone(object obj, optional object? target = null);
    639 
    640  /**
    641   * Dispatches the given callback to the main thread when it would be
    642   * otherwise idle. Similar to Window.requestIdleCallback, but not bound to a
    643   * particular DOM windw.
    644   */
    645  [Throws]
    646  undefined idleDispatch(IdleRequestCallback callback,
    647                         optional IdleRequestOptions options = {});
    648 
    649  /**
    650   * Returns the scripted location of the first ancestor stack frame with a
    651   * principal which is subsumed by the given principal. If no such frame
    652   * exists on the call stack, returns null.
    653   */
    654  object? getCallerLocation(Principal principal);
    655 
    656  /**
    657   * Creates a JS Error object with the given message and stack.
    658   *
    659   * If a stack object is provided, the error object is created in the global
    660   * that it belongs to.
    661   */
    662  [Throws]
    663  object createError(DOMString message, optional object? stack = null);
    664 
    665  /**
    666   * Set the collection of specific detailed performance timing information.
    667   * Passing an empty array will end existing collection. All metrics that
    668   * are chosen will be cleared after updating the features.
    669   *
    670   * @param aMetrics An array of metric names corresponding to the Metric enum
    671   *        values in PerfStats::Metric.
    672   */
    673  undefined setPerfStatsFeatures(sequence<DOMString> aMetrics);
    674 
    675  /**
    676   * Enables the collection of all perf stats features.  Will override the features
    677   * enabled by setPerfStatsFeatures.
    678   */
    679  undefined enableAllPerfStatsFeatures();
    680 
    681  /**
    682   * Collect results of detailed performance timing information.
    683   * The output is a JSON string containing performance timings.
    684   */
    685  [NewObject]
    686  Promise<DOMString> collectPerfStats();
    687 
    688  /**
    689  * Returns a Promise containing all processes info
    690  */
    691  [NewObject]
    692  Promise<ParentProcInfoDictionary> requestProcInfo();
    693 
    694  /**
    695   * For testing purpose.
    696   */
    697  [ChromeOnly]
    698  boolean vsyncEnabled();
    699 
    700  [ChromeOnly, Throws]
    701  boolean hasReportingHeaderForOrigin(DOMString aOrigin);
    702 
    703  [ChromeOnly]
    704  PopupBlockerState getPopupControlState();
    705 
    706  /**
    707   * Milliseconds from the last iframe loading an external protocol.
    708   */
    709  [ChromeOnly]
    710  double lastExternalProtocolIframeAllowed();
    711 
    712  /**
    713   * For testing purpose we need to reset this value.
    714   */
    715  [ChromeOnly]
    716  undefined resetLastExternalProtocolIframeAllowed();
    717 
    718  /**
    719   * For webdriver consistency purposes, we need to be able to end a wheel
    720   * transaction from the browser chrome.
    721   */
    722  [ChromeOnly, Throws]
    723  Promise<undefined> endWheelTransaction(WindowProxy window);
    724 
    725  /**
    726   * Register a new toplevel window global actor. This method may only be
    727   * called in the parent process. |name| must be globally unique.
    728   *
    729   * See JSWindowActor.webidl for WindowActorOptions fields documentation.
    730   */
    731  [ChromeOnly, Throws]
    732  undefined registerWindowActor(UTF8String aName, optional WindowActorOptions aOptions = {});
    733 
    734  [ChromeOnly, Throws]
    735  undefined unregisterWindowActor(UTF8String aName);
    736 
    737  /**
    738   * Register a new toplevel content global actor. This method may only be
    739   * called in the parent process. |name| must be globally unique.
    740   *
    741   * See JSProcessActor.webidl for ProcessActorOptions fields documentation.
    742   */
    743  [ChromeOnly, Throws]
    744  undefined registerProcessActor(UTF8String aName, optional ProcessActorOptions aOptions = {});
    745 
    746  [ChromeOnly, Throws]
    747  undefined unregisterProcessActor(UTF8String aName);
    748 
    749  /**
    750   * Ensure a content process with the given remote type is running, and return
    751   * a "KeepAlive" object for it. While this object is kept alive, the
    752   * process will not intentionally exit.
    753   *
    754   * This follows the same process selection logic as creating a remote browser,
    755   * allowing up to `dom.ipc.processCount.<aRemoteType>` processes (default 1)
    756   * to be created per remote type. Once the limit has been reached, a new
    757   * KeepAlive for an existing process will be returned instead.
    758   *
    759   * This can be used to start a content process for non-browser use cases, such
    760   * as running sandboxed JS/WASM operations in a content process.
    761   */
    762  [ChromeOnly, Throws]
    763  Promise<nsIContentParentKeepAlive> ensureHeadlessContentProcess(UTF8String aRemoteType);
    764 
    765  [ChromeOnly]
    766  // aError should a nsresult.
    767  boolean isClassifierBlockingErrorCode(unsigned long aError);
    768 
    769  /**
    770   * If leak detection is enabled, print a note to the leak log that this
    771   * process will intentionally crash. This should be called only on child
    772   * processes for testing purpose.
    773   */
    774  [ChromeOnly, Throws]
    775  undefined privateNoteIntentionalCrash();
    776 
    777  /**
    778   * nsIDOMProcessChild for the current process.
    779   */
    780  [ChromeOnly]
    781  readonly attribute nsIDOMProcessChild? domProcessChild;
    782 
    783  /**
    784   * nsIDOMProcessParent for all processes.
    785   *
    786   * The first is for the parent process and all the next are for the content
    787   * processes.
    788   */
    789  [Throws, ChromeOnly]
    790  sequence<nsIDOMProcessParent> getAllDOMProcesses();
    791 
    792  /**
    793   * Returns a record of user interaction data. Currently only typing,
    794   * but will include scrolling and potentially other metrics.
    795   *
    796   * Valid keys: "Typing"
    797   */
    798  [Throws, ChromeOnly]
    799  record<DOMString, InteractionData> consumeInteractionData();
    800 
    801  /**
    802   * Returns a record of user scrolling interactions collected from content processes.
    803   *
    804   * Valid keys: "Scrolling"
    805   */
    806  [NewObject]
    807  Promise<InteractionData> collectScrollingData();
    808 
    809  [Throws]
    810  sequence<FormAutofillConfidences> getFormAutofillConfidences(sequence<Element> elements);
    811 
    812  /**
    813   * Returns whether the background of the element is dark.
    814   */
    815  boolean isDarkBackground(Element element);
    816 
    817  /**
    818   * Starts the JSOracle process for ORB JavaScript validation, if it hasn't started already.
    819   */
    820  undefined ensureJSOracleStarted();
    821 
    822  /**
    823   * The number of currently alive utility processes.
    824   */
    825  [ChromeOnly]
    826  readonly attribute unsigned long aliveUtilityProcesses;
    827 
    828  /**
    829   * Get a list of all possible Utility process Actor Names ; mostly useful to
    830   * perform testing and ensure about:processes display is sound and misses no
    831   * actor name.
    832   */
    833  [ChromeOnly]
    834  sequence<UTF8String> getAllPossibleUtilityActorNames();
    835 
    836  boolean shouldResistFingerprinting(JSRFPTarget target,
    837                                     nsIRFPTargetSetIDL? overriddenFingerprintingSettings,
    838                                     optional boolean isPBM);
    839 
    840  // Equivalent to pressing the home button. Exclusively for testing.
    841  [ChromeOnly]
    842  undefined androidMoveTaskToBack();
    843 
    844  [Throws]
    845  ContentSecurityPolicy createCSPFromHeader(DOMString header, URI selfURI, Principal loadingPrincipal);
    846 
    847  // This helper function executes `func` and redirects any exception
    848  // that may be thrown while running it to the DevTools Console currently
    849  // debugging `targetGlobal`.
    850  //
    851  // This helps flag the nsIScriptError with a particular innerWindowID
    852  // which is especially useful for WebExtension content scripts
    853  // where script are running in a Sandbox whose prototype is the content window.
    854  // We expect content script exception to be flagged with the content window
    855  // innerWindowID in order to appear in the tab's DevTools.
    856  [ChromeOnly, Throws]
    857  any callFunctionAndLogException(any targetGlobal, any func);
    858 
    859  // For a given command name, returns:
    860  //  * Null if not all windows handle this command.
    861  //  * true if all windows handle it _and_ it's unconditionally enabled.
    862  //  * false if all windows handle and it is not unconditionally enabled.
    863  boolean? getGlobalWindowCommandEnabled(UTF8String name);
    864 
    865  [Throws]
    866  Promise<imgIContainer> fetchDecodedImage(URI uri, MozChannel channel);
    867 
    868  // Returns the stack trace captured from the most recent out-of-memory exception,
    869  // or null if no OOM stack trace is available. The stack trace shows the JavaScript
    870  // call stack at the time the out-of-memory condition occurred
    871  DOMString getLastOOMStackTrace();
    872 };
    873 
    874 /*
    875 * This type is a WebIDL representation of mozilla::ProcType.
    876 * These must match the similar ones in E10SUtils.sys.mjs, RemoteTypes.h,
    877 * ProcInfo.h and ChromeUtils.cpp
    878 */
    879 enum WebIDLProcType {
    880 "web",
    881 "webIsolated",
    882 "file",
    883 "extension",
    884 "privilegedabout",
    885 "privilegedmozilla",
    886 "withCoopCoep",
    887 "webServiceWorker",
    888 "browser",
    889 "ipdlUnitTest",
    890 "gmpPlugin",
    891 "gpu",
    892 "vr",
    893 "rdd",
    894 "socket",
    895 "inference",
    896 #ifdef MOZ_ENABLE_FORKSERVER
    897 "forkServer",
    898 #endif
    899 "utility",
    900 "preallocated",
    901 "unknown",
    902 };
    903 
    904 /**
    905 * These dictionaries hold information about Firefox running processes and
    906 * threads.
    907 *
    908 * See widget/ProcInfo.h for fields documentation.
    909 */
    910 dictionary ThreadInfoDictionary {
    911  long long tid = 0;
    912  DOMString name = "";
    913  unsigned long long cpuCycleCount = 0;
    914  unsigned long long cpuTime = 0;
    915 };
    916 
    917 dictionary WindowInfoDictionary {
    918  // Window ID, as known to the parent process.
    919  unsigned long long outerWindowId = 0;
    920 
    921  // URI of the document loaded in the window.
    922  URI? documentURI = null;
    923 
    924  // Title of the document loaded in the window.
    925  // Commonly empty for subframes.
    926  DOMString documentTitle = "";
    927 
    928  // `true` if this window is the root for the process.
    929  boolean isProcessRoot = false;
    930 
    931  // `true` if this is loaded in the same process as the parent, `false` otherwise.
    932  boolean isInProcess = false;
    933 };
    934 
    935 /*
    936 * Add new entry to WebIDLUtilityActorName here and update accordingly
    937 * UtilityActorNameToWebIDL in dom/base/ChromeUtils.cpp as well as
    938 * UtilityActorName in toolkit/components/processtools/ProcInfo.h
    939 */
    940 enum WebIDLUtilityActorName {
    941  "unknown",
    942  "audioDecoder_Generic",
    943  "audioDecoder_AppleMedia",
    944  "audioDecoder_WMF",
    945  "mfMediaEngineCDM",
    946  "jSOracle",
    947  "windowsUtils",
    948  "windowsFileDialog",
    949 };
    950 
    951 dictionary UtilityActorsDictionary {
    952  WebIDLUtilityActorName actorName = "unknown";
    953 };
    954 
    955 /**
    956 * Information on a child process.
    957 *
    958 * # Limitation
    959 *
    960 * If we lose a race with a process or thread attempting to close the
    961 * target process, not all information is available.
    962 *
    963 * Missing information will generally have its default value.
    964 */
    965 dictionary ChildProcInfoDictionary {
    966  // --- System info
    967 
    968  // The cross-process descriptor for this process.
    969  long long pid = 0;
    970 
    971  // The best end-user measure for "memory used" that we can obtain without
    972  // triggering expensive computations. The value is in bytes.
    973  // On Mac and Linux this matches the values shown by the system monitors.
    974  // On Windows this will return the Commit Size.
    975  unsigned long long memory = 0;
    976 
    977  // Total CPU time spent by the process, in ns.
    978  unsigned long long cpuTime = 0;
    979 
    980  // Total CPU cycles used by this process.
    981  // On Windows where the resolution of CPU timings is 16ms, this can
    982  // be used to determine if a process is idle or slightly active.
    983  unsigned long long cpuCycleCount = 0;
    984 
    985  // Thread information for this process.
    986  sequence<ThreadInfoDictionary> threads = [];
    987 
    988  // --- Firefox info
    989 
    990  // Internal-to-Firefox process identifier.
    991  unsigned long long childID = 0;
    992 
    993  // The origin of the process, e.g. the subset of domain names
    994  // that this subset serves.
    995  UTF8String origin = "";
    996 
    997  // Type of this child process.
    998  WebIDLProcType type = "web";
    999 
   1000  // The windows implemented by this process.
   1001  sequence<WindowInfoDictionary> windows = [];
   1002 
   1003  // The utility process list of actors if any
   1004  sequence<UtilityActorsDictionary> utilityActors = [];
   1005 };
   1006 
   1007 /**
   1008 * Information on the parent process.
   1009 */
   1010 dictionary ParentProcInfoDictionary {
   1011  // --- System info
   1012 
   1013  // The cross-process descriptor for this process.
   1014  long long pid = 0;
   1015 
   1016  // The best end-user measure for "memory used" that we can obtain without
   1017  // triggering expensive computations. The value is in bytes.
   1018  // On Mac and Linux this matches the values shown by the system monitors.
   1019  // On Windows this will return the Commit Size.
   1020  unsigned long long memory = 0;
   1021 
   1022  // Total CPU time spent by the process, in ns.
   1023  unsigned long long cpuTime = 0;
   1024 
   1025  // Total CPU cycles used by this process.
   1026  // On Windows where the resolution of CPU timings is 16ms, this can
   1027  // be used to determine if a process is idle or slightly active.
   1028  unsigned long long cpuCycleCount = 0;
   1029 
   1030  // Thread information for this process.
   1031  sequence<ThreadInfoDictionary> threads = [];
   1032 
   1033  // Information on children processes.
   1034  sequence<ChildProcInfoDictionary> children = [];
   1035 
   1036  // --- Firefox info
   1037  // Type of this parent process.
   1038  // As of this writing, this is always `browser`.
   1039  WebIDLProcType type = "browser";
   1040 };
   1041 
   1042 /**
   1043 * Used by principals and the script security manager to represent origin
   1044 * attributes. The first dictionary is designed to contain the full set of
   1045 * OriginAttributes, the second is used for pattern-matching (i.e. does this
   1046 * OriginAttributesDictionary match the non-empty attributes in this pattern).
   1047 *
   1048 * IMPORTANT: If you add any members here, you need to do the following:
   1049 * (1) Add them to both dictionaries.
   1050 * (2) Update the methods on mozilla::OriginAttributes, including equality,
   1051 *     serialization, deserialization, and inheritance.
   1052 * (3) Update the methods on mozilla::OriginAttributesPattern, including matching.
   1053 */
   1054 [GenerateInitFromJSON, GenerateEqualityOperator]
   1055 dictionary OriginAttributesDictionary {
   1056  unsigned long userContextId = 0;
   1057  unsigned long privateBrowsingId = 0;
   1058  DOMString firstPartyDomain = "";
   1059  DOMString geckoViewSessionContextId = "";
   1060  DOMString partitionKey = "";
   1061 };
   1062 
   1063 [GenerateInitFromJSON, GenerateToJSON]
   1064 dictionary OriginAttributesPatternDictionary {
   1065  unsigned long userContextId;
   1066  unsigned long privateBrowsingId;
   1067  DOMString firstPartyDomain;
   1068  DOMString geckoViewSessionContextId;
   1069  // partitionKey takes precedence over partitionKeyPattern.
   1070  DOMString partitionKey;
   1071  PartitionKeyPatternDictionary partitionKeyPattern;
   1072 };
   1073 
   1074 dictionary PartitionKeyPatternDictionary {
   1075  DOMString scheme;
   1076  DOMString baseDomain;
   1077  long port;
   1078  boolean foreignByAncestorContext;
   1079 };
   1080 
   1081 dictionary CompileScriptOptionsDictionary {
   1082  /**
   1083   * The character set from which to decode the script.
   1084   */
   1085  DOMString charset = "utf-8";
   1086 
   1087  /**
   1088   * The filename to associate with the script. Defaults to the source's URL.
   1089   */
   1090  DOMString filename;
   1091 
   1092  /**
   1093   * If true, certain parts of the script may be parsed lazily, the first time
   1094   * they are used, rather than eagerly parsed at load time.
   1095   */
   1096  boolean lazilyParse = false;
   1097 
   1098  /**
   1099   * If true, the script will be compiled so that its last expression will be
   1100   * returned as the value of its execution. This makes certain types of
   1101   * optimization impossible, and disables the JIT in many circumstances, so
   1102   * should not be used when not absolutely necessary.
   1103   */
   1104  boolean hasReturnValue = false;
   1105 };
   1106 
   1107 /**
   1108 * Where the modules are loaded into with importESModule and
   1109 * defineESModuleGetters.
   1110 */
   1111 enum ImportESModuleTargetGlobal {
   1112  /**
   1113   * Load into the shared system global.
   1114   * This is the default value.
   1115   */
   1116  "shared",
   1117 
   1118  /**
   1119   * Load into a distinct system global for DevTools, so that the DevTools can
   1120   * load a distinct set of modules and do not interfere with its debuggee.
   1121   */
   1122  "devtools",
   1123 
   1124  /**
   1125   * If the current global is DevTools' distinct system global, load into the
   1126   * DevTools' distinct system global.
   1127   * If the current thread is worker thread, load into the current global.
   1128   * Otherwise load into the shared system global.
   1129   *
   1130   * This is a temporary workaround until DevTools modules are ESMified.
   1131   */
   1132  "contextual",
   1133 
   1134  /**
   1135   * Load into current global.
   1136   *
   1137   * This can be used for any global.  If this is used for shared global or
   1138   * devtools global, this has the same effect as "shared" or "devtools".
   1139   */
   1140  "current",
   1141 };
   1142 
   1143 dictionary ImportESModuleOptionsDictionary {
   1144  // This field is required for importESModule and defineESModuleGetters in
   1145  // DevTools distinct global.
   1146  ImportESModuleTargetGlobal global;
   1147 };
   1148 
   1149 /**
   1150 * A JS object whose properties specify what portion of the heap graph to
   1151 * write. The recognized properties are:
   1152 *
   1153 * * globals: [ global, ... ]
   1154 *   Dump only nodes that either:
   1155 *   - belong in the compartment of one of the given globals;
   1156 *   - belong to no compartment, but do belong to a Zone that contains one of
   1157 *     the given globals;
   1158 *   - are referred to directly by one of the last two kinds of nodes; or
   1159 *   - is the fictional root node, described below.
   1160 *
   1161 * * debugger: Debugger object
   1162 *   Like "globals", but use the Debugger's debuggees as the globals.
   1163 *
   1164 * * runtime: true
   1165 *   Dump the entire heap graph, starting with the JSRuntime's roots.
   1166 *
   1167 * One, and only one, of these properties must exist on the boundaries object.
   1168 *
   1169 * The root of the dumped graph is a fictional node whose ubi::Node type name is
   1170 * "CoreDumpRoot". If we are dumping the entire ubi::Node graph, this root node
   1171 * has an edge for each of the JSRuntime's roots. If we are dumping a selected
   1172 * set of globals, the root has an edge to each global, and an edge for each
   1173 * incoming JS reference to the selected Zones.
   1174 */
   1175 dictionary HeapSnapshotBoundaries {
   1176  sequence<object> globals;
   1177  object           debugger;
   1178  boolean          runtime;
   1179 };
   1180 
   1181 dictionary Base64URLEncodeOptions {
   1182  /** Specifies whether the output should be padded with "=" characters. */
   1183  required boolean pad;
   1184 };
   1185 
   1186 enum Base64URLDecodePadding {
   1187  /**
   1188   * Fails decoding if the input is unpadded. RFC 4648, section 3.2 requires
   1189   * padding, unless the referring specification prohibits it.
   1190   */
   1191  "require",
   1192 
   1193  /** Tolerates padded and unpadded input. */
   1194  "ignore",
   1195 
   1196  /**
   1197   * Fails decoding if the input is padded. This follows the strict base64url
   1198   * variant used in JWS (RFC 7515, Appendix C) and HTTP Encrypted
   1199   * Content-Encoding (draft-ietf-httpbis-encryption-encoding-01).
   1200   */
   1201  "reject"
   1202 };
   1203 
   1204 dictionary Base64URLDecodeOptions {
   1205  /** Specifies the padding mode for decoding the input. */
   1206  required Base64URLDecodePadding padding;
   1207 };
   1208 
   1209 // Keep this in sync with PopupBlocker::PopupControlState!
   1210 enum PopupBlockerState {
   1211  "openAllowed",
   1212  "openControlled",
   1213  "openBlocked",
   1214  "openAbused",
   1215  "openOverridden",
   1216 };
   1217 
   1218 // Subset of RFPTargets.inc with JS callers.
   1219 // New values need to be handled in ChromeUtils::ShouldResistFingerprinting.
   1220 enum JSRFPTarget {
   1221  "RoundWindowSize",
   1222  "SiteSpecificZoom",
   1223  "CSSPrefersColorScheme",
   1224  "JSLocalePrompt",
   1225  "HttpUserAgent",
   1226 };
   1227 
   1228 #ifdef XP_UNIX
   1229 dictionary LibcConstants {
   1230  long EPERM;
   1231  long EINTR;
   1232  long EACCES;
   1233  long EAGAIN;
   1234  long EINVAL;
   1235  long ENOSYS;
   1236 
   1237  long F_SETFD;
   1238  long F_SETFL;
   1239 
   1240  long FD_CLOEXEC;
   1241 
   1242  long AT_EACCESS;
   1243 
   1244  long O_CREAT;
   1245  long O_NONBLOCK;
   1246  long O_WRONLY;
   1247 
   1248  long POLLIN;
   1249  long POLLOUT;
   1250  long POLLERR;
   1251  long POLLHUP;
   1252  long POLLNVAL;
   1253 
   1254  long WNOHANG;
   1255 
   1256 #ifdef XP_LINUX
   1257  long PR_CAPBSET_READ;
   1258 #endif
   1259 };
   1260 #endif
   1261 
   1262 dictionary CDMInformation {
   1263  required DOMString keySystemName;
   1264  required DOMString capabilities;
   1265  required boolean clearlead;
   1266  required boolean isHardwareDecryption;
   1267 };
   1268 
   1269 /**
   1270 * This is effectively a 1:1 mapping of the fields exposed by Necko's
   1271 * CacheControlParser, which lets us use the results from that parser in JS.
   1272 */
   1273 [GenerateConversionToJS]
   1274 dictionary HTTPCacheControlParseResult {
   1275  unsigned long maxAge = 0;
   1276  unsigned long maxStale = 0;
   1277  unsigned long minFresh = 0;
   1278  unsigned long staleWhileRevalidate = 0;
   1279  boolean noCache = false;
   1280  boolean noStore = false;
   1281  boolean public = false;
   1282  boolean private = false;
   1283  boolean immutable = false;
   1284 };