Document.webidl (29812B)
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 * https://wicg.github.io/scroll-to-text-fragment/#feature-detectability 17 */ 18 19 interface ContentSecurityPolicy; 20 interface PolicyContainer; 21 interface Principal; 22 interface WindowProxy; 23 interface nsISupports; 24 interface URI; 25 interface nsIDocShell; 26 interface nsILoadGroup; 27 interface nsIReferrerInfo; 28 interface nsICookieJarSettings; 29 interface nsIPermissionDelegateHandler; 30 interface XULCommandDispatcher; 31 32 enum VisibilityState { "hidden", "visible" }; 33 34 /* https://dom.spec.whatwg.org/#dictdef-elementcreationoptions */ 35 dictionary ElementCreationOptions { 36 DOMString is; 37 38 [ChromeOnly] 39 DOMString pseudo; 40 }; 41 42 /* https://dom.spec.whatwg.org/#interface-document */ 43 [Exposed=Window] 44 interface Document : Node { 45 [Throws] 46 constructor(); 47 48 [Throws] 49 readonly attribute DOMImplementation implementation; 50 [Pure, Throws, BinaryName="documentURIFromJS", NeedsCallerType] 51 readonly attribute DOMString URL; 52 [Pure, Throws, BinaryName="documentURIFromJS", NeedsCallerType] 53 readonly attribute DOMString documentURI; 54 [Pure] 55 readonly attribute DOMString compatMode; 56 [Pure] 57 readonly attribute DOMString characterSet; 58 [Pure,BinaryName="characterSet"] 59 readonly attribute DOMString charset; // legacy alias of .characterSet 60 [Pure,BinaryName="characterSet"] 61 readonly attribute DOMString inputEncoding; // legacy alias of .characterSet 62 [Pure] 63 readonly attribute DOMString contentType; 64 65 [Pure] 66 readonly attribute DocumentType? doctype; 67 [Pure] 68 readonly attribute Element? documentElement; 69 [Pure] 70 HTMLCollection getElementsByTagName(DOMString localName); 71 [Pure, Throws] 72 HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); 73 [Pure] 74 HTMLCollection getElementsByClassName(DOMString classNames); 75 76 // These DOM methods cannot be accessed by UA Widget scripts 77 // because the DOM element reflectors will be in the content scope, 78 // instead of the desired UA Widget scope. 79 [CEReactions, NewObject, Throws, Func="IsNotUAWidget"] 80 Element createElement(DOMString localName, optional (ElementCreationOptions or DOMString) options = {}); 81 [CEReactions, NewObject, Throws, Func="IsNotUAWidget"] 82 Element createElementNS(DOMString? namespace, DOMString qualifiedName, optional (ElementCreationOptions or DOMString) options = {}); 83 [NewObject] 84 DocumentFragment createDocumentFragment(); 85 [NewObject, Func="IsNotUAWidget"] 86 Text createTextNode(DOMString data); 87 [NewObject, Func="IsNotUAWidget"] 88 Comment createComment(DOMString data); 89 [NewObject, Throws] 90 ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data); 91 92 [CEReactions, Throws, Func="IsNotUAWidget"] 93 Node importNode(Node node, optional boolean deep = false); 94 [CEReactions, Throws, Func="IsNotUAWidget"] 95 Node adoptNode(Node node); 96 97 [NewObject, Throws, NeedsCallerType] 98 Event createEvent(DOMString interface); 99 100 [NewObject, Throws] 101 Range createRange(); 102 103 // NodeFilter.SHOW_ALL = 0xFFFFFFFF 104 [NewObject, Throws] 105 NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null); 106 [NewObject, Throws] 107 TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null); 108 109 // These are not in the spec, but leave them for now for backwards compat. 110 // So sort of like Gecko extensions 111 [NewObject, Throws] 112 CDATASection createCDATASection(DOMString data); 113 [NewObject, Throws] 114 Attr createAttribute(DOMString name); 115 [NewObject, Throws] 116 Attr createAttributeNS(DOMString? namespace, DOMString name); 117 }; 118 119 // https://html.spec.whatwg.org/multipage/dom.html#the-document-object 120 partial interface Document { 121 [Throws, NeedsSubjectPrincipal=NonSystem] 122 static Document parseHTMLUnsafe((TrustedHTML or DOMString) html, optional SetHTMLUnsafeOptions options = {}); 123 124 [PutForwards=href, LegacyUnforgeable] readonly attribute Location? location; 125 [SetterThrows] attribute DOMString domain; 126 readonly attribute UTF8String referrer; 127 [Throws] attribute DOMString cookie; 128 readonly attribute DOMString lastModified; 129 readonly attribute DOMString readyState; 130 131 // DOM tree accessors 132 //(Not proxy yet)getter object (DOMString name); 133 [CEReactions, SetterThrows, Pure] 134 attribute DOMString title; 135 [CEReactions, Pure] 136 attribute DOMString dir; 137 [CEReactions, Pure, SetterThrows] 138 attribute HTMLElement? body; 139 [Pure] 140 readonly attribute HTMLHeadElement? head; 141 [SameObject] readonly attribute HTMLCollection images; 142 [SameObject] readonly attribute HTMLCollection embeds; 143 [SameObject] readonly attribute HTMLCollection plugins; 144 [SameObject] readonly attribute HTMLCollection links; 145 [SameObject] readonly attribute HTMLCollection forms; 146 [SameObject] readonly attribute HTMLCollection scripts; 147 [Pure] 148 NodeList getElementsByName(DOMString elementName); 149 //(Not implemented)readonly attribute DOMElementMap cssElementMap; 150 151 // dynamic markup insertion 152 [CEReactions, Throws] 153 Document open(optional DOMString unused1, optional DOMString unused2); // both arguments are ignored 154 [CEReactions, Throws] 155 WindowProxy? open(UTF8String url, DOMString name, DOMString features); 156 [CEReactions, Throws] 157 undefined close(); 158 [CEReactions, Throws, NeedsSubjectPrincipal=NonSystem] 159 undefined write((TrustedHTML or DOMString)... text); 160 [CEReactions, Throws, NeedsSubjectPrincipal=NonSystem] 161 undefined writeln((TrustedHTML or DOMString)... text); 162 163 // user interaction 164 [Pure] 165 readonly attribute WindowProxy? defaultView; 166 [Throws] 167 boolean hasFocus(); 168 [CEReactions, SetterThrows, SetterNeedsSubjectPrincipal] 169 attribute DOMString designMode; 170 [CEReactions, Throws, NeedsSubjectPrincipal] 171 boolean execCommand(DOMString commandId, optional boolean showUI = false, 172 optional (TrustedHTML or DOMString) value = ""); 173 [Throws, NeedsSubjectPrincipal] 174 boolean queryCommandEnabled(DOMString commandId); 175 [Throws] 176 boolean queryCommandIndeterm(DOMString commandId); 177 [Throws] 178 boolean queryCommandState(DOMString commandId); 179 [Throws, NeedsSubjectPrincipal] 180 boolean queryCommandSupported(DOMString commandId); 181 [Throws] 182 DOMString queryCommandValue(DOMString commandId); 183 //(Not implemented)readonly attribute HTMLCollection commands; 184 185 // special event handler IDL attributes that only apply to Document objects 186 [LegacyLenientThis] attribute EventHandler onreadystatechange; 187 188 /** 189 * True if this document is synthetic : stand alone image, video, audio file, 190 * etc. 191 */ 192 [Func="IsChromeOrUAWidget"] readonly attribute boolean mozSyntheticDocument; 193 /** 194 * Returns the script element whose script is currently being processed. 195 * 196 * @see <https://developer.mozilla.org/en/DOM/document.currentScript> 197 */ 198 [Pure] 199 readonly attribute Element? currentScript; 200 /** 201 * Release the current mouse capture if it is on an element within this 202 * document. 203 * 204 * @see <https://developer.mozilla.org/en/DOM/document.releaseCapture> 205 */ 206 [Deprecated=DocumentReleaseCapture, Pref="dom.mouse_capture.enabled"] 207 undefined releaseCapture(); 208 /** 209 * Use the given DOM element as the source image of target |-moz-element()|. 210 * 211 * This function introduces a new special ID (called "image element ID"), 212 * which is only used by |-moz-element()|, and associates it with the given 213 * DOM element. Image elements ID's have the higher precedence than general 214 * HTML id's, so if |document.mozSetImageElement(<id>, <element>)| is called, 215 * |-moz-element(#<id>)| uses |<element>| as the source image even if there 216 * is another element with id attribute = |<id>|. To unregister an image 217 * element ID |<id>|, call |document.mozSetImageElement(<id>, null)|. 218 * 219 * Example: 220 * <script> 221 * canvas = document.createElement("canvas"); 222 * canvas.setAttribute("width", 100); 223 * canvas.setAttribute("height", 100); 224 * // draw to canvas 225 * document.mozSetImageElement("canvasbg", canvas); 226 * </script> 227 * <div style="background-image: -moz-element(#canvasbg);"></div> 228 * 229 * @param aImageElementId an image element ID to associate with 230 * |aImageElement| 231 * @param aImageElement a DOM element to be used as the source image of 232 * |-moz-element(#aImageElementId)|. If this is null, the function will 233 * unregister the image element ID |aImageElementId|. 234 * 235 * @see <https://developer.mozilla.org/en/DOM/document.mozSetImageElement> 236 */ 237 [UseCounter] 238 undefined mozSetImageElement(DOMString aImageElementId, 239 Element? aImageElement); 240 241 [ChromeOnly] 242 readonly attribute URI? documentURIObject; 243 244 /** 245 * Current referrer policy - one of the referrer policy value from 246 * ReferrerPolicy.webidl. 247 */ 248 [ChromeOnly] 249 readonly attribute ReferrerPolicy referrerPolicy; 250 251 /** 252 * Current referrer info, which holds all referrer related information 253 * including referrer policy and raw referrer of document. 254 */ 255 [ChromeOnly] 256 readonly attribute nsIReferrerInfo referrerInfo; 257 258 // If true, forces the (-moz-native-theme) media query to evaluate to false 259 // on this document. Note this doesn't propagate to subdocuments. 260 [ChromeOnly] 261 attribute boolean forceNonNativeTheme; 262 }; 263 264 // https://html.spec.whatwg.org/multipage/obsolete.html#other-elements%2C-attributes-and-apis 265 partial interface Document { 266 [CEReactions] attribute [LegacyNullToEmptyString] DOMString fgColor; 267 [CEReactions] attribute [LegacyNullToEmptyString] DOMString linkColor; 268 [CEReactions] attribute [LegacyNullToEmptyString] DOMString vlinkColor; 269 [CEReactions] attribute [LegacyNullToEmptyString] DOMString alinkColor; 270 [CEReactions] attribute [LegacyNullToEmptyString] DOMString bgColor; 271 272 [SameObject] readonly attribute HTMLCollection anchors; 273 [SameObject] readonly attribute HTMLCollection applets; 274 275 undefined clear(); 276 // @deprecated These are old Netscape 4 methods. Do not use, 277 // the implementation is no-op. 278 // XXXbz do we actually need these anymore? 279 undefined captureEvents(); 280 undefined releaseEvents(); 281 282 [SameObject] readonly attribute HTMLAllCollection all; 283 }; 284 285 // https://fullscreen.spec.whatwg.org/#api 286 partial interface Document { 287 // Note: Per spec the 'S' in these two is lowercase, but the "Moz" 288 // versions have it uppercase. 289 [LegacyLenientSetter, Unscopable] 290 readonly attribute boolean fullscreen; 291 [BinaryName="fullscreen"] 292 readonly attribute boolean mozFullScreen; 293 [LegacyLenientSetter, NeedsCallerType] 294 readonly attribute boolean fullscreenEnabled; 295 [BinaryName="fullscreenEnabled", NeedsCallerType] 296 readonly attribute boolean mozFullScreenEnabled; 297 298 [NewObject] 299 Promise<undefined> exitFullscreen(); 300 [NewObject, BinaryName="exitFullscreen"] 301 Promise<undefined> mozCancelFullScreen(); 302 303 // Events handlers 304 attribute EventHandler onfullscreenchange; 305 attribute EventHandler onfullscreenerror; 306 }; 307 308 // https://w3c.github.io/pointerlock/#extensions-to-the-document-interface 309 // https://w3c.github.io/pointerlock/#extensions-to-the-documentorshadowroot-mixin 310 partial interface Document { 311 undefined exitPointerLock(); 312 313 // Event handlers 314 attribute EventHandler onpointerlockchange; 315 attribute EventHandler onpointerlockerror; 316 }; 317 318 // Mozilla-internal document extensions specific to error pages. 319 partial interface Document { 320 [Func="Document::CallerIsTrustedAboutCertError", NewObject] 321 Promise<any> addCertException(boolean isTemporary); 322 323 [Func="Document::CallerIsTrustedAboutHttpsOnlyError"] 324 undefined reloadWithHttpsOnlyException(); 325 326 [Func="Document::CallerIsTrustedAboutCertError", Throws] 327 FailedCertSecurityInfo getFailedCertSecurityInfo(); 328 329 [Func="Document::CallerIsTrustedAboutNetError", Throws] 330 NetErrorInfo getNetErrorInfo(); 331 }; 332 333 // https://w3c.github.io/page-visibility/#extensions-to-the-document-interface 334 partial interface Document { 335 readonly attribute boolean hidden; 336 readonly attribute VisibilityState visibilityState; 337 attribute EventHandler onvisibilitychange; 338 }; 339 340 // https://drafts.csswg.org/cssom/#extensions-to-the-document-interface 341 partial interface Document { 342 attribute DOMString? selectedStyleSheetSet; 343 readonly attribute DOMString? lastStyleSheetSet; 344 readonly attribute DOMString? preferredStyleSheetSet; 345 [Constant] 346 readonly attribute DOMStringList styleSheetSets; 347 undefined enableStyleSheetsForSet (DOMString? name); 348 }; 349 350 dictionary CaretPositionFromPointOptions { 351 [Pref="dom.shadowdom.new_caretPositionFromPoint_behavior.enabled"] 352 sequence<ShadowRoot> shadowRoots = []; 353 }; 354 355 // https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface 356 partial interface Document { 357 CaretPosition? caretPositionFromPoint(float x, float y, optional CaretPositionFromPointOptions options = {}); 358 359 readonly attribute Element? scrollingElement; 360 }; 361 362 // https://drafts.csswg.org/web-animations/#extensions-to-the-document-interface 363 partial interface Document { 364 readonly attribute DocumentTimeline timeline; 365 }; 366 367 // https://svgwg.org/svg2-draft/struct.html#InterfaceDocumentExtensions 368 partial interface Document { 369 [BinaryName="SVGRootElement"] 370 readonly attribute SVGSVGElement? rootElement; 371 }; 372 373 // Mozilla extensions of various sorts 374 partial interface Document { 375 // Creates a new XUL element regardless of the document's default type. 376 [ChromeOnly, CEReactions, NewObject, Throws] 377 Element createXULElement(DOMString localName, optional (ElementCreationOptions or DOMString) options = {}); 378 // Wether the document was loaded using a nsXULPrototypeDocument. 379 [ChromeOnly] 380 readonly attribute boolean loadedFromPrototype; 381 382 // Whether we're in android's Picture-in-Picture mode. 383 // Top level document only (for now, if we want to deal with iframes, please 384 // also fix bug 1959448 while at it). 385 [Func="Document::CallerIsSystemPrincipalOrWebCompatAddon"] 386 readonly attribute boolean inAndroidPipMode; 387 388 // The principal to use for the storage area of this document 389 [ChromeOnly] 390 readonly attribute Principal effectiveStoragePrincipal; 391 392 // You should probably not be using this principal getter since it performs 393 // no checks to ensure that the partitioned principal should really be used 394 // here. It is only designed to be used in very specific circumstances, such 395 // as when inheriting the document/storage principal. 396 [ChromeOnly] 397 readonly attribute Principal partitionedPrincipal; 398 399 // The cookieJarSettings of this document 400 [ChromeOnly] 401 readonly attribute nsICookieJarSettings cookieJarSettings; 402 403 // Touch bits 404 // XXXbz I can't find the sane spec for this stuff, so just cribbing 405 // from our xpidl for now. 406 [NewObject, Func="nsGenericHTMLElement::LegacyTouchAPIEnabled"] 407 Touch createTouch(optional Window? view = null, 408 optional EventTarget? target = null, 409 optional long identifier = 0, 410 optional long pageX = 0, 411 optional long pageY = 0, 412 optional long screenX = 0, 413 optional long screenY = 0, 414 optional long clientX = 0, 415 optional long clientY = 0, 416 optional long radiusX = 0, 417 optional long radiusY = 0, 418 optional float rotationAngle = 0, 419 optional float force = 0); 420 // XXXbz a hack to get around the fact that we don't support variadics as 421 // distinguishing arguments yet. Once this hack is removed. we can also 422 // remove the corresponding overload on Document, since Touch... and 423 // sequence<Touch> look the same in the C++. 424 [NewObject, Func="nsGenericHTMLElement::LegacyTouchAPIEnabled"] 425 TouchList createTouchList(Touch touch, Touch... touches); 426 // XXXbz and another hack for the fact that we can't usefully have optional 427 // distinguishing arguments but need a working zero-arg form of 428 // createTouchList(). 429 [NewObject, Func="nsGenericHTMLElement::LegacyTouchAPIEnabled"] 430 TouchList createTouchList(); 431 [NewObject, Func="nsGenericHTMLElement::LegacyTouchAPIEnabled"] 432 TouchList createTouchList(sequence<Touch> touches); 433 434 [ChromeOnly] 435 attribute boolean styleSheetChangeEventsEnabled; 436 437 [ChromeOnly] 438 attribute boolean devToolsAnonymousAndShadowEventsEnabled; 439 440 [ChromeOnly] 441 attribute boolean pausedByDevTools; 442 443 [ChromeOnly, BinaryName="contentLanguageForBindings"] readonly attribute DOMString contentLanguage; 444 445 [ChromeOnly] readonly attribute nsILoadGroup? documentLoadGroup; 446 447 // Blocks the initial document parser until the given promise is settled. 448 // Note: In order to prevent extension or test code from altering about:blank 449 // semantics, this cannot block about:blank. 450 // 451 // If the option `blockScriptCreated` is not set to `false` this alters 452 // the Web-exposed behavior of `document.open()`ed documents, which is bad. 453 [ChromeOnly, NewObject] 454 Promise<any> blockParsing(Promise<any> promise, 455 optional BlockParsingOptions options = {}); 456 457 [Func="nsContentUtils::IsSystemOrPDFJS", BinaryName="blockUnblockOnloadForSystemOrPDFJS"] 458 undefined blockUnblockOnload(boolean block); 459 460 // like documentURI, except that for error pages, it returns the URI we were 461 // trying to load when we hit an error, rather than the error page's own URI. 462 [ChromeOnly] readonly attribute URI? mozDocumentURIIfNotForErrorPages; 463 464 // A promise that is resolved when we have both fired DOMContentLoaded and 465 // are ready to start layout. 466 // This is used for the "document_idle" webextension script injection point. 467 [ChromeOnly, Throws] 468 readonly attribute Promise<undefined> documentReadyForIdle; 469 470 // Lazily created command dispatcher, returns null if the document is not 471 // chrome privileged. 472 [ChromeOnly] 473 readonly attribute XULCommandDispatcher? commandDispatcher; 474 475 [ChromeOnly] 476 attribute boolean devToolsWatchingDOMMutations; 477 478 /** 479 * Returns all the shadow roots connected to the document, in no particular 480 * order, and without regard to open/closed-ness. Also returns UA widgets 481 * (like <video> controls), which can be checked using 482 * ShadowRoot.isUAWidget(). 483 */ 484 [ChromeOnly] 485 sequence<ShadowRoot> getConnectedShadowRoots(); 486 487 /** 488 * By default, we don't send resizes to inactive top browsers. 489 * Some callers (as of this writing the window sizing code and puppeteer) 490 * need to trigger these resizes. 491 * 492 * @param aIncludeInactive whether to include background tabs. 493 */ 494 [ChromeOnly] 495 undefined synchronouslyUpdateRemoteBrowserDimensions(optional boolean aIncludeInactive = false); 496 }; 497 498 dictionary BlockParsingOptions { 499 /** 500 * If true, blocks script-created parsers (created via document.open()) in 501 * addition to network-created parsers. 502 */ 503 boolean blockScriptCreated = true; 504 }; 505 506 // Extension to give chrome JS the ability to determine when a document was 507 // created to satisfy an iframe with srcdoc attribute. 508 partial interface Document { 509 [ChromeOnly] readonly attribute boolean isSrcdocDocument; 510 }; 511 512 513 // Extension to give chrome JS the ability to get the underlying 514 // sandbox flag attribute 515 partial interface Document { 516 [ChromeOnly] readonly attribute DOMString? sandboxFlagsAsString; 517 }; 518 519 520 /** 521 * Chrome document anonymous content management. 522 * This is a Chrome-only API that allows inserting fixed positioned anonymous 523 * content on top of the current page displayed in the document. 524 */ 525 partial interface Document { 526 [ChromeOnly, NewObject, Throws] 527 AnonymousContent insertAnonymousContent(); 528 529 /** 530 * Removes the element inserted into the CanvasFrame given an AnonymousContent 531 * instance. 532 */ 533 [ChromeOnly] 534 undefined removeAnonymousContent(AnonymousContent aContent); 535 }; 536 537 // http://w3c.github.io/selection-api/#extensions-to-document-interface 538 partial interface Document { 539 [Throws] 540 Selection? getSelection(); 541 }; 542 543 // https://github.com/whatwg/html/issues/3338 544 partial interface Document { 545 [Pref="dom.storage_access.enabled", NewObject] 546 Promise<boolean> hasStorageAccess(); 547 [Pref="dom.storage_access.enabled", NewObject] 548 Promise<undefined> requestStorageAccess(); 549 // https://github.com/privacycg/storage-access/pull/100 550 [Pref="dom.storage_access.forward_declared.enabled", NewObject] 551 Promise<undefined> requestStorageAccessUnderSite(DOMString serializedSite); 552 [Pref="dom.storage_access.forward_declared.enabled", NewObject] 553 Promise<undefined> completeStorageAccessRequestFromSite(DOMString serializedSite); 554 }; 555 556 // A privileged API to give chrome privileged code and the content script of the 557 // webcompat extension the ability to request the storage access for a given 558 // third party. 559 partial interface Document { 560 [Func="Document::CallerIsSystemPrincipalOrWebCompatAddon", NewObject] 561 Promise<undefined> requestStorageAccessForOrigin(DOMString thirdPartyOrigin, optional boolean requireUserInteraction = true); 562 }; 563 564 // Extension to give chrome JS the ability to simulate activate the document 565 // by user gesture. 566 partial interface Document { 567 [ChromeOnly] 568 undefined notifyUserGestureActivation(); 569 // For testing only. 570 [ChromeOnly] 571 undefined clearUserGestureActivation(); 572 [ChromeOnly] 573 readonly attribute boolean hasBeenUserGestureActivated; 574 [ChromeOnly] 575 readonly attribute boolean hasValidTransientUserGestureActivation; 576 [ChromeOnly] 577 readonly attribute DOMHighResTimeStamp lastUserGestureTimeStamp; 578 [ChromeOnly] 579 boolean consumeTransientUserGestureActivation(); 580 }; 581 582 // Extension to give chrome JS the ability to set an event handler which is 583 // called with certain events that happened while events were suppressed in the 584 // document or one of its subdocuments. 585 partial interface Document { 586 [ChromeOnly] 587 undefined setSuppressedEventListener(EventListener? aListener); 588 }; 589 590 // Allows frontend code to query a policyContainer which needs to be passed 591 // for a new load into docshell. Further, allows to query the CSP in JSON 592 // format for testing purposes. 593 partial interface Document { 594 [ChromeOnly] readonly attribute PolicyContainer? policyContainer; 595 [ChromeOnly] readonly attribute DOMString cspJSON; 596 }; 597 598 partial interface Document { 599 [ChromeOnly] readonly attribute URI? tlsCertificateBindingURI; 600 }; 601 602 partial interface Document { 603 [Func="Document::DocumentSupportsL10n"] readonly attribute DocumentL10n? l10n; 604 [Func="Document::DocumentSupportsL10n"] readonly attribute boolean hasPendingL10nMutations; 605 }; 606 607 Document includes XPathEvaluatorMixin; 608 Document includes GlobalEventHandlers; 609 Document includes TouchEventHandlers; 610 Document includes ParentNode; 611 Document includes OnErrorEventHandlerForNodes; 612 Document includes GeometryUtils; 613 Document includes FontFaceSource; 614 Document includes DocumentOrShadowRoot; 615 616 // https://w3c.github.io/webappsec-feature-policy/#idl-index 617 partial interface Document { 618 [SameObject, Pref="dom.security.featurePolicy.webidl.enabled"] 619 readonly attribute FeaturePolicy featurePolicy; 620 }; 621 622 // Extension to give chrome JS the ability to specify a non-default keypress 623 // event model. 624 partial interface Document { 625 /** 626 * setKeyPressEventModel() is called when we need to check whether the web 627 * app requires specific keypress event model or not. 628 * 629 * @param aKeyPressEventModel Proper keypress event model for the web app. 630 * KEYPRESS_EVENT_MODEL_DEFAULT: 631 * Use default keypress event model. I.e., depending on 632 * "dom.keyboardevent.keypress.set_keycode_and_charcode_to_same_value" 633 * pref. 634 * KEYPRESS_EVENT_MODEL_SPLIT: 635 * Use split model. I.e, if keypress event inputs a character, 636 * keyCode should be 0. Otherwise, charCode should be 0. 637 * KEYPRESS_EVENT_MODEL_CONFLATED: 638 * Use conflated model. I.e., keyCode and charCode values of each 639 * keypress event should be set to same value. 640 */ 641 [ChromeOnly] 642 const unsigned short KEYPRESS_EVENT_MODEL_DEFAULT = 0; 643 [ChromeOnly] 644 const unsigned short KEYPRESS_EVENT_MODEL_SPLIT = 1; 645 [ChromeOnly] 646 const unsigned short KEYPRESS_EVENT_MODEL_CONFLATED = 2; 647 [ChromeOnly] 648 undefined setKeyPressEventModel(unsigned short aKeyPressEventModel); 649 }; 650 651 // Extensions to return information about about the nodes blocked by the 652 // Safebrowsing API inside a document. 653 partial interface Document { 654 /* 655 * Number of nodes that have been blocked by the Safebrowsing API to prevent 656 * tracking, cryptomining and so on. This method is for testing only. 657 */ 658 [ChromeOnly, Pure] 659 readonly attribute long blockedNodeByClassifierCount; 660 661 /* 662 * List of nodes that have been blocked by the Safebrowsing API to prevent 663 * tracking, fingerprinting, cryptomining and so on. This method is for 664 * testing only. 665 */ 666 [ChromeOnly, Pure] 667 readonly attribute NodeList blockedNodesByClassifier; 668 }; 669 670 // Extension to programmatically simulate a user interaction on a document, 671 // used for testing. 672 partial interface Document { 673 [ChromeOnly, BinaryName="setUserHasInteracted"] 674 undefined userInteractionForTesting(); 675 }; 676 677 // Extension for permission delegation. 678 partial interface Document { 679 [ChromeOnly, Pure] 680 readonly attribute nsIPermissionDelegateHandler permDelegateHandler; 681 }; 682 683 // Extension used by the password manager to infer form submissions. 684 partial interface Document { 685 /* 686 * Set whether the document notifies an event when a fetch or 687 * XHR completes successfully. 688 */ 689 [ChromeOnly] 690 undefined setNotifyFetchSuccess(boolean aShouldNotify); 691 692 /* 693 * Set whether a form and a password field notify an event when it is 694 * removed from the DOM tree. 695 */ 696 [ChromeOnly] 697 undefined setNotifyFormOrPasswordRemoved(boolean aShouldNotify); 698 }; 699 700 // Extension to allow chrome code to detect initial about:blank documents. 701 partial interface Document { 702 /** 703 * https://html.spec.whatwg.org/#is-initial-about:blank 704 * 705 * True if this is the initial about:blank document that the browsing context 706 * started with. Any web-observable browsing context starts out with such 707 * an empty document. 708 * 709 * This flag remains true for the entire lifetime of that document. 710 */ 711 [ChromeOnly] 712 readonly attribute boolean isInitialDocument; 713 714 /** 715 * True if this is the initial about:blank document and it is still transient, 716 * i.e. it has not been committed to as a navigation destination. 717 * 718 * In this state, many actions (e.g. firing the load event) have not yet occurred. 719 * The browser may commit to it synchronously (causing those actions to run), 720 * but it could also remain transient or be replaced. 721 */ 722 [ChromeOnly] 723 readonly attribute boolean isUncommittedInitialDocument; 724 }; 725 726 // Extension to allow chrome code to get some wireframe-like structure. 727 enum WireframeRectType { 728 "image", 729 "background", 730 "text", 731 "unknown", 732 }; 733 dictionary WireframeTaggedRect { 734 unrestricted double x = 0; 735 unrestricted double y = 0; 736 unrestricted double width = 0; 737 unrestricted double height = 0; 738 unsigned long color = 0; // in nscolor format 739 WireframeRectType type; 740 Node? node; 741 }; 742 [GenerateInit] 743 dictionary Wireframe { 744 unsigned long canvasBackground = 0; // in nscolor format 745 sequence<WireframeTaggedRect> rects; 746 unsigned long version = 1; // Increment when the wireframe structure changes in backwards-incompatible ways 747 }; 748 partial interface Document { 749 [ChromeOnly] 750 Wireframe? getWireframe(optional boolean aIncludeNodes = false); 751 }; 752 753 partial interface Document { 754 // Returns true if the document is the current active document in a browsing 755 // context which isn't in bfcache. 756 [ChromeOnly] 757 boolean isActive(); 758 // Allow chrome JS to know whether a document has a valid Onion-Location 759 // that we could redirect to. 760 [ChromeOnly] readonly attribute URI? onionLocationURI; 761 }; 762 763 Document includes NonElementParentNode; 764 765 /** 766 * Extension to add the fragmentDirective property. 767 * https://wicg.github.io/scroll-to-text-fragment/#feature-detectability 768 */ 769 partial interface Document { 770 [Pref="dom.text_fragments.enabled", SameObject] 771 readonly attribute FragmentDirective fragmentDirective; 772 }; 773 774 775 callback ViewTransitionUpdateCallback = Promise<any> (); 776 dictionary StartViewTransitionOptions { 777 ViewTransitionUpdateCallback? update = null; 778 sequence<DOMString>? types = null; 779 }; 780 781 // https://drafts.csswg.org/css-view-transitions-2/#idl-index 782 partial interface Document { 783 [Pref="dom.viewTransitions.enabled"] 784 ViewTransition startViewTransition( 785 optional (ViewTransitionUpdateCallback or StartViewTransitionOptions) callbackOptions = {} 786 ); 787 [Pref="dom.viewTransitions.enabled"] 788 readonly attribute ViewTransition? activeViewTransition; 789 }; 790 791 // https://wicg.github.io/sanitizer-api/#sanitizer-api 792 partial interface Document { 793 [Throws, Pref="dom.security.sanitizer.enabled"] 794 static Document parseHTML(DOMString html, optional SetHTMLOptions options = {}); 795 };