author Boris Zbarsky <>
Tue, 20 May 2014 16:07:17 -0400
changeset 184015 55d1924160c9fcb408935a5ecc2672abf7b60535
parent 182929 882aa0d65975e6a472feb455da572685826090ef
child 184016 c82b3f25333753d26195d85952012df79f271b52
permissions -rw-r--r--
Bug 1012944. Hide window.home/back/forward from web pages, since those are non-standard and cause pages to not set up their own thins with the same names. r=peterv

/* -*- 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
 * The origin of this IDL file is:

interface ApplicationCache;
interface IID;
interface MozFrameRequestCallback;
interface nsIBrowserDOMWindow;
interface nsIMessageBroadcaster;
interface nsIDOMCrypto;
typedef any Transferable;

[Global, NeedNewResolve]
/*sealed*/ interface Window : EventTarget {
  // the current browsing context
  [Unforgeable, Throws,
   CrossOriginReadable] readonly attribute WindowProxy window;
  [Replaceable, Throws,
   CrossOriginReadable] readonly attribute WindowProxy self;
  [Unforgeable, StoreInSlot, Pure, Func="nsGlobalWindow::WindowOnWebIDL"] readonly attribute Document? document;
  [Throws] attribute DOMString name; 
  [PutForwards=href, Unforgeable, Throws,
   CrossOriginReadable, CrossOriginWritable] readonly attribute Location? location;
  [Throws] readonly attribute History history;
  [Replaceable, Throws] readonly attribute BarProp locationbar;
  [Replaceable, Throws] readonly attribute BarProp menubar;
  [Replaceable, Throws] readonly attribute BarProp personalbar;
  [Replaceable, Throws] readonly attribute BarProp scrollbars;
  [Replaceable, Throws] readonly attribute BarProp statusbar;
  [Replaceable, Throws] readonly attribute BarProp toolbar;
  [Throws] attribute DOMString status;
  [Throws, CrossOriginCallable] void close();
  [Throws, CrossOriginReadable] readonly attribute boolean closed;
  [Throws] void stop();
  [Throws, CrossOriginCallable] void focus();
  [Throws, CrossOriginCallable] void blur();

  // other browsing contexts
  [Replaceable, Throws, CrossOriginReadable] readonly attribute WindowProxy frames;
  [Replaceable, CrossOriginReadable] readonly attribute unsigned long length;
  [Unforgeable, Throws, CrossOriginReadable] readonly attribute WindowProxy top;
  [Throws, CrossOriginReadable] attribute WindowProxy? opener;
  //[Throws] readonly attribute WindowProxy parent;
  [Replaceable, Throws, CrossOriginReadable] readonly attribute WindowProxy? parent;
  [Throws] readonly attribute Element? frameElement;
  //[Throws] WindowProxy open(optional DOMString url = "about:blank", optional DOMString target = "_blank", [TreatNullAs=EmptyString] optional DOMString features = "", optional boolean replace = false);
  [Throws] WindowProxy? open(optional DOMString url = "", optional DOMString target = "", [TreatNullAs=EmptyString] optional DOMString features = "");
  // We think the indexed getter is a bug in the spec, it actually needs to live
  // on the WindowProxy
  //getter WindowProxy (unsigned long index);
  //getter object (DOMString name);

  // the user agent
  [Throws] readonly attribute Navigator navigator; 
  [Replaceable, Throws] readonly attribute External external;
  [Throws] readonly attribute ApplicationCache applicationCache;

  // user prompts
  [Throws] void alert(optional DOMString message = "");
  [Throws] boolean confirm(optional DOMString message = "");
  [Throws] DOMString? prompt(optional DOMString message = "", optional DOMString default = "");
  [Throws] void print();
  //[Throws] any showModalDialog(DOMString url, optional any argument);
  [Throws] any showModalDialog(DOMString url, optional any argument, optional DOMString options = "");

  [Throws, CrossOriginCallable] void postMessage(any message, DOMString targetOrigin, optional sequence<Transferable> transfer);

  // also has obsolete members
Window implements GlobalEventHandlers;
Window implements WindowEventHandlers;

interface WindowTimers {
  [Throws] long setTimeout(Function handler, optional long timeout = 0, any... arguments);
  [Throws] long setTimeout(DOMString handler, optional long timeout = 0, any... unused);
  [Throws] void clearTimeout(optional long handle = 0);
  [Throws] long setInterval(Function handler, optional long timeout, any... arguments);
  [Throws] long setInterval(DOMString handler, optional long timeout, any... unused);
  [Throws] void clearInterval(optional long handle = 0);
Window implements WindowTimers;

interface WindowBase64 {
  [Throws] DOMString btoa(DOMString btoa);
  [Throws] DOMString atob(DOMString atob);
Window implements WindowBase64;

interface WindowSessionStorage {
  //[Throws] readonly attribute Storage sessionStorage;
  [Throws] readonly attribute Storage? sessionStorage;
Window implements WindowSessionStorage;

interface WindowLocalStorage {
  [Throws] readonly attribute Storage? localStorage;
Window implements WindowLocalStorage;

partial interface Window {
  void captureEvents();
  void releaseEvents();

partial interface Window {
  //[Throws] Selection getSelection();
  [Throws] Selection? getSelection();

Window implements IDBEnvironment;

partial interface Window {
  //[NewObject, Throws] CSSStyleDeclaration getComputedStyle(Element elt, optional DOMString pseudoElt = "");
  [NewObject, Throws] CSSStyleDeclaration? getComputedStyle(Element elt, optional DOMString pseudoElt = "");

enum ScrollBehavior { "auto", "instant", "smooth" };

dictionary ScrollOptions {
  ScrollBehavior behavior = "auto";

partial interface Window {
  //[Throws,NewObject] MediaQueryList matchMedia(DOMString query);
  [Throws,NewObject] MediaQueryList? matchMedia(DOMString query);
  [Throws] readonly attribute Screen screen;

  // browsing context
  //[Throws] void moveTo(double x, double y);
  //[Throws] void moveBy(double x, double y);
  //[Throws] void resizeTo(double x, double y);
  //[Throws] void resizeBy(double x, double y);
  [Throws] void moveTo(long x, long y);
  [Throws] void moveBy(long x, long y);
  [Throws] void resizeTo(long x, long y);
  [Throws] void resizeBy(long x, long y);

  // viewport
  //[Throws] readonly attribute double innerWidth;
  //[Throws] readonly attribute double innerHeight;
  [Throws] attribute long innerWidth;
  [Throws] attribute long innerHeight;

  // viewport scrolling
  //[Throws] readonly attribute double scrollX;
  //[Throws] readonly attribute double pageXOffset;
  //[Throws] readonly attribute double scrollY;
  //[Throws] readonly attribute double pageYOffset;
  //void scroll(double x, double y, optional ScrollOptions options);
  //void scrollTo(double x, double y, optional ScrollOptions options);
  //void scrollBy(double x, double y, optional ScrollOptions options);
  [Replaceable, Throws] readonly attribute long scrollX;
  [Throws] readonly attribute long pageXOffset;
  [Replaceable, Throws] readonly attribute long scrollY;
  [Throws] readonly attribute long pageYOffset;
  void scroll(long x, long y);
  void scrollTo(long x, long y);
  void scrollBy(long x, long y);

  // client
  //[Throws] readonly attribute double screenX;
  //[Throws] readonly attribute double screenY;
  //[Throws] readonly attribute double outerWidth;
  //[Throws] readonly attribute double outerHeight;
  [Throws] attribute long screenX;
  [Throws] attribute long screenY;
  [Throws] attribute long outerWidth;
  [Throws] attribute long outerHeight;

 * Special function that gets the fill ratio from the compositor used for testing
 * and is an indicator that we're layerizing correctly.
 * This function will call the given callback current fill ratio for a
 * composited frame. We don't guarantee which frame fill ratios will be returned.
partial interface Window {
  [ChromeOnly, Throws] void mozRequestOverfill(OverfillCallback callback);
callback OverfillCallback = void (unsigned long overfill);

partial interface Window {
  [Throws] long requestAnimationFrame(FrameRequestCallback callback);
  [Throws] void cancelAnimationFrame(long handle);
callback FrameRequestCallback = void (DOMHighResTimeStamp time);

partial interface Window {
  [Replaceable, Throws] readonly attribute Performance? performance;

partial interface Window {
  //[Throws] readonly attribute Crypto crypto;
  [Throws] readonly attribute nsIDOMCrypto crypto;

interface SpeechSynthesisGetter {
  [Throws, Pref="media.webspeech.synth.enabled"] readonly attribute SpeechSynthesis speechSynthesis;

Window implements SpeechSynthesisGetter;

interface WindowModal {
  [Throws, Func="nsGlobalWindow::IsModalContentWindow"] readonly attribute any dialogArguments;
  [Throws, Func="nsGlobalWindow::IsModalContentWindow"] attribute any returnValue;
Window implements WindowModal;

// Mozilla-specific stuff
partial interface Window {
  //[NewObject, Throws] CSSStyleDeclaration getDefaultComputedStyle(Element elt, optional DOMString pseudoElt = "");
  [NewObject, Throws] CSSStyleDeclaration? getDefaultComputedStyle(Element elt, optional DOMString pseudoElt = "");

  [Throws] long mozRequestAnimationFrame(MozFrameRequestCallback aCallback);

   * Cancel a refresh callback.
  [Throws] void mozCancelAnimationFrame(long aHandle);
  // Backwards-compat shim for now to make Google maps work
  [Throws] void mozCancelRequestAnimationFrame(long aHandle);

   * The current animation start time in milliseconds since the epoch.
  [Throws] readonly attribute long long mozAnimationStartTime;

  // Mozilla extensions
   * Method for scrolling this window by a number of lines.
  void                      scrollByLines(long numLines);

   * Method for scrolling this window by a number of pages.
  void                      scrollByPages(long numPages);

   * Method for sizing this window to the content in the window.
  [Throws] void             sizeToContent();

  // XXX Shouldn't this be in nsIDOMChromeWindow?
  [ChromeOnly, Replaceable, Throws] readonly attribute MozControllers controllers;

  [Throws] readonly attribute float               mozInnerScreenX;
  [Throws] readonly attribute float               mozInnerScreenY;
  [Throws] readonly attribute float               devicePixelRatio;

  /* The maximum offset that the window can be scrolled to
     (i.e., the document width/height minus the scrollport width/height) */
  [Replaceable, Throws] readonly attribute long   scrollMaxX;
  [Replaceable, Throws] readonly attribute long   scrollMaxY;

  [Throws] attribute boolean                            fullScreen;

  [Throws, ChromeOnly] void             back();
  [Throws, ChromeOnly] void             forward();
  [Throws, ChromeOnly] void             home();

  // XXX Should this be in nsIDOMChromeWindow?
  void                      updateCommands(DOMString action);

  /* Find in page.
   * @param str: the search pattern
   * @param caseSensitive: is the search caseSensitive
   * @param backwards: should we search backwards
   * @param wrapAround: should we wrap the search
   * @param wholeWord: should we search only for whole words
   * @param searchInFrames: should we search through all frames
   * @param showDialog: should we show the Find dialog
  [Throws] boolean          find(optional DOMString str = "",
                                 optional boolean caseSensitive = false,
                                 optional boolean backwards = false,
                                 optional boolean wrapAround = false,
                                 optional boolean wholeWord = false,
                                 optional boolean searchInFrames = false,
                                 optional boolean showDialog = false);

   * Returns the number of times this document for this window has
   * been painted to the screen.
  [Throws] readonly attribute unsigned long long mozPaintCount;

           attribute EventHandler onwheel;

           attribute EventHandler ondevicemotion;
           attribute EventHandler ondeviceorientation;
           attribute EventHandler ondeviceproximity;
           attribute EventHandler onuserproximity;
           attribute EventHandler ondevicelight;

#ifdef MOZ_B2G
           attribute EventHandler onmoztimechange;
           attribute EventHandler onmoznetworkupload;
           attribute EventHandler onmoznetworkdownload;

  void                      dump(DOMString str);

   * This method is here for backwards compatibility with 4.x only,
   * its implementation is a no-op
  void                      setResizable(boolean resizable);

   * This is the scriptable version of
   * nsIDOMWindow::openDialog() that takes 3 optional
   * arguments, plus any additional arguments are passed on as
   * arguments on the dialog's window object (window.arguments).
  [Throws, ChromeOnly] WindowProxy? openDialog(optional DOMString url = "",
                                               optional DOMString name = "",
                                               optional DOMString options = "",
                                               any... extraArguments);

  [Replaceable, Throws] readonly attribute object? content;

  [ChromeOnly, Throws] readonly attribute object? __content;

  [Throws, ChromeOnly] any getInterface(IID iid);

Window implements TouchEventHandlers;

Window implements OnErrorEventHandlerForWindow;

// ConsoleAPI
partial interface Window {
  [Replaceable, GetterThrows]
  readonly attribute Console console;

// Mozilla extension
partial interface Window {
  [Replaceable, Throws]
  readonly attribute (External or WindowProxy) sidebar;

interface ChromeWindow {
  const unsigned short STATE_MAXIMIZED = 1;
  const unsigned short STATE_MINIMIZED = 2;
  const unsigned short STATE_NORMAL = 3;
  const unsigned short STATE_FULLSCREEN = 4;

  readonly attribute unsigned short windowState;

   * browserDOMWindow provides access to yet another layer of
   * utility functions implemented by chrome script. It will be null
   * for DOMWindows not corresponding to browsers.
  [Throws, Func="nsGlobalWindow::IsChromeWindow"]
           attribute nsIBrowserDOMWindow? browserDOMWindow;

  [Throws, Func="nsGlobalWindow::IsChromeWindow"]
  void                      getAttention();

  [Throws, Func="nsGlobalWindow::IsChromeWindow"]
  void                      getAttentionWithCycleCount(long aCycleCount);

  [Throws, Func="nsGlobalWindow::IsChromeWindow"]
  void                      setCursor(DOMString cursor);

  [Throws, Func="nsGlobalWindow::IsChromeWindow"]
  void                      maximize();
  [Throws, Func="nsGlobalWindow::IsChromeWindow"]
  void                      minimize();
  [Throws, Func="nsGlobalWindow::IsChromeWindow"]
  void                      restore();

   * Notify a default button is loaded on a dialog or a wizard.
   * defaultButton is the default button.
  [Throws, Func="nsGlobalWindow::IsChromeWindow"]
  void notifyDefaultButtonLoaded(Element defaultButton);

  [Throws, Func="nsGlobalWindow::IsChromeWindow"]
  readonly attribute nsIMessageBroadcaster messageManager;

   * On some operating systems, we must allow the window manager to
   * handle window dragging. This function tells the window manager to
   * start dragging the window. This function will fail unless called
   * while the left mouse button is held down, callers must check this.
   * The optional panel argument should be set when moving a panel.
   * Throws NS_ERROR_NOT_IMPLEMENTED if the OS doesn't support this.
  [Throws, Func="nsGlobalWindow::IsChromeWindow"]
  void beginWindowMove(Event mouseDownEvent, optional Element? panel = null);

Window implements ChromeWindow;