Backout changeset 2e466ccc7bd0 for devtools test failures.
authorMs2ger <ms2ger@gmail.com>
Sat, 26 Oct 2013 17:02:20 +0200
changeset 152332 389dbd870f322e2ef8c899aa5e6652302c59039a
parent 152331 32564a62dee7e4bbe7b0c4476c1936eb687266e9
child 152333 85b01def9e0484720530b99c84d66d74a5413bb0
push id35478
push userMs2ger@gmail.com
push dateSat, 26 Oct 2013 15:03:03 +0000
treeherdermozilla-inbound@389dbd870f32 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone27.0a1
backs out2e466ccc7bd04a024dace9cedc9719c300a7f7f7
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backout changeset 2e466ccc7bd0 for devtools test failures.
CLOBBER
browser/devtools/webconsole/test/browser_webconsole_property_provider.js
content/canvas/src/CanvasRenderingContext2D.cpp
content/canvas/src/CanvasRenderingContext2D.h
docshell/base/nsDocShell.cpp
dom/base/WindowNamedPropertiesHandler.cpp
dom/base/nsDOMClassInfoID.h
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
dom/base/nsJSTimeoutHandler.cpp
dom/bindings/BindingDeclarations.h
dom/bindings/Bindings.conf
dom/bindings/Codegen.py
dom/bindings/DOMJSProxyHandler.cpp
dom/gamepad/GamepadService.cpp
dom/imptests/failures/html/html/browsers/the-window-object/test_window-properties.html.json
dom/imptests/failures/html/html/webappapis/atob/test_base64.html.json
dom/tests/mochitest/bugs/grandchild_bug260264.html
dom/webidl/CanvasRenderingContext2D.webidl
dom/webidl/DOMRequest.webidl
dom/webidl/DummyBinding.webidl
dom/webidl/EventHandler.webidl
dom/webidl/IDBEnvironment.webidl
dom/webidl/PeerConnectionImpl.webidl
dom/webidl/PopupBlockedEvent.webidl
dom/webidl/Window.webidl
dom/webidl/moz.build
dom/workers/MessagePort.cpp
dom/workers/MessagePort.h
dom/workers/WorkerMessagePort.cpp
dom/workers/WorkerMessagePort.h
js/src/tests/js1_5/Regress/regress-317476.js
js/src/tests/js1_5/Regress/regress-328897.js
js/xpconnect/src/dom_quickstubs.qsconf
js/xpconnect/src/event_impl_gen.conf.in
js/xpconnect/src/nsDOMQS.h
js/xpconnect/src/nsXPConnect.cpp
layout/base/nsPresContext.cpp
layout/base/nsPresContext.h
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
xpfe/appshell/src/nsXULWindow.cpp
--- a/CLOBBER
+++ b/CLOBBER
@@ -13,9 +13,9 @@
 #          |               |
 #          O <-- Clobber   O  <-- Clobber
 #
 # Note: The description below will be part of the error message shown to users.
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
 
-Bug 918345 needs a clobber due to WebIDL binding dependency issues (bug 928195).
+Bug 914270 needs a clobber since moving variables to moz.build always requires a clobber (bug 852814)
--- a/browser/devtools/webconsole/test/browser_webconsole_property_provider.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_property_provider.js
@@ -26,16 +26,14 @@ function testPropertyProvider() {
   is (completion, null, "no match for 'window[1].acb");
 
   // A very advanced completion case.
   var strComplete =
     'function a() { }document;document.getElementById(window.locatio';
   completion = JSPropertyProvider(content, strComplete);
   ok(completion.matches.length == 2, "two matches found");
   ok(completion.matchProp == "locatio", "matching part is 'test'");
-  var matches = completion.matches;
-  matches.sort();
-  ok(matches[0] == "location", "the first match is 'location'");
-  ok(matches[1] == "locationbar", "the second match is 'locationbar'");
+  ok(completion.matches[0] == "location", "the first match is 'location'");
+  ok(completion.matches[1] == "locationbar", "the second match is 'locationbar'");
 
   finishTest();
 }
 
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -83,17 +83,16 @@
 #include "mozilla/unused.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsWrapperCacheInlines.h"
 #include "mozilla/dom/CanvasRenderingContext2DBinding.h"
 #include "mozilla/dom/HTMLImageElement.h"
 #include "mozilla/dom/HTMLVideoElement.h"
 #include "mozilla/dom/TextMetrics.h"
 #include "mozilla/dom/UnionTypes.h"
-#include "nsGlobalWindow.h"
 
 #ifdef USE_SKIA_GPU
 #undef free // apparently defined by some windows header, clashing with a free()
             // method in SkTypes.h
 #include "GLContext.h"
 #include "GLContextProvider.h"
 #include "GLContextSkia.h"
 #include "SurfaceTypes.h"
@@ -3220,17 +3219,17 @@ CanvasRenderingContext2D::GetGlobalCompo
     Demote();
   }
 #endif
 
 #undef CANVAS_OP_TO_GFX_OP
 }
 
 void
-CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& window, double x,
+CanvasRenderingContext2D::DrawWindow(nsIDOMWindow* window, double x,
                                      double y, double w, double h,
                                      const nsAString& bgColor,
                                      uint32_t flags, ErrorResult& error)
 {
   // protect against too-large surfaces that will cause allocation
   // or overflow issues
   if (!gfxASurface::CheckSurfaceSize(gfxIntSize(int32_t(w), int32_t(h)),
                                      0xffff)) {
@@ -3249,23 +3248,26 @@ CanvasRenderingContext2D::DrawWindow(nsG
     // not permitted to use DrawWindow
     // XXX ERRMSG we need to report an error to developers here! (bug 329026)
     error.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
   }
 
   // Flush layout updates
   if (!(flags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_DO_NOT_FLUSH)) {
-    nsContentUtils::FlushLayoutForTree(&window);
+    nsContentUtils::FlushLayoutForTree(window);
   }
 
   nsRefPtr<nsPresContext> presContext;
-  nsIDocShell* docshell = window.GetDocShell();
-  if (docshell) {
-    docshell->GetPresContext(getter_AddRefs(presContext));
+  nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(window);
+  if (win) {
+    nsIDocShell* docshell = win->GetDocShell();
+    if (docshell) {
+      docshell->GetPresContext(getter_AddRefs(presContext));
+    }
   }
   if (!presContext) {
     error.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   nscolor backgroundColor;
   if (!ParseColor(bgColor, &backgroundColor)) {
--- a/content/canvas/src/CanvasRenderingContext2D.h
+++ b/content/canvas/src/CanvasRenderingContext2D.h
@@ -19,17 +19,16 @@
 #include "mozilla/dom/CanvasGradient.h"
 #include "mozilla/dom/CanvasRenderingContext2DBinding.h"
 #include "mozilla/dom/CanvasPattern.h"
 #include "mozilla/gfx/Rect.h"
 #include "mozilla/gfx/2D.h"
 #include "gfx2DGlue.h"
 #include "imgIEncoder.h"
 
-class nsGlobalWindow;
 class nsXULElement;
 
 namespace mozilla {
 namespace gfx {
 class SourceSurface;
 }
 
 namespace dom {
@@ -365,17 +364,17 @@ public:
 
   void SetImageSmoothingEnabled(bool imageSmoothingEnabled)
   {
     if (imageSmoothingEnabled != CurrentState().imageSmoothingEnabled) {
       CurrentState().imageSmoothingEnabled = imageSmoothingEnabled;
     }
   }
 
-  void DrawWindow(nsGlobalWindow& window, double x, double y, double w, double h,
+  void DrawWindow(nsIDOMWindow* window, double x, double y, double w, double h,
                   const nsAString& bgColor, uint32_t flags,
                   mozilla::ErrorResult& error);
   void AsyncDrawXULElement(nsXULElement& elem, double x, double y, double w,
                            double h, const nsAString& bgColor, uint32_t flags,
                            mozilla::ErrorResult& error);
 
   void Demote();
 
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -8746,17 +8746,17 @@ nsDocShell::InternalLoad(nsIURI * aURI,
         NS_ASSERTION(requestingElement, "A frame but no DOM element!?");
         contentType = nsIContentPolicy::TYPE_SUBDOCUMENT;
     } else {
         contentType = nsIContentPolicy::TYPE_DOCUMENT;
     }
 
     nsISupports* context = requestingElement;
     if (!context) {
-        context = ToSupports(mScriptGlobal);
+        context = nsGlobalWindow::ToSupports(mScriptGlobal);
     }
 
     // XXXbz would be nice to know the loading principal here... but we don't
     nsCOMPtr<nsIPrincipal> loadingPrincipal = do_QueryInterface(aOwner);
     if (!loadingPrincipal && aReferrer) {
         nsCOMPtr<nsIScriptSecurityManager> secMan =
             do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
         NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/base/WindowNamedPropertiesHandler.cpp
+++ b/dom/base/WindowNamedPropertiesHandler.cpp
@@ -86,17 +86,17 @@ WindowNamedPropertiesHandler::getOwnProp
 
   nsDependentJSString str(aId);
 
   // Grab the DOM window.
   XPCWrappedNative* wrapper = XPCWrappedNative::Get(global);
   nsCOMPtr<nsPIDOMWindow> piWin = do_QueryWrappedNative(wrapper);
   MOZ_ASSERT(piWin);
   nsGlobalWindow* win = static_cast<nsGlobalWindow*>(piWin.get());
-  if (win->Length() > 0) {
+  if (win->GetLength() > 0) {
     nsCOMPtr<nsIDOMWindow> childWin = win->GetChildWindow(str);
     if (childWin && ShouldExposeChildWindow(str, childWin)) {
       // We found a subframe of the right name. Shadowing via |var foo| in
       // global scope is still allowed, since |var| only looks up |own|
       // properties. But unqualified shadowing will fail, per-spec.
       JS::Rooted<JS::Value> v(aCx);
       if (!WrapObject(aCx, aProxy, childWin, &v)) {
         return false;
--- a/dom/base/nsDOMClassInfoID.h
+++ b/dom/base/nsDOMClassInfoID.h
@@ -58,18 +58,17 @@ DOMCI_CASTABLE_INTERFACE(nsDOMEvent, nsI
 DOMCI_CASTABLE_INTERFACE(nsIDocument, nsIDocument, 4, _extra)                 \
 DOMCI_CASTABLE_INTERFACE(nsDocument, nsIDocument, 5, _extra)                  \
 DOMCI_CASTABLE_INTERFACE(nsGenericHTMLElement, nsIContent, 6, _extra)         \
 DOMCI_CASTABLE_INTERFACE(nsHTMLDocument, nsIDocument, 7, _extra)              \
 DOMCI_CASTABLE_INTERFACE(nsStyledElement, nsStyledElement, 8, _extra)         \
 DOMCI_CASTABLE_INTERFACE(nsSVGElement, nsIContent, 9, _extra)                 \
 /* NOTE: When removing the casts below, remove the nsDOMEventBase class */    \
 DOMCI_CASTABLE_INTERFACE(nsDOMMouseEvent, nsDOMEventBase, 10, _extra)         \
-DOMCI_CASTABLE_INTERFACE(nsDOMUIEvent, nsDOMEventBase, 11, _extra)            \
-DOMCI_CASTABLE_INTERFACE(nsGlobalWindow, nsIDOMEventTarget, 12, _extra)
+DOMCI_CASTABLE_INTERFACE(nsDOMUIEvent, nsDOMEventBase, 11, _extra)
 
 // Make sure all classes mentioned in DOMCI_CASTABLE_INTERFACES
 // have been declared.
 #define DOMCI_CASTABLE_NODECL_INTERFACE(_interface, _u1, _u2, _u3) /* Nothing */
 #define DOMCI_CASTABLE_INTERFACE(_interface, _u1, _u2, _u3) class _interface;
 DOMCI_CASTABLE_INTERFACES(unused)
 #undef DOMCI_CASTABLE_INTERFACE
 #undef DOMCI_CASTABLE_NODECL_INTERFACE
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -1,9 +1,9 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- 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/. */
 
 #include "nsGlobalWindow.h"
 
 #include <algorithm>
@@ -214,17 +214,16 @@
 #include "prrng.h"
 #include "nsSandboxFlags.h"
 #include "TimeChangeObserver.h"
 #include "mozilla/dom/AudioContext.h"
 #include "mozilla/dom/BrowserElementDictionariesBinding.h"
 #include "mozilla/dom/FunctionBinding.h"
 #include "mozilla/dom/WindowBinding.h"
 #include "mozilla/dom/TabChild.h"
-#include "nsIDOMMediaQueryList.h"
 
 #ifdef MOZ_WEBSPEECH
 #include "mozilla/dom/SpeechSynthesis.h"
 #endif
 
 #ifdef MOZ_JSDEBUGGER
 #include "jsdIDebuggerService.h"
 #endif
@@ -312,29 +311,16 @@ nsGlobalWindow::DOMMinTimeoutValue() con
     if (!outer) {                                                             \
       NS_WARNING("No outer window available!");                               \
       return err_rval;                                                        \
     }                                                                         \
     return outer->method args;                                                \
   }                                                                           \
   PR_END_MACRO
 
-#define FORWARD_TO_OUTER_OR_THROW(method, args, errorresult, err_rval)        \
-  PR_BEGIN_MACRO                                                              \
-  if (IsInnerWindow()) {                                                      \
-    nsGlobalWindow *outer = GetOuterWindowInternal();                         \
-    if (!outer) {                                                             \
-      NS_WARNING("No outer window available!");                               \
-      errorresult.Throw(NS_ERROR_NOT_INITIALIZED);                            \
-      return err_rval;                                                        \
-    }                                                                         \
-    return outer->method args;                                                \
-  }                                                                           \
-  PR_END_MACRO
-
 #define FORWARD_TO_OUTER_VOID(method, args)                                   \
   PR_BEGIN_MACRO                                                              \
   if (IsInnerWindow()) {                                                      \
     nsGlobalWindow *outer = GetOuterWindowInternal();                         \
     if (!outer) {                                                             \
       NS_WARNING("No outer window available!");                               \
       return;                                                                 \
     }                                                                         \
@@ -384,28 +370,16 @@ nsGlobalWindow::DOMMinTimeoutValue() con
     if (!mInnerWindow) {                                                      \
       NS_WARNING("No inner window available!");                               \
       return err_rval;                                                        \
     }                                                                         \
     return GetCurrentInnerWindowInternal()->method args;                      \
   }                                                                           \
   PR_END_MACRO
 
-#define FORWARD_TO_INNER_OR_THROW(method, args, errorresult, err_rval)        \
-  PR_BEGIN_MACRO                                                              \
-  if (IsOuterWindow()) {                                                      \
-    if (!mInnerWindow) {                                                      \
-      NS_WARNING("No inner window available!");                               \
-      errorresult.Throw(NS_ERROR_NOT_INITIALIZED);                            \
-      return err_rval;                                                        \
-    }                                                                         \
-    return GetCurrentInnerWindowInternal()->method args;                      \
-  }                                                                           \
-  PR_END_MACRO
-
 #define FORWARD_TO_INNER_MODAL_CONTENT_WINDOW(method, args, err_rval)         \
   PR_BEGIN_MACRO                                                              \
   if (IsOuterWindow()) {                                                      \
     if (!mInnerWindow) {                                                      \
       NS_WARNING("No inner window available!");                               \
       return err_rval;                                                        \
     }                                                                         \
     return ((nsGlobalModalWindow*)GetCurrentInnerWindowInternal())->method args; \
@@ -944,17 +918,17 @@ nsOuterWindowProxy::GetSubframeWindow(JS
   bool unused;
   return win->IndexedGetter(index, unused);
 }
 
 bool
 nsOuterWindowProxy::AppendIndexedPropertyNames(JSContext *cx, JSObject *proxy,
                                                JS::AutoIdVector &props)
 {
-  uint32_t length = GetWindow(proxy)->Length();
+  uint32_t length = GetWindow(proxy)->GetLength();
   MOZ_ASSERT(int32_t(length) >= 0);
   if (!props.reserve(props.length() + length)) {
     return false;
   }
   for (int32_t i = 0; i < int32_t(length); ++i) {
     props.append(INT_TO_JSID(i));
   }
 
@@ -3332,143 +3306,101 @@ nsPIDOMWindow::UnmuteAudioContexts()
       mAudioContexts[i]->Unmute();
     }
   }
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetDocument(nsIDOMDocument** aDocument)
 {
-  nsCOMPtr<nsIDOMDocument> document = do_QueryInterface(GetDocument());
+  nsCOMPtr<nsIDOMDocument> document = do_QueryInterface(GetDoc());
   document.forget(aDocument);
   return NS_OK;
 }
 
-nsIDOMWindow*
-nsGlobalWindow::GetWindow(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetWindow, (aError), aError, nullptr);
-
-  return this;
-}
-
 NS_IMETHODIMP
 nsGlobalWindow::GetWindow(nsIDOMWindow** aWindow)
 {
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMWindow> window = GetWindow(rv);
-  window.forget(aWindow);
-
-  return rv.ErrorCode();
-}
-
-nsIDOMWindow*
-nsGlobalWindow::GetSelf(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetSelf, (aError), aError, nullptr);
-
-  return this;
+  FORWARD_TO_OUTER(GetWindow, (aWindow), NS_ERROR_NOT_INITIALIZED);
+
+  *aWindow = static_cast<nsIDOMWindow*>(this);
+  NS_ADDREF(*aWindow);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetSelf(nsIDOMWindow** aWindow)
 {
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMWindow> window = GetSelf(rv);
-  window.forget(aWindow);
-
-  return rv.ErrorCode();
-}
-
-Navigator*
-nsGlobalWindow::GetNavigator(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetNavigator, (aError), aError, nullptr);
-
-  if (!mNavigator) {
-    mNavigator = new Navigator(this);
-  }
-
-  return mNavigator;
+  FORWARD_TO_OUTER(GetSelf, (aWindow), NS_ERROR_NOT_INITIALIZED);
+
+  *aWindow = static_cast<nsIDOMWindow*>(this);
+  NS_ADDREF(*aWindow);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetNavigator(nsIDOMNavigator** aNavigator)
 {
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMNavigator> navigator = GetNavigator(rv);
-  navigator.forget(aNavigator);
-
-  return rv.ErrorCode();
-}
-
-nsScreen*
-nsGlobalWindow::GetScreen(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetScreen, (aError), aError, nullptr);
-
-  if (!mScreen) {
-    mScreen = nsScreen::Create(this);
-    if (!mScreen) {
-      aError.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
-  }
-
-  return mScreen;
+  FORWARD_TO_INNER(GetNavigator, (aNavigator), NS_ERROR_NOT_INITIALIZED);
+
+  *aNavigator = nullptr;
+
+  if (!mNavigator) {
+    mNavigator = new Navigator(this);
+  }
+
+  NS_ADDREF(*aNavigator = mNavigator);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScreen(nsIDOMScreen** aScreen)
 {
-  ErrorResult rv;
-  nsRefPtr<nsScreen> screen = GetScreen(rv);
-  screen.forget(aScreen);
-
-  return rv.ErrorCode();
-}
-
-nsHistory*
-nsGlobalWindow::GetHistory(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetHistory, (aError), aError, nullptr);
-
-  if (!mHistory) {
-    mHistory = new nsHistory(this);
-  }
-
-  return mHistory;
+  FORWARD_TO_INNER(GetScreen, (aScreen), NS_ERROR_NOT_INITIALIZED);
+
+  *aScreen = nullptr;
+
+  if (!mScreen) {
+    mScreen = nsScreen::Create(this);
+    if (!mScreen) {
+      return NS_ERROR_UNEXPECTED;
+    }
+  }
+
+  NS_IF_ADDREF(*aScreen = mScreen);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetHistory(nsISupports** aHistory)
 {
-  ErrorResult rv;
-  nsCOMPtr<nsISupports> history = GetHistory(rv);
-  history.forget(aHistory);
-
-  return rv.ErrorCode();
-}
-
-nsPerformance*
-nsGlobalWindow::GetPerformance(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetPerformance, (aError), aError, nullptr);
-
-  return nsPIDOMWindow::GetPerformance();
+  FORWARD_TO_INNER(GetHistory, (aHistory), NS_ERROR_NOT_INITIALIZED);
+
+  *aHistory = nullptr;
+
+  if (!mHistory) {
+    mHistory = new nsHistory(this);
+    if (!mHistory) {
+      return NS_ERROR_OUT_OF_MEMORY;
+    }
+  }
+
+  NS_IF_ADDREF(*aHistory = mHistory);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetPerformance(nsISupports** aPerformance)
 {
-  ErrorResult rv;
-  nsCOMPtr<nsISupports> performance = GetPerformance(rv);
-  performance.forget(aPerformance);
-
-  return rv.ErrorCode();
+  FORWARD_TO_INNER(GetPerformance, (aPerformance), NS_ERROR_NOT_INITIALIZED);
+
+  NS_IF_ADDREF(*aPerformance = nsPIDOMWindow::GetPerformance());
+  return NS_OK;
 }
 
 nsPerformance*
 nsPIDOMWindow::GetPerformance()
 {
   MOZ_ASSERT(IsInnerWindow());
   CreatePerformanceObjectIfNeeded();
   return mPerformance;
@@ -3491,76 +3423,66 @@ nsPIDOMWindow::CreatePerformanceObjectIf
   if (timing) {
     mPerformance = new nsPerformance(this, timing, timedChannel);
   }
 }
 
 // nsISpeechSynthesisGetter
 
 #ifdef MOZ_WEBSPEECH
+NS_IMETHODIMP
+nsGlobalWindow::GetSpeechSynthesis(nsISupports** aSpeechSynthesis)
+{
+  FORWARD_TO_INNER(GetSpeechSynthesis, (aSpeechSynthesis), NS_ERROR_NOT_INITIALIZED);
+
+  NS_IF_ADDREF(*aSpeechSynthesis = GetSpeechSynthesisInternal());
+  return NS_OK;
+}
+
 SpeechSynthesis*
-nsGlobalWindow::GetSpeechSynthesis(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetSpeechSynthesis, (aError), aError, nullptr);
+nsGlobalWindow::GetSpeechSynthesisInternal()
+{
+  MOZ_ASSERT(IsInnerWindow());
+
+  if (!SpeechSynthesis::PrefEnabled()) {
+    return nullptr;
+  }
 
   if (!mSpeechSynthesis) {
     mSpeechSynthesis = new SpeechSynthesis(this);
   }
 
   return mSpeechSynthesis;
 }
-
-NS_IMETHODIMP
-nsGlobalWindow::GetSpeechSynthesis(nsISupports** aSpeechSynthesis)
-{
-  ErrorResult rv;
-  nsCOMPtr<nsISupports> speechSynthesis;
-  if (SpeechSynthesis::PrefEnabled()) {
-    speechSynthesis = GetSpeechSynthesis(rv);
-  }
-  speechSynthesis.forget(aSpeechSynthesis);
-
-  return rv.ErrorCode();
-}
 #endif
 
-already_AddRefed<nsIDOMWindow>
-nsGlobalWindow::GetParent(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetParent, (aError), aError, nullptr);
-
-  if (!mDocShell) {
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIDOMWindow> parent;
-  if (mDocShell->GetIsBrowserOrApp()) {
-    parent = this;
-  } else {
-    aError = GetRealParent(getter_AddRefs(parent));
-  }
-
-  return parent.forget();
-}
-
 /**
  * GetScriptableParent is called when script reads window.parent.
  *
  * In contrast to GetRealParent, GetScriptableParent respects <iframe
  * mozbrowser> boundaries, so if |this| is contained by an <iframe
  * mozbrowser>, we will return |this| as its own parent.
  */
 NS_IMETHODIMP
 nsGlobalWindow::GetScriptableParent(nsIDOMWindow** aParent)
 {
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMWindow> parent = GetParent(rv);
-  parent.forget(aParent);
-
-  return rv.ErrorCode();
+  FORWARD_TO_OUTER(GetScriptableParent, (aParent), NS_ERROR_NOT_INITIALIZED);
+
+  *aParent = NULL;
+  if (!mDocShell) {
+    return NS_OK;
+  }
+
+  if (mDocShell->GetIsBrowserOrApp()) {
+    nsCOMPtr<nsIDOMWindow> parent = static_cast<nsIDOMWindow*>(this);
+    parent.swap(*aParent);
+    return NS_OK;
+  }
+
+  return GetRealParent(aParent);
 }
 
 /**
  * nsIDOMWindow::GetParent (when called from C++) is just a wrapper around
  * GetRealParent.
  */
 NS_IMETHODIMP
 nsGlobalWindow::GetRealParent(nsIDOMWindow** aParent)
@@ -3643,77 +3565,34 @@ nsGlobalWindow::GetTopImpl(nsIDOMWindow*
 
   if (parent) {
     parent.swap(*aTop);
   }
 
   return NS_OK;
 }
 
-JSObject*
-nsGlobalWindow::GetContent(JSContext* aCx, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetContent, (aCx, aError), aError, nullptr);
-
-  nsCOMPtr<nsIDOMWindow> content = GetContentInternal(aError);
-  if (aError.Failed()) {
-    return nullptr;
-  }
-
-  if (content) {
-    JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
-    if (!global) {
-      aError.Throw(NS_ERROR_FAILURE);
-      return nullptr;
-    }
-
-    JS::Rooted<JS::Value> val(aCx);
-    aError = nsContentUtils::WrapNative(aCx, global, content, &val);
-    if (aError.Failed()) {
-      return nullptr;
-    }
-
-    return &val.toObject();
-  }
-
-  if (!nsContentUtils::IsCallerChrome() || !IsChromeWindow()) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  // Something tries to get .content on a ChromeWindow, try to fetch the CPOW.
-  nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
-  if (!treeOwner) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  JS::Rooted<JS::Value> val(aCx);
-  aError = treeOwner->GetContentWindow(aCx, val.address());
-  if (aError.Failed()) {
-    return nullptr;
-  }
-
-  return &val.toObject();
-}
-
-already_AddRefed<nsIDOMWindow>
-nsGlobalWindow::GetContentInternal(ErrorResult& aError)
-{
+NS_IMETHODIMP
+nsGlobalWindow::GetContent(nsIDOMWindow** aContent)
+{
+  FORWARD_TO_OUTER(GetContent, (aContent), NS_ERROR_NOT_INITIALIZED);
+  *aContent = nullptr;
+
   // First check for a named frame named "content"
   nsCOMPtr<nsIDOMWindow> domWindow =
     GetChildWindow(NS_LITERAL_STRING("content"));
   if (domWindow) {
-    return domWindow.forget();
+    domWindow.forget(aContent);
+    return NS_OK;
   }
 
   // If we're contained in <iframe mozbrowser> or <iframe mozapp>, then
   // GetContent is the same as window.top.
   if (mDocShell && mDocShell->GetIsInBrowserOrApp()) {
-    return GetTop(aError);
+    return GetScriptableTop(aContent);
   }
 
   nsCOMPtr<nsIDocShellTreeItem> primaryContent;
   if (!nsContentUtils::IsCallerChrome()) {
     // If we're called by non-chrome code, make sure we don't return
     // the primary content window if the calling tab is hidden. In
     // such a case we return the same-type root in the hidden tab,
     // which is "good enough", for now.
@@ -3726,47 +3605,51 @@ nsGlobalWindow::GetContentInternal(Error
       if (!visible) {
         mDocShell->GetSameTypeRootTreeItem(getter_AddRefs(primaryContent));
       }
     }
   }
 
   if (!primaryContent) {
     nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
-    if (!treeOwner) {
-      aError.Throw(NS_ERROR_FAILURE);
-      return nullptr;
-    }
+    NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);
 
     treeOwner->GetPrimaryContentShell(getter_AddRefs(primaryContent));
   }
 
   domWindow = do_GetInterface(primaryContent);
-  return domWindow.forget();
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::GetContent(nsIDOMWindow** aContent)
-{
-  ErrorResult rv;
-  *aContent = GetContentInternal(rv).get();
-
-  return rv.ErrorCode();
+  domWindow.forget(aContent);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScriptableContent(JSContext* aCx, JS::Value* aVal)
 {
-  ErrorResult rv;
-  JS::Rooted<JSObject*> content(aCx, GetContent(aCx, rv));
-  if (!rv.Failed()) {
-    *aVal = JS::ObjectValue(*content);
-  }
-
-  return rv.ErrorCode();
+  nsCOMPtr<nsIDOMWindow> content;
+  nsresult rv = GetContent(getter_AddRefs(content));
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  if (content || !nsContentUtils::IsCallerChrome() || !IsChromeWindow()) {
+    JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
+    if (content && global) {
+      nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
+      JS::Rooted<JS::Value> rval(aCx);
+      nsresult rv = nsContentUtils::WrapNative(aCx, global, content, &rval,
+                                               getter_AddRefs(wrapper));
+      *aVal = rval;
+      return rv;
+    }
+    return NS_ERROR_FAILURE;
+  }
+
+  // Something tries to get .content on a ChromeWindow, try to fetch the CPOW.
+  nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
+  NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);
+  return treeOwner->GetContentWindow(aCx, aVal);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetPrompter(nsIPrompt** aPrompt)
 {
   FORWARD_TO_OUTER(GetPrompter, (aPrompt), NS_ERROR_NOT_INITIALIZED);
 
   if (!mDocShell)
@@ -3774,161 +3657,139 @@ nsGlobalWindow::GetPrompter(nsIPrompt** 
 
   nsCOMPtr<nsIPrompt> prompter(do_GetInterface(mDocShell));
   NS_ENSURE_TRUE(prompter, NS_ERROR_NO_INTERFACE);
 
   NS_ADDREF(*aPrompt = prompter);
   return NS_OK;
 }
 
-BarProp*
-nsGlobalWindow::GetMenubar(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetMenubar, (aError), aError, nullptr);
+NS_IMETHODIMP
+nsGlobalWindow::GetMenubar(nsISupports** aMenubar)
+{
+  FORWARD_TO_INNER(GetMenubar, (aMenubar), NS_ERROR_NOT_INITIALIZED);
+
+  *aMenubar = nullptr;
 
   if (!mMenubar) {
     mMenubar = new MenubarProp(this);
-  }
-
-  return mMenubar;
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::GetMenubar(nsISupports** aMenubar)
-{
-  ErrorResult rv;
-  nsCOMPtr<nsISupports> menubar = GetMenubar(rv);
-  menubar.forget(aMenubar);
-
-  return rv.ErrorCode();
-}
-
-BarProp*
-nsGlobalWindow::GetToolbar(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetToolbar, (aError), aError, nullptr);
-
-  if (!mToolbar) {
-    mToolbar = new ToolbarProp(this);
-  }
-
-  return mToolbar;
+    if (!mMenubar) {
+      return NS_ERROR_OUT_OF_MEMORY;
+    }
+  }
+
+  NS_ADDREF(*aMenubar = mMenubar);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetToolbar(nsISupports** aToolbar)
 {
-  ErrorResult rv;
-  nsCOMPtr<nsISupports> toolbar = GetToolbar(rv);
-  toolbar.forget(aToolbar);
-
-  return rv.ErrorCode();
-}
-
-BarProp*
-nsGlobalWindow::GetLocationbar(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetLocationbar, (aError), aError, nullptr);
-
-  if (!mLocationbar) {
-    mLocationbar = new LocationbarProp(this);
-  }
-  return mLocationbar;
+  FORWARD_TO_INNER(GetToolbar, (aToolbar), NS_ERROR_NOT_INITIALIZED);
+
+  *aToolbar = nullptr;
+
+  if (!mToolbar) {
+    mToolbar = new ToolbarProp(this);
+    if (!mToolbar) {
+      return NS_ERROR_OUT_OF_MEMORY;
+    }
+  }
+
+  NS_ADDREF(*aToolbar = mToolbar);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetLocationbar(nsISupports** aLocationbar)
 {
-  ErrorResult rv;
-  nsCOMPtr<nsISupports> locationbar = GetLocationbar(rv);
-  locationbar.forget(aLocationbar);
-
-  return rv.ErrorCode();
-}
-
-BarProp*
-nsGlobalWindow::GetPersonalbar(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetPersonalbar, (aError), aError, nullptr);
-
-  if (!mPersonalbar) {
-    mPersonalbar = new PersonalbarProp(this);
-  }
-  return mPersonalbar;
+  FORWARD_TO_INNER(GetLocationbar, (aLocationbar), NS_ERROR_NOT_INITIALIZED);
+
+  *aLocationbar = nullptr;
+
+  if (!mLocationbar) {
+    mLocationbar = new LocationbarProp(this);
+    if (!mLocationbar) {
+      return NS_ERROR_OUT_OF_MEMORY;
+    }
+  }
+
+  NS_ADDREF(*aLocationbar = mLocationbar);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetPersonalbar(nsISupports** aPersonalbar)
 {
-  ErrorResult rv;
-  nsCOMPtr<nsISupports> personalbar = GetPersonalbar(rv);
-  personalbar.forget(aPersonalbar);
-
-  return rv.ErrorCode();
-}
-
-BarProp*
-nsGlobalWindow::GetStatusbar(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetStatusbar, (aError), aError, nullptr);
-
-  if (!mStatusbar) {
-    mStatusbar = new StatusbarProp(this);
-  }
-  return mStatusbar;
+  FORWARD_TO_INNER(GetPersonalbar, (aPersonalbar), NS_ERROR_NOT_INITIALIZED);
+
+  *aPersonalbar = nullptr;
+
+  if (!mPersonalbar) {
+    mPersonalbar = new PersonalbarProp(this);
+    if (!mPersonalbar) {
+      return NS_ERROR_OUT_OF_MEMORY;
+    }
+  }
+
+  NS_ADDREF(*aPersonalbar = mPersonalbar);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetStatusbar(nsISupports** aStatusbar)
 {
-  ErrorResult rv;
-  nsCOMPtr<nsISupports> statusbar = GetStatusbar(rv);
-  statusbar.forget(aStatusbar);
-
-  return rv.ErrorCode();
-}
-
-BarProp*
-nsGlobalWindow::GetScrollbars(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetScrollbars, (aError), aError, nullptr);
-
+  FORWARD_TO_INNER(GetStatusbar, (aStatusbar), NS_ERROR_NOT_INITIALIZED);
+
+  *aStatusbar = nullptr;
+
+  if (!mStatusbar) {
+    mStatusbar = new StatusbarProp(this);
+    if (!mStatusbar) {
+      return NS_ERROR_OUT_OF_MEMORY;
+    }
+  }
+
+  NS_ADDREF(*aStatusbar = mStatusbar);
+
+  return NS_OK;
+}
+
+mozilla::dom::BarProp*
+nsGlobalWindow::GetScrollbars()
+{
+  FORWARD_TO_INNER(GetScrollbars, (), nullptr);
   if (!mScrollbars) {
     mScrollbars = new ScrollbarsProp(this);
   }
 
   return mScrollbars;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScrollbars(nsISupports** aScrollbars)
 {
-  ErrorResult rv;
-  nsCOMPtr<nsISupports> scrollbars = GetScrollbars(rv);
-  scrollbars.forget(aScrollbars);
-
-  return rv.ErrorCode();
-}
-
-bool
-nsGlobalWindow::GetClosed(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetClosed, (aError), aError, false);
-
-  // If someone called close(), or if we don't have a docshell, we're closed.
-  return mIsClosed || !mDocShell;
+  NS_IF_ADDREF(*aScrollbars = GetScrollbars());
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetClosed(bool* aClosed)
 {
-  ErrorResult rv;
-  *aClosed = GetClosed(rv);
-
-  return rv.ErrorCode();
+  FORWARD_TO_OUTER(GetClosed, (aClosed), NS_ERROR_NOT_INITIALIZED);
+
+  // If someone called close(), or if we don't have a docshell, we're
+  // closed.
+  *aClosed = mIsClosed || !mDocShell;
+
+  return NS_OK;
 }
 
 nsDOMWindowList*
 nsGlobalWindow::GetWindowList()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (!mFrames && mDocShell) {
@@ -3973,340 +3834,254 @@ nsGlobalWindow::GetSupportedNames(nsTArr
     for (uint32_t i = 0; i < length; ++i, ++name) {
       nsCOMPtr<nsIDocShellTreeItem> item =
         windows->GetDocShellTreeItemAt(i);
       item->GetName(*name);
     }
   }
 }
 
-nsIDOMOfflineResourceList*
-nsGlobalWindow::GetApplicationCache(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetApplicationCache, (aError), aError, nullptr);
+NS_IMETHODIMP
+nsGlobalWindow::GetApplicationCache(nsIDOMOfflineResourceList **aApplicationCache)
+{
+  FORWARD_TO_INNER(GetApplicationCache, (aApplicationCache), NS_ERROR_UNEXPECTED);
+
+  NS_ENSURE_ARG_POINTER(aApplicationCache);
 
   if (!mApplicationCache) {
     nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetDocShell()));
     if (!webNav) {
-      aError.Throw(NS_ERROR_FAILURE);
-      return nullptr;
+      return NS_ERROR_FAILURE;
     }
 
     nsCOMPtr<nsIURI> uri;
-    aError = webNav->GetCurrentURI(getter_AddRefs(uri));
-    if (aError.Failed()) {
-      return nullptr;
-    }
+    nsresult rv = webNav->GetCurrentURI(getter_AddRefs(uri));
+    NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIURI> manifestURI;
     nsContentUtils::GetOfflineAppManifest(mDoc, getter_AddRefs(manifestURI));
 
     nsRefPtr<nsDOMOfflineResourceList> applicationCache =
       new nsDOMOfflineResourceList(manifestURI, uri, this);
+    NS_ENSURE_TRUE(applicationCache, NS_ERROR_OUT_OF_MEMORY);
 
     applicationCache->Init();
 
     mApplicationCache = applicationCache;
   }
 
-  return mApplicationCache;
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::GetApplicationCache(nsIDOMOfflineResourceList **aApplicationCache)
-{
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMOfflineResourceList> applicationCache =
-    GetApplicationCache(rv);
-  applicationCache.forget(aApplicationCache);
-
-  return rv.ErrorCode();
-}
-
-nsIDOMCrypto*
-nsGlobalWindow::GetCrypto(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetCrypto, (aError), aError, nullptr);
+  NS_IF_ADDREF(*aApplicationCache = mApplicationCache);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::GetCrypto(nsIDOMCrypto** aCrypto)
+{
+  FORWARD_TO_INNER(GetCrypto, (aCrypto), NS_ERROR_NOT_INITIALIZED);
 
   if (!mCrypto) {
 #ifndef MOZ_DISABLE_CRYPTOLEGACY
     if (XRE_GetProcessType() != GeckoProcessType_Content) {
       nsresult rv;
       mCrypto = do_CreateInstance(NS_CRYPTO_CONTRACTID, &rv);
-      if (NS_FAILED(rv)) {
-        aError.Throw(rv);
-        return nullptr;
-      }
+      NS_ENSURE_SUCCESS(rv, rv);
     } else
 #endif
     {
       mCrypto = new Crypto();
     }
 
     mCrypto->Init(this);
   }
-  return mCrypto;
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::GetCrypto(nsIDOMCrypto** aCrypto)
-{
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMCrypto> crypto = GetCrypto(rv);
-  crypto.forget(aCrypto);
-
-  return rv.ErrorCode();
+  NS_IF_ADDREF(*aCrypto = mCrypto);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetPkcs11(nsIDOMPkcs11** aPkcs11)
 {
   *aPkcs11 = nullptr;
   return NS_OK;
 }
 
-nsIControllers*
-nsGlobalWindow::GetControllers(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetControllers, (aError), aError, nullptr);
+NS_IMETHODIMP
+nsGlobalWindow::GetControllers(nsIControllers** aResult)
+{
+  FORWARD_TO_OUTER(GetControllers, (aResult), NS_ERROR_NOT_INITIALIZED);
 
   if (!mControllers) {
     nsresult rv;
     mControllers = do_CreateInstance(kXULControllersCID, &rv);
-    if (NS_FAILED(rv)) {
-      aError.Throw(rv);
-      return nullptr;
-    }
+    NS_ENSURE_SUCCESS(rv, rv);
 
     // Add in the default controller
     nsCOMPtr<nsIController> controller = do_CreateInstance(
                                NS_WINDOWCONTROLLER_CONTRACTID, &rv);
-    if (NS_FAILED(rv)) {
-      aError.Throw(rv);
-      return nullptr;
-    }
+    NS_ENSURE_SUCCESS(rv, rv);
     
     mControllers->InsertControllerAt(0, controller);
     nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller);
-    if (!controllerContext) {
-      aError.Throw(NS_ERROR_FAILURE);
-      return nullptr;
-    }
+    if (!controllerContext) return NS_ERROR_FAILURE;
 
     controllerContext->SetCommandContext(static_cast<nsIDOMWindow*>(this));
   }
 
-  return mControllers;
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::GetControllers(nsIControllers** aResult)
-{
-  ErrorResult rv;
-  nsCOMPtr<nsIControllers> controllers = GetControllers(rv);
-  controllers.forget(aResult);
-
-  return rv.ErrorCode();
-}
-
-nsIDOMWindow*
-nsGlobalWindow::GetOpener(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetOpener, (aError), aError, nullptr);
+  *aResult = mControllers;
+  NS_ADDREF(*aResult);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::GetOpener(nsIDOMWindow** aOpener)
+{
+  FORWARD_TO_OUTER(GetOpener, (aOpener), NS_ERROR_NOT_INITIALIZED);
+
+  *aOpener = nullptr;
 
   nsCOMPtr<nsPIDOMWindow> opener = do_QueryReferent(mOpener);
   if (!opener) {
-    return nullptr;
+    return NS_OK;
   }
 
   // First, check if we were called from a privileged chrome script
   if (nsContentUtils::IsCallerChrome()) {
-    return opener;
+    NS_ADDREF(*aOpener = opener);
+    return NS_OK;
+  }
+
+  nsCOMPtr<nsPIDOMWindow> openerPwin(do_QueryInterface(opener));
+  if (!openerPwin) {
+    return NS_OK;
   }
 
   // First, ensure that we're not handing back a chrome window.
-  nsGlobalWindow *win = static_cast<nsGlobalWindow *>(opener.get());
+  nsGlobalWindow *win = static_cast<nsGlobalWindow *>(openerPwin.get());
   if (win->IsChromeWindow()) {
-    return nullptr;
+    return NS_OK;
   }
 
   // We don't want to reveal the opener if the opener is a mail window,
   // because opener can be used to spoof the contents of a message (bug 105050).
   // So, we look in the opener's root docshell to see if it's a mail window.
-  nsCOMPtr<nsIDocShell> openerDocShell = opener->GetDocShell();
+  nsCOMPtr<nsIDocShell> openerDocShell = openerPwin->GetDocShell();
 
   if (openerDocShell) {
     nsCOMPtr<nsIDocShellTreeItem> openerRootItem;
     openerDocShell->GetRootTreeItem(getter_AddRefs(openerRootItem));
     nsCOMPtr<nsIDocShell> openerRootDocShell(do_QueryInterface(openerRootItem));
     if (openerRootDocShell) {
       uint32_t appType;
       nsresult rv = openerRootDocShell->GetAppType(&appType);
       if (NS_SUCCEEDED(rv) && appType != nsIDocShell::APP_TYPE_MAIL) {
-        return opener;
+        *aOpener = opener;
       }
     }
   }
 
-  return nullptr;
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::GetOpener(nsIDOMWindow** aOpener)
-{
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMWindow> opener = GetOpener(rv);
-  opener.forget(aOpener);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::SetOpener(nsIDOMWindow* aOpener, ErrorResult& aError)
+  NS_IF_ADDREF(*aOpener);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::SetOpener(nsIDOMWindow* aOpener)
 {
   // Check if we were called from a privileged chrome script.  If not, and if
   // aOpener is not null, just define aOpener on our inner window's JS object,
   // wapped into the current compartment so that for Xrays we define on the Xray
   // expando object, but don't set it on the outer window, so that it'll get
   // reset on navigation.  This is just like replaceable properties, but we're
   // not quite readonly.
   if (aOpener && !nsContentUtils::IsCallerChrome()) {
     // JS_WrapObject will outerize, so we don't care if aOpener is an inner.
     nsCOMPtr<nsIGlobalObject> glob = do_QueryInterface(aOpener);
-    if (!glob) {
-      aError.Throw(NS_ERROR_UNEXPECTED);
-      return;
-    }
+    NS_ENSURE_STATE(glob);
 
     AutoJSContext cx;
     JSAutoRequest ar(cx);
     // Note we explicitly do NOT enter any particular compartment here; we want
     // the caller compartment in cases when we have a caller, so that we define
     // expandos on Xrays as needed.
 
     JS::Rooted<JSObject*> otherObj(cx, glob->GetGlobalJSObject());
-    if (!otherObj) {
-      aError.Throw(NS_ERROR_UNEXPECTED);
-      return;
-    }
+    NS_ENSURE_STATE(otherObj);
 
     JS::Rooted<JSObject*> thisObj(cx, mJSObject);
-    if (!mJSObject) {
-      aError.Throw(NS_ERROR_UNEXPECTED);
-      return;
-    }
+    NS_ENSURE_STATE(mJSObject);
 
     if (!JS_WrapObject(cx, &otherObj) ||
         !JS_WrapObject(cx, &thisObj) ||
         !JS_DefineProperty(cx, thisObj, "opener", JS::ObjectValue(*otherObj),
                            JS_PropertyStub, JS_StrictPropertyStub,
                            JSPROP_ENUMERATE)) {
-      aError.Throw(NS_ERROR_FAILURE);
-    }
-
-    return;
+      return NS_ERROR_FAILURE;
+    }
+
+    return NS_OK;
   }
 
   SetOpenerWindow(aOpener, false);
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::SetOpener(nsIDOMWindow* aOpener)
-{
-  ErrorResult rv;
-  SetOpener(aOpener, rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::GetStatus(nsAString& aStatus, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetStatus, (aStatus, aError), aError, );
-
-  aStatus = mStatus;
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetStatus(nsAString& aStatus)
 {
-  ErrorResult rv;
-  GetStatus(aStatus, rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::SetStatus(const nsAString& aStatus, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(SetStatus, (aStatus, aError), aError, );
+  FORWARD_TO_OUTER(GetStatus, (aStatus), NS_ERROR_NOT_INITIALIZED);
+
+  aStatus = mStatus;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::SetStatus(const nsAString& aStatus)
+{
+  FORWARD_TO_OUTER(SetStatus, (aStatus), NS_ERROR_NOT_INITIALIZED);
 
   mStatus = aStatus;
 
   /*
    * If caller is not chrome and dom.disable_window_status_change is true,
    * prevent propagating window.status to the UI by exiting early
    */
 
   if (!CanSetProperty("dom.disable_window_status_change")) {
-    return;
+    return NS_OK;
   }
 
   nsCOMPtr<nsIWebBrowserChrome> browserChrome = GetWebBrowserChrome();
   if (browserChrome) {
     browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_SCRIPT,
                              PromiseFlatString(aStatus).get());
   }
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::SetStatus(const nsAString& aStatus)
-{
-  ErrorResult rv;
-  SetStatus(aStatus, rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::GetName(nsAString& aName, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetName, (aName, aError), aError, );
-
-  if (mDocShell) {
-    mDocShell->GetName(aName);
-  }
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetName(nsAString& aName)
 {
-  ErrorResult rv;
-  GetName(aName, rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::SetName(const nsAString& aName, mozilla::ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(SetName, (aName, aError), aError, );
-
-  if (mDocShell) {
-    aError = mDocShell->SetName(aName);
-  }
+  FORWARD_TO_OUTER(GetName, (aName), NS_ERROR_NOT_INITIALIZED);
+
+  if (mDocShell)
+    mDocShell->GetName(aName);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::SetName(const nsAString& aName)
 {
-  ErrorResult rv;
-  SetName(aName, rv);
-
-  return rv.ErrorCode();
+  FORWARD_TO_OUTER(SetName, (aName), NS_ERROR_NOT_INITIALIZED);
+
+  nsresult result = NS_OK;
+  if (mDocShell)
+    result = mDocShell->SetName(aName);
+  return result;
 }
 
 // Helper functions used by many methods below.
 int32_t
 nsGlobalWindow::DevToCSSIntPixels(int32_t px)
 {
   if (!mDocShell)
     return px; // assume 1:1
@@ -4399,315 +4174,241 @@ nsGlobalWindow::GetInnerSize(CSSIntSize&
     }
 
     aSize = CSSIntRect::FromAppUnitsRounded(
       presContext->GetVisibleArea().Size());
   }
   return NS_OK;
 }
 
-int32_t
-nsGlobalWindow::GetInnerWidth(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetInnerWidth, (aError), aError, 0);
-
-  CSSIntSize size;
-  aError = GetInnerSize(size);
-  return size.width;
-}
-
 NS_IMETHODIMP
 nsGlobalWindow::GetInnerWidth(int32_t* aInnerWidth)
 {
-  ErrorResult rv;
-  *aInnerWidth = GetInnerWidth(rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::SetInnerWidth(int32_t aInnerWidth, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(SetInnerWidth, (aInnerWidth, aError), aError, );
-
-  if (!mDocShell) {
-    aError.Throw(NS_ERROR_UNEXPECTED);
-    return;
-  }
+  FORWARD_TO_OUTER(GetInnerWidth, (aInnerWidth), NS_ERROR_NOT_INITIALIZED);
+
+  CSSIntSize size;
+  nsresult rv = GetInnerSize(size);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  *aInnerWidth = size.width;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::SetInnerWidth(int32_t aInnerWidth)
+{
+  FORWARD_TO_OUTER(SetInnerWidth, (aInnerWidth), NS_ERROR_NOT_INITIALIZED);
+
+  NS_ENSURE_STATE(mDocShell);
 
   /*
    * If caller is not chrome and the user has not explicitly exempted the site,
    * prevent setting window.innerWidth by exiting early
    */
   if (!CanMoveResizeWindows() || IsFrame()) {
-    return;
+    return NS_OK;
   }
 
   CheckSecurityWidthAndHeight(&aInnerWidth, nullptr);
 
+
   nsRefPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
 
   if (presShell && presShell->GetIsViewportOverridden())
   {
     nscoord height = 0;
+    nscoord width  = 0;
 
     nsRefPtr<nsPresContext> presContext;
     presContext = presShell->GetPresContext();
 
     nsRect shellArea = presContext->GetVisibleArea();
     height = shellArea.height;
-    SetCSSViewportWidthAndHeight(nsPresContext::CSSPixelsToAppUnits(aInnerWidth),
-                                 height);
-    return;
-  }
-
-  int32_t height = 0;
-  int32_t unused  = 0;
-
-  nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
-  docShellAsWin->GetSize(&unused, &height);
-  aError = SetDocShellWidthAndHeight(CSSToDevIntPixels(aInnerWidth), height);
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::SetInnerWidth(int32_t aInnerWidth)
-{
-  ErrorResult rv;
-  SetInnerWidth(aInnerWidth, rv);
-
-  return rv.ErrorCode();
-}
-
-int32_t
-nsGlobalWindow::GetInnerHeight(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetInnerHeight, (aError), aError, 0);
-
-  CSSIntSize size;
-  aError = GetInnerSize(size);
-  return size.height;
+    width  = nsPresContext::CSSPixelsToAppUnits(aInnerWidth);
+    SetCSSViewportWidthAndHeight(width, height);
+    return NS_OK;
+  }
+  else
+  {
+    int32_t height = 0;
+    int32_t width  = 0;
+
+    nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
+    docShellAsWin->GetSize(&width, &height);
+    width  = CSSToDevIntPixels(aInnerWidth);
+    return SetDocShellWidthAndHeight(width, height);
+  }
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetInnerHeight(int32_t* aInnerHeight)
 {
-  ErrorResult rv;
-  *aInnerHeight = GetInnerHeight(rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::SetInnerHeight(int32_t aInnerHeight, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(SetInnerHeight, (aInnerHeight, aError), aError, );
-
-  if (!mDocShell) {
-    aError.Throw(NS_ERROR_UNEXPECTED);
-    return;
-  }
+  FORWARD_TO_OUTER(GetInnerHeight, (aInnerHeight), NS_ERROR_NOT_INITIALIZED);
+
+  CSSIntSize size;
+  nsresult rv = GetInnerSize(size);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  *aInnerHeight = size.height;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::SetInnerHeight(int32_t aInnerHeight)
+{
+  FORWARD_TO_OUTER(SetInnerHeight, (aInnerHeight), NS_ERROR_NOT_INITIALIZED);
+
+  NS_ENSURE_STATE(mDocShell);
 
   /*
    * If caller is not chrome and the user has not explicitly exempted the site,
    * prevent setting window.innerHeight by exiting early
    */
   if (!CanMoveResizeWindows() || IsFrame()) {
-    return;
-  }
+    return NS_OK;
+  }
+
+  CheckSecurityWidthAndHeight(nullptr, &aInnerHeight);
 
   nsRefPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
 
   if (presShell && presShell->GetIsViewportOverridden())
   {
+    nscoord height = 0;
+    nscoord width  = 0;
+
     nsRefPtr<nsPresContext> presContext;
     presContext = presShell->GetPresContext();
 
     nsRect shellArea = presContext->GetVisibleArea();
-    nscoord height = aInnerHeight;
-    nscoord width = shellArea.width;
-    CheckSecurityWidthAndHeight(nullptr, &height);
-    SetCSSViewportWidthAndHeight(width,
-                                 nsPresContext::CSSPixelsToAppUnits(height));
-    return;
-  }
-
-  int32_t height = 0;
-  int32_t width  = 0;
-
-  nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
-  docShellAsWin->GetSize(&width, &height);
-  CheckSecurityWidthAndHeight(nullptr, &aInnerHeight);
-  aError = SetDocShellWidthAndHeight(width, CSSToDevIntPixels(aInnerHeight));
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::SetInnerHeight(int32_t aInnerHeight)
-{
-  ErrorResult rv;
-  SetInnerHeight(aInnerHeight, rv);
-
-  return rv.ErrorCode();
-}
-
-nsIntSize
-nsGlobalWindow::GetOuterSize(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetOuterSize, (aError), aError, nsIntSize(0, 0));
-
+    width = shellArea.width;
+    height  = nsPresContext::CSSPixelsToAppUnits(aInnerHeight);
+    SetCSSViewportWidthAndHeight(width, height);
+    return NS_OK;
+  }
+  else
+  {
+    int32_t height = 0;
+    int32_t width  = 0;
+
+    nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
+    docShellAsWin->GetSize(&width, &height);
+    height  = CSSToDevIntPixels(aInnerHeight);
+    return SetDocShellWidthAndHeight(width, height);
+  }
+}
+
+nsresult
+nsGlobalWindow::GetOuterSize(nsIntSize* aSizeCSSPixels)
+{
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
-  if (!treeOwnerAsWin) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return nsIntSize(0, 0);
-  }
+  NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
 
   nsGlobalWindow* rootWindow =
     static_cast<nsGlobalWindow *>(GetPrivateRoot());
   if (rootWindow) {
     rootWindow->FlushPendingNotifications(Flush_Layout);
   }
 
   nsIntSize sizeDevPixels;
-  aError = treeOwnerAsWin->GetSize(&sizeDevPixels.width, &sizeDevPixels.height);
-  if (aError.Failed()) {
-    return nsIntSize();
-  }
-
-  return DevToCSSIntPixels(sizeDevPixels);
-}
-
-int32_t
-nsGlobalWindow::GetOuterWidth(ErrorResult& aError)
-{
-  return GetOuterSize(aError).width;
+  NS_ENSURE_SUCCESS(treeOwnerAsWin->GetSize(&sizeDevPixels.width,
+                                            &sizeDevPixels.height),
+                    NS_ERROR_FAILURE);
+
+  *aSizeCSSPixels = DevToCSSIntPixels(sizeDevPixels);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetOuterWidth(int32_t* aOuterWidth)
 {
-  ErrorResult rv;
-  *aOuterWidth = GetOuterWidth(rv);
-
-  return rv.ErrorCode();
-}
-
-int32_t
-nsGlobalWindow::GetOuterHeight(ErrorResult& aError)
-{
-  return GetOuterSize(aError).height;
+  FORWARD_TO_OUTER(GetOuterWidth, (aOuterWidth), NS_ERROR_NOT_INITIALIZED);
+
+  nsIntSize sizeCSSPixels;
+  nsresult rv = GetOuterSize(&sizeCSSPixels);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  *aOuterWidth = sizeCSSPixels.width;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetOuterHeight(int32_t* aOuterHeight)
 {
-  ErrorResult rv;
-  *aOuterHeight = GetOuterHeight(rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth,
-                             ErrorResult& aError)
+  FORWARD_TO_OUTER(GetOuterHeight, (aOuterHeight), NS_ERROR_NOT_INITIALIZED);
+
+  nsIntSize sizeCSSPixels;
+  nsresult rv = GetOuterSize(&sizeCSSPixels);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  *aOuterHeight = sizeCSSPixels.height;
+  return NS_OK;
+}
+
+nsresult
+nsGlobalWindow::SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth)
 {
   /*
    * If caller is not chrome and the user has not explicitly exempted the site,
    * prevent setting window.outerWidth by exiting early
    */
 
   if (!CanMoveResizeWindows() || IsFrame()) {
-    return;
+    return NS_OK;
   }
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
-  if (!treeOwnerAsWin) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return;
-  }
+  NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
 
   CheckSecurityWidthAndHeight(aIsWidth ? &aLengthCSSPixels : nullptr,
                               aIsWidth ? nullptr : &aLengthCSSPixels);
 
   int32_t width, height;
-  aError = treeOwnerAsWin->GetSize(&width, &height);
-  if (aError.Failed()) {
-    return;
-  }
+  NS_ENSURE_SUCCESS(treeOwnerAsWin->GetSize(&width, &height), NS_ERROR_FAILURE);
 
   int32_t lengthDevPixels = CSSToDevIntPixels(aLengthCSSPixels);
   if (aIsWidth) {
     width = lengthDevPixels;
   } else {
     height = lengthDevPixels;
   }
-  aError = treeOwnerAsWin->SetSize(width, height, true);    
-}
-
-void
-nsGlobalWindow::SetOuterWidth(int32_t aOuterWidth, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(SetOuterWidth, (aOuterWidth, aError), aError, );
-
-  SetOuterSize(aOuterWidth, true, aError);
+  return treeOwnerAsWin->SetSize(width, height, true);    
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::SetOuterWidth(int32_t aOuterWidth)
 {
-  ErrorResult rv;
-  SetOuterWidth(aOuterWidth, rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::SetOuterHeight(int32_t aOuterHeight, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(SetOuterHeight, (aOuterHeight, aError), aError, );
-
-  SetOuterSize(aOuterHeight, false, aError);
+  FORWARD_TO_OUTER(SetOuterWidth, (aOuterWidth), NS_ERROR_NOT_INITIALIZED);
+
+  return SetOuterSize(aOuterWidth, true);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::SetOuterHeight(int32_t aOuterHeight)
 {
-  ErrorResult rv;
-  SetOuterHeight(aOuterHeight, rv);
-
-  return rv.ErrorCode();
-}
-
-nsIntPoint
-nsGlobalWindow::GetScreenXY(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetScreenXY, (aError), aError, nsIntPoint(0, 0));
-
-  nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
-  if (!treeOwnerAsWin) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return nsIntPoint(0, 0);
-  }
-
-  int32_t x = 0, y = 0;
-  aError = treeOwnerAsWin->GetPosition(&x, &y);
-  return nsIntPoint(x, y);
-}
-
-int32_t
-nsGlobalWindow::GetScreenX(ErrorResult& aError)
-{
-  return DevToCSSIntPixels(GetScreenXY(aError).x);
+  FORWARD_TO_OUTER(SetOuterHeight, (aOuterHeight), NS_ERROR_NOT_INITIALIZED);
+
+  return SetOuterSize(aOuterHeight, false);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScreenX(int32_t* aScreenX)
 {
-  ErrorResult rv;
-  *aScreenX = GetScreenX(rv);
-
-  return rv.ErrorCode();
+  FORWARD_TO_OUTER(GetScreenX, (aScreenX), NS_ERROR_NOT_INITIALIZED);
+
+  nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
+  NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
+
+  int32_t x, y;
+
+  NS_ENSURE_SUCCESS(treeOwnerAsWin->GetPosition(&x, &y),
+                    NS_ERROR_FAILURE);
+
+  *aScreenX = DevToCSSIntPixels(x);
+  return NS_OK;
 }
 
 nsRect
 nsGlobalWindow::GetInnerScreenRect()
 {
   if (!mDocShell) {
     return nsRect();
   }
@@ -4729,373 +4430,284 @@ nsGlobalWindow::GetInnerScreenRect()
   nsIFrame* rootFrame = presShell->GetRootFrame();
   if (!rootFrame) {
     return nsRect();
   }
 
   return rootFrame->GetScreenRectInAppUnits();
 }
 
-float
-nsGlobalWindow::GetMozInnerScreenX(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetMozInnerScreenX, (aError), aError, 0);
-
-  nsRect r = GetInnerScreenRect();
-  return nsPresContext::AppUnitsToFloatCSSPixels(r.x);
-}
-
 NS_IMETHODIMP
 nsGlobalWindow::GetMozInnerScreenX(float* aScreenX)
 {
-  ErrorResult rv;
-  *aScreenX = GetMozInnerScreenX(rv);
-
-  return rv.ErrorCode();
-}
-
-float
-nsGlobalWindow::GetMozInnerScreenY(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetMozInnerScreenY, (aError), aError, 0);
+  FORWARD_TO_OUTER(GetMozInnerScreenX, (aScreenX), NS_ERROR_NOT_INITIALIZED);
 
   nsRect r = GetInnerScreenRect();
-  return nsPresContext::AppUnitsToFloatCSSPixels(r.y);
+  *aScreenX = nsPresContext::AppUnitsToFloatCSSPixels(r.x);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetMozInnerScreenY(float* aScreenY)
 {
-  ErrorResult rv;
-  *aScreenY = GetMozInnerScreenY(rv);
-
-  return rv.ErrorCode();
-}
-
-float
-nsGlobalWindow::GetDevicePixelRatio(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetDevicePixelRatio, (aError), aError, 0.0);
-
-  if (!mDocShell) {
-    return 1.0;
-  }
-
-  nsCOMPtr<nsPresContext> presContext;
-  mDocShell->GetPresContext(getter_AddRefs(presContext));
-  if (!presContext) {
-    return 1.0;
-  }
-
-  return float(nsPresContext::AppUnitsPerCSSPixel())/
-      presContext->AppUnitsPerDevPixel();
+  FORWARD_TO_OUTER(GetMozInnerScreenY, (aScreenY), NS_ERROR_NOT_INITIALIZED);
+
+  nsRect r = GetInnerScreenRect();
+  *aScreenY = nsPresContext::AppUnitsToFloatCSSPixels(r.y);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetDevicePixelRatio(float* aRatio)
 {
-  ErrorResult rv;
-  *aRatio = GetDevicePixelRatio(rv);
-
-  return rv.ErrorCode();
-}
-
-uint64_t
-nsGlobalWindow::GetMozPaintCount(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetMozPaintCount, (aError), aError, 0);
-
-  if (!mDocShell) {
-    return 0;
-  }
-
-  nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
-  return presShell ? presShell->GetPaintCount() : 0;
+  FORWARD_TO_OUTER(GetDevicePixelRatio, (aRatio), NS_ERROR_NOT_INITIALIZED);
+
+  *aRatio = 1.0;
+
+  if (!mDocShell)
+    return NS_OK;
+
+  nsCOMPtr<nsPresContext> presContext;
+  mDocShell->GetPresContext(getter_AddRefs(presContext));
+  if (!presContext)
+    return NS_OK;
+
+  *aRatio = float(nsPresContext::AppUnitsPerCSSPixel())/
+      presContext->AppUnitsPerDevPixel();
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetMozPaintCount(uint64_t* aResult)
 {
-  ErrorResult rv;
-  *aResult = GetMozPaintCount(rv);
-
-  return rv.ErrorCode();
+  FORWARD_TO_OUTER(GetMozPaintCount, (aResult), NS_ERROR_NOT_INITIALIZED);
+
+  *aResult = 0;
+
+  if (!mDocShell)
+    return NS_OK;
+
+  nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
+  if (!presShell)
+    return NS_OK;
+
+  *aResult = presShell->GetPaintCount();
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::MozRequestAnimationFrame(nsIFrameRequestCallback* aCallback,
                                          int32_t *aHandle)
 {
+  FORWARD_TO_INNER(MozRequestAnimationFrame, (aCallback, aHandle),
+                   NS_ERROR_NOT_INITIALIZED);
+
   if (!aCallback) {
     if (mDoc) {
       mDoc->WarnOnceAbout(nsIDocument::eMozBeforePaint);
     }
     return NS_ERROR_XPC_BAD_CONVERT_JS;
   }
 
-  ErrorResult rv;
   nsIDocument::FrameRequestCallbackHolder holder(aCallback);
-  *aHandle = RequestAnimationFrame(holder, rv);
-
-  return rv.ErrorCode();
-}
-
-int32_t
-nsGlobalWindow::RequestAnimationFrame(FrameRequestCallback& aCallback,
-                                      ErrorResult& aError)
-{
-  nsIDocument::FrameRequestCallbackHolder holder(&aCallback);
-  return RequestAnimationFrame(holder, aError);
-}
-
-int32_t
-nsGlobalWindow::MozRequestAnimationFrame(nsIFrameRequestCallback* aCallback,
-                                         ErrorResult& aError)
-{
-  nsIDocument::FrameRequestCallbackHolder holder(aCallback);
-  return RequestAnimationFrame(holder, aError);
-}
-
-int32_t
+  return RequestAnimationFrame(holder, aHandle);
+}
+
+nsresult
 nsGlobalWindow::RequestAnimationFrame(const nsIDocument::FrameRequestCallbackHolder& aCallback,
-                                      ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(RequestAnimationFrame, (aCallback, aError), aError,
-                            0);
+                                      int32_t* aHandle)
+{
+  MOZ_ASSERT(IsInnerWindow());
 
   if (!mDoc) {
-    return 0;
-  }
-
-  if (mJSObject) {
+    *aHandle = 0;
+    return NS_OK;
+  }
+
+  if (mJSObject)
     js::NotifyAnimationActivity(mJSObject);
-  }
-
-  int32_t handle;
-  aError = mDoc->ScheduleFrameRequestCallback(aCallback, &handle);
-  return handle;
+
+  return mDoc->ScheduleFrameRequestCallback(aCallback, aHandle);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::RequestAnimationFrame(const JS::Value& aCallback,
                                       JSContext* cx,
                                       int32_t* aHandle)
 {
+  FORWARD_TO_INNER(RequestAnimationFrame, (aCallback, cx, aHandle),
+                   NS_ERROR_NOT_INITIALIZED);
+
   if (!aCallback.isObject() || !JS_ObjectIsCallable(cx, &aCallback.toObject())) {
     return NS_ERROR_INVALID_ARG;
   }
 
   nsRefPtr<FrameRequestCallback> callback =
     new FrameRequestCallback(&aCallback.toObject());
 
-  ErrorResult rv;
-  *aHandle = RequestAnimationFrame(*callback, rv);
-
-  return rv.ErrorCode();
+  nsIDocument::FrameRequestCallbackHolder holder(callback);
+  return RequestAnimationFrame(holder, aHandle);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::MozCancelRequestAnimationFrame(int32_t aHandle)
 {
   return CancelAnimationFrame(aHandle);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::MozCancelAnimationFrame(int32_t aHandle)
 {
   return CancelAnimationFrame(aHandle);
 }
 
-void
-nsGlobalWindow::CancelAnimationFrame(int32_t aHandle, ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(CancelAnimationFrame, (aHandle, aError), aError, );
+NS_IMETHODIMP
+nsGlobalWindow::CancelAnimationFrame(int32_t aHandle)
+{
+  FORWARD_TO_INNER(CancelAnimationFrame, (aHandle),
+                   NS_ERROR_NOT_INITIALIZED);
 
   if (!mDoc) {
-    return;
+    return NS_OK;
   }
 
   mDoc->CancelFrameRequestCallback(aHandle);
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::CancelAnimationFrame(int32_t aHandle)
-{
-  ErrorResult rv;
-  CancelAnimationFrame(aHandle, rv);
-
-  return rv.ErrorCode();
-}
-
-int64_t
-nsGlobalWindow::GetMozAnimationStartTime(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetMozAnimationStartTime, (aError), aError, 0);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::GetMozAnimationStartTime(int64_t *aTime)
+{
+  FORWARD_TO_INNER(GetMozAnimationStartTime, (aTime), NS_ERROR_NOT_INITIALIZED);
 
   if (mDoc) {
     nsIPresShell* presShell = mDoc->GetShell();
     if (presShell) {
-      return presShell->GetPresContext()->RefreshDriver()->
+      *aTime = presShell->GetPresContext()->RefreshDriver()->
         MostRecentRefreshEpochTime() / PR_USEC_PER_MSEC;
+      return NS_OK;
     }
   }
 
   // If all else fails, just be compatible with Date.now()
-  return JS_Now() / PR_USEC_PER_MSEC;
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::GetMozAnimationStartTime(int64_t *aTime)
-{
-  ErrorResult rv;
-  *aTime = GetMozAnimationStartTime(rv);
-
-  return rv.ErrorCode();
-}
-
-already_AddRefed<nsIDOMMediaQueryList>
+  *aTime = JS_Now() / PR_USEC_PER_MSEC;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsGlobalWindow::MatchMedia(const nsAString& aMediaQueryList,
-                           ErrorResult& aError)
+                           nsIDOMMediaQueryList** aResult)
 {
   // FIXME: This whole forward-to-outer and then get a pres
   // shell/context off the docshell dance is sort of silly; it'd make
   // more sense to forward to the inner, but it's what everyone else
   // (GetSelection, GetScrollXY, etc.) does around here.
-  FORWARD_TO_OUTER_OR_THROW(MatchMedia, (aMediaQueryList, aError), aError,
-                            nullptr);
+  FORWARD_TO_OUTER(MatchMedia, (aMediaQueryList, aResult),
+                   NS_ERROR_NOT_INITIALIZED);
+
+  *aResult = nullptr;
 
   // We need this now to ensure that we have a non-null |presContext|
   // when we ought to.
   // This is similar to EnsureSizeUpToDate, but only flushes frames.
   nsGlobalWindow *parent = static_cast<nsGlobalWindow*>(GetPrivateParent());
   if (parent) {
     parent->FlushPendingNotifications(Flush_Frames);
   }
 
-  if (!mDocShell) {
-    return nullptr;
-  }
+  if (!mDocShell)
+    return NS_OK;
 
   nsRefPtr<nsPresContext> presContext;
   mDocShell->GetPresContext(getter_AddRefs(presContext));
 
-  if (!presContext) {
-    return nullptr;
-  }
-
-  return presContext->MatchMedia(aMediaQueryList);
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::MatchMedia(const nsAString& aMediaQueryList,
-                           nsIDOMMediaQueryList** aResult)
-{
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMMediaQueryList> mediaQueryList =
-    MatchMedia(aMediaQueryList, rv);
-  mediaQueryList.forget(aResult);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::SetScreenX(int32_t aScreenX, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(SetScreenX, (aScreenX, aError), aError, );
+  if (!presContext)
+    return NS_OK;
+
+  presContext->MatchMedia(aMediaQueryList, aResult);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::SetScreenX(int32_t aScreenX)
+{
+  FORWARD_TO_OUTER(SetScreenX, (aScreenX), NS_ERROR_NOT_INITIALIZED);
 
   /*
    * If caller is not chrome and the user has not explicitly exempted the site,
    * prevent setting window.screenX by exiting early
    */
 
   if (!CanMoveResizeWindows() || IsFrame()) {
-    return;
+    return NS_OK;
   }
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
-  if (!treeOwnerAsWin) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return;
-  }
-
-  int32_t x, y;
-  aError = treeOwnerAsWin->GetPosition(&x, &y);
-  if (aError.Failed()) {
-    return;
-  }
+  NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
 
   CheckSecurityLeftAndTop(&aScreenX, nullptr);
+
+  int32_t x, y;
+  NS_ENSURE_SUCCESS(treeOwnerAsWin->GetPosition(&x, &y),
+                    NS_ERROR_FAILURE);
+
   x = CSSToDevIntPixels(aScreenX);
 
-  aError = treeOwnerAsWin->SetPosition(x, y);
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::SetScreenX(int32_t aScreenX)
-{
-  ErrorResult rv;
-  SetScreenX(aScreenX, rv);
-
-  return rv.ErrorCode();
-}
-
-int32_t
-nsGlobalWindow::GetScreenY(ErrorResult& aError)
-{
-  return DevToCSSIntPixels(GetScreenXY(aError).y);
+  NS_ENSURE_SUCCESS(treeOwnerAsWin->SetPosition(x, y),
+                    NS_ERROR_FAILURE);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScreenY(int32_t* aScreenY)
 {
-  ErrorResult rv;
-  *aScreenY = GetScreenY(rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::SetScreenY(int32_t aScreenY, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(SetScreenY, (aScreenY, aError), aError, );
+  FORWARD_TO_OUTER(GetScreenY, (aScreenY), NS_ERROR_NOT_INITIALIZED);
+
+  nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
+  NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
+
+  int32_t x, y;
+
+  NS_ENSURE_SUCCESS(treeOwnerAsWin->GetPosition(&x, &y),
+                    NS_ERROR_FAILURE);
+
+  *aScreenY = DevToCSSIntPixels(y);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::SetScreenY(int32_t aScreenY)
+{
+  FORWARD_TO_OUTER(SetScreenY, (aScreenY), NS_ERROR_NOT_INITIALIZED);
 
   /*
    * If caller is not chrome and the user has not explicitly exempted the site,
    * prevent setting window.screenY by exiting early
    */
 
   if (!CanMoveResizeWindows() || IsFrame()) {
-    return;
+    return NS_OK;
   }
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
-  if (!treeOwnerAsWin) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return;
-  }
-
-  int32_t x, y;
-  aError = treeOwnerAsWin->GetPosition(&x, &y);
-  if (aError.Failed()) {
-    return;
-  }
+  NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
 
   CheckSecurityLeftAndTop(nullptr, &aScreenY);
+
+  int32_t x, y;
+  NS_ENSURE_SUCCESS(treeOwnerAsWin->GetPosition(&x, &y),
+                    NS_ERROR_FAILURE);
+
   y = CSSToDevIntPixels(aScreenY);
 
-  aError = treeOwnerAsWin->SetPosition(x, y);
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::SetScreenY(int32_t aScreenY)
-{
-  ErrorResult rv;
-  SetScreenY(aScreenY, rv);
-
-  return rv.ErrorCode();
+  NS_ENSURE_SUCCESS(treeOwnerAsWin->SetPosition(x, y),
+                    NS_ERROR_FAILURE);
+
+  return NS_OK;
 }
 
 // NOTE: Arguments to this function should have values scaled to
 // CSS pixels, not device pixels.
 void
 nsGlobalWindow::CheckSecurityWidthAndHeight(int32_t* aWidth, int32_t* aHeight)
 {
 #ifdef MOZ_XUL
@@ -5237,149 +4849,121 @@ nsGlobalWindow::GetPageXOffset(int32_t* 
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetPageYOffset(int32_t* aPageYOffset)
 {
   return GetScrollY(aPageYOffset);
 }
 
-void
-nsGlobalWindow::GetScrollMaxXY(int32_t* aScrollMaxX, int32_t* aScrollMaxY,
-                               ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetScrollMaxXY, (aScrollMaxX, aScrollMaxY, aError),
-                            aError, );
+nsresult
+nsGlobalWindow::GetScrollMaxXY(int32_t* aScrollMaxX, int32_t* aScrollMaxY)
+{
+  FORWARD_TO_OUTER(GetScrollMaxXY, (aScrollMaxX, aScrollMaxY),
+                   NS_ERROR_NOT_INITIALIZED);
 
   FlushPendingNotifications(Flush_Layout);
   nsIScrollableFrame *sf = GetScrollFrame();
-  if (!sf) {
-    return;
-  }
+  if (!sf)
+    return NS_OK;
 
   nsRect scrollRange = sf->GetScrollRange();
 
-  if (aScrollMaxX) {
+  if (aScrollMaxX)
     *aScrollMaxX = std::max(0,
       (int32_t)floor(nsPresContext::AppUnitsToFloatCSSPixels(scrollRange.XMost())));
-  }
-  if (aScrollMaxY) {
+  if (aScrollMaxY)
     *aScrollMaxY = std::max(0,
       (int32_t)floor(nsPresContext::AppUnitsToFloatCSSPixels(scrollRange.YMost())));
-  }
-}
-
-int32_t
-nsGlobalWindow::GetScrollMaxX(ErrorResult& aError)
-{
-  int32_t scrollMaxX = 0;
-  GetScrollMaxXY(&scrollMaxX, nullptr, aError);
-  return scrollMaxX;
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScrollMaxX(int32_t* aScrollMaxX)
 {
   NS_ENSURE_ARG_POINTER(aScrollMaxX);
-  ErrorResult rv;
-  *aScrollMaxX = GetScrollMaxX(rv);
-
-  return rv.ErrorCode();
-}
-
-int32_t
-nsGlobalWindow::GetScrollMaxY(ErrorResult& aError)
-{
-  int32_t scrollMaxY = 0;
-  GetScrollMaxXY(nullptr, &scrollMaxY, aError);
-  return scrollMaxY;
+  *aScrollMaxX = 0;
+  return GetScrollMaxXY(aScrollMaxX, nullptr);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScrollMaxY(int32_t* aScrollMaxY)
 {
   NS_ENSURE_ARG_POINTER(aScrollMaxY);
-  ErrorResult rv;
-  *aScrollMaxY = GetScrollMaxY(rv);
-
-  return rv.ErrorCode();
-}
-
-CSSIntPoint
-nsGlobalWindow::GetScrollXY(bool aDoFlush, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetScrollXY, (aDoFlush, aError), aError,
-                            CSSIntPoint(0, 0));
+  *aScrollMaxY = 0;
+  return GetScrollMaxXY(nullptr, aScrollMaxY);
+}
+
+nsresult
+nsGlobalWindow::GetScrollXY(int32_t* aScrollX, int32_t* aScrollY,
+                            bool aDoFlush)
+{
+  FORWARD_TO_OUTER(GetScrollXY, (aScrollX, aScrollY, aDoFlush),
+                   NS_ERROR_NOT_INITIALIZED);
 
   if (aDoFlush) {
     FlushPendingNotifications(Flush_Layout);
   } else {
     EnsureSizeUpToDate();
   }
 
   nsIScrollableFrame *sf = GetScrollFrame();
-  if (!sf) {
-    return CSSIntPoint(0, 0);
-  }
+  if (!sf)
+    return NS_OK;
 
   nsPoint scrollPos = sf->GetScrollPosition();
   if (scrollPos != nsPoint(0,0) && !aDoFlush) {
     // Oh, well.  This is the expensive case -- the window is scrolled and we
     // didn't actually flush yet.  Repeat, but with a flush, since the content
     // may get shorter and hence our scroll position may decrease.
-    return GetScrollXY(true, aError);
-  }
-
-  return sf->GetScrollPositionCSSPixels();
-}
-
-int32_t
-nsGlobalWindow::GetScrollX(ErrorResult& aError)
-{
-  return GetScrollXY(false, aError).x;
+    return GetScrollXY(aScrollX, aScrollY, true);
+  }
+
+  CSSIntPoint scrollPosCSSPixels = sf->GetScrollPositionCSSPixels();
+  if (aScrollX) {
+    *aScrollX = scrollPosCSSPixels.x;
+  }
+  if (aScrollY) {
+    *aScrollY = scrollPosCSSPixels.y;
+  }
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScrollX(int32_t* aScrollX)
 {
   NS_ENSURE_ARG_POINTER(aScrollX);
-  ErrorResult rv;
-  *aScrollX = GetScrollXY(false, rv).x;
-  return rv.ErrorCode();
-}
-
-int32_t
-nsGlobalWindow::GetScrollY(ErrorResult& aError)
-{
-  return GetScrollXY(false, aError).y;
+  *aScrollX = 0;
+  return GetScrollXY(aScrollX, nullptr, false);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScrollY(int32_t* aScrollY)
 {
   NS_ENSURE_ARG_POINTER(aScrollY);
-  ErrorResult rv;
-  *aScrollY = GetScrollXY(false, rv).y;
-  return rv.ErrorCode();
+  *aScrollY = 0;
+  return GetScrollXY(nullptr, aScrollY, false);
 }
 
 uint32_t
-nsGlobalWindow::Length()
-{
-  FORWARD_TO_OUTER(Length, (), 0);
+nsGlobalWindow::GetLength()
+{
+  FORWARD_TO_OUTER(GetLength, (), 0);
 
   nsDOMWindowList* windows = GetWindowList();
-
-  return windows ? windows->GetLength() : 0;
+  NS_ENSURE_TRUE(windows, 0);
+
+  return windows->GetLength();
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetLength(uint32_t* aLength)
 {
-  *aLength = Length();
+  *aLength = GetLength();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMWindow>
 nsGlobalWindow::GetChildWindow(const nsAString& aName)
 {
   nsCOMPtr<nsIDocShellTreeNode> dsn(do_QueryInterface(GetDocShell()));
   NS_ENSURE_TRUE(dsn, nullptr);
@@ -5517,22 +5101,16 @@ nsGlobalWindow::GetNearestWidget()
   NS_ENSURE_TRUE(docShell, nullptr);
   nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
   NS_ENSURE_TRUE(presShell, nullptr);
   nsIFrame* rootFrame = presShell->GetRootFrame();
   NS_ENSURE_TRUE(rootFrame, nullptr);
   return rootFrame->GetView()->GetNearestWidget(nullptr);
 }
 
-void
-nsGlobalWindow::SetFullScreen(bool aFullScreen, mozilla::ErrorResult& aError)
-{
-  aError = SetFullScreenInternal(aFullScreen, true);
-}
-
 NS_IMETHODIMP
 nsGlobalWindow::SetFullScreen(bool aFullScreen)
 {
   return SetFullScreenInternal(aFullScreen, true);
 }
 
 nsresult
 nsGlobalWindow::SetFullScreenInternal(bool aFullScreen, bool aRequireTrust)
@@ -5617,47 +5195,36 @@ nsGlobalWindow::SetFullScreenInternal(bo
   } else if (mWakeLock && !mFullScreen) {
     mWakeLock->Unlock();
     mWakeLock = NULL;
   }
 
   return NS_OK;
 }
 
-bool
-nsGlobalWindow::GetFullScreen(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetFullScreen, (aError), aError, false);
+NS_IMETHODIMP
+nsGlobalWindow::GetFullScreen(bool* aFullScreen)
+{
+  FORWARD_TO_OUTER(GetFullScreen, (aFullScreen), NS_ERROR_NOT_INITIALIZED);
 
   // Get the fullscreen value of the root window, to always have the value
   // accurate, even when called from content.
   if (mDocShell) {
     nsCOMPtr<nsIDocShellTreeItem> rootItem;
     mDocShell->GetRootTreeItem(getter_AddRefs(rootItem));
     if (rootItem != mDocShell) {
       nsCOMPtr<nsIDOMWindow> window = do_GetInterface(rootItem);
-      if (window) {
-        bool fullScreen = false;
-        aError = window->GetFullScreen(&fullScreen);
-        return fullScreen;
-      }
+      if (window)
+        return window->GetFullScreen(aFullScreen);
     }
   }
 
   // We are the root window, or something went wrong. Return our internal value.
-  return mFullScreen;
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::GetFullScreen(bool* aFullScreen)
-{
-  ErrorResult rv;
-  *aFullScreen = GetFullScreen(rv);
-
-  return rv.ErrorCode();
+  *aFullScreen = mFullScreen;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Dump(const nsAString& aStr)
 {
   if (!nsContentUtils::DOMWindowDumpEnabled()) {
     return NS_OK;
   }
@@ -5866,24 +5433,23 @@ nsGlobalWindow::CanMoveResizeWindows()
     if (ds) {
       gDragServiceDisabled = true;
       ds->Suppress();
     }
   }
   return true;
 }
 
-void
-nsGlobalWindow::Alert(const nsAString& aMessage, mozilla::ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(Alert, (aMessage, aError), aError, );
+NS_IMETHODIMP
+nsGlobalWindow::Alert(const nsAString& aString)
+{
+  FORWARD_TO_OUTER(Alert, (aString), NS_ERROR_NOT_INITIALIZED);
 
   if (!AreDialogsEnabled()) {
-    aError.Throw(NS_ERROR_NOT_AVAILABLE);
-    return;
+    return NS_ERROR_NOT_AVAILABLE;
   }
 
   // Reset popup state while opening a modal dialog, and firing events
   // about the dialog, to prevent the current state from being active
   // the whole time a modal dialog is open.
   nsAutoPopupStatePusher popupStatePusher(openAbused, true);
 
   // Before bringing up the window, unsuppress painting and flush
@@ -5891,160 +5457,133 @@ nsGlobalWindow::Alert(const nsAString& a
   EnsureReflowFlushAndPaint();
 
   nsAutoString title;
   MakeScriptDialogTitle(title);
 
   // Remove non-terminating null characters from the 
   // string. See bug #310037. 
   nsAutoString final;
-  nsContentUtils::StripNullChars(aMessage, final);
+  nsContentUtils::StripNullChars(aString, final);
 
   // Check if we're being called at a point where we can't use tab-modal
   // prompts, because something doesn't want reentrancy.
   bool allowTabModal = GetIsTabModalPromptAllowed();
 
   nsresult rv;
   nsCOMPtr<nsIPromptFactory> promptFac =
     do_GetService("@mozilla.org/prompter;1", &rv);
-  if (NS_FAILED(rv)) {
-    aError.Throw(rv);
-    return;
-  }
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIPrompt> prompt;
-  aError = promptFac->GetPrompt(this, NS_GET_IID(nsIPrompt),
-                                reinterpret_cast<void**>(&prompt));
-  if (aError.Failed()) {
-    return;
-  }
+  rv = promptFac->GetPrompt(this, NS_GET_IID(nsIPrompt),
+                            reinterpret_cast<void**>(&prompt));
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIWritablePropertyBag2> promptBag = do_QueryInterface(prompt);
   if (promptBag)
     promptBag->SetPropertyAsBool(NS_LITERAL_STRING("allowTabModal"), allowTabModal);
 
   nsAutoSyncOperation sync(GetCurrentInnerWindowInternal() ? 
                              GetCurrentInnerWindowInternal()->mDoc :
                              nullptr);
   if (ShouldPromptToBlockDialogs()) {
     bool disallowDialog = false;
     nsXPIDLString label;
     nsContentUtils::GetLocalizedString(nsContentUtils::eCOMMON_DIALOG_PROPERTIES,
                                        "ScriptDialogLabel", label);
 
-    aError = prompt->AlertCheck(title.get(), final.get(), label.get(),
-                                &disallowDialog);
+    rv = prompt->AlertCheck(title.get(), final.get(), label.get(),
+                            &disallowDialog);
     if (disallowDialog)
       DisableDialogs();
   } else {
-    aError = prompt->Alert(title.get(), final.get());
-  }
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::Alert(const nsAString& aString)
-{
-  ErrorResult rv;
-  Alert(aString, rv);
-
-  return rv.ErrorCode();
-}
-
-bool
-nsGlobalWindow::Confirm(const nsAString& aMessage, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(Confirm, (aMessage, aError), aError, false);
+    rv = prompt->Alert(title.get(), final.get());
+  }
+
+  return rv;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::Confirm(const nsAString& aString, bool* aReturn)
+{
+  FORWARD_TO_OUTER(Confirm, (aString, aReturn), NS_ERROR_NOT_INITIALIZED);
 
   if (!AreDialogsEnabled()) {
-    aError.Throw(NS_ERROR_NOT_AVAILABLE);
-    return false;
+    return NS_ERROR_NOT_AVAILABLE;
   }
 
   // Reset popup state while opening a modal dialog, and firing events
   // about the dialog, to prevent the current state from being active
   // the whole time a modal dialog is open.
   nsAutoPopupStatePusher popupStatePusher(openAbused, true);
 
+  *aReturn = false;
+
   // Before bringing up the window, unsuppress painting and flush
   // pending reflows.
   EnsureReflowFlushAndPaint();
 
   nsAutoString title;
   MakeScriptDialogTitle(title);
 
   // Remove non-terminating null characters from the 
   // string. See bug #310037. 
   nsAutoString final;
-  nsContentUtils::StripNullChars(aMessage, final);
+  nsContentUtils::StripNullChars(aString, final);
 
   // Check if we're being called at a point where we can't use tab-modal
   // prompts, because something doesn't want reentrancy.
   bool allowTabModal = GetIsTabModalPromptAllowed();
 
   nsresult rv;
   nsCOMPtr<nsIPromptFactory> promptFac =
     do_GetService("@mozilla.org/prompter;1", &rv);
-  if (NS_FAILED(rv)) {
-    aError.Throw(rv);
-    return false;
-  }
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIPrompt> prompt;
-  aError = promptFac->GetPrompt(this, NS_GET_IID(nsIPrompt),
-                                reinterpret_cast<void**>(&prompt));
-  if (aError.Failed()) {
-    return false;
-  }
+  rv = promptFac->GetPrompt(this, NS_GET_IID(nsIPrompt),
+                            reinterpret_cast<void**>(&prompt));
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIWritablePropertyBag2> promptBag = do_QueryInterface(prompt);
   if (promptBag)
     promptBag->SetPropertyAsBool(NS_LITERAL_STRING("allowTabModal"), allowTabModal);
 
-  bool result = false;
   nsAutoSyncOperation sync(GetCurrentInnerWindowInternal() ? 
                              GetCurrentInnerWindowInternal()->mDoc :
                              nullptr);
   if (ShouldPromptToBlockDialogs()) {
     bool disallowDialog = false;
     nsXPIDLString label;
     nsContentUtils::GetLocalizedString(nsContentUtils::eCOMMON_DIALOG_PROPERTIES,
                                        "ScriptDialogLabel", label);
 
-    aError = prompt->ConfirmCheck(title.get(), final.get(), label.get(),
-                                  &disallowDialog, &result);
+    rv = prompt->ConfirmCheck(title.get(), final.get(), label.get(),
+                              &disallowDialog, aReturn);
     if (disallowDialog)
       DisableDialogs();
   } else {
-    aError = prompt->Confirm(title.get(), final.get(), &result);
-  }
-
-  return result;
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::Confirm(const nsAString& aString, bool* aReturn)
-{
-  ErrorResult rv;
-  *aReturn = Confirm(aString, rv);
-
-  return rv.ErrorCode();
-}
-
-void
+    rv = prompt->Confirm(title.get(), final.get(), aReturn);
+  }
+
+  return rv;
+}
+
+NS_IMETHODIMP
 nsGlobalWindow::Prompt(const nsAString& aMessage, const nsAString& aInitial,
-                       nsAString& aReturn, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(Prompt, (aMessage, aInitial, aReturn, aError),
-                            aError, );
+                       nsAString& aReturn)
+{
+  FORWARD_TO_OUTER(Prompt, (aMessage, aInitial, aReturn),
+                   NS_ERROR_NOT_INITIALIZED);
 
   SetDOMStringToNull(aReturn);
 
   if (!AreDialogsEnabled()) {
-    aError.Throw(NS_ERROR_NOT_AVAILABLE);
-    return;
+    return NS_ERROR_NOT_AVAILABLE;
   }
 
   // Reset popup state while opening a modal dialog, and firing events
   // about the dialog, to prevent the current state from being active
   // the whole time a modal dialog is open.
   nsAutoPopupStatePusher popupStatePusher(openAbused, true);
 
   // Before bringing up the window, unsuppress painting and flush
@@ -6062,27 +5601,22 @@ nsGlobalWindow::Prompt(const nsAString& 
 
   // Check if we're being called at a point where we can't use tab-modal
   // prompts, because something doesn't want reentrancy.
   bool allowTabModal = GetIsTabModalPromptAllowed();
 
   nsresult rv;
   nsCOMPtr<nsIPromptFactory> promptFac =
     do_GetService("@mozilla.org/prompter;1", &rv);
-  if (NS_FAILED(rv)) {
-    aError.Throw(rv);
-    return;
-  }
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIPrompt> prompt;
-  aError = promptFac->GetPrompt(this, NS_GET_IID(nsIPrompt),
-                                reinterpret_cast<void**>(&prompt));
-  if (aError.Failed()) {
-    return;
-  }
+  rv = promptFac->GetPrompt(this, NS_GET_IID(nsIPrompt),
+                            reinterpret_cast<void**>(&prompt));
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIWritablePropertyBag2> promptBag = do_QueryInterface(prompt);
   if (promptBag)
     promptBag->SetPropertyAsBool(NS_LITERAL_STRING("allowTabModal"), allowTabModal);
 
   // Pass in the default value, if any.
   PRUnichar *inoutValue = ToNewUnicode(fixedInitial);
   bool disallowDialog = false;
@@ -6092,64 +5626,53 @@ nsGlobalWindow::Prompt(const nsAString& 
     nsContentUtils::GetLocalizedString(nsContentUtils::eCOMMON_DIALOG_PROPERTIES,
                                        "ScriptDialogLabel", label);
   }
 
   nsAutoSyncOperation sync(GetCurrentInnerWindowInternal() ? 
                              GetCurrentInnerWindowInternal()->mDoc :
                              nullptr);
   bool ok;
-  aError = prompt->Prompt(title.get(), fixedMessage.get(),
-                          &inoutValue, label.get(), &disallowDialog, &ok);
+  rv = prompt->Prompt(title.get(), fixedMessage.get(),
+                      &inoutValue, label.get(), &disallowDialog, &ok);
 
   if (disallowDialog) {
     DisableDialogs();
   }
 
-  if (aError.Failed()) {
-    return;
-  }
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsAdoptingString outValue(inoutValue);
 
   if (ok && outValue) {
     aReturn.Assign(outValue);
   }
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::Prompt(const nsAString& aMessage, const nsAString& aInitial,
-                       nsAString& aReturn)
-{
-  ErrorResult rv;
-  Prompt(aMessage, aInitial, aReturn, rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::Focus(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(Focus, (aError), aError, );
+
+  return rv;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::Focus()
+{
+  FORWARD_TO_OUTER(Focus, (), NS_ERROR_NOT_INITIALIZED);
 
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
-  if (!fm) {
-    return;
-  }
+  if (!fm)
+    return NS_OK;
 
   nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(mDocShell);
 
   bool isVisible = false;
   if (baseWin) {
     baseWin->GetVisibility(&isVisible);
   }
 
   if (!isVisible) {
     // A hidden tab is being focused, ignore this call.
-    return;
+    return NS_OK;
   }
 
   nsIDOMWindow *caller = nsContentUtils::GetWindowFromCaller();
   nsCOMPtr<nsIDOMWindow> opener;
   GetOpener(getter_AddRefs(opener));
 
   // Enforce dom.disable_window_flip (for non-chrome), but still allow the
   // window which opened us to raise us at times when popups are allowed
@@ -6166,28 +5689,27 @@ nsGlobalWindow::Focus(ErrorResult& aErro
   nsCOMPtr<nsIDOMWindow> rootWin = do_GetInterface(rootItem);
   bool isActive = (rootWin == activeWindow);
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
   if (treeOwnerAsWin && (canFocus || isActive)) {
     bool isEnabled = true;
     if (NS_SUCCEEDED(treeOwnerAsWin->GetEnabled(&isEnabled)) && !isEnabled) {
       NS_WARNING( "Should not try to set the focus on a disabled window" );
-      return;
+      return NS_OK;
     }
 
     // XXXndeakin not sure what this is for or if it should go somewhere else
     nsCOMPtr<nsIEmbeddingSiteWindow> embeddingWin(do_GetInterface(treeOwnerAsWin));
     if (embeddingWin)
       embeddingWin->SetFocus();
   }
 
-  if (!mDocShell) {
-    return;
-  }
+  if (!mDocShell)
+    return NS_OK;
 
   nsCOMPtr<nsIPresShell> presShell;
   // Don't look for a presshell if we're a root chrome window that's got
   // about:blank loaded.  We don't want to focus our widget in that case.
   // XXXbz should we really be checking for IsInitialDocument() instead?
   bool lookForPresShell = true;
   int32_t itemType = nsIDocShellTreeItem::typeContent;
   mDocShell->GetItemType(&itemType);
@@ -6206,59 +5728,49 @@ nsGlobalWindow::Focus(ErrorResult& aErro
 
   nsCOMPtr<nsIDocShellTreeItem> parentDsti;
   mDocShell->GetParent(getter_AddRefs(parentDsti));
 
   // set the parent's current focus to the frame containing this window.
   nsCOMPtr<nsPIDOMWindow> parent = do_GetInterface(parentDsti);
   if (parent) {
     nsCOMPtr<nsIDocument> parentdoc = parent->GetDoc();
-    if (!parentdoc) {
-      return;
-    }
+    if (!parentdoc)
+      return NS_OK;
 
     nsIContent* frame = parentdoc->FindContentForSubDocument(mDoc);
     nsCOMPtr<nsIDOMElement> frameElement = do_QueryInterface(frame);
     if (frameElement) {
       uint32_t flags = nsIFocusManager::FLAG_NOSCROLL;
       if (canFocus)
         flags |= nsIFocusManager::FLAG_RAISE;
-      aError = fm->SetFocus(frameElement, flags);
-    }
-    return;
-  }
-  if (TabChild *child = TabChild::GetFrom(this)) {
+      return fm->SetFocus(frameElement, flags);
+    }
+  }
+  else if (TabChild *child = TabChild::GetFrom(this)) {
     child->SendRequestFocus(canFocus);
-    return;
-  }
-  if (canFocus) {
+  }
+  else if (canFocus) {
     // if there is no parent, this must be a toplevel window, so raise the
     // window if canFocus is true
-    aError = fm->SetActiveWindow(this);
-  }
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::Focus()
-{
-  ErrorResult rv;
-  Focus(rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::Blur(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(Blur, (aError), aError, );
+    return fm->SetActiveWindow(this);
+  }
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::Blur()
+{
+  FORWARD_TO_OUTER(Blur, (), NS_ERROR_NOT_INITIALIZED);
 
   // If dom.disable_window_flip == true, then content should not be allowed
   // to call this function (this would allow popunders, bug 369306)
   if (!CanSetProperty("dom.disable_window_flip")) {
-    return;
+    return NS_OK;
   }
 
   // If embedding apps don't implement nsIEmbeddingSiteWindow, we
   // shouldn't throw exceptions to web content.
 
   nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
   nsCOMPtr<nsIEmbeddingSiteWindow> siteWindow(do_GetInterface(treeOwner));
   if (siteWindow) {
@@ -6270,81 +5782,49 @@ nsGlobalWindow::Blur(ErrorResult& aError
     if (fm && mDoc) {
       nsCOMPtr<nsIDOMElement> element;
       fm->GetFocusedElementForWindow(this, false, nullptr, getter_AddRefs(element));
       nsCOMPtr<nsIContent> content = do_QueryInterface(element);
       if (content == mDoc->GetRootElement())
         fm->ClearFocus(this);
     }
   }
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::Blur()
-{
-  ErrorResult rv;
-  Blur(rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::Back(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(Back, (aError), aError, );
-
-  nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
-  if (!webNav) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return;
-  }
-
-  aError = webNav->GoBack();
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Back()
 {
-  ErrorResult rv;
-  Back(rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::Forward(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(Forward, (aError), aError, );
+  FORWARD_TO_OUTER(Back, (), NS_ERROR_NOT_INITIALIZED);
 
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
-  if (!webNav) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return;
-  }
-
-  aError = webNav->GoForward();
+  NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
+
+  return webNav->GoBack();
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Forward()
 {
-  ErrorResult rv;
-  Forward(rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::Home(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(Home, (aError), aError, );
-
-  if (!mDocShell) {
-    return;
-  }
+  FORWARD_TO_OUTER(Forward, (), NS_ERROR_NOT_INITIALIZED);
+
+  nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
+  NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
+
+  return webNav->GoForward();
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::Home()
+{
+  FORWARD_TO_OUTER(Home, (), NS_ERROR_NOT_INITIALIZED);
+
+  if (!mDocShell)
+    return NS_OK;
 
   nsAdoptingString homeURL =
     Preferences::GetLocalizedString(PREF_BROWSER_STARTUP_HOMEPAGE);
 
   if (homeURL.IsEmpty()) {
     // if all else fails, use this
 #ifdef DEBUG_seth
     printf("all else failed.  using %s as the home page\n", DEFAULT_HOME_PAGE);
@@ -6366,77 +5846,55 @@ nsGlobalWindow::Home(ErrorResult& aError
     int32_t firstPipe = homeURL.FindChar('|');
 
     if (firstPipe > 0) {
       homeURL.Truncate(firstPipe);
     }
   }
 #endif
 
+  nsresult rv;
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
-  if (!webNav) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return;
-  }
-
-  aError = webNav->LoadURI(homeURL.get(),
-                           nsIWebNavigation::LOAD_FLAGS_NONE,
-                           nullptr,
-                           nullptr,
-                           nullptr);
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::Home()
-{
-  ErrorResult rv;
-  Home(rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::Stop(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(Stop, (aError), aError, );
-
-  nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
-  if (webNav) {
-    aError = webNav->Stop(nsIWebNavigation::STOP_ALL);
-  }
+  NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
+  rv = webNav->LoadURI(homeURL.get(),
+                       nsIWebNavigation::LOAD_FLAGS_NONE,
+                       nullptr,
+                       nullptr,
+                       nullptr);
+  NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Stop()
 {
-  ErrorResult rv;
-  Stop(rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::Print(ErrorResult& aError)
+  FORWARD_TO_OUTER(Stop, (), NS_ERROR_NOT_INITIALIZED);
+
+  nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
+  if (!webNav)
+    return NS_OK;
+
+  return webNav->Stop(nsIWebNavigation::STOP_ALL);
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::Print()
 {
 #ifdef NS_PRINTING
-  FORWARD_TO_OUTER_OR_THROW(Print, (aError), aError, );
-
-  if (Preferences::GetBool("dom.disable_window_print", false)) {
-    aError.Throw(NS_ERROR_NOT_AVAILABLE);
-    return;
-  }
+  FORWARD_TO_OUTER(Print, (), NS_ERROR_NOT_INITIALIZED);
+
+  if (Preferences::GetBool("dom.disable_window_print", false))
+    return NS_ERROR_NOT_AVAILABLE;
 
   if (!AreDialogsEnabled()) {
-    aError.Throw(NS_ERROR_NOT_AVAILABLE);
-    return;
+    return NS_ERROR_NOT_AVAILABLE;
   }
 
   if (ShouldPromptToBlockDialogs() && !ConfirmDialogIfNeeded()) {
-    aError.Throw(NS_ERROR_NOT_AVAILABLE);
-    return;
+    return NS_ERROR_NOT_AVAILABLE;
   }
 
   nsCOMPtr<nsIWebBrowserPrint> webBrowserPrint;
   if (NS_SUCCEEDED(GetInterface(NS_GET_IID(nsIWebBrowserPrint),
                                 getter_AddRefs(webBrowserPrint)))) {
     nsAutoSyncOperation sync(GetCurrentInnerWindowInternal() ? 
                                GetCurrentInnerWindowInternal()->mDoc :
                                nullptr);
@@ -6483,297 +5941,233 @@ nsGlobalWindow::Print(ErrorResult& aErro
                                    nsIPrintSettings::kInitSavePrinterName);
       }
     } else {
       webBrowserPrint->GetGlobalPrintSettings(getter_AddRefs(printSettings));
       webBrowserPrint->Print(printSettings, nullptr);
     }
   }
 #endif //NS_PRINTING
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::Print()
-{
-  ErrorResult rv;
-  Print(rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::MoveTo(int32_t aXPos, int32_t aYPos, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(MoveTo, (aXPos, aYPos, aError), aError, );
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::MoveTo(int32_t aXPos, int32_t aYPos)
+{
+  FORWARD_TO_OUTER(MoveTo, (aXPos, aYPos), NS_ERROR_NOT_INITIALIZED);
 
   /*
    * If caller is not chrome and the user has not explicitly exempted the site,
    * prevent window.moveTo() by exiting early
    */
 
   if (!CanMoveResizeWindows() || IsFrame()) {
-    return;
+    return NS_OK;
   }
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
-  if (!treeOwnerAsWin) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return;
-  }
-
-  // Mild abuse of a "size" object so we don't need more helper functions.
-  nsIntSize cssPos(aXPos, aYPos);
-  CheckSecurityLeftAndTop(&cssPos.width, &cssPos.height);
-
-  nsIntSize devPos = CSSToDevIntPixels(cssPos);
-
-  aError = treeOwnerAsWin->SetPosition(devPos.width, devPos.height);
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::MoveTo(int32_t aXPos, int32_t aYPos)
-{
-  ErrorResult rv;
-  MoveTo(aXPos, aYPos, rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::MoveBy(int32_t aXDif, int32_t aYDif, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(MoveBy, (aXDif, aYDif, aError), aError, );
+  NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
+
+  CheckSecurityLeftAndTop(&aXPos, &aYPos);
+
+  // mild abuse of a "size" object so we don't need more helper functions
+  nsIntSize devPos(CSSToDevIntPixels(nsIntSize(aXPos, aYPos)));
+
+  NS_ENSURE_SUCCESS(treeOwnerAsWin->SetPosition(devPos.width, devPos.height),
+                    NS_ERROR_FAILURE);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::MoveBy(int32_t aXDif, int32_t aYDif)
+{
+  FORWARD_TO_OUTER(MoveBy, (aXDif, aYDif), NS_ERROR_NOT_INITIALIZED);
 
   /*
    * If caller is not chrome and the user has not explicitly exempted the site,
    * prevent window.moveBy() by exiting early
    */
 
   if (!CanMoveResizeWindows() || IsFrame()) {
-    return;
+    return NS_OK;
   }
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
-  if (!treeOwnerAsWin) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return;
-  }
+  NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
 
   // To do this correctly we have to convert what we get from GetPosition
   // into CSS pixels, add the arguments, do the security check, and
   // then convert back to device pixels for the call to SetPosition.
 
   int32_t x, y;
-  aError = treeOwnerAsWin->GetPosition(&x, &y);
-  if (aError.Failed()) {
-    return;
-  }
+  NS_ENSURE_SUCCESS(treeOwnerAsWin->GetPosition(&x, &y), NS_ERROR_FAILURE);
 
   // mild abuse of a "size" object so we don't need more helper functions
   nsIntSize cssPos(DevToCSSIntPixels(nsIntSize(x, y)));
 
   cssPos.width += aXDif;
   cssPos.height += aYDif;
   
   CheckSecurityLeftAndTop(&cssPos.width, &cssPos.height);
 
   nsIntSize newDevPos(CSSToDevIntPixels(cssPos));
 
-  aError = treeOwnerAsWin->SetPosition(newDevPos.width, newDevPos.height);
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::MoveBy(int32_t aXDif, int32_t aYDif)
-{
-  ErrorResult rv;
-  MoveBy(aXDif, aYDif, rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::ResizeTo(int32_t aWidth, int32_t aHeight, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(ResizeTo, (aWidth, aHeight, aError), aError, );
+  NS_ENSURE_SUCCESS(treeOwnerAsWin->SetPosition(newDevPos.width,
+                                                newDevPos.height),
+                    NS_ERROR_FAILURE);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::ResizeTo(int32_t aWidth, int32_t aHeight)
+{
+  FORWARD_TO_OUTER(ResizeTo, (aWidth, aHeight), NS_ERROR_NOT_INITIALIZED);
 
   /*
    * If caller is a browser-element then dispatch a resize event to
    * the embedder.
    */
   if (mDocShell && mDocShell->GetIsBrowserOrApp()) {
     nsIntSize size(aWidth, aHeight);
     if (!DispatchResizeEvent(size)) {
       // The embedder chose to prevent the default action for this
       // event, so let's not resize this window after all...
-      return;
+      return NS_OK;
     }
   }
 
   /*
    * If caller is not chrome and the user has not explicitly exempted the site,
    * prevent window.resizeTo() by exiting early
    */
 
   if (!CanMoveResizeWindows() || IsFrame()) {
-    return;
+    return NS_OK;
   }
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
-  if (!treeOwnerAsWin) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return;
-  }
+  NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
   
-  nsIntSize cssSize(aWidth, aHeight);
-  CheckSecurityWidthAndHeight(&cssSize.width, &cssSize.height);
-
-  nsIntSize devSz(CSSToDevIntPixels(cssSize));
-
-  aError = treeOwnerAsWin->SetSize(devSz.width, devSz.height, true);
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::ResizeTo(int32_t aWidth, int32_t aHeight)
-{
-  ErrorResult rv;
-  ResizeTo(aWidth, aHeight, rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::ResizeBy(int32_t aWidthDif, int32_t aHeightDif,
-                         ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(ResizeBy, (aWidthDif, aHeightDif, aError), aError, );
+  CheckSecurityWidthAndHeight(&aWidth, &aHeight);
+
+  nsIntSize devSz(CSSToDevIntPixels(nsIntSize(aWidth, aHeight)));
+
+  NS_ENSURE_SUCCESS(treeOwnerAsWin->SetSize(devSz.width, devSz.height, true),
+                    NS_ERROR_FAILURE);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::ResizeBy(int32_t aWidthDif, int32_t aHeightDif)
+{
+  FORWARD_TO_OUTER(ResizeBy, (aWidthDif, aHeightDif), NS_ERROR_NOT_INITIALIZED);
 
   /*
    * If caller is a browser-element then dispatch a resize event to
    * parent.
    */
   if (mDocShell && mDocShell->GetIsBrowserOrApp()) {
     CSSIntSize size;
-    if (NS_FAILED(GetInnerSize(size))) {
-      return;
-    }
+    nsresult rv = GetInnerSize(size);
+    NS_ENSURE_SUCCESS(rv, NS_OK);
 
     size.width += aWidthDif;
     size.height += aHeightDif;
 
     if (!DispatchResizeEvent(nsIntSize(size.width, size.height))) {
       // The embedder chose to prevent the default action for this
       // event, so let's not resize this window after all...
-      return;
+      return NS_OK;
     }
   }
 
   /*
    * If caller is not chrome and the user has not explicitly exempted the site,
    * prevent window.resizeBy() by exiting early
    */
 
   if (!CanMoveResizeWindows() || IsFrame()) {
-    return;
+    return NS_OK;
   }
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
-  if (!treeOwnerAsWin) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return;
-  }
+  NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
 
   int32_t width, height;
-  aError = treeOwnerAsWin->GetSize(&width, &height);
-  if (aError.Failed()) {
-    return;
-  }
+  NS_ENSURE_SUCCESS(treeOwnerAsWin->GetSize(&width, &height), NS_ERROR_FAILURE);
 
   // To do this correctly we have to convert what we got from GetSize
   // into CSS pixels, add the arguments, do the security check, and
   // then convert back to device pixels for the call to SetSize.
 
   nsIntSize cssSize(DevToCSSIntPixels(nsIntSize(width, height)));
 
   cssSize.width += aWidthDif;
   cssSize.height += aHeightDif;
 
   CheckSecurityWidthAndHeight(&cssSize.width, &cssSize.height);
 
   nsIntSize newDevSize(CSSToDevIntPixels(cssSize));
 
-  aError = treeOwnerAsWin->SetSize(newDevSize.width, newDevSize.height, true);
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::ResizeBy(int32_t aWidthDif, int32_t aHeightDif)
-{
-  ErrorResult rv;
-  ResizeBy(aWidthDif, aHeightDif, rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::SizeToContent(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(SizeToContent, (aError), aError, );
+  NS_ENSURE_SUCCESS(treeOwnerAsWin->SetSize(newDevSize.width,
+                                            newDevSize.height,
+                                            true),
+                    NS_ERROR_FAILURE);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::SizeToContent()
+{
+  FORWARD_TO_OUTER(SizeToContent, (), NS_ERROR_NOT_INITIALIZED);
 
   if (!mDocShell) {
-    return;
+    return NS_OK;
   }
 
   /*
    * If caller is not chrome and the user has not explicitly exempted the site,
    * prevent window.sizeToContent() by exiting early
    */
 
   if (!CanMoveResizeWindows() || IsFrame()) {
-    return;
+    return NS_OK;
   }
 
   // The content viewer does a check to make sure that it's a content
   // viewer for a toplevel docshell.
   nsCOMPtr<nsIContentViewer> cv;
   mDocShell->GetContentViewer(getter_AddRefs(cv));
   nsCOMPtr<nsIMarkupDocumentViewer> markupViewer(do_QueryInterface(cv));
-  if (!markupViewer) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return;
-  }
+  NS_ENSURE_TRUE(markupViewer, NS_ERROR_FAILURE);
 
   int32_t width, height;
-  aError = markupViewer->GetContentSize(&width, &height);
-  if (aError.Failed()) {
-    return;
-  }
+  NS_ENSURE_SUCCESS(markupViewer->GetContentSize(&width, &height),
+                    NS_ERROR_FAILURE);
 
   // Make sure the new size is following the CheckSecurityWidthAndHeight
   // rules.
   nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
-  if (!treeOwner) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return;
-  }
+  NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);
 
   nsIntSize cssSize(DevToCSSIntPixels(nsIntSize(width, height)));
   CheckSecurityWidthAndHeight(&cssSize.width, &cssSize.height);
 
   nsIntSize newDevSize(CSSToDevIntPixels(cssSize));
 
-  aError = treeOwner->SizeShellTo(mDocShell, newDevSize.width,
-                                  newDevSize.height);
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::SizeToContent()
-{
-  ErrorResult rv;
-  SizeToContent(rv);
-
-  return rv.ErrorCode();
+  NS_ENSURE_SUCCESS(treeOwner->SizeShellTo(mDocShell,
+                                           newDevSize.width, newDevSize.height),
+                    NS_ERROR_FAILURE);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetWindowRoot(nsIDOMEventTarget **aWindowRoot)
 {
   nsCOMPtr<nsPIWindowRoot> root = GetTopWindowRoot();
   return CallQueryInterface(root, aWindowRoot);
 }
@@ -6875,48 +6269,34 @@ nsGlobalWindow::ScrollByPages(int32_t nu
     // Perhaps Web content does too.
     sf->ScrollBy(nsIntPoint(0, numPages), nsIScrollableFrame::PAGES,
                  nsIScrollableFrame::INSTANT);
   }
 
   return NS_OK;
 }
 
-void
-nsGlobalWindow::ClearTimeout(int32_t aHandle, ErrorResult& aError)
-{
-  if (aHandle > 0) {
-    ClearTimeoutOrInterval(aHandle, aError);
-  }
-}
-
 NS_IMETHODIMP
 nsGlobalWindow::ClearTimeout(int32_t aHandle)
 {
-  ErrorResult rv;
-  ClearTimeout(aHandle, rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::ClearInterval(int32_t aHandle, ErrorResult& aError)
-{
-  if (aHandle > 0) {
-    ClearTimeoutOrInterval(aHandle, aError);
-  }
+  if (aHandle <= 0) {
+    return NS_OK;
+  }
+
+  return ClearTimeoutOrInterval(aHandle);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::ClearInterval(int32_t aHandle)
 {
-  ErrorResult rv;
-  ClearTimeoutOrInterval(aHandle, rv);
-
-  return rv.ErrorCode();
+  if (aHandle <= 0) {
+    return NS_OK;
+  }
+
+  return ClearTimeoutOrInterval(aHandle);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::SetTimeout(int32_t *_retval)
 {
   return SetTimeoutOrInterval(false, _retval);
 }
 
@@ -7141,25 +6521,16 @@ nsGlobalWindow::FireAbuseEvents(bool aBl
   if (aBlocked) {
     FirePopupBlockedEvent(topDoc, this, popupURI, aPopupWindowName,
                           aPopupWindowFeatures);
   }
   if (aWindow)
     FirePopupWindowEvent(topDoc);
 }
 
-already_AddRefed<nsIDOMWindow>
-nsGlobalWindow::Open(const nsAString& aUrl, const nsAString& aName,
-                     const nsAString& aOptions, ErrorResult& aError)
-{
-  nsCOMPtr<nsIDOMWindow> window;
-  aError = OpenJS(aUrl, aName, aOptions, getter_AddRefs(window));
-  return window.forget();
-}
-
 NS_IMETHODIMP
 nsGlobalWindow::Open(const nsAString& aUrl, const nsAString& aName,
                      const nsAString& aOptions, nsIDOMWindow **_retval)
 {
   return OpenInternal(aUrl, aName, aOptions,
                       false,          // aDialog
                       false,          // aContentModal
                       true,           // aCalledNoScript
@@ -7221,44 +6592,16 @@ nsGlobalWindow::OpenNoNavigate(const nsA
                       false,          // aNavigate
                       nullptr, nullptr,  // No args
                       GetPrincipal(),    // aCalleePrincipal
                       nullptr,           // aJSCallerContext
                       _retval);
 
 }
 
-already_AddRefed<nsIDOMWindow>
-nsGlobalWindow::OpenDialog(JSContext* aCx, const nsAString& aUrl,
-                           const nsAString& aName, const nsAString& aOptions,
-                           const Sequence<JS::Value>& aExtraArgument,
-                           ErrorResult& aError)
-{
-  nsCOMPtr<nsIJSArgArray> argvArray;
-  aError = NS_CreateJSArgv(aCx, aExtraArgument.Length(),
-                           const_cast<JS::Value*>(aExtraArgument.Elements()),
-                           getter_AddRefs(argvArray));
-  if (aError.Failed()) {
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIDOMWindow> dialog;
-  aError = OpenInternal(aUrl, aName, aOptions,
-                        true,             // aDialog
-                        false,            // aContentModal
-                        false,            // aCalledNoScript
-                        false,            // aDoJSFixups
-                        true,                // aNavigate
-                        argvArray, nullptr,  // Arguments
-                        GetPrincipal(),      // aCalleePrincipal
-                        aCx,                 // aJSCallerContext
-                        getter_AddRefs(dialog));
-  return dialog.forget();
-}
-
 NS_IMETHODIMP
 nsGlobalWindow::OpenDialog(const nsAString& aUrl, const nsAString& aName,
                            const nsAString& aOptions, nsIDOMWindow** _retval)
 {
   if (!nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
@@ -7296,34 +6639,27 @@ nsGlobalWindow::OpenDialog(const nsAStri
                       false,            // aDoJSFixups
                       true,                // aNavigate
                       argvArray, nullptr,  // Arguments
                       GetPrincipal(),      // aCalleePrincipal
                       cx,                  // aJSCallerContext
                       _retval);
 }
 
-already_AddRefed<nsIDOMWindow>
-nsGlobalWindow::GetFrames(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetFrames, (aError), aError, nullptr);
-
-  nsRefPtr<nsGlobalWindow> frames(this);
-  FlushPendingNotifications(Flush_ContentAndNotify);
-  return frames.forget();
-}
-
 NS_IMETHODIMP
 nsGlobalWindow::GetFrames(nsIDOMWindow** aFrames)
 {
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMWindow> frames = GetFrames(rv);
-  frames.forget(aFrames);
-
-  return rv.ErrorCode();
+  FORWARD_TO_OUTER(GetFrames, (aFrames), NS_ERROR_NOT_INITIALIZED);
+
+  *aFrames = this;
+  NS_ADDREF(*aFrames);
+
+  FlushPendingNotifications(Flush_ContentAndNotify);
+
+  return NS_OK;
 }
 
 JSObject* nsGlobalWindow::CallerGlobal()
 {
   JSContext *cx = nsContentUtils::GetCurrentJSContext();
   if (!cx) {
     NS_ERROR("Please don't call this method from C++!");
 
@@ -7685,25 +7021,24 @@ PostMessageEvent::Run()
   nsEventDispatcher::Dispatch(static_cast<nsPIDOMWindow*>(mTargetWindow),
                               presContext,
                               internalEvent,
                               message,
                               &status);
   return NS_OK;
 }
 
-void
-nsGlobalWindow::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
-                               const nsAString& aTargetOrigin,
-                               JS::Handle<JS::Value> aTransfer,
-                               ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(PostMessageMoz,
-                            (aCx, aMessage, aTargetOrigin, aTransfer, aError),
-                            aError, );
+NS_IMETHODIMP
+nsGlobalWindow::PostMessageMoz(const JS::Value& aMessage,
+                               const nsAString& aOrigin,
+                               const JS::Value& aTransfer,
+                               JSContext* aCx)
+{
+  FORWARD_TO_OUTER(PostMessageMoz, (aMessage, aOrigin, aTransfer, aCx),
+                   NS_ERROR_NOT_INITIALIZED);
 
   //
   // Window.postMessage is an intentional subversion of the same-origin policy.
   // As such, this code must be particularly careful in the information it
   // exposes to calling code.
   //
   // http://www.whatwg.org/specs/web-apps/current-work/multipage/section-crossDocumentMessages.html
   //
@@ -7726,59 +7061,52 @@ nsGlobalWindow::PostMessageMoz(JSContext
   else {
     // In case the global is not a window, it can be a sandbox, and the sandbox's
     // principal can be used for the security check.
     JSObject *global = CallerGlobal();
     NS_ASSERTION(global, "Why is there no global object?");
     JSCompartment *compartment = js::GetObjectCompartment(global);
     callerPrin = xpc::GetCompartmentPrincipal(compartment);
   }
-  if (!callerPrin) {
-    return;
-  }
+  if (!callerPrin)
+    return NS_OK;
 
   nsCOMPtr<nsIURI> callerOuterURI;
-  if (NS_FAILED(callerPrin->GetURI(getter_AddRefs(callerOuterURI)))) {
-    return;
-  }
+  if (NS_FAILED(callerPrin->GetURI(getter_AddRefs(callerOuterURI))))
+    return NS_OK;
 
   nsAutoString origin;
   if (callerOuterURI) {
     // if the principal has a URI, use that to generate the origin
     nsContentUtils::GetUTFOrigin(callerPrin, origin);
   }
   else if (callerInnerWin) {
     // otherwise use the URI of the document to generate origin
     nsCOMPtr<nsIDocument> doc = callerInnerWin->GetExtantDoc();
-    if (!doc) {
-      return;
-    }
+    if (!doc)
+      return NS_OK;
     callerOuterURI = doc->GetDocumentURI();
     // if the principal has a URI, use that to generate the origin
     nsContentUtils::GetUTFOrigin(callerOuterURI, origin);
   }
   else {
     // in case of a sandbox with a system principal origin can be empty
-    if (!nsContentUtils::IsSystemPrincipal(callerPrin)) {
-      return;
-    }
+    if (!nsContentUtils::IsSystemPrincipal(callerPrin))
+      return NS_OK;
   }
 
   // Convert the provided origin string into a URI for comparison purposes.
   // "*" indicates no specific origin is required.
   nsCOMPtr<nsIURI> providedOrigin;
-  if (!aTargetOrigin.EqualsASCII("*")) {
-    if (NS_FAILED(NS_NewURI(getter_AddRefs(providedOrigin), aTargetOrigin))) {
-      aError.Throw(NS_ERROR_DOM_SYNTAX_ERR);
-      return;
-    }
+  if (!aOrigin.EqualsASCII("*")) {
+    if (NS_FAILED(NS_NewURI(getter_AddRefs(providedOrigin), aOrigin)))
+      return NS_ERROR_DOM_SYNTAX_ERR;
     if (NS_FAILED(providedOrigin->SetUserPass(EmptyCString())) ||
-        NS_FAILED(providedOrigin->SetPath(EmptyCString()))) {
-      return;
-    }
+        NS_FAILED(providedOrigin->SetPath(EmptyCString())))
+      return NS_OK;
   }
 
   // Create and asynchronously dispatch a runnable which will handle actual DOM
   // event creation and dispatch.
   nsRefPtr<PostMessageEvent> event =
     new PostMessageEvent(nsContentUtils::IsCallerChrome() || !callerInnerWin
                          ? nullptr
                          : callerInnerWin->GetOuterWindowInternal(),
@@ -7790,63 +7118,27 @@ nsGlobalWindow::PostMessageMoz(JSContext
   // We *must* clone the data here, or the JS::Value could be modified
   // by script
   JSAutoStructuredCloneBuffer buffer;
   StructuredCloneInfo scInfo;
   scInfo.event = event;
   scInfo.window = this;
 
   nsIPrincipal* principal = GetPrincipal();
+  if (NS_FAILED(callerPrin->Subsumes(principal, &scInfo.subsumes)))
+    return NS_ERROR_DOM_DATA_CLONE_ERR;
+
   JS::Rooted<JS::Value> message(aCx, aMessage);
   JS::Rooted<JS::Value> transfer(aCx, aTransfer);
-  if (NS_FAILED(callerPrin->Subsumes(principal, &scInfo.subsumes)) ||
-      !buffer.write(aCx, message, transfer, &kPostMessageCallbacks,
-                    &scInfo)) {
-    aError.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
-    return;
-  }
+  if (!buffer.write(aCx, message, transfer, &kPostMessageCallbacks, &scInfo))
+    return NS_ERROR_DOM_DATA_CLONE_ERR;
 
   event->SetJSData(buffer);
 
-  aError = NS_DispatchToCurrentThread(event);
-}
-
-void
-nsGlobalWindow::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
-                               const nsAString& aTargetOrigin,
-                               const Optional<Sequence<JS::Value > >& aTransfer,
-                               ErrorResult& aError)
-{
-  JS::Rooted<JS::Value> transferArray(aCx, JS::UndefinedValue());
-  if (aTransfer.WasPassed()) {
-    const Sequence<JS::Value >& values = aTransfer.Value();
-    transferArray = JS::ObjectOrNullValue(JS_NewArrayObject(aCx,
-                                                            values.Length(),
-                                                            const_cast<JS::Value*>(values.Elements())));
-    if (transferArray.isNull()) {
-      aError.Throw(NS_ERROR_OUT_OF_MEMORY);
-      return;
-    }
-  }
-
-  PostMessageMoz(aCx, aMessage, aTargetOrigin, transferArray, aError);
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::PostMessageMoz(const JS::Value& aMessage,
-                               const nsAString& aOrigin,
-                               const JS::Value& aTransfer,
-                               JSContext* aCx)
-{
-  JS::Rooted<JS::Value> message(aCx, aMessage);
-  JS::Rooted<JS::Value> transfer(aCx, aTransfer);
-  ErrorResult rv;
-  PostMessageMoz(aCx, message, aOrigin, transfer, rv);
-
-  return rv.ErrorCode();
+  return NS_DispatchToCurrentThread(event);
 }
 
 class nsCloseEvent : public nsRunnable {
 
   nsRefPtr<nsGlobalWindow> mWindow;
   bool mIndirect;
 
   nsCloseEvent(nsGlobalWindow *aWindow, bool aIndirect)
@@ -7899,41 +7191,42 @@ nsGlobalWindow::CanClose()
     rv = cv->RequestWindowClose(&canClose);
     if (NS_SUCCEEDED(rv) && !canClose)
       return false;
   }
 
   return true;
 }
 
-void
-nsGlobalWindow::Close(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(Close, (aError), aError, );
+NS_IMETHODIMP
+nsGlobalWindow::Close()
+{
+  FORWARD_TO_OUTER(Close, (), NS_ERROR_NOT_INITIALIZED);
 
   if (!mDocShell || IsInModalState() ||
       (IsFrame() && !mDocShell->GetIsBrowserOrApp())) {
     // window.close() is called on a frame in a frameset, on a window
     // that's already closed, or on a window for which there's
     // currently a modal dialog open. Ignore such calls.
-    return;
+
+    return NS_OK;
   }
 
   if (mHavePendingClose) {
     // We're going to be closed anyway; do nothing since we don't want
     // to double-close
-    return;
+    return NS_OK;
   }
 
   if (mBlockScriptedClosingFlag)
   {
     // A script's popup has been blocked and we don't want
     // the window to be closed directly after this event,
     // so the user can see that there was a blocked popup.
-    return;
+    return NS_OK;
   }
 
   // Don't allow scripts from content to close non-app windows that were not
   // opened by script.
   if (!mDocShell->GetIsApp() &&
       !mHadOriginalOpener && !nsContentUtils::IsCallerChrome()) {
     bool allowClose = mAllowScriptsToClose ||
       Preferences::GetBool("dom.allow_scripts_to_close_windows", true);
@@ -7941,52 +7234,42 @@ nsGlobalWindow::Close(ErrorResult& aErro
       // We're blocking the close operation
       // report localized error msg in JS console
       nsContentUtils::ReportToConsole(
           nsIScriptError::warningFlag,
           NS_LITERAL_CSTRING("DOM Window"), mDoc,  // Better name for the category?
           nsContentUtils::eDOM_PROPERTIES,
           "WindowCloseBlockedWarning");
 
-      return;
-    }
-  }
-
-  if (!mInClose && !mIsClosed && !CanClose()) {
-    return;
-  }
+      return NS_OK;
+    }
+  }
+
+  if (!mInClose && !mIsClosed && !CanClose())
+    return NS_OK;
 
   // Fire a DOM event notifying listeners that this window is about to
   // be closed. The tab UI code may choose to cancel the default
   // action for this event, if so, we won't actually close the window
   // (since the tab UI code will close the tab in stead). Sure, this
   // could be abused by content code, but do we care? I don't think
   // so...
 
   bool wasInClose = mInClose;
   mInClose = true;
 
   if (!DispatchCustomEvent("DOMWindowClose")) {
     // Someone chose to prevent the default action for this event, if
     // so, let's not close this window after all...
 
     mInClose = wasInClose;
-    return;
-  }
-
-  aError = FinalClose();
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::Close()
-{
-  ErrorResult rv;
-  Close(rv);
-
-  return rv.ErrorCode();
+    return NS_OK;
+  }
+
+  return FinalClose();
 }
 
 nsresult
 nsGlobalWindow::ForceClose()
 {
   if (IsFrame() || !mDocShell) {
     // This may be a frame in a frameset, or a window that's already closed.
     // Ignore such calls.
@@ -8391,73 +7674,54 @@ nsGlobalWindow::CacheXBLPrototypeHandler
  * In contrast to GetRealFrameElement, GetScriptableFrameElement says that the
  * window contained by an <iframe mozbrowser> or <iframe mozapp> has no frame
  * element (effectively treating a mozbrowser the same as a content/chrome
  * boundary).
  */
 NS_IMETHODIMP
 nsGlobalWindow::GetScriptableFrameElement(nsIDOMElement** aFrameElement)
 {
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMElement> frameElement = do_QueryInterface(GetFrameElement(rv));
-  if (rv.Failed()) {
-    return rv.ErrorCode();
-  }
-
-  frameElement.forget(aFrameElement);
-
-  return NS_OK;
-}
-
-Element*
-nsGlobalWindow::GetFrameElement(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetFrameElement, (aError), aError, nullptr);
+  FORWARD_TO_OUTER(GetScriptableFrameElement, (aFrameElement), NS_ERROR_NOT_INITIALIZED);
+  *aFrameElement = NULL;
 
   if (!mDocShell || mDocShell->GetIsBrowserOrApp()) {
-    return nullptr;
-  }
-
-  return GetRealFrameElement(aError);
-}
-
-Element*
-nsGlobalWindow::GetRealFrameElement(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetRealFrameElement, (aError), aError, nullptr);
+    return NS_OK;
+  }
+
+  return GetFrameElement(aFrameElement);
+}
+
+/**
+ * nsIGlobalWindow::GetFrameElement (when called from C++) is just a wrapper
+ * around GetRealFrameElement.
+ */
+NS_IMETHODIMP
+nsGlobalWindow::GetRealFrameElement(nsIDOMElement** aFrameElement)
+{
+  FORWARD_TO_OUTER(GetRealFrameElement, (aFrameElement), NS_ERROR_NOT_INITIALIZED);
+
+  *aFrameElement = NULL;
 
   if (!mDocShell) {
-    return nullptr;
+    return NS_OK;
   }
 
   nsCOMPtr<nsIDocShell> parent;
   mDocShell->GetSameTypeParentIgnoreBrowserAndAppBoundaries(getter_AddRefs(parent));
 
   if (!parent || parent == mDocShell) {
     // We're at a chrome boundary, don't expose the chrome iframe
     // element to content code.
-    return nullptr;
-  }
-
-  return mFrameElement;
-}
-
-/**
- * nsIGlobalWindow::GetFrameElement (when called from C++) is just a wrapper
- * around GetRealFrameElement.
- */
-NS_IMETHODIMP
-nsGlobalWindow::GetRealFrameElement(nsIDOMElement** aFrameElement)
-{
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMElement> frameElement =
-    do_QueryInterface(GetRealFrameElement(rv));
-  frameElement.forget(aFrameElement);
-
-  return rv.ErrorCode();
+    return NS_OK;
+  }
+
+  if (mFrameElement) {
+    CallQueryInterface(mFrameElement, aFrameElement);
+  }
+  return NS_OK;
 }
 
 // Helper for converting window.showModalDialog() options (list of ';'
 // separated name (:|=) value pairs) to a format that's parsable by
 // our normal window opening code.
 
 void
 ConvertDialogOptions(const nsAString& aOptions, nsAString& aResult)
@@ -8573,133 +7837,82 @@ ConvertDialogOptions(const nsAString& aO
     if (iter == end) {
       break;
     }
 
     iter++;
   }
 }
 
-already_AddRefed<nsIVariant>
-nsGlobalWindow::ShowModalDialog(const nsAString& aUrl, nsIVariant* aArgument,
-                                const nsAString& aOptions, ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(ShowModalDialog,
-                            (aUrl, aArgument, aOptions, aError), aError,
-                            nullptr);
-
-  if (Preferences::GetBool("dom.disable_window_showModalDialog", false)) {
-    aError.Throw(NS_ERROR_NOT_AVAILABLE);
-    return nullptr;
-  }
-
+NS_IMETHODIMP
+nsGlobalWindow::ShowModalDialog(const nsAString& aURI, nsIVariant *aArgs_,
+                                const nsAString& aOptions, uint8_t aArgc,
+                                nsIVariant **aRetVal)
+{
+  FORWARD_TO_OUTER(ShowModalDialog, (aURI, aArgs_, aOptions, aArgc, aRetVal),
+                   NS_ERROR_NOT_INITIALIZED);
+
+  *aRetVal = nullptr;
+
+  if (Preferences::GetBool("dom.disable_window_showModalDialog", false))
+    return NS_ERROR_NOT_AVAILABLE;
+
+  // Per-spec the |arguments| parameter is supposed to pass through unmodified.
+  // However, XPConnect default-initializes variants to null, rather than
+  // undefined. Fix this up here.
+  nsCOMPtr<nsIVariant> aArgs = aArgs_;
+  if (aArgc < 1) {
+    aArgs = CreateVoidVariant();
+  }
   nsRefPtr<DialogValueHolder> argHolder =
-    new DialogValueHolder(nsContentUtils::GetSubjectPrincipal(), aArgument);
+    new DialogValueHolder(nsContentUtils::GetSubjectPrincipal(), aArgs);
 
   // Before bringing up the window/dialog, unsuppress painting and flush
   // pending reflows.
   EnsureReflowFlushAndPaint();
 
   if (!AreDialogsEnabled()) {
-    aError.Throw(NS_ERROR_NOT_AVAILABLE);
-    return nullptr;
+    return NS_ERROR_NOT_AVAILABLE;
   }
 
   if (ShouldPromptToBlockDialogs() && !ConfirmDialogIfNeeded()) {
-    aError.Throw(NS_ERROR_NOT_AVAILABLE);
-    return nullptr;
+    return NS_ERROR_NOT_AVAILABLE;
   }
 
   nsCOMPtr<nsIDOMWindow> dlgWin;
   nsAutoString options(NS_LITERAL_STRING("-moz-internal-modal=1,status=1"));
 
   ConvertDialogOptions(aOptions, options);
 
   options.AppendLiteral(",scrollbars=1,centerscreen=1,resizable=0");
 
   EnterModalState();
   uint32_t oldMicroTaskLevel = nsContentUtils::MicroTaskLevel();
   nsContentUtils::SetMicroTaskLevel(0);
-  aError = OpenInternal(aUrl, EmptyString(), options,
-                        false,          // aDialog
-                        true,           // aContentModal
-                        true,           // aCalledNoScript
-                        true,           // aDoJSFixups
-                        true,           // aNavigate
-                        nullptr, argHolder, // args
-                        GetPrincipal(),     // aCalleePrincipal
-                        nullptr,            // aJSCallerContext
-                        getter_AddRefs(dlgWin));
+  nsresult rv = OpenInternal(aURI, EmptyString(), options,
+                             false,          // aDialog
+                             true,           // aContentModal
+                             true,           // aCalledNoScript
+                             true,           // aDoJSFixups
+                             true,           // aNavigate
+                             nullptr, argHolder, // args
+                             GetPrincipal(),     // aCalleePrincipal
+                             nullptr,            // aJSCallerContext
+                             getter_AddRefs(dlgWin));
   nsContentUtils::SetMicroTaskLevel(oldMicroTaskLevel);
   LeaveModalState();
-  if (aError.Failed()) {
-    return nullptr;
-  }
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIDOMModalContentWindow> dialog = do_QueryInterface(dlgWin);
-  if (!dialog) {
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIVariant> retVal;
-  aError = dialog->GetReturnValue(getter_AddRefs(retVal));
-  MOZ_ASSERT(!aError.Failed());
-
-  return retVal.forget();
-}
-
-JS::Value
-nsGlobalWindow::ShowModalDialog(JSContext* aCx, const nsAString& aUrl,
-                                const Optional<JS::Handle<JS::Value> >& aArgument,
-                                const nsAString& aOptions,
-                                ErrorResult& aError)
-{
-  nsCOMPtr<nsIVariant> args;
-  if (aArgument.WasPassed()) {
-    aError = nsContentUtils::XPConnect()->JSToVariant(aCx,
-                                                      aArgument.Value().get(),
-                                                      getter_AddRefs(args));
-  } else {
-    args = CreateVoidVariant();
-  }
-
-  nsCOMPtr<nsIVariant> retVal = ShowModalDialog(aUrl, args, aOptions, aError);
-  if (aError.Failed()) {
-    return JS::UndefinedValue();
-  }
-
-  JS::Value result;
-  if (retVal) {
-    aError = nsContentUtils::XPConnect()->VariantToJS(aCx,
-                                                      FastGetGlobalJSObject(),
-                                                      retVal, &result);
-  } else {
-    result = JS::NullValue();
-  }
-  return result;
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::ShowModalDialog(const nsAString& aURI, nsIVariant *aArgs_,
-                                const nsAString& aOptions, uint8_t aArgc,
-                                nsIVariant **aRetVal)
-{
-  // Per-spec the |arguments| parameter is supposed to pass through unmodified.
-  // However, XPConnect default-initializes variants to null, rather than
-  // undefined. Fix this up here.
-  nsCOMPtr<nsIVariant> aArgs = aArgs_;
-  if (aArgc < 1) {
-    aArgs = CreateVoidVariant();
-  }
-
-  ErrorResult rv;
-  nsCOMPtr<nsIVariant> retVal = ShowModalDialog(aURI, aArgs, aOptions, rv);
-  retVal.forget(aRetVal);
-
-  return rv.ErrorCode();
+  if (dialog) {
+    rv = dialog->GetReturnValue(aRetVal);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
+  }
+
+  return NS_OK;
 }
 
 class CommandDispatcher : public nsRunnable
 {
 public:
   CommandDispatcher(nsIDOMXULCommandDispatcher* aDispatcher,
                     const nsAString& aAction)
   : mDispatcher(aDispatcher), mAction(aAction) {}
@@ -8731,70 +7944,61 @@ nsGlobalWindow::UpdateCommands(const nsA
       nsContentUtils::AddScriptRunner(new CommandDispatcher(xulCommandDispatcher,
                                                             anAction));
     }
   }
 
   return NS_OK;
 }
 
-nsISelection*
-nsGlobalWindow::GetSelection(ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetSelection, (aError), aError, nullptr);
-
-  if (!mDocShell) {
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
-  if (!presShell) {
-    return nullptr;
-  }
-    
-  return presShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL);
-}
-
 NS_IMETHODIMP
 nsGlobalWindow::GetSelection(nsISelection** aSelection)
 {
-  ErrorResult rv;
-  nsCOMPtr<nsISelection> selection = GetSelection(rv);
-  selection.forget(aSelection);
-
-  return rv.ErrorCode();
-}
-
-bool
-nsGlobalWindow::Find(const nsAString& aString, bool aCaseSensitive,
+  FORWARD_TO_OUTER(GetSelection, (aSelection), NS_ERROR_NOT_INITIALIZED);
+
+  NS_ENSURE_ARG_POINTER(aSelection);
+  *aSelection = nullptr;
+
+  if (!mDocShell)
+    return NS_OK;
+
+  nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
+
+  if (!presShell)
+    return NS_OK;
+    
+  *aSelection = presShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL);
+  
+  NS_IF_ADDREF(*aSelection);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::Find(const nsAString& aStr, bool aCaseSensitive,
                      bool aBackwards, bool aWrapAround, bool aWholeWord,
                      bool aSearchInFrames, bool aShowDialog,
-                     ErrorResult& aError)
-{
-  if (Preferences::GetBool("dom.disable_window_find", false)) {
-    aError.Throw(NS_ERROR_NOT_AVAILABLE);
-    return false;
-  }
-
-  FORWARD_TO_OUTER_OR_THROW(Find,
-                            (aString, aCaseSensitive, aBackwards, aWrapAround,
-                             aWholeWord, aSearchInFrames, aShowDialog, aError),
-                            aError, false);
+                     bool *aDidFind)
+{
+  if (Preferences::GetBool("dom.disable_window_find", false))
+    return NS_ERROR_NOT_AVAILABLE;
+
+  FORWARD_TO_OUTER(Find, (aStr, aCaseSensitive, aBackwards, aWrapAround,
+                          aWholeWord, aSearchInFrames, aShowDialog, aDidFind),
+                   NS_ERROR_NOT_INITIALIZED);
+
+  nsresult rv = NS_OK;
+  *aDidFind = false;
 
   nsCOMPtr<nsIWebBrowserFind> finder(do_GetInterface(mDocShell));
-  if (!finder) {
-    aError.Throw(NS_ERROR_NOT_AVAILABLE);
-    return false;
-  }
+  NS_ENSURE_TRUE(finder, NS_ERROR_FAILURE);
 
   // Set the options of the search
-  aError = finder->SetSearchString(PromiseFlatString(aString).get());
-  if (aError.Failed()) {
-    return false;
-  }
+  rv = finder->SetSearchString(PromiseFlatString(aStr).get());
+  NS_ENSURE_SUCCESS(rv, rv);
   finder->SetMatchCase(aCaseSensitive);
   finder->SetFindBackwards(aBackwards);
   finder->SetWrapFind(aWrapAround);
   finder->SetEntireWord(aWholeWord);
   finder->SetSearchFrames(aSearchInFrames);
 
   // the nsIWebBrowserFind is initialized to use this window
   // as the search root, but uses focus to set the current search
@@ -8802,94 +8006,61 @@ nsGlobalWindow::Find(const nsAString& aS
   // should be the current search frame.
   nsCOMPtr<nsIWebBrowserFindInFrames> framesFinder(do_QueryInterface(finder));
   if (framesFinder) {
     framesFinder->SetRootSearchFrame(this);   // paranoia
     framesFinder->SetCurrentSearchFrame(this);
   }
   
   // The Find API does not accept empty strings. Launch the Find Dialog.
-  if (aString.IsEmpty() || aShowDialog) {
+  if (aStr.IsEmpty() || aShowDialog) {
     // See if the find dialog is already up using nsIWindowMediator
     nsCOMPtr<nsIWindowMediator> windowMediator =
       do_GetService(NS_WINDOWMEDIATOR_CONTRACTID);
 
     nsCOMPtr<nsIDOMWindow> findDialog;
 
     if (windowMediator) {
       windowMediator->GetMostRecentWindow(NS_LITERAL_STRING("findInPage").get(),
                                           getter_AddRefs(findDialog));
     }
 
     if (findDialog) {
       // The Find dialog is already open, bring it to the top.
-      aError = findDialog->Focus();
-    } else if (finder) {
-      // Open a Find dialog
-      nsCOMPtr<nsIDOMWindow> dialog;
-      aError = OpenDialog(NS_LITERAL_STRING("chrome://global/content/finddialog.xul"),
-                          NS_LITERAL_STRING("_blank"),
-                          NS_LITERAL_STRING("chrome, resizable=no, dependent=yes"),
-                          finder, getter_AddRefs(dialog));
-    }
-
-    return false;
-  }
-
-  // Launch the search with the passed in search string
-  bool didFind = false;
-  aError = finder->FindNext(&didFind);
-  return didFind;
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::Find(const nsAString& aStr, bool aCaseSensitive,
-                     bool aBackwards, bool aWrapAround, bool aWholeWord,
-                     bool aSearchInFrames, bool aShowDialog,
-                     bool *aDidFind)
-{
-  ErrorResult rv;
-  *aDidFind = Find(aStr, aCaseSensitive, aBackwards, aWrapAround, aWholeWord,
-                   aSearchInFrames, aShowDialog, rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::Atob(const nsAString& aAsciiBase64String,
-                     nsAString& aBinaryData, ErrorResult& aError)
-{
-  aError = nsContentUtils::Atob(aAsciiBase64String, aBinaryData);
+      rv = findDialog->Focus();
+    } else { // Open a Find dialog
+      if (finder) {
+        nsCOMPtr<nsIDOMWindow> dialog;
+        rv = OpenDialog(NS_LITERAL_STRING("chrome://global/content/finddialog.xul"),
+                        NS_LITERAL_STRING("_blank"),
+                        NS_LITERAL_STRING("chrome, resizable=no, dependent=yes"),
+                        finder, getter_AddRefs(dialog));
+      }
+    }
+  } else {
+    // Launch the search with the passed in search string
+    rv = finder->FindNext(aDidFind);
+    NS_ENSURE_SUCCESS(rv, rv);
+  }
+
+  return rv;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Atob(const nsAString& aAsciiBase64String,
                      nsAString& aBinaryData)
 {
-  ErrorResult rv;
-  Atob(aAsciiBase64String, aBinaryData, rv);
-
-  return rv.ErrorCode();
-}
-
-void
-nsGlobalWindow::Btoa(const nsAString& aBinaryData,
-                     nsAString& aAsciiBase64String, ErrorResult& aError)
-{
-  aError = nsContentUtils::Btoa(aBinaryData, aAsciiBase64String);
+  return nsContentUtils::Atob(aAsciiBase64String, aBinaryData);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Btoa(const nsAString& aBinaryData,
                      nsAString& aAsciiBase64String)
 {
-  ErrorResult rv;
-  Btoa(aBinaryData, aAsciiBase64String, rv);
-
-  return rv.ErrorCode();
+  return nsContentUtils::Btoa(aBinaryData, aAsciiBase64String);
 }
 
 //*****************************************************************************
 // nsGlobalWindow::nsIDOMEventTarget
 //*****************************************************************************
 
 NS_IMETHODIMP
 nsGlobalWindow::RemoveEventListener(const nsAString& aType,
@@ -9112,36 +8283,34 @@ nsGlobalWindow::GetPrivateRoot()
       }
     }
   }
 
   return static_cast<nsGlobalWindow*>(top.get());
 }
 
 
-nsIDOMLocation*
-nsGlobalWindow::GetLocation(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetLocation, (aError), aError, nullptr);
+NS_IMETHODIMP
+nsGlobalWindow::GetLocation(nsIDOMLocation ** aLocation)
+{
+  FORWARD_TO_INNER(GetLocation, (aLocation), NS_ERROR_NOT_INITIALIZED);
+
+  *aLocation = nullptr;
 
   nsIDocShell *docShell = GetDocShell();
   if (!mLocation && docShell) {
     mLocation = new nsLocation(docShell);
-  }
-  return mLocation;
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::GetLocation(nsIDOMLocation ** aLocation)
-{
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMLocation> location = GetLocation(rv);
-  location.forget(aLocation);
-
-  return rv.ErrorCode();
+    if (!mLocation) {
+      return NS_ERROR_OUT_OF_MEMORY;
+    }
+  }
+
+  NS_IF_ADDREF(*aLocation = mLocation);
+
+  return NS_OK;
 }
 
 void
 nsGlobalWindow::ActivateOrDeactivate(bool aActivate)
 {
   // Set / unset mIsActive on the top level window, which is used for the
   // :-moz-window-inactive pseudoclass, and its sheet (if any).
   nsCOMPtr<nsIWidget> mainWidget = GetMainWidget();
@@ -9711,125 +8880,105 @@ nsGlobalWindow::UpdateCanvasFocus(bool a
           nsCanvasFrame* canvasFrame = FindCanvasFrame(frame);
           if (canvasFrame) {
               canvasFrame->SetHasFocus(false);
           }
       }
   }
 }
 
-already_AddRefed<nsICSSDeclaration>
-nsGlobalWindow::GetComputedStyle(Element& aElt, const nsAString& aPseudoElt,
-                                 ErrorResult& aError)
-{
-  return GetComputedStyleHelper(aElt, aPseudoElt, false, aError);
-}
-
 NS_IMETHODIMP
 nsGlobalWindow::GetComputedStyle(nsIDOMElement* aElt,
                                  const nsAString& aPseudoElt,
                                  nsIDOMCSSStyleDeclaration** aReturn)
 {
   return GetComputedStyleHelper(aElt, aPseudoElt, false, aReturn);
 }
 
-already_AddRefed<nsICSSDeclaration>
-nsGlobalWindow::GetDefaultComputedStyle(Element& aElt,
-                                        const nsAString& aPseudoElt,
-                                        ErrorResult& aError)
-{
-  return GetComputedStyleHelper(aElt, aPseudoElt, true, aError);
-}
-
 NS_IMETHODIMP
 nsGlobalWindow::GetDefaultComputedStyle(nsIDOMElement* aElt,
                                         const nsAString& aPseudoElt,
                                         nsIDOMCSSStyleDeclaration** aReturn)
 {
   return GetComputedStyleHelper(aElt, aPseudoElt, true, aReturn);
 }
 
 nsresult
 nsGlobalWindow::GetComputedStyleHelper(nsIDOMElement* aElt,
                                        const nsAString& aPseudoElt,
                                        bool aDefaultStylesOnly,
                                        nsIDOMCSSStyleDeclaration** aReturn)
 {
+  FORWARD_TO_OUTER(GetComputedStyleHelper, (aElt, aPseudoElt,
+                                            aDefaultStylesOnly, aReturn),
+                   NS_ERROR_NOT_INITIALIZED);
+
   NS_ENSURE_ARG_POINTER(aReturn);
   *aReturn = nullptr;
 
-  nsCOMPtr<dom::Element> element = do_QueryInterface(aElt);
-  if (!element) {
+  if (!aElt) {
     return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
   }
 
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMCSSStyleDeclaration> declaration =
-    GetComputedStyleHelper(*element, aPseudoElt, aDefaultStylesOnly, rv);
-  declaration.forget(aReturn);
-
-  return rv.ErrorCode();
-}
-
-already_AddRefed<nsICSSDeclaration>
-nsGlobalWindow::GetComputedStyleHelper(Element& aElt,
-                                       const nsAString& aPseudoElt,
-                                       bool aDefaultStylesOnly,
-                                       ErrorResult& aError)
-{
-  FORWARD_TO_OUTER_OR_THROW(GetComputedStyleHelper,
-                            (aElt, aPseudoElt, aDefaultStylesOnly, aError),
-                            aError, nullptr);
-
   if (!mDocShell) {
-    return nullptr;
+    return NS_OK;
   }
 
   nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
 
   if (!presShell) {
     // Try flushing frames on our parent in case there's a pending
     // style change that will create the presshell.
     nsGlobalWindow *parent =
       static_cast<nsGlobalWindow *>(GetPrivateParent());
     if (!parent) {
-      return nullptr;
+      return NS_OK;
     }
 
     parent->FlushPendingNotifications(Flush_Frames);
 
     // Might have killed mDocShell
     if (!mDocShell) {
-      return nullptr;
+      return NS_OK;
     }
 
     presShell = mDocShell->GetPresShell();
     if (!presShell) {
-      return nullptr;
-    }
-  }
-
+      return NS_OK;
+    }
+  }
+
+  nsCOMPtr<dom::Element> element = do_QueryInterface(aElt);
+  NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
   nsRefPtr<nsComputedDOMStyle> compStyle =
-    NS_NewComputedDOMStyle(&aElt, aPseudoElt, presShell,
+    NS_NewComputedDOMStyle(element, aPseudoElt, presShell,
                            aDefaultStylesOnly ? nsComputedDOMStyle::eDefaultOnly :
                                                 nsComputedDOMStyle::eAll);
 
-  return compStyle.forget();
-}
-
-nsIDOMStorage*
-nsGlobalWindow::GetSessionStorage(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetSessionStorage, (aError), aError, nullptr);
+  *aReturn = compStyle.forget().get();
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::GetSessionStorage(nsIDOMStorage ** aSessionStorage)
+{
+  FORWARD_TO_INNER(GetSessionStorage, (aSessionStorage), NS_ERROR_UNEXPECTED);
 
   nsIPrincipal *principal = GetPrincipal();
   nsIDocShell* docShell = GetDocShell();
 
-  if (!principal || !docShell || !Preferences::GetBool(kStorageEnabled)) {
-    return nullptr;
+  if (!principal || !docShell) {
+    *aSessionStorage = nullptr;
+    return NS_OK;
+  }
+
+  if (!Preferences::GetBool(kStorageEnabled)) {
+    *aSessionStorage = nullptr;
+    return NS_OK;
   }
 
   if (mSessionStorage) {
 #ifdef PR_LOGGING
     if (PR_LOG_TEST(gDOMLeakPRLog, PR_LOG_DEBUG)) {
       PR_LogPrint("nsGlobalWindow %p has %p sessionStorage", this, mSessionStorage.get());
     }
 #endif
@@ -9841,155 +8990,132 @@ nsGlobalWindow::GetSessionStorage(ErrorR
                    "that could not be accessed!");
       if (!canAccess) {
         mSessionStorage = nullptr;
       }
     }
   }
 
   if (!mSessionStorage) {
+    *aSessionStorage = nullptr;
+
     nsString documentURI;
     if (mDoc) {
       mDoc->GetDocumentURI(documentURI);
     }
 
     // If the document has the sandboxed origin flag set
     // don't allow access to sessionStorage.
     if (!mDoc) {
-      aError.Throw(NS_ERROR_FAILURE);
-      return nullptr;
+      return NS_ERROR_FAILURE;
     }
 
     if (mDoc->GetSandboxFlags() & SANDBOXED_ORIGIN) {
-      aError.Throw(NS_ERROR_DOM_SECURITY_ERR);
-      return nullptr;
+      return NS_ERROR_DOM_SECURITY_ERR;
     }
 
     nsresult rv;
 
     nsCOMPtr<nsIDOMStorageManager> storageManager = do_QueryInterface(docShell, &rv);
-    if (NS_FAILED(rv)) {
-      aError.Throw(rv);
-      return nullptr;
-    }
+    NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
 
-    aError = storageManager->CreateStorage(principal,
-                                           documentURI,
-                                           loadContext && loadContext->UsePrivateBrowsing(),
-                                           getter_AddRefs(mSessionStorage));
-    if (aError.Failed()) {
-      return nullptr;
-    }
+    rv = storageManager->CreateStorage(principal,
+                                       documentURI,
+                                       loadContext && loadContext->UsePrivateBrowsing(),
+                                       getter_AddRefs(mSessionStorage));
+    NS_ENSURE_SUCCESS(rv, rv);
 
 #ifdef PR_LOGGING
     if (PR_LOG_TEST(gDOMLeakPRLog, PR_LOG_DEBUG)) {
       PR_LogPrint("nsGlobalWindow %p tried to get a new sessionStorage %p", this, mSessionStorage.get());
     }
 #endif
 
     if (!mSessionStorage) {
-      aError.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
-      return nullptr;
+      return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
     }
   }
 
 #ifdef PR_LOGGING
   if (PR_LOG_TEST(gDOMLeakPRLog, PR_LOG_DEBUG)) {
     PR_LogPrint("nsGlobalWindow %p returns %p sessionStorage", this, mSessionStorage.get());
   }
 #endif
 
-  return mSessionStorage;
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::GetSessionStorage(nsIDOMStorage ** aSessionStorage)
-{
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMStorage> storage = GetSessionStorage(rv);
-  storage.forget(aSessionStorage);
-
-  return rv.ErrorCode();
-}
-
-nsIDOMStorage*
-nsGlobalWindow::GetLocalStorage(ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(GetLocalStorage, (aError), aError, nullptr);
+  NS_ADDREF(*aSessionStorage = mSessionStorage);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::GetLocalStorage(nsIDOMStorage ** aLocalStorage)
+{
+  FORWARD_TO_INNER(GetLocalStorage, (aLocalStorage), NS_ERROR_UNEXPECTED);
+
+  NS_ENSURE_ARG(aLocalStorage);
 
   if (!Preferences::GetBool(kStorageEnabled)) {
-    return nullptr;
+    *aLocalStorage = nullptr;
+    return NS_OK;
   }
 
   if (!mLocalStorage) {
+    *aLocalStorage = nullptr;
+
+    nsresult rv;
+
     if (!DOMStorage::CanUseStorage()) {
-      aError.Throw(NS_ERROR_DOM_SECURITY_ERR);
-      return nullptr;
+      return NS_ERROR_DOM_SECURITY_ERR;
     }
 
     nsIPrincipal *principal = GetPrincipal();
     if (!principal) {
-      return nullptr;
-    }
-
-    nsresult rv;
+      return NS_OK;
+    }
+
     nsCOMPtr<nsIDOMStorageManager> storageManager =
       do_GetService("@mozilla.org/dom/localStorage-manager;1", &rv);
-    if (NS_FAILED(rv)) {
-      aError.Throw(rv);
-      return nullptr;
-    }
+    NS_ENSURE_SUCCESS(rv, rv);
 
     // If the document has the sandboxed origin flag set
     // don't allow access to localStorage.
     if (mDoc && (mDoc->GetSandboxFlags() & SANDBOXED_ORIGIN)) {
-      aError.Throw(NS_ERROR_DOM_SECURITY_ERR);
-      return nullptr;
+      return NS_ERROR_DOM_SECURITY_ERR;
     }
 
     nsString documentURI;
     if (mDoc) {
       mDoc->GetDocumentURI(documentURI);
     }
 
     nsIDocShell* docShell = GetDocShell();
     nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
 
-    aError = storageManager->CreateStorage(principal,
-                                           documentURI,
-                                           loadContext && loadContext->UsePrivateBrowsing(),
-                                           getter_AddRefs(mLocalStorage));
-  }
-
-  return mLocalStorage;
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::GetLocalStorage(nsIDOMStorage ** aLocalStorage)
-{
-  NS_ENSURE_ARG(aLocalStorage);
-
-  ErrorResult rv;
-  nsCOMPtr<nsIDOMStorage> storage = GetLocalStorage(rv);
-  storage.forget(aLocalStorage);
-
-  return rv.ErrorCode();
-}
-
-indexedDB::IDBFactory*
-nsGlobalWindow::GetIndexedDB(ErrorResult& aError)
+    rv = storageManager->CreateStorage(principal,
+                                       documentURI,
+                                       loadContext && loadContext->UsePrivateBrowsing(),
+                                       getter_AddRefs(mLocalStorage));
+    NS_ENSURE_SUCCESS(rv, rv);
+  }
+
+  NS_ADDREF(*aLocalStorage = mLocalStorage);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGlobalWindow::GetIndexedDB(nsISupports** _retval)
 {
   if (!mIndexedDB) {
+    nsresult rv;
+
     // If the document has the sandboxed origin flag set
     // don't allow access to indexedDB.
     if (mDoc && (mDoc->GetSandboxFlags() & SANDBOXED_ORIGIN)) {
-      aError.Throw(NS_ERROR_DOM_SECURITY_ERR);
-      return nullptr;
+      return NS_ERROR_DOM_SECURITY_ERR;
     }
 
     if (!IsChromeWindow()) {
       // Whitelist about:home, since it doesn't have a base domain it would not
       // pass the thirdPartyUtil check, though it should be able to use
       // indexedDB.
       bool skipThirdPartyCheck = false;
       nsIPrincipal *principal = GetPrincipal();
@@ -10002,48 +9128,39 @@ nsGlobalWindow::GetIndexedDB(ErrorResult
           skipThirdPartyCheck = NS_SUCCEEDED(uri->GetPath(path)) &&
                                 path.EqualsLiteral("home");
         }
       }
 
       if (!skipThirdPartyCheck) {
         nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
           do_GetService(THIRDPARTYUTIL_CONTRACTID);
-        if (!thirdPartyUtil) {
-          aError.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
-          return nullptr;
-        }
+        NS_ENSURE_TRUE(thirdPartyUtil, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
 
         bool isThirdParty;
-        aError = thirdPartyUtil->IsThirdPartyWindow(this, nullptr,
-                                                    &isThirdParty);
-        if (aError.Failed() || isThirdParty) {
-          NS_WARN_IF_FALSE(aError.Failed(),
-                           "IndexedDB is not permitted in a third-party window.");
-          return nullptr;
+        rv = thirdPartyUtil->IsThirdPartyWindow(this, nullptr, &isThirdParty);
+        NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
+
+        if (isThirdParty) {
+          NS_WARNING("IndexedDB is not permitted in a third-party window.");
+          *_retval = nullptr;
+          return NS_OK;
         }
       }
     }
 
     // This may be null if being created from a file.
-    aError = indexedDB::IDBFactory::Create(this, nullptr,
-                                           getter_AddRefs(mIndexedDB));
-  }
-
-  return mIndexedDB;
-}
-
-NS_IMETHODIMP
-nsGlobalWindow::GetIndexedDB(nsISupports** _retval)
-{
-  ErrorResult rv;
-  nsCOMPtr<nsISupports> request(GetIndexedDB(rv));
+    rv = indexedDB::IDBFactory::Create(this, nullptr,
+                                       getter_AddRefs(mIndexedDB));
+    NS_ENSURE_SUCCESS(rv, rv);
+  }
+
+  nsCOMPtr<nsISupports> request(mIndexedDB);
   request.forget(_retval);
-
-  return rv.ErrorCode();
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetMozIndexedDB(nsISupports** _retval)
 {
   return GetIndexedDB(_retval);
 }
 
@@ -11173,108 +10290,16 @@ nsGlobalWindow::OpenInternal(const nsASt
 }
 
 //*****************************************************************************
 // nsGlobalWindow: Timeout Functions
 //*****************************************************************************
 
 uint32_t sNestingLevel;
 
-nsGlobalWindow*
-nsGlobalWindow::InnerForSetTimeoutOrInterval(ErrorResult& aError)
-{
-  // This needs to forward to the inner window, but since the current
-  // inner may not be the inner in the calling scope, we need to treat
-  // this specially here as we don't want timeouts registered in a
-  // dying inner window to get registered and run on the current inner
-  // window. To get this right, we need to forward this call to the
-  // inner window that's calling window.setTimeout().
-
-  if (!IsOuterWindow()) {
-    return this;
-  }
-
-  nsGlobalWindow* callerInner = CallerInnerWindow();
-  if (!callerInner) {
-    aError.Throw(NS_ERROR_NOT_AVAILABLE);
-    return nullptr;
-  }
-
-  // If the caller and the callee share the same outer window,
-  // forward to the caller inner. Else, we forward to the current
-  // inner (e.g. someone is calling setTimeout() on a reference to
-  // some other window).
-
-  if (callerInner->GetOuterWindow() == this &&
-      callerInner->IsInnerWindow()) {
-    return callerInner;
-  }
-
-  nsGlobalWindow* currentInner = GetCurrentInnerWindowInternal();
-  if (!currentInner) {
-    NS_WARNING("No inner window available!");
-    aError.Throw(NS_ERROR_NOT_INITIALIZED);
-    return nullptr;
-  }
-
-  return currentInner;
-}
-
-int32_t
-nsGlobalWindow::SetTimeout(JSContext* aCx, Function& aFunction,
-                           int32_t aTimeout,
-                           const Sequence<JS::Value>& aArguments,
-                           ErrorResult& aError)
-{
-  return SetTimeoutOrInterval(aFunction, aTimeout, aArguments, false, aError);
-}
-
-int32_t
-nsGlobalWindow::SetTimeout(JSContext* aCx, const nsAString& aHandler,
-                           int32_t aTimeout, ErrorResult& aError)
-{
-  return SetTimeoutOrInterval(aCx, aHandler, aTimeout, false, aError);
-}
-
-static bool
-IsInterval(const Optional<int32_t>& aTimeout, int32_t& aResultTimeout)
-{
-  if (aTimeout.WasPassed()) {
-    aResultTimeout = aTimeout.Value();
-    return true;
-  }
-
-  // If no interval was specified, treat this like a timeout, to avoid setting
-  // an interval of 0 milliseconds.
-  aResultTimeout = 0;
-  return false;
-}
-
-int32_t
-nsGlobalWindow::SetInterval(JSContext* aCx, Function& aFunction,
-                            const Optional<int32_t>& aTimeout,
-                            const Sequence<JS::Value>& aArguments,
-                            ErrorResult& aError)
-{
-  int32_t timeout;
-  bool isInterval = IsInterval(aTimeout, timeout);
-  return SetTimeoutOrInterval(aFunction, timeout, aArguments, isInterval,
-                              aError);
-}
-
-int32_t
-nsGlobalWindow::SetInterval(JSContext* aCx, const nsAString& aHandler,
-                            const Optional<int32_t>& aTimeout,
-                            ErrorResult& aError)
-{
-  int32_t timeout;
-  bool isInterval = IsInterval(aTimeout, timeout);
-  return SetTimeoutOrInterval(aCx, aHandler, timeout, isInterval, aError);
-}
-
 nsresult
 nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
                                      int32_t interval,
                                      bool aIsInterval, int32_t *aReturn)
 {
   FORWARD_TO_INNER(SetTimeoutOrInterval, (aHandler, interval, aIsInterval, aReturn),
                    NS_ERROR_NOT_INITIALIZED);
 
@@ -11440,76 +10465,22 @@ nsGlobalWindow::SetTimeoutOrInterval(boo
 
   int32_t interval = 0;
   bool isInterval = aIsInterval;
   nsCOMPtr<nsIScriptTimeoutHandler> handler;
   nsresult rv = NS_CreateJSTimeoutHandler(this,
                                           &isInterval,
                                           &interval,
                                           getter_AddRefs(handler));
-  if (!handler) {
-    *aReturn = 0;
-    return rv;
-  }
+  if (NS_FAILED(rv))
+    return (rv == NS_ERROR_DOM_TYPE_ERR) ? NS_OK : rv;
 
   return SetTimeoutOrInterval(handler, interval, isInterval, aReturn);
 }
 
-int32_t
-nsGlobalWindow::SetTimeoutOrInterval(Function& aFunction, int32_t aTimeout,
-                                     const Sequence<JS::Value>& aArguments,
-                                     bool aIsInterval, ErrorResult& aError)
-{
-  nsGlobalWindow* inner = InnerForSetTimeoutOrInterval(aError);
-  if (aError.Failed()) {
-    return 0;
-  }
-
-  if (inner != this) {
-    return inner->SetTimeoutOrInterval(aFunction, aTimeout, aArguments,
-                                       aIsInterval, aError);
-  }
-
-  nsCOMPtr<nsIScriptTimeoutHandler> handler =
-    NS_CreateJSTimeoutHandler(this, aFunction, aArguments, aError);
-  if (!handler) {
-    return 0;
-  }
-
-  int32_t result;
-  aError = SetTimeoutOrInterval(handler, aTimeout, aIsInterval, &result);
-  return result;
-}
-
-int32_t
-nsGlobalWindow::SetTimeoutOrInterval(JSContext* aCx, const nsAString& aHandler,
-                                     int32_t aTimeout, bool aIsInterval,
-                                     ErrorResult& aError)
-{
-  nsGlobalWindow* inner = InnerForSetTimeoutOrInterval(aError);
-  if (aError.Failed()) {
-    return 0;
-  }
-
-  if (inner != this) {
-    return inner->SetTimeoutOrInterval(aCx, aHandler, aTimeout, aIsInterval,
-                                       aError);
-  }
-
-  nsCOMPtr<nsIScriptTimeoutHandler> handler =
-    NS_CreateJSTimeoutHandler(aCx, this, aHandler, aError);
-  if (!handler) {
-    return 0;
-  }
-
-  int32_t result;
-  aError = SetTimeoutOrInterval(handler, aTimeout, aIsInterval, &result);
-  return result;
-}
-
 bool
 nsGlobalWindow::RunTimeoutHandler(nsTimeout* aTimeout,
                                   nsIScriptContext* aScx)
 {
   // Hold on to the timeout in case mExpr or mFunObj releases its
   // doc.
   nsRefPtr<nsTimeout> timeout = aTimeout;
   nsTimeout* last_running_timeout = mRunningTimeout;
@@ -11833,21 +10804,20 @@ nsGlobalWindow::RunTimeout(nsTimeout *aT
   // Take the dummy timeout off the head of the list
   dummy_timeout->remove();
   dummy_timeout->Release();
   MOZ_ASSERT(dummy_timeout->HasRefCntOne(), "dummy_timeout may leak");
 
   mTimeoutInsertionPoint = last_insertion_point;
 }
 
-void
-nsGlobalWindow::ClearTimeoutOrInterval(int32_t aTimerID, ErrorResult& aError)
-{
-  FORWARD_TO_INNER_OR_THROW(ClearTimeoutOrInterval, (aTimerID, aError),
-                            aError, );
+nsresult
+nsGlobalWindow::ClearTimeoutOrInterval(int32_t aTimerID)
+{
+  FORWARD_TO_INNER(ClearTimeoutOrInterval, (aTimerID), NS_ERROR_NOT_INITIALIZED);
 
   uint32_t public_id = (uint32_t)aTimerID;
   nsTimeout *timeout;
 
   for (timeout = mTimeouts.getFirst(); timeout; timeout = timeout->getNext()) {
     if (timeout->mPublicId == public_id) {
       if (timeout->mRunning) {
         /* We're running from inside the timeout. Mark this
@@ -11864,16 +10834,18 @@ nsGlobalWindow::ClearTimeoutOrInterval(i
           timeout->mTimer = nullptr;
           timeout->Release();
         }
         timeout->Release();
       }
       break;
     }
   }
+
+  return NS_OK;
 }
 
 nsresult nsGlobalWindow::ResetTimersForNonBackgroundWindow()
 {
   FORWARD_TO_INNER(ResetTimersForNonBackgroundWindow, (),
                    NS_ERROR_NOT_INITIALIZED);
 
   if (IsFrozen() || mTimeoutsSuspendDepth) {
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -41,16 +41,17 @@
 #include "nsFrameMessageManager.h"
 #include "mozilla/LinkedList.h"
 #include "mozilla/TimeStamp.h"
 #include "nsIInlineEventHandlers.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsIIdleObserver.h"
 #include "nsIDocument.h"
 #include "nsIDOMTouchEvent.h"
+
 #include "mozilla/dom/EventTarget.h"
 #include "Units.h"
 #include "nsComponentManagerUtils.h"
 
 #ifdef MOZ_B2G
 #include "nsIDOMWindowB2G.h"
 #endif // MOZ_B2G
 
@@ -73,17 +74,16 @@
 #define MAX_IDLE_FUZZ_TIME_MS 90000
 
 // Min idle notification time in seconds.
 #define MIN_IDLE_NOTIFICATION_TIME_S 1
 
 class nsIArray;
 class nsIBaseWindow;
 class nsIContent;
-class nsICSSDeclaration;
 class nsIDocShellTreeOwner;
 class nsIDOMCrypto;
 class nsIDOMOfflineResourceList;
 class nsIDOMMozWakeLock;
 class nsIScrollableFrame;
 class nsIControllers;
 class nsIScriptContext;
 class nsIScriptTimeoutHandler;
@@ -101,43 +101,31 @@ class nsIIdleService;
 struct nsIntSize;
 struct nsRect;
 
 class nsWindowSizes;
 
 namespace mozilla {
 namespace dom {
 class BarProp;
-class Function;
 class Gamepad;
 class Navigator;
 class SpeechSynthesis;
 namespace indexedDB {
 class IDBFactory;
 } // namespace indexedDB
 } // namespace dom
 } // namespace mozilla
 
 extern nsresult
 NS_CreateJSTimeoutHandler(nsGlobalWindow *aWindow,
                           bool *aIsInterval,
                           int32_t *aInterval,
                           nsIScriptTimeoutHandler **aRet);
 
-extern already_AddRefed<nsIScriptTimeoutHandler>
-NS_CreateJSTimeoutHandler(nsGlobalWindow *aWindow,
-                          mozilla::dom::Function& aFunction,
-                          const mozilla::dom::Sequence<JS::Value>& aArguments,
-                          mozilla::ErrorResult& aError);
-
-extern already_AddRefed<nsIScriptTimeoutHandler>
-NS_CreateJSTimeoutHandler(JSContext* aCx, nsGlobalWindow *aWindow,
-                          const nsAString& aExpression,
-                          mozilla::ErrorResult& aError);
-
 /*
  * Timeout struct that holds information about each script
  * timeout.  Holds a strong reference to an nsIScriptTimeoutHandler, which
  * abstracts the language specific cruft.
  */
 struct nsTimeout : mozilla::LinkedListElement<nsTimeout>
 {
   nsTimeout();
@@ -313,16 +301,17 @@ class nsGlobalWindow : public mozilla::d
 #endif // MOZ_B2G
 #ifdef MOZ_WEBSPEECH
                      , public nsISpeechSynthesisGetter
 #endif // MOZ_WEBSPEECH
 {
 public:
   typedef mozilla::TimeStamp TimeStamp;
   typedef mozilla::TimeDuration TimeDuration;
+  typedef mozilla::dom::Navigator Navigator;
   typedef nsDataHashtable<nsUint64HashKey, nsGlobalWindow*> WindowByIdTable;
 
   // public methods
   nsPIDOMWindow* GetPrivateParent();
   // callback for close event
   void ReallyCloseWindow();
 
   // nsISupports
@@ -462,28 +451,34 @@ public:
   virtual NS_HIDDEN_(nsresult) SetFullScreenInternal(bool aIsFullScreen, bool aRequireTrust);
 
   virtual NS_HIDDEN_(void) SetHasGamepadEventListener(bool aHasGamepad = true);
 
   // nsIInterfaceRequestor
   NS_DECL_NSIINTERFACEREQUESTOR
 
   // WebIDL interface.
+  uint32_t GetLength();
   already_AddRefed<nsIDOMWindow> IndexedGetter(uint32_t aIndex, bool& aFound);
 
   void GetSupportedNames(nsTArray<nsString>& aNames);
 
   // Object Management
   nsGlobalWindow(nsGlobalWindow *aOuterWindow);
 
   static nsGlobalWindow *FromSupports(nsISupports *supports)
   {
     // Make sure this matches the casts we do in QueryInterface().
     return (nsGlobalWindow *)(mozilla::dom::EventTarget *)supports;
   }
+  static nsISupports *ToSupports(nsGlobalWindow *win)
+  {
+    // Make sure this matches the casts we do in QueryInterface().
+    return (nsISupports *)(mozilla::dom::EventTarget *)win;
+  }
   static nsGlobalWindow *FromWrapper(nsIXPConnectWrappedNative *wrapper)
   {
     return FromSupports(wrapper->Native());
   }
 
   /**
    * Wrap nsIDOMWindow::GetTop so we can overload the inline GetTop()
    * implementation below.  (nsIDOMWindow::GetTop simply calls
@@ -502,17 +497,20 @@ public:
       return static_cast<nsGlobalWindow *>(top.get());
     return nullptr;
   }
 
   inline nsGlobalWindow* GetScriptableTop()
   {
     nsCOMPtr<nsIDOMWindow> top;
     GetScriptableTop(getter_AddRefs(top));
-    return static_cast<nsGlobalWindow *>(top.get());
+    if (top) {
+      return static_cast<nsGlobalWindow *>(top.get());
+    }
+    return nullptr;
   }
 
   already_AddRefed<nsIDOMWindow> GetChildWindow(const nsAString& aName);
 
   // These return true if we've reached the state in this top level window
   // where we ask the user if further dialogs should be blocked.
   //
   // DialogsAreBeingAbused must be called on the scriptable top inner window.
@@ -758,187 +756,21 @@ public:
 #define TOUCH_EVENT EVENT
 #include "nsEventNameList.h"
 #undef TOUCH_EVENT
 #undef WINDOW_ONLY_EVENT
 #undef BEFOREUNLOAD_EVENT
 #undef ERROR_EVENT
 #undef EVENT
 
-  nsISupports* GetParentObject()
-  {
-    return nullptr;
-  }
+#ifdef MOZ_WEBSPEECH
+  mozilla::dom::SpeechSynthesis* GetSpeechSynthesisInternal();
+#endif
 
-  nsIDOMWindow* GetWindow(mozilla::ErrorResult& aError);
-  nsIDOMWindow* GetSelf(mozilla::ErrorResult& aError);
-  nsIDocument* GetDocument()
-  {
-    return GetDoc();
-  }
-  void GetName(nsAString& aName, mozilla::ErrorResult& aError);
-  void SetName(const nsAString& aName, mozilla::ErrorResult& aError);
-  nsIDOMLocation* GetLocation(mozilla::ErrorResult& aError);
-  nsHistory* GetHistory(mozilla::ErrorResult& aError);
-  mozilla::dom::BarProp* GetLocationbar(mozilla::ErrorResult& aError);
-  mozilla::dom::BarProp* GetMenubar(mozilla::ErrorResult& aError);
-  mozilla::dom::BarProp* GetPersonalbar(mozilla::ErrorResult& aError);
-  mozilla::dom::BarProp* GetScrollbars(mozilla::ErrorResult& aError);
-  mozilla::dom::BarProp* GetStatusbar(mozilla::ErrorResult& aError);
-  mozilla::dom::BarProp* GetToolbar(mozilla::ErrorResult& aError);
-  void GetStatus(nsAString& aStatus, mozilla::ErrorResult& aError);
-  void SetStatus(const nsAString& aStatus, mozilla::ErrorResult& aError);
-  void Close(mozilla::ErrorResult& aError);
-  bool GetClosed(mozilla::ErrorResult& aError);
-  void Stop(mozilla::ErrorResult& aError);
-  void Focus(mozilla::ErrorResult& aError);
-  void Blur(mozilla::ErrorResult& aError);
-  already_AddRefed<nsIDOMWindow> GetFrames(mozilla::ErrorResult& aError);
-  uint32_t Length();
-  already_AddRefed<nsIDOMWindow> GetTop(mozilla::ErrorResult& aError)
-  {
-    nsCOMPtr<nsIDOMWindow> top;
-    aError = GetScriptableTop(getter_AddRefs(top));
-    return top.forget();
-  }
-  nsIDOMWindow* GetOpener(mozilla::ErrorResult& aError);
-  void SetOpener(nsIDOMWindow* aOpener, mozilla::ErrorResult& aError);
-  using nsIDOMWindow::GetParent;
-  already_AddRefed<nsIDOMWindow> GetParent(mozilla::ErrorResult& aError);
-  mozilla::dom::Element* GetFrameElement(mozilla::ErrorResult& aError);
-  already_AddRefed<nsIDOMWindow> Open(const nsAString& aUrl,
-                                      const nsAString& aName,
-                                      const nsAString& aOptions,
-                                      mozilla::ErrorResult& aError);
-  mozilla::dom::Navigator* GetNavigator(mozilla::ErrorResult& aError);
-  nsIDOMOfflineResourceList* GetApplicationCache(mozilla::ErrorResult& aError);
-  void Alert(const nsAString& aMessage, mozilla::ErrorResult& aError);
-  bool Confirm(const nsAString& aMessage, mozilla::ErrorResult& aError);
-  void Prompt(const nsAString& aMessage, const nsAString& aInitial,
-              nsAString& aReturn, mozilla::ErrorResult& aError);
-  void Print(mozilla::ErrorResult& aError);
-  JS::Value ShowModalDialog(JSContext* aCx, const nsAString& aUrl, const mozilla::dom::Optional<JS::Handle<JS::Value> >& aArgument, const nsAString& aOptions, mozilla::ErrorResult& aError);
-  void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
-                      const nsAString& aTargetOrigin,
-                      const mozilla::dom::Optional<mozilla::dom::Sequence<JS::Value > >& aTransfer,
-                      mozilla::ErrorResult& aError);
-  int32_t SetTimeout(JSContext* aCx, mozilla::dom::Function& aFunction,
-                     int32_t aTimeout,
-                     const mozilla::dom::Sequence<JS::Value>& aArguments,
-                     mozilla::ErrorResult& aError);
-  int32_t SetTimeout(JSContext* aCx, const nsAString& aHandler,
-                     int32_t aTimeout, mozilla::ErrorResult& aError);
-  void ClearTimeout(int32_t aHandle, mozilla::ErrorResult& aError);
-  int32_t SetInterval(JSContext* aCx, mozilla::dom::Function& aFunction,
-                      const mozilla::dom::Optional<int32_t>& aTimeout,
-                      const mozilla::dom::Sequence<JS::Value>& aArguments,
-                      mozilla::ErrorResult& aError);
-  int32_t SetInterval(JSContext* aCx, const nsAString& aHandler,
-                      const mozilla::dom::Optional<int32_t>& aTimeout,
-                      mozilla::ErrorResult& aError);
-  void ClearInterval(int32_t aHandle, mozilla::ErrorResult& aError);
-  void Atob(const nsAString& aAsciiBase64String, nsAString& aBinaryData,
-            mozilla::ErrorResult& aError);
-  void Btoa(const nsAString& aBinaryData, nsAString& aAsciiBase64String,
-            mozilla::ErrorResult& aError);
-  nsIDOMStorage* GetSessionStorage(mozilla::ErrorResult& aError);
-  nsIDOMStorage* GetLocalStorage(mozilla::ErrorResult& aError);
-  nsISelection* GetSelection(mozilla::ErrorResult& aError);
-  mozilla::dom::indexedDB::IDBFactory* GetIndexedDB(mozilla::ErrorResult& aError);
-  already_AddRefed<nsICSSDeclaration>
-    GetComputedStyle(mozilla::dom::Element& aElt, const nsAString& aPseudoElt,
-                     mozilla::ErrorResult& aError);
-  already_AddRefed<nsIDOMMediaQueryList> MatchMedia(const nsAString& aQuery,
-                                                    mozilla::ErrorResult& aError);
-  nsScreen* GetScreen(mozilla::ErrorResult& aError);
-  void MoveTo(int32_t aXPos, int32_t aYPos, mozilla::ErrorResult& aError);
-  void MoveBy(int32_t aXDif, int32_t aYDif, mozilla::ErrorResult& aError);
-  void ResizeTo(int32_t aWidth, int32_t aHeight,
-                mozilla::ErrorResult& aError);
-  void ResizeBy(int32_t aWidthDif, int32_t aHeightDif,
-                mozilla::ErrorResult& aError);
-  int32_t GetInnerWidth(mozilla::ErrorResult& aError);
-  void SetInnerWidth(int32_t aInnerWidth, mozilla::ErrorResult& aError);
-  int32_t GetInnerHeight(mozilla::ErrorResult& aError);
-  void SetInnerHeight(int32_t aInnerHeight, mozilla::ErrorResult& aError);
-  int32_t GetScrollX(mozilla::ErrorResult& aError);
-  int32_t GetPageXOffset(mozilla::ErrorResult& aError)
-  {
-    return GetScrollX(aError);
-  }
-  int32_t GetScrollY(mozilla::ErrorResult& aError);
-  int32_t GetPageYOffset(mozilla::ErrorResult& aError)
-  {
-    return GetScrollY(aError);
-  }
-  int32_t GetScreenX(mozilla::ErrorResult& aError);
-  void SetScreenX(int32_t aScreenX, mozilla::ErrorResult& aError);
-  int32_t GetScreenY(mozilla::ErrorResult& aError);
-  void SetScreenY(int32_t aScreenY, mozilla::ErrorResult& aError);
-  int32_t GetOuterWidth(mozilla::ErrorResult& aError);
-  void SetOuterWidth(int32_t aOuterWidth, mozilla::ErrorResult& aError);
-  int32_t GetOuterHeight(mozilla::ErrorResult& aError);
-  void SetOuterHeight(int32_t aOuterHeight, mozilla::ErrorResult& aError);
-  int32_t RequestAnimationFrame(mozilla::dom::FrameRequestCallback& aCallback,
-                                mozilla::ErrorResult& aError);
-  void CancelAnimationFrame(int32_t aHandle, mozilla::ErrorResult& aError);
-  nsPerformance* GetPerformance(mozilla::ErrorResult& aError);
-#ifdef MOZ_WEBSPEECH
-  mozilla::dom::SpeechSynthesis*
-    GetSpeechSynthesis(mozilla::ErrorResult& aError);
-#endif
-  already_AddRefed<nsICSSDeclaration>
-    GetDefaultComputedStyle(mozilla::dom::Element& aElt,
-                            const nsAString& aPseudoElt,
-                            mozilla::ErrorResult& aError);
-  mozilla::dom::indexedDB::IDBFactory*
-    GetMozIndexedDB(mozilla::ErrorResult& aError)
-  {
-    return GetIndexedDB(aError);
-  }
-  int32_t MozRequestAnimationFrame(nsIFrameRequestCallback* aRequestCallback,
-                                   mozilla::ErrorResult& aError);
-  void MozCancelAnimationFrame(int32_t aHandle, mozilla::ErrorResult& aError)
-  {
-    return CancelAnimationFrame(aHandle, aError);
-  }
-  void MozCancelRequestAnimationFrame(int32_t aHandle,
-                                      mozilla::ErrorResult& aError)
-  {
-    return CancelAnimationFrame(aHandle, aError);
-  }
-  int64_t GetMozAnimationStartTime(mozilla::ErrorResult& aError);
-  void SizeToContent(mozilla::ErrorResult& aError);
-  nsIDOMCrypto* GetCrypto(mozilla::ErrorResult& aError);
-  nsIDOMPkcs11* GetPkcs11()
-  {
-    return nullptr;
-  }
-  nsIControllers* GetControllers(mozilla::ErrorResult& aError);
-  float GetMozInnerScreenX(mozilla::ErrorResult& aError);
-  float GetMozInnerScreenY(mozilla::ErrorResult& aError);
-  float GetDevicePixelRatio(mozilla::ErrorResult& aError);
-  int32_t GetScrollMaxX(mozilla::ErrorResult& aError);
-  int32_t GetScrollMaxY(mozilla::ErrorResult& aError);
-  bool GetFullScreen(mozilla::ErrorResult& aError);
-  void SetFullScreen(bool aFullScreen, mozilla::ErrorResult& aError);
-  void Back(mozilla::ErrorResult& aError);
-  void Forward(mozilla::ErrorResult& aError);
-  void Home(mozilla::ErrorResult& aError);
-  bool Find(const nsAString& aString, bool aCaseSensitive, bool aBackwards,
-            bool aWrapAround, bool aWholeWord, bool aSearchInFrames,
-            bool aShowDialog, mozilla::ErrorResult& aError);
-  uint64_t GetMozPaintCount(mozilla::ErrorResult& aError);
-  already_AddRefed<nsIDOMWindow> OpenDialog(JSContext* aCx,
-                                            const nsAString& aUrl,
-                                            const nsAString& aName,
-                                            const nsAString& aOptions,
-                                            const mozilla::dom::Sequence<JS::Value>& aExtraArgument,
-                                            mozilla::ErrorResult& aError);
-  JSObject* GetContent(JSContext* aCx, mozilla::ErrorResult& aError);
+  mozilla::dom::BarProp* GetScrollbars();
 
 protected:
   // Array of idle observers that are notified of idle events.
   nsTObserverArray<IdleObserverHolder> mIdleObservers;
 
   // Idle timer used for function callbacks to notify idle observers.
   nsCOMPtr<nsITimer> mIdleTimer;
 
@@ -1080,31 +912,17 @@ protected:
                                     nsIDOMWindow **aReturn);
 
   // Timeout Functions
   // Language agnostic timeout function (all args passed).
   // |interval| is in milliseconds.
   nsresult SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
                                 int32_t interval,
                                 bool aIsInterval, int32_t *aReturn);
-  int32_t SetTimeoutOrInterval(mozilla::dom::Function& aFunction,
-                               int32_t aTimeout,
-                               const mozilla::dom::Sequence<JS::Value>& aArguments,
-                               bool aIsInterval, mozilla::ErrorResult& aError);
-  int32_t SetTimeoutOrInterval(JSContext* aCx, const nsAString& aHandler,
-                               int32_t aTimeout, bool aIsInterval,
-                               mozilla::ErrorResult& aError);
-  void ClearTimeoutOrInterval(int32_t aTimerID,
-                                  mozilla::ErrorResult& aError);
-  nsresult ClearTimeoutOrInterval(int32_t aTimerID)
-  {
-    mozilla::ErrorResult rv;
-    ClearTimeoutOrInterval(aTimerID, rv);
-    return rv.ErrorCode();
-  }
+  nsresult ClearTimeoutOrInterval(int32_t aTimerID);
 
   // JS specific timeout functions (JS args grabbed from context).
   nsresult SetTimeoutOrInterval(bool aIsInterval, int32_t* aReturn);
   nsresult ResetTimersForNonBackgroundWindow();
 
   // The timeout implementation functions.
   void RunTimeout(nsTimeout *aTimeout);
   void RunTimeout() { RunTimeout(nullptr); }
@@ -1162,27 +980,25 @@ protected:
   static void MakeScriptDialogTitle(nsAString &aOutTitle);
 
   bool CanMoveResizeWindows();
 
   bool     GetBlurSuppression();
 
   // If aDoFlush is true, we'll flush our own layout; otherwise we'll try to
   // just flush our parent and only flush ourselves if we think we need to.
-  mozilla::CSSIntPoint GetScrollXY(bool aDoFlush, mozilla::ErrorResult& aError);
-  nsresult GetScrollXY(int32_t* aScrollX, int32_t* aScrollY, bool aDoFlush);
-  void GetScrollMaxXY(int32_t* aScrollMaxX, int32_t* aScrollMaxY,
-                      mozilla::ErrorResult& aError);
+  nsresult GetScrollXY(int32_t* aScrollX, int32_t* aScrollY,
+                       bool aDoFlush);
+  nsresult GetScrollMaxXY(int32_t* aScrollMaxX, int32_t* aScrollMaxY);
 
   // Outer windows only.
   nsresult GetInnerSize(mozilla::CSSIntSize& aSize);
 
-  nsIntSize GetOuterSize(mozilla::ErrorResult& aError);
-  void SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth,
-                    mozilla::ErrorResult& aError);
+  nsresult GetOuterSize(nsIntSize* aSizeCSSPixels);
+  nsresult SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth);
   nsRect GetInnerScreenRect();
 
   void ScrollTo(const mozilla::CSSIntPoint& aScroll);
 
   bool IsFrame()
   {
     return GetParentInternal() != nullptr;
   }
@@ -1258,49 +1074,25 @@ protected:
 
   // Implements Get{Real,Scriptable}Top.
   nsresult GetTopImpl(nsIDOMWindow **aWindow, bool aScriptable);
 
   // Outer windows only.
   nsDOMWindowList* GetWindowList();
 
   // Helper for getComputedStyle and getDefaultComputedStyle
-  already_AddRefed<nsICSSDeclaration>
-    GetComputedStyleHelper(mozilla::dom::Element& aElt,
-                           const nsAString& aPseudoElt,
-                           bool aDefaultStylesOnly,
-                           mozilla::ErrorResult& aError);
   nsresult GetComputedStyleHelper(nsIDOMElement* aElt,
                                   const nsAString& aPseudoElt,
                                   bool aDefaultStylesOnly,
                                   nsIDOMCSSStyleDeclaration** aReturn);
 
   void PreloadLocalStorage();
 
-  // Returns device pixels.
-  nsIntPoint GetScreenXY(mozilla::ErrorResult& aError);
-
-  int32_t RequestAnimationFrame(const nsIDocument::FrameRequestCallbackHolder& aCallback,
-                                mozilla::ErrorResult& aError);
-
-  nsGlobalWindow* InnerForSetTimeoutOrInterval(mozilla::ErrorResult& aError);
-
-  mozilla::dom::Element* GetRealFrameElement(mozilla::ErrorResult& aError);
-
-  void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
-                      const nsAString& aTargetOrigin,
-                      JS::Handle<JS::Value> aTransfer,
-                      mozilla::ErrorResult& aError);
-
-  already_AddRefed<nsIVariant>
-    ShowModalDialog(const nsAString& aUrl, nsIVariant* aArgument,
-                    const nsAString& aOptions, mozilla::ErrorResult& aError);
-
-  already_AddRefed<nsIDOMWindow>
-    GetContentInternal(mozilla::ErrorResult& aError);
+  nsresult RequestAnimationFrame(const nsIDocument::FrameRequestCallbackHolder& aCallback,
+                                 int32_t* aHandle);
 
   // When adding new member variables, be careful not to create cycles
   // through JavaScript.  If there is any chance that a member variable
   // could own objects that are implemented in JavaScript, then those
   // objects will keep the global object (this object) alive.  To prevent
   // these cycles, ownership of such members must be released in
   // |CleanUp| and |DetachFromDocShell|.
 
@@ -1381,17 +1173,17 @@ protected:
   nsCOMPtr<nsIControllers>      mControllers;
 
   // For |window.arguments|, via |openDialog|.
   nsCOMPtr<nsIArray>            mArguments;
 
   // For |window.dialogArguments|, via |showModalDialog|.
   nsRefPtr<DialogValueHolder> mDialogArguments;
 
-  nsRefPtr<mozilla::dom::Navigator> mNavigator;
+  nsRefPtr<Navigator>           mNavigator;
   nsRefPtr<nsScreen>            mScreen;
   nsRefPtr<nsDOMWindowList>     mFrames;
   nsRefPtr<mozilla::dom::BarProp> mMenubar;
   nsRefPtr<mozilla::dom::BarProp> mToolbar;
   nsRefPtr<mozilla::dom::BarProp> mLocationbar;
   nsRefPtr<mozilla::dom::BarProp> mPersonalbar;
   nsRefPtr<mozilla::dom::BarProp> mStatusbar;
   nsRefPtr<mozilla::dom::BarProp> mScrollbars;
@@ -1487,28 +1279,16 @@ protected:
   friend class nsDOMWindowUtils;
   friend class PostMessageEvent;
   friend class DesktopNotification;
 
   static WindowByIdTable* sWindowsById;
   static bool sWarnedAboutWindowInternal;
 };
 
-inline nsISupports*
-ToSupports(nsGlobalWindow *p)
-{
-    return static_cast<nsIDOMEventTarget*>(p);
-}
-
-inline nsISupports*
-ToCanonicalSupports(nsGlobalWindow *p)
-{
-    return static_cast<nsIDOMEventTarget*>(p);
-}
-
 /*
  * nsGlobalChromeWindow inherits from nsGlobalWindow. It is the global
  * object created for a Chrome Window only.
  */
 class nsGlobalChromeWindow : public nsGlobalWindow,
                              public nsIDOMChromeWindow
 {
 public:
--- a/dom/base/nsJSTimeoutHandler.cpp
+++ b/dom/base/nsJSTimeoutHandler.cpp
@@ -17,35 +17,27 @@
 #include "mozilla/Likely.h"
 #include <algorithm>
 #include "mozilla/dom/FunctionBinding.h"
 #include "nsAXPCNativeCallContext.h"
 
 static const char kSetIntervalStr[] = "setInterval";
 static const char kSetTimeoutStr[] = "setTimeout";
 
-using namespace mozilla;
 using namespace mozilla::dom;
 
 // Our JS nsIScriptTimeoutHandler implementation.
 class nsJSScriptTimeoutHandler MOZ_FINAL : public nsIScriptTimeoutHandler
 {
 public:
   // nsISupports
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsJSScriptTimeoutHandler)
 
   nsJSScriptTimeoutHandler();
-  // This will call SwapElements on aArguments with an empty array.
-  nsJSScriptTimeoutHandler(nsGlobalWindow *aWindow, Function& aFunction,
-                           FallibleTArray<JS::Heap<JS::Value> >& aArguments,
-                           ErrorResult& aError);
-  nsJSScriptTimeoutHandler(JSContext* aCx, nsGlobalWindow *aWindow,
-                           const nsAString& aExpression, bool* aAllowEval,
-                           ErrorResult& aError);
   ~nsJSScriptTimeoutHandler();
 
   virtual const PRUnichar *GetHandlerText();
   virtual Function* GetCallback()
   {
     return mFunction;
   }
   virtual void GetLocation(const char **aFileName, uint32_t *aLineNo)
@@ -55,211 +47,119 @@ public:
   }
 
   virtual const nsTArray<JS::Value>& GetArgs()
   {
     return mArgs;
   }
 
   nsresult Init(nsGlobalWindow *aWindow, bool *aIsInterval,
-                int32_t *aInterval, bool* aAllowEval);
+                int32_t *aInterval);
 
   void ReleaseJSObjects();
 
 private:
   // filename, line number and JS language version string of the
   // caller of setTimeout()
   nsCString mFileName;
   uint32_t mLineNo;
   nsTArray<JS::Heap<JS::Value> > mArgs;
 
-  // The expression to evaluate or function to call. If mFunction is non-null
-  // it should be used, else use mExpr.
-  nsString mExpr;
+  // The JS expression to evaluate or function to call, if !mExpr
+  // Note this is always a flat string.
+  JS::Heap<JSString*> mExpr;
   nsRefPtr<Function> mFunction;
 };
 
 
 // nsJSScriptTimeoutHandler
 // QueryInterface implementation for nsJSScriptTimeoutHandler
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsJSScriptTimeoutHandler)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSScriptTimeoutHandler)
   tmp->ReleaseJSObjects();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsJSScriptTimeoutHandler)
   if (MOZ_UNLIKELY(cb.WantDebugInfo())) {
     nsAutoCString name("nsJSScriptTimeoutHandler");
-    if (tmp->mFunction) {
+    if (tmp->mExpr) {
+      name.AppendLiteral(" [");
+      name.Append(tmp->mFileName);
+      name.AppendLiteral(":");
+      name.AppendInt(tmp->mLineNo);
+      name.AppendLiteral("]");
+    }
+    else if (tmp->mFunction) {
       JSFunction* fun =
         JS_GetObjectFunction(js::UncheckedUnwrap(tmp->mFunction->Callable()));
       if (fun && JS_GetFunctionId(fun)) {
         JSFlatString *funId = JS_ASSERT_STRING_IS_FLAT(JS_GetFunctionId(fun));
         size_t size = 1 + JS_PutEscapedFlatString(NULL, 0, funId, 0);
         char *funIdName = new char[size];
         if (funIdName) {
           JS_PutEscapedFlatString(funIdName, size, funId, 0);
           name.AppendLiteral(" [");
           name.Append(funIdName);
           delete[] funIdName;
           name.AppendLiteral("]");
         }
       }
-    } else {
-      name.AppendLiteral(" [");
-      name.Append(tmp->mFileName);
-      name.AppendLiteral(":");
-      name.AppendInt(tmp->mLineNo);
-      name.AppendLiteral("]");
     }
     cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name.get());
   }
   else {
     NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsJSScriptTimeoutHandler,
                                       tmp->mRefCnt.get())
   }
 
-  if (tmp->mFunction) {
-    NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFunction)
-    NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
-  }
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFunction)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSScriptTimeoutHandler)
+  NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mExpr)
   for (uint32_t i = 0; i < tmp->mArgs.Length(); ++i) {
     NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mArgs[i])
   }
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsJSScriptTimeoutHandler)
   NS_INTERFACE_MAP_ENTRY(nsIScriptTimeoutHandler)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsJSScriptTimeoutHandler)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsJSScriptTimeoutHandler)
 
-static bool
-CheckCSPForEval(JSContext* aCx, nsGlobalWindow* aWindow, ErrorResult& aError)
+nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler() :
+  mLineNo(0),
+  mExpr(nullptr)
 {
-  // if CSP is enabled, and setTimeout/setInterval was called with a string,
-  // disable the registration and log an error
-  nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
-  if (!doc) {
-    // if there's no document, we don't have to do anything.
-    return true;
-  }
-
-  nsCOMPtr<nsIContentSecurityPolicy> csp;
-  aError = doc->NodePrincipal()->GetCsp(getter_AddRefs(csp));
-  if (aError.Failed()) {
-    return false;
-  }
-
-  if (!csp) {
-    return true;
-  }
-
-  bool allowsEval = true;
-  bool reportViolation = false;
-  aError = csp->GetAllowsEval(&reportViolation, &allowsEval);
-  if (aError.Failed()) {
-    return false;
-  }
-
-  if (reportViolation) {
-    // TODO : need actual script sample in violation report.
-    NS_NAMED_LITERAL_STRING(scriptSample,
-                            "call to eval() or related function blocked by CSP");
-
-    // Get the calling location.
-    uint32_t lineNum = 0;
-    const char *fileName;
-    nsAutoString fileNameString;
-    if (nsJSUtils::GetCallingLocation(aCx, &fileName, &lineNum)) {
-      AppendUTF8toUTF16(fileName, fileNameString);
-    } else {
-      fileNameString.AssignLiteral("unknown");
-    }
-
-    csp->LogViolationDetails(nsIContentSecurityPolicy::VIOLATION_TYPE_EVAL,
-                             fileNameString, scriptSample, lineNum);
-  }
-
-  return allowsEval;
-}
-
-nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler() :
-  mLineNo(0)
-{
-}
-
-nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler(nsGlobalWindow *aWindow,
-                                                   Function& aFunction,
-                                                   FallibleTArray<JS::Heap<JS::Value> >& aArguments,
-                                                   ErrorResult& aError) :
-  mLineNo(0),
-  mFunction(&aFunction)
-{
-  if (!aWindow->GetContextInternal() || !aWindow->FastGetGlobalJSObject()) {
-    // This window was already closed, or never properly initialized,
-    // don't let a timer be scheduled on such a window.
-    aError.Throw(NS_ERROR_NOT_INITIALIZED);
-    return;
-  }
-
-  mozilla::HoldJSObjects(this);
-  mArgs.SwapElements(aArguments);
-}
-
-nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler(JSContext* aCx,
-                                                   nsGlobalWindow *aWindow,
-                                                   const nsAString& aExpression,
-                                                   bool* aAllowEval,
-                                                   ErrorResult& aError) :
-  mLineNo(0),
-  mExpr(aExpression)
-{
-  if (!aWindow->GetContextInternal() || !aWindow->FastGetGlobalJSObject()) {
-    // This window was already closed, or never properly initialized,
-    // don't let a timer be scheduled on such a window.
-    aError.Throw(NS_ERROR_NOT_INITIALIZED);
-    return;
-  }
-
-  *aAllowEval = CheckCSPForEval(aCx, aWindow, aError);
-  if (aError.Failed() || !*aAllowEval) {
-    return;
-  }
-
-  // Get the calling location.
-  const char *filename;
-  if (nsJSUtils::GetCallingLocation(aCx, &filename, &mLineNo)) {
-    mFileName.Assign(filename);
-  }
 }
 
 nsJSScriptTimeoutHandler::~nsJSScriptTimeoutHandler()
 {
   ReleaseJSObjects();
 }
 
 void
 nsJSScriptTimeoutHandler::ReleaseJSObjects()
 {
-  if (mFunction) {
+  if (mExpr) {
+    mExpr = nullptr;
+  } else {
     mFunction = nullptr;
     mArgs.Clear();
-    mozilla::DropJSObjects(this);
   }
+  mozilla::DropJSObjects(this);
 }
 
 nsresult
 nsJSScriptTimeoutHandler::Init(nsGlobalWindow *aWindow, bool *aIsInterval,
-                               int32_t *aInterval, bool *aAllowEval)
+                               int32_t *aInterval)
 {
   if (!aWindow->GetContextInternal() || !aWindow->FastGetGlobalJSObject()) {
     // This window was already closed, or never properly initialized,
     // don't let a timer be scheduled on such a window.
 
     return NS_ERROR_NOT_INITIALIZED;
   }
 
@@ -333,35 +233,68 @@ nsJSScriptTimeoutHandler::Init(nsGlobalW
     ::JS_ReportError(cx, "useless %s call (missing quotes around argument?)",
                      *aIsInterval ? kSetIntervalStr : kSetTimeoutStr);
 
     // Return an error that nsGlobalWindow can recognize and turn into NS_OK.
     return NS_ERROR_DOM_TYPE_ERR;
   }
 
   if (expr) {
-    // if CSP is enabled, and setTimeout/setInterval was called with a string,
-    // disable the registration and log an error
-    ErrorResult error;
-    *aAllowEval = CheckCSPForEval(cx, aWindow, error);
-    if (error.Failed() || !*aAllowEval) {
-      return error.ErrorCode();
-    }
+    // if CSP is enabled, and setTimeout/setInterval was called with a string
+    // or object, disable the registration and log an error
+    nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
+
+    if (doc) {
+      nsCOMPtr<nsIContentSecurityPolicy> csp;
+      nsresult rv = doc->NodePrincipal()->GetCsp(getter_AddRefs(csp));
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      if (csp) {
+        bool allowsEval = true;
+        bool reportViolation = false;
+        rv = csp->GetAllowsEval(&reportViolation, &allowsEval);
+        NS_ENSURE_SUCCESS(rv, rv);
+
+        if (reportViolation) {
+          // TODO : need actual script sample in violation report.
+          NS_NAMED_LITERAL_STRING(scriptSample, "call to eval() or related function blocked by CSP");
 
-    mExpr.Append(JS_GetFlatStringChars(expr),
-                 JS_GetStringLength(JS_FORGET_STRING_FLATNESS(expr)));
+          // Get the calling location.
+          uint32_t lineNum = 0;
+          const char *fileName;
+          nsAutoCString aFileName;
+          if (nsJSUtils::GetCallingLocation(cx, &fileName, &lineNum)) {
+            aFileName.Assign(fileName);
+          } else {
+            aFileName.Assign("unknown");
+          }
+
+          csp->LogViolationDetails(nsIContentSecurityPolicy::VIOLATION_TYPE_EVAL,
+                                   NS_ConvertUTF8toUTF16(aFileName),
+                                   scriptSample,
+                                   lineNum);
+        }
+
+        if (!allowsEval) {
+          // Note: Our only caller knows to turn NS_ERROR_DOM_TYPE_ERR into NS_OK.
+          return NS_ERROR_DOM_TYPE_ERR;
+        }
+      }
+    } // if there's no document, we don't have to do anything.
+
+    mozilla::HoldJSObjects(this);
+
+    mExpr = JS_FORGET_STRING_FLATNESS(expr);
 
     // Get the calling location.
     const char *filename;
     if (nsJSUtils::GetCallingLocation(cx, &filename, &mLineNo)) {
       mFileName.Assign(filename);
     }
   } else if (funobj) {
-    *aAllowEval = true;
-
     mozilla::HoldJSObjects(this);
 
     mFunction = new Function(funobj);
 
     // Create our arg array.  argc is the number of arguments passed
     // to setTimeout or setInterval; the first two are our callback
     // and the delay, so only arguments after that need to go in our
     // array.
@@ -382,60 +315,28 @@ nsJSScriptTimeoutHandler::Init(nsGlobalW
   }
   *aInterval = interval;
   return NS_OK;
 }
 
 const PRUnichar *
 nsJSScriptTimeoutHandler::GetHandlerText()
 {
-  NS_ASSERTION(!mFunction, "No expression, so no handler text!");
-  return mExpr.get();
+  NS_ASSERTION(mExpr, "No expression, so no handler text!");
+  return ::JS_GetFlatStringChars(JS_ASSERT_STRING_IS_FLAT(mExpr));
 }
 
 nsresult NS_CreateJSTimeoutHandler(nsGlobalWindow *aWindow,
                                    bool *aIsInterval,
                                    int32_t *aInterval,
                                    nsIScriptTimeoutHandler **aRet)
 {
   *aRet = nullptr;
   nsRefPtr<nsJSScriptTimeoutHandler> handler = new nsJSScriptTimeoutHandler();
-  bool allowEval;
-  nsresult rv = handler->Init(aWindow, aIsInterval, aInterval, &allowEval);
-  if (NS_FAILED(rv) || !allowEval) {
+  nsresult rv = handler->Init(aWindow, aIsInterval, aInterval);
+  if (NS_FAILED(rv)) {
     return rv;
   }
 
   handler.forget(aRet);
 
   return NS_OK;
 }
-
-already_AddRefed<nsIScriptTimeoutHandler>
-NS_CreateJSTimeoutHandler(nsGlobalWindow *aWindow, Function& aFunction,
-                          const Sequence<JS::Value>& aArguments,
-                          ErrorResult& aError)
-{
-  FallibleTArray<JS::Heap<JS::Value> > args;
-  if (!args.AppendElements(aArguments)) {
-    aError.Throw(NS_ERROR_OUT_OF_MEMORY);
-    return 0;
-  }
-
-  nsRefPtr<nsJSScriptTimeoutHandler> handler =
-    new nsJSScriptTimeoutHandler(aWindow, aFunction, args, aError);
-  return aError.Failed() ? nullptr : handler.forget();
-}
-
-already_AddRefed<nsIScriptTimeoutHandler>
-NS_CreateJSTimeoutHandler(JSContext* aCx, nsGlobalWindow *aWindow,
-                          const nsAString& aExpression, ErrorResult& aError)
-{
-  ErrorResult rv;
-  bool allowEval = false;
-  nsRefPtr<nsJSScriptTimeoutHandler> handler =
-    new nsJSScriptTimeoutHandler(aCx, aWindow, aExpression, &allowEval, rv);
-  if (rv.Failed() || !allowEval) {
-    return nullptr;
-  }
-
-  return handler.forget();
-}
--- a/dom/bindings/BindingDeclarations.h
+++ b/dom/bindings/BindingDeclarations.h
@@ -446,20 +446,17 @@ public:
 
 inline nsWrapperCache*
 GetWrapperCache(nsWrapperCache* cache)
 {
   return cache;
 }
 
 inline nsWrapperCache*
-GetWrapperCache(nsGlobalWindow*)
-{
-  return nullptr;
-}
+GetWrapperCache(nsGlobalWindow* not_allowed);
 
 inline nsWrapperCache*
 GetWrapperCache(void* p)
 {
   return NULL;
 }
 
 // Helper template for smart pointers to resolve ambiguity between
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1412,26 +1412,16 @@ DOMInterfaces = {
     'headerFile': 'WebSocket.h',
 },
 
 'WheelEvent': {
     'headerFile': 'DOMWheelEvent.h',
     'nativeType': 'mozilla::dom::DOMWheelEvent',
 },
 
-'Window': {
-    'nativeType': 'nsGlobalWindow',
-    'hasXPConnectImpls': True,
-    'register': False,
-    'implicitJSContext': [ 'setInterval', 'setTimeout' ],
-    'binaryNames': {
-        'postMessage': 'postMessageMoz',
-    },
-},
-
 'WindowProxy': [
 {
     'nativeType': 'nsIDOMWindow',
     'concrete': False
 },
 {
     # We need a worker descriptor for WindowProxy because EventTarget exists in
     # workers.  But it's an external interface, so it'll just map to JSObject*.
@@ -1442,28 +1432,22 @@ DOMInterfaces = {
     'headerFile': 'mozilla/dom/workers/bindings/Location.h',
     'workers': True,
 },
 
 'WorkerMessagePort': [{
     'nativeType': 'mozilla::dom::workers::MessagePort',
     'headerFile': 'mozilla/dom/workers/bindings/MessagePort.h',
     'implicitJSContext': [ 'postMessage' ],
-    'binaryNames': {
-        'postMessage': 'postMessageMoz',
-    },
 },
 {
     'nativeType': 'mozilla::dom::workers::WorkerMessagePort',
     'headerFile': 'mozilla/dom/workers/bindings/WorkerMessagePort.h',
     'workers': True,
     'nativeOwnership': 'worker',
-    'binaryNames': {
-        'postMessage': 'postMessageMoz',
-    },
 }],
 
 'WorkerNavigator': {
     'headerFile': 'mozilla/dom/workers/bindings/Navigator.h',
     'workers': True,
 },
 
 'XMLHttpRequest': [
@@ -1807,79 +1791,73 @@ def addExternalIface(iface, nativeType=N
     }
     if not nativeType is None:
         domInterface['nativeType'] = nativeType
     if not headerFile is None:
         domInterface['headerFile'] = headerFile
     domInterface['notflattened'] = notflattened
     DOMInterfaces[iface] = domInterface
 
-addExternalIface('ApplicationCache', nativeType='nsIDOMOfflineResourceList')
 addExternalIface('ActivityOptions', nativeType='nsIDOMMozActivityOptions',
                  headerFile='nsIDOMActivityOptions.h')
 addExternalIface('Counter')
 addExternalIface('CSSRule')
 addExternalIface('DeviceAcceleration', headerFile='nsIDOMDeviceMotionEvent.h', notflattened=True)
 addExternalIface('DeviceRotationRate', headerFile='nsIDOMDeviceMotionEvent.h', notflattened=True)
 addExternalIface('mozIDOMApplication', nativeType='mozIDOMApplication', headerFile='nsIDOMApplicationRegistry.h')
 addExternalIface('CSSRuleList')
 addExternalIface('DOMStringList')
 addExternalIface('RTCDataChannel', nativeType='nsIDOMDataChannel')
 addExternalIface('File')
 addExternalIface('HitRegionOptions', nativeType='nsISupports')
 addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
 addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
 addExternalIface('LockedFile')
 addExternalIface('MediaList')
-addExternalIface('MediaQueryList')
 addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
 addExternalIface('MozBoxObject', nativeType='nsIBoxObject')
 addExternalIface('MozConnection', headerFile='nsIDOMConnection.h')
 addExternalIface('MozControllers', nativeType='nsIControllers')
 addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True)
-addExternalIface('MozFrameRequestCallback', nativeType='nsIFrameRequestCallback',
-                 notflattened=True);
 addExternalIface('MozIccManager', headerFile='nsIDOMIccManager.h')
 addExternalIface('MozMobileConnection', headerFile='nsIDOMMobileConnection.h')
 addExternalIface('MozMobileMessageManager', headerFile='nsIDOMMobileMessageManager.h')
 addExternalIface('MozObserver', nativeType='nsIObserver', notflattened=True)
 addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSource',
                  notflattened=True)
 addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=True)
 addExternalIface('MozTreeBoxObject', nativeType='nsITreeBoxObject',
                  notflattened=True)
 addExternalIface('MozTreeColumn', nativeType='nsITreeColumn',
                  headerFile='nsITreeColumns.h')
 addExternalIface('MozVoicemailStatus')
 addExternalIface('MozWakeLock', headerFile='nsIDOMWakeLock.h')
 addExternalIface('MozWakeLockListener', headerFile='nsIDOMWakeLockListener.h')
 addExternalIface('MozXULTemplateBuilder', nativeType='nsIXULTemplateBuilder')
 addExternalIface('nsIControllers', nativeType='nsIControllers')
-addExternalIface('nsIDOMCrypto', nativeType='nsIDOMCrypto',
-                 headerFile='Crypto.h')
 addExternalIface('nsIInputStreamCallback', nativeType='nsIInputStreamCallback',
                  headerFile='nsIAsyncInputStream.h')
 addExternalIface('nsIStreamListener', nativeType='nsIStreamListener', notflattened=True)
 addExternalIface('nsISupports', nativeType='nsISupports')
 addExternalIface('nsIEditor', nativeType='nsIEditor', notflattened=True)
 addExternalIface('nsIVariant', nativeType='nsIVariant', notflattened=True)
 addExternalIface('OutputStream', nativeType='nsIOutputStream',
                  notflattened=True)
-addExternalIface('Pkcs11')
 addExternalIface('Principal', nativeType='nsIPrincipal',
                  headerFile='nsIPrincipal.h', notflattened=True)
 addExternalIface('Selection', nativeType='nsISelection')
 addExternalIface('StackFrame', nativeType='nsIStackFrame',
                  headerFile='nsIException.h', notflattened=True)
 addExternalIface('StyleSheetList')
 addExternalIface('SVGLength')
 addExternalIface('SVGNumber')
 addExternalIface('URI', nativeType='nsIURI', headerFile='nsIURI.h',
                  notflattened=True)
 addExternalIface('UserDataHandler')
+addExternalIface('Window')
 addExternalIface('XPathResult', nativeType='nsISupports')
 addExternalIface('XPathExpression')
 addExternalIface('XPathNSResolver')
 addExternalIface('XULCommandDispatcher')
 addExternalIface('DataTransfer', notflattened=True)
 addExternalIface('GetCameraCallback', nativeType='nsICameraGetCameraCallback', headerFile='nsIDOMCameraManager.h')
 addExternalIface('CameraErrorCallback', nativeType='nsICameraErrorCallback', headerFile='nsIDOMCameraManager.h')
 addExternalIface('CameraCapabilities', nativeType='nsICameraCapabilities', headerFile='nsIDOMCameraManager.h')
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -166,16 +166,18 @@ def DOMClass(descriptor):
 
 class CGDOMJSClass(CGThing):
     """
     Generate a DOMJSClass for a given descriptor
     """
     def __init__(self, descriptor):
         CGThing.__init__(self)
         self.descriptor = descriptor
+        # Our current reserved slot situation is unsafe for globals. Fix bug 760095!
+        assert "Window" not in descriptor.interface.identifier.name
     def declare(self):
         return ""
     def define(self):
         traceHook = TRACE_HOOK_NAME if self.descriptor.customTrace else 'nullptr'
         callHook = LEGACYCALLER_HOOK_NAME if self.descriptor.operations["LegacyCaller"] else 'nullptr'
         classFlags = "JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(3)"
         if self.descriptor.interface.getExtendedAttribute("NeedNewResolve"):
             newResolveHook = "(JSResolveOp)" + NEWRESOLVE_HOOK_NAME
@@ -2147,21 +2149,16 @@ def CreateBindingJSObject(descriptor, pr
     else:
         create = """  obj = JS_NewObject(aCx, &Class.mBase, proto, %s);
   if (!obj) {
     return nullptr;
   }
 
   js::SetReservedSlot(obj, DOM_OBJECT_SLOT, PRIVATE_TO_JSVAL(aObject));
 """
-        if "Window" in descriptor.interface.identifier.name:
-            create = """  MOZ_ASSERT(false,
-             "Our current reserved slot situation is unsafe for globals. Fix "
-             "bug 760095!");
-""" + create
     create = objDecl + create
 
     if descriptor.nativeOwnership == 'refcounted':
         create += """  NS_ADDREF(aObject);
 """
     else:
         create += """  // Make sure the native objects inherit from NonRefcountedDOMObject so that we
   // log their ctor and dtor.
--- a/dom/bindings/DOMJSProxyHandler.cpp
+++ b/dom/bindings/DOMJSProxyHandler.cpp
@@ -8,16 +8,17 @@
 
 #include "mozilla/dom/DOMJSProxyHandler.h"
 #include "xpcpublic.h"
 #include "xpcprivate.h"
 #include "XPCQuickStubs.h"
 #include "XPCWrapper.h"
 #include "WrapperFactory.h"
 #include "nsDOMClassInfo.h"
+#include "nsGlobalWindow.h"
 #include "nsWrapperCacheInlines.h"
 #include "mozilla/dom/BindingUtils.h"
 
 #include "jsapi.h"
 
 using namespace JS;
 
 namespace mozilla {
--- a/dom/gamepad/GamepadService.cpp
+++ b/dom/gamepad/GamepadService.cpp
@@ -447,17 +447,17 @@ GamepadService::SetWindowHasSeenGamepad(
 {
   if (mListeners.IndexOf(aWindow) == NoIndex) {
     // This window isn't even listening for gamepad events.
     return;
   }
 
   if (aHasSeen) {
     aWindow->SetHasSeenGamepadInput(true);
-    nsCOMPtr<nsISupports> window = ToSupports(aWindow);
+    nsCOMPtr<nsISupports> window = nsGlobalWindow::ToSupports(aWindow);
     nsRefPtr<Gamepad> gamepad = mGamepads[aIndex]->Clone(window);
     aWindow->AddGamepad(aIndex, gamepad);
   } else {
     aWindow->RemoveGamepad(aIndex);
   }
 }
 
 // static
--- a/dom/imptests/failures/html/html/browsers/the-window-object/test_window-properties.html.json
+++ b/dom/imptests/failures/html/html/browsers/the-window-object/test_window-properties.html.json
@@ -25,10 +25,18 @@
   "Window attribute: onclose": true,
   "Window attribute: oncuechange": true,
   "Window attribute: onmousewheel": true,
   "Window attribute: onstorage": true,
   "Window unforgeable attribute: window": true,
   "Window unforgeable attribute: document": true,
   "Window unforgeable attribute: location": true,
   "Window unforgeable attribute: top": true,
+  "Window replaceable attribute: locationbar": true,
+  "Window replaceable attribute: menubar": true,
+  "Window replaceable attribute: personalbar": true,
+  "Window replaceable attribute: scrollbars": true,
+  "Window replaceable attribute: statusbar": true,
+  "Window replaceable attribute: toolbar": true,
+  "Window replaceable attribute: frames": true,
+  "Window replaceable attribute: length": true,
   "constructor": true
 }
--- a/dom/imptests/failures/html/html/webappapis/atob/test_base64.html.json
+++ b/dom/imptests/failures/html/html/webappapis/atob/test_base64.html.json
@@ -1,2 +1,4 @@
 {
+  "btoa(null) == \"bnVsbA==\"": true,
+  "atob(null) == \"\u009e\u00e9e\"": true
 }
--- a/dom/tests/mochitest/bugs/grandchild_bug260264.html
+++ b/dom/tests/mochitest/bugs/grandchild_bug260264.html
@@ -4,15 +4,15 @@
     <script type="application/javascript" src="utils_bug260264.js"></script>
   </head>
   <body>
     <a id="nested link" href="javascript:(function(){})()">nested link</a>
     <script type="application/javascript">
       var event = location.hash.split("#").pop();
       send(document.getElementById("nested link"), event, function() {
         var popup = window.open("http://example.com"),
-            grandparent = window.open("", "parent260264");
+            grandparent = window.open(null, "parent260264");
         try { grandparent.report(popup) }
         finally { popup && popup.close() }
       });
     </script>
   </body>
 </html>
--- a/dom/webidl/CanvasRenderingContext2D.webidl
+++ b/dom/webidl/CanvasRenderingContext2D.webidl
@@ -7,16 +7,17 @@
  * http://www.whatwg.org/specs/web-apps/current-work/
  *
  * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
  * Opera Software ASA. You are granted a license to use, reproduce
  * and create derivative works of this document.
  */
 
 interface HitRegionOptions;
+interface Window;
 
 enum CanvasWindingRule { "nonzero", "evenodd" };
 
 interface CanvasRenderingContext2D {
 
   // back-reference to the canvas.  Might be null if we're not
   // associated with a canvas.
   readonly attribute HTMLCanvasElement? canvas;
--- a/dom/webidl/DOMRequest.webidl
+++ b/dom/webidl/DOMRequest.webidl
@@ -1,13 +1,14 @@
 /* -*- 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 Window;
 interface nsISupports;
 
 enum DOMRequestReadyState { "pending", "done" };
 
 interface DOMRequest : EventTarget {
   readonly attribute DOMRequestReadyState readyState;
 
   readonly attribute any result;
--- a/dom/webidl/DummyBinding.webidl
+++ b/dom/webidl/DummyBinding.webidl
@@ -2,16 +2,17 @@
 /* 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/.
  */
 
 // Dummy bindings that we need to force generation of things that
 // aren't actually referenced anywhere in IDL yet but are used in C++.
 
+[Global]
 interface DummyInterface : EventTarget {
   readonly attribute OnErrorEventHandlerNonNull onErrorEventHandler;
   FilePropertyBag fileBag();
   InspectorRGBTriple rgbTriple();
   Function getFunction();
   void funcSocketsDict(optional SocketsDict arg);
   void funcHttpConnDict(optional HttpConnDict arg);
   void funcWebSocketDict(optional WebSocketDict arg);
--- a/dom/webidl/EventHandler.webidl
+++ b/dom/webidl/EventHandler.webidl
@@ -117,12 +117,12 @@ interface WindowEventHandlers {
 // whether an ErrorEvent was fired. We don't do that, and until we do we'll
 // need to distinguish between onerror on Window or on nodes.
 
 [NoInterfaceObject]
 interface OnErrorEventHandlerForNodes {
            attribute EventHandler onerror;
 };
 
-[NoInterfaceObject]
-interface OnErrorEventHandlerForWindow {
-           attribute OnErrorEventHandler onerror;
-};
+//[NoInterfaceObject]
+//interface OnErrorEventHandlerForWindow {
+//           attribute OnErrorEventHandler onerror;
+//};
deleted file mode 100644
--- a/dom/webidl/IDBEnvironment.webidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/* -*- 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/.
- *
- * The origin of this IDL file is:
- * https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html
- */
-
-[NoInterfaceObject]
-interface IDBEnvironment {
-    //[Throws] readonly    attribute IDBFactory indexedDB;
-    [Throws] readonly    attribute IDBFactory? indexedDB;
-};
-
-// Mozilla-specific stuff
-partial interface IDBEnvironment {
-    [Throws] readonly    attribute IDBFactory? mozIndexedDB;
-};
--- a/dom/webidl/PeerConnectionImpl.webidl
+++ b/dom/webidl/PeerConnectionImpl.webidl
@@ -8,16 +8,17 @@
  * Do not confuse with mozRTCPeerConnection. This interface is purely for
  * communication between the PeerConnection JS DOM binding and the C++
  * implementation in SIPCC.
  *
  * See media/webrtc/signaling/include/PeerConnectionImpl.h
  *
  */
 
+interface Window;
 interface nsISupports;
 
 /* Must be created first. Observer events will be dispatched on the thread provided */
 [ChromeOnly, Constructor]
 interface PeerConnectionImpl  {
   /* Must be called first. Observer events dispatched on the thread provided */
   [Throws]
   void initialize(PeerConnectionObserver observer, Window window,
--- a/dom/webidl/PopupBlockedEvent.webidl
+++ b/dom/webidl/PopupBlockedEvent.webidl
@@ -1,13 +1,14 @@
 /* -*- 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 Window;
 interface URI;
 
 [Constructor(DOMString type, optional PopupBlockedEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
 interface PopupBlockedEvent : Event
 {
   readonly attribute Window? requestingWindow;
   readonly attribute URI? popupWindowURI;
   readonly attribute DOMString? popupWindowName;
--- a/dom/webidl/Window.webidl
+++ b/dom/webidl/Window.webidl
@@ -1,340 +1,12 @@
 /* -*- 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/.
  *
  * The origin of this IDL file is:
- * http://www.whatwg.org/specs/web-apps/current-work/
- * https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html
- * https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html
- * http://dev.w3.org/csswg/cssom/
- * http://dev.w3.org/csswg/cssom-view/
  * https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/RequestAnimationFrame/Overview.html
- * https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
- * https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html
- * http://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
  */
 
-interface ApplicationCache;
-interface MediaQueryList;
-interface MozFrameRequestCallback;
-interface nsIDOMCrypto;
-interface Pkcs11;
-typedef any Transferable;
-
-// http://www.whatwg.org/specs/web-apps/current-work/
-[Global]
-/*sealed*/ interface Window : EventTarget {
-  // the current browsing context
-  [Unforgeable, Throws] readonly attribute WindowProxy window;
-  [Replaceable, Throws] readonly attribute WindowProxy self;
-  [Unforgeable] readonly attribute Document? document;
-  [Throws] attribute DOMString name; 
-  [PutForwards=href, Unforgeable, Throws] 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] void close();
-  [Throws] readonly attribute boolean closed;
-  [Throws] void stop();
-  [Throws] void focus();
-  [Throws] void blur();
-
-  // other browsing contexts
-  [Replaceable, Throws] readonly attribute WindowProxy frames;
-  [Replaceable] readonly attribute unsigned long length;
-  [Unforgeable, Throws] readonly attribute WindowProxy top;
-  [Throws] attribute WindowProxy? opener;
-  //[Throws] readonly attribute WindowProxy parent;
-  [Replaceable, Throws] readonly attribute WindowProxy? parent;
-  [Throws] readonly attribute Element? frameElement;
-  //[Throws] WindowProxy open(optional DOMString url = "about:blank", optional DOMString target = "_blank", optional DOMString features = "", optional boolean replace = false);
-  [Throws] WindowProxy? open(optional DOMString url = "", optional DOMString target = "", 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; 
-  //(Not implemented)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] void postMessage(any message, DOMString targetOrigin, optional sequence<Transferable> transfer);
-
-  // also has obsolete members
-};
-Window implements GlobalEventHandlers;
-Window implements WindowEventHandlers;
-
-// http://www.whatwg.org/specs/web-apps/current-work/
-[NoInterfaceObject]
-interface WindowTimers {
-  [Throws] long setTimeout(Function handler, optional long timeout = 0, any... arguments);
-  [Throws] long setTimeout(DOMString handler, optional long timeout = 0);
-  [Throws] void clearTimeout(long handle);
-  [Throws] long setInterval(Function handler, optional long timeout, any... arguments);
-  [Throws] long setInterval(DOMString handler, optional long timeout);
-  [Throws] void clearInterval(long handle);
-};
-Window implements WindowTimers;
-
-// http://www.whatwg.org/specs/web-apps/current-work/
-[NoInterfaceObject]
-interface WindowBase64 {
-  [Throws] DOMString btoa(DOMString btoa);
-  [Throws] DOMString atob(DOMString atob);
-};
-Window implements WindowBase64;
-
-// http://www.whatwg.org/specs/web-apps/current-work/
-[NoInterfaceObject]
-interface WindowSessionStorage {
-  //[Throws] readonly attribute Storage sessionStorage;
-  [Throws] readonly attribute Storage? sessionStorage;
-};
-Window implements WindowSessionStorage;
-
-// http://www.whatwg.org/specs/web-apps/current-work/
-[NoInterfaceObject]
-interface WindowLocalStorage {
-  [Throws] readonly attribute Storage? localStorage;
-};
-Window implements WindowLocalStorage;
-
-// http://www.whatwg.org/specs/web-apps/current-work/
-partial interface Window {
-  void captureEvents(long dummy);
-  void releaseEvents(long dummy);
-};
-
-// https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html
-partial interface Window {
-  //[Throws] Selection getSelection();
-  [Throws] Selection? getSelection();
-};
-
-// https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html
-Window implements IDBEnvironment;
-
-// http://dev.w3.org/csswg/cssom/
-partial interface Window {
-  //[NewObject, Throws] CSSStyleDeclaration getComputedStyle(Element elt, optional DOMString pseudoElt = "");
-  [NewObject, Throws] CSSStyleDeclaration? getComputedStyle(Element elt, optional DOMString pseudoElt = "");
-};
-
-// http://dev.w3.org/csswg/cssom-view/
-enum ScrollBehavior { "auto", "instant", "smooth" };
-
-dictionary ScrollOptions {
-  ScrollBehavior behavior = "auto";
-};
-
-partial interface Window {
-  //[Throws] MediaQueryList matchMedia(DOMString query);
-  [Throws] MediaQueryList? matchMedia(DOMString query);
-  //[SameObject]
-  [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;
-};
-
-// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/RequestAnimationFrame/Overview.html
-partial interface Window {
-  [Throws] long requestAnimationFrame(FrameRequestCallback callback);
-  [Throws] void cancelAnimationFrame(long handle);
-};
 callback FrameRequestCallback = void (DOMHighResTimeStamp time);
 
-// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
-partial interface Window {
-  [Replaceable, Throws] readonly attribute Performance? performance;
-};
-
-// https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html
-partial interface Window {
-  //[Throws] readonly attribute Crypto crypto;
-  [Throws] readonly attribute nsIDOMCrypto crypto;
-};
-
-#ifdef MOZ_WEBSPEECH
-// http://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
-[NoInterfaceObject]
-interface SpeechSynthesisGetter {
-  [Throws, Pref="media.webspeech.synth.enabled"] readonly attribute SpeechSynthesis speechSynthesis;
-};
-
-Window implements SpeechSynthesisGetter;
-#endif
-
-// 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();
-
-  readonly attribute Pkcs11?                      pkcs11;
-
-  // XXX Shouldn't this be in nsIDOMChromeWindow?
-  [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] void             back();
-  [Throws] void             forward();
-  [Throws] 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 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;
-#endif
-
-  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] WindowProxy? openDialog(optional DOMString url = "",
-                                   optional DOMString name = "",
-                                   optional DOMString options = "",
-                                   any... extraArguments);
-
-  [Replaceable, Throws] readonly attribute object content;
-};
-
-Window implements TouchEventHandlers;
-
-Window implements OnErrorEventHandlerForWindow;
+//Window implements OnErrorEventHandlerForWindow;
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -8,17 +8,16 @@ MODULE = 'dom'
 
 GENERATED_WEBIDL_FILES = [
     'CSS2Properties.webidl',
 ]
 
 PREPROCESSED_WEBIDL_FILES = [
     'Crypto.webidl',
     'Navigator.webidl',
-    'Window.webidl',
 ]
 
 WEBIDL_FILES = [
     'AbstractWorker.webidl',
     'AnalyserNode.webidl',
     'AnimationEvent.webidl',
     'AppNotificationServiceOptions.webidl',
     'ArchiveReader.webidl',
@@ -177,17 +176,16 @@ WEBIDL_FILES = [
     'HTMLTextAreaElement.webidl',
     'HTMLTimeElement.webidl',
     'HTMLTitleElement.webidl',
     'HTMLTrackElement.webidl',
     'HTMLUListElement.webidl',
     'HTMLVideoElement.webidl',
     'IDBCursor.webidl',
     'IDBDatabase.webidl',
-    'IDBEnvironment.webidl',
     'IDBFactory.webidl',
     'IDBFileHandle.webidl',
     'IDBIndex.webidl',
     'IDBKeyRange.webidl',
     'IDBObjectStore.webidl',
     'IDBOpenDBRequest.webidl',
     'IDBRequest.webidl',
     'IDBTransaction.webidl',
@@ -408,16 +406,17 @@ WEBIDL_FILES = [
     'VTTCue.webidl',
     'VTTRegion.webidl',
     'VTTRegionList.webidl',
     'WaveShaperNode.webidl',
     'WebComponents.webidl',
     'WebSocket.webidl',
     'WheelEvent.webidl',
     'WifiOptions.webidl',
+    'Window.webidl',
     'WorkerLocation.webidl',
     'WorkerMessagePort.webidl',
     'WorkerNavigator.webidl',
     'XMLDocument.webidl',
     'XMLHttpRequest.webidl',
     'XMLHttpRequestEventTarget.webidl',
     'XMLHttpRequestUpload.webidl',
     'XMLSerializer.webidl',
--- a/dom/workers/MessagePort.cpp
+++ b/dom/workers/MessagePort.cpp
@@ -61,19 +61,19 @@ MessagePort::PrefEnabled()
 {
   AssertIsOnMainThread();
 
   // Currently tied to the SharedWorker preference.
   return SharedWorker::PrefEnabled();
 }
 
 void
-MessagePort::PostMessageMoz(JSContext* aCx, JS::HandleValue aMessage,
-                            const Optional<Sequence<JS::Value>>& aTransferable,
-                            ErrorResult& aRv)
+MessagePort::PostMessage(JSContext* aCx, JS::HandleValue aMessage,
+                         const Optional<Sequence<JS::Value>>& aTransferable,
+                         ErrorResult& aRv)
 {
   AssertIsOnMainThread();
 
   if (IsClosed()) {
     aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
     return;
   }
 
--- a/dom/workers/MessagePort.h
+++ b/dom/workers/MessagePort.h
@@ -29,19 +29,19 @@ class MessagePort MOZ_FINAL : public nsD
   uint64_t mSerial;
   bool mStarted;
 
 public:
   static bool
   PrefEnabled();
 
   void
-  PostMessageMoz(JSContext* aCx, JS::HandleValue aMessage,
-                 const Optional<Sequence<JS::Value>>& aTransferable,
-                 ErrorResult& aRv);
+  PostMessage(JSContext* aCx, JS::HandleValue aMessage,
+              const Optional<Sequence<JS::Value>>& aTransferable,
+              ErrorResult& aRv);
 
   void
   Start();
 
   void
   Close()
   {
     AssertIsOnMainThread();
--- a/dom/workers/WorkerMessagePort.cpp
+++ b/dom/workers/WorkerMessagePort.cpp
@@ -120,17 +120,17 @@ WorkerMessagePort::_trace(JSTracer* aTrc
 
 void
 WorkerMessagePort::_finalize(JSFreeOp* aFop)
 {
   EventTarget::_finalize(aFop);
 }
 
 void
-WorkerMessagePort::PostMessageMoz(
+WorkerMessagePort::PostMessage(
                              JSContext* /* aCx */, JS::HandleValue aMessage,
                              const Optional<Sequence<JS::Value>>& aTransferable,
                              ErrorResult& aRv)
 {
   if (mClosed) {
     aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
     return;
   }
--- a/dom/workers/WorkerMessagePort.h
+++ b/dom/workers/WorkerMessagePort.h
@@ -34,17 +34,17 @@ class WorkerMessagePort : public EventTa
 public:
   virtual void
   _trace(JSTracer* aTrc) MOZ_OVERRIDE;
 
   virtual void
   _finalize(JSFreeOp* aFop) MOZ_OVERRIDE;
 
   void
-  PostMessageMoz(JSContext* aCx, JS::HandleValue aMessage,
+  PostMessage(JSContext* aCx, JS::HandleValue aMessage,
               const Optional<Sequence<JS::Value>>& aTransferable,
               ErrorResult& aRv);
 
   void
   Start();
 
   void
   Close()
--- a/js/src/tests/js1_5/Regress/regress-317476.js
+++ b/js/src/tests/js1_5/Regress/regress-317476.js
@@ -12,17 +12,17 @@ var expect = 'no error';
 printBugNumber(BUGNUMBER);
 printStatus (summary);
 
 if (typeof setTimeout != 'undefined')
 {
   expect = 'error';
   try
   {
-    setTimeout();
+    setTimeout(2);
   }
   catch(ex)
   {
     actual = 'error';
     printStatus(ex+'');
   }
 }
 
--- a/js/src/tests/js1_5/Regress/regress-328897.js
+++ b/js/src/tests/js1_5/Regress/regress-328897.js
@@ -14,17 +14,17 @@ printBugNumber(BUGNUMBER);
 printStatus (summary);
  
 if (typeof window == 'undefined')
 {
   reportCompare(expect, actual, summary);
 }
 else
 {
-  expect = /TypeError: Not enough arguments to Window.showModalDialog./;
+  expect = /NS_ERROR_XPC_NOT_ENOUGH_ARGS/;
 
   window._onerror = window.onerror;
   window.onerror = (function (msg, page, line) { 
       actual = msg; 
       gDelayTestDriverEnd = false;
       jsTestDriverEnd();
       reportMatch(expect, actual, summary);
     });
--- a/js/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/xpconnect/src/dom_quickstubs.qsconf
@@ -23,16 +23,33 @@ members = [
     #   - nsIDOMNSHistory.go
     #   - nsIDOMJSPluginArray.refresh
     #   - nsIDOMWindow.postMessage
     #   - nsIDOMJSWindow.{prompt,setTimeout,setInterval,open,openDialog}
     #
     # (And nsIDOMModalContentWindow.returnValue is an attribute of type
     # nsIVariant, which qsgen.py can't handle.)
     #
+    'nsIDOMWindow.name',
+    'nsIDOMWindow.parent',
+    'nsIDOMWindow.top',
+    'nsIDOMWindow.self',
+    # Several window properties are magically resolved, including
+    # location, _content, navigator, document, and window itself.
+    # These do not need quick stubs.
+    #'nsIDOMWindow.document',
+    'nsIDOMWindow.getSelection',
+    'nsIDOMWindow.scrollByLines',
+    'nsIDOMWindow.getComputedStyle',
+    'nsIDOMWindow.sessionStorage',
+    'nsIDOMWindow.localStorage',
+    'nsIDOMWindow.onmouseenter',
+    'nsIDOMWindow.onmouseleave',
+    'nsIDOMWindowPerformance.performance',
+    'nsIDOMJSWindow.dump',
     # nsLocationSH has ~ALLOW_PROP_MODS_TO_PROTOTYPE, so don't try.
     #'nsIDOMLocation.hostname',
     #'nsIDOMLocation.href',
 
     # dom/interfaces/core
     'nsIDOMDOMStringList.*',
 
     # dom/interfaces/storage
@@ -83,34 +100,56 @@ members = [
 # don't have their own files, just for extra wackiness.  So qsgen.py needs
 # a little help.
 #
 irregularFilenames = {
     # stowaways
     'nsIDOMBlob': 'nsIDOMFile',
     'nsIIndexedDatabaseUsageCallback': 'nsIIndexedDatabaseManager',
     'nsITelephoneCallback': 'nsITelephone',
+    'nsIDOMWindowPerformance': 'nsIDOMWindow',
     }
 
 customIncludes = [
+    'nsPerformance.h',
+    'nsPIDOMWindow.h',
     'mozilla/dom/BindingUtils.h',
     'mozilla/dom/EventTargetBinding.h',
-    'mozilla/dom/WindowBinding.h',
     ]
 
 nsIDOMStorage_Clear_customMethodCallCode = """
     rv = self->Clear();
     if (NS_SUCCEEDED(rv))
         JS_ClearNonGlobalObject(cx, obj);
 """
 
 customMethodCalls = {
     'nsIDOMStorage_Clear': {
         'code': nsIDOMStorage_Clear_customMethodCallCode
         },
+    'nsIDOMWindow_GetOnmouseenter' : {
+        'thisType' : 'nsIDOMWindow',
+        'unwrapThisFailureFatal' : False
+        },
+    'nsIDOMWindow_SetOnmouseenter' : {
+        'thisType' : 'nsIDOMWindow',
+        'unwrapThisFailureFatal' : False
+        },
+    'nsIDOMWindow_GetOnmouseleave' : {
+        'thisType' : 'nsIDOMWindow',
+        'unwrapThisFailureFatal' : False
+        },
+    'nsIDOMWindow_SetOnmouseleave' : {
+        'thisType' : 'nsIDOMWindow',
+        'unwrapThisFailureFatal' : False
+        },
+    'nsIDOMWindowPerformance_GetPerformance' : {
+        'thisType': 'nsPIDOMWindow',
+        'code' : '    nsPerformance* result = self->GetPerformance();\n',
+        'canFail': False,
+        },
     }
 
 newBindingProperties = {
     # Once the last entry here goes away, we can make the sNativePropertyHooks
     # of bindings static.
     'nsIDOMEventTarget': 'mozilla::dom::EventTargetBinding::sNativePropertyHooks->mNativeProperties.regular',
-    'nsIDOMWindow': 'mozilla::dom::WindowBinding::sNativePropertyHooks->mNativeProperties.regular',
     }
--- a/js/xpconnect/src/event_impl_gen.conf.in
+++ b/js/xpconnect/src/event_impl_gen.conf.in
@@ -67,11 +67,10 @@ exclude_automatic_type_include = [
   ]
 
 """ Map xpidl interface names to implementation classes. The third column is the canonical interface. """
 xpidl_to_native = [
     ['nsIDOMBluetoothDevice', 'bluetooth::BluetoothDevice', 'nsIDOMBluetoothDevice'],
     ['nsIDOMDocument', 'nsIDocument', 'nsIDocument'],
     ['nsIDOMElement', 'mozilla::dom::Element', 'mozilla::dom::Element'],
     ['nsIDOMCSSStyleSheet', 'nsCSSStyleSheet', 'nsIStyleSheet'],
-    ['nsIDOMWindow', 'nsGlobalWindow', 'nsIDOMEventTarget']
   ]
 
--- a/js/xpconnect/src/nsDOMQS.h
+++ b/js/xpconnect/src/nsDOMQS.h
@@ -22,17 +22,16 @@
 #include "mozilla/dom/EventTargetBinding.h"
 #include "mozilla/dom/NodeBinding.h"
 #include "mozilla/dom/ElementBinding.h"
 #include "mozilla/dom/HTMLElementBinding.h"
 #include "mozilla/dom/DocumentBinding.h"
 #include "mozilla/dom/SVGElementBinding.h"
 #include "mozilla/dom/HTMLDocumentBinding.h"
 #include "XPCQuickStubs.h"
-#include "nsGlobalWindow.h"
 
 template<class T>
 struct ProtoIDAndDepth
 {
     enum {
         PrototypeID = mozilla::dom::prototypes::id::_ID_Count,
         Depth = -1
     };
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -1369,17 +1369,17 @@ namespace xpc {
 NS_EXPORT_(bool)
 Base64Encode(JSContext *cx, JS::Value val, JS::Value *out)
 {
     MOZ_ASSERT(cx);
     MOZ_ASSERT(out);
 
     JS::RootedValue root(cx, val);
     xpc_qsACString encodedString(cx, root, &root, false,
-                                 xpc_qsACString::eStringify,
+                                 xpc_qsACString::eNull,
                                  xpc_qsACString::eStringify);
     if (!encodedString.IsValid())
         return false;
 
     nsAutoCString result;
     if (NS_FAILED(mozilla::Base64Encode(encodedString, result))) {
         JS_ReportError(cx, "Failed to encode base64 data!");
         return false;
@@ -1396,18 +1396,18 @@ Base64Encode(JSContext *cx, JS::Value va
 NS_EXPORT_(bool)
 Base64Decode(JSContext *cx, JS::Value val, JS::Value *out)
 {
     MOZ_ASSERT(cx);
     MOZ_ASSERT(out);
 
     JS::RootedValue root(cx, val);
     xpc_qsACString encodedString(cx, root, &root, false,
-                                 xpc_qsACString::eStringify,
-                                 xpc_qsACString::eStringify);
+                                 xpc_qsACString::eNull,
+                                 xpc_qsACString::eNull);
     if (!encodedString.IsValid())
         return false;
 
     nsAutoCString result;
     if (NS_FAILED(mozilla::Base64Decode(encodedString, result))) {
         JS_ReportError(cx, "Failed to decode base64 string!");
         return false;
     }
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1868,26 +1868,27 @@ nsPresContext::HandleMediaFeatureValuesC
 {
   // Null-check mShell in case the shell has been destroyed (and the
   // event is the only thing holding the pres context alive).
   if (mPendingMediaFeatureValuesChanged && mShell) {
     MediaFeatureValuesChanged(eRebuildStyleIfNeeded);
   }
 }
 
-already_AddRefed<nsIDOMMediaQueryList>
-nsPresContext::MatchMedia(const nsAString& aMediaQueryList)
+void
+nsPresContext::MatchMedia(const nsAString& aMediaQueryList,
+                          nsIDOMMediaQueryList** aResult)
 {
   nsRefPtr<nsDOMMediaQueryList> result =
     new nsDOMMediaQueryList(this, aMediaQueryList);
 
   // Insert the new item at the end of the linked list.
   PR_INSERT_BEFORE(result, &mDOMMediaQueryLists);
 
-  return result.forget();
+  result.forget(aResult);
 }
 
 nsCompatibility
 nsPresContext::CompatibilityMode() const
 {
   return Document()->GetCompatibilityMode();
 }
 
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -260,18 +260,18 @@ public:
   void FlushPendingMediaFeatureValuesChanged() {
     if (mPendingMediaFeatureValuesChanged)
       MediaFeatureValuesChanged(eRebuildStyleIfNeeded);
   }
 
   /**
    * Support for window.matchMedia()
    */
-  already_AddRefed<nsIDOMMediaQueryList>
-    MatchMedia(const nsAString& aMediaQueryList);
+  void MatchMedia(const nsAString& aMediaQueryList,
+                  nsIDOMMediaQueryList** aResult);
 
   /**
    * Access compatibility mode for this context.  This is the same as
    * our document's compatibility mode.
    */
   nsCompatibility CompatibilityMode() const;
 
   /**
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -31,22 +31,22 @@
 #include "nsIConsoleService.h"
 #include "nsThreadUtils.h"
 #include "nsProxyRelease.h"
 
 #include "runnable_utils.h"
 #include "PeerConnectionCtx.h"
 #include "PeerConnectionImpl.h"
 #include "PeerConnectionMedia.h"
+#include "nsPIDOMWindow.h"
 #include "nsDOMDataChannelDeclarations.h"
 #include "dtlsidentity.h"
 
 #ifdef MOZILLA_INTERNAL_API
 #include "nsPerformance.h"
-#include "nsGlobalWindow.h"
 #include "nsDOMDataChannel.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Telemetry.h"
 #include "nsDOMJSUtils.h"
 #include "nsIDocument.h"
 #include "nsIScriptError.h"
 #include "nsPrintfCString.h"
 #include "nsURLHelper.h"
@@ -618,17 +618,17 @@ PeerConnectionImpl::ConvertRTCConfigurat
     }
   }
 #endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver,
-                               nsGlobalWindow* aWindow,
+                               nsIDOMWindow* aWindow,
                                const IceConfiguration* aConfiguration,
                                const RTCConfiguration* aRTCConfiguration,
                                nsISupports* aThread)
 {
   nsresult res;
 
   // Invariant: we receive configuration one way or the other but not both (XOR)
   MOZ_ASSERT(!aConfiguration != !aRTCConfiguration);
@@ -647,17 +647,17 @@ PeerConnectionImpl::Initialize(PeerConne
 
 #ifdef MOZILLA_INTERNAL_API
   // This code interferes with the C++ unit test startup code.
   nsCOMPtr<nsISupports> nssDummy = do_GetService("@mozilla.org/psm;1", &res);
   NS_ENSURE_SUCCESS(res, res);
   // Currently no standalone unit tests for DataChannel,
   // which is the user of mWindow
   MOZ_ASSERT(aWindow);
-  mWindow = aWindow;
+  mWindow = do_QueryInterface(aWindow);
   NS_ENSURE_STATE(mWindow);
 #endif
 
   // Generate a random handle
   unsigned char handle_bin[8];
   SECStatus rv;
   rv = PK11_GenerateRandom(handle_bin, sizeof(handle_bin));
   if (rv != SECSuccess) {
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
@@ -249,30 +249,30 @@ public:
 
   nsPIDOMWindow* GetWindow() const {
     PC_AUTO_ENTER_API_CALL_NO_CHECK();
     return mWindow;
   }
 
   // Initialize PeerConnection from an IceConfiguration object (unit-tests)
   nsresult Initialize(PeerConnectionObserver& aObserver,
-                      nsGlobalWindow* aWindow,
+                      nsIDOMWindow* aWindow,
                       const IceConfiguration& aConfiguration,
                       nsIThread* aThread) {
     return Initialize(aObserver, aWindow, &aConfiguration, nullptr, aThread);
   }
 
   // Initialize PeerConnection from an RTCConfiguration object (JS entrypoint)
   void Initialize(PeerConnectionObserver& aObserver,
-                  nsGlobalWindow& aWindow,
+                  nsIDOMWindow* aWindow,
                   const RTCConfiguration& aConfiguration,
                   nsISupports* aThread,
                   ErrorResult &rv)
   {
-    nsresult r = Initialize(aObserver, &aWindow, nullptr, &aConfiguration, aThread);
+    nsresult r = Initialize(aObserver, aWindow, nullptr, &aConfiguration, aThread);
     if (NS_FAILED(r)) {
       rv.Throw(r);
     }
   }
 
   NS_IMETHODIMP_TO_ERRORRESULT(CreateOffer, ErrorResult &rv,
                                const MediaConstraintsInternal& aConstraints)
   {
@@ -442,17 +442,17 @@ public:
   // initialize telemetry for when calls start
   void startCallTelem();
 #endif
 
 private:
   PeerConnectionImpl(const PeerConnectionImpl&rhs);
   PeerConnectionImpl& operator=(PeerConnectionImpl);
   NS_IMETHODIMP Initialize(PeerConnectionObserver& aObserver,
-                           nsGlobalWindow* aWindow,
+                           nsIDOMWindow* aWindow,
                            const IceConfiguration* aConfiguration,
                            const RTCConfiguration* aRTCConfiguration,
                            nsISupports* aThread);
 
   NS_IMETHODIMP EnsureDataConnection(uint16_t aNumstreams);
 
   nsresult CloseInt();
   void ChangeReadyState(mozilla::dom::PCImplReadyState aReadyState);
--- a/xpfe/appshell/src/nsXULWindow.cpp
+++ b/xpfe/appshell/src/nsXULWindow.cpp
@@ -1957,20 +1957,20 @@ void nsXULWindow::PlaceWindowLayersBehin
     }
   }
 }
 
 void nsXULWindow::SetContentScrollbarVisibility(bool aVisible)
 {
   nsCOMPtr<nsPIDOMWindow> contentWin(do_GetInterface(mPrimaryContentShell));
   if (contentWin) {
-    mozilla::ErrorResult rv;
     nsRefPtr<nsGlobalWindow> window = static_cast<nsGlobalWindow*>(contentWin.get());
-    nsRefPtr<mozilla::dom::BarProp> scrollbars = window->GetScrollbars(rv);
+    nsRefPtr<mozilla::dom::BarProp> scrollbars = window->GetScrollbars();
     if (scrollbars) {
+      mozilla::ErrorResult rv;
       scrollbars->SetVisible(aVisible, rv);
     }
   }
 }
 
 bool nsXULWindow::GetContentScrollbarVisibility()
 {
   // This code already exists in dom/src/base/nsBarProp.cpp, but we