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/. */
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 // The granular fingerprinting protection overrides for the context. We will
38 // use the granular overrides to decide which fingerprinting protection we
39 // want to enable in the context due to the WebCompat reason. The value can be
40 // null, which means we are using default fingerprinting protection in the
42 [BinaryName="OverriddenFingerprintingSettingsWebIDL"]
43 readonly attribute unsigned long long? overriddenFingerprintingSettings;
46 * Partially determines whether script execution is allowed in this
47 * BrowsingContext. Script execution will be permitted only if this
48 * attribute is true and script execution is allowed in the owner
51 * May only be set in the context's owning process.
53 [SetterThrows] attribute boolean allowJavascript;
56 // Keep this in sync with nsIDocumentViewer::PermitUnloadAction.
57 enum PermitUnloadAction {
63 [Exposed=Window, ChromeOnly]
64 interface WindowGlobalParent : WindowContext {
65 readonly attribute boolean isClosed;
67 readonly attribute boolean isCurrentGlobal;
69 // This should return true if the window is currently visible in its tab.
70 // (A more technically accurate name would be something like
71 // "isActiveInRootNavigable".)
72 readonly attribute boolean isActiveInTab;
74 readonly attribute unsigned long long outerWindowId;
75 readonly attribute unsigned long long contentParentId;
77 readonly attribute long osPid;
79 // A WindowGlobalParent is the root in its process if it has no parent, or its
80 // embedder is in a different process.
81 readonly attribute boolean isProcessRoot;
83 // Is the document loaded in this WindowGlobalParent the initial document
84 // implicitly created while "creating a new browsing context".
85 // https://html.spec.whatwg.org/multipage/browsers.html#creating-a-new-browsing-context
86 readonly attribute boolean isInitialDocument;
88 readonly attribute FrameLoader? rootFrameLoader; // Embedded (browser) only
90 readonly attribute WindowGlobalChild? childActor; // in-process only
92 // Checks for any WindowContexts with "beforeunload" listeners in this
93 // WindowGlobal's subtree. If any exist, a "beforeunload" event is
94 // dispatched to them. If any of those request to block the navigation,
95 // displays a prompt to the user. Returns a boolean which resolves to true
96 // if the navigation should be allowed.
98 // If `timeout` is greater than 0, it is the maximum time (in milliseconds)
99 // we will wait for a child process to respond with a request to block
100 // navigation before proceeding. If the user needs to be prompted, however,
101 // the promise will not resolve until the user has responded, regardless of
104 Promise<boolean> permitUnload(optional PermitUnloadAction action = "prompt",
105 optional unsigned long timeout = 0);
107 // Information about the currently loaded document.
108 readonly attribute Principal documentPrincipal;
109 readonly attribute Principal documentStoragePrincipal;
110 readonly attribute Principal? contentBlockingAllowListPrincipal;
111 readonly attribute URI? documentURI;
112 readonly attribute DOMString documentTitle;
113 readonly attribute nsICookieJarSettings? cookieJarSettings;
115 // True if the the currently loaded document is in fullscreen.
116 attribute boolean fullscreen;
118 // Bit mask containing content blocking events that are recorded in
119 // the document's content blocking log.
120 readonly attribute unsigned long contentBlockingEvents;
122 // String containing serialized content blocking log.
123 readonly attribute DOMString contentBlockingLog;
125 // DOM Process which this window was loaded in. Will be either InProcessParent
126 // for windows loaded in the parent process, or ContentParent for windows
127 // loaded in the content process.
128 readonly attribute nsIDOMProcessParent? domProcess;
130 static WindowGlobalParent? getByInnerWindowId(unsigned long long innerWindowId);
133 * Get or create the JSWindowActor with the given name.
135 * See WindowActorOptions from JSWindowActor.webidl for details on how to
136 * customize actor creation.
139 JSWindowActorParent getActor(UTF8String name);
140 JSWindowActorParent? getExistingActor(UTF8String name);
143 * Renders a region of the frame into an image bitmap.
145 * @param rect Specify the area of the document to render, in CSS pixels,
146 * relative to the page. If null, the currently visible viewport is rendered.
147 * @param scale The scale to render the window at. Use devicePixelRatio
148 * to have comparable rendering to the OS.
149 * @param backgroundColor The background color to use.
150 * @param resetScrollPosition If true, temporarily resets the scroll position
151 * of the root scroll frame to 0, such that position:fixed elements are drawn
152 * at their initial position. This parameter only takes effect when passing a
155 * This API can only be used in the parent process, as content processes
156 * cannot access the rendering of out of process iframes. This API works
157 * with remote and local frames.
160 Promise<ImageBitmap> drawSnapshot(DOMRect? rect,
162 UTF8String backgroundColor,
163 optional boolean resetScrollPosition = false);
165 // True if any of the windows in the subtree rooted at this window
166 // has active peer connections. If this is called for a non-top-level
167 // context, it always returns false.
168 boolean hasActivePeerConnections();
171 [Exposed=Window, ChromeOnly]
172 interface WindowGlobalChild {
173 readonly attribute boolean isClosed;
174 readonly attribute boolean isInProcess;
175 readonly attribute BrowsingContext browsingContext;
176 readonly attribute WindowContext windowContext;
178 readonly attribute boolean isCurrentGlobal;
180 readonly attribute unsigned long long innerWindowId;
181 readonly attribute unsigned long long outerWindowId;
182 readonly attribute unsigned long long contentParentId;
184 // A WindowGlobalChild is the root in its process if it has no parent, or its
185 // embedder is in a different process.
186 readonly attribute boolean isProcessRoot;
188 // Is this WindowGlobalChild same-origin with `window.top`?
189 readonly attribute boolean sameOriginWithTop;
191 readonly attribute WindowGlobalParent? parentActor; // in-process only
193 static WindowGlobalChild? getByInnerWindowId(unsigned long long innerWIndowId);
195 BrowsingContext? findBrowsingContextWithName(DOMString name);
198 * Get or create the JSWindowActor with the given name.
200 * See WindowActorOptions from JSWindowActor.webidl for details on how to
201 * customize actor creation.
204 JSWindowActorChild getActor(UTF8String name);
205 JSWindowActorChild? getExistingActor(UTF8String name);