Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / dom / webidl / Document.webidl
blob6a00c04796202c911704f58f2cb4da8ef3e4dd82
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4  * You can obtain one at http://mozilla.org/MPL/2.0/.
5  *
6  * https://dom.spec.whatwg.org/#interface-document
7  * https://html.spec.whatwg.org/multipage/dom.html#the-document-object
8  * https://html.spec.whatwg.org/multipage/obsolete.html#other-elements%2C-attributes-and-apis
9  * https://fullscreen.spec.whatwg.org/#api
10  * https://w3c.github.io/pointerlock/#extensions-to-the-document-interface
11  * https://w3c.github.io/pointerlock/#extensions-to-the-documentorshadowroot-mixin
12  * https://w3c.github.io/page-visibility/#extensions-to-the-document-interface
13  * https://drafts.csswg.org/cssom/#extensions-to-the-document-interface
14  * https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface
15  * https://wicg.github.io/feature-policy/#policy
16  */
18 interface ContentSecurityPolicy;
19 interface Principal;
20 interface WindowProxy;
21 interface nsISupports;
22 interface URI;
23 interface nsIDocShell;
24 interface nsILoadGroup;
25 interface nsIReferrerInfo;
26 interface nsICookieJarSettings;
27 interface nsIPermissionDelegateHandler;
28 interface XULCommandDispatcher;
30 enum VisibilityState { "hidden", "visible" };
32 /* https://dom.spec.whatwg.org/#dictdef-elementcreationoptions */
33 dictionary ElementCreationOptions {
34   DOMString is;
36   [ChromeOnly]
37   DOMString pseudo;
40 /* https://dom.spec.whatwg.org/#interface-document */
41 [Exposed=Window,
42  InstrumentedProps=(caretRangeFromPoint,
43                     exitPictureInPicture,
44                     featurePolicy,
45                     onbeforecopy,
46                     onbeforecut,
47                     onbeforepaste,
48                     oncancel,
49                     onfreeze,
50                     onmousewheel,
51                     onresume,
52                     onsearch,
53                     onwebkitfullscreenchange,
54                     onwebkitfullscreenerror,
55                     pictureInPictureElement,
56                     pictureInPictureEnabled,
57                     registerElement,
58                     wasDiscarded,
59                     webkitCancelFullScreen,
60                     webkitCurrentFullScreenElement,
61                     webkitExitFullscreen,
62                     webkitFullscreenElement,
63                     webkitFullscreenEnabled,
64                     webkitHidden,
65                     webkitIsFullScreen,
66                     webkitVisibilityState,
67                     xmlEncoding,
68                     xmlStandalone,
69                     xmlVersion)]
70 interface Document : Node {
71   [Throws]
72   constructor();
74   [Throws]
75   readonly attribute DOMImplementation implementation;
76   [Pure, Throws, BinaryName="documentURIFromJS", NeedsCallerType]
77   readonly attribute DOMString URL;
78   [Pure, Throws, BinaryName="documentURIFromJS", NeedsCallerType]
79   readonly attribute DOMString documentURI;
80   [Pure]
81   readonly attribute DOMString compatMode;
82   [Pure]
83   readonly attribute DOMString characterSet;
84   [Pure,BinaryName="characterSet"]
85   readonly attribute DOMString charset; // legacy alias of .characterSet
86   [Pure,BinaryName="characterSet"]
87   readonly attribute DOMString inputEncoding; // legacy alias of .characterSet
88   [Pure]
89   readonly attribute DOMString contentType;
91   [Pure]
92   readonly attribute DocumentType? doctype;
93   [Pure]
94   readonly attribute Element? documentElement;
95   [Pure]
96   HTMLCollection getElementsByTagName(DOMString localName);
97   [Pure, Throws]
98   HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
99   [Pure]
100   HTMLCollection getElementsByClassName(DOMString classNames);
101   [Pure]
102   Element? getElementById(DOMString elementId);
104   // These DOM methods cannot be accessed by UA Widget scripts
105   // because the DOM element reflectors will be in the content scope,
106   // instead of the desired UA Widget scope.
107   [CEReactions, NewObject, Throws, Func="IsNotUAWidget"]
108   Element createElement(DOMString localName, optional (ElementCreationOptions or DOMString) options = {});
109   [CEReactions, NewObject, Throws, Func="IsNotUAWidget"]
110   Element createElementNS(DOMString? namespace, DOMString qualifiedName, optional (ElementCreationOptions or DOMString) options = {});
111   [NewObject]
112   DocumentFragment createDocumentFragment();
113   [NewObject, Func="IsNotUAWidget"]
114   Text createTextNode(DOMString data);
115   [NewObject, Func="IsNotUAWidget"]
116   Comment createComment(DOMString data);
117   [NewObject, Throws]
118   ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
120   [CEReactions, Throws, Func="IsNotUAWidget"]
121   Node importNode(Node node, optional boolean deep = false);
122   [CEReactions, Throws, Func="IsNotUAWidget"]
123   Node adoptNode(Node node);
125   [NewObject, Throws, NeedsCallerType]
126   Event createEvent(DOMString interface);
128   [NewObject, Throws]
129   Range createRange();
131   // NodeFilter.SHOW_ALL = 0xFFFFFFFF
132   [NewObject, Throws]
133   NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
134   [NewObject, Throws]
135   TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
137   // NEW
138   // No support for prepend/append yet
139   // undefined prepend((Node or DOMString)... nodes);
140   // undefined append((Node or DOMString)... nodes);
142   // These are not in the spec, but leave them for now for backwards compat.
143   // So sort of like Gecko extensions
144   [NewObject, Throws]
145   CDATASection createCDATASection(DOMString data);
146   [NewObject, Throws]
147   Attr createAttribute(DOMString name);
148   [NewObject, Throws]
149   Attr createAttributeNS(DOMString? namespace, DOMString name);
152 // https://html.spec.whatwg.org/multipage/dom.html#the-document-object
153 partial interface Document {
154   [PutForwards=href, LegacyUnforgeable] readonly attribute Location? location;
155   [SetterThrows]                           attribute DOMString domain;
156   readonly attribute DOMString referrer;
157   [Throws] attribute DOMString cookie;
158   readonly attribute DOMString lastModified;
159   readonly attribute DOMString readyState;
161   // DOM tree accessors
162   //(Not proxy yet)getter object (DOMString name);
163   [CEReactions, SetterThrows, Pure]
164            attribute DOMString title;
165   [CEReactions, Pure]
166            attribute DOMString dir;
167   [CEReactions, Pure, SetterThrows]
168            attribute HTMLElement? body;
169   [Pure]
170   readonly attribute HTMLHeadElement? head;
171   [SameObject] readonly attribute HTMLCollection images;
172   [SameObject] readonly attribute HTMLCollection embeds;
173   [SameObject] readonly attribute HTMLCollection plugins;
174   [SameObject] readonly attribute HTMLCollection links;
175   [SameObject] readonly attribute HTMLCollection forms;
176   [SameObject] readonly attribute HTMLCollection scripts;
177   [Pure]
178   NodeList getElementsByName(DOMString elementName);
179   //(Not implemented)readonly attribute DOMElementMap cssElementMap;
181   // dynamic markup insertion
182   [CEReactions, Throws]
183   Document open(optional DOMString unused1, optional DOMString unused2); // both arguments are ignored
184   [CEReactions, Throws]
185   WindowProxy? open(USVString url, DOMString name, DOMString features);
186   [CEReactions, Throws]
187   undefined close();
188   [CEReactions, Throws]
189   undefined write(DOMString... text);
190   [CEReactions, Throws]
191   undefined writeln(DOMString... text);
193   // user interaction
194   [Pure]
195   readonly attribute WindowProxy? defaultView;
196   [Throws]
197   boolean hasFocus();
198   [CEReactions, SetterThrows, SetterNeedsSubjectPrincipal]
199            attribute DOMString designMode;
200   [CEReactions, Throws, NeedsSubjectPrincipal]
201   boolean execCommand(DOMString commandId, optional boolean showUI = false,
202                       optional DOMString value = "");
203   [Throws, NeedsSubjectPrincipal]
204   boolean queryCommandEnabled(DOMString commandId);
205   [Throws]
206   boolean queryCommandIndeterm(DOMString commandId);
207   [Throws]
208   boolean queryCommandState(DOMString commandId);
209   [Throws, NeedsCallerType]
210   boolean queryCommandSupported(DOMString commandId);
211   [Throws]
212   DOMString queryCommandValue(DOMString commandId);
213   //(Not implemented)readonly attribute HTMLCollection commands;
215   // special event handler IDL attributes that only apply to Document objects
216   [LegacyLenientThis] attribute EventHandler onreadystatechange;
218   // Gecko extensions?
219                 attribute EventHandler onbeforescriptexecute;
220                 attribute EventHandler onafterscriptexecute;
222   /**
223    * True if this document is synthetic : stand alone image, video, audio file,
224    * etc.
225    */
226   [Func="IsChromeOrUAWidget"] readonly attribute boolean mozSyntheticDocument;
227   /**
228    * Returns the script element whose script is currently being processed.
229    *
230    * @see <https://developer.mozilla.org/en/DOM/document.currentScript>
231    */
232   [Pure]
233   readonly attribute Element? currentScript;
234   /**
235    * Release the current mouse capture if it is on an element within this
236    * document.
237    *
238    * @see <https://developer.mozilla.org/en/DOM/document.releaseCapture>
239    */
240   [Deprecated=DocumentReleaseCapture, Pref="dom.mouse_capture.enabled"]
241   undefined releaseCapture();
242   /**
243    * Use the given DOM element as the source image of target |-moz-element()|.
244    *
245    * This function introduces a new special ID (called "image element ID"),
246    * which is only used by |-moz-element()|, and associates it with the given
247    * DOM element.  Image elements ID's have the higher precedence than general
248    * HTML id's, so if |document.mozSetImageElement(<id>, <element>)| is called,
249    * |-moz-element(#<id>)| uses |<element>| as the source image even if there
250    * is another element with id attribute = |<id>|.  To unregister an image
251    * element ID |<id>|, call |document.mozSetImageElement(<id>, null)|.
252    *
253    * Example:
254    * <script>
255    *   canvas = document.createElement("canvas");
256    *   canvas.setAttribute("width", 100);
257    *   canvas.setAttribute("height", 100);
258    *   // draw to canvas
259    *   document.mozSetImageElement("canvasbg", canvas);
260    * </script>
261    * <div style="background-image: -moz-element(#canvasbg);"></div>
262    *
263    * @param aImageElementId an image element ID to associate with
264    * |aImageElement|
265    * @param aImageElement a DOM element to be used as the source image of
266    * |-moz-element(#aImageElementId)|. If this is null, the function will
267    * unregister the image element ID |aImageElementId|.
268    *
269    * @see <https://developer.mozilla.org/en/DOM/document.mozSetImageElement>
270    */
271   [UseCounter]
272   undefined mozSetImageElement(DOMString aImageElementId,
273                                Element? aImageElement);
275   [ChromeOnly]
276   readonly attribute URI? documentURIObject;
278   /**
279    * Current referrer policy - one of the referrer policy value from
280    * ReferrerPolicy.webidl.
281    */
282   [ChromeOnly]
283   readonly attribute ReferrerPolicy referrerPolicy;
285     /**
286    * Current referrer info, which holds all referrer related information
287    * including referrer policy and raw referrer of document.
288    */
289   [ChromeOnly]
290   readonly attribute nsIReferrerInfo referrerInfo;
294 // https://html.spec.whatwg.org/multipage/obsolete.html#other-elements%2C-attributes-and-apis
295 partial interface Document {
296   [CEReactions] attribute [LegacyNullToEmptyString] DOMString fgColor;
297   [CEReactions] attribute [LegacyNullToEmptyString] DOMString linkColor;
298   [CEReactions] attribute [LegacyNullToEmptyString] DOMString vlinkColor;
299   [CEReactions] attribute [LegacyNullToEmptyString] DOMString alinkColor;
300   [CEReactions] attribute [LegacyNullToEmptyString] DOMString bgColor;
302   [SameObject] readonly attribute HTMLCollection anchors;
303   [SameObject] readonly attribute HTMLCollection applets;
305   undefined clear();
306   // @deprecated These are old Netscape 4 methods. Do not use,
307   //             the implementation is no-op.
308   // XXXbz do we actually need these anymore?
309   undefined captureEvents();
310   undefined releaseEvents();
312   [SameObject] readonly attribute HTMLAllCollection all;
315 // https://fullscreen.spec.whatwg.org/#api
316 partial interface Document {
317   // Note: Per spec the 'S' in these two is lowercase, but the "Moz"
318   // versions have it uppercase.
319   [LegacyLenientSetter, Unscopable]
320   readonly attribute boolean fullscreen;
321   [BinaryName="fullscreen"]
322   readonly attribute boolean mozFullScreen;
323   [LegacyLenientSetter, NeedsCallerType]
324   readonly attribute boolean fullscreenEnabled;
325   [BinaryName="fullscreenEnabled", NeedsCallerType]
326   readonly attribute boolean mozFullScreenEnabled;
328   [NewObject]
329   Promise<undefined> exitFullscreen();
330   [NewObject, BinaryName="exitFullscreen"]
331   Promise<undefined> mozCancelFullScreen();
333   // Events handlers
334   attribute EventHandler onfullscreenchange;
335   attribute EventHandler onfullscreenerror;
338 // https://w3c.github.io/pointerlock/#extensions-to-the-document-interface
339 // https://w3c.github.io/pointerlock/#extensions-to-the-documentorshadowroot-mixin
340 partial interface Document {
341   undefined exitPointerLock();
343   // Event handlers
344   attribute EventHandler onpointerlockchange;
345   attribute EventHandler onpointerlockerror;
348 // Mozilla-internal document extensions specific to error pages.
349 partial interface Document {
350   [Func="Document::CallerIsTrustedAboutCertError", NewObject]
351   Promise<any> addCertException(boolean isTemporary);
353   [Func="Document::CallerIsTrustedAboutHttpsOnlyError"]
354   undefined reloadWithHttpsOnlyException();
356   [Func="Document::CallerIsTrustedAboutCertError", Throws]
357   FailedCertSecurityInfo getFailedCertSecurityInfo();
359   [Func="Document::CallerIsTrustedAboutNetError", Throws]
360   NetErrorInfo getNetErrorInfo();
363 // https://w3c.github.io/page-visibility/#extensions-to-the-document-interface
364 partial interface Document {
365   readonly attribute boolean hidden;
366   readonly attribute VisibilityState visibilityState;
367            attribute EventHandler onvisibilitychange;
370 // https://drafts.csswg.org/cssom/#extensions-to-the-document-interface
371 partial interface Document {
372     attribute DOMString? selectedStyleSheetSet;
373     readonly attribute DOMString? lastStyleSheetSet;
374     readonly attribute DOMString? preferredStyleSheetSet;
375     [Constant]
376     readonly attribute DOMStringList styleSheetSets;
377     undefined enableStyleSheetsForSet (DOMString? name);
380 // https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface
381 partial interface Document {
382     CaretPosition? caretPositionFromPoint (float x, float y);
384     readonly attribute Element? scrollingElement;
387 // http://dev.w3.org/2006/webapi/selectors-api2/#interface-definitions
388 partial interface Document {
389   [Throws, Pure]
390   Element?  querySelector(UTF8String selectors);
391   [Throws, Pure]
392   NodeList  querySelectorAll(UTF8String selectors);
394   //(Not implemented)Element?  find(DOMString selectors, optional (Element or sequence<Node>)? refNodes);
395   //(Not implemented)NodeList  findAll(DOMString selectors, optional (Element or sequence<Node>)? refNodes);
398 // https://drafts.csswg.org/web-animations/#extensions-to-the-document-interface
399 partial interface Document {
400   [Func="Document::AreWebAnimationsTimelinesEnabled"]
401   readonly attribute DocumentTimeline timeline;
404 // https://svgwg.org/svg2-draft/struct.html#InterfaceDocumentExtensions
405 partial interface Document {
406   [BinaryName="SVGRootElement"]
407   readonly attribute SVGSVGElement? rootElement;
410 //  Mozilla extensions of various sorts
411 partial interface Document {
412   // Creates a new XUL element regardless of the document's default type.
413   [ChromeOnly, CEReactions, NewObject, Throws]
414   Element createXULElement(DOMString localName, optional (ElementCreationOptions or DOMString) options = {});
415   // Wether the document was loaded using a nsXULPrototypeDocument.
416   [ChromeOnly]
417   readonly attribute boolean loadedFromPrototype;
419   // The principal to use for the storage area of this document
420   [ChromeOnly]
421   readonly attribute Principal effectiveStoragePrincipal;
423   // You should probably not be using this principal getter since it performs
424   // no checks to ensure that the partitioned principal should really be used
425   // here.  It is only designed to be used in very specific circumstances, such
426   // as when inheriting the document/storage principal.
427   [ChromeOnly]
428   readonly attribute Principal partitionedPrincipal;
430   // The cookieJarSettings of this document
431   [ChromeOnly]
432   readonly attribute nsICookieJarSettings cookieJarSettings;
434   // Touch bits
435   // XXXbz I can't find the sane spec for this stuff, so just cribbing
436   // from our xpidl for now.
437   [NewObject, Func="nsGenericHTMLElement::LegacyTouchAPIEnabled"]
438   Touch createTouch(optional Window? view = null,
439                     optional EventTarget? target = null,
440                     optional long identifier = 0,
441                     optional long pageX = 0,
442                     optional long pageY = 0,
443                     optional long screenX = 0,
444                     optional long screenY = 0,
445                     optional long clientX = 0,
446                     optional long clientY = 0,
447                     optional long radiusX = 0,
448                     optional long radiusY = 0,
449                     optional float rotationAngle = 0,
450                     optional float force = 0);
451   // XXXbz a hack to get around the fact that we don't support variadics as
452   // distinguishing arguments yet.  Once this hack is removed. we can also
453   // remove the corresponding overload on Document, since Touch... and
454   // sequence<Touch> look the same in the C++.
455   [NewObject, Func="nsGenericHTMLElement::LegacyTouchAPIEnabled"]
456   TouchList createTouchList(Touch touch, Touch... touches);
457   // XXXbz and another hack for the fact that we can't usefully have optional
458   // distinguishing arguments but need a working zero-arg form of
459   // createTouchList().
460   [NewObject, Func="nsGenericHTMLElement::LegacyTouchAPIEnabled"]
461   TouchList createTouchList();
462   [NewObject, Func="nsGenericHTMLElement::LegacyTouchAPIEnabled"]
463   TouchList createTouchList(sequence<Touch> touches);
465   [ChromeOnly]
466   attribute boolean styleSheetChangeEventsEnabled;
468   [ChromeOnly]
469   attribute boolean devToolsAnonymousAndShadowEventsEnabled;
471   [ChromeOnly] readonly attribute DOMString contentLanguage;
473   [ChromeOnly] readonly attribute nsILoadGroup? documentLoadGroup;
475   // Blocks the initial document parser until the given promise is settled.
476   [ChromeOnly, NewObject]
477   Promise<any> blockParsing(Promise<any> promise,
478                             optional BlockParsingOptions options = {});
480   [Func="nsContentUtils::IsSystemOrPDFJS", BinaryName="blockUnblockOnloadForSystemOrPDFJS"]
481   undefined blockUnblockOnload(boolean block);
483   // like documentURI, except that for error pages, it returns the URI we were
484   // trying to load when we hit an error, rather than the error page's own URI.
485   [ChromeOnly] readonly attribute URI? mozDocumentURIIfNotForErrorPages;
487   // A promise that is resolved when we have both fired DOMContentLoaded and
488   // are ready to start layout.
489   // This is used for the  "document_idle" webextension script injection point.
490   [ChromeOnly, Throws]
491   readonly attribute Promise<undefined> documentReadyForIdle;
493   // Lazily created command dispatcher, returns null if the document is not
494   // chrome privileged.
495   [ChromeOnly]
496   readonly attribute XULCommandDispatcher? commandDispatcher;
498   [ChromeOnly]
499   attribute boolean devToolsWatchingDOMMutations;
501   /**
502    * Returns all the shadow roots connected to the document, in no particular
503    * order, and without regard to open/closed-ness. Also returns UA widgets
504    * (like <video> controls), which can be checked using
505    * ShadowRoot.isUAWidget().
506    */
507   [ChromeOnly]
508   sequence<ShadowRoot> getConnectedShadowRoots();
511 dictionary BlockParsingOptions {
512   /**
513    * If true, blocks script-created parsers (created via document.open()) in
514    * addition to network-created parsers.
515    */
516   boolean blockScriptCreated = true;
519 // Extension to give chrome JS the ability to determine when a document was
520 // created to satisfy an iframe with srcdoc attribute.
521 partial interface Document {
522   [ChromeOnly] readonly attribute boolean isSrcdocDocument;
526 // Extension to give chrome JS the ability to get the underlying
527 // sandbox flag attribute
528 partial interface Document {
529   [ChromeOnly] readonly attribute DOMString? sandboxFlagsAsString;
534  * Chrome document anonymous content management.
535  * This is a Chrome-only API that allows inserting fixed positioned anonymous
536  * content on top of the current page displayed in the document.
537  */
538 partial interface Document {
539   /**
540    * If aForce is true, tries to update layout to be able to insert the element
541    * synchronously.
542    */
543   [ChromeOnly, NewObject, Throws]
544   AnonymousContent insertAnonymousContent(optional boolean aForce = false);
546   /**
547    * Removes the element inserted into the CanvasFrame given an AnonymousContent
548    * instance.
549    */
550   [ChromeOnly]
551   undefined removeAnonymousContent(AnonymousContent aContent);
554 // http://w3c.github.io/selection-api/#extensions-to-document-interface
555 partial interface Document {
556   [Throws]
557   Selection? getSelection();
560 // https://github.com/whatwg/html/issues/3338
561 partial interface Document {
562   [Pref="dom.storage_access.enabled", NewObject]
563   Promise<boolean> hasStorageAccess();
564   [Pref="dom.storage_access.enabled", NewObject]
565   Promise<undefined> requestStorageAccess();
566   // https://github.com/privacycg/storage-access/pull/100
567   [Pref="dom.storage_access.forward_declared.enabled", NewObject]
568   Promise<undefined> requestStorageAccessUnderSite(DOMString serializedSite);
569   [Pref="dom.storage_access.forward_declared.enabled", NewObject]
570   Promise<undefined> completeStorageAccessRequestFromSite(DOMString serializedSite);
573 // A privileged API to give chrome privileged code and the content script of the
574 // webcompat extension the ability to request the storage access for a given
575 // third party.
576 partial interface Document {
577   [Func="Document::CallerCanAccessPrivilegeSSA", NewObject]
578   Promise<undefined> requestStorageAccessForOrigin(DOMString thirdPartyOrigin, optional boolean requireUserInteraction = true);
581 // Extension to give chrome JS the ability to determine whether
582 // the user has interacted with the document or not.
583 partial interface Document {
584   [ChromeOnly] readonly attribute boolean userHasInteracted;
587 // Extension to give chrome JS the ability to simulate activate the document
588 // by user gesture.
589 partial interface Document {
590   [ChromeOnly]
591   undefined notifyUserGestureActivation();
592   // For testing only.
593   [ChromeOnly]
594   undefined clearUserGestureActivation();
595   [ChromeOnly]
596   readonly attribute boolean hasBeenUserGestureActivated;
597   [ChromeOnly]
598   readonly attribute boolean hasValidTransientUserGestureActivation;
599   [ChromeOnly]
600   readonly attribute DOMHighResTimeStamp lastUserGestureTimeStamp;
601   [ChromeOnly]
602   boolean consumeTransientUserGestureActivation();
605 // Extension to give chrome JS the ability to set an event handler which is
606 // called with certain events that happened while events were suppressed in the
607 // document or one of its subdocuments.
608 partial interface Document {
609   [ChromeOnly]
610   undefined setSuppressedEventListener(EventListener? aListener);
613 // Allows frontend code to query a CSP which needs to be passed for a
614 // new load into docshell. Further, allows to query the CSP in JSON
615 // format for testing purposes.
616 partial interface Document {
617   [ChromeOnly] readonly attribute ContentSecurityPolicy? csp;
618   [ChromeOnly] readonly attribute DOMString cspJSON;
621 partial interface Document {
622   [Func="Document::DocumentSupportsL10n"] readonly attribute DocumentL10n? l10n;
623   [Func="Document::DocumentSupportsL10n"] readonly attribute boolean hasPendingL10nMutations;
626 Document includes XPathEvaluatorMixin;
627 Document includes GlobalEventHandlers;
628 Document includes TouchEventHandlers;
629 Document includes ParentNode;
630 Document includes OnErrorEventHandlerForNodes;
631 Document includes GeometryUtils;
632 Document includes FontFaceSource;
633 Document includes DocumentOrShadowRoot;
635 // https://w3c.github.io/webappsec-feature-policy/#idl-index
636 partial interface Document {
637     [SameObject, Pref="dom.security.featurePolicy.webidl.enabled"]
638     readonly attribute FeaturePolicy featurePolicy;
641 // Extension to give chrome JS the ability to specify a non-default keypress
642 // event model.
643 partial interface Document {
644   /**
645    * setKeyPressEventModel() is called when we need to check whether the web
646    * app requires specific keypress event model or not.
647    *
648    * @param aKeyPressEventModel  Proper keypress event model for the web app.
649    *   KEYPRESS_EVENT_MODEL_DEFAULT:
650    *     Use default keypress event model.  I.e., depending on
651    *     "dom.keyboardevent.keypress.set_keycode_and_charcode_to_same_value"
652    *     pref.
653    *   KEYPRESS_EVENT_MODEL_SPLIT:
654    *     Use split model.  I.e, if keypress event inputs a character,
655    *     keyCode should be 0.  Otherwise, charCode should be 0.
656    *   KEYPRESS_EVENT_MODEL_CONFLATED:
657    *     Use conflated model.  I.e., keyCode and charCode values of each
658    *     keypress event should be set to same value.
659    */
660   [ChromeOnly]
661   const unsigned short KEYPRESS_EVENT_MODEL_DEFAULT = 0;
662   [ChromeOnly]
663   const unsigned short KEYPRESS_EVENT_MODEL_SPLIT = 1;
664   [ChromeOnly]
665   const unsigned short KEYPRESS_EVENT_MODEL_CONFLATED = 2;
666   [ChromeOnly]
667   undefined setKeyPressEventModel(unsigned short aKeyPressEventModel);
670 // Extensions to return information about about the nodes blocked by the
671 // Safebrowsing API inside a document.
672 partial interface Document {
673   /*
674    * Number of nodes that have been blocked by the Safebrowsing API to prevent
675    * tracking, cryptomining and so on. This method is for testing only.
676    */
677   [ChromeOnly, Pure]
678   readonly attribute long blockedNodeByClassifierCount;
680   /*
681    * List of nodes that have been blocked by the Safebrowsing API to prevent
682    * tracking, fingerprinting, cryptomining and so on. This method is for
683    * testing only.
684    */
685   [ChromeOnly, Pure]
686   readonly attribute NodeList blockedNodesByClassifier;
689 // Extension to programmatically simulate a user interaction on a document,
690 // used for testing.
691 partial interface Document {
692   [ChromeOnly, BinaryName="setUserHasInteracted"]
693   undefined userInteractionForTesting();
696 // Extension for permission delegation.
697 partial interface Document {
698   [ChromeOnly, Pure]
699   readonly attribute nsIPermissionDelegateHandler permDelegateHandler;
702 // Extension used by the password manager to infer form submissions.
703 partial interface Document {
704   /*
705    * Set whether the document notifies an event when a fetch or
706    * XHR completes successfully.
707    */
708   [ChromeOnly]
709   undefined setNotifyFetchSuccess(boolean aShouldNotify);
711   /*
712    * Set whether a form and a password field notify an event when it is
713    * removed from the DOM tree.
714    */
715   [ChromeOnly]
716   undefined setNotifyFormOrPasswordRemoved(boolean aShouldNotify);
719 // Extension to allow chrome code to detect initial about:blank documents.
720 partial interface Document {
721   [ChromeOnly]
722   readonly attribute boolean isInitialDocument;
725 // Extension to allow chrome code to get some wireframe-like structure.
726 enum WireframeRectType {
727   "image",
728   "background",
729   "text",
730   "unknown",
732 dictionary WireframeTaggedRect {
733   unrestricted double x = 0;
734   unrestricted double y = 0;
735   unrestricted double width = 0;
736   unrestricted double height = 0;
737   unsigned long color = 0; // in nscolor format
738   WireframeRectType type;
739   Node? node;
741 [GenerateInit]
742 dictionary Wireframe {
743   unsigned long canvasBackground = 0; // in nscolor format
744   sequence<WireframeTaggedRect> rects;
745   unsigned long version = 1; // Increment when the wireframe structure changes in backwards-incompatible ways
747 partial interface Document {
748   [ChromeOnly]
749   Wireframe? getWireframe(optional boolean aIncludeNodes = false);
752 partial interface Document {
753   // Returns true if the document is the current active document in a browsing
754   // context which isn't in bfcache.
755   [ChromeOnly]
756   boolean isActive();