diff options
Diffstat (limited to '')
55 files changed, 8104 insertions, 0 deletions
diff --git a/dom/chrome-webidl/BrowserSessionStore.webidl b/dom/chrome-webidl/BrowserSessionStore.webidl new file mode 100644 index 0000000000..23d3df9457 --- /dev/null +++ b/dom/chrome-webidl/BrowserSessionStore.webidl @@ -0,0 +1,59 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// object contains either a CollectedFileListValue or a CollectedNonMultipleSelectValue or Sequence<DOMString> +typedef (DOMString or boolean or object) FormDataValue; + +[ChromeOnly, Exposed=Window] +interface SessionStoreFormData { + [Cached, Pure] + readonly attribute ByteString? url; + + [Cached, Pure] + readonly attribute record<DOMString, FormDataValue>? id; + + [Cached, Pure] + readonly attribute record<DOMString, FormDataValue>? xpath; + + [Cached, Pure] + readonly attribute DOMString? innerHTML; + + [Cached, Frozen, Pure] + readonly attribute sequence<SessionStoreFormData?>? children; + + object toJSON(); +}; + +[GenerateConversionToJS] +dictionary SessionStoreDisplaySize { + unsigned long width; + unsigned long height; +}; + +[GenerateConversionToJS] +dictionary SessionStoreZoomData { + double resolution; + SessionStoreDisplaySize displaySize; +}; + +[ChromeOnly, Exposed=Window] +interface SessionStoreScrollData { + [Cached, Pure] + readonly attribute ByteString? scroll; + + [Cached, Pure] + readonly attribute sequence<SessionStoreScrollData?>? children; + + object toJSON(); +}; + +[GenerateConversionToJS] +dictionary UpdateSessionStoreData { + // This is docshell caps, but on-disk format uses the disallow property name. + ByteString? disallow; + boolean isPrivate; + SessionStoreFormData? formdata; + SessionStoreScrollData? scroll; +}; diff --git a/dom/chrome-webidl/BrowsingContext.webidl b/dom/chrome-webidl/BrowsingContext.webidl new file mode 100644 index 0000000000..590ad9e2fd --- /dev/null +++ b/dom/chrome-webidl/BrowsingContext.webidl @@ -0,0 +1,394 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +interface URI; +interface nsIDocShell; +interface nsISecureBrowserUI; +interface nsIPrintSettings; +interface nsIWebProgress; + +interface mixin LoadContextMixin { + readonly attribute WindowProxy? associatedWindow; + + readonly attribute WindowProxy? topWindow; + + readonly attribute Element? topFrameElement; + + readonly attribute boolean isContent; + + [SetterThrows] + attribute boolean usePrivateBrowsing; + + readonly attribute boolean useRemoteTabs; + + readonly attribute boolean useRemoteSubframes; + + [BinaryName="useTrackingProtectionWebIDL", SetterThrows] + attribute boolean useTrackingProtection; + + [NewObject, Throws] + readonly attribute any originAttributes; +}; + +/** + * Allowed CSS display modes. This needs to be kept in + * sync with similar values in ServoStyleConsts.h + */ +enum DisplayMode { + "browser", + "minimal-ui", + "standalone", + "fullscreen", +}; + +/** + * CSS prefers-color-scheme values. + */ +enum PrefersColorSchemeOverride { + "none", + "light", + "dark", +}; + +/** + * Allowed overrides of platform/pref default behaviour for touch events. + */ +enum TouchEventsOverride { + "disabled", // Force-disable touch events. + "enabled", // Force-enable touch events. + "none", // Don't override behaviour for touch events. +}; + +[Exposed=Window, ChromeOnly] +interface BrowsingContext { + static BrowsingContext? get(unsigned long long aId); + + static BrowsingContext? getFromWindow(WindowProxy window); + + static BrowsingContext? getCurrentTopByBrowserId(unsigned long long aId); + + sequence<BrowsingContext> getAllBrowsingContextsInSubtree(); + + BrowsingContext? findChildWithName(DOMString name, BrowsingContext accessor); + BrowsingContext? findWithName(DOMString name); + + readonly attribute DOMString name; + + readonly attribute BrowsingContext? parent; + + readonly attribute BrowsingContext top; + + [Cached, Frozen, Pure] + readonly attribute sequence<BrowsingContext> children; + + readonly attribute nsIDocShell? docShell; + + readonly attribute Element? embedderElement; + + readonly attribute unsigned long long id; + + readonly attribute BrowsingContext? opener; + + readonly attribute BrowsingContextGroup group; + + readonly attribute WindowProxy? window; + + readonly attribute WindowContext? currentWindowContext; + + readonly attribute WindowContext? parentWindowContext; + + readonly attribute WindowContext? topWindowContext; + + readonly attribute boolean ancestorsAreCurrent; + + [SetterThrows] attribute [LegacyNullToEmptyString] DOMString customPlatform; + + [SetterThrows] attribute [LegacyNullToEmptyString] DOMString customUserAgent; + + readonly attribute DOMString embedderElementType; + + readonly attribute boolean createdDynamically; + + readonly attribute boolean isInBFCache; + + readonly attribute boolean isDiscarded; + + /** + * The sandbox flags on the browsing context. These reflect the value of the + * sandbox attribute of the associated IFRAME or CSP-protectable content, if + * existent. See the HTML5 spec for more details. + * These flags on the browsing context reflect the current state of the + * sandbox attribute, which is modifiable. They are only used when loading new + * content, sandbox flags are also immutably set on the document when it is + * loaded. + * The sandbox flags of a document depend on the sandbox flags on its + * browsing context and of its parent document, if any. + * See nsSandboxFlags.h for the possible flags. + */ + [SetterThrows] attribute unsigned long sandboxFlags; + + [SetterThrows] attribute boolean isActive; + + // The inRDMPane flag indicates whether or not Responsive Design Mode is + // active for the browsing context. + [SetterThrows] attribute boolean inRDMPane; + + [SetterThrows] attribute float fullZoom; + + [SetterThrows] attribute float textZoom; + + // Override the dots-per-CSS-pixel scaling factor in this BrowsingContext + // and all of its descendants. May only be set on the top BC, and should + // only be set from the parent process. + // + // A value of 0.0 causes us to use the global default scaling factor. + // + // NOTE that this override only affects a few minor things (the value exposed + // to devicePixelRatio and some media queries in content, and responsive + // image selection). Most notably, it does _not_ affect rendering. + // + // It is intended for RDM, and is probably not what you want in other cases. + // If you want to change the actual device pixel ratio that rendering code + // uses, you probably want to change the fullZoom. + [SetterThrows] attribute float overrideDPPX; + + [SetterThrows] attribute boolean suspendMediaWhenInactive; + + // Default value for nsIContentViewer::authorStyleDisabled in any new + // browsing contexts created as a descendant of this one. + // + // Valid only for top browsing contexts. + [SetterThrows] attribute boolean authorStyleDisabledDefault; + + /** + * Whether this docshell should save entries in global history. + */ + [SetterThrows] attribute boolean useGlobalHistory; + + // Extension to give chrome JS the ability to set the window screen + // orientation while in RDM. + [Throws] undefined setRDMPaneOrientation(OrientationType type, float rotationAngle); + + // Extension to give chrome JS the ability to set a maxTouchPoints override + // while in RDM. + [Throws] undefined setRDMPaneMaxTouchPoints(octet maxTouchPoints); + + // The watchedByDevTools flag indicates whether or not DevTools are currently + // debugging this browsing context. + [SetterThrows] attribute boolean watchedByDevTools; + + // Enable some service workers testing features, for DevTools. + [SetterThrows] attribute boolean serviceWorkersTestingEnabled; + + // Enable media query medium override, for DevTools. + [SetterThrows] attribute DOMString mediumOverride; + + // Color-scheme simulation, for DevTools. + [SetterThrows] attribute PrefersColorSchemeOverride prefersColorSchemeOverride; + + /** + * A unique identifier for the browser element that is hosting this + * BrowsingContext tree. Every BrowsingContext in the element's tree will + * return the same ID in all processes and it will remain stable regardless of + * process changes. When a browser element's frameloader is switched to + * another browser element this ID will remain the same but hosted under the + * under the new browser element. + */ + [SetterThrows] attribute unsigned long long browserId; + + [SetterThrows] attribute DisplayMode displayMode; + + /** + * This allows chrome to override the default choice of whether touch events + * are available in a specific BrowsingContext and its descendents. + */ + readonly attribute TouchEventsOverride touchEventsOverride; + + /** + * Returns true if the top-level BrowsingContext has been configured to + * default-target user-initiated link clicks to _blank. + */ + readonly attribute boolean targetTopLevelLinkClicksToBlank; + + /** + * Partially determines whether script execution is allowed in this + * BrowsingContext. Script execution will be permitted only if this + * attribute is true and script execution is allowed in the parent + * WindowContext. + * + * May only be set in the parent process. + */ + [SetterThrows] attribute boolean allowJavascript; + + /** + * Determines whether we're forcing a desktop-mode viewport. Only settable in + * the top browsing context from the parent process. + */ + [SetterThrows] attribute boolean forceDesktopViewport; + + /* + * Default load flags (as defined in nsIRequest) that will be set on all + * requests made by this BrowsingContext. + */ + [SetterThrows] attribute long defaultLoadFlags; + + /** + * The nsID of the browsing context in the session history. + */ + [NewObject, Throws] + readonly attribute any historyID; + + readonly attribute ChildSHistory? childSessionHistory; + + // Resets the location change rate limit. Used for testing. + undefined resetLocationChangeRateLimit(); + + readonly attribute long childOffset; +}; + +BrowsingContext includes LoadContextMixin; + +[Exposed=Window, ChromeOnly] +interface CanonicalBrowsingContext : BrowsingContext { + sequence<WindowGlobalParent> getWindowGlobals(); + + readonly attribute WindowGlobalParent? currentWindowGlobal; + + readonly attribute WindowProxy? topChromeWindow; + + // XXX(nika): This feels kinda hacky, but will do for now while we don't + // synchronously create WindowGlobalParent. It can throw if somehow the + // content process has died. + [Throws] + readonly attribute UTF8String? currentRemoteType; + + readonly attribute WindowGlobalParent? embedderWindowGlobal; + + undefined notifyStartDelayedAutoplayMedia(); + [Throws] undefined notifyMediaMutedChanged(boolean muted); + + readonly attribute nsISecureBrowserUI? secureBrowserUI; + + /** + * Returns an nsIWebProgress object for this BrowsingContext, if this + * is a top-level content BC. + * + * Progress listeners attached to this will get notifications filtered by + * nsBrowserStatusFilter, and don't get any notifications from sub frames. + */ + readonly attribute nsIWebProgress? webProgress; + + static unsigned long countSiteOrigins(sequence<BrowsingContext> roots); + + /** + * Loads a given URI. This will give priority to loading the requested URI + * in the object implementing this interface. If it can't be loaded here + * however, the URI dispatcher will go through its normal process of content + * loading. + * + * @param aURI + * The URI string to load. For HTTP and FTP URLs and possibly others, + * characters above U+007F will be converted to UTF-8 and then URL- + * escaped per the rules of RFC 2396. + * @param aLoadURIOptions + * A JSObject defined in LoadURIOptions.webidl holding info like e.g. + * the triggeringPrincipal, the referrer info. + */ + [Throws] + undefined loadURI(DOMString aURI, optional LoadURIOptions aOptions = {}); + + /** + * Print the current document. + * + * @param aOuterWindowID the ID of the outer window to print + * @param aPrintSettings print settings to use; printSilent can be + * set to prevent prompting. + * @return A Promise that resolves once printing is finished. + */ + [NewObject, BinaryName="printJS"] + Promise<undefined> print(nsIPrintSettings aPrintSettings); + + /** + * These methods implement the nsIWebNavigation methods of the same names + */ + undefined goBack(optional long aCancelContentJSEpoch, optional boolean aRequireUserInteraction = false, optional boolean aUserActivation = false); + undefined goForward(optional long aCancelContentJSEpoch, optional boolean aRequireUserInteraction = false, optional boolean aUserActivation = false); + undefined goToIndex(long aIndex, optional long aCancelContentJSEpoch, optional boolean aUserActivation = false); + undefined reload(unsigned long aReloadFlags); + undefined stop(unsigned long aStopFlags); + + readonly attribute nsISHistory? sessionHistory; + + readonly attribute MediaController? mediaController; + + undefined resetScalingZoom(); + + // The current URI loaded in this BrowsingContext according to nsDocShell. + // This may not match the current window global's document URI in some cases. + readonly attribute URI? currentURI; + + undefined clearRestoreState(); + + // Force this browsing context, which must correspond to an app window, to + // be active regardless of the window being minimized or fully occluded. + [SetterThrows] attribute boolean forceAppWindowActive; + + /** + * This allows chrome to override the default choice of whether touch events + * are available in a specific BrowsingContext and its descendents. + */ + [SetterThrows] inherit attribute TouchEventsOverride touchEventsOverride; + + /** + * Set to true to configure the top-level BrowsingContext to default-target + * user-initiated link clicks to _blank. + */ + [SetterThrows] inherit attribute boolean targetTopLevelLinkClicksToBlank; + + /** + * Set the cross-group opener of this BrowsingContext. This is used to + * retarget the download dialog to an opener window, and close this + * BrowsingContext, if the first load in a newly created BrowsingContext is a + * download. + * + * This value will be automatically set for documents created using + * `window.open`. + */ + [Throws] + undefined setCrossGroupOpener(CanonicalBrowsingContext crossGroupOpener); + + readonly attribute boolean isReplaced; + + + /** + * Notify APZ to start autoscrolling. + * + * (aAnchorX, aAnchorY) are the coordinates of the autoscroll anchor, in + * device coordinates relative to the screen. + * aScrollId and aPresShellId identify the scroll frame that content chose to + * scroll. + * + * Returns whether we were successfully able to notify APZ. + * If this function returns true, APZ (which may live in another process) may + * still reject the autoscroll, but it's then APZ's responsibility to notify + * content via an "autoscroll-rejected-by-apz" message. + */ + boolean startApzAutoscroll(float aAnchorX, float aAnchorY, + unsigned long long aScrollId, + unsigned long aPresShellId); + + /** + * Notify APZ to stop autoscrolling. + */ + undefined stopApzAutoscroll(unsigned long long aScrollId, + unsigned long aPresShellId); +}; + +[Exposed=Window, ChromeOnly] +interface BrowsingContextGroup { + sequence<BrowsingContext> getToplevels(); + + readonly attribute unsigned long long id; +}; diff --git a/dom/chrome-webidl/ChannelWrapper.webidl b/dom/chrome-webidl/ChannelWrapper.webidl new file mode 100644 index 0000000000..b932e79c76 --- /dev/null +++ b/dom/chrome-webidl/ChannelWrapper.webidl @@ -0,0 +1,578 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +interface LoadInfo; +interface MozChannel; +interface RemoteTab; +interface URI; +interface nsISupports; + +/** + * Load types that correspond to the external types in nsIContentPolicy.idl. + * Please also update that IDL when updating this list. + */ +enum MozContentPolicyType { + "main_frame", + "sub_frame", + "stylesheet", + "script", + "image", + "object", + "object_subrequest", + "xmlhttprequest", + "fetch", + "xslt", + "ping", + "beacon", + "xml_dtd", + "font", + "media", + "websocket", + "csp_report", + "imageset", + "web_manifest", + "speculative", + "other" +}; + +/** + * String versions of CLASSIFIED_* tracking flags from nsIClassifiedChannel.idl + */ +enum MozUrlClassificationFlags { + "fingerprinting", + "fingerprinting_content", + "cryptomining", + "cryptomining_content", + "emailtracking", + "emailtracking_content", + "tracking", + "tracking_ad", + "tracking_analytics", + "tracking_social", + "tracking_content", + "socialtracking", + "socialtracking_facebook", + "socialtracking_linkedin", + "socialtracking_twitter", + "any_basic_tracking", + "any_strict_tracking", + "any_social_tracking" +}; + +/** + * A thin wrapper around nsIChannel and nsIHttpChannel that allows JS + * callers to access them without XPConnect overhead. + */ +[ChromeOnly, Exposed=Window] +interface ChannelWrapper : EventTarget { + /** + * Returns the wrapper instance for the given channel. The same wrapper is + * always returned for a given channel. + */ + static ChannelWrapper get(MozChannel channel); + + /** + * Returns the wrapper instance for the given channel. The same wrapper is + * always returned for a given channel. + */ + static ChannelWrapper? getRegisteredChannel(unsigned long long aChannelId, + WebExtensionPolicy extension, + RemoteTab? remoteTab); + + /** + * A unique ID for for the requests which remains constant throughout the + * redirect chain. + */ + [Constant, StoreInSlot] + readonly attribute unsigned long long id; + + // Not technically pure, since it's backed by a weak reference, but if JS + // has a reference to the previous value, we can depend on it not being + // collected. + [Pure] + attribute MozChannel? channel; + + + /** + * Cancels the request with the given nsresult status code. + * + * The optional reason parameter should be one of the BLOCKING_REASON + * constants from nsILoadInfo.idl + */ + [Throws] + undefined cancel(unsigned long result, optional unsigned long reason = 0); + + /** + * Redirects the wrapped HTTP channel to the given URI. For other channel + * types, this method will throw. The redirect is an internal redirect, and + * the behavior is the same as nsIHttpChannel.redirectTo. + */ + [Throws] + undefined redirectTo(URI url); + + /** + * Requests an upgrade of the HTTP channel to a secure request. For other channel + * types, this method will throw. The redirect is an internal redirect, and + * the behavior is the same as nsIHttpChannel.upgradeToSecure. Setting this + * flag is only effective during the WebRequest.onBeforeRequest in + * Web Extensions, calling this at any other point during the request will + * have no effect. Setting this flag in addition to calling redirectTo + * results in the redirect happening rather than the upgrade request. + */ + [Throws] + undefined upgradeToSecure(); + + /** + * Suspends the underlying channel. The profilerText parameter is only used + * to annotate profiles. + */ + [Throws] + undefined suspend(ByteString profileMarkerText); + + /** + * Resumes (un-suspends) the underlying channel. + */ + [Throws] + undefined resume(); + + /** + * The content type of the request, usually as read from the Content-Type + * header. This should be used in preference to the header to determine the + * content type of the channel. + */ + [Pure] + attribute ByteString contentType; + + + /** + * For HTTP requests, the request method (e.g., GET, POST, HEAD). For other + * request types, returns an empty string. + */ + [Cached, Pure] + readonly attribute ByteString method; + + /** + * For requests with LoadInfo, the content policy type that corresponds to + * the request. For requests without LoadInfo, returns "other". + */ + [Cached, Pure] + readonly attribute MozContentPolicyType type; + + + /** + * When true, the request is currently suspended by the wrapper. When false, + * the request is not suspended by the wrapper, but may still be suspended + * by another caller. + */ + [Pure] + readonly attribute boolean suspended; + + + /** + * The final URI of the channel (as returned by NS_GetFinalChannelURI) after + * any redirects have been processed. + */ + [Cached, Pure] + readonly attribute URI finalURI; + + /** + * The string version of finalURI (but cheaper to access than + * finalURI.spec). + */ + [Cached, Pure] + readonly attribute DOMString finalURL; + + + /** + * Returns true if the request matches the given request filter, and the + * given extension has permission to access it. + */ + boolean matches(optional MozRequestFilter filter = {}, + optional WebExtensionPolicy? extension = null, + optional MozRequestMatchOptions options = {}); + + + /** + * Register's this channel as traceable by the given add-on when accessed + * via the process of the given RemoteTab. + */ + undefined registerTraceableChannel(WebExtensionPolicy extension, RemoteTab? remoteTab); + + /** + * The current HTTP status code of the request. This will be 0 if a response + * has not yet been received, or if the request is not an HTTP request. + */ + [Cached, Pure] + readonly attribute unsigned long statusCode; + + /** + * The HTTP status line for the request (e.g., "HTTP/1.0 200 Success"). This + * will be an empty string if a response has not yet been received, or if + * the request is not an HTTP request. + */ + [Cached, Pure] + readonly attribute ByteString statusLine; + + + /** + * If the request has failed or been canceled, an opaque string representing + * the error. For requests that failed at the NSS layer, this is an NSS + * error message. For requests that failed for any other reason, it is the + * name of an nsresult error code. For requests which haven't failed, this + * is null. + * + * This string is used in the error message when notifying extension + * webRequest listeners of failure. The documentation specifically states + * that this value MUST NOT be parsed, and is only meant to be displayed to + * humans, but we all know how that works in real life. + */ + [Cached, Pure] + readonly attribute DOMString? errorString; + + /** + * Dispatched when the channel is closed with an error status. Check + * errorString for the error details. + */ + attribute EventHandler onerror; + + /** + * Checks the request's current status and dispatches an error event if the + * request has failed and one has not already been dispatched. + */ + undefined errorCheck(); + + + /** + * Dispatched when the channel begins receiving data. + */ + attribute EventHandler onstart; + + /** + * Dispatched when the channel has finished receiving data. + */ + attribute EventHandler onstop; + + + /** + * Information about the proxy server which is handling this request, or + * null if the request is not proxied. + */ + [Cached, Frozen, GetterThrows, Pure] + readonly attribute MozProxyInfo? proxyInfo; + + /** + * For HTTP requests, the IP address of the remote server handling the + * request. For other request types, returns null. + */ + [Cached, Pure] + readonly attribute ByteString? remoteAddress; + + + /** + * The LoadInfo object for this channel, if available. Null for channels + * without load info, until support for those is removed. + */ + [Cached, Pure] + readonly attribute LoadInfo? loadInfo; + + /** + * True if this load for a service worker script (either a main script or import scripts). + */ + [Cached, Pure] + readonly attribute boolean isServiceWorkerScript; + + /** + * True if this load was triggered by a system caller. This currently always + * false if the request has no LoadInfo or is a top-level document load. + */ + [Cached, Pure] + readonly attribute boolean isSystemLoad; + + /** + * The URL of the principal that triggered this load. This is equivalent to + * the LoadInfo's triggeringPrincipal, and will only ever be null for + * requests without LoadInfo. + */ + [Cached, Pure] + readonly attribute ByteString? originURL; + + /** + * The URL of the document loading the content for this request. This is + * equivalent to the LoadInfo's loadingPrincipal. This may only ever be null + * for top-level requests and requests without LoadInfo. + */ + [Cached, Pure] + readonly attribute ByteString? documentURL; + + /** + * The URI version of originURL. Will be null only when originURL is null. + */ + [Pure] + readonly attribute URI? originURI; + + /** + * The URI version of documentURL. Will be null only when documentURL is + * null. + */ + [Pure] + readonly attribute URI? documentURI; + + + /** + * True if extensions may modify this request. This is currently false only + * if the request belongs to a document which has access to the + * mozAddonManager API. + */ + [Cached, GetterThrows, Pure] + readonly attribute boolean canModify; + + + /** + * The BrowsingContext ID of the frame that the request belongs to, or 0 if it + * is a top-level load or does not belong to a document. + */ + [Cached, Constant] + readonly attribute long long frameId; + + /** + * The BrowsingContext ID of the parent frame of the window that the request + * belongs to, 0 if that parent frame is the top-level frame, and -1 if the + * request belongs to a top-level frame. + */ + [Cached, Constant] + readonly attribute long long parentFrameId; + + /** + * For cross-process requests, the <browser> or <iframe> element to which the + * content loading this request belongs. For requests that don't originate + * from a remote browser, this is null. + * + * This is not an Element because those are by default only exposed in + * Window, but we're exposed in System. + */ + [Cached, Pure] + readonly attribute nsISupports? browserElement; + + /** + * Returns an array of objects that combine the url and frameId from the + * ancestorPrincipals and ancestorOuterWindowIDs on loadInfo. + * The immediate parent is the first entry, the last entry is always the top + * level frame. It will be an empty list for toplevel window loads and + * non-subdocument resource loads within a toplevel window. For the latter, + * originURL will provide information on what window is doing the load. It + * will be null if the request is not associated with a window (e.g. XHR with + * mozBackgroundRequest = true). + */ + [Cached, Frozen, GetterThrows, Pure] + readonly attribute sequence<MozFrameAncestorInfo>? frameAncestors; + + /** + * For HTTP requests, returns an array of request headers which will be, or + * have been, sent with this request. + * + * For non-HTTP requests, throws NS_ERROR_UNEXPECTED. + */ + [Throws] + sequence<MozHTTPHeader> getRequestHeaders(); + + /** + * For HTTP requests: returns the value of the request header, null if not set. + * + * For non-HTTP requests, throws NS_ERROR_UNEXPECTED. + */ + [Throws] + ByteString? getRequestHeader(ByteString header); + + /** + * For HTTP requests, returns an array of response headers which were + * received for this request, in the same format as returned by + * getRequestHeaders. + + * Throws NS_ERROR_NOT_AVAILABLE if a response has not yet been received, or + * NS_ERROR_UNEXPECTED if the channel is not an HTTP channel. + * + * Note: The Content-Type header is handled specially. That header is + * usually not mutable after the request has been received, and the content + * type must instead be changed via the contentType attribute. If a caller + * attempts to set the Content-Type header via setRequestHeader, however, + * that value is assigned to the contentType attribute and its original + * string value is cached. That original value is returned in place of the + * actual Content-Type header. + */ + [Throws] + sequence<MozHTTPHeader> getResponseHeaders(); + + /** + * Sets the given request header to the given value, overwriting any + * previous value. Setting a header to a null string has the effect of + * removing it. If merge is true, then the passed value will be merged + * to any existing value that exists for the header. Otherwise, any prior + * value for the header will be overwritten. Merge is ignored for headers + * that cannot be merged. + * + * For non-HTTP requests, throws NS_ERROR_UNEXPECTED. + */ + [Throws] + undefined setRequestHeader(ByteString header, + ByteString value, + optional boolean merge = false); + + /** + * Sets the given response header to the given value, overwriting any + * previous value. Setting a header to a null string has the effect of + * removing it. If merge is true, then the passed value will be merged + * to any existing value that exists for the header (e.g. handling multiple + * Set-Cookie headers). Otherwise, any prior value for the header will be + * overwritten. Merge is ignored for headers that cannot be merged. + * + * For non-HTTP requests, throws NS_ERROR_UNEXPECTED. + * + * Note: The content type header is handled specially by this function. See + * getResponseHeaders() for details. + */ + [Throws] + undefined setResponseHeader(ByteString header, + ByteString value, + optional boolean merge = false); + + /** + * Provides the tracking classification data when it is available. + */ + [Cached, Frozen, GetterThrows, Pure] + readonly attribute MozUrlClassification? urlClassification; + + /** + * Indicates if this response and its content window hierarchy is third + * party. + */ + [Cached, Constant] + readonly attribute boolean thirdParty; + + /** + * The current bytes sent of the request. This will be 0 if a request has not + * sent yet, or if the request is not an HTTP request. + */ + [Cached, Pure] + readonly attribute unsigned long long requestSize; + + /** + * The current bytes received of the response. This will be 0 if a response + * has not recieved yet, or if the request is not an HTTP response. + */ + [Cached, Pure] + readonly attribute unsigned long long responseSize; +}; + +/** + * Wrapper for first and third party tracking classification data. + */ +dictionary MozUrlClassification { + required sequence<MozUrlClassificationFlags> firstParty; + required sequence<MozUrlClassificationFlags> thirdParty; +}; + +/** + * Information about the proxy server handing a request. This is approximately + * equivalent to nsIProxyInfo. + */ +dictionary MozProxyInfo { + /** + * The hostname of the server. + */ + required ByteString host; + /** + * The TCP port of the server. + */ + required long port; + /** + * The type of proxy (e.g., HTTP, SOCKS). + */ + required ByteString type; + + /** + * True if the proxy is responsible for DNS lookups. + */ + required boolean proxyDNS; + + /** + * The authentication username for the proxy, if any. + */ + ByteString? username = null; + + /** + * The timeout, in seconds, before the network stack will failover to the + * next candidate proxy server if it has not received a response. + */ + unsigned long failoverTimeout; + + /** + * Any non-empty value will be passed directly as Proxy-Authorization header + * value for the CONNECT request attempt. However, this header set on the + * resource request itself takes precedence. + */ + ByteString? proxyAuthorizationHeader = null; + + /** + * An optional key used for additional isolation of this proxy connection. + */ + ByteString? connectionIsolationKey = null; +}; + +/** + * MozFrameAncestorInfo combines loadInfo::AncestorPrincipals with + * loadInfo::AncestorOuterWindowIDs for easier access in the WebRequest API. + * + * url represents the parent of the loading window. + * frameId is the outerWindowID for the parent of the loading window. + * + * For further details see nsILoadInfo.idl and Document::AncestorPrincipals. + */ +dictionary MozFrameAncestorInfo { + required ByteString url; + required unsigned long long frameId; +}; + +/** + * Represents an HTTP request or response header. + */ +dictionary MozHTTPHeader { + /** + * The case-insensitive, non-case-normalized header name. + */ + required ByteString name; + /** + * The header value. + */ + required ByteString value; +}; + +/** + * An object used for filtering requests. + */ +dictionary MozRequestFilter { + /** + * If present, the request only matches if its `type` attribute matches one + * of the given types. + */ + sequence<MozContentPolicyType>? types = null; + + /** + * If present, the request only matches if its finalURI matches the given + * match pattern set. + */ + MatchPatternSet? urls = null; + + /** + * If present, the request only matches if the loadInfo privateBrowsingId matches + * against the given incognito value. + */ + boolean? incognito = null; +}; + +dictionary MozRequestMatchOptions { + /** + * True if we're matching for the proxy portion of a proxied request. + */ + boolean isProxy = false; +}; diff --git a/dom/chrome-webidl/ChromeUtils.webidl b/dom/chrome-webidl/ChromeUtils.webidl new file mode 100644 index 0000000000..f8f0b02ee7 --- /dev/null +++ b/dom/chrome-webidl/ChromeUtils.webidl @@ -0,0 +1,1009 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +interface nsIDOMProcessChild; +interface nsIDOMProcessParent; +interface Principal; + +/** + * An optimized QueryInterface method, generated by generateQI. + * + * For JS callers, this behaves like a normal QueryInterface function. When + * called with a supported interface, it returns its `this` object. When + * called with an unsupported interface, it throws NS_ERROR_NO_INTERFACE. + * + * C++ callers use a fast path, and never call the JSAPI or WebIDL methods of + * this object. + */ +[ChromeOnly, Exposed=Window] +interface MozQueryInterface { + [Throws] + legacycaller any (any aIID); +}; + +/** + * Options for a marker created with the addProfilerMarker method. + * All fields are optional. + */ +dictionary ProfilerMarkerOptions { + // A timestamp to use as the start time of the marker. + // If no start time is provided, the marker will have no duration. + // In window and ChromeWorker contexts, use a timestamp from + // `performance.now()`. + // In JS modules, use `Cu.now()` to get a timestamp. + DOMHighResTimeStamp startTime = 0; + + // If captureStack is true, a profiler stack will be captured and associated + // with the marker. + boolean captureStack = false; + + // Markers are created by default in the JavaScript category, but this can be + // overridden. + // Examples of correct values: "JavaScript", "Test", "Other", ... + // See ProfilingCategoryList.h for the complete list of valid values. + // Using an unrecognized value will set the category to "Other". + ByteString category = "JavaScript"; + + // Inner window ID to use for the marker. If the global object is a window, + // the inner window id of the marker will be set automatically. + // If a marker that relates to a specific window is added from a JS module, + // setting the inner window id will allow the profiler to show which window + // the marker applies to. + unsigned long long innerWindowId = 0; +}; + +dictionary InteractionData { + unsigned long interactionCount = 0; + unsigned long interactionTimeInMilliseconds = 0; + unsigned long scrollingDistanceInPixels = 0; +}; + +/** + * Confidence value of credit card fields. This is used by the native + * Fathom Credit Card model to return the score to JS. + */ +dictionary FormAutofillConfidences { + double ccNumber = 0; + double ccName = 0; +}; + +/** + * A collection of static utility methods that are only exposed to system code. + * This is exposed in all the system globals where we can expose stuff by + * default, so should only include methods that are **thread-safe**. + */ +[ChromeOnly, Exposed=(Window,Worker)] +namespace ChromeUtils { + /** + * Get the |NodeId| for the given JS Object. + * |NodeId| is the identifier of |JS::ubi::Node|. + */ + NodeId getObjectNodeId(object obj); + + /** + * Serialize a snapshot of the heap graph, as seen by |JS::ubi::Node| and + * restricted by |boundaries|, and write it to the provided file path. + * + * @param boundaries The portion of the heap graph to write. + * + * @returns The path to the file the heap snapshot was written + * to. This is guaranteed to be within the temp + * directory and its file name will match the regexp + * `\d+(\-\d+)?\.fxsnapshot`. + */ + [Throws] + DOMString saveHeapSnapshot(optional HeapSnapshotBoundaries boundaries = {}); + + /** + * This is the same as saveHeapSnapshot, but with a different return value. + * + * @returns The snapshot ID of the file. This is the file name + * without the temp directory or the trailing + * `.fxsnapshot`. + */ + [Throws] + DOMString saveHeapSnapshotGetId(optional HeapSnapshotBoundaries boundaries = {}); + + /** + * Deserialize a core dump into a HeapSnapshot. + * + * @param filePath The file path to read the heap snapshot from. + */ + [Throws, NewObject] + HeapSnapshot readHeapSnapshot(DOMString filePath); + + /** + * Return the keys in a weak map. This operation is + * non-deterministic because it is affected by the scheduling of the + * garbage collector and the cycle collector. + * + * @param aMap weak map or other JavaScript value + * @returns If aMap is a weak map object, return the keys of the weak + * map as an array. Otherwise, return undefined. + */ + [Throws, NewObject] + any nondeterministicGetWeakMapKeys(any map); + + /** + * Return the keys in a weak set. This operation is + * non-deterministic because it is affected by the scheduling of the + * garbage collector and the cycle collector. + * + * @param aSet weak set or other JavaScript value + * @returns If aSet is a weak set object, return the keys of the weak + * set as an array. Otherwise, return undefined. + */ + [Throws, NewObject] + any nondeterministicGetWeakSetKeys(any aSet); + + /** + * Converts a buffer to a Base64 URL-encoded string per RFC 4648. + * + * @param source The buffer to encode. + * @param options Additional encoding options. + * @returns The encoded string. + */ + [Throws] + ByteString base64URLEncode(BufferSource source, + Base64URLEncodeOptions options); + + /** + * Decodes a Base64 URL-encoded string per RFC 4648. + * + * @param string The string to decode. + * @param options Additional decoding options. + * @returns The decoded buffer. + */ + [Throws, NewObject] + ArrayBuffer base64URLDecode(ByteString string, + Base64URLDecodeOptions options); + + /** + * Cause the current process to fatally crash unless the given condition is + * true. This is similar to MOZ_RELEASE_ASSERT in C++ code. + * + * WARNING: This message is included publicly in the crash report, and must + * not contain private information. + * + * Crash report will be augmented with the current JS stack information. + */ + undefined releaseAssert(boolean condition, + optional DOMString message = "<no message>"); + +#ifdef NIGHTLY_BUILD + + /** + * If the chrome code has thrown a JavaScript Dev Error + * in the current JSRuntime. the first such error, or `undefined` + * otherwise. + * + * A JavaScript Dev Error is an exception thrown by JavaScript + * code that matches both conditions: + * - it was thrown by chrome code; + * - it is either a `ReferenceError`, a `TypeError` or a `SyntaxError`. + * + * Such errors are stored regardless of whether they have been + * caught. + * + * This mechanism is designed to help ensure that the code of + * Firefox is free from Dev Errors, even if they are accidentally + * caught by clients. + * + * The object returned is not an exception. It has fields: + * - DOMString stack + * - DOMString filename + * - DOMString lineNumber + * - DOMString message + */ + [Throws] + readonly attribute any recentJSDevError; + + /** + * Reset `recentJSDevError` to `undefined` for the current JSRuntime. + */ + undefined clearRecentJSDevError(); +#endif // NIGHTLY_BUILD + + /** + * Clears the stylesheet cache by baseDomain. This includes associated + * state-partitioned cache. + */ + undefined clearStyleSheetCacheByBaseDomain(UTF8String baseDomain); + + /** + * Clears the stylesheet cache by principal. + */ + undefined clearStyleSheetCacheByPrincipal(Principal principal); + + /** + * Clears the entire stylesheet cache. + */ + undefined clearStyleSheetCache(); + + /** + * If the profiler is currently running and recording the current thread, + * add a marker for the current thread. No-op otherwise. + * + * @param name The name of the marker. + * @param options Either a timestamp to use as the start time of the + * marker, or a ProfilerMarkerOptions object that can + * contain startTime, captureStack or category fields. + * If this parameter is omitted, the marker will have + * no duration. + * In window and ChromeWorker contexts, use a + * timestamp from `performance.now()`. + * In JS modules, use `Cu.now()` to get a timestamp. + * @param text Text to associate with the marker. + */ + undefined addProfilerMarker(UTF8String name, + optional (ProfilerMarkerOptions or DOMHighResTimeStamp) options = {}, + optional UTF8String text); + + /** + * Return the symbolic name of any given XPCOM error code (nsresult): + * "NS_OK", "NS_ERROR_FAILURE",... + */ + UTF8String getXPCOMErrorName(unsigned long aErrorCode); + + /** + * Return a fractional number representing the current time (in milliseconds from the Epoch). + * Should be JS_Now()/1000 so that it can be compared to Date.now in Javascript. + */ + double dateNow(); + + /** + * IF YOU ADD NEW METHODS HERE, MAKE SURE THEY ARE THREAD-SAFE. + */ +}; + +/** + * Additional ChromeUtils methods that are _not_ thread-safe, and hence not + * exposed in workers. + */ +[Exposed=Window] +partial namespace ChromeUtils { + /** + * A helper that converts OriginAttributesDictionary to a opaque suffix string. + * + * @param originAttrs The originAttributes from the caller. + */ + ByteString + originAttributesToSuffix(optional OriginAttributesDictionary originAttrs = {}); + + /** + * Returns true if the members of |originAttrs| match the provided members + * of |pattern|. + * + * @param originAttrs The originAttributes under consideration. + * @param pattern The pattern to use for matching. + */ + boolean + originAttributesMatchPattern(optional OriginAttributesDictionary originAttrs = {}, + optional OriginAttributesPatternDictionary pattern = {}); + + /** + * Returns an OriginAttributesDictionary with values from the |origin| suffix + * and unspecified attributes added and assigned default values. + * + * @param origin The origin URI to create from. + * @returns An OriginAttributesDictionary with values from + * the origin suffix and unspecified attributes + * added and assigned default values. + */ + [Throws] + OriginAttributesDictionary + createOriginAttributesFromOrigin(DOMString origin); + + /** + * Returns an OriginAttributesDictionary with values from the origin |suffix| + * and unspecified attributes added and assigned default values. + * + * @param suffix The origin suffix to create from. + * @returns An OriginAttributesDictionary with values from + * the origin suffix and unspecified attributes + * added and assigned default values. + */ + [Throws] + OriginAttributesDictionary + CreateOriginAttributesFromOriginSuffix(DOMString suffix); + + /** + * Returns an OriginAttributesDictionary that is a copy of |originAttrs| with + * unspecified attributes added and assigned default values. + * + * @param originAttrs The origin attributes to copy. + * @returns An OriginAttributesDictionary copy of |originAttrs| + * with unspecified attributes added and assigned + * default values. + */ + OriginAttributesDictionary + fillNonDefaultOriginAttributes(optional OriginAttributesDictionary originAttrs = {}); + + /** + * Returns true if the 2 OriginAttributes are equal. + */ + boolean + isOriginAttributesEqual(optional OriginAttributesDictionary aA = {}, + optional OriginAttributesDictionary aB = {}); + + /** + * Returns the base domain portion of a given partitionKey. + * Returns the empty string for an empty partitionKey. + * Throws for invalid partition keys. + */ + [Throws] + DOMString + getBaseDomainFromPartitionKey(DOMString partitionKey); + + /** + * Returns the partitionKey for a given URL. + * + * The function will treat the URL as a first party and construct the + * partitionKey according to the scheme, site and port in the URL. + * + * Throws for invalid urls. + */ + [Throws] + DOMString + getPartitionKeyFromURL(DOMString url); + + /** + * Loads and compiles the script at the given URL and returns an object + * which may be used to execute it repeatedly, in different globals, without + * re-parsing. + */ + [NewObject] + Promise<PrecompiledScript> + compileScript(DOMString url, optional CompileScriptOptionsDictionary options = {}); + + /** + * Returns an optimized QueryInterface method which, when called from + * JavaScript, acts as an ordinary QueryInterface function call, and when + * called from XPConnect, circumvents JSAPI entirely. + * + * The list of interfaces may include a mix of JS ID objects and interface + * name strings. + * + * nsISupports is implicitly supported, and must not be included in the + * interface list. + */ + [Affects=Nothing, NewObject, Throws] + MozQueryInterface generateQI(sequence<any> interfaces); + + /** + * Waive Xray on a given value. Identity op for primitives. + */ + [Throws] + any waiveXrays(any val); + + /** + * Strip off Xray waivers on a given value. Identity op for primitives. + */ + [Throws] + any unwaiveXrays(any val); + + /** + * Gets the name of the JSClass of the object. + * + * if |unwrap| is true, all wrappers are unwrapped first. Unless you're + * specifically trying to detect whether the object is a proxy, this is + * probably what you want. + */ + DOMString getClassName(object obj, optional boolean unwrap = true); + + /** + * Returns whether the object is a DOM object. + * + * if |unwrap| is true, all wrappers are unwrapped first. Unless you're + * specifically trying to detect whether the object is a proxy, this is + * probably what you want. + */ + boolean isDOMObject(object obj, optional boolean unwrap = true); + + /** + * Clones the properties of the given object into a new object in the given + * target compartment (or the caller compartment if no target is provided). + * Property values themeselves are not cloned. + * + * Ignores non-enumerable properties, properties on prototypes, and properties + * with getters or setters. + */ + [Throws] + object shallowClone(object obj, optional object? target = null); + + /** + * Dispatches the given callback to the main thread when it would be + * otherwise idle. Similar to Window.requestIdleCallback, but not bound to a + * particular DOM windw. + */ + [Throws] + undefined idleDispatch(IdleRequestCallback callback, + optional IdleRequestOptions options = {}); + + /** + * Synchronously loads and evaluates the js file located at + * 'aResourceURI' with a new, fully privileged global object. + * + * If `aTargetObj` is specified all properties exported by the module are + * copied to that object. This is deprecated and should not be used in + * new code. + * + * @param aResourceURI A resource:// URI string to load the module from. + * @param aTargetObj the object to install the exported properties on or null. + * @returns the module code's global object. + * + * The implementation maintains a hash of aResourceURI->global obj. + * Subsequent invocations of import with 'aResourceURI' pointing to + * the same file will not cause the module to be re-evaluated, but + * the symbols in EXPORTED_SYMBOLS will be exported into the + * specified target object and the global object returned as above. + */ + [Throws] + object import(UTF8String aResourceURI, optional object aTargetObj); + + /** + * Synchronously loads and evaluates the JS module source located at + * 'aResourceURI'. + * + * @param aResourceURI A resource:// URI string to load the module from. + * @returns the module's namespace object. + * + * The implementation maintains a hash of aResourceURI->global obj. + * Subsequent invocations of import with 'aResourceURI' pointing to + * the same file will not cause the module to be re-evaluated. + */ + [Throws] + object importESModule(DOMString aResourceURI, optional ImportESModuleOptionsDictionary options = {}); + + /** + * Defines a property on the given target which lazily imports a JavaScript + * module when accessed. + * + * The first time the property is accessed, the module at the given URL is + * imported, and the property is replaced with the module's exported symbol + * of the same name. + * + * Some points to note when using this utility: + * + * - The cached module export is always stored on the `this` object that was + * used to access the getter. This means that if you define the lazy + * getter on a prototype, the module will be re-imported every time the + * property is accessed on a new instance. + * + * - The getter property may be overwritten by simple assignment, but as + * with imports, the new property value is always defined on the `this` + * object that the setter is called with. + * + * - If the module import fails, the getter will throw an error, and the + * property will not be replaced. Each subsequent attempt to access the + * getter will attempt to re-import the object, which will likely continue + * to result in errors. + * + * @param target The target object on which to define the property. + * @param id The name of the property to define, and of the symbol to + * import. + * @param resourceURI The resource URI of the module, as passed to + * ChromeUtils.import. + */ + [Throws] + undefined defineModuleGetter(object target, DOMString id, DOMString resourceURI); + + /** + * Defines propertys on the given target which lazily imports a ES module + * when accessed. + * + * @param target The target object on which to define the property. + * @param modules An object with a property for each module property to be + * imported, where the property name is the name of the + * imported symbol and the value is the module URI. + */ + [Throws] + undefined defineESModuleGetters(object target, object modules); + + /** + * Returns the scripted location of the first ancestor stack frame with a + * principal which is subsumed by the given principal. If no such frame + * exists on the call stack, returns null. + */ + object? getCallerLocation(Principal principal); + + /** + * Creates a JS Error object with the given message and stack. + * + * If a stack object is provided, the error object is created in the global + * that it belongs to. + */ + [Throws] + object createError(DOMString message, optional object? stack = null); + + /** + * Request performance metrics to the current process & all content processes. + */ + [NewObject] + Promise<sequence<PerformanceInfoDictionary>> requestPerformanceMetrics(); + + /** + * Set the collection of specific detailed performance timing information. + * Selecting 0 for the mask will end existing collection. All metrics that + * are chosen will be cleared after updating the mask. + * + * @param aCollectionMask A bitmask where each bit corresponds to a metric + * to be collected as listed in PerfStats::Metric. + */ + undefined setPerfStatsCollectionMask(unsigned long long aCollectionMask); + + /** + * Collect results of detailed performance timing information. + * The output is a JSON string containing performance timings. + */ + [NewObject] + Promise<DOMString> collectPerfStats(); + + /** + * Returns a Promise containing a sequence of I/O activities + */ + [NewObject] + Promise<sequence<IOActivityDataDictionary>> requestIOActivity(); + + /** + * Returns a Promise containing all processes info + */ + [NewObject] + Promise<ParentProcInfoDictionary> requestProcInfo(); + + /** + * For testing purpose. + */ + [ChromeOnly] + boolean vsyncEnabled(); + + [ChromeOnly, Throws] + boolean hasReportingHeaderForOrigin(DOMString aOrigin); + + [ChromeOnly] + PopupBlockerState getPopupControlState(); + + /** + * Milliseconds from the last iframe loading an external protocol. + */ + [ChromeOnly] + double lastExternalProtocolIframeAllowed(); + + /** + * For testing purpose we need to reset this value. + */ + [ChromeOnly] + undefined resetLastExternalProtocolIframeAllowed(); + + /** + * Register a new toplevel window global actor. This method may only be + * called in the parent process. |name| must be globally unique. + * + * See JSWindowActor.webidl for WindowActorOptions fields documentation. + */ + [ChromeOnly, Throws] + undefined registerWindowActor(UTF8String aName, optional WindowActorOptions aOptions = {}); + + [ChromeOnly] + undefined unregisterWindowActor(UTF8String aName); + + /** + * Register a new toplevel content global actor. This method may only be + * called in the parent process. |name| must be globally unique. + * + * See JSProcessActor.webidl for ProcessActorOptions fields documentation. + */ + [ChromeOnly, Throws] + undefined registerProcessActor(UTF8String aName, optional ProcessActorOptions aOptions = {}); + + [ChromeOnly] + undefined unregisterProcessActor(UTF8String aName); + + [ChromeOnly] + // aError should a nsresult. + boolean isClassifierBlockingErrorCode(unsigned long aError); + + /** + * If leak detection is enabled, print a note to the leak log that this + * process will intentionally crash. This should be called only on child + * processes for testing purpose. + */ + [ChromeOnly, Throws] + undefined privateNoteIntentionalCrash(); + + /** + * nsIDOMProcessChild for the current process. + */ + [ChromeOnly] + readonly attribute nsIDOMProcessChild? domProcessChild; + + /** + * nsIDOMProcessParent for all processes. + * + * The first is for the parent process and all the next are for the content + * processes. + */ + [Throws, ChromeOnly] + sequence<nsIDOMProcessParent> getAllDOMProcesses(); + + /** + * Returns a record of user interaction data. Currently only typing, + * but will include scrolling and potentially other metrics. + * + * Valid keys: "Typing" + */ + [Throws, ChromeOnly] + record<DOMString, InteractionData> consumeInteractionData(); + + /** + * Returns a record of user scrolling interactions collected from content processes. + * + * Valid keys: "Scrolling" + */ + [NewObject] + Promise<InteractionData> collectScrollingData(); + + [Throws] + sequence<FormAutofillConfidences> getFormAutofillConfidences(sequence<Element> elements); + + /** + * Returns whether the background of the element is dark. + */ + boolean isDarkBackground(Element element); +}; + +/* + * This type is a WebIDL representation of mozilla::ProcType. + * These must match the similar ones in E10SUtils.sys.mjs, RemoteTypes.h, + * ProcInfo.h and ChromeUtils.cpp + */ +enum WebIDLProcType { + "web", + "webIsolated", + "file", + "extension", + "privilegedabout", + "privilegedmozilla", + "withCoopCoep", + "webServiceWorker", + "browser", + "ipdlUnitTest", + "gmpPlugin", + "gpu", + "vr", + "rdd", + "socket", + "remoteSandboxBroker", +#ifdef MOZ_ENABLE_FORKSERVER + "forkServer", +#endif + "utility", + "preallocated", + "unknown", +}; + +/** + * These dictionaries hold information about Firefox running processes and + * threads. + * + * See widget/ProcInfo.h for fields documentation. + */ +dictionary ThreadInfoDictionary { + long long tid = 0; + DOMString name = ""; + unsigned long long cpuCycleCount = 0; + unsigned long long cpuTime = 0; +}; + +dictionary WindowInfoDictionary { + // Window ID, as known to the parent process. + unsigned long long outerWindowId = 0; + + // URI of the document loaded in the window. + URI? documentURI = null; + + // Title of the document loaded in the window. + // Commonly empty for subframes. + DOMString documentTitle = ""; + + // `true` if this window is the root for the process. + boolean isProcessRoot = false; + + // `true` if this is loaded in the same process as the parent, `false` otherwise. + boolean isInProcess = false; +}; + +/* + * Add new entry to WebIDLUtilityActorName here and update accordingly + * UtilityActorNameToWebIDL in dom/base/ChromeUtils.cpp as well as + * UtilityActorName in toolkit/components/processtools/ProcInfo.h + */ +enum WebIDLUtilityActorName { + "unknown", + "audioDecoder_Generic", + "audioDecoder_AppleMedia", + "audioDecoder_WMF", + "mfMediaEngineCDM", + "jSOracle", +}; + +dictionary UtilityActorsDictionary { + WebIDLUtilityActorName actorName = "unknown"; +}; + +/** + * Information on a child process. + * + * # Limitation + * + * If we lose a race with a process or thread attempting to close the + * target process, not all information is available. + * + * Missing information will generally have its default value. + */ +dictionary ChildProcInfoDictionary { + // --- System info + + // The cross-process descriptor for this process. + long long pid = 0; + + // The best end-user measure for "memory used" that we can obtain without + // triggering expensive computations. The value is in bytes. + // On Mac and Linux this matches the values shown by the system monitors. + // On Windows this will return the Commit Size. + unsigned long long memory = 0; + + // Total CPU time spent by the process, in ns. + unsigned long long cpuTime = 0; + + // Total CPU cycles used by this process. + // On Windows where the resolution of CPU timings is 16ms, this can + // be used to determine if a process is idle or slightly active. + unsigned long long cpuCycleCount = 0; + + // Thread information for this process. + sequence<ThreadInfoDictionary> threads = []; + + // --- Firefox info + + // Internal-to-Firefox process identifier. + unsigned long long childID = 0; + + // The origin of the process, e.g. the subset of domain names + // that this subset serves. + UTF8String origin = ""; + + // Type of this child process. + WebIDLProcType type = "web"; + + // The windows implemented by this process. + sequence<WindowInfoDictionary> windows = []; + + // The utility process list of actors if any + sequence<UtilityActorsDictionary> utilityActors = []; +}; + +/** + * Information on the parent process. + */ +dictionary ParentProcInfoDictionary { + // --- System info + + // The cross-process descriptor for this process. + long long pid = 0; + + // The best end-user measure for "memory used" that we can obtain without + // triggering expensive computations. The value is in bytes. + // On Mac and Linux this matches the values shown by the system monitors. + // On Windows this will return the Commit Size. + unsigned long long memory = 0; + + // Total CPU time spent by the process, in ns. + unsigned long long cpuTime = 0; + + // Total CPU cycles used by this process. + // On Windows where the resolution of CPU timings is 16ms, this can + // be used to determine if a process is idle or slightly active. + unsigned long long cpuCycleCount = 0; + + // Thread information for this process. + sequence<ThreadInfoDictionary> threads = []; + + // Information on children processes. + sequence<ChildProcInfoDictionary> children = []; + + // --- Firefox info + // Type of this parent process. + // As of this writing, this is always `browser`. + WebIDLProcType type = "browser"; +}; + +/** + * Dictionaries duplicating IPDL types in dom/ipc/DOMTypes.ipdlh + * Used by requestPerformanceMetrics + */ +dictionary MediaMemoryInfoDictionary { + unsigned long long audioSize = 0; + unsigned long long videoSize = 0; + unsigned long long resourcesSize = 0; +}; + +dictionary MemoryInfoDictionary { + unsigned long long domDom = 0; + unsigned long long domStyle = 0; + unsigned long long domOther = 0; + unsigned long long jsMemUsage = 0; + required MediaMemoryInfoDictionary media; +}; + +dictionary CategoryDispatchDictionary +{ + unsigned short category = 0; + unsigned short count = 0; +}; + +dictionary PerformanceInfoDictionary { + ByteString host = ""; + unsigned long pid = 0; + unsigned long long windowId = 0; + unsigned long long duration = 0; + unsigned long long counterId = 0; + boolean isWorker = false; + boolean isTopLevel = false; + required MemoryInfoDictionary memoryInfo; + sequence<CategoryDispatchDictionary> items = []; +}; + +/** + * Used by requestIOActivity() to return the number of bytes + * that were read (rx) and/or written (tx) for a given location. + * + * Locations can be sockets or files. + */ +dictionary IOActivityDataDictionary { + ByteString location = ""; + unsigned long long rx = 0; + unsigned long long tx = 0; +}; + +/** + * Used by principals and the script security manager to represent origin + * attributes. The first dictionary is designed to contain the full set of + * OriginAttributes, the second is used for pattern-matching (i.e. does this + * OriginAttributesDictionary match the non-empty attributes in this pattern). + * + * IMPORTANT: If you add any members here, you need to do the following: + * (1) Add them to both dictionaries. + * (2) Update the methods on mozilla::OriginAttributes, including equality, + * serialization, deserialization, and inheritance. + * (3) Update the methods on mozilla::OriginAttributesPattern, including matching. + */ +[GenerateInitFromJSON] +dictionary OriginAttributesDictionary { + unsigned long userContextId = 0; + boolean inIsolatedMozBrowser = false; + unsigned long privateBrowsingId = 0; + DOMString firstPartyDomain = ""; + DOMString geckoViewSessionContextId = ""; + DOMString partitionKey = ""; +}; + +[GenerateInitFromJSON, GenerateToJSON] +dictionary OriginAttributesPatternDictionary { + unsigned long userContextId; + boolean inIsolatedMozBrowser; + unsigned long privateBrowsingId; + DOMString firstPartyDomain; + DOMString geckoViewSessionContextId; + // partitionKey takes precedence over partitionKeyPattern. + DOMString partitionKey; + PartitionKeyPatternDictionary partitionKeyPattern; +}; + +dictionary PartitionKeyPatternDictionary { + DOMString scheme; + DOMString baseDomain; + long port; +}; + +dictionary CompileScriptOptionsDictionary { + /** + * The character set from which to decode the script. + */ + DOMString charset = "utf-8"; + + /** + * If true, certain parts of the script may be parsed lazily, the first time + * they are used, rather than eagerly parsed at load time. + */ + boolean lazilyParse = false; + + /** + * If true, the script will be compiled so that its last expression will be + * returned as the value of its execution. This makes certain types of + * optimization impossible, and disables the JIT in many circumstances, so + * should not be used when not absolutely necessary. + */ + boolean hasReturnValue = false; +}; + +dictionary ImportESModuleOptionsDictionary { + /** + * If true, a distinct module loader will be used, in the system principal, + * but with a distinct global so that the DevTools can load a distinct set + * of modules and do not interfere with its debuggee. + */ + boolean loadInDevToolsLoader; +}; + +/** + * A JS object whose properties specify what portion of the heap graph to + * write. The recognized properties are: + * + * * globals: [ global, ... ] + * Dump only nodes that either: + * - belong in the compartment of one of the given globals; + * - belong to no compartment, but do belong to a Zone that contains one of + * the given globals; + * - are referred to directly by one of the last two kinds of nodes; or + * - is the fictional root node, described below. + * + * * debugger: Debugger object + * Like "globals", but use the Debugger's debuggees as the globals. + * + * * runtime: true + * Dump the entire heap graph, starting with the JSRuntime's roots. + * + * One, and only one, of these properties must exist on the boundaries object. + * + * The root of the dumped graph is a fictional node whose ubi::Node type name is + * "CoreDumpRoot". If we are dumping the entire ubi::Node graph, this root node + * has an edge for each of the JSRuntime's roots. If we are dumping a selected + * set of globals, the root has an edge to each global, and an edge for each + * incoming JS reference to the selected Zones. + */ +dictionary HeapSnapshotBoundaries { + sequence<object> globals; + object debugger; + boolean runtime; +}; + +dictionary Base64URLEncodeOptions { + /** Specifies whether the output should be padded with "=" characters. */ + required boolean pad; +}; + +enum Base64URLDecodePadding { + /** + * Fails decoding if the input is unpadded. RFC 4648, section 3.2 requires + * padding, unless the referring specification prohibits it. + */ + "require", + + /** Tolerates padded and unpadded input. */ + "ignore", + + /** + * Fails decoding if the input is padded. This follows the strict base64url + * variant used in JWS (RFC 7515, Appendix C) and HTTP Encrypted + * Content-Encoding (draft-ietf-httpbis-encryption-encoding-01). + */ + "reject" +}; + +dictionary Base64URLDecodeOptions { + /** Specifies the padding mode for decoding the input. */ + required Base64URLDecodePadding padding; +}; + +// Keep this in sync with PopupBlocker::PopupControlState! +enum PopupBlockerState { + "openAllowed", + "openControlled", + "openBlocked", + "openAbused", + "openOverridden", +}; diff --git a/dom/chrome-webidl/ClonedErrorHolder.webidl b/dom/chrome-webidl/ClonedErrorHolder.webidl new file mode 100644 index 0000000000..8ab62f99ed --- /dev/null +++ b/dom/chrome-webidl/ClonedErrorHolder.webidl @@ -0,0 +1,18 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * A stub object to hold an Error, Exception, or DOMException object to be + * transferred via structured clone. The object will automatically be decoded + * directly into the type of the error object that it wraps. + * + * This is a temporary workaround for lack of native Error and Exception + * cloning support, and can be removed once bug 1556604 and bug 1561357 are + * fixed. + */ +[ChromeOnly, Exposed=Window] +interface ClonedErrorHolder { + [Throws] + constructor(object aError); +}; diff --git a/dom/chrome-webidl/DOMCollectedFrames.webidl b/dom/chrome-webidl/DOMCollectedFrames.webidl new file mode 100644 index 0000000000..4875fbf8ba --- /dev/null +++ b/dom/chrome-webidl/DOMCollectedFrames.webidl @@ -0,0 +1,29 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/** + * A single frame collected by the |CompositionRecorder|. + */ +[GenerateConversionToJS] +dictionary DOMCollectedFrame { + /** + * The offset of the frame past the start point of the recording (in + * milliseconds). + */ + required double timeOffset; + /** A data: URI containing the PNG image data of the frame. */ + required ByteString dataUri; +}; + +/** + * Information about frames collected by the |CompositionRecorder|. + */ +[GenerateConversionToJS] +dictionary DOMCollectedFrames { + /** The collected frames. */ + required sequence<DOMCollectedFrame> frames; + /** The start point of the recording (in milliseconds). */ + required double recordingStart; +}; diff --git a/dom/chrome-webidl/DebuggerNotification.webidl b/dom/chrome-webidl/DebuggerNotification.webidl new file mode 100644 index 0000000000..d549eb7ae9 --- /dev/null +++ b/dom/chrome-webidl/DebuggerNotification.webidl @@ -0,0 +1,58 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +enum DebuggerNotificationType { + // DebuggerNotification + "setTimeout", + "clearTimeout", + "setInterval", + "clearInterval", + "requestAnimationFrame", + "cancelAnimationFrame", + + // CallbackDebuggerNotification + "setTimeoutCallback", + "setIntervalCallback", + "requestAnimationFrameCallback", + + // EventCallbackDebuggerNotification + "domEvent", +}; + +[ChromeOnly, Exposed=Window] +interface DebuggerNotification { + readonly attribute DebuggerNotificationType type; + + // The global object that has triggered the notification. + readonly attribute object global; +}; + +// For DOM events, we send notifications just before, and just after the +// event handler has been dispatched so that listeners +enum CallbackDebuggerNotificationPhase { + "pre", + "post", +}; + +// A base notification type for notifications that are dispatched as pairs with +// a before and after notification. +[ChromeOnly, Exposed=Window] +interface CallbackDebuggerNotification : DebuggerNotification { + readonly attribute CallbackDebuggerNotificationPhase phase; +}; + +enum EventCallbackDebuggerNotificationType { + "global", + "node", + "xhr", + "worker", + "websocket", +}; + +// A notification that about the engine calling a DOM event handler. +[ChromeOnly, Exposed=Window] +interface EventCallbackDebuggerNotification : CallbackDebuggerNotification { + readonly attribute Event event; + readonly attribute EventCallbackDebuggerNotificationType targetType; +}; diff --git a/dom/chrome-webidl/DebuggerNotificationObserver.webidl b/dom/chrome-webidl/DebuggerNotificationObserver.webidl new file mode 100644 index 0000000000..e37d2dc312 --- /dev/null +++ b/dom/chrome-webidl/DebuggerNotificationObserver.webidl @@ -0,0 +1,31 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +callback DebuggerNotificationCallback = undefined (DebuggerNotification n); + +[ChromeOnly, Exposed=(Window, Worker)] +interface DebuggerNotificationObserver { + [Throws] + constructor(); + + // Throws if the object is not a browser global or does not support + // debugger notifications. + // Returns false if already connected to this global. + [Throws] + boolean connect(object global); + + // Throws if the object is not a browser global or does not support + // debugger notifications. + // Returns false if not connected to this global. + [Throws] + boolean disconnect(object global); + + // Returns false if listener already added. + boolean addListener(DebuggerNotificationCallback handler); + + // Returns false if listener was not found. + boolean removeListener(DebuggerNotificationCallback handler); +}; diff --git a/dom/chrome-webidl/DebuggerUtils.webidl b/dom/chrome-webidl/DebuggerUtils.webidl new file mode 100644 index 0000000000..31421efcaa --- /dev/null +++ b/dom/chrome-webidl/DebuggerUtils.webidl @@ -0,0 +1,16 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +// Interfaces and structures for use by the debugger and other devtools. + +// Data sent to the devtools when new data has been received in an HTML parse. +[GenerateToJSON] +dictionary HTMLContent { + DOMString parserID; + DOMString uri; + DOMString contents; + boolean complete; +}; diff --git a/dom/chrome-webidl/DocumentL10n.webidl b/dom/chrome-webidl/DocumentL10n.webidl new file mode 100644 index 0000000000..5f252de2cb --- /dev/null +++ b/dom/chrome-webidl/DocumentL10n.webidl @@ -0,0 +1,47 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/** + * DocumentL10n is a public interface for handling DOM localization. + * + * In it's current form it exposes the DOMLocalization API which + * allows for localization-specific DOM operations on a defined + * localization context, and retrival of formatted localization + * messages out of that context. + * + * The context is created when `<link rel="localization"/>` elements + * are added to the document, and is removed in case all links + * of that type are removed from it. + */ +[LegacyNoInterfaceObject, + Exposed=Window] +interface DocumentL10n : DOMLocalization { + /** + * A promise which gets resolved when the initial DOM localization resources + * fetching is complete and the initial translation of the DOM is finished. + */ + readonly attribute Promise<any> ready; + + /** + * An overload for the DOMLocalization::connectRoot which takes an optional second + * argument to allow the user to express an intent of translating the root + * as soon as the localization becomes available. + * + * If the root is being connected while the document is still being parsed, + * then irrelevant of the value of the second argument, it will be translated + * as part of the initial translation step right after the parsing completes. + * + * If the root is being connected after the document is parsed, then the + * second argument controls whether the root is also going to get translated, + * or just connected. + * + * This is a temporary workaround to avoid having to wait for the `DocumentL10n` + * to become active. It should be unnecessary once we remove JSM and make + * the `TranslateFragment` be available immediately when `DocumentL10n` becomes + * available. + */ + [Throws] undefined connectRoot(Node aElement, optional boolean aTranslate = false); +}; diff --git a/dom/chrome-webidl/DominatorTree.webidl b/dom/chrome-webidl/DominatorTree.webidl new file mode 100644 index 0000000000..518f0e9802 --- /dev/null +++ b/dom/chrome-webidl/DominatorTree.webidl @@ -0,0 +1,70 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +typedef unsigned long long NodeId; +typedef unsigned long long NodeSize; + +/** + * In a directed graph with a root node `R`, a node `A` is said to "dominate" a + * node `B` iff every path from `R` to `B` contains `A`. A node `A` is said to + * be the "immediate dominator" of a node `B` iff it dominates `B`, is not `B` + * itself, and does not dominate any other nodes which also dominate `B` in + * turn. + * + * If we take every node from a graph `G` and create a new graph `T` with edges + * to each node from its immediate dominator, then `T` is a tree (each node has + * only one immediate dominator, or none if it is the root). This tree is called + * a "dominator tree". + * + * This interface represents a dominator tree constructed from a HeapSnapshot's + * heap graph. The domination relationship and dominator trees are useful tools + * for analyzing heap graphs because they tell you: + * + * - Exactly what could be reclaimed by the GC if some node `A` became + * unreachable: those nodes which are dominated by `A`, + * + * - The "retained size" of a node in the heap graph, in contrast to its + * "shallow size". The "shallow size" is the space taken by a node itself, + * not counting anything it references. The "retained size" of a node is its + * shallow size plus the size of all the things that would be collected if + * the original node wasn't (directly or indirectly) referencing them. In + * other words, the retained size is the shallow size of a node plus the + * shallow sizes of every other node it dominates. For example, the root + * node in a binary tree might have a small shallow size that does not take + * up much space itself, but it dominates the rest of the binary tree and + * its retained size is therefore significant (assuming no external + * references into the tree). + */ +[ChromeOnly, Exposed=(Window,Worker)] +interface DominatorTree { + /** + * The `NodeId` for the root of the dominator tree. This is a "meta-root" in + * that it has an edge to each GC root in the heap snapshot this dominator + * tree was created from. + */ + readonly attribute NodeId root; + + /** + * Get the retained size of the node with the given id. If given an invalid + * id, null is returned. Throws an error on OOM. + */ + [Throws] + NodeSize? getRetainedSize(NodeId node); + + /** + * Get the set of ids of nodes immediately dominated by the node with the + * given id. The resulting array is sorted by greatest to least retained + * size. If given an invalid id, null is returned. Throws an error on OOM. + */ + [Throws] + sequence<NodeId>? getImmediatelyDominated(NodeId node); + + /** + * Get the immediate dominator of the node with the given id. Returns null if + * given an invalid id, or the id of the root node. + */ + NodeId? getImmediateDominator(NodeId node); +}; diff --git a/dom/chrome-webidl/Flex.webidl b/dom/chrome-webidl/Flex.webidl new file mode 100644 index 0000000000..f04897e65c --- /dev/null +++ b/dom/chrome-webidl/Flex.webidl @@ -0,0 +1,94 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/** + * These objects support visualization of flex containers by the + * dev tools. + */ + +/** + * A flex container's main and cross axes are either horizontal or + * vertical, each with two possible directions. + */ +enum FlexPhysicalDirection { + "horizontal-lr", + "horizontal-rl", + "vertical-tb", + "vertical-bt", +}; + +[ChromeOnly, Exposed=Window] +interface Flex +{ + sequence<FlexLineValues> getLines(); + + /** + * The physical direction in which successive flex items are placed, + * within a flex line in this flex container. + */ + readonly attribute FlexPhysicalDirection mainAxisDirection; + + /** + * The physical direction in which successive flex lines are placed + * in this flex container (if it is or were multi-line). + */ + readonly attribute FlexPhysicalDirection crossAxisDirection; +}; + +/** + * This indicates which flex factor (flex-grow vs. flex-shrink) the + * flex layout algorithm uses internally when resolving flexible sizes + * in a given flex line, per flexbox spec section 9.7 step 1. Note that + * this value doesn't necessarily mean that any items on this line + * are *actually* growing (or shrinking). This simply indicates what + * the layout algorithm "wants" to do, based on the free space -- + * and items will stretch from their flex base size in the corresponding + * direction, if permitted by their min/max constraints and their + * corresponding flex factor. + */ +enum FlexLineGrowthState { "shrinking", "growing" }; + +[ChromeOnly, Exposed=Window] +interface FlexLineValues +{ + readonly attribute FlexLineGrowthState growthState; + readonly attribute double crossStart; + readonly attribute double crossSize; + + // firstBaselineOffset measures from flex-start edge. + readonly attribute double firstBaselineOffset; + + // lastBaselineOffset measures from flex-end edge. + readonly attribute double lastBaselineOffset; + + /** + * getItems() returns FlexItemValues only for the Elements in + * this Flex container -- ignoring struts and abs-pos Elements. + */ + sequence<FlexItemValues> getItems(); +}; + +/** + * Item main sizes have either been unclamped, clamped to the minimum, + * or clamped to the maximum. + */ +enum FlexItemClampState { + "unclamped", "clamped_to_min", "clamped_to_max" +}; + +[ChromeOnly, Exposed=Window] +interface FlexItemValues +{ + readonly attribute Node? node; + readonly attribute DOMRectReadOnly frameRect; + readonly attribute double mainBaseSize; + readonly attribute double mainDeltaSize; + readonly attribute double mainMinSize; + readonly attribute double mainMaxSize; + readonly attribute double crossMinSize; + readonly attribute double crossMaxSize; + readonly attribute FlexItemClampState clampState; +}; diff --git a/dom/chrome-webidl/Fluent.webidl b/dom/chrome-webidl/Fluent.webidl new file mode 100644 index 0000000000..5a8d6fca2b --- /dev/null +++ b/dom/chrome-webidl/Fluent.webidl @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +[ChromeOnly, Exposed=Window] +interface FluentResource { + constructor(UTF8String source); +}; + +[ChromeOnly, Exposed=Window] +interface FluentPattern {}; + +/** + * FluentMessage is a structure storing an unresolved L10nMessage, + * as returned by the Fluent Bundle. + * + * It stores a FluentPattern of the value and attributes, which + * can be then passed to bundle.formatPattern. + */ + +dictionary FluentMessage { + FluentPattern? value = null; + required record<UTF8String, FluentPattern> attributes; +}; + +typedef record<UTF8String, (UTF8String or double)?> L10nArgs; + +dictionary FluentBundleOptions { + boolean useIsolating = false; + UTF8String pseudoStrategy; +}; + +dictionary FluentBundleAddResourceOptions { + boolean allowOverrides = false; +}; + +[ChromeOnly, Exposed=Window] +interface FluentBundle { + [Throws] + constructor((UTF8String or sequence<UTF8String>) aLocales, optional FluentBundleOptions aOptions = {}); + + [Pure, Cached] + readonly attribute sequence<UTF8String> locales; + + undefined addResource(FluentResource aResource, optional FluentBundleAddResourceOptions aOptions = {}); + boolean hasMessage(UTF8String id); + FluentMessage? getMessage(UTF8String id); + [Throws] + UTF8String formatPattern(FluentPattern pattern, optional L10nArgs? aArgs = null, optional object aErrors); +}; diff --git a/dom/chrome-webidl/FrameLoader.webidl b/dom/chrome-webidl/FrameLoader.webidl new file mode 100644 index 0000000000..5669d2af41 --- /dev/null +++ b/dom/chrome-webidl/FrameLoader.webidl @@ -0,0 +1,233 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +interface LoadContext; +interface RemoteTab; +interface URI; +interface nsIDocShell; +interface nsIPrintSettings; +interface nsIWebBrowserPersistDocumentReceiver; +interface nsIWebProgressListener; + +[ChromeOnly, + Exposed=Window] +interface FrameLoader { + /** + * Get the docshell from the frame loader. + */ + [GetterThrows] + readonly attribute nsIDocShell? docShell; + + /** + * Get this frame loader's RemoteTab, if it has a remote frame. Otherwise, + * returns null. + */ + readonly attribute RemoteTab? remoteTab; + + /** + * Get an nsILoadContext for the top-level docshell. For remote + * frames, a shim is returned that contains private browsing and app + * information. + */ + readonly attribute LoadContext loadContext; + + /** + * Get the root BrowsingContext within the frame. + * This may be null immediately after creating a remote frame. + */ + readonly attribute BrowsingContext? browsingContext; + + /** + * Find out whether the loader's frame is at too great a depth in + * the frame tree. This can be used to decide what operations may + * or may not be allowed on the loader's docshell. + */ + [Pure] + readonly attribute boolean depthTooGreat; + + /** + * Find out whether the loader's frame is a remote frame. + */ + readonly attribute boolean isRemoteFrame; + + // Note, when frameloaders are swapped, also messageManagers are swapped. + readonly attribute MessageSender? messageManager; + + /** + * Force a remote browser to recompute its dimension and screen position. + */ + [Throws] + undefined requestUpdatePosition(); + + /** + * Force a TabStateFlush from native sessionStoreListeners. + * Returns a promise that resolves when all session store data has been + * flushed. + */ + [NewObject] + Promise<undefined> requestTabStateFlush(); + + /** + * Force Epoch update in native sessionStoreListeners. + */ + undefined requestEpochUpdate(unsigned long aEpoch); + + /** + * Request a session history update in native sessionStoreListeners. + */ + undefined requestSHistoryUpdate(); + + /** + * Creates a print preview document in this frame, or updates the existing + * print preview document with new print settings. + * + * @param aPrintSettings The print settings to use to layout the print + * preview document. + * @param aSourceBrowsingContext Optionally, the browsing context that + * contains the document from which the print preview is to be generated, + * which must be in the same process as the browsing context of the frame + * loader itself. + * + * This should only be passed on the first call. It should not be passed + * for any subsequent calls that are made to update the existing print + * preview document with a new print settings object. + * @return A Promise that resolves with a PrintPreviewSuccessInfo on success. + */ + [NewObject] + Promise<unsigned long> printPreview(nsIPrintSettings aPrintSettings, + BrowsingContext? aSourceBrowsingContext); + + /** + * Inform the print preview document that we're done with it. + */ + undefined exitPrintPreview(); + + /** + * The element which owns this frame loader. + * + * For example, if this is a frame loader for an <iframe>, this attribute + * returns the iframe element. + */ + [Pure] + readonly attribute Element? ownerElement; + + + /** + * Cached childID of the ContentParent owning the RemoteTab in this frame + * loader. This can be used to obtain the childID after the RemoteTab died. + */ + [Pure] + readonly attribute unsigned long long childID; + + /** + * Find out whether the owner content really is a mozbrowser. <xul:browser> + * is not considered to be a mozbrowser frame. + */ + [Pure] + readonly attribute boolean ownerIsMozBrowserFrame; + + /** + * The last known width of the frame. Reading this property will not trigger + * a reflow, and therefore may not reflect the current state of things. It + * should only be used in asynchronous APIs where values are not guaranteed + * to be up-to-date when received. + */ + [Pure] + readonly attribute unsigned long lazyWidth; + + /** + * The last known height of the frame. Reading this property will not trigger + * a reflow, and therefore may not reflect the current state of things. It + * should only be used in asynchronous APIs where values are not guaranteed + * to be up-to-date when received. + */ + [Pure] + readonly attribute unsigned long lazyHeight; + + /** + * Is `true` if the frameloader is dead (destroy has been called on it) + */ + [Pure] + readonly attribute boolean isDead; +}; + +/** + * Interface for objects which represent a document that can be + * serialized with nsIWebBrowserPersist. This interface is + * asynchronous because the actual document can be in another process + * (e.g., if this object is a FrameLoader for an out-of-process + * frame). + * + * @see nsIWebBrowserPersistDocumentReceiver + * @see nsIWebBrowserPersistDocument + * @see nsIWebBrowserPersist + * + * @param aContext + * The browsing context of the subframe we'd like to persist. + * If set to nullptr, WebBrowserPersistable will attempt to persist + * the top-level document. If the browsing context is for a subframe + * that is not held beneath the WebBrowserPersistable, aRecv's onError + * method will be called with NS_ERROR_NO_CONTENT. + * @param aRecv + * The nsIWebBrowserPersistDocumentReceiver is a callback that + * will be fired once the document is ready for persisting. + */ +interface mixin WebBrowserPersistable +{ + [Throws] + undefined startPersistence(BrowsingContext? aContext, + nsIWebBrowserPersistDocumentReceiver aRecv); +}; + +enum PrintPreviewOrientation { + "landscape", + "portrait", + "unspecified" +}; + +/** + * Interface for the object that's used to resolve the Promise returned from + * FrameLoader.printPreview() if that method successfully creates the print + * preview document/successfully updates it with new settings. + */ +[GenerateConversionToJS] +dictionary PrintPreviewSuccessInfo { + /** + * The total number of sheets of paper required to print, taking into account + * the provided nsIPrintSettings. This takes into account page range + * selection, the pages-per-sheet, whether duplex printing is enabled, etc. + */ + unsigned long sheetCount = 0; + + /** + * The total number of virtual pages, not taking into account page range + * selection, the pages-per-sheet, whether duplex printing is enabled, etc. + */ + unsigned long totalPageCount = 0; + + /** + * Whether the preview is empty because of page range selection. + */ + boolean isEmpty = false; + + /** + * Whether the document or any subdocument has a selection that can be + * printed. + */ + boolean hasSelection = false; + + /** + * Whether the previewed document has a selection itself. + */ + boolean hasSelfSelection = false; + + /** + * Specified orientation of the document, or "unspecified". + */ + PrintPreviewOrientation orientation = "unspecified"; +}; + +FrameLoader includes WebBrowserPersistable; diff --git a/dom/chrome-webidl/Glean.webidl b/dom/chrome-webidl/Glean.webidl new file mode 100644 index 0000000000..f8f55e2418 --- /dev/null +++ b/dom/chrome-webidl/Glean.webidl @@ -0,0 +1,45 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +interface nsISupports; + +[ChromeOnly, Exposed=Window] +interface GleanCategory { + /** + * Get a metric by name. + * + * Returns an object of the corresponding metric type, + * with only the allowed functions available. + */ + getter nsISupports (DOMString identifier); +}; + +[ChromeOnly, Exposed=Window] +interface GleanImpl { + /** + * Get a metric category by name. + * + * Returns an object for further metric lookup. + */ + getter GleanCategory (DOMString identifier); +}; + +[ChromeOnly, Exposed=Window] +interface GleanLabeled { + /** + * Get a specific metric for a given label. + * + * If a set of acceptable labels were specified in the `metrics.yaml` file, + * and the given label is not in the set, it will be recorded under the + * special `OTHER_LABEL` label. + * + * If a set of acceptable labels was not specified in the `metrics.yaml` file, + * only the first 16 unique labels will be used. + * After that, any additional labels will be recorded under the special + * `OTHER_LABEL` label. + */ + getter nsISupports (DOMString identifier); +}; diff --git a/dom/chrome-webidl/GleanPings.webidl b/dom/chrome-webidl/GleanPings.webidl new file mode 100644 index 0000000000..3dee22205b --- /dev/null +++ b/dom/chrome-webidl/GleanPings.webidl @@ -0,0 +1,15 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +interface nsIGleanPing; + +[ChromeOnly, Exposed=Window] +interface GleanPingsImpl { + /** + * Get a ping by name. + */ + getter nsIGleanPing (DOMString identifier); +}; diff --git a/dom/chrome-webidl/HeapSnapshot.webidl b/dom/chrome-webidl/HeapSnapshot.webidl new file mode 100644 index 0000000000..8b1b0b1a14 --- /dev/null +++ b/dom/chrome-webidl/HeapSnapshot.webidl @@ -0,0 +1,105 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/** + * A HeapSnapshot represents a snapshot of the heap graph + */ +[ChromeOnly, Exposed=(Window,Worker)] +interface HeapSnapshot { + /** + * A time stamp of when the heap snapshot was taken, if available. Units are + * microseconds since midnight (00:00:00) 1 January 1970 UTC. + */ + readonly attribute unsigned long long? creationTime; + + /** + * Take a census of the heap snapshot. + * + * This is the same as |Debugger.Memory.prototype.takeCensus|, but operates on + * the offline heap snapshot's serialized heap graph rather than the live heap + * graph. The same optional configuration options that can be passed to that + * function can be passed here. + * + * The returned value is determined by the `"breakdown"` option used, and is + * usually a `Map`, `Object`, or `Array`. For example, the following breakdown + * + * { + * by: "coarseType", + * objects: { by: "objectClass" }, + * other: { by: "internalType" } + * } + * + * produces a result like this: + * + * { + * "objects": { + * "Function": { "count": 404, "bytes": 37328 }, + * "Object": { "count": 11, "bytes": 1264 }, + * "Debugger": { "count": 1, "bytes": 416 }, + * "ScriptSource": { "count": 1, "bytes": 64 }, + * // ... omitted for brevity... + * }, + * "scripts": { "count": 1, "bytes": 0 }, + * "strings": { "count": 701, "bytes": 49080 }, + * "other": { + * "js::Shape": { "count": 450, "bytes": 0 }, + * "js::BaseShape": { "count": 21, "bytes": 0 }, + * "js::ObjectGroup": { "count": 17, "bytes": 0 } + * } + * } + * + * See the `takeCensus` section of the `js/src/doc/Debugger/Debugger.Memory.md` + * file for detailed documentation. + */ + [Throws] + any takeCensus(object? options); + + /** + * Describe `node` with the specified `breakdown`. See the comment above + * `takeCensus` or `js/src/doc/Debugger/Debugger.Memory.md` for detailed + * documentation on breakdowns. + * + * Throws an error when `node` is not the id of a node in the heap snapshot, + * or if the breakdown is invalid. + */ + [Throws] + any describeNode(object breakdown, NodeId node); + + /** + * Compute the dominator tree for this heap snapshot. + * + * @see DominatorTree.webidl + */ + [Throws] + DominatorTree computeDominatorTree(); + + /** + * Find the shortest retaining paths from the node associated with the ID + * `start` to each node associated with the IDs in `targets`. Find at most + * `maxNumPaths` retaining paths for each target node. + * + * The return value is a Map object mapping from each target node ID to an + * array of retaining paths. The array may be empty if we did not find any + * retaining paths. + * + * A path is an array of objects of the form: + * + * { + * predecessor: <node ID>, + * edge: <string or null>, + * } + * + * The first `predecessor` will always be `start`. The last edge in the path + * leads to the `target` node that is mapped to the path; the `target` does + * not appear as a `predecessor` in the path. + * + * Throws when `start` or any of the elements of `targets` are not an ID of a + * node in the snapshot, or if we encounter an out of memory exception. + */ + [Throws] + object computeShortestPaths(NodeId start, sequence<NodeId> targets, + unsigned long long maxNumPaths); +}; diff --git a/dom/chrome-webidl/IOUtils.webidl b/dom/chrome-webidl/IOUtils.webidl new file mode 100644 index 0000000000..e1b67a53bd --- /dev/null +++ b/dom/chrome-webidl/IOUtils.webidl @@ -0,0 +1,766 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +interface nsIFile; + +/** + * IOUtils is a simple, efficient interface for performing file I/O from a + * privileged chrome-only context. All asynchronous I/O tasks are run on + * a background thread. + * + * Pending I/O tasks will block shutdown at the |profileBeforeChange| phase. + * During this shutdown phase, no additional I/O tasks will be accepted -- + * method calls to this interface will reject once shutdown has entered this + * phase. + * + * IOUtils methods may reject for any number of reasons. Reasonable attempts + * have been made to map each common operating system error to a |DOMException|. + * Most often, a caller only needs to check if a given file wasn't found by + * catching the rejected error and checking if |ex.name === 'NotFoundError'|. + * In other cases, it is likely sufficient to allow the error to be caught and + * reported elsewhere. + */ +[ChromeOnly, Exposed=(Window, Worker)] +namespace IOUtils { + /** + * Reads up to |opts.maxBytes| of the file at |path| according to |opts|. + * + * NB: The maximum file size that can be read is UINT32_MAX. + * + * @param path An absolute file path. + * + * @return Resolves with an array of unsigned byte values read from disk, + * otherwise rejects with a DOMException. + */ + [NewObject] + Promise<Uint8Array> read(DOMString path, optional ReadOptions opts = {}); + /** + * Reads the UTF-8 text file located at |path| and returns the decoded + * contents as a |DOMString|. + * + * NB: The maximum file size that can be read is UINT32_MAX. + * + * @param path An absolute file path. + * + * @return Resolves with the file contents encoded as a string, otherwise + * rejects with a DOMException. + */ + [NewObject] + Promise<UTF8String> readUTF8(DOMString path, optional ReadUTF8Options opts = {}); + /** + * Read the UTF-8 text file located at |path| and return the contents + * parsed as JSON into a JS value. + * + * NB: The maximum file size that can be read is UINT32_MAX. + * + * @param path An absolute path. + * + * @return Resolves with the contents of the file parsed as JSON. + */ + [NewObject] + Promise<any> readJSON(DOMString path, optional ReadUTF8Options opts = {}); + /** + * Attempts to safely write |data| to a file at |path|. + * + * This operation can be made atomic by specifying the |tmpPath| option. If + * specified, then this method ensures that the destination file is not + * modified until the data is entirely written to the temporary file, after + * which point the |tmpPath| is moved to the specified |path|. + * + * The target file can also be backed up to a |backupFile| before any writes + * are performed to prevent data loss in case of corruption. + * + * @param path An absolute file path. + * @param data Data to write to the file at path. + * + * @return Resolves with the number of bytes successfully written to the file, + * otherwise rejects with a DOMException. + */ + [NewObject] + Promise<unsigned long long> write(DOMString path, Uint8Array data, optional WriteOptions options = {}); + /** + * Attempts to encode |string| to UTF-8, then safely write the result to a + * file at |path|. Works exactly like |write|. + * + * @param path An absolute file path. + * @param string A string to write to the file at path. + * @param options Options for writing the file. + * + * @return Resolves with the number of bytes successfully written to the file, + * otherwise rejects with a DOMException. + */ + [NewObject] + Promise<unsigned long long> writeUTF8(DOMString path, UTF8String string, optional WriteOptions options = {}); + /** + * Attempts to serialize |value| into a JSON string and encode it as into a + * UTF-8 string, then safely write the result to a file at |path|. Works + * exactly like |write|. + * + * @param path An absolute file path + * @param value The value to be serialized. + * @param options Options for writing the file. The "append" mode is not supported. + * + * @return Resolves with the number of bytes successfully written to the file, + * otherwise rejects with a DOMException. + */ + [NewObject] + Promise<unsigned long long> writeJSON(DOMString path, any value, optional WriteOptions options = {}); + /** + * Moves the file from |sourcePath| to |destPath|, creating necessary parents. + * If |destPath| is a directory, then the source file will be moved into the + * destination directory. + * + * @param sourcePath An absolute file path identifying the file or directory + * to move. + * @param destPath An absolute file path identifying the destination + * directory and/or file name. + * + * @return Resolves if the file is moved successfully, otherwise rejects with + * a DOMException. + */ + [NewObject] + Promise<undefined> move(DOMString sourcePath, DOMString destPath, optional MoveOptions options = {}); + /** + * Removes a file or directory at |path| according to |options|. + * + * @param path An absolute file path identifying the file or directory to + * remove. + * + * @return Resolves if the file is removed successfully, otherwise rejects + * with a DOMException. + */ + [NewObject] + Promise<undefined> remove(DOMString path, optional RemoveOptions options = {}); + /** + * Creates a new directory at |path| according to |options|. + * + * @param path An absolute file path identifying the directory to create. + * + * @return Resolves if the directory is created successfully, otherwise + * rejects with a DOMException. + */ + [NewObject] + Promise<undefined> makeDirectory(DOMString path, optional MakeDirectoryOptions options = {}); + /** + * Obtains information about a file, such as size, modification dates, etc. + * + * @param path An absolute file path identifying the file or directory to + * inspect. + * + * @return Resolves with a |FileInfo| object for the file at path, otherwise + * rejects with a DOMException. + * + * @see FileInfo + */ + [NewObject] + Promise<FileInfo> stat(DOMString path); + /** + * Copies a file or directory from |sourcePath| to |destPath| according to + * |options|. + * + * @param sourcePath An absolute file path identifying the source file to be + * copied. + * @param destPath An absolute file path identifying the location for the + * copy. + * + * @return Resolves if the file was copied successfully, otherwise rejects + * with a DOMException. + */ + [NewObject] + Promise<undefined> copy(DOMString sourcePath, DOMString destPath, optional CopyOptions options = {}); + /** + * Updates the access time for the file at |path|. + * + * @param path An absolute file path identifying the file whose + * modification time is to be set. This file must exist + * and will not be created. + * @param modification An optional access time for the file expressed in + * milliseconds since the Unix epoch + * (1970-01-01T00:00:00Z). The current system time is used + * if this parameter is not provided. + * + * @return Resolves with the updated access time time expressed in + * milliseconds since the Unix epoch, otherwise rejects with a + * DOMException. + */ + [NewObject] + Promise<long long> setAccessTime(DOMString path, optional long long access); + /** + * Updates the modification time for the file at |path|. + * + * @param path An absolute file path identifying the file whose + * modification time is to be set. This file must exist + * and will not be created. + * @param modification An optional modification time for the file expressed in + * milliseconds since the Unix epoch + * (1970-01-01T00:00:00Z). The current system time is used + * if this parameter is not provided. + * + * @return Resolves with the updated modification time expressed in + * milliseconds since the Unix epoch, otherwise rejects with a + * DOMException. + */ + [NewObject] + Promise<long long> setModificationTime(DOMString path, optional long long modification); + /** + * Retrieves a (possibly empty) list of immediate children of the directory at + * |path|. + * + * @param path An absolute file path. + * + * @return Resolves with a sequence of absolute file paths representing the + * children of the directory at |path|, otherwise rejects with a + * DOMException. + */ + [NewObject] + Promise<sequence<DOMString>> getChildren(DOMString path, optional GetChildrenOptions options = {}); + /** + * Set the permissions of the file at |path|. + * + * Windows does not make a distinction between user, group, and other + * permissions like UNICES do. If a permission flag is set for any of user, + * group, or other has a permission, then all users will have that + * permission. Additionally, Windows does not support setting the + * "executable" permission. + * + * @param path An absolute file path + * @param permissions The UNIX file mode representing the permissions. + * @param honorUmask If omitted or true, any UNIX file mode value is + * modified by the process umask. If false, the exact value + * of UNIX file mode will be applied. This value has no effect + * on Windows. + * + * @return Resolves if the permissions were set successfully, otherwise + * rejects with a DOMException. + */ + [NewObject] + Promise<undefined> setPermissions(DOMString path, unsigned long permissions, optional boolean honorUmask = true); + /** + * Return whether or not the file exists at the given path. + * + * @param path An absolute file path. + * + * @return A promise that resolves to whether or not the given file exists. + */ + [NewObject] + Promise<boolean> exists(DOMString path); + + /** + * Create a file with a unique name and return its path. + * + * @param parent An absolute path to the directory where the file is to be + * created. + * @param prefix A prefix for the filename. + * + * @return A promise that resolves to a unique filename. + */ + [NewObject] + Promise<DOMString> createUniqueFile(DOMString parent, DOMString prefix, optional unsigned long permissions = 0644); + + /** + * Create a directory with a unique name and return its path. + * + * @param parent An absolute path to the directory where the file is to be + * created. + * @param prefix A prefix for the directory name. + * + * @return A promise that resolves to a unique directory name. + */ + [NewObject] + Promise<DOMString> createUniqueDirectory(DOMString parent, DOMString prefix, optional unsigned long permissions = 0755); + + /** + * Compute the hash of a file as a hex digest. + * + * @param path The absolute path of the file to hash. + * @param method The hashing method to use. + * + * @return A promise that resolves to the hex digest of the file's hash in lowercase. + */ + [NewObject] + Promise<UTF8String> computeHexDigest(DOMString path, HashAlgorithm method); + +#if defined(XP_WIN) + /** + * Return the Windows-specific file attributes of the file at the given path. + * + * @param path An absolute file path. + * + * @return A promise that resolves to the Windows-specific file attributes. + */ + [NewObject] + Promise<WindowsFileAttributes> getWindowsAttributes(DOMString path); + + /** + * Set the Windows-specific file attributes of the file at the given path. + * + * @param path An absolute file path. + * @param attrs The attributes to set. Attributes will only be set if they are + * |true| or |false| (i.e., |undefined| attributes are not + * changed). + * + * @return A promise that resolves is the attributes were set successfully. + */ + [NewObject] + Promise<undefined> setWindowsAttributes(DOMString path, optional WindowsFileAttributes attrs = {}); +#elif defined(XP_MACOSX) + /** + * Return whether or not the file has a specific extended attribute. + * + * @param path An absolute path. + * @param attr The attribute to check for. + * + * @return A promise that resolves to whether or not the file has an extended + * attribute, or rejects with an error. + */ + [NewObject] + Promise<boolean> hasMacXAttr(DOMString path, UTF8String attr); + /** + * Return the value of an extended attribute for a file. + * + * @param path An absolute path. + * @param attr The attribute to get the value of. + * + * @return A promise that resolves to the value of the extended attribute, or + * rejects with an error. + */ + [NewObject] + Promise<Uint8Array> getMacXAttr(DOMString path, UTF8String attr); + /** + * Set the extended attribute on a file. + * + * @param path An absolute path. + * @param attr The attribute to set. + * @param value The value of the attribute to set. + * + * @return A promise that resolves to whether or not the file has an extended + * attribute, or rejects with an error. + */ + [NewObject] + Promise<undefined> setMacXAttr(DOMString path, UTF8String attr, Uint8Array value); + /** + * Delete the extended attribute on a file. + * + * @param path An absolute path. + * @param attr The attribute to delete. + * + * @return A promise that resolves if the attribute was deleted, or rejects + * with an error. + */ + [NewObject] + Promise<undefined> delMacXAttr(DOMString path, UTF8String attr); +#endif + + /** + * Return a nsIFile whose parent directory exists. The parent directory of the + * file will be created off main thread if it does not already exist. + * + * @param components The path components. The first component must be an + * absolute path. + * + * @return A promise that resolves to an nsIFile for the requested file. + */ + [NewObject] + Promise<nsIFile> getFile(DOMString... components); + + /** + * Return an nsIFile corresponding to a directory. It will be created + * off-main-thread if it does not already exist. + * + * @param components The path components. The first component must be an + * absolute path. + * + * @return A promise that resolves to an nsIFile for the requested directory. + */ + [NewObject] + Promise<nsIFile> getDirectory(DOMString... components); +}; + +[Exposed=Window] +partial namespace IOUtils { + /** + * The async shutdown client for the profile-before-change shutdown phase. + */ + [Throws] + readonly attribute any profileBeforeChange; + + /** + * The async shutdown client for the profile-before-change-telemetry shutdown + * phase. + * + * ONLY telemetry should register blockers on this client. + */ + [Throws] + readonly attribute any sendTelemetry; +}; + +[Exposed=Worker] +partial namespace IOUtils { + /** + * Synchronously opens the file at |path|. This API is only available in workers. + * + * @param path An absolute file path. + * + * @return A |SyncReadFile| object for the file. + */ + [Throws] + SyncReadFile openFileForSyncReading(DOMString path); + +#ifdef XP_UNIX + /** + * Launch a child process; uses `base::LaunchApp` from IPC. (This WebIDL + * binding is currently Unix-only; it could also be supported on Windows + * but it would use u16-based strings, so it would basically be a separate + * copy of the bindings.) + * + * This interface was added for use by `Subprocess.sys.jsm`; other would-be + * callers may want to just use Subprocess instead of calling this directly. + * + * @param argv The command to run and its arguments. + * @param options Various parameters about how the child process is launched + * and its initial environment. + * + * @return The process ID. Note that various errors (e.g., the + * executable to be launched doesn't exist) may not be + * encountered until after the process is created, so a + * successful return doesn't necessarily imply a successful + * launch. + */ + [Throws] + unsigned long launchProcess(sequence<UnixString> argv, LaunchOptions options); +#endif +}; + +/** + * An object representing an open file, allowing parts of the file contents to be + * read synchronously. Only available in workers. + */ +[ChromeOnly, Exposed=Worker] +interface SyncReadFile { + /** + * The file size, in bytes. + */ + readonly attribute long long size; + + /** + * Synchronously read |dest.length| bytes at offset |offset| into |dest|. + * Throws if the file has been closed already or if the read would be out-of-bounds. + * + * @param dest A Uint8Array whose entire contents will be overwritten with + * bytes read from the file. + * @param offset The file offset at which the read range begins. (The length of the + * range is given by |dest.length|.) + */ + [Throws] + undefined readBytesInto(Uint8Array dest, long long offset); + + /** + * Close the file. Subsequent calls to readBytesInto will throw. + * If the file is not closed manually, it will be closed once this object is GC'ed. + */ + undefined close(); +}; + +/** + * Options to be passed to the |IOUtils.readUTF8| method. + */ +dictionary ReadUTF8Options { + /** + * If true, this option indicates that the file to be read is compressed with + * LZ4-encoding, and should be decompressed before the data is returned to + * the caller. + */ + boolean decompress = false; +}; + +/** + * Options to be passed to the |IOUtils.read| method. + */ +dictionary ReadOptions : ReadUTF8Options { + /** + * The offset into the file to read from. If unspecified, the file will be read + * from the start. + */ + unsigned long long offset = 0; + + /** + * The max bytes to read from the file at path. If unspecified, the entire + * file will be read. This option is incompatible with |decompress|. + */ + unsigned long? maxBytes = null; +}; + +/** + * Modes for writing to a file. + */ +enum WriteMode { + /** + * Overwrite the contents of the file. + * + * The file will be created if it does not exist. + */ + "overwrite", + /** + * Append to the end of the file. + * + * This mode will refuse to create the file if it does not exist. + */ + "append", + /** + * Append to the end of the file, or create it if it does not exist. + */ + "appendOrCreate", + /** + * Create a new file. + * + * This mode will refuse to overwrite an existing file. + */ + "create", +}; + +/** + * Options to be passed to the |IOUtils.write| and |writeUTF8| + * methods. + */ +dictionary WriteOptions { + /** + * If specified, backup the destination file to this path before writing. + */ + DOMString backupFile; + /** + * If specified, write the data to a file at |tmpPath| instead of directly to + * the destination. Once the write is complete, the destination will be + * overwritten by a move. Specifying this option will make the write a little + * slower, but also safer. + */ + DOMString tmpPath; + /** + * The mode used to write to the file. + */ + WriteMode mode = "overwrite"; + /** + * If true, force the OS to write its internal buffers to the disk. + * This is considerably slower for the whole system, but safer in case of + * an improper system shutdown (e.g. due to a kernel panic) or device + * disconnection before the buffers are flushed. + */ + boolean flush = false; + /** + * If true, compress the data with LZ4-encoding before writing to the file. + */ + boolean compress = false; +}; + +/** + * Options to be passed to the |IOUtils.move| method. + */ +dictionary MoveOptions { + /** + * If true, fail if the destination already exists. + */ + boolean noOverwrite = false; +}; + +/** + * Options to be passed to the |IOUtils.remove| method. + */ +dictionary RemoveOptions { + /** + * If true, no error will be reported if the target file is missing. + */ + boolean ignoreAbsent = true; + /** + * If true, and the target is a directory, recursively remove files. + */ + boolean recursive = false; +}; + +/** + * Options to be passed to the |IOUtils.makeDirectory| method. + */ +dictionary MakeDirectoryOptions { + /** + * If true, create the directory and all necessary ancestors if they do not + * already exist. If false and any ancestor directories do not exist, + * |makeDirectory| will reject with an error. + */ + boolean createAncestors = true; + /** + * If true, succeed even if the directory already exists (default behavior). + * Otherwise, fail if the directory already exists. + */ + boolean ignoreExisting = true; + /** + * The file mode to create the directory with. + * + * This is ignored on Windows. + */ + unsigned long permissions = 0755; + +}; + +/** + * Options to be passed to the |IOUtils.copy| method. + */ +dictionary CopyOptions { + /** + * If true, fail if the destination already exists. + */ + boolean noOverwrite = false; + /** + * If true, copy the source recursively. + */ + boolean recursive = false; +}; + +/** + * Options to be passed to the |IOUtils.getChildren| method. + */ +dictionary GetChildrenOptions { + /** + * If true, no error will be reported if the target file is missing. + */ + boolean ignoreAbsent = false; +}; + +/** + * Types of files that are recognized by the |IOUtils.stat| method. + */ +enum FileType { "regular", "directory", "other" }; + +/** + * Basic metadata about a file. + */ +dictionary FileInfo { + /** + * The absolute path to the file on disk, as known when this file info was + * obtained. + */ + DOMString path; + + /** + * Identifies if the file at |path| is a regular file, directory, or something + * something else. + */ + FileType type; + + /** + * If this represents a regular file, the size of the file in bytes. + * Otherwise, -1. + */ + long long size; + + /** + * The timestamp of file creation, represented in milliseconds since Epoch + * (1970-01-01T00:00:00.000Z). + * + * This is only available on MacOS and Windows. + */ + long long creationTime; + + /** + * The timestmp of last file accesss, represented in milliseconds since Epoch + * (1970-01-01T00:00:00.000Z). + */ + long long lastAccessed; + + /** + * The timestamp of the last file modification, represented in milliseconds + * since Epoch (1970-01-01T00:00:00.000Z). + */ + long long lastModified; + + /** + * The permissions of the file, expressed as a UNIX file mode. + * + * NB: Windows does not make a distinction between user, group, and other + * permissions like UNICES do. The user, group, and other parts will always + * be identical on Windows. + */ + unsigned long permissions; +}; + +/** + * The supported hash algorithms for |IOUtils.hashFile|. + */ +enum HashAlgorithm { "sha1", "sha256", "sha384", "sha512" }; + +#ifdef XP_WIN +/** + * Windows-specific file attributes. + */ +dictionary WindowsFileAttributes { + /** + * Whether or not the file is read-only. + */ + boolean readOnly; + /** + * Whether or not the file is hidden. + */ + boolean hidden; + /** + * Whether or not the file is classified as a system file. + */ + boolean system; +}; +#endif + +#ifdef XP_UNIX +/** + * Used where the POSIX API allows an arbitrary byte string but in + * practice it's usually UTF-8, so JS strings are accepted for + * convenience. + */ +typedef (UTF8String or Uint8Array) UnixString; + +/** + * Options for the `launchApp` method. See also `base::LaunchOptions` + * in C++. + */ +dictionary LaunchOptions { + /** + * The environment variables, as a sequence of `NAME=value` strings. + * (The underlying C++ code can also inherit the current environment + * with optional changes; that feature could be added here if needed.) + */ + required sequence<UnixString> environment; + + /** + * The initial current working directory. + */ + UnixString workdir; + + /** + * File descriptors to pass to the child process. Any fds not + * mentioned here, other than stdin/out/err, will not be inherited + * even if they aren't marked close-on-exec. + */ + sequence<FdMapping> fdMap; + + /** + * On macOS 10.14+, disclaims responsibility for the child process + * with respect to privacy/security permission prompts and + * decisions. Ignored if not supported by the OS. + */ + boolean disclaim = false; +}; + +/** + * Describes a file descriptor to give to the child process. + */ +dictionary FdMapping { + /** + * The fd in the parent process to pass. This must remain open during + * the call to `launchApp` but can be closed after it returns (or throws). + */ + required unsigned long src; + + /** + * The fd number to map it to in the child process. + */ + required unsigned long dst; +}; +#endif diff --git a/dom/chrome-webidl/ImageText.webidl b/dom/chrome-webidl/ImageText.webidl new file mode 100644 index 0000000000..262a82b353 --- /dev/null +++ b/dom/chrome-webidl/ImageText.webidl @@ -0,0 +1,29 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/** + * Text that has been extracted from an image using an image recognition API. + */ +dictionary ImageText { + /** + * A scalar value representing how confident the text recognition model was in the + * produced result. + */ + required float confidence; + + /** + * The recognized text. + */ + required DOMString string; + + /** + * A DOMQuad representing the bounds of the text. This can be a free-form four pointed + * polygon, and not necessarily a square or parallelogram. It does not actually contain + * CSSPixels, but the points are ranged 0-1 and represent a ratio of the width / height + * of the source image. + */ + required DOMQuad quad; +}; diff --git a/dom/chrome-webidl/InspectorUtils.webidl b/dom/chrome-webidl/InspectorUtils.webidl new file mode 100644 index 0000000000..1a17250dc0 --- /dev/null +++ b/dom/chrome-webidl/InspectorUtils.webidl @@ -0,0 +1,188 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/** + * A collection of utility methods for use by devtools. + * + * See InspectorUtils.h for documentation on these methods. + */ +[Func="nsContentUtils::IsCallerChromeOrFuzzingEnabled", + Exposed=Window] +namespace InspectorUtils { + // documentOnly tells whether user and UA sheets should get included. + sequence<StyleSheet> getAllStyleSheets(Document document, optional boolean documentOnly = false); + sequence<CSSStyleRule> getCSSStyleRules( + Element element, + optional [LegacyNullToEmptyString] DOMString pseudo = "", + optional boolean relevantLinkVisited = false); + unsigned long getRuleLine(CSSRule rule); + unsigned long getRuleColumn(CSSRule rule); + unsigned long getRelativeRuleLine(CSSRule rule); + boolean hasRulesModifiedByCSSOM(CSSStyleSheet sheet); + unsigned long getSelectorCount(CSSStyleRule rule); + [Throws] UTF8String getSelectorText(CSSStyleRule rule, + unsigned long selectorIndex); + [Throws] unsigned long long getSpecificity(CSSStyleRule rule, + unsigned long selectorIndex); + [Throws] boolean selectorMatchesElement( + Element element, + CSSStyleRule rule, + unsigned long selectorIndex, + optional [LegacyNullToEmptyString] DOMString pseudo = "", + optional boolean includeVisitedStyle = false); + boolean isInheritedProperty(UTF8String property); + sequence<DOMString> getCSSPropertyNames(optional PropertyNamesOptions options = {}); + sequence<PropertyPref> getCSSPropertyPrefs(); + [Throws] sequence<DOMString> getCSSValuesForProperty(UTF8String property); + [Throws] DOMString rgbToColorName(octet r, octet g, octet b); + InspectorRGBATuple? colorToRGBA(UTF8String colorString, optional Document? doc = null); + boolean isValidCSSColor(UTF8String colorString); + [Throws] sequence<DOMString> getSubpropertiesForCSSProperty(UTF8String property); + [Throws] boolean cssPropertyIsShorthand(UTF8String property); + + [Throws] boolean cssPropertySupportsType(UTF8String property, InspectorPropertyType type); + + // A version of CSS.supports that allows you to set UA or chrome context. + boolean supports(UTF8String conditionText, optional SupportsOptions options = {}); + + boolean isIgnorableWhitespace(CharacterData dataNode); + Node? getParentForNode(Node node, boolean showingAnonymousContent); + [NewObject] NodeList getChildrenForNode(Node node, + boolean showingAnonymousContent); + [Throws] boolean setContentState(Element element, unsigned long long state); + [Throws] boolean removeContentState( + Element element, + unsigned long long state, + optional boolean clearActiveDocument = false); + unsigned long long getContentState(Element element); + + // Get the font face(s) actually used to render the text in /range/, + // as a collection of InspectorFontFace objects (below). + // If /maxRanges/ is greater than zero, each InspectorFontFace will record + // up to /maxRanges/ fragments of content that used the face, for the caller + // to access via its .ranges attribute. + [NewObject, Throws] sequence<InspectorFontFace> getUsedFontFaces( + Range range, + optional unsigned long maxRanges = 0, + optional boolean skipCollapsedWhitespace = true); + + sequence<DOMString> getCSSPseudoElementNames(); + undefined addPseudoClassLock(Element element, + DOMString pseudoClass, + optional boolean enabled = true); + undefined removePseudoClassLock(Element element, DOMString pseudoClass); + boolean hasPseudoClassLock(Element element, DOMString pseudoClass); + undefined clearPseudoClassLocks(Element element); + [Throws] undefined parseStyleSheet(CSSStyleSheet sheet, UTF8String input); + boolean isCustomElementName([LegacyNullToEmptyString] DOMString name, + DOMString? namespaceURI); + + boolean isElementThemed(Element element); + + Element? containingBlockOf(Element element); + + [NewObject] NodeList getOverflowingChildrenOfElement(Element element); +}; + +dictionary SupportsOptions { + boolean userAgent = false; + boolean chrome = false; + boolean quirks = false; +}; + +dictionary PropertyNamesOptions { + boolean includeAliases = false; + boolean includeShorthands = true; + boolean includeExperimentals = false; +}; + +dictionary PropertyPref { + required DOMString name; + required DOMString pref; +}; + +dictionary InspectorRGBATuple { + /* + * NOTE: This tuple is in the normal 0-255-sized RGB space but can be + * fractional and may extend outside the 0-255 range. + * + * a is in the range 0 - 1. + */ + double r = 0; + double g = 0; + double b = 0; + double a = 1; +}; + +// Any update to this enum should probably also update +// devtools/shared/css/constants.js +enum InspectorPropertyType { + "color", + "gradient", + "timing-function", +}; + +dictionary InspectorVariationAxis { + required DOMString tag; + required DOMString name; + required float minValue; + required float maxValue; + required float defaultValue; +}; + +dictionary InspectorVariationValue { + required DOMString axis; + required float value; +}; + +dictionary InspectorVariationInstance { + required DOMString name; + required sequence<InspectorVariationValue> values; +}; + +dictionary InspectorFontFeature { + required DOMString tag; + required DOMString script; + required DOMString languageSystem; +}; + +[Func="nsContentUtils::IsCallerChromeOrFuzzingEnabled", + Exposed=Window] +interface InspectorFontFace { + // An indication of how we found this font during font-matching. + // Note that the same physical font may have been found in multiple ways within a range. + readonly attribute boolean fromFontGroup; + readonly attribute boolean fromLanguagePrefs; + readonly attribute boolean fromSystemFallback; + + // available for all fonts + readonly attribute DOMString name; // full font name as obtained from the font resource + readonly attribute DOMString CSSFamilyName; // a family name that could be used in CSS font-family + // (not necessarily the actual name that was used, + // due to aliases, generics, localized names, etc) + readonly attribute DOMString CSSGeneric; // CSS generic (serif, sans-serif, etc) that was mapped + // to this font, if any (frequently empty!) + + [NewObject,Throws] sequence<InspectorVariationAxis> getVariationAxes(); + [NewObject,Throws] sequence<InspectorVariationInstance> getVariationInstances(); + [NewObject,Throws] sequence<InspectorFontFeature> getFeatures(); + + // A list of Ranges of text rendered with this face. + // This will list the first /maxRanges/ ranges found when InspectorUtils.getUsedFontFaces + // was called (so it will be empty unless a non-zero maxRanges argument was passed). + // Note that this indicates how the document was rendered at the time of calling + // getUsedFontFaces; it does not reflect any subsequent modifications, so if styles + // have been modified since calling getUsedFontFaces, it may no longer be accurate. + [Constant,Cached] readonly attribute sequence<Range> ranges; + + // meaningful only when the font is a user font defined using @font-face + readonly attribute CSSFontFaceRule? rule; // null if no associated @font-face rule + readonly attribute long srcIndex; // index in the rule's src list, -1 if no @font-face rule + readonly attribute DOMString URI; // empty string if not a downloaded font, i.e. local + readonly attribute DOMString localName; // empty string if not a src:local(...) rule + readonly attribute DOMString format; // as per http://www.w3.org/TR/css3-webfonts/#referencing + readonly attribute DOMString metadata; // XML metadata from WOFF file (if any) +}; diff --git a/dom/chrome-webidl/IteratorResult.webidl b/dom/chrome-webidl/IteratorResult.webidl new file mode 100644 index 0000000000..b066ab409b --- /dev/null +++ b/dom/chrome-webidl/IteratorResult.webidl @@ -0,0 +1,15 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +/** + * A dictionary which represents the result of a call to a next() method on a + * JS iterator object. + */ +[GenerateConversionToJS, GenerateInit] +dictionary IteratorResult { + required boolean done; + any value; +}; diff --git a/dom/chrome-webidl/JSActor.webidl b/dom/chrome-webidl/JSActor.webidl new file mode 100644 index 0000000000..db73fb7994 --- /dev/null +++ b/dom/chrome-webidl/JSActor.webidl @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +interface mixin JSActor { + [Throws] + undefined sendAsyncMessage(DOMString messageName, + optional any obj); + + [NewObject] + Promise<any> sendQuery(DOMString messageName, + optional any obj); + + readonly attribute UTF8String name; +}; + +/** + * WebIDL callback interface version of the nsIObserver interface for use when + * calling the observe method on JSActors. + * + * NOTE: This isn't marked as ChromeOnly, as it has no interface object, and + * thus cannot be conditionally exposed. + */ +[Exposed=Window] +callback interface MozObserverCallback { + undefined observe(nsISupports subject, ByteString topic, DOMString? data); +}; + +/** + * WebIDL callback interface calling the `didDestroy`, and + * `actorCreated` methods on JSActors. + */ +[MOZ_CAN_RUN_SCRIPT_BOUNDARY] +callback MozJSActorCallback = undefined(); + +/** + * The didDestroy method, if present, will be called after the actor is no + * longer able to receive any more messages. + * The actorCreated method, if present, will be called immediately after the + * actor has been created and initialized. + */ +[GenerateInit] +dictionary MozJSActorCallbacks { + [ChromeOnly] MozJSActorCallback didDestroy; + [ChromeOnly] MozJSActorCallback actorCreated; +}; diff --git a/dom/chrome-webidl/JSProcessActor.webidl b/dom/chrome-webidl/JSProcessActor.webidl new file mode 100644 index 0000000000..13a7062427 --- /dev/null +++ b/dom/chrome-webidl/JSProcessActor.webidl @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * An actor architecture designed to allow compositional parent/content + * communications. The lifetime of a JSProcessActor{Child, Parent} is the `ContentParent` + * (for the parent-side) / `ContentChild` (for the child-side). + */ + +interface nsISupports; + +/** + * Base class for parent-side actor. + */ +[ChromeOnly, Exposed=Window] +interface JSProcessActorParent { + [ChromeOnly] + constructor(); + + readonly attribute nsIDOMProcessParent manager; +}; +JSProcessActorParent includes JSActor; + +[ChromeOnly, Exposed=Window] +interface JSProcessActorChild { + [ChromeOnly] + constructor(); + + readonly attribute nsIDOMProcessChild manager; +}; +JSProcessActorChild includes JSActor; + + +/** + * Used by `ChromeUtils.registerProcessActor()` to register actors. + */ +dictionary ProcessActorOptions { + /** + * An array of remote type which restricts the actor is allowed to instantiate + * in specific process type. If this is defined, the prefix of process type + * matches the remote type by prefix match is allowed to instantiate, ex: if + * Fission is enabled, the prefix of process type will be `webIsolated`, it + * can prefix match remote type either `web` or `webIsolated`. If not passed, + * all content processes are allowed to instantiate the actor. + */ + sequence<UTF8String> remoteTypes; + + /** + * If this is set to `true`, allow this actor to be created for the parent + * process. + */ + boolean includeParent = false; + + /** This fields are used for configuring individual sides of the actor. */ + ProcessActorSidedOptions parent; + ProcessActorChildOptions child; +}; + +dictionary ProcessActorSidedOptions { + /** + * The JSM path which should be loaded for the actor on this side. + * + * Mutually exclusive with `esModuleURI`. + * + * If neither this nor `esModuleURI` is passed, the specified side cannot receive + * messages, but may send them using `sendAsyncMessage` or `sendQuery`. + */ + ByteString moduleURI; + + /** + * The ESM path which should be loaded for the actor on this side. + * + * Mutually exclusive with `moduleURI`. + * + * If neither this nor `moduleURI` is passed, the specified side cannot + * receive messages, but may send them using `sendAsyncMessage` or + * `sendQuery`. + */ + ByteString esModuleURI; +}; + +dictionary ProcessActorChildOptions : ProcessActorSidedOptions { + /** + * An array of observer topics to listen to. An observer will be added for each + * topic in the list. + * + * Unlike for JSWindowActor, observers are always invoked, and do not need to + * pass an inner or outer window as subject. + */ + sequence<ByteString> observers; +}; diff --git a/dom/chrome-webidl/JSWindowActor.webidl b/dom/chrome-webidl/JSWindowActor.webidl new file mode 100644 index 0000000000..767b4854c5 --- /dev/null +++ b/dom/chrome-webidl/JSWindowActor.webidl @@ -0,0 +1,186 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * An actor architecture designed to allow compositional parent/content + * communications. The lifetime of a JSWindowActor{Child, Parent} is the `WindowGlobalParent` + * (for the parent-side) / `WindowGlobalChild` (for the child-side). + * + * See https://firefox-source-docs.mozilla.org/dom/ipc/jsactors.html for + * more details on how to use this architecture. + */ + +interface nsISupports; + +[ChromeOnly, Exposed=Window] +interface JSWindowActorParent { + [ChromeOnly] + constructor(); + + /** + * Actor initialization occurs after the constructor is called but before the + * first message is delivered. Until the actor is initialized, accesses to + * manager will fail. + */ + readonly attribute WindowGlobalParent? manager; + + /** + * The WindowContext associated with this JSWindowActorParent. For + * JSWindowActorParent this is identical to `manager`, but is also exposed as + * `windowContext` for consistency with `JSWindowActorChild`. Until the actor + * is initialized, accesses to windowContext will fail. + */ + readonly attribute WindowContext? windowContext; + + [Throws] + readonly attribute CanonicalBrowsingContext? browsingContext; +}; +JSWindowActorParent includes JSActor; + +[ChromeOnly, Exposed=Window] +interface JSWindowActorChild { + [ChromeOnly] + constructor(); + + /** + * Actor initialization occurs after the constructor is called but before the + * first message is delivered. Until the actor is initialized, accesses to + * manager will fail. + */ + readonly attribute WindowGlobalChild? manager; + + /** + * The WindowContext associated with this JSWindowActorChild. Until the actor + * is initialized, accesses to windowContext will fail. + */ + readonly attribute WindowContext? windowContext; + + [Throws] + readonly attribute Document? document; + + [Throws] + readonly attribute BrowsingContext? browsingContext; + + [Throws] + readonly attribute nsIDocShell? docShell; + + /** + * NOTE: As this returns a window proxy, it may not be currently referencing + * the document associated with this JSWindowActor. Generally prefer using + * `document`. + */ + [Throws] + readonly attribute WindowProxy? contentWindow; +}; +JSWindowActorChild includes JSActor; + +/** + * Used by ChromeUtils.registerWindowActor() to register JS window actor. + */ +dictionary WindowActorOptions { + /** + * If this is set to `true`, allow this actor to be created for subframes, + * and not just toplevel window globals. + */ + boolean allFrames = false; + + /** + * If this is set to `true`, allow this actor to be created for window + * globals loaded in chrome browsing contexts, such as those used to load the + * tabbrowser. + */ + boolean includeChrome = false; + + /** + * An array of URL match patterns (as accepted by the MatchPattern + * class in MatchPattern.webidl) which restrict which pages the actor + * may be instantiated for. If this is defined, only documents URL which match + * are allowed to have the given actor created for them. Other + * documents will fail to have their actor constructed, returning nullptr. + */ + sequence<DOMString> matches; + + /** + * An array of remote type which restricts the actor is allowed to instantiate + * in specific process type. If this is defined, the prefix of process type + * matches the remote type by prefix match is allowed to instantiate, ex: if + * Fission is enabled, the prefix of process type will be `webIsolated`, it + * can prefix match remote type either `web` or `webIsolated`. If not passed, + * all content processes are allowed to instantiate the actor. + */ + sequence<UTF8String> remoteTypes; + + /** + * An array of MessageManagerGroup values which restrict which type + * of browser elements the actor is allowed to be loaded within. + */ + sequence<DOMString> messageManagerGroups; + + /** This fields are used for configuring individual sides of the actor. */ + WindowActorSidedOptions parent; + WindowActorChildOptions child; +}; + +dictionary WindowActorSidedOptions { + /** + * The JSM path which should be loaded for the actor on this side. + * + * Mutually exclusive with `esModuleURI`. + * + * If neither this nor `esModuleURI` is passed, the specified side cannot receive + * messages, but may send them using `sendAsyncMessage` or `sendQuery`. + */ + ByteString moduleURI; + + /** + * The ESM path which should be loaded for the actor on this side. + * + * Mutually exclusive with `moduleURI`. + * + * If neither this nor `moduleURI` is passed, the specified side cannot + * receive messages, but may send them using `sendAsyncMessage` or + * `sendQuery`. + */ + ByteString esModuleURI; +}; + +dictionary WindowActorEventListenerOptions : AddEventListenerOptions { + /** + * If this attribute is set to true (the default), this event will cause the + * actor to be created when it is fired. If the attribute is set false, the + * actor will not receive the event unless it had already been created through + * some other mechanism. + * + * This should be set to `false` for event listeners which are only intended + * to perform cleanup operations, and will have no effect if the actor doesn't + * already exist. + */ + boolean createActor = true; +}; + +dictionary WindowActorChildOptions : WindowActorSidedOptions { + /** + * Events which this actor wants to be listening to. When these events fire, + * it will trigger actor creation, and then forward the event to the actor. + * + * NOTE: Listeners are not attached for windows loaded in chrome docshells. + * + * NOTE: `once` option is not support due to we register listeners in a shared + * location. + */ + record<DOMString, WindowActorEventListenerOptions> events; + + /** + * An array of observer topics to listen to. An observer will be added for each + * topic in the list. + * + * Observer notifications in the list use nsGlobalWindowInner or + * nsGlobalWindowOuter object as their subject, and the events will only be + * dispatched to the corresponding window actor. If additional observer + * notification's subjects are needed, please file a bug for that. + */ + sequence<ByteString> observers; +}; diff --git a/dom/chrome-webidl/L10nOverlays.webidl b/dom/chrome-webidl/L10nOverlays.webidl new file mode 100644 index 0000000000..afe96cc58b --- /dev/null +++ b/dom/chrome-webidl/L10nOverlays.webidl @@ -0,0 +1,24 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +dictionary L10nOverlaysError { + short code; + DOMString translatedElementName; + DOMString sourceElementName; + DOMString l10nName; +}; + +[ChromeOnly, + Exposed=Window] +namespace L10nOverlays { + const unsigned short ERROR_UNKNOWN = 1; + const unsigned short ERROR_FORBIDDEN_TYPE = 2; + const unsigned short ERROR_NAMED_ELEMENT_MISSING = 3; + const unsigned short ERROR_NAMED_ELEMENT_TYPE_MISMATCH = 4; + const unsigned short ERROR_TRANSLATED_ELEMENT_DISCONNECTED = 5; + const unsigned short ERROR_TRANSLATED_ELEMENT_DISALLOWED_DOM = 6; + + sequence<L10nOverlaysError>? translateElement(Element element, optional L10nMessage translation = {}); +}; diff --git a/dom/chrome-webidl/L10nRegistry.webidl b/dom/chrome-webidl/L10nRegistry.webidl new file mode 100644 index 0000000000..81932b2cd7 --- /dev/null +++ b/dom/chrome-webidl/L10nRegistry.webidl @@ -0,0 +1,180 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +dictionary L10nFileSourceMockFile { + required UTF8String path; + required UTF8String source; +}; + +enum L10nFileSourceHasFileStatus { + "present", + "missing", + "unknown" +}; + +dictionary FileSourceOptions { + FluentBundleAddResourceOptions addResourceOptions = {}; +}; + +/** + * A `ResourceId` refers to a localization resource that is either required + * or optional. The default for a `ResourceId` is that the resource is required. + * + * If a required resource is missing for a given locale, then the L10nRegistry + * will not generate a bundle for that locale, because the resource is required + * to be present in order for the bundle to be considered valid. + * + * If an optional resource is missing for a given locale, then the L10nRegistry + * will still generate a bundle for that locale, but entries for the missing + * optional resource will be missing in the bundle. + * + * It is recommended to only use this sparingly, since marking many resources as + * optional will increase the state space that the L10nRegistry solver has to cover, + * and it will have a negative impact on performance. + * + * We should also strive to have valid resources for all supported locales, so using + * optional resources should be reserved for exceptional circumstances such as + * experimental features and features under development. + */ +dictionary ResourceId { + required UTF8String path; + boolean _optional = false; +}; + +typedef (UTF8String or ResourceId) L10nResourceId; + +/** + * The interface represents a single source location for + * the registry. + * + * Examples of sources are: + * * Toolkit omni.ja Localization Directory + * * Browser omni.ja Localization Directory + * * Language Pack Toolkit Localization Directory + * * Language Pack Browser Localization Directory + */ +[ChromeOnly, + Exposed=Window] +interface L10nFileSource { + /** + * The `name` is the name of the `L10nFileSource`. + * + * The `metaSource` is the name of the package that contains the + * `L10nFileSource`, e.g. `app` for sources packaged with the browser, or + * `langpack` for sources packaged in an addon. + * + * The `locales` is a list of locales for which resources are contained in + * the `L10nFileSource`. + * + * The `prePath` is the path prefix for files contained in the `L10nFileSource`. + * + * Optional argument `index` can be used to provide a list + * of files available in the source. + * + * This is particularly useful for custom file sources which + * provide a small number of known override files allowing the + * registry to avoid trying I/O on the source for all + * files not available in the source. + */ + [Throws] + constructor(UTF8String name, UTF8String metaSource, sequence<UTF8String> locales, UTF8String prePath, optional FileSourceOptions options = {}, optional sequence<UTF8String> index); + + /** + * Tests may want to introduce custom file sources and + * register them in a custom `L10nRegistry` to mock + * behavior of using localization with test file sources. + * + * # Example: + * + * ``` + * let fs = [ + * { + * "path": "/localization/en-US/test.ftl", + * "source": "key = Hello World!", + * } + * ]; + * let mockSource = L10nFileSource.createMock("mock", "app", ["en-US"], "/localization/{locale}/", fs); + * + * let reg = new L10nRegistry(); + * reg.registerSources([mockSource]); + * + * let loc = new Localization(["test.ftl"], reg); + * let value = await loc.formatValue("key"); + * assert(value, "Hello World!"); + * ``` + */ + [Throws] + static L10nFileSource createMock(UTF8String name, UTF8String metasource, sequence<UTF8String> locales, UTF8String prePath, sequence<L10nFileSourceMockFile> fs); + + readonly attribute UTF8String name; + readonly attribute UTF8String metaSource; + [Pure, Cached, Frozen] + readonly attribute sequence<UTF8String> locales; + /** + * `prePath` is the root path used together with a relative path to construct the full path used to retrieve a file + * out of a file source. + * + * The `prePath` will usually contain a placeholder `{locale}` which gets replaced with a given locale. + */ + readonly attribute UTF8String prePath; + [Pure, Cached, Frozen] + readonly attribute sequence<UTF8String>? index; + + [Throws] + L10nFileSourceHasFileStatus hasFile(UTF8String locale, UTF8String path); + [NewObject] + Promise<FluentResource?> fetchFile(UTF8String locale, UTF8String path); + [Throws] + FluentResource? fetchFileSync(UTF8String locale, UTF8String path); +}; + +dictionary FluentBundleIteratorResult +{ + required FluentBundle? value; + required boolean done; +}; + +[LegacyNoInterfaceObject, Exposed=Window] +interface FluentBundleIterator { + FluentBundleIteratorResult next(); + [Alias="@@iterator"] FluentBundleIterator values(); +}; + +[LegacyNoInterfaceObject, Exposed=Window] +interface FluentBundleAsyncIterator { + [NewObject] + Promise<FluentBundleIteratorResult> next(); + [Alias="@@asyncIterator"] FluentBundleAsyncIterator values(); +}; + +dictionary L10nRegistryOptions { + FluentBundleOptions bundleOptions = {}; +}; + +[ChromeOnly, Exposed=Window] +interface L10nRegistry { + constructor(optional L10nRegistryOptions aOptions = {}); + + static L10nRegistry getInstance(); + + sequence<UTF8String> getAvailableLocales(); + + undefined registerSources(sequence<L10nFileSource> aSources); + undefined updateSources(sequence<L10nFileSource> aSources); + undefined removeSources(sequence<UTF8String> aSources); + + [Throws] + boolean hasSource(UTF8String aName); + [Throws] + L10nFileSource? getSource(UTF8String aName); + sequence<UTF8String> getSourceNames(); + undefined clearSources(); + + [Throws, NewObject] + FluentBundleIterator generateBundlesSync(sequence<UTF8String> aLocales, sequence<L10nResourceId> aResourceIds); + + [Throws, NewObject] + FluentBundleAsyncIterator generateBundles(sequence<UTF8String> aLocales, sequence<L10nResourceId> aResourceIds); +}; diff --git a/dom/chrome-webidl/MatchGlob.webidl b/dom/chrome-webidl/MatchGlob.webidl new file mode 100644 index 0000000000..91554d21c4 --- /dev/null +++ b/dom/chrome-webidl/MatchGlob.webidl @@ -0,0 +1,26 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * Represents a simple glob pattern matcher. Any occurrence of "*" in the glob + * pattern matches any literal string of characters in the string being + * compared. Additionally, if created with `allowQuestion = true`, any + * occurrence of "?" in the glob matches any single literal character. + */ +[ChromeOnly, Exposed=Window] +interface MatchGlob { + [Throws] + constructor(UTF8String glob, optional boolean allowQuestion = true); + + /** + * Returns true if the string matches the glob. + */ + boolean matches(UTF8String string); + + /** + * The glob string this MatchGlob represents. + */ + [Constant] + readonly attribute UTF8String glob; +}; diff --git a/dom/chrome-webidl/MatchPattern.webidl b/dom/chrome-webidl/MatchPattern.webidl new file mode 100644 index 0000000000..4e75d39ba2 --- /dev/null +++ b/dom/chrome-webidl/MatchPattern.webidl @@ -0,0 +1,150 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +interface Cookie; +interface URI; + +/** + * A URL match pattern as used by the WebExtension and Chrome extension APIs. + * + * A match pattern is a string with one of the following formats: + * + * - "<all_urls>" + * The literal string "<all_urls>" matches any URL with a supported + * protocol. + * + * - <proto>://<host>/<path> + * A URL pattern with the following placeholders: + * + * - <proto> + * The protocol to match, or "*" to match either "http" or "https". + * - <host> + * The hostname to match. May be either a complete, literal hostname to + * match a specific host, the wildcard character "*", to match any host, + * or a subdomain pattern, with "*." followed by a domain name, to match + * that domain name or any subdomain thereof. + * - <path> + * A glob pattern for paths to match. A "*" may appear anywhere within + * the path, and will match any string of characters. If no "*" appears, + * the URL path must exactly match the pattern path. + */ +[ChromeOnly, Exposed=Window] +interface MatchPattern { + [Throws] + constructor(DOMString pattern, optional MatchPatternOptions options = {}); + + /** + * Returns true if the given URI matches the pattern. + * + * If explicit is true, only explicit domain matches, without wildcards, are + * considered. + */ + [Throws] + boolean matches(URI uri, optional boolean explicit = false); + + [Throws] + boolean matches(DOMString url, optional boolean explicit = false); + + /** + * Returns true if a URL exists which a) would be able to access the given + * cookie, and b) would be matched by this match pattern. + */ + boolean matchesCookie(Cookie cookie); + + /** + * Returns true if this pattern will match any host which would be matched + * by the given pattern. + */ + boolean subsumes(MatchPattern pattern); + + /** + * Returns true if this pattern will match any host which would be matched + * by the given pattern, ignoring the scheme. + */ + boolean subsumesDomain(MatchPattern pattern); + + /** + * Returns true if there is any host which would be matched by both this + * pattern and the given pattern. + */ + boolean overlaps(MatchPattern pattern); + + /** + * The match pattern string represented by this pattern. + */ + [Constant] + readonly attribute DOMString pattern; +}; + +/** + * A set of MatchPattern objects, which implements the MatchPattern API and + * matches when any of its sub-patterns matches. + */ +[ChromeOnly, Exposed=Window] +interface MatchPatternSet { + [Throws] + constructor(sequence<(DOMString or MatchPattern)> patterns, optional MatchPatternOptions options = {}); + + /** + * Returns true if the given URI matches any sub-pattern. + * + * If explicit is true, only explicit domain matches, without wildcards, are + * considered. + */ + [Throws] + boolean matches(URI uri, optional boolean explicit = false); + + [Throws] + boolean matches(DOMString url, optional boolean explicit = false); + + /** + * Returns true if any sub-pattern matches the given cookie. + */ + boolean matchesCookie(Cookie cookie); + + /** + * Returns true if any sub-pattern subsumes the given pattern. + */ + boolean subsumes(MatchPattern pattern); + + /** + * Returns true if any sub-pattern subsumes the given pattern, + * ignoring any of the schemes in the patterns. + */ + boolean subsumesDomain(MatchPattern pattern); + + /** + * Returns true if any sub-pattern overlaps the given pattern. + */ + boolean overlaps(MatchPattern pattern); + + /** + * Returns true if any sub-pattern overlaps any sub-pattern the given + * pattern set. + */ + boolean overlaps(MatchPatternSet patternSet); + + /** + * Returns true if any sub-pattern overlaps *every* sub-pattern in the given + * pattern set. + */ + boolean overlapsAll(MatchPatternSet patternSet); + + [Cached, Constant, Frozen] + readonly attribute sequence<MatchPattern> patterns; +}; + +dictionary MatchPatternOptions { + /** + * If true, the path portion of the pattern is ignored, and replaced with a + * wildcard. The `pattern` property is updated to reflect this. + */ + boolean ignorePath = false; + + /** + * If true, the set of schemes this pattern can match is restricted to + * those accessible by WebExtensions. + */ + boolean restrictSchemes = true; +}; diff --git a/dom/chrome-webidl/MediaController.webidl b/dom/chrome-webidl/MediaController.webidl new file mode 100644 index 0000000000..b16282877a --- /dev/null +++ b/dom/chrome-webidl/MediaController.webidl @@ -0,0 +1,75 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/** + * This enum lists all supported behaviors on the media controller. + */ +enum MediaControlKey { + "focus", + "play", + "pause", + "playpause", + "previoustrack", + "nexttrack", + "seekbackward", + "seekforward", + "skipad", + "seekto", + "stop", +}; + +/** + * MediaController is used to control media playback for a tab, and each tab + * would only have one media controller, which can be accessed from the + * canonical browsing context. + */ +[Exposed=Window, ChromeOnly] +interface MediaController : EventTarget { + readonly attribute unsigned long long id; + readonly attribute boolean isActive; + readonly attribute boolean isAudible; + readonly attribute boolean isPlaying; + readonly attribute MediaSessionPlaybackState playbackState; + + [Throws] + MediaMetadataInit getMetadata(); + + [Frozen, Cached, Pure] + readonly attribute sequence<MediaControlKey> supportedKeys; + + attribute EventHandler onactivated; + attribute EventHandler ondeactivated; + + // Following events would only be dispatched after controller is active. + attribute EventHandler onmetadatachange; + attribute EventHandler onplaybackstatechange; + attribute EventHandler onpositionstatechange; + attribute EventHandler onsupportedkeyschange; + + undefined focus(); + undefined play(); + undefined pause(); + undefined stop(); + undefined prevTrack(); + undefined nextTrack(); + undefined seekBackward(); + undefined seekForward(); + undefined skipAd(); + undefined seekTo(double seekTime, optional boolean fastSeek = false); +}; + +[ChromeOnly,Exposed=Window,HeaderFile="mozilla/dom/MediaControlService.h"] +namespace MediaControlService { + // This is used to generate fake media control keys event in testing. + undefined generateMediaControlKey(MediaControlKey aKey); + + // This is used to get the media metadata from the current main controller in + // testing. + MediaMetadataInit getCurrentActiveMediaMetadata(); + + // This is used to get the actual media playback state from the current main + // controller in testing. + MediaSessionPlaybackState getCurrentMediaSessionPlaybackState(); +}; diff --git a/dom/chrome-webidl/MessageManager.webidl b/dom/chrome-webidl/MessageManager.webidl new file mode 100644 index 0000000000..d77f1751ee --- /dev/null +++ b/dom/chrome-webidl/MessageManager.webidl @@ -0,0 +1,576 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +interface nsIEventTarget; +interface Principal; + +/** + * Message managers provide a way for chrome-privileged JS code to + * communicate with each other, even across process boundaries. + * + * Message managers are separated into "parent side" and "child side". + * These don't always correspond to process boundaries, but can. For + * each child-side message manager, there is always exactly one + * corresponding parent-side message manager that it sends messages + * to. However, for each parent-side message manager, there may be + * either one or many child-side managers it can message. + * + * Message managers that always have exactly one "other side" are of + * type MessageSender. Parent-side message managers that have many + * "other sides" are of type MessageBroadcaster. + * + * Child-side message managers can send synchronous messages to their + * parent side, but not the other way around. + * + * There are two realms of message manager hierarchies. One realm + * approximately corresponds to DOM elements, the other corresponds to + * process boundaries. + * + * Message managers corresponding to DOM elements + * ============================================== + * + * In this realm of message managers, there are + * - "frame message managers" which correspond to frame elements + * - "window message managers" which correspond to top-level chrome + * windows + * - "group message managers" which correspond to named message + * managers with a specific window MM as the parent + * - the "global message manager", on the parent side. See below. + * + * The DOM-realm message managers can communicate in the ways shown by + * the following diagram. The parent side and child side can + * correspond to process boundaries, but don't always. + * + * Parent side Child side + * ------------- ------------ + * global MMg + * | + * +-->window MMw1 + * | | + * | +-->frame MMp1_1<------------>frame MMc1_1 + * | | + * | +-->frame MMp1_2<------------>frame MMc1_2 + * | | + * | +-->group MMgr1 + * | | | + * | | +-->frame MMp2_1<------->frame MMc2_1 + * | | | + * | | +-->frame MMp2_2<------->frame MMc2_2 + * | | + * | +-->group MMgr2 + * | | ... + * | | + * | ... + * | + * +-->window MMw2 + * ... + * + * For example: a message sent from MMc1_1, from the child side, is + * sent only to MMp1_1 on the parent side. However, note that all + * message managers in the hierarchy above MMp1_1, in this diagram + * MMw1 and MMg, will also notify their message listeners when the + * message arrives. + * + * A message sent from MMc2_1 will be sent to MMp2_1 and also notify + * all message managers in the hierarchy above that, including the + * group message manager MMgr1. + + * For example: a message broadcast through the global MMg on the + * parent side would be broadcast to MMw1, which would transitively + * broadcast it to MMp1_1, MM1p_2. The message would next be + * broadcast to MMgr1, which would broadcast it to MMp2_1 and MMp2_2. + * After that it would broadcast to MMgr2 and then to MMw2, and so + * on down the hierarchy. + * + * ***** PERFORMANCE AND SECURITY WARNING ***** + * Messages broadcast through the global MM and window or group MMs + * can result in messages being dispatched across many OS processes, + * and to many processes with different permissions. Great care + * should be taken when broadcasting. + * + * Interfaces + * ---------- + * + * The global MMg and window MMw's are message broadcasters implementing + * MessageBroadcaster while the frame MMp's are simple message senders (MessageSender). + * Their counterparts in the content processes are message senders implementing + * ContentFrameMessageManager. + * + * MessageListenerManager + * / \ + * MessageSender MessageBroadcaster + * | + * SyncMessageSender (content process/in-process only) + * | + * ContentFrameMessageManager (content process/in-process only) + * | + * nsIInProcessContentFrameMessageManager (in-process only) + * + * + * Message managers in the chrome process also implement FrameScriptLoader. + * + * + * Message managers corresponding to process boundaries + * ==================================================== + * + * The second realm of message managers is the "process message + * managers". With one exception, these always correspond to process + * boundaries. The picture looks like + * + * Parent process Child processes + * ---------------- ----------------- + * global (GPPMM) + * | + * +-->parent in-process PIPMM<-->child in-process CIPPMM + * | + * +-->parent (PPMM1)<------------------>child (CPMM1) + * | + * +-->parent (PPMM2)<------------------>child (CPMM2) + * ... + * + * Note, PIPMM and CIPPMM both run in the parent process. + * + * For example: the parent-process PPMM1 sends messages to the + * child-process CPMM1. + * + * For example: CPMM1 sends messages directly to PPMM1. The global GPPMM + * will also notify their message listeners when the message arrives. + * + * For example: messages sent through the global GPPMM will be + * dispatched to the listeners of the same-process, CIPPMM, CPMM1, + * CPMM2, etc. + * + * ***** PERFORMANCE AND SECURITY WARNING ***** + * Messages broadcast through the GPPMM can result in messages + * being dispatched across many OS processes, and to many processes + * with different permissions. Great care should be taken when + * broadcasting. + * + * Requests sent to parent-process message listeners should usually + * have replies scoped to the requesting CPMM. The following pattern + * is common + * + * const ParentProcessListener = { + * receiveMessage: function(aMessage) { + * switch (aMessage.name) { + * case "Foo:Request": + * // service request + * aMessage.target.sendAsyncMessage("Foo:Response", { data }); + * } + * } + * }; + */ + +dictionary ReceiveMessageArgument +{ + /** + * The target of the message. Either an element owning the message manager, or message + * manager itself if no element owns it. + */ + required nsISupports target; + + /** + * Message name. + */ + required DOMString name; + + required boolean sync; + + /** + * Structured clone of the sent message data + */ + any data = null; + + /** + * Same as .data, deprecated. + */ + any json = null; + + sequence<MessagePort> ports; + + FrameLoader targetFrameLoader; +}; + +[Exposed=Window] +callback interface MessageListener +{ + /** + * Each listener is invoked with its own copy of the message + * parameter. + * + * When the listener is called, 'this' value is the target of the message. + * + * If the message is synchronous, the possible return value is + * returned as JSON (will be changed to use structured clones). + * When there are multiple listeners to sync messages, each + * listener's return value is sent back as an array. |undefined| + * return values show up as undefined values in the array. + */ + any receiveMessage(ReceiveMessageArgument argument); +}; + +[ChromeOnly, Exposed=Window] +interface MessageListenerManager +{ + // All the methods are pulled in via mixin. +}; +MessageListenerManager includes MessageListenerManagerMixin; + +interface mixin MessageListenerManagerMixin +{ + /** + * Register |listener| to receive |messageName|. All listener + * callbacks for a particular message are invoked when that message + * is received. + * + * The message manager holds a strong ref to |listener|. + * + * If the same listener registers twice for the same message, the + * second registration is ignored. + * + * Pass true for listenWhenClosed if you want to receive messages + * during the short period after a frame has been removed from the + * DOM and before its frame script has finished unloading. This + * parameter only has an effect for frame message managers in + * the main process. Default is false. + */ + [Throws] + undefined addMessageListener(DOMString messageName, + MessageListener listener, + optional boolean listenWhenClosed = false); + + /** + * Undo an |addMessageListener| call -- that is, calling this causes us to no + * longer invoke |listener| when |messageName| is received. + * + * removeMessageListener does not remove a message listener added via + * addWeakMessageListener; use removeWeakMessageListener for that. + */ + [Throws] + undefined removeMessageListener(DOMString messageName, + MessageListener listener); + + /** + * This is just like addMessageListener, except the message manager holds a + * weak ref to |listener|. + * + * If you have two weak message listeners for the same message, they may be + * called in any order. + */ + [Throws] + undefined addWeakMessageListener(DOMString messageName, + MessageListener listener); + + /** + * This undoes an |addWeakMessageListener| call. + */ + [Throws] + undefined removeWeakMessageListener(DOMString messageName, + MessageListener listener); +}; + +/** + * Message "senders" have a single "other side" to which messages are + * sent. For example, a child-process message manager will send + * messages that are only delivered to its one parent-process message + * manager. + */ +[ChromeOnly, Exposed=Window] +interface MessageSender : MessageListenerManager +{ + // All the methods are pulled in via mixin. +}; +MessageSender includes MessageSenderMixin; + +/** + * Anyone including this MUST also incude MessageListenerManagerMixin. + */ +interface mixin MessageSenderMixin { + /** + * Send |messageName| and |obj| to the "other side" of this message + * manager. This invokes listeners who registered for + * |messageName|. + * + * See ReceiveMessageArgument for the format of the data delivered to listeners. + * @throws NS_ERROR_NOT_INITIALIZED if the sender is not initialized. For + * example, we will throw NS_ERROR_NOT_INITIALIZED if we try to send + * a message to a cross-process frame but the other process has not + * yet been set up. + * @throws NS_ERROR_FAILURE when the message receiver cannot be found. For + * example, we will throw NS_ERROR_FAILURE if we try to send a message + * to a cross-process frame whose process has crashed. + */ + [Throws] + undefined sendAsyncMessage(optional DOMString? messageName = null, + optional any obj, + optional any transfers); + + /** + * For remote browsers there is always a corresponding process message + * manager. The intention of this attribute is to link leaf level frame + * message managers on the parent side with the corresponding process + * message managers (if there is one). For any other cases this property + * is null. + */ + [Throws] + readonly attribute MessageSender? processMessageManager; + + /** + * For remote browsers, this contains the remoteType of the content child. + * Otherwise, it is empty. + */ + [Throws] + readonly attribute UTF8String remoteType; +}; + +[ChromeOnly, Exposed=Window] +interface SyncMessageSender : MessageSender +{ + // All the methods are pulled in via mixin. +}; +SyncMessageSender includes SyncMessageSenderMixin; + +/** + * Anyone including this MUST also incude MessageSenderMixin. + */ +interface mixin SyncMessageSenderMixin +{ + /** + * Like |sendAsyncMessage()|, except blocks the sender until all + * listeners of the message have been invoked. Returns an array + * containing return values from each listener invoked. + */ + [Throws] + sequence<any> sendSyncMessage(optional DOMString? messageName = null, + optional any obj); +}; + +/** + * ChildProcessMessageManager is used in a child process to communicate with the parent + * process. + */ +[ChromeOnly, Exposed=Window] +interface ChildProcessMessageManager : SyncMessageSender +{ +}; + +/** + * Mixin for message manager globals. Anyone including this MUST also + * include SyncMessageSenderMixin. + */ +interface mixin MessageManagerGlobal +{ + /** + * Print a string to stdout. + */ + undefined dump(DOMString str); + + /** + * Ascii base64 data to binary data and vice versa + */ + [Throws] + DOMString atob(DOMString asciiString); + [Throws] + DOMString btoa(DOMString base64Data); +}; + +interface mixin FrameScriptLoader +{ + /** + * Load a script in the (remote) frame. |url| must be the absolute URL. + * data: URLs are also supported. For example data:,dump("foo\n"); + * If allowDelayedLoad is true, script will be loaded when the + * remote frame becomes available. Otherwise the script will be loaded + * only if the frame is already available. + */ + [Throws] + undefined loadFrameScript(DOMString url, boolean allowDelayedLoad, + optional boolean runInGlobalScope = false); + + /** + * Removes |url| from the list of scripts which support delayed load. + */ + undefined removeDelayedFrameScript(DOMString url); + + /** + * Returns all delayed scripts that will be loaded once a (remote) + * frame becomes available. The return value is a list of pairs + * [<URL>, <WasLoadedInGlobalScope>]. + */ + [Throws] + sequence<sequence<any>> getDelayedFrameScripts(); +}; + +interface mixin ProcessScriptLoader +{ + /** + * Load a script in the (possibly remote) process. |url| must be the absolute + * URL. data: URLs are also supported. For example data:,dump("foo\n"); + * If allowDelayedLoad is true, script will be loaded when the + * remote frame becomes available. Otherwise the script will be loaded + * only if the frame is already available. + */ + [Throws] + undefined loadProcessScript(DOMString url, boolean allowDelayedLoad); + + /** + * Removes |url| from the list of scripts which support delayed load. + */ + undefined removeDelayedProcessScript(DOMString url); + + /** + * Returns all delayed scripts that will be loaded once a (remote) + * frame becomes available. The return value is a list of pairs + * [<URL>, <WasLoadedInGlobalScope>]. + */ + [Throws] + sequence<sequence<any>> getDelayedProcessScripts(); +}; + +/** + * Anyone including GlobalProcessScriptLoader MUST also include ProcessScriptLoader. + */ +interface mixin GlobalProcessScriptLoader +{ + /** + * Allows the parent process to set the initial process data for + * new, not-yet-created child processes. This attribute should only + * be used by the global parent process message manager. When a new + * process is created, it gets a copy of this data (via structured + * cloning). It can access the data via the initialProcessData + * attribute of its childprocessmessagemanager. + * + * This value will always be a JS object if it's not null or undefined. Different + * users are expected to set properties on this object. The property name should be + * unique enough that other Gecko consumers won't accidentally choose it. + */ + [Throws] + readonly attribute any initialProcessData; + + readonly attribute MozWritableSharedMap sharedData; +}; + +[ChromeOnly, Exposed=Window] +interface ContentFrameMessageManager : EventTarget +{ + /** + * The current top level window in the frame or null. + */ + [Throws] + readonly attribute WindowProxy? content; + + /** + * The top level docshell or null. + */ + [Throws] + readonly attribute nsIDocShell? docShell; + + /** + * Returns the SchedulerEventTarget corresponding to the TabGroup + * for this frame. + */ + readonly attribute nsIEventTarget? tabEventTarget; + +}; +ContentFrameMessageManager includes MessageManagerGlobal; +ContentFrameMessageManager includes SyncMessageSenderMixin; +ContentFrameMessageManager includes MessageSenderMixin; +ContentFrameMessageManager includes MessageListenerManagerMixin; + +[ChromeOnly, Exposed=Window] +interface ContentProcessMessageManager +{ + /** + * Read out a copy of the object that was initialized in the parent + * process via ProcessScriptLoader.initialProcessData. + */ + [Throws] + readonly attribute any initialProcessData; + + readonly attribute MozSharedMap? sharedData; +}; +ContentProcessMessageManager includes MessageManagerGlobal; +ContentProcessMessageManager includes SyncMessageSenderMixin; +ContentProcessMessageManager includes MessageSenderMixin; +ContentProcessMessageManager includes MessageListenerManagerMixin; + +/** + * Message "broadcasters" don't have a single "other side" that they send messages to, but + * rather a set of subordinate message managers. For example, broadcasting a message + * through a window message manager will broadcast the message to all frame message + * managers within its window. + */ +[ChromeOnly, Exposed=Window] +interface MessageBroadcaster : MessageListenerManager +{ + /** + * Like |sendAsyncMessage()|, but also broadcasts this message to + * all "child" message managers of this message manager. See long + * comment above for details. + * + * WARNING: broadcasting messages can be very expensive and leak + * sensitive data. Use with extreme caution. + */ + [Throws] + undefined broadcastAsyncMessage(optional DOMString? messageName = null, + optional any obj); + + /** + * Number of subordinate message managers. + */ + readonly attribute unsigned long childCount; + + /** + * Return a single subordinate message manager. + */ + MessageListenerManager? getChildAt(unsigned long aIndex); + + /** + * Some processes are kept alive after their last tab/window are closed for testing + * (see dom.ipc.keepProcessesAlive). This function releases those. + */ + undefined releaseCachedProcesses(); +}; + +/** + * ChromeMessageBroadcaster is used for window and group message managers. + */ +[ChromeOnly, Exposed=Window] +interface ChromeMessageBroadcaster : MessageBroadcaster +{ +}; +ChromeMessageBroadcaster includes FrameScriptLoader; + +/** + * ParentProcessMessageManager is used in a parent process to communicate with all the + * child processes. + */ +[ChromeOnly, Exposed=Window] +interface ParentProcessMessageManager : MessageBroadcaster +{ +}; +ParentProcessMessageManager includes ProcessScriptLoader; +ParentProcessMessageManager includes GlobalProcessScriptLoader; + +[ChromeOnly, Exposed=Window] +interface ChromeMessageSender : MessageSender +{ +}; +ChromeMessageSender includes FrameScriptLoader; + +/** + * ProcessMessageManager is used in a parent process to communicate with a child process + * (or with the process itself in a single-process scenario). + */ +[ChromeOnly, Exposed=Window] +interface ProcessMessageManager : MessageSender +{ + // PID of the process being communicated with. + readonly attribute long osPid; + + // Whether this is message manager for the current process. + readonly attribute boolean isInProcess; +}; +ProcessMessageManager includes ProcessScriptLoader; diff --git a/dom/chrome-webidl/MozDocumentObserver.webidl b/dom/chrome-webidl/MozDocumentObserver.webidl new file mode 100644 index 0000000000..06abd37eeb --- /dev/null +++ b/dom/chrome-webidl/MozDocumentObserver.webidl @@ -0,0 +1,20 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +[Exposed=Window] +callback interface MozDocumentCallback { + undefined onNewDocument(MozDocumentMatcher matcher, WindowProxy window); + undefined onPreloadDocument(MozDocumentMatcher matcher, LoadInfo loadInfo); +}; + +[ChromeOnly, Exposed=Window] +interface MozDocumentObserver { + constructor(MozDocumentCallback callbacks); + + [Throws] + undefined observe(sequence<MozDocumentMatcher> matchers); + undefined disconnect(); +}; diff --git a/dom/chrome-webidl/MozSharedMap.webidl b/dom/chrome-webidl/MozSharedMap.webidl new file mode 100644 index 0000000000..ef262fc48e --- /dev/null +++ b/dom/chrome-webidl/MozSharedMap.webidl @@ -0,0 +1,54 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +typedef any StructuredClonable; + +[ChromeOnly, Exposed=Window] +interface MozSharedMapChangeEvent : Event { + [Cached, Constant] + readonly attribute sequence<DOMString> changedKeys; +}; + +dictionary MozSharedMapChangeEventInit : EventInit { + required sequence<DOMString> changedKeys; +}; + +[ChromeOnly, Exposed=Window] +interface MozSharedMap : EventTarget { + boolean has(DOMString name); + + [Throws] + StructuredClonable get(DOMString name); + + iterable<DOMString, StructuredClonable>; +}; + +[ChromeOnly, Exposed=Window] +interface MozWritableSharedMap : MozSharedMap { + /** + * Sets the given key to the given structured-clonable value. The value is + * synchronously structured cloned, and the serialized value is saved in the + * map. + * + * Unless flush() is called, the new value will be broadcast to content + * processes after a short delay. + */ + [Throws] + undefined set(DOMString name, StructuredClonable value); + + /** + * Removes the given key from the map. + * + * Unless flush() is called, the removal will be broadcast to content + * processes after a short delay. + */ + undefined delete(DOMString name); + + /** + * Broadcasts any pending changes to all content processes. + */ + undefined flush(); +}; diff --git a/dom/chrome-webidl/MozStorageAsyncStatementParams.webidl b/dom/chrome-webidl/MozStorageAsyncStatementParams.webidl new file mode 100644 index 0000000000..853d86581a --- /dev/null +++ b/dom/chrome-webidl/MozStorageAsyncStatementParams.webidl @@ -0,0 +1,22 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +[ChromeOnly, Exposed=Window] +interface MozStorageAsyncStatementParams +{ + readonly attribute unsigned long length; + + [Throws] + getter any(unsigned long index); + + [Throws] + getter any(DOMString name); + + [Throws] + setter undefined(unsigned long index, any arg); + + [Throws] + setter undefined(DOMString name, any arg); +}; diff --git a/dom/chrome-webidl/MozStorageStatementParams.webidl b/dom/chrome-webidl/MozStorageStatementParams.webidl new file mode 100644 index 0000000000..1c4eb4cbf7 --- /dev/null +++ b/dom/chrome-webidl/MozStorageStatementParams.webidl @@ -0,0 +1,22 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +[ChromeOnly, Exposed=Window] +interface MozStorageStatementParams +{ + readonly attribute unsigned long length; + + [Throws] + getter any(unsigned long index); + + [Throws] + getter any(DOMString name); + + [Throws] + setter undefined(unsigned long index, any arg); + + [Throws] + setter undefined(DOMString name, any arg); +}; diff --git a/dom/chrome-webidl/MozStorageStatementRow.webidl b/dom/chrome-webidl/MozStorageStatementRow.webidl new file mode 100644 index 0000000000..2ba31f5810 --- /dev/null +++ b/dom/chrome-webidl/MozStorageStatementRow.webidl @@ -0,0 +1,11 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +[ChromeOnly, Exposed=Window] +interface MozStorageStatementRow +{ + [Throws] + getter any(DOMString name); +}; diff --git a/dom/chrome-webidl/NetDashboard.webidl b/dom/chrome-webidl/NetDashboard.webidl new file mode 100644 index 0000000000..937ffc11d8 --- /dev/null +++ b/dom/chrome-webidl/NetDashboard.webidl @@ -0,0 +1,155 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// This file defines dictionaries used by about:networking page. + +dictionary SocketElement { + DOMString host = ""; + unsigned long port = 0; + boolean active = false; + DOMString type = ""; + double sent = 0; + double received = 0; +}; + +[GenerateConversionToJS] +dictionary SocketsDict { + sequence<SocketElement> sockets; + double sent = 0; + double received = 0; +}; + +dictionary HttpConnInfo { + unsigned long rtt = 0; + unsigned long ttl = 0; + DOMString protocolVersion = ""; +}; + +dictionary DnsAndSockInfoDict { + boolean speculative = false; +}; + +dictionary HttpConnectionElement { + DOMString host = ""; + unsigned long port = 0; + DOMString httpVersion = ""; + boolean ssl = false; + sequence<HttpConnInfo> active; + sequence<HttpConnInfo> idle; + sequence<DnsAndSockInfoDict> dnsAndSocks; +}; + +[GenerateConversionToJS] +dictionary HttpConnDict { + sequence<HttpConnectionElement> connections; +}; + +dictionary WebSocketElement { + DOMString hostport = ""; + unsigned long msgsent = 0; + unsigned long msgreceived = 0; + double sentsize = 0; + double receivedsize = 0; + boolean encrypted = false; +}; + +[GenerateConversionToJS] +dictionary WebSocketDict { + sequence<WebSocketElement> websockets; +}; + +dictionary DnsCacheEntry { + DOMString hostname = ""; + sequence<DOMString> hostaddr; + DOMString family = ""; + double expiration = 0; + boolean trr = false; + DOMString originAttributesSuffix = ""; + DOMString flags = ""; +}; + +[GenerateConversionToJS] +dictionary DNSCacheDict { + sequence<DnsCacheEntry> entries; +}; + +[GenerateConversionToJS] +dictionary DNSLookupDict { + sequence<DOMString> address; + DOMString error = ""; + boolean answer = false; +}; + +dictionary SVCParam { + unsigned short type = 0; +}; + +dictionary SVCParamAlpn : SVCParam { + DOMString alpn = ""; +}; + +dictionary SVCParamNoDefaultAlpn : SVCParam { +}; + +dictionary SVCParamPort : SVCParam { + unsigned short port = 0; +}; + +dictionary SVCParamIPv4Hint : SVCParam { + sequence<DOMString> address; +}; + +dictionary SVCParamIPv6Hint : SVCParam { + sequence<DOMString> address; +}; + +dictionary SVCParamEchConfig : SVCParam { + DOMString echConfig = ""; +}; + +dictionary SVCParamODoHConfig : SVCParam { + DOMString ODoHConfig = ""; +}; + +dictionary HTTPSRecord { + unsigned short priority = 0; + DOMString targetName = ""; + SVCParamAlpn alpn; + SVCParamNoDefaultAlpn noDefaultAlpn; + SVCParamPort port; + SVCParamIPv4Hint ipv4Hint; + SVCParamIPv6Hint ipv6Hint; + SVCParamEchConfig echConfig; + SVCParamODoHConfig ODoHConfig; +}; + +[GenerateConversionToJS] +dictionary HTTPSRRLookupDict { + DOMString error = ""; + boolean answer = false; + sequence<HTTPSRecord> records; +}; + +[GenerateConversionToJS] +dictionary ConnStatusDict { + DOMString status = ""; +}; + +dictionary RcwnPerfStats { + unsigned long avgShort = 0; + unsigned long avgLong = 0; + unsigned long stddevLong = 0; +}; + +[GenerateConversionToJS] +dictionary RcwnStatus { + unsigned long totalNetworkRequests = 0; + unsigned long rcwnCacheWonCount = 0; + unsigned long rcwnNetWonCount = 0; + unsigned long cacheSlowCount = 0; + unsigned long cacheNotSlowCount = 0; + // Sequence is indexed by CachePerfStats::EDataType + sequence<RcwnPerfStats> perfStats; +}; diff --git a/dom/chrome-webidl/PathUtils.webidl b/dom/chrome-webidl/PathUtils.webidl new file mode 100644 index 0000000000..0b8be50f0b --- /dev/null +++ b/dom/chrome-webidl/PathUtils.webidl @@ -0,0 +1,187 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/** + * PathUtils is a set of utilities for operating on absolute paths. + */ +[ChromeOnly, Exposed=(Window, Worker)] +namespace PathUtils { + /** + * Return the last path component. + * + * @param path An absolute path. + * + * @returns The last path component. + */ + [Throws] + DOMString filename(DOMString path); + + /** + * Return an ancestor directory of the given path. + * + * @param path An absolute path. + * @param depth The number of ancestors to remove, defaulting to 1 (i.e., the + * parent). + * + * @return The ancestor directory. + * + * If the path provided is a root path (e.g., `C:` on Windows or `/` + * on *NIX), then null is returned. + */ + [Throws] + DOMString? parent(DOMString path, optional long depth = 1); + + /** + * Join the given components into a full path. + * + * @param components The path components. The first component must be an + * absolute path. There must be at least one component. + */ + [Throws] + DOMString join(DOMString... components); + + /** + * Join the given relative path to the base path. + * + * @param base The base path. This must be an absolute path. + * @param relativePath A relative path to join to the base path. + */ + [Throws] + DOMString joinRelative(DOMString base, DOMString relativePath); + + /** + * Creates an adjusted path using a path whose length is already close + * to MAX_PATH. For windows only. + * + * @param path An absolute path. + */ + [Throws] + DOMString toExtendedWindowsPath(DOMString path); + + /** + * Normalize a path by removing multiple separators and `..` and `.` + * directories. + * + * On UNIX platforms, the path must exist as symbolic links will be resolved. + * + * @param path The absolute path to normalize. + * + */ + [Throws] + DOMString normalize(DOMString path); + + /** + * Split a path into its components. + * + * @param path An absolute path. + */ + [Throws] + sequence<DOMString> split(DOMString path); + + /** + * Split a relative path into its components. + * + * @param path A relative path. + */ + [Throws] + sequence<DOMString> splitRelative(DOMString path, optional SplitRelativeOptions options = {}); + + /** + * Transform a file path into a file: URI + * + * @param path An absolute path. + * + * @return The file: URI as a string. + */ + [Throws] + UTF8String toFileURI(DOMString path); + + /** + * Determine if the given path is an absolute or relative path. + * + * @param path A file path that is either relative or absolute. + * + * @return Whether or not the path is absolute. + */ + boolean isAbsolute(DOMString path); +}; + +[Exposed=Window] +partial namespace PathUtils { + /** + * The profile directory. + */ + [Throws, BinaryName="ProfileDirSync"] + readonly attribute DOMString profileDir; + + /** + * The local-specific profile directory. + */ + [Throws, BinaryName="LocalProfileDirSync"] + readonly attribute DOMString localProfileDir; + + /** + * The temporary directory for the process. + */ + [Throws, BinaryName="TempDirSync"] + readonly attribute DOMString tempDir; + + /** + * The OS temporary directory. + */ + [Throws, BinaryName="OSTempDirSync"] + readonly attribute DOMString osTempDir; + + /** + * The libxul path. + */ + [Throws, BinaryName="XulLibraryPathSync"] + readonly attribute DOMString xulLibraryPath; +}; + +[Exposed=Worker] +partial namespace PathUtils { + /** + * The profile directory. + */ + [NewObject, BinaryName="GetProfileDirAsync"] + Promise<DOMString> getProfileDir(); + + /** + * The local-specific profile directory. + */ + [NewObject, BinaryName="GetLocalProfileDirAsync"] + Promise<DOMString> getLocalProfileDir(); + + /** + * The temporary directory for the process. + */ + [NewObject, BinaryName="GetTempDirAsync"] + Promise<DOMString> getTempDir(); + + /** + * The OS temporary directory. + */ + [NewObject, BinaryName="GetOSTempDirAsync"] + Promise<DOMString> getOSTempDir(); + + /** + * The libxul path. + */ + [NewObject, BinaryName="GetXulLibraryPathAsync"] + Promise<DOMString> getXulLibraryPath(); +}; + +dictionary SplitRelativeOptions { + /** Allow for a path that contains empty components. */ + boolean allowEmpty = false; + + /** Allow for a path that contains ".." components. */ + boolean allowParentDir = false; + + /** Allow for a path that contains "." components. */ + boolean allowCurrentDir = false; +}; diff --git a/dom/chrome-webidl/PlacesEvent.webidl b/dom/chrome-webidl/PlacesEvent.webidl new file mode 100644 index 0000000000..63d89572d8 --- /dev/null +++ b/dom/chrome-webidl/PlacesEvent.webidl @@ -0,0 +1,520 @@ +enum PlacesEventType { + "none", + + /** + * data: PlacesVisit. Fired whenever a page is visited. + */ + "page-visited", + /** + * data: PlacesBookmarkAddition. Fired whenever a bookmark + * (or a bookmark folder/separator) is created. + */ + "bookmark-added", + /** + * data: PlacesBookmarkRemoved. Fired whenever a bookmark + * (or a bookmark folder/separator) is removed. + */ + "bookmark-removed", + /** + * data: PlacesBookmarkMoved. Fired whenever a bookmark + * (or a bookmark folder/separator) is moved. + */ + "bookmark-moved", + /** + * data: PlacesBookmarkGuid. Fired whenever a bookmark guid changes. + */ + "bookmark-guid-changed", + /** + * data: PlacesBookmarkTags. Fired whenever tags of bookmark changes. + */ + "bookmark-tags-changed", + /** + * data: PlacesBookmarkTime. + * Fired whenever dateAdded or lastModified of a bookmark is explicitly changed + * through the Bookmarks API. This notification doesn't fire when a bookmark is + * created, or when a property of a bookmark (e.g. title) is changed, even if + * lastModified will be updated as a consequence of that change. + */ + "bookmark-time-changed", + /** + * data: PlacesBookmarkTitle. Fired whenever a bookmark title changes. + */ + "bookmark-title-changed", + /** + * data: PlacesBookmarkUrl. Fired whenever a bookmark url changes. + */ + "bookmark-url-changed", + /** + * data: PlacesFavicon. Fired whenever a favicon changes. + */ + "favicon-changed", + /** + * data: PlacesVisitTitle. Fired whenever a page title changes. + */ + "page-title-changed", + /** + * data: PlacesHistoryCleared. Fired whenever history is cleared. + */ + "history-cleared", + /** + * data: PlacesRanking. Fired whenever pages ranking is changed. + */ + "pages-rank-changed", + /** + * data: PlacesVisitRemoved. Fired whenever a page or its visits are removed. + * This may be invoked when a page is removed from the store because it has no more + * visits, nor bookmarks. It may also be invoked when all or some of the page visits are + * removed, but the page itself is not removed from the store, because it may be + * bookmarked. + */ + "page-removed", + /** + * data: PlacesPurgeCaches. Fired whenever changes happened that could not be observed + * through other notifications, for example a database fixup. When received, observers, + * especially data views, should drop any caches and reload from scratch. + */ + "purge-caches", +}; + +[ChromeOnly, Exposed=Window] +interface PlacesEvent { + readonly attribute PlacesEventType type; +}; + +[ChromeOnly, Exposed=Window] +interface PlacesVisit : PlacesEvent { + /** + * URL of the visit. + */ + readonly attribute DOMString url; + + /** + * Id of the visit. + */ + readonly attribute unsigned long long visitId; + + /** + * Time of the visit, in milliseconds since epoch. + */ + readonly attribute unsigned long long visitTime; + + /** + * The id of the visit the user came from, defaults to 0 for no referrer. + */ + readonly attribute unsigned long long referringVisitId; + + /** + * One of nsINavHistory.TRANSITION_* + */ + readonly attribute unsigned long transitionType; + + /** + * The unique id associated with the page. + */ + readonly attribute ByteString pageGuid; + + /** + * Whether the visited page is marked as hidden. + */ + readonly attribute boolean hidden; + + /** + * Number of visits (including this one) for this URL. + */ + readonly attribute unsigned long visitCount; + + /** + * Whether the URL has been typed or not. + * TODO (Bug 1271801): This will become a count, rather than a boolean. + * For future compatibility, always compare it with "> 0". + */ + readonly attribute unsigned long typedCount; + + /** + * The last known title of the page. Might not be from the current visit, + * and might be null if it is not known. + */ + readonly attribute DOMString? lastKnownTitle; +}; + +/** + * Base class for properties that are common to all bookmark events. + */ +[ChromeOnly, Exposed=Window] +interface PlacesBookmark : PlacesEvent { + /** + * The id of the item. + */ + readonly attribute long long id; + + /** + * The id of the folder to which the item belongs. + */ + readonly attribute long long parentId; + + /** + * The type of the added item (see TYPE_* constants in nsINavBooksService.idl). + */ + readonly attribute unsigned short itemType; + + /** + * The URI of the added item if it was TYPE_BOOKMARK, "" otherwise. + */ + readonly attribute DOMString url; + + /** + * The unique ID associated with the item. + */ + readonly attribute ByteString guid; + + /** + * The unique ID associated with the item's parent. + */ + readonly attribute ByteString parentGuid; + + /** + * A change source constant from nsINavBookmarksService::SOURCE_*, + * passed to the method that notifies the observer. + */ + readonly attribute unsigned short source; + + /** + * True if the item is a tag or a tag folder. + * NOTE: this will go away with bug 424160. + */ + readonly attribute boolean isTagging; +}; + +dictionary PlacesBookmarkAdditionInit { + required long long id; + required long long parentId; + required unsigned short itemType; + required DOMString url; + required ByteString guid; + required ByteString parentGuid; + required unsigned short source; + required long index; + required DOMString title; + required unsigned long long dateAdded; + required boolean isTagging; +}; + +[ChromeOnly, Exposed=Window] +interface PlacesBookmarkAddition : PlacesBookmark { + constructor(PlacesBookmarkAdditionInit initDict); + + /** + * The item's index in the folder. + */ + readonly attribute long index; + + /** + * The title of the added item. + */ + readonly attribute DOMString title; + + /** + * The time that the item was added, in milliseconds from the epoch. + */ + readonly attribute unsigned long long dateAdded; +}; + +dictionary PlacesBookmarkRemovedInit { + required long long id; + required long long parentId; + required unsigned short itemType; + required DOMString url; + required DOMString title; + required ByteString guid; + required ByteString parentGuid; + required unsigned short source; + required long index; + required boolean isTagging; + boolean isDescendantRemoval = false; +}; + +[ChromeOnly, Exposed=Window] +interface PlacesBookmarkRemoved : PlacesBookmark { + constructor(PlacesBookmarkRemovedInit initDict); + /** + * The item's index in the folder. + */ + readonly attribute long index; + + /** + * The title of the the removed item. + */ + readonly attribute DOMString title; + + /** + * The item is a descendant of an item whose notification has been sent out. + */ + readonly attribute boolean isDescendantRemoval; +}; + +dictionary PlacesBookmarkMovedInit { + required long long id; + required unsigned short itemType; + DOMString? url = null; + required ByteString guid; + required ByteString parentGuid; + required long index; + required ByteString oldParentGuid; + required long oldIndex; + required unsigned short source; + required boolean isTagging; +}; + +[ChromeOnly, Exposed=Window] +/** + * NOTE: Though PlacesBookmarkMoved extends PlacesBookmark, + * parentId will not be set. Use parentGuid instead. + */ +interface PlacesBookmarkMoved : PlacesBookmark { + constructor(PlacesBookmarkMovedInit initDict); + /** + * The item's index in the folder. + */ + readonly attribute long index; + + /** + * The unique ID associated with the item's old parent. + */ + readonly attribute ByteString oldParentGuid; + + /** + * The item's old index in the folder. + */ + readonly attribute long oldIndex; +}; + +[ChromeOnly, Exposed=Window] +interface PlacesBookmarkChanged : PlacesBookmark { + /** + * The updated last modified value in milliseconds. + */ + readonly attribute long long lastModified; +}; + +dictionary PlacesBookmarkGuidInit { + required long long id; + required unsigned short itemType; + DOMString? url = null; + required ByteString guid; + required ByteString parentGuid; + required long long lastModified; + required unsigned short source; + required boolean isTagging; +}; + +[ChromeOnly, Exposed=Window] +interface PlacesBookmarkGuid : PlacesBookmarkChanged { + constructor(PlacesBookmarkGuidInit initDict); +}; + +dictionary PlacesBookmarkTagsInit { + required long long id; + required unsigned short itemType; + DOMString? url = null; + required ByteString guid; + required ByteString parentGuid; + required sequence<DOMString> tags; + required long long lastModified; + required unsigned short source; + required boolean isTagging; +}; + +[ChromeOnly, Exposed=Window] +interface PlacesBookmarkTags : PlacesBookmarkChanged { + constructor(PlacesBookmarkTagsInit initDict); + + /** + * Tags the bookmark has currently. + */ + [Constant,Cached] + readonly attribute sequence<DOMString> tags; +}; + +dictionary PlacesBookmarkTimeInit { + required long long id; + required unsigned short itemType; + DOMString? url = null; + required ByteString guid; + required ByteString parentGuid; + required long long dateAdded; + required long long lastModified; + required unsigned short source; + required boolean isTagging; +}; + +[ChromeOnly, Exposed=Window] +interface PlacesBookmarkTime : PlacesBookmarkChanged { + constructor(PlacesBookmarkTimeInit initDict); + + /** + * The added date in milliseconds. + */ + readonly attribute long long dateAdded; +}; + +dictionary PlacesBookmarkTitleInit { + required long long id; + required unsigned short itemType; + DOMString? url = null; + required ByteString guid; + required ByteString parentGuid; + required DOMString title; + required long long lastModified; + required unsigned short source; + required boolean isTagging; +}; + +[ChromeOnly, Exposed=Window] +interface PlacesBookmarkTitle : PlacesBookmarkChanged { + constructor(PlacesBookmarkTitleInit initDict); + + /** + * The title of the changed bookmark. + */ + readonly attribute DOMString title; +}; + +dictionary PlacesBookmarkUrlInit { + required long long id; + required unsigned short itemType; + required DOMString url; + required ByteString guid; + required ByteString parentGuid; + required long long lastModified; + required unsigned short source; + required boolean isTagging; +}; + +[ChromeOnly, Exposed=Window] +interface PlacesBookmarkUrl : PlacesBookmarkChanged { + constructor(PlacesBookmarkUrlInit initDict); +}; + +dictionary PlacesFaviconInit { + required DOMString url; + required ByteString pageGuid; + required DOMString faviconUrl; +}; + +[ChromeOnly, Exposed=Window] +interface PlacesFavicon : PlacesEvent { + constructor(PlacesFaviconInit initDict); + + /** + * The URI of the changed page. + */ + readonly attribute DOMString url; + + /** + * The unique id associated with the page. + */ + readonly attribute ByteString pageGuid; + + /** + * The URI of the new favicon. + */ + readonly attribute DOMString faviconUrl; +}; + +dictionary PlacesVisitTitleInit { + required DOMString url; + required ByteString pageGuid; + required DOMString title; +}; + +[ChromeOnly, Exposed=Window] +interface PlacesVisitTitle : PlacesEvent { + constructor(PlacesVisitTitleInit initDict); + + /** + * The URI of the changed page. + */ + readonly attribute DOMString url; + + /** + * The unique id associated with the page. + */ + readonly attribute ByteString pageGuid; + + /** + * The title of the changed page. + */ + readonly attribute DOMString title; +}; + +[ChromeOnly, Exposed=Window] +interface PlacesHistoryCleared : PlacesEvent { + constructor(); +}; + +[ChromeOnly, Exposed=Window] +interface PlacesRanking : PlacesEvent { + constructor(); +}; + +dictionary PlacesVisitRemovedInit { + required DOMString url; + required ByteString pageGuid; + required unsigned short reason; + unsigned long transitionType = 0; + boolean isRemovedFromStore = false; + boolean isPartialVisistsRemoval = false; +}; + +[ChromeOnly, Exposed=Window] +interface PlacesVisitRemoved : PlacesEvent { + /** + * Removed by the user. + */ + const unsigned short REASON_DELETED = 0; + + /** + * Removed by periodic expiration. + */ + const unsigned short REASON_EXPIRED = 1; + + constructor(PlacesVisitRemovedInit initDict); + + /** + * The URI of the page. + */ + readonly attribute DOMString url; + + /** + * The unique id associated with the page. + */ + readonly attribute ByteString pageGuid; + + /** + * The reason of removal. + */ + readonly attribute unsigned short reason; + + /** + * One of nsINavHistoryService.TRANSITION_* + * NOTE: Please refer this attribute only when isRemovedFromStore is false. + * Otherwise this will be 0. + */ + readonly attribute unsigned long transitionType; + + /** + * This will be true if the page is removed from store. + * If false, only visits were removed, but not the page. + */ + readonly attribute boolean isRemovedFromStore; + + /** + * This will be true if remains at least one visit to the page. + */ + readonly attribute boolean isPartialVisistsRemoval; +}; + +[ChromeOnly, Exposed=Window] +interface PlacesPurgeCaches : PlacesEvent { + constructor(); +}; diff --git a/dom/chrome-webidl/PlacesObservers.webidl b/dom/chrome-webidl/PlacesObservers.webidl new file mode 100644 index 0000000000..662d8558ff --- /dev/null +++ b/dom/chrome-webidl/PlacesObservers.webidl @@ -0,0 +1,31 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +callback PlacesEventCallback = undefined (sequence<PlacesEvent> events); + +[ChromeOnly, Exposed=Window] +interface PlacesWeakCallbackWrapper { + constructor(PlacesEventCallback callback); +}; + +// Global singleton which should handle all events for places. +[ChromeOnly, Exposed=Window] +namespace PlacesObservers { + [Throws] + undefined addListener(sequence<PlacesEventType> eventTypes, + PlacesEventCallback listener); + [Throws] + undefined addListener(sequence<PlacesEventType> eventTypes, + PlacesWeakCallbackWrapper listener); + [Throws] + undefined removeListener(sequence<PlacesEventType> eventTypes, + PlacesEventCallback listener); + [Throws] + undefined removeListener(sequence<PlacesEventType> eventTypes, + PlacesWeakCallbackWrapper listener); + [Throws] + undefined notifyListeners(sequence<PlacesEvent> events); +}; diff --git a/dom/chrome-webidl/PrecompiledScript.webidl b/dom/chrome-webidl/PrecompiledScript.webidl new file mode 100644 index 0000000000..4a71f67fc8 --- /dev/null +++ b/dom/chrome-webidl/PrecompiledScript.webidl @@ -0,0 +1,43 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +dictionary ExecuteInGlobalOptions { + /** + * If `reportExceptions` is set to true and any exception happens + * while executing the script, the exceptions will automatically be logged + * in the console. This helps log the exception with the right global innerWindowID + * and make it display in the right DevTools console. + */ + boolean reportExceptions = false; +}; + +/** + * Represents a pre-compiled JS script, which can be repeatedly executed in + * different globals without being re-parsed. + */ +[ChromeOnly, Exposed=Window] +interface PrecompiledScript { + /** + * Executes the script in the context of, and with the security principal + * of, the given object's global. If compiled with a return value, returns + * the value of the script's last expression. Otherwise returns undefined. + */ + [Throws] + any executeInGlobal(object global, optional ExecuteInGlobalOptions options = {}); + + /** + * The URL that the script was loaded from. + */ + [Pure] + readonly attribute DOMString url; + + /** + * True if the script was compiled with a return value, and will return the + * value of its last expression when executed. + */ + [Pure] + readonly attribute boolean hasReturnValue; +}; diff --git a/dom/chrome-webidl/PrioEncoder.webidl b/dom/chrome-webidl/PrioEncoder.webidl new file mode 100644 index 0000000000..81c5bf0a4d --- /dev/null +++ b/dom/chrome-webidl/PrioEncoder.webidl @@ -0,0 +1,20 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +[ChromeOnly, Exposed=Window] +namespace PrioEncoder { + [Throws, NewObject] + PrioEncodedData encode(ByteString batchID, PrioParams params); +}; + +dictionary PrioParams { + required sequence<boolean> booleans; +}; + +dictionary PrioEncodedData { + Uint8Array a; + Uint8Array b; +}; diff --git a/dom/chrome-webidl/PromiseDebugging.webidl b/dom/chrome-webidl/PromiseDebugging.webidl new file mode 100644 index 0000000000..c4c4e8ec96 --- /dev/null +++ b/dom/chrome-webidl/PromiseDebugging.webidl @@ -0,0 +1,110 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* This is a utility namespace for promise-debugging functionality */ + + +dictionary PromiseDebuggingStateHolder { + PromiseDebuggingState state = "pending"; + any value; + any reason; +}; +enum PromiseDebuggingState { "pending", "fulfilled", "rejected" }; + +/** + * An observer for Promise that _may_ be leaking uncaught rejections. + * + * It is generally a programming error to leave a Promise rejected and + * not consume its rejection. The information exposed by this + * interface is designed to allow clients to track down such Promise, + * i.e. Promise that are currently + * - in `rejected` state; + * - last of their chain. + * + * Note, however, that a promise in such a state at the end of a tick + * may eventually be consumed in some ulterior tick. Implementers of + * this interface are responsible for presenting the information + * in a meaningful manner. + */ +[Exposed=Window] +callback interface UncaughtRejectionObserver { + /** + * A Promise has been left in `rejected` state and is the + * last in its chain. If this callback returns true, the rejection + * will not be reported. + * + * @param p A currently uncaught Promise. If `p` is is eventually + * caught, i.e. if its `then` callback is called, `onConsumed` will + * be called. + */ + boolean onLeftUncaught(object p); + + /** + * A Promise previously left uncaught is not the last in its + * chain anymore. + * + * @param p A Promise that was previously left in uncaught state is + * now caught, i.e. it is not the last in its chain anymore. + */ + undefined onConsumed(object p); +}; + +[ChromeOnly, Exposed=Window] +namespace PromiseDebugging { + /** + * The various functions on this interface all expect to take promises but + * don't want the WebIDL behavior of assimilating random passed-in objects + * into promises. They also want to treat Promise subclass instances as + * promises instead of wrapping them in a vanilla Promise, which is what the + * IDL spec says to do. So we list all our arguments as "object" instead of + * "Promise" and check for them being a Promise internally. + */ + + /** + * Get the current state of the given promise. + */ + [Throws] + PromiseDebuggingStateHolder getState(object p); + + /** + * Return an identifier for a promise. This identifier is guaranteed + * to be unique to the current process. + */ + [Throws] + DOMString getPromiseID(object p); + + /** + * Return the stack to the promise's allocation point. This can + * return null if the promise was not created from script. + */ + [Throws] + object? getAllocationStack(object p); + + /** + * Return the stack to the promise's rejection point, if the + * rejection happened from script. This can return null if the + * promise has not been rejected or was not rejected from script. + */ + [Throws] + object? getRejectionStack(object p); + + /** + * Return the stack to the promise's fulfillment point, if the + * fulfillment happened from script. This can return null if the + * promise has not been fulfilled or was not fulfilled from script. + */ + [Throws] + object? getFullfillmentStack(object p); + + /** + * Watching uncaught rejections on the current thread. + * + * Adding an observer twice will cause it to be notified twice + * of events. + */ + undefined addUncaughtRejectionObserver(UncaughtRejectionObserver o); + boolean removeUncaughtRejectionObserver(UncaughtRejectionObserver o); +}; diff --git a/dom/chrome-webidl/SessionStoreUtils.webidl b/dom/chrome-webidl/SessionStoreUtils.webidl new file mode 100644 index 0000000000..9032c784c4 --- /dev/null +++ b/dom/chrome-webidl/SessionStoreUtils.webidl @@ -0,0 +1,169 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +interface nsIDocShell; +interface nsISupports; +interface nsISessionStoreRestoreData; + +/** + * A callback passed to SessionStoreUtils.forEachNonDynamicChildFrame(). + */ +callback SessionStoreUtilsFrameCallback = undefined (WindowProxy frame, unsigned long index); + +/** + * SessionStore utility functions implemented in C++ for performance reasons. + */ +[ChromeOnly, Exposed=Window] +namespace SessionStoreUtils { + /** + * Calls the given |callback| once for each non-dynamic child frame of the + * given |window|. + */ + [Throws] + undefined forEachNonDynamicChildFrame(WindowProxy window, + SessionStoreUtilsFrameCallback callback); + + /** + * Takes the given listener, wraps it in a filter that filters out events from + * dynamic docShells, and adds that filter as a listener for the given event + * type on the given event target. The listener that was added is returned + * (as nsISupports) so that it can later be removed via + * removeDynamicFrameFilteredListener. + * + * This is implemented as a native filter, rather than a JS-based one, for + * performance reasons. + */ + [Throws] + nsISupports? addDynamicFrameFilteredListener(EventTarget target, + DOMString type, + any listener, + boolean useCapture, + optional boolean mozSystemGroup = false); + + /** + * Remove the passed-in filtered listener from the given event target, if it's + * currently a listener for the given event type there. The 'listener' + * argument must be something that was returned by + * addDynamicFrameFilteredListener. + * + * This is needed, instead of the normal removeEventListener, because the + * caller doesn't actually have something that WebIDL considers an + * EventListener. + */ + [Throws] + undefined removeDynamicFrameFilteredListener(EventTarget target, + DOMString type, + nsISupports listener, + boolean useCapture, + optional boolean mozSystemGroup = false); + + /* + * Save the docShell.allow* properties + */ + ByteString collectDocShellCapabilities(nsIDocShell docShell); + + /* + * Restore the docShell.allow* properties + */ + undefined restoreDocShellCapabilities(nsIDocShell docShell, + ByteString disallowCapabilities); + + /** + * Collects scroll position data for any given |frame| in the frame hierarchy. + * + * @param document (DOMDocument) + * + * @return {scroll: "x,y"} e.g. {scroll: "100,200"} + * Returns null when there is no scroll data we want to store for the + * given |frame|. + */ + CollectedData? collectScrollPosition(WindowProxy window); + + /** + * Restores scroll position data for any given |frame| in the frame hierarchy. + * + * @param frame (DOMWindow) + * @param value (object, see collectScrollPosition()) + */ + undefined restoreScrollPosition(Window frame, optional CollectedData data = {}); + + /** + * Collect form data for a given |frame| *not* including any subframes. + * + * The returned object may have an "id", "xpath", or "innerHTML" key or a + * combination of those three. Form data stored under "id" is for input + * fields with id attributes. Data stored under "xpath" is used for input + * fields that don't have a unique id and need to be queried using XPath. + * The "innerHTML" key is used for editable documents (designMode=on). + * + * Example: + * { + * id: {input1: "value1", input3: "value3"}, + * xpath: { + * "/xhtml:html/xhtml:body/xhtml:input[@name='input2']" : "value2", + * "/xhtml:html/xhtml:body/xhtml:input[@name='input4']" : "value4" + * } + * } + * + * @return object + * Returns null when there is no scroll data + */ + CollectedData? collectFormData(WindowProxy window); + + boolean restoreFormData(Document document, optional CollectedData data = {}); + + nsISessionStoreRestoreData constructSessionStoreRestoreData(); + + [Throws] + Promise<undefined> initializeRestore(CanonicalBrowsingContext browsingContext, + nsISessionStoreRestoreData? data); + + [NewObject] + Promise<undefined> restoreDocShellState( + CanonicalBrowsingContext browsingContext, + UTF8String? url, + ByteString? docShellCaps); + + undefined restoreSessionStorageFromParent( + CanonicalBrowsingContext browsingContext, + record<UTF8String, record<DOMString, DOMString>> sessionStorage); +}; + +[GenerateConversionToJS, GenerateInit] +dictionary CollectedFileListValue +{ + DOMString type = "file"; + required sequence<DOMString> fileList; +}; + +[GenerateConversionToJS, GenerateInit] +dictionary CollectedNonMultipleSelectValue +{ + required long selectedIndex; + required DOMString value; +}; + +// object contains either a CollectedFileListValue or a CollectedNonMultipleSelectValue or Sequence<DOMString> +typedef (DOMString or boolean or object) CollectedFormDataValue; + +dictionary CollectedData +{ + ByteString scroll; + record<DOMString, CollectedFormDataValue> id; + record<DOMString, CollectedFormDataValue> xpath; + DOMString innerHTML; + ByteString url; + // mChildren contains CollectedData instances + sequence<object?> children; +}; + +dictionary InputElementData { + sequence<DOMString> id; + sequence<DOMString> type; + sequence<long> valueIdx; + sequence<long> selectedIndex; + sequence<DOMString> selectVal; + sequence<DOMString> strVal; + sequence<boolean> boolVal; +}; diff --git a/dom/chrome-webidl/StructuredCloneHolder.webidl b/dom/chrome-webidl/StructuredCloneHolder.webidl new file mode 100644 index 0000000000..235464a059 --- /dev/null +++ b/dom/chrome-webidl/StructuredCloneHolder.webidl @@ -0,0 +1,32 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/** + * A holder for structured-clonable data which can itself be cloned with + * little overhead, and deserialized into an arbitrary global. + */ +[ChromeOnly, Exposed=(Window,Worker)] +interface StructuredCloneHolder { + /** + * Serializes the given value to an opaque structured clone blob, and + * returns the result. + * + * The serialization happens in the compartment of the given global or, if no + * global is provided, the compartment of the data value. + */ + [Throws] + constructor(any data, optional object? global = null); + + /** + * Deserializes the structured clone data in the scope of the given global, + * and returns the result. + * + * If `keepData` is true, the structured clone data is preserved, and can be + * deserialized repeatedly. Otherwise, it is immediately discarded. + */ + [Throws] + any deserialize(object global, optional boolean keepData = false); +}; diff --git a/dom/chrome-webidl/TelemetryStopwatch.webidl b/dom/chrome-webidl/TelemetryStopwatch.webidl new file mode 100644 index 0000000000..92f8a0d630 --- /dev/null +++ b/dom/chrome-webidl/TelemetryStopwatch.webidl @@ -0,0 +1,238 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +typedef DOMString HistogramID; +typedef DOMString HistogramKey; + +[ChromeOnly, Exposed=Window] +namespace TelemetryStopwatch { + /** + * Starts a timer associated with a telemetry histogram. The timer can be + * directly associated with a histogram, or with a pair of a histogram and + * an object. + * + * @param histogram - a string which must be a valid histogram name. + * + * @param obj - Optional parameter. If specified, the timer is + * associated with this object, meaning that multiple + * timers for the same histogram may be run + * concurrently, as long as they are associated with + * different objects. + * @param [options.inSeconds=false] - record elapsed time for this + * histogram in seconds instead of milliseconds. Defaults to + * false. + * + * @returns True if the timer was successfully started, false + * otherwise. If a timer already exists, it can't be + * started again, and the existing one will be cleared in + * order to avoid measurements errors. + */ + boolean start(HistogramID histogram, optional object? obj = null, + optional TelemetryStopwatchOptions options = {}); + + /** + * Returns whether a timer associated with a telemetry histogram is currently + * running. The timer can be directly associated with a histogram, or with a + * pair of a histogram and an object. + * + * @param histogram - a string which must be a valid histogram name. + * + * @param obj - Optional parameter. If specified, the timer is + * associated with this object, meaning that multiple + * timers for the same histogram may be run + * concurrently, as long as they are associated with + * different objects. + * + * @returns True if the timer exists and is currently running. + */ + boolean running(HistogramID histogram, optional object? obj = null); + + /** + * Deletes the timer associated with a telemetry histogram. The timer can be + * directly associated with a histogram, or with a pair of a histogram and + * an object. Important: Only use this method when a legitimate cancellation + * should be done. + * + * @param histogram - a string which must be a valid histogram name. + * + * @param obj - Optional parameter. If specified, the timer is + * associated with this object, meaning that multiple + * timers or a same histogram may be run concurrently, + * as long as they are associated with different + * objects. + * + * @returns True if the timer exist and it was cleared, False + * otherwise. + */ + boolean cancel(HistogramID histogram, optional object? obj = null); + + /** + * Returns the elapsed time for a particular stopwatch. Primarily for + * debugging purposes. Must be called prior to finish. + * + * @param histogram - a string which must be a valid histogram name. + * if an invalid name is given, the function will + * throw. + * + * @param obj - Optional parameter which associates the histogram + * timer with the given object. + * + * @param canceledOkay - Optional parameter which will suppress any + * warnings that normally fire when a stopwatch + * is finished after being cancelled. Defaults + * to false. + * + * @returns Time in milliseconds or -1 if the stopwatch was not + * found. + */ + long timeElapsed(HistogramID histogram, + optional object? obj = null, + optional boolean canceledOkay = false); + + /** + * Stops the timer associated with the given histogram (and object), + * calculates the time delta between start and finish, and adds the value + * to the histogram. + * + * @param histogram - a string which must be a valid histogram name. + * + * @param obj - Optional parameter which associates the histogram + * timer with the given object. + * + * @param canceledOkay - Optional parameter which will suppress any + * warnings that normally fire when a stopwatch + * is finished after being cancelled. Defaults + * to false. + * + * @returns True if the timer was succesfully stopped and the data + * was added to the histogram, false otherwise. + */ + boolean finish(HistogramID histogram, + optional object? obj = null, + optional boolean canceledOkay = false); + + /** + * Starts a timer associated with a keyed telemetry histogram. The timer can + * be directly associated with a histogram and its key. Similarly to + * @see{TelemetryStopwatch.start} the histogram and its key can be associated + * with an object. Each key may have multiple associated objects and each + * object can be associated with multiple keys. + * + * @param histogram - a string which must be a valid histogram name. + * + * @param key - a string which must be a valid histgram key. + * + * @param obj - Optional parameter. If specified, the timer is + * associated with this object, meaning that multiple + * timers for the same histogram may be run + * concurrently,as long as they are associated with + * different objects. + * @param [options.inSeconds=false] - record elapsed time for this + * histogram in seconds instead of milliseconds. Defaults to + * false. + * + * @returns True if the timer was successfully started, false + * otherwise. If a timer already exists, it can't be + * started again, and the existing one will be cleared in + * order to avoid measurements errors. + */ + boolean startKeyed(HistogramID histogram, HistogramKey key, + optional object? obj = null, + optional TelemetryStopwatchOptions options = {}); + + /** + * Returns whether a timer associated with a telemetry histogram is currently + * running. Similarly to @see{TelemetryStopwatch.running} the timer and its + * key can be associated with an object. Each key may have multiple associated + * objects and each object can be associated with multiple keys. + * + * @param histogram - a string which must be a valid histogram name. + * + * @param key - a string which must be a valid histgram key. + * + * @param obj - Optional parameter. If specified, the timer is + * associated with this object, meaning that multiple + * timers for the same histogram may be run + * concurrently, as long as they are associated with + * different objects. + * + * @returns True if the timer exists and is currently running. + */ + boolean runningKeyed(HistogramID histogram, HistogramKey key, + optional object? obj = null); + + /** + * Deletes the timer associated with a keyed histogram. Important: Only use + * this method when a legitimate cancellation should be done. + * + * @param histogram - a string which must be a valid histogram name. + * + * @param key - a string which must be a valid histgram key. + * + * @param obj - Optional parameter. If specified, the timer + * associated with this object is deleted. + * + * @returns True if the timer exist and it was cleared, False + * otherwise. + */ + boolean cancelKeyed(HistogramID histogram, HistogramKey key, + optional object? obj = null); + + /** + * Returns the elapsed time for a particular stopwatch. Primarily for + * debugging purposes. Cannot be called after finish(). + * + * @param histogram - a string which must be a valid histogram name. + * + * @param key - a string which must be a valid histgram key. + * + * @param obj - Optional parameter. If specified, the timer + * associated with this object is used to calculate + * the elapsed time. + * + * @returns Time in milliseconds or -1 if the stopwatch was not + * found. + */ + long timeElapsedKeyed(HistogramID histogram, HistogramKey key, + optional object? obj = null, + optional boolean canceledOkay = false); + + /** + * Stops the timer associated with the given keyed histogram (and object), + * calculates the time delta between start and finish, and adds the value + * to the keyed histogram. + * + * @param histogram - a string which must be a valid histogram name. + * + * @param key - a string which must be a valid histgram key. + * + * @param obj - optional parameter which associates the histogram + * timer with the given object. + * + * @param canceledOkay - Optional parameter which will suppress any + * warnings that normally fire when a stopwatch + * is finished after being cancelled. Defaults + * to false. + * + * @returns True if the timer was succesfully stopped and the data + * was added to the histogram, false otherwise. + */ + boolean finishKeyed(HistogramID histogram, HistogramKey key, + optional object? obj = null, + optional boolean canceledOkay = false); + + /** + * Set the testing mode. Used by tests. + */ + undefined setTestModeEnabled(optional boolean testing = true); +}; + +dictionary TelemetryStopwatchOptions { + /** + * If true, record elapsed time for this histogram in seconds instead of + * milliseconds. + */ + boolean inSeconds = false; +}; diff --git a/dom/chrome-webidl/UniFFI.webidl b/dom/chrome-webidl/UniFFI.webidl new file mode 100644 index 0000000000..7a3f68fbbd --- /dev/null +++ b/dom/chrome-webidl/UniFFI.webidl @@ -0,0 +1,107 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// Interface for making UniFFI scaffolding calls +// +// Gecko uses UniFFI to generate privileged JS bindings for Rust components. +// UniFFI defines a C-ABI FFI layer for calling into Rust, called the +// scaffolding. This interface is a bridge that allows the JS code to make +// scaffolding calls +// +// See https://mozilla.github.io/uniffi-rs/ for details. + +// Define some ID types to identify various parts of the UDL interfaces. Using +// these IDs, allow this .webidl file to remain static, but support new +// interfaces. Using IDs is that the C++ and JS code need to agree on their +// meaning, which is handled by +// toolkit/components/uniffi-bindgen-gecko-js/src/ci_list.rs. + +// Identifies a scaffolding function. +typedef unsigned long long UniFFIFunctionId; + +// Identifies a pointer type +typedef unsigned long long UniFFIPointerId; + +// Identifies a callback interface +typedef unsigned long UniFFICallbackInterfaceId; + +// Identifies a method of a callback interface +typedef unsigned long UniFFICallbackMethodId; + +// Handle for a callback interface instance +typedef unsigned long long UniFFICallbackObjectHandle; + +// Opaque type used to represent a pointer from Rust +[ChromeOnly, Exposed=Window] +interface UniFFIPointer {}; + +// Types that can be passed or returned from scaffolding functions +// +// - double is used for all numeric types and types which the JS code coerces +// to an int including Boolean and CallbackInterface. +// - ArrayBuffer is used for RustBuffer +// - UniFFIPointer is used for Arc pointers +typedef (double or ArrayBuffer or UniFFIPointer) UniFFIScaffoldingType; + +// The result of a call into UniFFI scaffolding call +enum UniFFIScaffoldingCallCode { + "success", // Successful return + "error", // Rust Err return + "internal-error", // Internal/unexpected error +}; + +dictionary UniFFIScaffoldingCallResult { + required UniFFIScaffoldingCallCode code; + // For success, this will be the return value for non-void returns + // For error, this will be an ArrayBuffer storing the serialized error value + UniFFIScaffoldingType data; + // For internal-error, this will be a utf-8 string describing the error + ByteString internalErrorMessage; +}; + +// JS handler for calling a CallbackInterface method. +// The arguments and return value are always packed into an ArrayBuffer +callback UniFFICallbackHandler = undefined (UniFFICallbackObjectHandle objectId, UniFFICallbackMethodId methodId, ArrayBuffer aArgs); + +// Functions to facilitate UniFFI scaffolding calls +[ChromeOnly, Exposed=Window] +namespace UniFFIScaffolding { + // Call a scaffolding function on the worker thread. + // + // id is a unique identifier for the function, known to both the C++ and JS code + [Throws] + Promise<UniFFIScaffoldingCallResult> callAsync(UniFFIFunctionId id, UniFFIScaffoldingType... args); + + // Call a scaffolding function on the main thread + // + // id is a unique identifier for the function, known to both the C++ and JS code + [Throws] + UniFFIScaffoldingCallResult callSync(UniFFIFunctionId id, UniFFIScaffoldingType... args); + + // Read a UniFFIPointer from an ArrayBuffer + // + // id is a unique identifier for the pointer type, known to both the C++ and JS code + [Throws] + UniFFIPointer readPointer(UniFFIPointerId id, ArrayBuffer buff, long position); + + // Write a UniFFIPointer to an ArrayBuffer + // + // id is a unique identifier for the pointer type, known to both the C++ and JS code + [Throws] + undefined writePointer(UniFFIPointerId id, UniFFIPointer ptr, ArrayBuffer buff, long position); + + // Register the global calblack handler + // + // This will be used to invoke all calls for a CallbackInterface. + // interfaceId is a unique identifier for the callback interface, known to both the C++ and JS code + [Throws] + undefined registerCallbackHandler(UniFFICallbackInterfaceId interfaceId, UniFFICallbackHandler handler); + + // Deregister the global calblack handler + // + // This is called at shutdown to clear out the reference to the JS function. + [Throws] + undefined deregisterCallbackHandler(UniFFICallbackInterfaceId interfaceId); +}; diff --git a/dom/chrome-webidl/UserInteraction.webidl b/dom/chrome-webidl/UserInteraction.webidl new file mode 100644 index 0000000000..ccde57dcac --- /dev/null +++ b/dom/chrome-webidl/UserInteraction.webidl @@ -0,0 +1,113 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +[ChromeOnly, Exposed=Window] +namespace UserInteraction { + /** + * Starts a timer associated with a UserInteraction ID. The timer can be + * directly associated with a UserInteraction ID, or with a pair of a + * UserInteraction ID and an object. + * + * @param id - the interaction being recorded, as + * declared in UserInteractions.yaml. This is also the annotation + * key that will be set in the BHR hang report if a hang occurs + * before the UserInteraction is finished. + * + * @param value - a value to be set on the key in the event + * that a hang occurs when the timer is running. This value is limited + * to 50 characters to avoid abuse, and if the value exceeds that limit + * then no timer is started, an error is printed, and this function returns + * false. + * + * @param obj - Optional parameter. If specified, the timer is + * associated with this object, meaning that multiple timers for the + * same annotation key may be run concurrently, as long as they are + * associated with different objects. + * + * @returns True if the timer was successfully started, false otherwise. + * If a timer already exists, it will be overwritten, and the new timer + * will include a "(clobbered)" suffix in any BHR annotations that get + * created. + */ + boolean start(DOMString id, + UTF8String value, + optional object? obj = null); + + /** + * Updates an already-running timer associated with a UserInteraction ID + * (and object) with a new value string. + * + * @param id - the interaction being recorded, as + * declared in UserInteractions.yaml. This is also the annotation + * key that will be set in the BHR hang report if a hang occurs + * before the UserInteraction is finished. + * + * @param value - a new value to be set on the key in the event + * that a hang occurs when the timer is running. This value is limited + * to 50 characters to avoid abuse. + * + * @param obj - Optional parameter. If specified, the timer is + * associated with this object, meaning that multiple timers for the + * same annotation key may be run concurrently, as long as they are + * associated with different objects. + * + * @returns True if the timer was successfully updated, false + * otherwise. + */ + boolean update(DOMString id, + UTF8String value, + optional object? obj = null); + + /** + * Cancels the timer associated with the given UserInteraction ID + * (and object) and does not add the profiler marker for it. + * + * @param id - the interaction being recorded, as + * declared in UserInteractions.yaml. + * + * @param obj - Optional parameter which associates the + * timer with the given object. + * + * @returns True if the timer was successfully stopped. + */ + boolean cancel(DOMString id, optional object? obj = null); + + /** + * Returns whether a UserInteraction timer is currently running. + * + * @param id - the ID of the interaction to check, as declared in + * UserInteractions.yaml. + * + * @param obj - Optional parameter which checks for a timer associated + * with this particular object. If you're checking for a running timer + * that was started with an object, you'll need to pass in that same + * object here to check its running state. + * + * @returns True if the timer exists and is currently running. + */ + boolean running(DOMString id, optional object? obj = null); + + /** + * Stops the timer associated with the given UserInteraction ID + * (and object), calculates the time delta between start and finish, + * and adds a profiler marker with that time range. + * + * @param id - the interaction being recorded, as + * declared in UserInteractions.yaml. + * + * @param obj - Optional parameter which associates the + * timer with the given object. + * + * @param additionalText - Optional parameter with includes additional + * text in the profiler marker. This text is not included in the hang + * annotation. + * + * @returns True if the timer was successfully stopped and the data + * was added to the profile. + */ + boolean finish(DOMString id, + optional object? obj = null, + optional UTF8String additionalText); +}; diff --git a/dom/chrome-webidl/WebExtensionContentScript.webidl b/dom/chrome-webidl/WebExtensionContentScript.webidl new file mode 100644 index 0000000000..4eadfbcb09 --- /dev/null +++ b/dom/chrome-webidl/WebExtensionContentScript.webidl @@ -0,0 +1,174 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +interface LoadInfo; +interface URI; +interface WindowProxy; + +typedef (MatchPatternSet or sequence<DOMString>) MatchPatternSetOrStringSequence; +typedef (MatchGlob or UTF8String) MatchGlobOrString; + +[ChromeOnly, Exposed=Window] +interface MozDocumentMatcher { + [Throws] + constructor(MozDocumentMatcherInit options); + + /** + * Returns true if the script's match and exclude patterns match the given + * URI, without reference to attributes such as `allFrames`. + */ + boolean matchesURI(URI uri); + + /** + * Returns true if the given window matches. This should be used to + * determine whether to run a script in a window at load time. Use + * ignorePermissions to match without origin permissions in MV3. + */ + boolean matchesWindowGlobal(WindowGlobalChild windowGlobal, + optional boolean ignorePermissions = false); + + /** + * If true, match all frames. If false, match only top-level frames. + */ + [Constant] + readonly attribute boolean allFrames; + + /** + * If we can't check extension has permissions to access the URI upfront, + * set the flag to perform the origin check at runtime, upon matching. + * This is always true in MV3, where host permissions are optional. + */ + [Constant] + readonly attribute boolean checkPermissions; + + /** + * If true, this (misleadingly-named, but inherited from Chrome) attribute + * causes us to match frames with URLs which inherit a principal that + * matches one of the match patterns, such as about:blank or about:srcdoc. + * If false, we only match frames with an explicit matching URL. + */ + [Constant] + readonly attribute boolean matchAboutBlank; + + /** + * The outer window ID of the frame in which to run the script, or 0 if it + * should run in the top-level frame. Should only be used for + * dynamically-injected scripts. + */ + [Constant] + readonly attribute unsigned long long? frameID; + + /** + * The set of match patterns for URIs of pages in which this script should + * run. This attribute is mandatory, and is a prerequisite for all other + * match patterns. + */ + [Constant] + readonly attribute MatchPatternSet matches; + + /** + * A set of match patterns for URLs in which this script should not run, + * even if they match other include patterns or globs. + */ + [Constant] + readonly attribute MatchPatternSet? excludeMatches; + + /** + * The originAttributesPattern for which this script should be enabled for. + */ + [Constant, Throws] + readonly attribute any originAttributesPatterns; + + /** + * The policy object for the extension that this matcher belongs to. + */ + [Constant] + readonly attribute WebExtensionPolicy? extension; +}; + +dictionary MozDocumentMatcherInit { + boolean allFrames = false; + + boolean checkPermissions = false; + + sequence<OriginAttributesPatternDictionary>? originAttributesPatterns = null; + + boolean matchAboutBlank = false; + + unsigned long long? frameID = null; + + required MatchPatternSetOrStringSequence matches; + + MatchPatternSetOrStringSequence? excludeMatches = null; + + sequence<MatchGlobOrString>? includeGlobs = null; + + sequence<MatchGlobOrString>? excludeGlobs = null; + + boolean hasActiveTabPermission = false; +}; + +/** + * Describes the earliest point in the load cycle at which a script should + * run. + */ +enum ContentScriptRunAt { + /** + * The point in the load cycle just after the document element has been + * inserted, before any page scripts have been allowed to run. + */ + "document_start", + /** + * The point after which the page DOM has fully loaded, but before all page + * resources have necessarily been loaded. Corresponds approximately to the + * DOMContentLoaded event. + */ + "document_end", + /** + * The first point after the page and all of its resources has fully loaded + * when the event loop is idle, and can run scripts without delaying a paint + * event. + */ + "document_idle", +}; + +[ChromeOnly, Exposed=Window] +interface WebExtensionContentScript : MozDocumentMatcher { + [Throws] + constructor(WebExtensionPolicy extension, + WebExtensionContentScriptInit options); + + /** + * The earliest point in the load cycle at which this script should run. For + * static content scripts, in extensions which were present at browser + * startup, the browser makes every effort to make sure that the script runs + * no later than this point in the load cycle. For dynamic content scripts, + * and scripts from extensions installed during this session, the scripts + * may run at a later point. + */ + [Constant] + readonly attribute ContentScriptRunAt runAt; + + /** + * A set of paths, relative to the extension root, of CSS sheets to inject + * into matching pages. + */ + [Cached, Constant, Frozen] + readonly attribute sequence<DOMString> cssPaths; + + /** + * A set of paths, relative to the extension root, of JavaScript scripts to + * execute in matching pages. + */ + [Cached, Constant, Frozen] + readonly attribute sequence<DOMString> jsPaths; +}; + +dictionary WebExtensionContentScriptInit : MozDocumentMatcherInit { + ContentScriptRunAt runAt = "document_idle"; + + sequence<DOMString> cssPaths = []; + + sequence<DOMString> jsPaths = []; +}; diff --git a/dom/chrome-webidl/WebExtensionPolicy.webidl b/dom/chrome-webidl/WebExtensionPolicy.webidl new file mode 100644 index 0000000000..8a486a9231 --- /dev/null +++ b/dom/chrome-webidl/WebExtensionPolicy.webidl @@ -0,0 +1,320 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +interface URI; +interface WindowProxy; + +callback WebExtensionLocalizeCallback = DOMString (DOMString unlocalizedText); + +/** + * Defines the platform-level policies for a WebExtension, including its + * permissions and the characteristics of its moz-extension: URLs. + */ +[ChromeOnly, Exposed=Window] +interface WebExtensionPolicy { + [Throws] + constructor(WebExtensionInit options); + + /** + * The add-on's internal ID, as specified in its manifest.json file or its + * XPI signature. + */ + [Constant, StoreInSlot] + readonly attribute DOMString id; + + /** + * The hostname part of the extension's moz-extension: URLs. This value is + * generated randomly at install time. + */ + [Constant, StoreInSlot] + readonly attribute ByteString mozExtensionHostname; + + /** + * The file: or jar: URL to use for the base of the extension's + * moz-extension: URL root. + */ + [Constant] + readonly attribute ByteString baseURL; + + /** + * The extension's user-visible name. + */ + [Constant] + readonly attribute DOMString name; + + /** + * The add-on's internal type as determined by parsing the manifest.json file. + */ + [Constant] + readonly attribute DOMString type; + + /** + * Whether the extension has access to privileged features + */ + [Constant] + readonly attribute boolean isPrivileged; + + /** + * Whether the extension is installed temporarily + */ + [Constant] + readonly attribute boolean temporarilyInstalled; + + /** + * The manifest version in use by the extension. + */ + [Constant] + readonly attribute unsigned long manifestVersion; + + /** + * The base content security policy string to apply on extension + * pages for this extension. The baseCSP is specific to the + * manifest version. If the manifest version is 3 or higher it + * is also applied to content scripts. + */ + [Constant] + readonly attribute DOMString baseCSP; + + /** + * The content security policy string to apply to all pages loaded from the + * extension's moz-extension: protocol. If one is not provided by the + * extension the default value from preferences is used. + * See extensions.webextensions.default-content-security-policy. + */ + [Constant] + readonly attribute DOMString extensionPageCSP; + + /** + * The list of currently-active permissions for the extension, as specified + * in its manifest.json file. May be updated to reflect changes in the + * extension's optional permissions. + */ + [Cached, Frozen, Pure] + attribute sequence<DOMString> permissions; + + /** + * Match patterns for the set of web origins to which the extension is + * currently allowed access. May be updated to reflect changes in the + * extension's optional permissions. + */ + [Pure] + attribute MatchPatternSet allowedOrigins; + + /** + * The set of content scripts active for this extension. + */ + [Cached, Frozen, Pure] + readonly attribute sequence<WebExtensionContentScript> contentScripts; + + /** + * True if the extension is currently active, false otherwise. When active, + * the extension's moz-extension: protocol will point to the given baseURI, + * and the set of policies for this object will be active for its ID. + * + * Only one extension policy with a given ID or hostname may be active at a + * time. Attempting to activate a policy while a conflicting policy is + * active will raise an error. + */ + [Affects=Everything, SetterThrows] + attribute boolean active; + + /** + * True if both e10s and webextensions.remote are enabled. This must be + * used instead of checking the remote pref directly since remote extensions + * require both to be enabled. + */ + static readonly attribute boolean useRemoteWebExtensions; + + /** + * True if the calling process is an extension process. + */ + static readonly attribute boolean isExtensionProcess; + + /** + * Whether the background.service_worker in the extension manifest.json file + * is enabled. + * + * NOTE: **do not use Services.prefs to retrieve the value of the undelying pref** + * + * It is defined in StaticPrefs.yaml as `mirror: once` and so checking + * its current value using Services.prefs doesn't guarantee that it does + * match the value as accessible from the C++ layers, and unexpected issue + * may be possible if different code has a different idea of its value. + */ + static readonly attribute boolean backgroundServiceWorkerEnabled; + + /** + * Set based on the manifest.incognito value: + * If "spanning" or "split" will be true. + * If "not_allowed" will be false. + */ + [Pure] + readonly attribute boolean privateBrowsingAllowed; + + /** + * Returns true if the extension can access a window. Access is + * determined by matching the windows private browsing context + * with privateBrowsingMode. This does not, and is not meant to + * handle specific differences between spanning and split mode. + */ + [Affects=Nothing] + boolean canAccessWindow(WindowProxy window); + + /** + * Returns true if the extension has cross-origin access to the given URI. + */ + boolean canAccessURI(URI uri, optional boolean explicit = false); + + /** + * Returns true if the extension currently has the given permission. + */ + boolean hasPermission(DOMString permission); + + /** + * Returns true if the given path relative to the extension's moz-extension: + * URL root is listed as a web accessible path. Access checks on a path, such + * as performed in nsScriptSecurityManager, use sourceMayAccessPath below. + */ + boolean isWebAccessiblePath(UTF8String pathname); + + /** + * Returns true if the given path relative to the extension's moz-extension: + * URL root may be accessed by web content at sourceURI. For Manifest V2, + * sourceURI is ignored and the path must merely be listed as web accessible. + */ + boolean sourceMayAccessPath(URI sourceURI, UTF8String pathname); + + /** + * Replaces localization placeholders in the given string with localized + * text from the extension's currently active locale. + */ + DOMString localize(DOMString unlocalizedText); + + /** + * Returns the moz-extension: URL for the given path. + */ + [Throws] + DOMString getURL(optional DOMString path = ""); + + /** + * Register a new content script programmatically. + */ + [Throws] + undefined registerContentScript(WebExtensionContentScript script); + + /** + * Unregister a content script. + */ + [Throws] + undefined unregisterContentScript(WebExtensionContentScript script); + + /** + * Injects the extension's content script into all existing matching windows. + */ + [Throws] + undefined injectContentScripts(); + + /** + * Returns the list of currently active extension policies. + */ + static sequence<WebExtensionPolicy> getActiveExtensions(); + + /** + * Returns the currently-active policy for the extension with the given ID, + * or null if no policy is active for that ID. + */ + static WebExtensionPolicy? getByID(DOMString id); + + /** + * Returns the currently-active policy for the extension with the given + * moz-extension: hostname, or null if no policy is active for that + * hostname. + */ + static WebExtensionPolicy? getByHostname(ByteString hostname); + + /** + * Returns the currently-active policy for the extension extension URI, or + * null if the URI is not an extension URI, or no policy is currently active + * for it. + */ + static WebExtensionPolicy? getByURI(URI uri); + + /** + * Returns true if the URI is restricted for any extension. + */ + static boolean isRestrictedURI(URI uri); + + /** + * When present, the extension is not yet ready to load URLs. In that case, + * this policy object is a stub, and the attribute contains a promise which + * resolves to a new, non-stub policy object when the extension is ready. + * + * This may be used to delay operations, such as loading extension pages, + * which depend on extensions being fully initialized. + * + * Note: This will always be either a Promise<WebExtensionPolicy?> or null, + * but the WebIDL grammar does not allow us to specify a nullable Promise + * type. + * + * Note: This could resolve to null when the startup was interrupted. + */ + readonly attribute object? readyPromise; + + /** + * Returns true if the given worker script URL matches the background + * service worker url declared in the extension manifest.json file. + */ + boolean isManifestBackgroundWorker(DOMString workerURL); + + /** + * Get the unique BrowsingContextGroup ID which will be used for toplevel + * page loads from this extension. + * + * This method will raise an exception if called from outside of the parent + * process, or if the extension is inactive. + */ + [Throws] + readonly attribute unsigned long long browsingContextGroupId; +}; + +dictionary WebAccessibleResourceInit { + required sequence<MatchGlobOrString> resources; + MatchPatternSetOrStringSequence? matches = null; + sequence<DOMString>? extension_ids = null; +}; + +dictionary WebExtensionInit { + required DOMString id; + + required ByteString mozExtensionHostname; + + required DOMString baseURL; + + DOMString name = ""; + + DOMString type = ""; + + boolean isPrivileged = false; + + boolean temporarilyInstalled = false; + + required WebExtensionLocalizeCallback localizeCallback; + + required MatchPatternSetOrStringSequence allowedOrigins; + + sequence<DOMString> permissions = []; + + sequence<WebAccessibleResourceInit> webAccessibleResources = []; + + sequence<WebExtensionContentScriptInit> contentScripts = []; + + // The use of a content script csp is determined by the manifest version. + unsigned long manifestVersion = 2; + DOMString? extensionPageCSP = null; + + sequence<DOMString>? backgroundScripts = null; + DOMString? backgroundWorkerScript = null; + + Promise<WebExtensionPolicy?> readyPromise; +}; diff --git a/dom/chrome-webidl/WindowGlobalActors.webidl b/dom/chrome-webidl/WindowGlobalActors.webidl new file mode 100644 index 0000000000..e860e98891 --- /dev/null +++ b/dom/chrome-webidl/WindowGlobalActors.webidl @@ -0,0 +1,189 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +interface Principal; +interface URI; +interface nsIDocShell; +interface RemoteTab; +interface nsIDOMProcessParent; + +[Exposed=Window, ChromeOnly] +interface WindowContext { + readonly attribute BrowsingContext? browsingContext; + + readonly attribute WindowGlobalChild? windowGlobalChild; // in-process only + + readonly attribute unsigned long long innerWindowId; + + readonly attribute WindowContext? parentWindowContext; + + readonly attribute WindowContext topWindowContext; + + readonly attribute boolean isInProcess; + + // True if this WindowContext is currently frozen in the BFCache. + readonly attribute boolean isInBFCache; + + // True if this window has registered a "beforeunload" event handler. + readonly attribute boolean hasBeforeUnload; + + // True if the principal of this window is for a local ip address. + readonly attribute boolean isLocalIP; + + /** + * Partially determines whether script execution is allowed in this + * BrowsingContext. Script execution will be permitted only if this + * attribute is true and script execution is allowed in the owner + * BrowsingContext. + * + * May only be set in the context's owning process. + */ + [SetterThrows] attribute boolean allowJavascript; +}; + +// Keep this in sync with nsIContentViewer::PermitUnloadAction. +enum PermitUnloadAction { + "prompt", + "dontUnload", + "unload", +}; + +[Exposed=Window, ChromeOnly] +interface WindowGlobalParent : WindowContext { + readonly attribute boolean isClosed; + + readonly attribute boolean isCurrentGlobal; + + readonly attribute unsigned long long outerWindowId; + readonly attribute unsigned long long contentParentId; + + readonly attribute long osPid; + + // A WindowGlobalParent is the root in its process if it has no parent, or its + // embedder is in a different process. + readonly attribute boolean isProcessRoot; + + // Is the document loaded in this WindowGlobalParent the initial document + // implicitly created while "creating a new browsing context". + // https://html.spec.whatwg.org/multipage/browsers.html#creating-a-new-browsing-context + readonly attribute boolean isInitialDocument; + + readonly attribute FrameLoader? rootFrameLoader; // Embedded (browser) only + + readonly attribute WindowGlobalChild? childActor; // in-process only + + // Checks for any WindowContexts with "beforeunload" listeners in this + // WindowGlobal's subtree. If any exist, a "beforeunload" event is + // dispatched to them. If any of those request to block the navigation, + // displays a prompt to the user. Returns a boolean which resolves to true + // if the navigation should be allowed. + // + // If `timeout` is greater than 0, it is the maximum time (in milliseconds) + // we will wait for a child process to respond with a request to block + // navigation before proceeding. If the user needs to be prompted, however, + // the promise will not resolve until the user has responded, regardless of + // the timeout. + [NewObject] + Promise<boolean> permitUnload(optional PermitUnloadAction action = "prompt", + optional unsigned long timeout = 0); + + // Information about the currently loaded document. + readonly attribute Principal documentPrincipal; + readonly attribute Principal documentStoragePrincipal; + readonly attribute Principal? contentBlockingAllowListPrincipal; + readonly attribute URI? documentURI; + readonly attribute DOMString documentTitle; + readonly attribute nsICookieJarSettings? cookieJarSettings; + + // True if the the currently loaded document is in fullscreen. + attribute boolean fullscreen; + + // Bit mask containing content blocking events that are recorded in + // the document's content blocking log. + readonly attribute unsigned long contentBlockingEvents; + + // String containing serialized content blocking log. + readonly attribute DOMString contentBlockingLog; + + // DOM Process which this window was loaded in. Will be either InProcessParent + // for windows loaded in the parent process, or ContentParent for windows + // loaded in the content process. + readonly attribute nsIDOMProcessParent? domProcess; + + static WindowGlobalParent? getByInnerWindowId(unsigned long long innerWindowId); + + /** + * Get or create the JSWindowActor with the given name. + * + * See WindowActorOptions from JSWindowActor.webidl for details on how to + * customize actor creation. + */ + [Throws] + JSWindowActorParent getActor(UTF8String name); + JSWindowActorParent? getExistingActor(UTF8String name); + + /** + * Renders a region of the frame into an image bitmap. + * + * @param rect Specify the area of the document to render, in CSS pixels, + * relative to the page. If null, the currently visible viewport is rendered. + * @param scale The scale to render the window at. Use devicePixelRatio + * to have comparable rendering to the OS. + * @param backgroundColor The background color to use. + * @param resetScrollPosition If true, temporarily resets the scroll position + * of the root scroll frame to 0, such that position:fixed elements are drawn + * at their initial position. This parameter only takes effect when passing a + * non-null rect. + * + * This API can only be used in the parent process, as content processes + * cannot access the rendering of out of process iframes. This API works + * with remote and local frames. + */ + [NewObject] + Promise<ImageBitmap> drawSnapshot(DOMRect? rect, + double scale, + UTF8String backgroundColor, + optional boolean resetScrollPosition = false); + + // True if any of the windows in the subtree rooted at this window + // has active peer connections. If this is called for a non-top-level + // context, it always returns false. + boolean hasActivePeerConnections(); +}; + +[Exposed=Window, ChromeOnly] +interface WindowGlobalChild { + readonly attribute boolean isClosed; + readonly attribute boolean isInProcess; + readonly attribute BrowsingContext browsingContext; + readonly attribute WindowContext windowContext; + + readonly attribute boolean isCurrentGlobal; + + readonly attribute unsigned long long innerWindowId; + readonly attribute unsigned long long outerWindowId; + readonly attribute unsigned long long contentParentId; + + // A WindowGlobalChild is the root in its process if it has no parent, or its + // embedder is in a different process. + readonly attribute boolean isProcessRoot; + + // Is this WindowGlobalChild same-origin with `window.top`? + readonly attribute boolean sameOriginWithTop; + + readonly attribute WindowGlobalParent? parentActor; // in-process only + + static WindowGlobalChild? getByInnerWindowId(unsigned long long innerWIndowId); + + /** + * Get or create the JSWindowActor with the given name. + * + * See WindowActorOptions from JSWindowActor.webidl for details on how to + * customize actor creation. + */ + [Throws] + JSWindowActorChild getActor(UTF8String name); + JSWindowActorChild? getExistingActor(UTF8String name); +}; diff --git a/dom/chrome-webidl/XULFrameElement.webidl b/dom/chrome-webidl/XULFrameElement.webidl new file mode 100644 index 0000000000..53be81a04a --- /dev/null +++ b/dom/chrome-webidl/XULFrameElement.webidl @@ -0,0 +1,31 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +interface nsIDocShell; +interface nsIWebNavigation; +interface nsIOpenWindowInfo; + +[ChromeOnly, + Exposed=Window] +interface XULFrameElement : XULElement +{ + [HTMLConstructor] constructor(); + + readonly attribute nsIDocShell? docShell; + readonly attribute nsIWebNavigation? webNavigation; + + readonly attribute WindowProxy? contentWindow; + readonly attribute Document? contentDocument; + + readonly attribute unsigned long long browserId; + + /** + * The optional open window information provided by the window creation code + * and used to initialize a new browser. + */ + attribute nsIOpenWindowInfo? openWindowInfo; +}; + +XULFrameElement includes MozFrameLoaderOwner; diff --git a/dom/chrome-webidl/XULMenuElement.webidl b/dom/chrome-webidl/XULMenuElement.webidl new file mode 100644 index 0000000000..3959c810ba --- /dev/null +++ b/dom/chrome-webidl/XULMenuElement.webidl @@ -0,0 +1,19 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +[ChromeOnly, + Exposed=Window] +interface XULMenuElement : XULElement { + [HTMLConstructor] constructor(); + + [BinaryName="activeMenuChild"] + attribute Element? activeChild; + + boolean handleKeyPress(KeyboardEvent keyEvent); + + readonly attribute boolean openedWithKey; + +}; diff --git a/dom/chrome-webidl/XULTextElement.webidl b/dom/chrome-webidl/XULTextElement.webidl new file mode 100644 index 0000000000..6d75ca8602 --- /dev/null +++ b/dom/chrome-webidl/XULTextElement.webidl @@ -0,0 +1,15 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +[ChromeOnly, + Exposed=Window] +interface XULTextElement : XULElement { + [HTMLConstructor] constructor(); + + attribute boolean disabled; + attribute DOMString value; + attribute DOMString accessKey; +}; diff --git a/dom/chrome-webidl/XULTreeElement.webidl b/dom/chrome-webidl/XULTreeElement.webidl new file mode 100644 index 0000000000..df9dc6a0f9 --- /dev/null +++ b/dom/chrome-webidl/XULTreeElement.webidl @@ -0,0 +1,180 @@ + +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +interface MozTreeView; + +dictionary TreeCellInfo { + long row = 0; + TreeColumn? col = null; + DOMString childElt = ""; +}; + +[ChromeOnly, + Exposed=Window] +interface XULTreeElement : XULElement +{ + [HTMLConstructor] constructor(); + + /** + * Obtain the columns. + */ + readonly attribute TreeColumns? columns; + + /** + * The view that backs the tree and that supplies it with its data. + * It is dynamically settable, either using a view attribute on the + * tree tag or by setting this attribute to a new value. + */ + [SetterThrows, NeedsCallerType] + attribute MozTreeView? view; + + /** + * Whether or not we are currently focused. + */ + attribute boolean focused; + + /** + * Obtain the treebody content node + */ + readonly attribute Element? treeBody; + + /** + * Obtain the height of a row. + */ + readonly attribute long rowHeight; + + /** + * Obtain the width of a row. + */ + readonly attribute long rowWidth; + + /** + * Get the pixel position of the horizontal scrollbar. + */ + readonly attribute long horizontalPosition; + + /** + * Get the index of the first visible row. + */ + long getFirstVisibleRow(); + + /** + * Get the index of the last visible row. + */ + long getLastVisibleRow(); + + /** + * Gets the number of possible visible rows. + */ + long getPageLength(); + + /** + * Ensures that a row at a given index is visible. + */ + undefined ensureRowIsVisible(long index); + + /** + * Ensures that a given cell in the tree is visible. + */ + [Throws] + undefined ensureCellIsVisible(long row, TreeColumn? col); + + /** + * Scrolls such that the row at index is at the top of the visible view. + */ + undefined scrollToRow(long index); + + /** + * Scroll the tree up or down by numLines lines. Positive + * values move down in the tree. Prevents scrolling off the + * end of the tree. + */ + undefined scrollByLines(long numLines); + + /** + * Scroll the tree up or down by numPages pages. A page + * is considered to be the amount displayed by the tree. + * Positive values move down in the tree. Prevents scrolling + * off the end of the tree. + */ + undefined scrollByPages(long numPages); + + /** + * Invalidation methods for fine-grained painting control. + */ + undefined invalidate(); + undefined invalidateColumn(TreeColumn? col); + undefined invalidateRow(long index); + undefined invalidateCell(long row, TreeColumn? col); + undefined invalidateRange(long startIndex, long endIndex); + + /** + * A hit test that can tell you what row the mouse is over. + * returns -1 for invalid mouse coordinates. + * + * The coordinate system is the client coordinate system for the + * document this tree lives in, and the units are CSS pixels. + */ + long getRowAt(long x, long y); + + /** + * A hit test that can tell you what cell the mouse is over. + * TreeCellInfo.row is the row index hit, returns -1 for invalid mouse + * coordinates. TreeCellInfo.col is the column hit. + * TreeCellInfo.childElt is the pseudoelement hit: this can have values of + * "cell", "twisty", "image", and "text". + * + * The coordinate system is the client coordinate system for the + * document this tree lives in, and the units are CSS pixels. + */ + [Throws] + TreeCellInfo getCellAt(long x, long y); + + /** + * Find the coordinates of an element within a specific cell. + */ + [Throws] + DOMRect? getCoordsForCellItem(long row, TreeColumn col, DOMString element); + + /** + * Determine if the text of a cell is being cropped or not. + */ + [Throws] + boolean isCellCropped(long row, TreeColumn? col); + + /** + * The view is responsible for calling these notification methods when + * rows are added or removed. Index is the position at which the new + * rows were added or at which rows were removed. For + * non-contiguous additions/removals, this method should be called multiple times. + */ + undefined rowCountChanged(long index, long count); + + /** + * Notify the tree that the view is about to perform a batch + * update, that is, add, remove or invalidate several rows at once. + * This must be followed by calling endUpdateBatch(), otherwise the tree + * will get out of sync. + */ + undefined beginUpdateBatch(); + + /** + * Notify the tree that the view has completed a batch update. + */ + undefined endUpdateBatch(); + + /** + * Called on a theme switch to flush out the tree's style and image caches. + */ + undefined clearStyleAndImageCaches(); + + /** + * Remove an image source from the image cache to allow its invalidation. + */ + [Throws] + undefined removeImageCacheEntry(long row, TreeColumn col); +}; diff --git a/dom/chrome-webidl/moz.build b/dom/chrome-webidl/moz.build new file mode 100644 index 0000000000..ef2da6b22a --- /dev/null +++ b/dom/chrome-webidl/moz.build @@ -0,0 +1,112 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +with Files("**"): + BUG_COMPONENT = ("Core", "DOM: Core & HTML") + +with Files("ChannelWrapper.webidl"): + BUG_COMPONENT = ("WebExtensions", "Request Handling") + +with Files("Flex.webidl"): + BUG_COMPONENT = ("Core", "CSS Parsing and Computation") + +with Files("HeapSnapshot.webidl"): + BUG_COMPONENT = ("DevTools", "Memory") + +with Files("InspectorUtils.webidl"): + BUG_COMPONENT = ("DevTools", "Inspector") + +with Files("MatchGlob.webidl"): + BUG_COMPONENT = ("WebExtensions", "General") + +with Files("MatchPattern.webidl"): + BUG_COMPONENT = ("WebExtensions", "General") + +with Files("WebExtension*.webidl"): + BUG_COMPONENT = ("WebExtensions", "General") + +with Files("Glean*.webidl"): + BUG_COMPONENT = ("Toolkit", "Telemetry") + +with Files("IOUtils.webidl"): + BUG_COMPONENT = ("Toolkit", "OS.File") + +with Files("PathUtils.webidl"): + BUG_COMPONENT = ("Toolkit", "OS.File") + +PREPROCESSED_WEBIDL_FILES = [ + "ChromeUtils.webidl", + "IOUtils.webidl", +] + +WEBIDL_FILES = [ + "BrowserSessionStore.webidl", + "BrowsingContext.webidl", + "ChannelWrapper.webidl", + "ClonedErrorHolder.webidl", + "DebuggerNotification.webidl", + "DebuggerNotificationObserver.webidl", + "DebuggerUtils.webidl", + "DocumentL10n.webidl", + "DOMCollectedFrames.webidl", + "DominatorTree.webidl", + "Flex.webidl", + "Fluent.webidl", + "FrameLoader.webidl", + "HeapSnapshot.webidl", + "ImageText.webidl", + "InspectorUtils.webidl", + "IteratorResult.webidl", + "JSActor.webidl", + "JSProcessActor.webidl", + "JSWindowActor.webidl", + "L10nOverlays.webidl", + "L10nRegistry.webidl", + "MatchGlob.webidl", + "MatchPattern.webidl", + "MediaController.webidl", + "MessageManager.webidl", + "MozDocumentObserver.webidl", + "MozSharedMap.webidl", + "MozStorageAsyncStatementParams.webidl", + "MozStorageStatementParams.webidl", + "MozStorageStatementRow.webidl", + "NetDashboard.webidl", + "PathUtils.webidl", + "PrecompiledScript.webidl", + "PromiseDebugging.webidl", + "SessionStoreUtils.webidl", + "StructuredCloneHolder.webidl", + "TelemetryStopwatch.webidl", + "UserInteraction.webidl", + "WebExtensionContentScript.webidl", + "WebExtensionPolicy.webidl", + "WindowGlobalActors.webidl", + "XULFrameElement.webidl", + "XULMenuElement.webidl", + "XULTextElement.webidl", + "XULTreeElement.webidl", +] + +if CONFIG["MOZ_BUILD_APP"] != "mobile/android": + WEBIDL_FILES += [ + "UniFFI.webidl", + ] + +if CONFIG["MOZ_PLACES"]: + WEBIDL_FILES += [ + "PlacesEvent.webidl", + "PlacesObservers.webidl", + ] + +WEBIDL_FILES += [ + "Glean.webidl", + "GleanPings.webidl", +] + +WEBIDL_FILES += [ + "PrioEncoder.webidl", +] |