Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / dom / chrome-webidl / WindowGlobalActors.webidl
blob7e202ee445d9fc7c169c7b8bb5f84342af368079
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/. */
6 interface Principal;
7 interface URI;
8 interface nsIDocShell;
9 interface RemoteTab;
10 interface nsIDOMProcessParent;
12 [Exposed=Window, ChromeOnly]
13 interface WindowContext {
14   readonly attribute BrowsingContext? browsingContext;
16   readonly attribute WindowGlobalChild? windowGlobalChild; // in-process only
18   readonly attribute unsigned long long innerWindowId;
20   readonly attribute WindowContext? parentWindowContext;
22   readonly attribute WindowContext topWindowContext;
24   readonly attribute boolean isInProcess;
26   // True if this WindowContext is currently frozen in the BFCache.
27   readonly attribute boolean isInBFCache;
29   // True if this window has registered a "beforeunload" event handler.
30   readonly attribute boolean hasBeforeUnload;
32   // True if the principal of this window is for a local ip address.
33   readonly attribute boolean isLocalIP;
35   readonly attribute boolean shouldResistFingerprinting;
37   /**
38    * Partially determines whether script execution is allowed in this
39    * BrowsingContext. Script execution will be permitted only if this
40    * attribute is true and script execution is allowed in the owner
41    * BrowsingContext.
42    *
43    * May only be set in the context's owning process.
44    */
45   [SetterThrows] attribute boolean allowJavascript;
48 // Keep this in sync with nsIContentViewer::PermitUnloadAction.
49 enum PermitUnloadAction {
50   "prompt",
51   "dontUnload",
52   "unload",
55 [Exposed=Window, ChromeOnly]
56 interface WindowGlobalParent : WindowContext {
57   readonly attribute boolean isClosed;
59   readonly attribute boolean isCurrentGlobal;
61   readonly attribute unsigned long long outerWindowId;
62   readonly attribute unsigned long long contentParentId;
64   readonly attribute long osPid;
66   // A WindowGlobalParent is the root in its process if it has no parent, or its
67   // embedder is in a different process.
68   readonly attribute boolean isProcessRoot;
70   // Is the document loaded in this WindowGlobalParent the initial document
71   // implicitly created while "creating a new browsing context".
72   // https://html.spec.whatwg.org/multipage/browsers.html#creating-a-new-browsing-context
73   readonly attribute boolean isInitialDocument;
75   readonly attribute FrameLoader? rootFrameLoader; // Embedded (browser) only
77   readonly attribute WindowGlobalChild? childActor; // in-process only
79   // Checks for any WindowContexts with "beforeunload" listeners in this
80   // WindowGlobal's subtree. If any exist, a "beforeunload" event is
81   // dispatched to them. If any of those request to block the navigation,
82   // displays a prompt to the user. Returns a boolean which resolves to true
83   // if the navigation should be allowed.
84   //
85   // If `timeout` is greater than 0, it is the maximum time (in milliseconds)
86   // we will wait for a child process to respond with a request to block
87   // navigation before proceeding. If the user needs to be prompted, however,
88   // the promise will not resolve until the user has responded, regardless of
89   // the timeout.
90   [NewObject]
91   Promise<boolean> permitUnload(optional PermitUnloadAction action = "prompt",
92                                 optional unsigned long timeout = 0);
94   // Information about the currently loaded document.
95   readonly attribute Principal documentPrincipal;
96   readonly attribute Principal documentStoragePrincipal;
97   readonly attribute Principal? contentBlockingAllowListPrincipal;
98   readonly attribute URI? documentURI;
99   readonly attribute DOMString documentTitle;
100   readonly attribute nsICookieJarSettings? cookieJarSettings;
102   // True if the the currently loaded document is in fullscreen.
103   attribute boolean fullscreen;
105   // Bit mask containing content blocking events that are recorded in
106   // the document's content blocking log.
107   readonly attribute unsigned long contentBlockingEvents;
109   // String containing serialized content blocking log.
110   readonly attribute DOMString contentBlockingLog;
112   // DOM Process which this window was loaded in. Will be either InProcessParent
113   // for windows loaded in the parent process, or ContentParent for windows
114   // loaded in the content process.
115   readonly attribute nsIDOMProcessParent? domProcess;
117   static WindowGlobalParent? getByInnerWindowId(unsigned long long innerWindowId);
119   /**
120    * Get or create the JSWindowActor with the given name.
121    *
122    * See WindowActorOptions from JSWindowActor.webidl for details on how to
123    * customize actor creation.
124    */
125   [Throws]
126   JSWindowActorParent getActor(UTF8String name);
127   JSWindowActorParent? getExistingActor(UTF8String name);
129   /**
130    * Renders a region of the frame into an image bitmap.
131    *
132    * @param rect Specify the area of the document to render, in CSS pixels,
133    * relative to the page. If null, the currently visible viewport is rendered.
134    * @param scale The scale to render the window at. Use devicePixelRatio
135    * to have comparable rendering to the OS.
136    * @param backgroundColor The background color to use.
137    * @param resetScrollPosition If true, temporarily resets the scroll position
138    * of the root scroll frame to 0, such that position:fixed elements are drawn
139    * at their initial position. This parameter only takes effect when passing a
140    * non-null rect.
141    *
142    * This API can only be used in the parent process, as content processes
143    * cannot access the rendering of out of process iframes. This API works
144    * with remote and local frames.
145    */
146   [NewObject]
147   Promise<ImageBitmap> drawSnapshot(DOMRect? rect,
148                                     double scale,
149                                     UTF8String backgroundColor,
150                                     optional boolean resetScrollPosition = false);
152   // True if any of the windows in the subtree rooted at this window
153   // has active peer connections.  If this is called for a non-top-level
154   // context, it always returns false.
155   boolean hasActivePeerConnections();
158 [Exposed=Window, ChromeOnly]
159 interface WindowGlobalChild {
160   readonly attribute boolean isClosed;
161   readonly attribute boolean isInProcess;
162   readonly attribute BrowsingContext browsingContext;
163   readonly attribute WindowContext windowContext;
165   readonly attribute boolean isCurrentGlobal;
167   readonly attribute unsigned long long innerWindowId;
168   readonly attribute unsigned long long outerWindowId;
169   readonly attribute unsigned long long contentParentId;
171   // A WindowGlobalChild is the root in its process if it has no parent, or its
172   // embedder is in a different process.
173   readonly attribute boolean isProcessRoot;
175   // Is this WindowGlobalChild same-origin with `window.top`?
176   readonly attribute boolean sameOriginWithTop;
178   readonly attribute WindowGlobalParent? parentActor; // in-process only
180   static WindowGlobalChild? getByInnerWindowId(unsigned long long innerWIndowId);
182   BrowsingContext? findBrowsingContextWithName(DOMString name);
184   /**
185    * Get or create the JSWindowActor with the given name.
186    *
187    * See WindowActorOptions from JSWindowActor.webidl for details on how to
188    * customize actor creation.
189    */
190   [Throws]
191   JSWindowActorChild getActor(UTF8String name);
192   JSWindowActorChild? getExistingActor(UTF8String name);