tor-browser

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

BrowsingContext.webidl (17092B)


      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
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 interface URI;
      7 interface nsIDocShell;
      8 interface nsIDOMGeoPosition;
      9 interface nsISecureBrowserUI;
     10 interface nsISHEntry;
     11 interface nsIPrintSettings;
     12 interface nsIWebProgress;
     13 
     14 interface mixin LoadContextMixin {
     15  readonly attribute WindowProxy? associatedWindow;
     16 
     17  readonly attribute WindowProxy? topWindow;
     18 
     19  readonly attribute Element? topFrameElement;
     20 
     21  readonly attribute boolean isContent;
     22 
     23  [SetterThrows]
     24  attribute boolean usePrivateBrowsing;
     25 
     26  readonly attribute boolean useRemoteTabs;
     27 
     28  readonly attribute boolean useRemoteSubframes;
     29 
     30  [BinaryName="useTrackingProtectionWebIDL", SetterThrows]
     31  attribute boolean useTrackingProtection;
     32 
     33  [NewObject, Throws]
     34  readonly attribute any originAttributes;
     35 };
     36 
     37 /**
     38 * Allowed CSS display modes. This needs to be kept in
     39 * sync with similar values in ServoStyleConsts.h
     40 */
     41 enum DisplayMode {
     42  "browser",
     43  "minimal-ui",
     44  "standalone",
     45  "fullscreen",
     46  "picture-in-picture"
     47 };
     48 
     49 /**
     50 * CSS prefers-color-scheme values.
     51 */
     52 enum PrefersColorSchemeOverride {
     53  "none",
     54  "light",
     55  "dark",
     56 };
     57 
     58 /**
     59 * CSS forced-colors values.
     60 */
     61 enum ForcedColorsOverride {
     62  "none",
     63  "active",
     64 };
     65 
     66 /**
     67 * Allowed overrides of platform/pref default behaviour for touch events.
     68 */
     69 enum TouchEventsOverride {
     70  "disabled", // Force-disable touch events.
     71  "enabled", // Force-enable touch events.
     72  "none", // Don't override behaviour for touch events.
     73 };
     74 
     75 [Exposed=Window, ChromeOnly]
     76 interface BrowsingContext {
     77  static BrowsingContext? get(unsigned long long aId);
     78 
     79  static BrowsingContext? getFromWindow(WindowProxy window);
     80 
     81  static BrowsingContext? getCurrentTopByBrowserId(unsigned long long aId);
     82 
     83  sequence<BrowsingContext> getAllBrowsingContextsInSubtree();
     84 
     85  readonly attribute DOMString name;
     86 
     87  readonly attribute BrowsingContext? parent;
     88 
     89  readonly attribute BrowsingContext top;
     90 
     91  [Cached, Frozen, Pure]
     92  readonly attribute sequence<BrowsingContext> children;
     93 
     94  readonly attribute nsIDocShell? docShell;
     95 
     96  readonly attribute Element? embedderElement;
     97 
     98  readonly attribute unsigned long long id;
     99 
    100  readonly attribute BrowsingContext? opener;
    101 
    102  readonly attribute BrowsingContextGroup group;
    103 
    104  readonly attribute WindowProxy? window;
    105 
    106  readonly attribute WindowContext? currentWindowContext;
    107 
    108  readonly attribute WindowContext? parentWindowContext;
    109 
    110  readonly attribute WindowContext? topWindowContext;
    111 
    112  readonly attribute boolean ancestorsAreCurrent;
    113 
    114  [SetterThrows] attribute [LegacyNullToEmptyString] DOMString customPlatform;
    115 
    116  [SetterThrows] attribute [LegacyNullToEmptyString] DOMString customUserAgent;
    117 
    118  readonly attribute DOMString embedderElementType;
    119 
    120  readonly attribute boolean createdDynamically;
    121 
    122  readonly attribute boolean isInBFCache;
    123 
    124  readonly attribute boolean isDiscarded;
    125 
    126  /**
    127   * The sandbox flags on the browsing context. These reflect the value of the
    128   * sandbox attribute of the associated IFRAME or CSP-protectable content, if
    129   * existent. See the HTML5 spec for more details.
    130   * These flags on the browsing context reflect the current state of the
    131   * sandbox attribute, which is modifiable. They are only used when loading new
    132   * content, sandbox flags are also immutably set on the document when it is
    133   * loaded.
    134   * The sandbox flags of a document depend on the sandbox flags on its
    135   * browsing context and of its parent document, if any.
    136   * See nsSandboxFlags.h for the possible flags.
    137   */
    138  [SetterThrows] attribute unsigned long sandboxFlags;
    139 
    140  /**
    141   * Whether the BrowsingContext is active. That is, whether it's in a
    142   * foreground tab, and not minimized or fully occluded otherwise.
    143   */
    144  readonly attribute boolean isActive;
    145 
    146  /**
    147   * When set to true all channels in this browsing context or its children will report navigator.onLine = false,
    148   * and HTTP requests created from these browsing context will fail with NS_ERROR_OFFLINE.
    149   */
    150  [SetterThrows] attribute boolean forceOffline;
    151 
    152  /**
    153   * Sets whether this is an app tab. Non-same-origin link navigations from app
    154   * tabs may be forced to open in new contexts, rather than in the same context.
    155   */
    156  [SetterThrows] attribute boolean isAppTab;
    157 
    158  /**
    159   * Sets whether this is BC has siblings **at the toplevel** (e.g. in a tabbed
    160   * browser environment). Used to determine if web content can resize the top
    161   * window. Never set correctly for non-top BCs.
    162   */
    163  [SetterThrows] attribute boolean hasSiblings;
    164 
    165  // The inRDMPane flag indicates whether or not Responsive Design Mode is
    166  // active for the browsing context.
    167  [SetterThrows] attribute boolean inRDMPane;
    168 
    169  [SetterThrows] attribute float fullZoom;
    170 
    171  [SetterThrows] attribute float textZoom;
    172 
    173  // Override the dots-per-CSS-pixel scaling factor in this BrowsingContext
    174  // and all of its descendants. May only be set on the top BC, and should
    175  // only be set from the parent process.
    176  //
    177  // A value of 0.0 causes us to use the global default scaling factor.
    178  //
    179  // NOTE that this override only affects a few minor things (the value exposed
    180  // to devicePixelRatio and some media queries in content, and responsive
    181  // image selection). Most notably, it does _not_ affect rendering.
    182  //
    183  // It is intended for RDM, and is probably not what you want in other cases.
    184  // If you want to change the actual device pixel ratio that rendering code
    185  // uses, you probably want to change the fullZoom.
    186  [SetterThrows] attribute float overrideDPPX;
    187 
    188  [SetterThrows] attribute boolean suspendMediaWhenInactive;
    189 
    190  // Default value for nsIDocumentViewer::authorStyleDisabled in any new
    191  // browsing contexts created as a descendant of this one.
    192  //
    193  // Valid only for top browsing contexts.
    194  [SetterThrows] attribute boolean authorStyleDisabledDefault;
    195 
    196  /**
    197   * Whether this docshell should save entries in global history.
    198   */
    199  [SetterThrows] attribute boolean useGlobalHistory;
    200 
    201  // Extension to give chrome JS the ability to set the window screen
    202  // dimensions override with WebDriver BiDi.
    203  [Throws] undefined setScreenAreaOverride(unsigned long long screenWidth, unsigned long long screenHeight);
    204  // Extension to give chrome JS the ability to reset the window screen
    205  // dimensions override with WebDriver BiDi.
    206  undefined resetScreenAreaOverride();
    207 
    208  // Extension to give chrome JS the ability to set the window screen
    209  // orientation override with WebDriver BiDi and DevTools.
    210  [Throws] undefined setOrientationOverride(OrientationType type, float rotationAngle);
    211  // Extension to give chrome JS the ability to reset the window screen
    212  // orientation override with WebDriver BiDi and DevTools.
    213  undefined resetOrientationOverride();
    214 
    215  // Extension to give chrome JS the ability to set a maxTouchPoints override
    216  // while in RDM.
    217  [Throws] undefined setRDMPaneMaxTouchPoints(octet maxTouchPoints);
    218 
    219  // Geolocation emulation for WebDriver BiDi and DevTools.
    220  // Note: in case of watchPosition emulation, the override has to be set
    221  // before the watcher is started.
    222  undefined setGeolocationServiceOverride(optional nsIDOMGeoPosition position);
    223 
    224  // The watchedByDevTools flag indicates whether or not DevTools are currently
    225  // debugging this browsing context.
    226  [SetterThrows] attribute boolean watchedByDevTools;
    227 
    228  // Enable some service workers testing features, for DevTools.
    229  [SetterThrows] attribute boolean serviceWorkersTestingEnabled;
    230 
    231  // Enable media query medium override, for DevTools.
    232  [SetterThrows] attribute DOMString mediumOverride;
    233 
    234  // Language emulation for WebDriver BiDi and DevTools.
    235  [SetterThrows] attribute UTF8String languageOverride;
    236 
    237  // Timezone emulation for WebDriver BiDi and DevTools per browsing context.
    238  [SetterThrows] attribute DOMString timezoneOverride;
    239 
    240  // Color-scheme simulation, for DevTools.
    241  [SetterThrows] attribute PrefersColorSchemeOverride prefersColorSchemeOverride;
    242 
    243  // Forced-colors simulation, for DevTools
    244  [SetterThrows] attribute ForcedColorsOverride forcedColorsOverride;
    245 
    246  /**
    247   * A unique identifier for the browser element that is hosting this
    248   * BrowsingContext tree. Every BrowsingContext in the element's tree will
    249   * return the same ID in all processes and it will remain stable regardless of
    250   * process changes. When a browser element's frameloader is switched to
    251   * another browser element this ID will remain the same but hosted under the
    252   * under the new browser element.
    253   */
    254  [SetterThrows] attribute unsigned long long browserId;
    255 
    256  [SetterThrows] attribute DisplayMode displayMode;
    257 
    258  /**
    259   * This allows chrome to override the default choice of whether touch events
    260   * are available in a specific BrowsingContext and its descendents.
    261   */
    262  readonly attribute TouchEventsOverride touchEventsOverride;
    263 
    264  /**
    265   * Returns true if the top-level BrowsingContext has been configured to
    266   * default-target user-initiated link clicks to _blank.
    267   */
    268  readonly attribute boolean targetTopLevelLinkClicksToBlank;
    269 
    270  /**
    271   * Partially determines whether script execution is allowed in this
    272   * BrowsingContext. Script execution will be permitted only if this
    273   * attribute is true and script execution is allowed in the parent
    274   * WindowContext.
    275   *
    276   * May only be set in the parent process.
    277   */
    278  [SetterThrows] attribute boolean allowJavascript;
    279 
    280  /**
    281   * Determines whether we're forcing a desktop-mode viewport. Only settable in
    282   * the top browsing context from the parent process.
    283   */
    284  [SetterThrows] attribute boolean forceDesktopViewport;
    285 
    286  /*
    287   * Default load flags (as defined in nsIRequest) that will be set on all
    288   * requests made by this BrowsingContext.
    289   */
    290  [SetterThrows] attribute long defaultLoadFlags;
    291 
    292  /**
    293   * The nsID of the browsing context in the session history.
    294   */
    295  [NewObject, Throws]
    296  readonly attribute any historyID;
    297 
    298  readonly attribute ChildSHistory? childSessionHistory;
    299 
    300  // Resets the location change rate limit. Used for testing.
    301  undefined resetNavigationRateLimit();
    302 
    303  readonly attribute long childOffset;
    304 
    305  // https://wicg.github.io/document-picture-in-picture/
    306  // This is true both for the top-level BC of the content and chrome window
    307  // of a Document Picture-in-Picture window.
    308  [BinaryName="GetIsDocumentPiP"]
    309  readonly attribute boolean isDocumentPiP;
    310 };
    311 
    312 BrowsingContext includes LoadContextMixin;
    313 
    314 [Exposed=Window, ChromeOnly]
    315 interface CanonicalBrowsingContext : BrowsingContext {
    316  sequence<WindowGlobalParent> getWindowGlobals();
    317 
    318  readonly attribute WindowGlobalParent? currentWindowGlobal;
    319 
    320  readonly attribute WindowProxy? topChromeWindow;
    321 
    322  // XXX(nika): This feels kinda hacky, but will do for now while we don't
    323  // synchronously create WindowGlobalParent. It can throw if somehow the
    324  // content process has died.
    325  [Throws]
    326  readonly attribute UTF8String? currentRemoteType;
    327 
    328  readonly attribute WindowGlobalParent? embedderWindowGlobal;
    329 
    330  undefined notifyStartDelayedAutoplayMedia();
    331  [Throws] undefined notifyMediaMutedChanged(boolean muted);
    332 
    333  readonly attribute nsISecureBrowserUI? secureBrowserUI;
    334 
    335  /**
    336   * Returns an nsIWebProgress object for this BrowsingContext, if this
    337   * is a top-level content BC.
    338   *
    339   * Progress listeners attached to this will get notifications filtered by
    340   * nsBrowserStatusFilter, and don't get any notifications from sub frames.
    341   */
    342  readonly attribute nsIWebProgress? webProgress;
    343 
    344  static unsigned long countSiteOrigins(sequence<BrowsingContext> roots);
    345 
    346  /**
    347   * Loads a given URI.  This will give priority to loading the requested URI
    348   * in the object implementing this interface.  If it can't be loaded here
    349   * however, the URI dispatcher will go through its normal process of content
    350   * loading.
    351   *
    352   * @param aURI
    353   *        The URI to load.  No fixup will be performed on this URI.
    354   * @param aLoadURIOptions
    355   *        A JSObject defined in LoadURIOptions.webidl holding info like e.g.
    356   *        the triggeringPrincipal, the referrer info.
    357   */
    358  [Throws]
    359  undefined loadURI(URI aURI, optional LoadURIOptions aOptions = {});
    360 
    361  /**
    362   * Like `loadURI` but takes a DOMString instead. This will use nsIURIFixup
    363   * to "fix up" the input if it doesn't parse as a string. If an existing
    364   * DOM URL or nsIURI object is available to you, prefer using `loadURI`
    365   * directly.
    366   *
    367   * @param aURI
    368   *        The URI to load.  For HTTP and FTP URLs and possibly others,
    369   *        characters above U+007F will be converted to UTF-8 and then URL-
    370   *        escaped per the rules of RFC 2396.
    371   * @param aLoadURIOptions
    372   *        A JSObject defined in LoadURIOptions.webidl holding info like e.g.
    373   *        the triggeringPrincipal, the referrer info.
    374   */
    375  [Throws]
    376  undefined fixupAndLoadURIString(DOMString aURI, optional LoadURIOptions aOptions = {});
    377 
    378   /**
    379    * Print the current document.
    380    *
    381    * @param aOuterWindowID the ID of the outer window to print
    382    * @param aPrintSettings print settings to use; printSilent can be
    383    *                       set to prevent prompting.
    384    * @return A Promise that resolves once printing is finished.
    385    */
    386  [NewObject, BinaryName="printJS"]
    387  Promise<undefined> print(nsIPrintSettings aPrintSettings);
    388 
    389  /**
    390   * These methods implement the nsIWebNavigation methods of the same names
    391   */
    392  undefined goBack(optional long aCancelContentJSEpoch, optional boolean aRequireUserInteraction = false, optional boolean aUserActivation = false);
    393  undefined goForward(optional long aCancelContentJSEpoch, optional boolean aRequireUserInteraction  = false, optional boolean aUserActivation = false);
    394  undefined goToIndex(long aIndex, optional long aCancelContentJSEpoch, optional boolean aUserActivation = false);
    395  undefined reload(unsigned long aReloadFlags);
    396  undefined stop(unsigned long aStopFlags);
    397 
    398  readonly attribute nsISHistory? sessionHistory;
    399  readonly attribute nsISHEntry? activeSessionHistoryEntry;
    400 
    401  readonly attribute MediaController? mediaController;
    402 
    403  undefined resetScalingZoom();
    404 
    405  // The current URI loaded in this BrowsingContext according to nsDocShell.
    406  // This may not match the current window global's document URI in some cases.
    407  readonly attribute URI? currentURI;
    408 
    409  undefined clearRestoreState();
    410 
    411  // Force this browsing context, which must correspond to an app window, to
    412  // be active regardless of the window being minimized or fully occluded.
    413  [SetterThrows] attribute boolean forceAppWindowActive;
    414 
    415  // @see BrowsingContext.isActive.
    416  [SetterThrows] attribute boolean isActive;
    417 
    418  /**
    419   * This allows chrome to override the default choice of whether touch events
    420   * are available in a specific BrowsingContext and its descendents.
    421   */
    422  [SetterThrows] inherit attribute TouchEventsOverride touchEventsOverride;
    423 
    424  /**
    425   * Set to true to configure the top-level BrowsingContext to default-target
    426   * user-initiated link clicks to _blank.
    427   */
    428  [SetterThrows] inherit attribute boolean targetTopLevelLinkClicksToBlank;
    429 
    430  /**
    431   * Set the cross-group opener of this BrowsingContext. This tracks the opener
    432   * of a browsing context regardless if that context is opened using noopener.
    433   *
    434   * This value will be automatically set for documents created using
    435   * `window.open`.
    436   */
    437  [SetterThrows]
    438  attribute CanonicalBrowsingContext? crossGroupOpener;
    439 
    440  readonly attribute boolean isReplaced;
    441 
    442 
    443  /**
    444   * Notify APZ to start autoscrolling.
    445   *
    446   * (aAnchorX, aAnchorY) are the coordinates of the autoscroll anchor, in
    447   *                      device coordinates relative to the screen.
    448   * aScrollId and aPresShellId identify the scroll frame that content chose to
    449   *                            scroll.
    450   *
    451   * Returns whether we were successfully able to notify APZ.
    452   * If this function returns true, APZ (which may live in another process) may
    453   * still reject the autoscroll, but it's then APZ's responsibility to notify
    454   * content via an "autoscroll-rejected-by-apz" message.
    455   */
    456  boolean startApzAutoscroll(float aAnchorX, float aAnchorY,
    457                             unsigned long long aScrollId,
    458                             unsigned long aPresShellId);
    459 
    460  /**
    461   * Notify APZ to stop autoscrolling.
    462   */
    463  undefined stopApzAutoscroll(unsigned long long aScrollId,
    464                              unsigned long aPresShellId);
    465 
    466  readonly attribute nsISHEntry? mostRecentLoadingSessionHistoryEntry;
    467 
    468  /**
    469   * Indicates if the embedder element or an ancestor has hidden
    470   * visibility, or no frame.
    471   */
    472  readonly attribute boolean isUnderHiddenEmbedderElement;
    473 
    474  /**
    475   * Indicates whether opening a modal picker is permitted.
    476   */
    477  readonly attribute boolean canOpenModalPicker;
    478 };
    479 
    480 [Exposed=Window, ChromeOnly]
    481 interface BrowsingContextGroup {
    482  sequence<BrowsingContext> getToplevels();
    483 
    484  readonly attribute unsigned long long id;
    485 };