Merge mozilla-central to mozilla-inbound
authorEd Morley <emorley@mozilla.com>
Tue, 02 Oct 2012 11:19:03 +0100
changeset 108996 a16dfb364f8cc690b36948cc2e628601c59b56a9
parent 108995 da5df2c1ae16428cd4827ab31b6562a519e7e9d3 (current diff)
parent 108937 c9a8f55d8541397f63894112088df7846c8078b8 (diff)
child 108997 7897fb9e2563162c391049f494fde1116861a608
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
milestone18.0a1
Merge mozilla-central to mozilla-inbound
content/base/public/nsINode.h
content/base/src/nsGenericDOMDataNode.h
content/html/content/src/nsGenericHTMLElement.h
dom/base/nsDOMClassInfo.cpp
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1024,17 +1024,17 @@ pref("devtools.layoutview.open", false);
 pref("devtools.responsiveUI.enabled", true);
 
 // Enable the Debugger
 pref("devtools.debugger.enabled", true);
 pref("devtools.debugger.chrome-enabled", false);
 pref("devtools.debugger.remote-host", "localhost");
 pref("devtools.debugger.remote-autoconnect", false);
 pref("devtools.debugger.remote-connection-retries", 3);
-pref("devtools.debugger.remote-timeout", 3000);
+pref("devtools.debugger.remote-timeout", 20000);
 
 // The default Debugger UI settings
 pref("devtools.debugger.ui.height", 250);
 pref("devtools.debugger.ui.remote-win.width", 900);
 pref("devtools.debugger.ui.remote-win.height", 400);
 pref("devtools.debugger.ui.stackframes-width", 200);
 pref("devtools.debugger.ui.stackframes-pane-visible", true);
 pref("devtools.debugger.ui.variables-width", 300);
--- a/browser/devtools/debugger/DebuggerUI.jsm
+++ b/browser/devtools/debugger/DebuggerUI.jsm
@@ -6,17 +6,17 @@
 "use strict";
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 
 const DBG_XUL = "chrome://browser/content/debugger.xul";
 const DBG_STRINGS_URI = "chrome://browser/locale/devtools/debugger.properties";
-const REMOTE_PROFILE_NAME = "_remote-debug";
+const CHROME_DEBUGGER_PROFILE_NAME = "_chrome-debugger-profile";
 const TAB_SWITCH_NOTIFICATION = "debugger-tab-switch";
 
 Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/FileUtils.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 let EXPORTED_SYMBOLS = ["DebuggerUI"];
@@ -484,19 +484,19 @@ ChromeDebuggerProcess.prototype = {
    * Initializes a profile for the remote debugger process.
    */
   _initProfile: function RDP__initProfile() {
     let profileService = Cc["@mozilla.org/toolkit/profile-service;1"]
       .createInstance(Ci.nsIToolkitProfileService);
 
     let dbgProfileName;
     try {
-      dbgProfileName = profileService.selectedProfile.name + REMOTE_PROFILE_NAME;
+      dbgProfileName = profileService.selectedProfile.name + CHROME_DEBUGGER_PROFILE_NAME;
     } catch(e) {
-      dbgProfileName = REMOTE_PROFILE_NAME;
+      dbgProfileName = CHROME_DEBUGGER_PROFILE_NAME;
       Cu.reportError(e);
     }
 
     this._dbgProfile = profileService.createProfile(null, null, dbgProfileName);
     profileService.flush();
   },
 
   /**
--- a/browser/devtools/debugger/debugger-controller.js
+++ b/browser/devtools/debugger/debugger-controller.js
@@ -1348,16 +1348,26 @@ SourceScripts.prototype = {
    *        The content type of the source script.
    * @param object aOptions [optional]
    *        Additional options for showing the script. Supported options:
    *        - targetLine: place the editor at the given line number.
    */
   _onLoadSourceFinished:
   function SS__onLoadSourceFinished(aScriptUrl, aSourceText, aContentType, aOptions) {
     let element = DebuggerView.Scripts.getScriptByLocation(aScriptUrl);
+
+    // Tab navigated before we got a chance to finish loading and displaying
+    // the source. The outcome is that the expected url is not present anymore
+    // in the scripts container, hence the original script object coming from
+    // the active thread no longer exists. There's really nothing that needs
+    // to be done in this case, nor something that can be currently avoided.
+    if (!element) {
+      return;
+    }
+
     let script = element.getUserData("sourceScript");
 
     script.loaded = true;
     script.text = aSourceText;
     script.contentType = aContentType;
     element.setUserData("sourceScript", script, null);
 
     if (aOptions.silent) {
--- a/browser/devtools/debugger/debugger.xul
+++ b/browser/devtools/debugger/debugger.xul
@@ -78,18 +78,17 @@
         <toolbarbutton id="step-in"
                        class="devtools-toolbarbutton"
                        tabindex="0"/>
         <toolbarbutton id="step-out"
                        class="devtools-toolbarbutton"
                        tabindex="0"/>
       </hbox>
       <menulist id="scripts" class="devtools-menulist"
-                sizetopopup="always"
-                label="&debuggerUI.emptyScriptText;"/>
+                sizetopopup="always"/>
       <textbox id="scripts-search" type="search"
                class="devtools-searchinput"/>
       <checkbox id="pause-exceptions"
                 type="checkbox"
                 tabindex="0"
                 label="&debuggerUI.pauseExceptions;"/>
       <spacer flex="1"/>
 #ifndef XP_MACOSX
--- a/browser/devtools/debugger/test/browser_dbg_createRemote.js
+++ b/browser/devtools/debugger/test/browser_dbg_createRemote.js
@@ -2,29 +2,35 @@
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 // Tests that a remote debugger can be created in a new window.
 
 var gWindow = null;
 var gTab = null;
+var gRemoteHost = null;
 var gRemotePort = null;
+var gRemoteTimeout = null;
 var gAutoConnect = null;
 
 const TEST_URL = EXAMPLE_URL + "browser_dbg_iframes.html";
 
 function test() {
   debug_remote(TEST_URL, function(aTab, aDebuggee, aWindow) {
     gTab = aTab;
     gWindow = aWindow;
     let gDebugger = gWindow.contentWindow;
 
+    info("Current remote host: " +
+      Services.prefs.getCharPref("devtools.debugger.remote-host"));
     info("Current remote port: " +
       Services.prefs.getIntPref("devtools.debugger.remote-port"));
+    info("Current remote timeout: " +
+      Services.prefs.getIntPref("devtools.debugger.remote-timeout"));
     info("Current autoconnect flag: " +
       Services.prefs.getBoolPref("devtools.debugger.remote-autoconnect"));
 
     is(gDebugger.document.getElementById("close").getAttribute("hidden"), "true",
       "The close button should be hidden in a remote debugger.");
 
     is(gDebugger.DebuggerController.activeThread.paused, false,
       "Should be running after debug_remote.");
@@ -61,28 +67,32 @@ function test() {
   },
   function beforeTabAdded() {
     if (!DebuggerServer.initialized) {
       DebuggerServer.init(function() { return true; });
       DebuggerServer.addBrowserActors();
     }
     DebuggerServer.closeListener();
 
+    gRemoteHost = Services.prefs.getCharPref("devtools.debugger.remote-host");
     gRemotePort = Services.prefs.getIntPref("devtools.debugger.remote-port");
+    gRemoteTimeout = Services.prefs.getIntPref("devtools.debugger.remote-timeout");
     gAutoConnect = Services.prefs.getBoolPref("devtools.debugger.remote-autoconnect");
 
     // Open the listener at some point in the future to test automatic reconnect.
-    openListener(gRemotePort + 1);
+    openListener(gRemoteHost, gRemotePort + 1, gRemoteTimeout / 10);
   });
 }
 
 let attempts = 0;
 
-function openListener(port) {
+function openListener(host, port, timeout) {
+  Services.prefs.setCharPref("devtools.debugger.remote-host", host);
   Services.prefs.setIntPref("devtools.debugger.remote-port", port);
+  Services.prefs.setIntPref("devtools.debugger.remote-timeout", timeout);
   Services.prefs.setBoolPref("devtools.debugger.remote-autoconnect", true);
 
   info("Attempting to open a new listener on port " + port);
   try {
     info("Closing listener...");
     DebuggerServer.closeListener();
     info("Opening listener...");
     DebuggerServer.openListener(port);
@@ -96,16 +106,20 @@ function openListener(port) {
       openListener(port);
     } else {
       ok(false, "Timed out while opening a listener.");
     }
   }
 }
 
 registerCleanupFunction(function() {
+  Services.prefs.setCharPref("devtools.debugger.remote-host", gRemoteHost);
   Services.prefs.setIntPref("devtools.debugger.remote-port", gRemotePort);
+  Services.prefs.setIntPref("devtools.debugger.remote-timeout", gRemoteTimeout);
   Services.prefs.setBoolPref("devtools.debugger.remote-autoconnect", gAutoConnect);
   removeTab(gTab);
   gWindow = null;
   gTab = null;
+  gRemoteHost = null;
   gRemotePort = null;
+  gRemoteTimeout = null;
   gAutoConnect = null;
 });
--- a/browser/devtools/markupview/MarkupView.jsm
+++ b/browser/devtools/markupview/MarkupView.jsm
@@ -94,17 +94,17 @@ MarkupView.prototype = {
   },
 
   /**
    * Highlight the given element in the markup panel.
    */
   _onSelect: function MT__onSelect()
   {
     if (this._inspector.selection) {
-      this.showNode(this._inspector.selection);
+      this.showNode(this._inspector.selection, true);
     }
     this.selectNode(this._inspector.selection);
   },
 
   /**
    * Create a TreeWalker to find the next/previous
    * node for selection.
    */
@@ -249,17 +249,17 @@ MarkupView.prototype = {
    */
   navigate: function MT__navigate(aContainer, aIgnoreFocus)
   {
     if (!aContainer) {
       return;
     }
 
     let node = aContainer.node;
-    this.showNode(node);
+    this.showNode(node, false);
     this.selectNode(node);
 
     if (this._inspector._IUI.highlighter.isNodeHighlightable(node)) {
       this._inspector._IUI.select(node, true, false, "treepanel");
       this._inspector._IUI.highlighter.highlight(node);
     }
 
     if (!aIgnoreFocus) {
@@ -338,25 +338,25 @@ MarkupView.prototype = {
     }
     this._inspector.emit("markupmutation");
   },
 
   /**
    * Make sure the given node's parents are expanded and the
    * node is scrolled on to screen.
    */
-  showNode: function MT_showNode(aNode)
+  showNode: function MT_showNode(aNode, centered)
   {
     this.importNode(aNode);
     let walker = documentWalker(aNode);
     let parent;
     while (parent = walker.parentNode()) {
       this.expandNode(parent);
     }
-    LayoutHelpers.scrollIntoViewIfNeeded(this._containers.get(aNode).editor.elt, false);
+    LayoutHelpers.scrollIntoViewIfNeeded(this._containers.get(aNode).editor.elt, centered);
   },
 
   /**
    * Expand the container's children.
    */
   _expandContainer: function MT__expandContainer(aContainer)
   {
     if (aContainer.hasChildren && !aContainer.expanded) {
--- a/browser/devtools/markupview/markup-view.xhtml
+++ b/browser/devtools/markupview/markup-view.xhtml
@@ -4,36 +4,37 @@
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 <!DOCTYPE html>
 
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
   <link rel="stylesheet" href="chrome://browser/content/devtools/markup-view.css" type="text/css"/>
   <link rel="stylesheet" href="chrome://browser/skin/devtools/markup-view.css" type="text/css"/>
+  <link rel="stylesheet" href="chrome://browser/skin/devtools/common.css" type="text/css"/>
 </head>
 <body role="application">
   <div id="root"></div>
   <div id="templates" style="display:none">
     <ul>
       <li id="template-container" save="${elt}" class="container"><span save="${expander}" class="expander"></span><span save="${codeBox}" class="codebox"><ul save="${children}" class="children"></ul></span></li>
     </ul>
 
-    <span id="template-element" save="${elt}" class="editor"><span>&lt;</span><span save="${tag}" class="tagname"></span><span save="${attrList}"></span><span save="${newAttr}" class="newattr" tabindex="0"></span>&gt;</span>
+    <span id="template-element" save="${elt}" class="editor"><span>&lt;</span><span save="${tag}" class="tagname devtools-theme-tagname"></span><span save="${attrList}"></span><span save="${newAttr}" class="newattr" tabindex="0"></span>&gt;</span>
 
-    <span id="template-attribute" save="${attr}" data-attr="${attrName}" class="attreditor" style="display:none"> <span class="editable" save="${inner}" tabindex="0"><span save="${name}" class="attrname"></span>=&quot;<span save="${val}" class="attrvalue"></span>&quot;</span></span>
+    <span id="template-attribute" save="${attr}" data-attr="${attrName}" class="attreditor" style="display:none"> <span class="editable" save="${inner}" tabindex="0"><span save="${name}" class="attrname devtools-theme-attrname"></span>=&quot;<span save="${val}" class="attrvalue devtools-theme-attrvalue"></span>&quot;</span></span>
 
-    <span id="template-text" save="${elt}" class="editor">
+    <span id="template-text" save="${elt}" class="editor text">
       <pre save="${value}" style="display:inline-block;" tabindex="0"></pre>
     </span>
 
-    <span id="template-comment" save="${elt}" class="editor comment">
+    <span id="template-comment" save="${elt}" class="editor comment devtools-theme-comment">
       <span>&lt;!--</span><pre save="${value}" style="display:inline-block;" tabindex="0"></pre><span>--&gt;</span>
     </span>
 
-    <span id="template-elementClose" save="${closeElt}">&lt;/<span save="${closeTag}" class="tagname"></span>&gt;</span>
+    <span id="template-elementClose" save="${closeElt}">&lt;/<span save="${closeTag}" class="tagname devtools-theme-tagname"></span>&gt;</span>
    </div>
    <div id="previewbar" class="disabled">
      <div id="preview"/>
      <div id="viewbox"/>
    </div>
 </body>
 </html>
--- a/browser/locales/en-US/chrome/browser/devtools/debugger.dtd
+++ b/browser/locales/en-US/chrome/browser/devtools/debugger.dtd
@@ -30,29 +30,11 @@
 <!-- LOCALIZATION NOTE (debuggerUI.closeButton.tooltip): This is the tooltip for
   -  the button that closes the debugger UI. -->
 <!ENTITY debuggerUI.closeButton.tooltip "Close">
 
 <!-- LOCALIZATION NOTE (debuggerUI.pauseExceptions): This is the label for the
   -  checkbox that toggles pausing on exceptions. -->
 <!ENTITY debuggerUI.pauseExceptions     "Pause on exceptions">
 
-<!-- LOCALIZATION NOTE (debuggerUI.stackTitle): This is the label for the
-  -  widget that displays the call stack frames in the debugger. -->
-<!ENTITY debuggerUI.stackTitle          "Call stack">
-
-<!-- LOCALIZATION NOTE (debuggerUI.scriptTitle): This is the label for the
-  -  widget that displays the source code for the script that is currently
-  -  being inspected in the debugger. -->
-<!ENTITY debuggerUI.scriptTitle         "Script">
-
-<!-- LOCALIZATION NOTE (debuggerUI.propertiesTitle): This is the label for the
-  -  widget that displays the variables in the various available scopes in the
-  -  debugger. -->
-<!ENTITY debuggerUI.propertiesTitle     "Scope variables">
-
 <!-- LOCALIZATION NOTE (debuggerUI.searchPanelTitle): This is the text that
   -  appears in the filter panel popup as a description. -->
 <!ENTITY debuggerUI.searchPanelTitle    "Operators">
-
-<!-- LOCALIZATION NOTE (emptyScriptText): The text to display in the menulist when
-  - there are no scripts. -->
-<!ENTITY debuggerUI.emptyScriptText     "No scripts">
--- a/browser/themes/gnomestripe/devtools/common.css
+++ b/browser/themes/gnomestripe/devtools/common.css
@@ -169,8 +169,38 @@
   border: 0;
   -moz-border-start: 1px solid black;
   min-width: 0;
   width: 3px;
   background-color: transparent;
   -moz-margin-end: -3px;
   position: relative;
 }
+
+/* Theme */
+
+.devtools-theme-background {
+  background-color: white;
+}
+
+.devtools-theme-comment {
+  color: hsl(90,2%,46%); /* grey */
+}
+
+.devtools-theme-keyword {
+  color: hsl(276,44%,45%); /* purple */
+}
+
+.devtools-theme-string {
+  color: hsl(72,100%,27%); /* green */
+}
+
+.devtools-theme-tagname {
+  color: hsl(208,81%,21%); /* dark blue */
+}
+
+.devtools-theme-attrname {
+  color: hsl(208,56%,40%); /* blue */
+}
+
+.devtools-theme-attrvalue {
+  color: hsl(24,85%,39%); /* orange */
+}
--- a/browser/themes/gnomestripe/devtools/csshtmltree.css
+++ b/browser/themes/gnomestripe/devtools/csshtmltree.css
@@ -139,17 +139,17 @@
  * CSS Rule View
  */
 
 .ruleview {
   background-color: white;
 }
 
 .ruleview-rule-source {
-  color: hsl(121,42%,43%); /* green */
+  color: hsl(90,2%,46%); /* grey */
   -moz-padding-start: 5px;
   cursor: pointer;
   text-align: right;
   float: right;
   -moz-user-select: -moz-none;
 }
 
 .ruleview-rule-inheritance {
@@ -226,17 +226,17 @@
 
 .ruleview-newproperty {
   /* (enable checkbox width: 12px) + (expander width: 15px) */
   -moz-margin-start: 27px;
 }
 
 .ruleview-propertyname {
   padding: 1px 0;
-  color: hsl(210,100%,38%); /* blue */
+  color: hsl(276,44%,45%); /* purple */
 }
 
 .ruleview-propertyvalue {
   padding: 1px 0;
 }
 
 .ruleview-namecontainer,
 .ruleview-propertycontainer,
--- a/browser/themes/gnomestripe/devtools/markup-view.css
+++ b/browser/themes/gnomestripe/devtools/markup-view.css
@@ -4,42 +4,29 @@
 
 * {
   padding: 0;
   margin: 0;
 }
 
 body {
   font: message-box;
-  background-color: #131c26;
-  color: #8fa1b2;
+  color: hsl(0,0%,50%);
 }
 
-.tagname {
-  color: #a673bf;
-}
-
-.attrname {
-  color: #b26b47;
-}
-
-.attrvalue {
-  color: #3689b2;
+.text {
+  color: black;
 }
 
 .newattr {
   cursor: pointer;
 }
 
-.comment {
-  color: #5c6773;
-}
-
 .selected {
-  background-color: #253847;
+  background-color: hsl(0,0%,90%);
 }
 
 /* Give some padding to focusable elements to match the editor input
  * that will replace them. */
 span[tabindex] {
   display: inline-block;
   padding: 1px 0;
 }
--- a/browser/themes/gnomestripe/devtools/orion.css
+++ b/browser/themes/gnomestripe/devtools/orion.css
@@ -1,31 +1,31 @@
 /* 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/. */
 
 .viewContainer {
-  background: #cddae5; /* This will be seen as the continuation of the ruler */
+  background: hsl(0,0%,89%); /* This will be seen as the continuation of the ruler */
   font-family: monospace;
   font-size: inherit; /* inherit browser's default monospace font size */
 }
 
 .view {
   color: black; /* Default text color */
-  background: #f0f0ff; /* Background of the editor */
+  background: white; /* Background of the editor */
   padding-left: 4px;
 }
 
 .readonly > .view {
-  background: #f0f0ff;
+  background: #fdfefd; /* super light green */
 }
 
 .ruler {
-  background: #cddae5;
-  color: #7a8a99;
+  background: hsl(0,0%,89%);
+  color: hsl(0,0%,55%);
 }
 .ruler.annotations {
   width: 16px;
   padding-left: 4px;
 }
 .ruler.lines {
   border-right: 1px solid #b4c4d3;
   min-width: 1.4em;
@@ -100,48 +100,42 @@
 }
 .annotationRange.task {
   outline: 1px dashed rgba(0, 255, 0, 0.5);
 }
 .annotationRange.matchingBracket {
   outline: 1px solid grey;
 }
 
-.token_singleline_comment {
-  color: #45a946; /* green */
-}
-
-.token_multiline_comment {
-  color: #45a946; /* green */
-}
-
-.token_doc_comment {
-  color: #45a946; /* green */
+.token_singleline_comment,
+.token_multiline_comment,
+.token_doc_comment  {
+  color: hsl(90,2%,50%); /* grey */
 }
 
 .token_doc_html_markup {
   color: #dd0058; /* purple */
 }
 
 .token_doc_tag {
   color: #dd0058; /* purple */
 }
 
 .token_task_tag { /* "TODO" */
   color: black;
   background: yellow;
 }
 
 .token_string {
-  color: #1e66b1; /* blue */
+  color: hsl(72,100%,27%); /* green */
   font-style: italic;
 }
 
 .token_keyword {
-  color: #dd0058; /* purple */
+  color: hsl(276,44%,45%); /* purple */
 }
 
 .token_space {
   /* images/white_space.png */
   background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAIAAABv85FHAAAABnRSTlMA/wAAAACkwsAdAAAAIUlEQVR4nGP4z8CAC+GUIEXuABhgkTuABEiRw2cmae4EAH05X7xDolNRAAAAAElFTkSuQmCC");
   background-repeat: no-repeat;
   background-position: center center;
 }
@@ -150,42 +144,41 @@
   /* images/white_tab.png */
   background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAJCAIAAACJ2loDAAAABnRSTlMA/wD/AP83WBt9AAAAMklEQVR4nGP4TwRgoK6i52c3bz5w6zMSA6tJn28d2Lx589nnCAYu63AaSLxJRLoJPwAAeNk0aG4opfMAAAAASUVORK5CYII=");
   background-repeat: no-repeat;
   background-position: left center;
 }
 
 .line_caret,
 .annotationLine.currentLine { /* Current line */
-  background: #dae2ee; /* lighter than the background */
+  background: hsl(208, 93%, 94%);
 }
 
 .readonly .line_caret,
 .readonly .annotationLine.currentLine {
-  background: #cddae5; /* a bit darker than the background */
+  background: hsl(208, 80%, 90%);
 }
 
 /* Styling for html syntax highlighting */
 .entity-name-tag {
-  color: #dd0058; /* purple */
+  color: hsl(208,48%,40%); /* blue */
 }
 
 .entity-other-attribute-name {
-  color: #dd0058; /* purple */
+  color: hsl(208,48%,40%); /* blue */
 }
 
 .punctuation-definition-comment {
-  color: #45a946; /* green */
+  color: hsl(90,2%,50%); /* grey */
 }
 
 .comment {
-  color: #45a946; /* green */
+  color: hsl(90,2%,50%); /* grey */
 }
 
 .string-quoted {
-  color: #1e66b1; /* blue */
-  font-style: italic;
+  color: hsl(24,85%,39%); /* orange */
 }
 
 .invalid {
   color: red;
   font-weight: bold;
 }
--- a/browser/themes/pinstripe/devtools/common.css
+++ b/browser/themes/pinstripe/devtools/common.css
@@ -184,8 +184,38 @@
   background-image: none;
   border: 0;
   -moz-border-start: 1px solid black;
   min-width: 0;
   width: 3px;
   -moz-margin-end: -3px;
   position: relative;
 }
+
+/* Theme */
+
+.devtools-theme-background {
+  background-color: white;
+}
+
+.devtools-theme-comment {
+  color: hsl(90,2%,46%); /* grey */
+}
+
+.devtools-theme-keyword {
+  color: hsl(276,44%,45%); /* purple */
+}
+
+.devtools-theme-string {
+  color: hsl(72,100%,27%); /* green */
+}
+
+.devtools-theme-tagname {
+  color: hsl(208,81%,21%); /* dark blue */
+}
+
+.devtools-theme-attrname {
+  color: hsl(208,56%,40%); /* blue */
+}
+
+.devtools-theme-attrvalue {
+  color: hsl(24,85%,39%); /* orange */
+}
--- a/browser/themes/pinstripe/devtools/csshtmltree.css
+++ b/browser/themes/pinstripe/devtools/csshtmltree.css
@@ -141,17 +141,17 @@
  * CSS Rule View
  */
 
 .ruleview {
   background-color: white;
 }
 
 .ruleview-rule-source {
-  color: hsl(121,42%,43%); /* green */
+  color: hsl(90,2%,46%); /* grey */
   -moz-padding-start: 5px;
   cursor: pointer;
   text-align: right;
   float: right;
   -moz-user-select: -moz-none;
 }
 
 .ruleview-rule-inheritance {
@@ -228,17 +228,17 @@
 
 .ruleview-newproperty {
   /* (enable checkbox width: 12px) + (expander width: 15px) */
   -moz-margin-start: 27px;
 }
 
 .ruleview-propertyname {
   padding: 1px 0;
-  color: hsl(210,100%,38%); /* blue */
+  color: hsl(276,44%,45%); /* purple */
 }
 
 .ruleview-propertyvalue {
   padding: 1px 0;
 }
 
 .ruleview-namecontainer,
 .ruleview-propertycontainer,
--- a/browser/themes/pinstripe/devtools/markup-view.css
+++ b/browser/themes/pinstripe/devtools/markup-view.css
@@ -4,42 +4,29 @@
 
 * {
   padding: 0;
   margin: 0;
 }
 
 body {
   font: message-box;
-  background-color: #131c26;
-  color: #8fa1b2;
+  color: hsl(0,0%,50%);
 }
 
-.tagname {
-  color: #a673bf;
-}
-
-.attrname {
-  color: #b26b47;
-}
-
-.attrvalue {
-  color: #3689b2;
+.text {
+  color: black;
 }
 
 .newattr {
   cursor: pointer;
 }
 
-.comment {
-  color: #5c6773;
-}
-
 .selected {
-  background-color: #253847;
+  background-color: hsl(0,0%,90%);
 }
 
 /* Give some padding to focusable elements to match the editor input
  * that will replace them. */
 span[tabindex] {
   display: inline-block;
   padding: 1px 0;
 }
--- a/browser/themes/pinstripe/devtools/orion.css
+++ b/browser/themes/pinstripe/devtools/orion.css
@@ -1,31 +1,31 @@
 /* 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/. */
 
 .viewContainer {
-  background: #cddae5; /* This will be seen as the continuation of the ruler */
+  background: hsl(0,0%,89%); /* This will be seen as the continuation of the ruler */
   font-family: monospace;
   font-size: inherit; /* inherit browser's default monospace font size */
 }
 
 .view {
   color: black; /* Default text color */
-  background: #f0f0ff; /* Background of the editor */
+  background: white; /* Background of the editor */
   padding-left: 4px;
 }
 
 .readonly > .view {
-  background: #f0f0ff;
+  background: #fdfefd; /* super light green */
 }
 
 .ruler {
-  background: #cddae5;
-  color: #7a8a99;
+  background: hsl(0,0%,89%);
+  color: hsl(0,0%,55%);
 }
 .ruler.annotations {
   width: 16px;
   padding-left: 4px;
 }
 .ruler.lines {
   border-right: 1px solid #b4c4d3;
   min-width: 1.4em;
@@ -100,48 +100,42 @@
 }
 .annotationRange.task {
   outline: 1px dashed rgba(0, 255, 0, 0.5);
 }
 .annotationRange.matchingBracket {
   outline: 1px solid grey;
 }
 
-.token_singleline_comment {
-  color: #45a946; /* green */
-}
-
-.token_multiline_comment {
-  color: #45a946; /* green */
-}
-
-.token_doc_comment {
-  color: #45a946; /* green */
+.token_singleline_comment,
+.token_multiline_comment,
+.token_doc_comment  {
+  color: hsl(90,2%,50%); /* grey */
 }
 
 .token_doc_html_markup {
   color: #dd0058; /* purple */
 }
 
 .token_doc_tag {
   color: #dd0058; /* purple */
 }
 
 .token_task_tag { /* "TODO" */
   color: black;
   background: yellow;
 }
 
 .token_string {
-  color: #1e66b1; /* blue */
+  color: hsl(72,100%,27%); /* green */
   font-style: italic;
 }
 
 .token_keyword {
-  color: #dd0058; /* purple */
+  color: hsl(276,44%,45%); /* purple */
 }
 
 .token_space {
   /* images/white_space.png */
   background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAIAAABv85FHAAAABnRSTlMA/wAAAACkwsAdAAAAIUlEQVR4nGP4z8CAC+GUIEXuABhgkTuABEiRw2cmae4EAH05X7xDolNRAAAAAElFTkSuQmCC");
   background-repeat: no-repeat;
   background-position: center center;
 }
@@ -150,42 +144,41 @@
   /* images/white_tab.png */
   background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAJCAIAAACJ2loDAAAABnRSTlMA/wD/AP83WBt9AAAAMklEQVR4nGP4TwRgoK6i52c3bz5w6zMSA6tJn28d2Lx589nnCAYu63AaSLxJRLoJPwAAeNk0aG4opfMAAAAASUVORK5CYII=");
   background-repeat: no-repeat;
   background-position: left center;
 }
 
 .line_caret,
 .annotationLine.currentLine { /* Current line */
-  background: #dae2ee; /* lighter than the background */
+  background: hsl(208, 93%, 94%);
 }
 
 .readonly .line_caret,
 .readonly .annotationLine.currentLine {
-  background: #cddae5; /* a bit darker than the background */
+  background: hsl(208, 80%, 90%);
 }
 
 /* Styling for html syntax highlighting */
 .entity-name-tag {
-  color: #dd0058; /* purple */
+  color: hsl(208,48%,40%); /* blue */
 }
 
 .entity-other-attribute-name {
-  color: #dd0058; /* purple */
+  color: hsl(208,48%,40%); /* blue */
 }
 
 .punctuation-definition-comment {
-  color: #45a946; /* green */
+  color: hsl(90,2%,50%); /* grey */
 }
 
 .comment {
-  color: #45a946; /* green */
+  color: hsl(90,2%,50%); /* grey */
 }
 
 .string-quoted {
-  color: #1e66b1; /* blue */
-  font-style: italic;
+  color: hsl(24,85%,39%); /* orange */
 }
 
 .invalid {
   color: red;
   font-weight: bold;
 }
--- a/browser/themes/winstripe/devtools/common.css
+++ b/browser/themes/winstripe/devtools/common.css
@@ -190,8 +190,38 @@
   border: 0;
   -moz-border-start: 1px solid #242b33;
   min-width: 0;
   width: 3px;
   background-color: transparent;
   -moz-margin-end: -3px;
   position: relative;
 }
+
+/* Theme */
+
+.devtools-theme-background {
+  background-color: white;
+}
+
+.devtools-theme-comment {
+  color: hsl(90,2%,46%); /* grey */
+}
+
+.devtools-theme-keyword {
+  color: hsl(276,44%,45%); /* purple */
+}
+
+.devtools-theme-string {
+  color: hsl(72,100%,27%); /* green */
+}
+
+.devtools-theme-tagname {
+  color: hsl(208,81%,21%); /* dark blue */
+}
+
+.devtools-theme-attrname {
+  color: hsl(208,56%,40%); /* blue */
+}
+
+.devtools-theme-attrvalue {
+  color: hsl(24,85%,39%); /* orange */
+}
--- a/browser/themes/winstripe/devtools/csshtmltree.css
+++ b/browser/themes/winstripe/devtools/csshtmltree.css
@@ -141,17 +141,17 @@
  * CSS Rule View
  */
 
 .ruleview {
   background-color: white;
 }
 
 .ruleview-rule-source {
-  color: hsl(121,42%,43%); /* green */
+  color: hsl(90,2%,46%); /* grey */
   -moz-padding-start: 5px;
   cursor: pointer;
   text-align: right;
   float: right;
   -moz-user-select: -moz-none;
 }
 
 .ruleview-rule-inheritance {
@@ -228,17 +228,17 @@
 
 .ruleview-newproperty {
   /* (enable checkbox width: 12px) + (expander width: 15px) */
   -moz-margin-start: 27px;
 }
 
 .ruleview-propertyname {
   padding: 1px 0;
-  color: hsl(210,100%,38%); /* blue */
+  color: hsl(276,44%,45%); /* purple */
 }
 
 .ruleview-propertyvalue {
   padding: 1px 0;
 }
 
 .ruleview-namecontainer,
 .ruleview-propertycontainer,
--- a/browser/themes/winstripe/devtools/markup-view.css
+++ b/browser/themes/winstripe/devtools/markup-view.css
@@ -4,42 +4,29 @@
 
 * {
   padding: 0;
   margin: 0;
 }
 
 body {
   font: message-box;
-  background-color: #131c26;
-  color: #8fa1b2;
+  color: hsl(0,0%,50%);
 }
 
-.tagname {
-  color: #a673bf;
-}
-
-.attrname {
-  color: #b26b47;
-}
-
-.attrvalue {
-  color: #3689b2;
+.text {
+  color: black;
 }
 
 .newattr {
   cursor: pointer;
 }
 
-.comment {
-  color: #5c6773;
-}
-
 .selected {
-  background-color: #253847;
+  background-color: hsl(0,0%,90%);
 }
 
 /* Give some padding to focusable elements to match the editor input
  * that will replace them. */
 span[tabindex] {
   display: inline-block;
   padding: 1px 0;
 }
--- a/browser/themes/winstripe/devtools/orion.css
+++ b/browser/themes/winstripe/devtools/orion.css
@@ -1,31 +1,31 @@
 /* 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/. */
 
 .viewContainer {
-  background: #cddae5; /* This will be seen as the continuation of the ruler */
+  background: hsl(0,0%,89%); /* This will be seen as the continuation of the ruler */
   font-family: monospace;
   font-size: inherit; /* inherit browser's default monospace font size */
 }
 
 .view {
   color: black; /* Default text color */
-  background: #f0f0ff; /* Background of the editor */
+  background: white; /* Background of the editor */
   padding-left: 4px;
 }
 
 .readonly > .view {
-  background: #f0f0ff;
+  background: #fdfefd; /* super light green */
 }
 
 .ruler {
-  background: #cddae5;
-  color: #7a8a99;
+  background: hsl(0,0%,89%);
+  color: hsl(0,0%,55%);
 }
 .ruler.annotations {
   width: 16px;
   padding-left: 4px;
 }
 .ruler.lines {
   border-right: 1px solid #b4c4d3;
   min-width: 1.4em;
@@ -100,48 +100,42 @@
 }
 .annotationRange.task {
   outline: 1px dashed rgba(0, 255, 0, 0.5);
 }
 .annotationRange.matchingBracket {
   outline: 1px solid grey;
 }
 
-.token_singleline_comment {
-  color: #45a946; /* green */
-}
-
-.token_multiline_comment {
-  color: #45a946; /* green */
-}
-
-.token_doc_comment {
-  color: #45a946; /* green */
+.token_singleline_comment,
+.token_multiline_comment,
+.token_doc_comment  {
+  color: hsl(90,2%,50%); /* grey */
 }
 
 .token_doc_html_markup {
   color: #dd0058; /* purple */
 }
 
 .token_doc_tag {
   color: #dd0058; /* purple */
 }
 
 .token_task_tag { /* "TODO" */
   color: black;
   background: yellow;
 }
 
 .token_string {
-  color: #1e66b1; /* blue */
+  color: hsl(72,100%,27%); /* green */
   font-style: italic;
 }
 
 .token_keyword {
-  color: #dd0058; /* purple */
+  color: hsl(276,44%,45%); /* purple */
 }
 
 .token_space {
   /* images/white_space.png */
   background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAIAAABv85FHAAAABnRSTlMA/wAAAACkwsAdAAAAIUlEQVR4nGP4z8CAC+GUIEXuABhgkTuABEiRw2cmae4EAH05X7xDolNRAAAAAElFTkSuQmCC");
   background-repeat: no-repeat;
   background-position: center center;
 }
@@ -150,42 +144,41 @@
   /* images/white_tab.png */
   background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAJCAIAAACJ2loDAAAABnRSTlMA/wD/AP83WBt9AAAAMklEQVR4nGP4TwRgoK6i52c3bz5w6zMSA6tJn28d2Lx589nnCAYu63AaSLxJRLoJPwAAeNk0aG4opfMAAAAASUVORK5CYII=");
   background-repeat: no-repeat;
   background-position: left center;
 }
 
 .line_caret,
 .annotationLine.currentLine { /* Current line */
-  background: #dae2ee; /* lighter than the background */
+  background: hsl(208, 93%, 94%);
 }
 
 .readonly .line_caret,
 .readonly .annotationLine.currentLine {
-  background: #cddae5; /* a bit darker than the background */
+  background: hsl(208, 80%, 90%);
 }
 
 /* Styling for html syntax highlighting */
 .entity-name-tag {
-  color: #dd0058; /* purple */
+  color: hsl(208,48%,40%); /* blue */
 }
 
 .entity-other-attribute-name {
-  color: #dd0058; /* purple */
+  color: hsl(208,48%,40%); /* blue */
 }
 
 .punctuation-definition-comment {
-  color: #45a946; /* green */
+  color: hsl(90,2%,50%); /* grey */
 }
 
 .comment {
-  color: #45a946; /* green */
+  color: hsl(90,2%,50%); /* grey */
 }
 
 .string-quoted {
-  color: #1e66b1; /* blue */
-  font-style: italic;
+  color: hsl(24,85%,39%); /* orange */
 }
 
 .invalid {
   color: red;
   font-weight: bold;
 }
--- a/content/base/public/FragmentOrElement.h
+++ b/content/base/public/FragmentOrElement.h
@@ -405,17 +405,17 @@ public:
   };
 
 protected:
   // Override from nsINode
   virtual nsINode::nsSlots* CreateSlots();
 
   nsDOMSlots *DOMSlots()
   {
-    return static_cast<nsDOMSlots*>(GetSlots());
+    return static_cast<nsDOMSlots*>(Slots());
   }
 
   nsDOMSlots *GetExistingDOMSlots() const
   {
     return static_cast<nsDOMSlots*>(GetExistingSlots());
   }
 
   friend class ::ContentUnbinder;
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -785,35 +785,31 @@ public:
    * remove itself in case it dies before the node.  If an observer is added
    * while observers are being notified, it may also be notified.  In general,
    * adding observers while inside a notification is not a good idea.  An
    * observer that is already observing the node must not be added without
    * being removed first.
    */
   void AddMutationObserver(nsIMutationObserver* aMutationObserver)
   {
-    nsSlots* s = GetSlots();
-    if (s) {
-      NS_ASSERTION(s->mMutationObservers.IndexOf(aMutationObserver) ==
-                   nsTArray<int>::NoIndex,
-                   "Observer already in the list");
-      s->mMutationObservers.AppendElement(aMutationObserver);
-    }
+    nsSlots* s = Slots();
+    NS_ASSERTION(s->mMutationObservers.IndexOf(aMutationObserver) ==
+                 nsTArray<int>::NoIndex,
+                 "Observer already in the list");
+    s->mMutationObservers.AppendElement(aMutationObserver);
   }
 
   /**
    * Same as above, but only adds the observer if its not observing
    * the node already.
    */
   void AddMutationObserverUnlessExists(nsIMutationObserver* aMutationObserver)
   {
-    nsSlots* s = GetSlots();
-    if (s) {
-      s->mMutationObservers.AppendElementUnlessExists(aMutationObserver);
-    }
+    nsSlots* s = Slots();
+    s->mMutationObservers.AppendElementUnlessExists(aMutationObserver);
   }
 
   /**
    * Removes a mutation observer.
    */
   void RemoveMutationObserver(nsIMutationObserver* aMutationObserver)
   {
     nsSlots* s = GetExistingSlots();
@@ -889,21 +885,21 @@ public:
   };
 
   /**
    * Functions for managing flags and slots
    */
 #ifdef DEBUG
   nsSlots* DebugGetSlots()
   {
-    return GetSlots();
+    return Slots();
   }
 #endif
 
-  bool HasFlag(PtrBits aFlag) const
+  bool HasFlag(uintptr_t aFlag) const
   {
     return !!(GetFlags() & aFlag);
   }
 
   uint32_t GetFlags() const
   {
     return mFlags;
   }
@@ -1415,32 +1411,34 @@ public:
    * Returns the length of this node, as specified at
    * <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-length>
    */
   uint32_t Length() const;
 
 protected:
 
   // Override this function to create a custom slots class.
+  // Must not return null.
   virtual nsINode::nsSlots* CreateSlots();
 
   bool HasSlots() const
   {
     return mSlots != nullptr;
   }
 
   nsSlots* GetExistingSlots() const
   {
     return mSlots;
   }
 
-  nsSlots* GetSlots()
+  nsSlots* Slots()
   {
     if (!HasSlots()) {
       mSlots = CreateSlots();
+      MOZ_ASSERT(mSlots);
     }
     return GetExistingSlots();
   }
 
   nsTObserverArray<nsIMutationObserver*> *GetMutationObservers()
   {
     return HasSlots() ? &GetExistingSlots()->mMutationObservers : nullptr;
   }
--- a/content/base/src/FragmentOrElement.cpp
+++ b/content/base/src/FragmentOrElement.cpp
@@ -477,20 +477,19 @@ FragmentOrElement::GetChildrenList()
 
 
 NS_IMPL_ISUPPORTS1(nsNodeWeakReference,
                    nsIWeakReference)
 
 nsNodeWeakReference::~nsNodeWeakReference()
 {
   if (mNode) {
-    NS_ASSERTION(mNode->GetSlots() &&
-                 mNode->GetSlots()->mWeakReference == this,
+    NS_ASSERTION(mNode->Slots()->mWeakReference == this,
                  "Weak reference has wrong value");
-    mNode->GetSlots()->mWeakReference = nullptr;
+    mNode->Slots()->mWeakReference = nullptr;
   }
 }
 
 NS_IMETHODIMP
 nsNodeWeakReference::QueryReferent(const nsIID& aIID, void** aInstancePtr)
 {
   return mNode ? mNode->QueryInterface(aIID, aInstancePtr) :
                  NS_ERROR_NULL_POINTER;
@@ -504,19 +503,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
 NS_INTERFACE_MAP_END_AGGREGATED(mNode)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsNodeSupportsWeakRefTearoff)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsNodeSupportsWeakRefTearoff)
 
 NS_IMETHODIMP
 nsNodeSupportsWeakRefTearoff::GetWeakReference(nsIWeakReference** aInstancePtr)
 {
-  nsINode::nsSlots* slots = mNode->GetSlots();
-  NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY);
-
+  nsINode::nsSlots* slots = mNode->Slots();
   if (!slots->mWeakReference) {
     slots->mWeakReference = new nsNodeWeakReference(mNode);
     NS_ENSURE_TRUE(slots->mWeakReference, NS_ERROR_OUT_OF_MEMORY);
   }
 
   NS_ADDREF(*aInstancePtr = slots->mWeakReference);
 
   return NS_OK;
--- a/content/base/src/nsAttrName.h
+++ b/content/base/src/nsAttrName.h
@@ -11,76 +11,74 @@
 
 #ifndef nsAttrName_h___
 #define nsAttrName_h___
 
 #include "nsINodeInfo.h"
 #include "nsIAtom.h"
 #include "nsDOMString.h"
 
-typedef uintptr_t PtrBits;
-
 #define NS_ATTRNAME_NODEINFO_BIT 1
 class nsAttrName
 {
 public:
   nsAttrName(const nsAttrName& aOther)
     : mBits(aOther.mBits)
   {
     AddRefInternalName();
   }
 
   explicit nsAttrName(nsIAtom* aAtom)
-    : mBits(reinterpret_cast<PtrBits>(aAtom))
+    : mBits(reinterpret_cast<uintptr_t>(aAtom))
   {
     NS_ASSERTION(aAtom, "null atom-name in nsAttrName");
     NS_ADDREF(aAtom);
   }
 
   explicit nsAttrName(nsINodeInfo* aNodeInfo)
   {
     NS_ASSERTION(aNodeInfo, "null nodeinfo-name in nsAttrName");
     if (aNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
-      mBits = reinterpret_cast<PtrBits>(aNodeInfo->NameAtom());
+      mBits = reinterpret_cast<uintptr_t>(aNodeInfo->NameAtom());
       NS_ADDREF(aNodeInfo->NameAtom());
     }
     else {
-      mBits = reinterpret_cast<PtrBits>(aNodeInfo) |
+      mBits = reinterpret_cast<uintptr_t>(aNodeInfo) |
               NS_ATTRNAME_NODEINFO_BIT;
       NS_ADDREF(aNodeInfo);
     }
   }
 
   ~nsAttrName()
   {
     ReleaseInternalName();
   }
 
   void SetTo(nsINodeInfo* aNodeInfo)
   {
     NS_ASSERTION(aNodeInfo, "null nodeinfo-name in nsAttrName");
 
     ReleaseInternalName();
     if (aNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
-      mBits = reinterpret_cast<PtrBits>(aNodeInfo->NameAtom());
+      mBits = reinterpret_cast<uintptr_t>(aNodeInfo->NameAtom());
       NS_ADDREF(aNodeInfo->NameAtom());
     }
     else {
-      mBits = reinterpret_cast<PtrBits>(aNodeInfo) |
+      mBits = reinterpret_cast<uintptr_t>(aNodeInfo) |
               NS_ATTRNAME_NODEINFO_BIT;
       NS_ADDREF(aNodeInfo);
     }
   }
 
   void SetTo(nsIAtom* aAtom)
   {
     NS_ASSERTION(aAtom, "null atom-name in nsAttrName");
 
     ReleaseInternalName();
-    mBits = reinterpret_cast<PtrBits>(aAtom);
+    mBits = reinterpret_cast<uintptr_t>(aAtom);
     NS_ADDREF(aAtom);
   }
 
   bool IsAtom() const
   {
     return !(mBits & NS_ATTRNAME_NODEINFO_BIT);
   }
 
@@ -99,17 +97,17 @@ public:
   bool Equals(const nsAttrName& aOther) const
   {
     return mBits == aOther.mBits;
   }
 
   // Faster comparison in the case we know the namespace is null
   bool Equals(nsIAtom* aAtom) const
   {
-    return reinterpret_cast<PtrBits>(aAtom) == mBits;
+    return reinterpret_cast<uintptr_t>(aAtom) == mBits;
   }
 
   bool Equals(nsIAtom* aLocalName, int32_t aNamespaceID) const
   {
     if (aNamespaceID == kNameSpaceID_None) {
       return Equals(aLocalName);
     }
     return !IsAtom() && NodeInfo()->Equals(aLocalName, aNamespaceID);
@@ -175,17 +173,17 @@ public:
     // mBits and uint32_t might have different size. This should silence
     // any warnings or compile-errors. This is what the implementation of
     // NS_PTR_TO_INT32 does to take care of the same problem.
     return mBits - 0;
   }
 
   bool IsSmaller(nsIAtom* aOther) const
   {
-    return mBits < reinterpret_cast<PtrBits>(aOther);
+    return mBits < reinterpret_cast<uintptr_t>(aOther);
   }
 
 private:
 
   void AddRefInternalName()
   {
     // Since both nsINodeInfo and nsIAtom inherit nsISupports as its first
     // interface we can safely assume that it's first in the vtable
@@ -200,12 +198,12 @@ private:
     // Since both nsINodeInfo and nsIAtom inherit nsISupports as its first
     // interface we can safely assume that it's first in the vtable
     nsISupports* name = reinterpret_cast<nsISupports *>
                                         (mBits & ~NS_ATTRNAME_NODEINFO_BIT);
 
     NS_RELEASE(name);
   }
 
-  PtrBits mBits;
+  uintptr_t mBits;
 };
 
 #endif
--- a/content/base/src/nsAttrValue.cpp
+++ b/content/base/src/nsAttrValue.cpp
@@ -559,17 +559,17 @@ void
 nsAttrValue::SetTo(const nsSVGViewBox& aValue, const nsAString* aSerialized)
 {
   SetSVGType(eSVGViewBox, &aValue, aSerialized);
 }
 
 void
 nsAttrValue::SwapValueWith(nsAttrValue& aOther)
 {
-  PtrBits tmp = aOther.mBits;
+  uintptr_t tmp = aOther.mBits;
   aOther.mBits = mBits;
   mBits = tmp;
 }
 
 void
 nsAttrValue::ToString(nsAString& aResult) const
 {
   MiscContainer* cont = nullptr;
@@ -1531,17 +1531,17 @@ nsAttrValue::SetColorValue(nscolor aColo
     return;
   }
 
   MiscContainer* cont = EnsureEmptyMiscContainer();
   cont->mValue.mColor = aColor;
   cont->mType = eColor;
 
   // Save the literal string we were passed for round-tripping.
-  cont->mStringBits = reinterpret_cast<PtrBits>(buf) | eStringBase;
+  cont->mStringBits = reinterpret_cast<uintptr_t>(buf) | eStringBase;
 }
 
 bool
 nsAttrValue::ParseColor(const nsAString& aString)
 {
   ResetIfSet();
 
   // FIXME (partially, at least): HTML5's algorithm says we shouldn't do
@@ -1708,22 +1708,22 @@ nsAttrValue::SetMiscAtomOrString(const n
     //   for enumerated values that are not limited enumerated.
     // Add other types as needed.
     NS_ASSERTION(len || Type() == eCSSStyleRule || Type() == eEnum,
                  "Empty string?");
     MiscContainer* cont = GetMiscContainer();
     if (len <= NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM) {
       nsIAtom* atom = NS_NewAtom(*aValue);
       if (atom) {
-        cont->mStringBits = reinterpret_cast<PtrBits>(atom) | eAtomBase;
+        cont->mStringBits = reinterpret_cast<uintptr_t>(atom) | eAtomBase;
       }
     } else {
       nsStringBuffer* buf = GetStringBuffer(*aValue);
       if (buf) {
-        cont->mStringBits = reinterpret_cast<PtrBits>(buf) | eStringBase;
+        cont->mStringBits = reinterpret_cast<uintptr_t>(buf) | eStringBase;
       }
     }
   }
 }
 
 void
 nsAttrValue::ResetMiscAtomOrString()
 {
--- a/content/base/src/nsAttrValue.h
+++ b/content/base/src/nsAttrValue.h
@@ -15,17 +15,16 @@
 #include "nsStringGlue.h"
 #include "nsStringBuffer.h"
 #include "nsColor.h"
 #include "nsCaseTreatment.h"
 #include "nsMargin.h"
 #include "nsCOMPtr.h"
 #include "SVGAttrValueWrapper.h"
 
-typedef uintptr_t PtrBits;
 class nsAString;
 class nsIAtom;
 class nsIDocument;
 template<class E, class A> class nsTArray;
 struct nsTArrayDefaultAllocator;
 class nsStyledElementNotElementCSSInlineStyle;
 struct MiscContainer;
 
@@ -34,30 +33,30 @@ namespace css {
 class StyleRule;
 struct URLValue;
 struct ImageValue;
 }
 }
 
 #define NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM 12
 
-#define NS_ATTRVALUE_BASETYPE_MASK (PtrBits(3))
+#define NS_ATTRVALUE_BASETYPE_MASK (uintptr_t(3))
 #define NS_ATTRVALUE_POINTERVALUE_MASK (~NS_ATTRVALUE_BASETYPE_MASK)
 
 #define NS_ATTRVALUE_INTEGERTYPE_BITS 4
-#define NS_ATTRVALUE_INTEGERTYPE_MASK (PtrBits((1 << NS_ATTRVALUE_INTEGERTYPE_BITS) - 1))
+#define NS_ATTRVALUE_INTEGERTYPE_MASK (uintptr_t((1 << NS_ATTRVALUE_INTEGERTYPE_BITS) - 1))
 #define NS_ATTRVALUE_INTEGERTYPE_MULTIPLIER (1 << NS_ATTRVALUE_INTEGERTYPE_BITS)
 #define NS_ATTRVALUE_INTEGERTYPE_MAXVALUE ((1 << (31 - NS_ATTRVALUE_INTEGERTYPE_BITS)) - 1)
 #define NS_ATTRVALUE_INTEGERTYPE_MINVALUE (-NS_ATTRVALUE_INTEGERTYPE_MAXVALUE - 1)
 
 #define NS_ATTRVALUE_ENUMTABLEINDEX_BITS (32 - 16 - NS_ATTRVALUE_INTEGERTYPE_BITS)
 #define NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER (1 << (NS_ATTRVALUE_ENUMTABLEINDEX_BITS - 1))
 #define NS_ATTRVALUE_ENUMTABLEINDEX_MAXVALUE (NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER - 1)
 #define NS_ATTRVALUE_ENUMTABLEINDEX_MASK \
-  (PtrBits((((1 << NS_ATTRVALUE_ENUMTABLEINDEX_BITS) - 1) &~ NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER)))
+  (uintptr_t((((1 << NS_ATTRVALUE_ENUMTABLEINDEX_BITS) - 1) &~ NS_ATTRVALUE_ENUMTABLE_VALUE_NEEDS_TO_UPPER)))
 
 /**
  * A class used to construct a nsString from a nsStringBuffer (we might
  * want to move this to nsString at some point).
  */
 class nsCheapString : public nsString {
 public:
   nsCheapString(nsStringBuffer* aBuf)
@@ -423,17 +422,17 @@ private:
                           bool* aIsPercent = nullptr) const;
   // Given an enum table and a particular entry in that table, return
   // the actual integer value we should store.
   int32_t EnumTableEntryToValue(const EnumTable* aEnumTable,
                                 const EnumTable* aTableEntry);  
 
   static nsTArray<const EnumTable*, nsTArrayDefaultAllocator>* sEnumTableArray;
 
-  PtrBits mBits;
+  uintptr_t mBits;
 };
 
 inline const nsAttrValue&
 nsAttrValue::operator=(const nsAttrValue& aOther)
 {
   SetTo(aOther);
   return *this;
 }
--- a/content/base/src/nsAttrValueInlines.h
+++ b/content/base/src/nsAttrValueInlines.h
@@ -1,25 +1,27 @@
 /* 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/. */
 
 #ifndef nsAttrValueInlines_h__
 #define nsAttrValueInlines_h__
 
+#include "mozilla/StandardInteger.h"
+
 struct MiscContainer
 {
   typedef nsAttrValue::ValueType ValueType;
 
   ValueType mType;
   // mStringBits points to either nsIAtom* or nsStringBuffer* and is used when
   // mType isn't mCSSStyleRule.
   // Note eStringBase and eAtomBase is used also to handle the type of
   // mStringBits.
-  PtrBits mStringBits;
+  uintptr_t mStringBits;
   union {
     struct {
       union {
         int32_t mInteger;
         nscolor mColor;
         uint32_t mEnumValue;
         int32_t mPercent;
         mozilla::css::StyleRule* mCSSStyleRule;
@@ -178,17 +180,17 @@ nsAttrValue::IsSVGType(ValueType aType) 
   return aType >= eSVGTypesBegin && aType <= eSVGTypesEnd;
 }
 
 inline void
 nsAttrValue::SetPtrValueAndType(void* aValue, ValueBaseType aType)
 {
   NS_ASSERTION(!(NS_PTR_TO_INT32(aValue) & ~NS_ATTRVALUE_POINTERVALUE_MASK),
                "pointer not properly aligned, this will crash");
-  mBits = reinterpret_cast<PtrBits>(aValue) | aType;
+  mBits = reinterpret_cast<intptr_t>(aValue) | aType;
 }
 
 inline void
 nsAttrValue::ResetIfSet()
 {
   if (mBits) {
     Reset();
   }
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -6923,19 +6923,17 @@ nsContentUtils::ReleaseWrapper(nsISuppor
                                nsWrapperCache* aCache)
 {
   if (aCache->PreservingWrapper()) {
     // PreserveWrapper puts new DOM bindings in the JS holders hash, but they
     // can also be in the DOM expando hash, so we need to try to remove them
     // from both here.
     JSObject* obj = aCache->GetWrapperPreserveColor();
     if (aCache->IsDOMBinding() && obj) {
-      JSCompartment *compartment = js::GetObjectCompartment(obj);
-      xpc::CompartmentPrivate *priv =
-        static_cast<xpc::CompartmentPrivate *>(JS_GetCompartmentPrivate(compartment));
+      xpc::CompartmentPrivate *priv = xpc::GetCompartmentPrivate(obj);
       priv->RemoveDOMExpandoObject(obj);
     }
     DropJSObjects(aScriptObjectHolder);
 
     aCache->SetPreservingWrapper(false);
   }
 }
 
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -1981,17 +1981,17 @@ nsDocument::Init()
     return NS_ERROR_ALREADY_INITIALIZED;
   }
 
   mIdentifierMap.Init();
   mStyledLinks.Init();
   mRadioGroups.Init();
 
   // Force initialization.
-  nsINode::nsSlots* slots = GetSlots();
+  nsINode::nsSlots* slots = Slots();
 
   // Prepend self as mutation-observer whether we need it or not (some
   // subclasses currently do, other don't). This is because the code in
   // nsNodeUtils always notifies the first observer first, expecting the
   // first observer to be the document.
   NS_ENSURE_TRUE(slots->mMutationObservers.PrependElementUnlessExists(static_cast<nsIMutationObserver*>(this)),
                  NS_ERROR_OUT_OF_MEMORY);
 
--- a/content/base/src/nsGenericDOMDataNode.cpp
+++ b/content/base/src/nsGenericDOMDataNode.cpp
@@ -453,25 +453,22 @@ nsGenericDOMDataNode::BindToTree(nsIDocu
                   "own binding parent");
 
   if (!aBindingParent && aParent) {
     aBindingParent = aParent->GetBindingParent();
   }
 
   // First set the binding parent
   if (aBindingParent) {
-    nsDataSlots *slots = GetDataSlots();
-    NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY);
-
     NS_ASSERTION(IsRootOfNativeAnonymousSubtree() ||
                  !HasFlag(NODE_IS_IN_ANONYMOUS_SUBTREE) ||
                  (aParent && aParent->IsInNativeAnonymousSubtree()),
                  "Trying to re-bind content from native anonymous subtree to "
                  "non-native anonymous parent!");
-    slots->mBindingParent = aBindingParent; // Weak, so no addref happens.
+    DataSlots()->mBindingParent = aBindingParent; // Weak, so no addref happens.
     if (aParent->IsInNativeAnonymousSubtree()) {
       SetFlags(NODE_IS_IN_ANONYMOUS_SUBTREE);
     }
   }
 
   // Set parent
   if (aParent) {
     if (!GetParent()) {
--- a/content/base/src/nsGenericDOMDataNode.h
+++ b/content/base/src/nsGenericDOMDataNode.h
@@ -269,19 +269,19 @@ protected:
      * @see nsIContent::GetBindingParent
      */
     nsIContent* mBindingParent;  // [Weak]
   };
 
   // Override from nsINode
   virtual nsINode::nsSlots* CreateSlots();
 
-  nsDataSlots *GetDataSlots()
+  nsDataSlots* DataSlots()
   {
-    return static_cast<nsDataSlots*>(GetSlots());
+    return static_cast<nsDataSlots*>(Slots());
   }
 
   nsDataSlots *GetExistingDataSlots() const
   {
     return static_cast<nsDataSlots*>(GetExistingSlots());
   }
 
   nsresult SplitText(uint32_t aOffset, nsIDOMText** aReturn);
--- a/content/base/src/nsGenericElement.h
+++ b/content/base/src/nsGenericElement.h
@@ -52,18 +52,16 @@ class nsEventChainVisitor;
 class nsEventListenerManager;
 class nsIScrollableFrame;
 class nsAttrValueOrString;
 class nsContentList;
 class nsDOMTokenList;
 class ContentUnbinder;
 struct nsRect;
 
-typedef uintptr_t PtrBits;
-
 /**
  * A generic base class for DOM elements, implementing many nsIContent,
  * nsIDOMNode and nsIDOMElement methods.
  */
 class nsGenericElement : public mozilla::dom::Element
 {
 public:
   nsGenericElement(already_AddRefed<nsINodeInfo> aNodeInfo);
--- a/content/base/src/nsINode.cpp
+++ b/content/base/src/nsINode.cpp
@@ -306,21 +306,17 @@ nsINode::GetSelectionRootContent(nsIPres
   NS_ENSURE_TRUE(content, nullptr);
   return nsContentUtils::IsInSameAnonymousTree(this, content) ?
            content : GetRootForContentSubtree(static_cast<nsIContent*>(this));
 }
 
 nsINodeList*
 nsINode::GetChildNodesList()
 {
-  nsSlots *slots = GetSlots();
-  if (!slots) {
-    return nullptr;
-  }
-
+  nsSlots* slots = Slots();
   if (!slots->mChildNodes) {
     slots->mChildNodes = new nsChildContentList(this);
     if (slots->mChildNodes) {
       NS_ADDREF(slots->mChildNodes);
     }
   }
 
   return slots->mChildNodes;
@@ -1118,21 +1114,21 @@ nsINode::Trace(nsINode *tmp, TraceCallba
 {
   nsContentUtils::TraceWrapper(tmp, cb, closure);
 }
 
 
 bool
 nsINode::UnoptimizableCCNode() const
 {
-  const PtrBits problematicFlags = (NODE_IS_ANONYMOUS |
-                                    NODE_IS_IN_ANONYMOUS_SUBTREE |
-                                    NODE_IS_NATIVE_ANONYMOUS_ROOT |
-                                    NODE_MAY_BE_IN_BINDING_MNGR |
-                                    NODE_IS_INSERTION_PARENT);
+  const uintptr_t problematicFlags = (NODE_IS_ANONYMOUS |
+                                      NODE_IS_IN_ANONYMOUS_SUBTREE |
+                                      NODE_IS_NATIVE_ANONYMOUS_ROOT |
+                                      NODE_MAY_BE_IN_BINDING_MNGR |
+                                      NODE_IS_INSERTION_PARENT);
   return HasFlag(problematicFlags) ||
          NodeType() == nsIDOMNode::ATTRIBUTE_NODE ||
          // For strange cases like xbl:content/xbl:children
          (IsElement() &&
           AsElement()->IsInNamespace(kNameSpaceID_XBL));
 }
 
 /* static */
--- a/content/base/src/nsPropertyTable.h
+++ b/content/base/src/nsPropertyTable.h
@@ -22,17 +22,16 @@
 
 #ifndef nsPropertyTable_h_
 #define nsPropertyTable_h_
 
 #include "nscore.h"
 #include "prtypes.h"
 
 class nsIAtom;
-typedef uintptr_t PtrBits;
 
 typedef void
 (*NSPropertyFunc)(void           *aObject,
                   nsIAtom        *aPropertyName,
                   void           *aPropertyValue,
                   void           *aData);
 
 /**
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -2869,34 +2869,24 @@ nsGenericHTMLElement::SetBoolAttr(nsIAto
 {
   if (aValue) {
     return SetAttr(kNameSpaceID_None, aAttr, EmptyString(), true);
   }
 
   return UnsetAttr(kNameSpaceID_None, aAttr, true);
 }
 
-nsresult
-nsGenericHTMLElement::GetBoolAttr(nsIAtom* aAttr, bool* aValue) const
-{
-  *aValue = HasAttr(kNameSpaceID_None, aAttr);
-  return NS_OK;
-}
-
-nsresult
-nsGenericHTMLElement::GetIntAttr(nsIAtom* aAttr, int32_t aDefault, int32_t* aResult)
+int32_t
+nsGenericHTMLElement::GetIntAttr(nsIAtom* aAttr, int32_t aDefault) const
 {
   const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(aAttr);
   if (attrVal && attrVal->Type() == nsAttrValue::eInteger) {
-    *aResult = attrVal->GetIntegerValue();
+    return attrVal->GetIntegerValue();
   }
-  else {
-    *aResult = aDefault;
-  }
-  return NS_OK;
+  return aDefault;
 }
 
 nsresult
 nsGenericHTMLElement::SetIntAttr(nsIAtom* aAttr, int32_t aValue)
 {
   nsAutoString value;
   value.AppendInt(aValue);
 
@@ -3550,18 +3540,17 @@ nsGenericHTMLFormElement::IntrinsicState
                    "Default submit element that isn't a submit control.");
       // We are the default submit element (:default)
       state |= NS_EVENT_STATE_DEFAULT;
   }
 
   // Make the text controls read-write
   if (!state.HasState(NS_EVENT_STATE_MOZ_READWRITE) &&
       IsTextControl(false)) {
-    bool roState;
-    GetBoolAttr(nsGkAtoms::readonly, &roState);
+    bool roState = GetBoolAttr(nsGkAtoms::readonly);
 
     if (!roState) {
       state |= NS_EVENT_STATE_MOZ_READWRITE;
       state &= ~NS_EVENT_STATE_MOZ_READONLY;
     }
   }
 
   return state;
--- a/content/html/content/src/nsGenericHTMLElement.h
+++ b/content/html/content/src/nsGenericHTMLElement.h
@@ -640,17 +640,20 @@ protected:
   /**
    * Helper method for NS_IMPL_BOOL_ATTR macro.
    * Gets value of boolean attribute. Only works for attributes in null
    * namespace.
    *
    * @param aAttr    name of attribute.
    * @param aValue   Boolean value of attribute.
    */
-  NS_HIDDEN_(nsresult) GetBoolAttr(nsIAtom* aAttr, bool* aValue) const;
+  NS_HIDDEN_(bool) GetBoolAttr(nsIAtom* aAttr) const
+  {
+    return HasAttr(kNameSpaceID_None, aAttr);
+  }
 
   /**
    * Helper method for NS_IMPL_BOOL_ATTR macro.
    * Sets value of boolean attribute by removing attribute or setting it to
    * the empty string. Only works for attributes in null namespace.
    *
    * @param aAttr    name of attribute.
    * @param aValue   Boolean value of attribute.
@@ -660,19 +663,18 @@ protected:
   /**
    * Helper method for NS_IMPL_INT_ATTR macro.
    * Gets the integer-value of an attribute, returns specified default value
    * if the attribute isn't set or isn't set to an integer. Only works for
    * attributes in null namespace.
    *
    * @param aAttr    name of attribute.
    * @param aDefault default-value to return if attribute isn't set.
-   * @param aResult  result value [out]
    */
-  NS_HIDDEN_(nsresult) GetIntAttr(nsIAtom* aAttr, int32_t aDefault, int32_t* aValue);
+  NS_HIDDEN_(int32_t) GetIntAttr(nsIAtom* aAttr, int32_t aDefault) const;
 
   /**
    * Helper method for NS_IMPL_INT_ATTR macro.
    * Sets value of attribute to specified integer. Only works for attributes
    * in null namespace.
    *
    * @param aAttr    name of attribute.
    * @param aValue   Integer value of attribute.
@@ -1019,17 +1021,18 @@ protected:
  * A macro to implement the getter and setter for a given boolean
  * valued content property. The method uses the generic GetAttr and
  * SetAttr methods.
  */
 #define NS_IMPL_BOOL_ATTR(_class, _method, _atom)                     \
   NS_IMETHODIMP                                                       \
   _class::Get##_method(bool* aValue)                                \
   {                                                                   \
-    return GetBoolAttr(nsGkAtoms::_atom, aValue);                   \
+    *aValue = GetBoolAttr(nsGkAtoms::_atom);                          \
+    return NS_OK;                                                     \
   }                                                                   \
   NS_IMETHODIMP                                                       \
   _class::Set##_method(bool aValue)                                 \
   {                                                                   \
     return SetBoolAttr(nsGkAtoms::_atom, aValue);                   \
   }
 
 /**
@@ -1039,22 +1042,23 @@ protected:
  */
 #define NS_IMPL_INT_ATTR(_class, _method, _atom)                    \
   NS_IMPL_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, 0)
 
 #define NS_IMPL_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default)  \
   NS_IMETHODIMP                                                           \
   _class::Get##_method(int32_t* aValue)                                   \
   {                                                                       \
-    return GetIntAttr(nsGkAtoms::_atom, _default, aValue);              \
+    *aValue = GetIntAttr(nsGkAtoms::_atom, _default);                     \
+    return NS_OK;                                                         \
   }                                                                       \
   NS_IMETHODIMP                                                           \
   _class::Set##_method(int32_t aValue)                                    \
   {                                                                       \
-    return SetIntAttr(nsGkAtoms::_atom, aValue);                        \
+    return SetIntAttr(nsGkAtoms::_atom, aValue);                          \
   }
 
 /**
  * A macro to implement the getter and setter for a given unsigned integer
  * valued content property. The method uses GetUnsignedIntAttr and
  * SetUnsignedIntAttr methods.
  */
 #define NS_IMPL_UINT_ATTR(_class, _method, _atom)                         \
@@ -1157,17 +1161,18 @@ protected:
  */
 #define NS_IMPL_NON_NEGATIVE_INT_ATTR(_class, _method, _atom)             \
   NS_IMPL_NON_NEGATIVE_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, -1)
 
 #define NS_IMPL_NON_NEGATIVE_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default)  \
   NS_IMETHODIMP                                                           \
   _class::Get##_method(int32_t* aValue)                                   \
   {                                                                       \
-    return GetIntAttr(nsGkAtoms::_atom, _default, aValue);                \
+    *aValue = GetIntAttr(nsGkAtoms::_atom, _default);                     \
+    return NS_OK;                                                         \
   }                                                                       \
   NS_IMETHODIMP                                                           \
   _class::Set##_method(int32_t aValue)                                    \
   {                                                                       \
     if (aValue < 0) {                                                     \
       return NS_ERROR_DOM_INDEX_SIZE_ERR;                                 \
     }                                                                     \
     return SetIntAttr(nsGkAtoms::_atom, aValue);                          \
--- a/content/html/content/src/nsHTMLScriptElement.cpp
+++ b/content/html/content/src/nsHTMLScriptElement.cpp
@@ -212,21 +212,18 @@ NS_IMPL_URI_ATTR(nsHTMLScriptElement, Sr
 NS_IMPL_STRING_ATTR(nsHTMLScriptElement, Type, type)
 NS_IMPL_STRING_ATTR(nsHTMLScriptElement, HtmlFor, _for)
 NS_IMPL_STRING_ATTR(nsHTMLScriptElement, Event, event)
 NS_IMPL_STRING_ATTR(nsHTMLScriptElement, CrossOrigin, crossorigin)
 
 nsresult
 nsHTMLScriptElement::GetAsync(bool* aValue)
 {
-  if (mForceAsync) {
-    *aValue = true;
-    return NS_OK;
-  }
-  return GetBoolAttr(nsGkAtoms::async, aValue);
+  *aValue = mForceAsync || GetBoolAttr(nsGkAtoms::async);
+  return NS_OK;
 }
 
 nsresult
 nsHTMLScriptElement::SetAsync(bool aValue)
 {
   mForceAsync = false;
   return SetBoolAttr(nsGkAtoms::async, aValue);
 }
--- a/content/xbl/src/nsXBLDocumentInfo.cpp
+++ b/content/xbl/src/nsXBLDocumentInfo.cpp
@@ -279,18 +279,18 @@ nsXBLDocGlobalObject::EnsureScriptEnviro
   // nsJSEnvironment set the error reporter to NS_ScriptErrorReporter so
   // we must apparently override that with our own (although it isn't clear 
   // why - see bug 339647)
   JS_SetErrorReporter(cx, XBL_ProtoErrorReporter);
 
   nsIPrincipal *principal = GetPrincipal();
   JSCompartment *compartment;
 
-  rv = xpc_CreateGlobalObject(cx, &gSharedGlobalClass, principal, nullptr,
-                              false, &mJSObject, &compartment);
+  rv = xpc::CreateGlobalObject(cx, &gSharedGlobalClass, principal, false,
+                               &mJSObject, &compartment);
   NS_ENSURE_SUCCESS(rv, NS_OK);
 
   // Set the location information for the new global, so that tools like
   // about:memory may use that information
   nsIURI *ownerURI = mGlobalObjectOwner->DocumentURI();
   xpc::SetLocationForGlobal(mJSObject, ownerURI);
 
   ::JS_SetGlobalObject(cx, mJSObject);
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -1371,18 +1371,17 @@ nsXULElement::LoadSrc()
         return NS_OK;
     }
     if (!IsInDoc() ||
         !OwnerDoc()->GetRootElement() ||
         OwnerDoc()->GetRootElement()->
             NodeInfo()->Equals(nsGkAtoms::overlay, kNameSpaceID_XUL)) {
         return NS_OK;
     }
-    nsXULSlots* slots = static_cast<nsXULSlots*>(GetSlots());
-    NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY);
+    nsXULSlots* slots = static_cast<nsXULSlots*>(Slots());
     if (!slots->mFrameLoader) {
         // false as the last parameter so that xul:iframe/browser/editor
         // session history handling works like dynamic html:iframes.
         // Usually xul elements are used in chrome, which doesn't have
         // session history at all.
         slots->mFrameLoader = nsFrameLoader::Create(this, false);
         NS_ENSURE_TRUE(slots->mFrameLoader, NS_OK);
     }
--- a/content/xul/document/src/nsXULPrototypeDocument.cpp
+++ b/content/xul/document/src/nsXULPrototypeDocument.cpp
@@ -751,18 +751,18 @@ nsXULPDGlobalObject::EnsureScriptEnviron
   {
     JSContext *cx = ctxNew->GetNativeContext();
     JSAutoRequest ar(cx);
 
     nsIPrincipal *principal = GetPrincipal();
     JSObject *newGlob;
     JSCompartment *compartment;
 
-    rv = xpc_CreateGlobalObject(cx, &gSharedGlobalClass, principal, nullptr,
-                                false, &newGlob, &compartment);
+    rv = xpc::CreateGlobalObject(cx, &gSharedGlobalClass, principal, false,
+                                 &newGlob, &compartment);
     NS_ENSURE_SUCCESS(rv, NS_OK);
 
     ::JS_SetGlobalObject(cx, newGlob);
 
     // Add an owning reference from JS back to us. This'll be
     // released when the JSObject is finalized.
     ::JS_SetPrivate(newGlob, this);
     NS_ADDREF(this);
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -2429,41 +2429,34 @@ nsDOMClassInfo::RegisterExternalClasses(
   DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver,                   \
                                       nsDOMTouchEvent::PrefEnabled())
 
 nsresult
 nsDOMClassInfo::Init()
 {
   /* Errors that can trigger early returns are done first,
      otherwise nsDOMClassInfo is left in a half inited state. */
-  NS_ASSERTION(sizeof(PtrBits) == sizeof(void*),
-               "BAD! You'll need to adjust the size of PtrBits to the size "
-               "of a pointer on your platform.");
+  MOZ_STATIC_ASSERT(sizeof(uintptr_t) == sizeof(void*),
+                    "BAD! You'll need to adjust the size of uintptr_t to the "
+                    "size of a pointer on your platform.");
 
   NS_ENSURE_TRUE(!sIsInitialized, NS_ERROR_ALREADY_INITIALIZED);
 
   nsScriptNameSpaceManager *nameSpaceManager = nsJSRuntime::GetNameSpaceManager();
   NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
 
   nsresult rv = CallGetService(nsIXPConnect::GetCID(), &sXPConnect);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIXPCFunctionThisTranslator> old;
-
   nsCOMPtr<nsIXPCFunctionThisTranslator> elt = new nsEventListenerThisTranslator();
-  NS_ENSURE_TRUE(elt, NS_ERROR_OUT_OF_MEMORY);
-
-  sXPConnect->SetFunctionThisTranslator(NS_GET_IID(nsIDOMEventListener),
-                                        elt, getter_AddRefs(old));
+  sXPConnect->SetFunctionThisTranslator(NS_GET_IID(nsIDOMEventListener), elt);
 
   nsCOMPtr<nsIXPCFunctionThisTranslator> mctl = new nsMutationCallbackThisTranslator();
-  NS_ENSURE_TRUE(elt, NS_ERROR_OUT_OF_MEMORY);
-
   sXPConnect->SetFunctionThisTranslator(NS_GET_IID(nsIMutationObserverCallback),
-                                        mctl, getter_AddRefs(old));
+                                        mctl);
 
   nsCOMPtr<nsIScriptSecurityManager> sm =
     do_GetService("@mozilla.org/scriptsecuritymanager;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   sSecMan = sm;
   NS_ADDREF(sSecMan);
 
@@ -5603,32 +5596,16 @@ nsWindowSH::InstallGlobalScopePolluter(J
 
   // The global scope polluter will release doc on destruction (or
   // invalidation).
   NS_ADDREF(doc);
 
   return NS_OK;
 }
 
-static
-already_AddRefed<nsIDOMWindow>
-GetChildFrame(nsGlobalWindow *win, uint32_t index)
-{
-  nsCOMPtr<nsIDOMWindowCollection> frames;
-  win->GetFrames(getter_AddRefs(frames));
-
-  nsIDOMWindow *frame = nullptr;
-
-  if (frames) {
-    frames->Item(index, &frame);
-  }
-
-  return frame;
-}
-
 NS_IMETHODIMP
 nsWindowSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
                         JSObject *obj, jsid id, jsval *vp, bool *_retval)
 {
   nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
 
   JSAutoRequest ar(cx);
 
@@ -5656,49 +5633,50 @@ nsWindowSH::GetProperty(nsIXPConnectWrap
   // critical. Don't touch this unless you know what you're doing.
 
   if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0) {
     // If we're accessing a numeric property we'll treat that as if
     // window.frames[n] is accessed (since window.frames === window),
     // if window.frames[n] is a child frame, wrap the frame and return
     // it without doing a security check.
     uint32_t index = uint32_t(JSID_TO_INT(id));
-    nsresult rv = NS_OK;
-    if (nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, index)) {
+    bool found = false;
+    if (nsCOMPtr<nsIDOMWindow> frame = win->IndexedGetter(index, found)) {
       // A numeric property accessed and the numeric property is a
       // child frame, wrap the child frame without doing a security
       // check and return.
 
       nsGlobalWindow *frameWin = (nsGlobalWindow *)frame.get();
-      NS_ASSERTION(frameWin->IsOuterWindow(), "GetChildFrame gave us an inner?");
+      NS_ASSERTION(frameWin->IsOuterWindow(), "IndexedGetter gave us an inner?");
 
       frameWin->EnsureInnerWindow();
       JSObject *global = frameWin->GetGlobalJSObject();
 
       // This null check fixes a hard-to-reproduce crash that occurs when we
       // get here when we're mid-call to nsDocShell::Destroy. See bug 640904
       // comment 105.
-      if (MOZ_UNLIKELY(!global))
-          return NS_ERROR_FAILURE;
+      if (MOZ_UNLIKELY(!global)) {
+        return NS_ERROR_FAILURE;
+      }
 
       nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
       jsval v;
-      rv = WrapNative(cx, xpc_UnmarkGrayObject(global),
-                      frame, &NS_GET_IID(nsIDOMWindow), true, &v,
-                      getter_AddRefs(holder));
+      nsresult rv = WrapNative(cx, xpc_UnmarkGrayObject(global), frame,
+                               &NS_GET_IID(nsIDOMWindow), true, &v,
+                               getter_AddRefs(holder));
       NS_ENSURE_SUCCESS(rv, rv);
 
       if (!JS_WrapValue(cx, &v)) {
         return NS_ERROR_FAILURE;
       }
 
       *vp = v;
     }
 
-    return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
+    return NS_SUCCESS_I_DID_SOMETHING;
   }
 
   if (JSID_IS_STRING(id) && !JSVAL_IS_PRIMITIVE(*vp) &&
       ::JS_TypeOfValue(cx, *vp) != JSTYPE_FUNCTION) {
     // A named property accessed which could have been resolved to a
     // child frame in nsWindowSH::NewResolve() (*vp will tell us if
     // that's the case). If *vp is a window object (i.e. a child
     // frame), return without doing a security check.
@@ -6829,20 +6807,22 @@ nsWindowSH::GlobalResolve(nsGlobalWindow
           !ConstructorEnabled(name_struct, aWin)) {
         return NS_OK;
       }
 
       if (name_struct->mPrefEnabled && !(*name_struct->mPrefEnabled)()) {
         return NS_OK;
       }
 
-      if (mozilla::dom::DefineConstructor(cx, obj, define, &rv)) {
-        *did_resolve = NS_SUCCEEDED(rv);
-
-        return rv;
+      bool enabled;
+      bool defined = define(cx, obj, &enabled);
+      MOZ_ASSERT_IF(defined, enabled);
+      if (enabled) {
+        *did_resolve = defined;
+        return defined ? NS_OK : NS_ERROR_FAILURE;
       }
     }
   }
 
   if (name_struct->mType == nsGlobalNameStruct::eTypeInterface) {
     // We're resolving a name of a DOM interface for which there is no
     // direct DOM class, create a constructor object...
     nsRefPtr<nsDOMConstructor> constructor;
@@ -7137,17 +7117,19 @@ nsWindowSH::NewResolve(nsIXPConnectWrapp
 
   if (!JSID_IS_STRING(id)) {
     if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0 && !(flags & JSRESOLVE_ASSIGNING)) {
       // If we're resolving a numeric property, treat that as if
       // window.frames[n] is resolved (since window.frames ===
       // window), if window.frames[n] is a child frame, define a
       // property for this index.
       uint32_t index = uint32_t(JSID_TO_INT(id));
-      if (nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, index)) {
+      bool found;
+      nsCOMPtr<nsIDOMWindow> frame = win->IndexedGetter(index, found);
+      if (found) {
         // A numeric property accessed and the numeric property is a
         // child frame. Define a property for this index.
 
         *_retval = ::JS_DefineElement(cx, obj, index, JSVAL_VOID,
                                       nullptr, nullptr, JSPROP_SHARED);
 
         if (*_retval) {
           *objp = obj;
@@ -7291,29 +7273,23 @@ nsWindowSH::NewResolve(nsIXPConnectWrapp
   }
 
   // Hmm, we do an awful lot of QIs here; maybe we should add a
   // method on an interface that would let us just call into the
   // window code directly...
 
   if (!ObjectIsNativeWrapper(cx, obj) ||
       xpc::WrapperFactory::XrayWrapperNotShadowing(obj, id)) {
-    nsCOMPtr<nsIDocShellTreeNode> dsn(do_QueryInterface(win->GetDocShell()));
-
-    int32_t count = 0;
-
-    if (dsn) {
-      dsn->GetChildCount(&count);
-    }
-
-    if (count > 0) {
+    if (win->GetLength() > 0) {
+      const jschar *chars = ::JS_GetInternedStringChars(JSID_TO_STRING(id));
+
+      nsCOMPtr<nsIDocShellTreeNode> dsn(do_QueryInterface(win->GetDocShell()));
+      MOZ_ASSERT(dsn);
+
       nsCOMPtr<nsIDocShellTreeItem> child;
-
-      const jschar *chars = ::JS_GetInternedStringChars(JSID_TO_STRING(id));
-
       dsn->FindChildWithName(reinterpret_cast<const PRUnichar*>(chars),
                              false, true, nullptr, nullptr,
                              getter_AddRefs(child));
 
       nsCOMPtr<nsIDOMWindow> child_win(do_GetInterface(child));
 
       if (child_win) {
         // We found a subframe of the right name, define the property
@@ -8650,22 +8626,18 @@ nsDOMStringMapSH::GetProperty(nsIXPConne
   nsresult rv = dataset->GetDataAttr(propName, propVal);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (propVal.IsVoid()) {
     *vp = JSVAL_VOID;
     return NS_SUCCESS_I_DID_SOMETHING;
   }
 
-  nsStringBuffer* valBuf;
-  *vp = XPCStringConvert::ReadableToJSVal(cx, propVal, &valBuf);
-  if (valBuf) {
-    propVal.ForgetSharedBuffer();
-  }
-
+  NS_ENSURE_TRUE(xpc::NonVoidStringToJsval(cx, propVal, vp),
+                 NS_ERROR_OUT_OF_MEMORY);
   return NS_SUCCESS_I_DID_SOMETHING;
 }
 
 NS_IMETHODIMP
 nsDOMStringMapSH::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
                               JSObject *obj, jsid id, jsval *vp,
                               bool *_retval)
 {
@@ -10233,24 +10205,21 @@ nsStringArraySH::GetProperty(nsIXPConnec
 
   nsresult rv = GetStringAt(GetNative(wrapper, obj), n, val);
   NS_ENSURE_SUCCESS(rv, rv);
 
   JSAutoRequest ar(cx);
 
   if (DOMStringIsNull(val)) {
     *vp = JSVAL_VOID;
-  } else {
-    nsStringBuffer* sharedBuffer = nullptr;
-    *vp = XPCStringConvert::ReadableToJSVal(cx, val, &sharedBuffer);
-    if (sharedBuffer) {
-      val.ForgetSharedBuffer();
-    }
-  }
-
+    return NS_SUCCESS_I_DID_SOMETHING;
+  }
+
+  NS_ENSURE_TRUE(xpc::NonVoidStringToJsval(cx, val, vp),
+                 NS_ERROR_OUT_OF_MEMORY);
   return NS_SUCCESS_I_DID_SOMETHING;
 }
 
 
 // History helper
 
 NS_IMETHODIMP
 nsHistorySH::PreCreate(nsISupports *nativeObj, JSContext *cx,
@@ -10662,54 +10631,39 @@ NS_INTERFACE_MAP_END
 
 
 NS_IMPL_ADDREF(nsEventListenerThisTranslator)
 NS_IMPL_RELEASE(nsEventListenerThisTranslator)
 
 
 NS_IMETHODIMP
 nsEventListenerThisTranslator::TranslateThis(nsISupports *aInitialThis,
-                                             nsIInterfaceInfo *aInterfaceInfo,
-                                             uint16_t aMethodIndex,
-                                             bool *aHideFirstParamFromJS,
-                                             nsIID * *aIIDOfResult,
                                              nsISupports **_retval)
 {
-  *aHideFirstParamFromJS = false;
-  *aIIDOfResult = nullptr;
-
   nsCOMPtr<nsIDOMEvent> event(do_QueryInterface(aInitialThis));
   NS_ENSURE_TRUE(event, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIDOMEventTarget> target;
   event->GetCurrentTarget(getter_AddRefs(target));
-
-  *_retval = target.forget().get();
-
+  target.forget(_retval);
   return NS_OK;
 }
 
 NS_INTERFACE_MAP_BEGIN(nsMutationCallbackThisTranslator)
   NS_INTERFACE_MAP_ENTRY(nsIXPCFunctionThisTranslator)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(nsMutationCallbackThisTranslator)
 NS_IMPL_RELEASE(nsMutationCallbackThisTranslator)
 
 NS_IMETHODIMP
 nsMutationCallbackThisTranslator::TranslateThis(nsISupports *aInitialThis,
-                                                nsIInterfaceInfo *aInterfaceInfo,
-                                                uint16_t aMethodIndex,
-                                                bool *aHideFirstParamFromJS,
-                                                nsIID * *aIIDOfResult,
                                                 nsISupports **_retval)
 {
-  *aHideFirstParamFromJS = false;
-  *aIIDOfResult = nullptr;
   NS_IF_ADDREF(*_retval = nsDOMMutationObserver::CurrentObserver());
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMConstructorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
                               JSObject *globalObj, JSObject **parentObj)
 {
--- a/dom/base/nsDOMClassInfo.h
+++ b/dom/base/nsDOMClassInfo.h
@@ -77,24 +77,22 @@ struct nsDOMClassInfoData
 };
 
 struct nsExternalDOMClassInfoData : public nsDOMClassInfoData
 {
   const nsCID *mConstructorCID;
 };
 
 
-typedef uintptr_t PtrBits;
-
 // To be used with the nsDOMClassInfoData::mCachedClassInfo pointer.
 // The low bit is set when we created a generic helper for an external
 // (which holds on to the nsDOMClassInfoData).
-#define GET_CLEAN_CI_PTR(_ptr) (nsIClassInfo*)(PtrBits(_ptr) & ~0x1)
-#define MARK_EXTERNAL(_ptr) (nsIClassInfo*)(PtrBits(_ptr) | 0x1)
-#define IS_EXTERNAL(_ptr) (PtrBits(_ptr) & 0x1)
+#define GET_CLEAN_CI_PTR(_ptr) (nsIClassInfo*)(uintptr_t(_ptr) & ~0x1)
+#define MARK_EXTERNAL(_ptr) (nsIClassInfo*)(uintptr_t(_ptr) | 0x1)
+#define IS_EXTERNAL(_ptr) (uintptr_t(_ptr) & 0x1)
 
 
 class nsDOMClassInfo : public nsXPCClassInfo
 {
 public:
   nsDOMClassInfo(nsDOMClassInfoData* aData);
   virtual ~nsDOMClassInfo();
 
--- a/dom/base/nsDOMWindowList.cpp
+++ b/dom/base/nsDOMWindowList.cpp
@@ -59,55 +59,65 @@ nsDOMWindowList::EnsureFresh()
     nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
 
     if (doc) {
       doc->FlushPendingNotifications(Flush_ContentAndNotify);
     }
   }
 }
 
+uint32_t
+nsDOMWindowList::GetLength()
+{
+  EnsureFresh();
+
+  NS_ENSURE_TRUE(mDocShellNode, 0);
+
+  int32_t length;
+  nsresult rv = mDocShellNode->GetChildCount(&length);
+  NS_ENSURE_SUCCESS(rv, 0);
+
+  return uint32_t(length);
+}
+
 NS_IMETHODIMP 
 nsDOMWindowList::GetLength(uint32_t* aLength)
 {
-  nsresult rv = NS_OK;
+  *aLength = GetLength();
+  return NS_OK;
+}
 
-  *aLength = 0;
-
+already_AddRefed<nsIDOMWindow>
+nsDOMWindowList::IndexedGetter(uint32_t aIndex, bool& aFound)
+{
   EnsureFresh();
 
-  if (mDocShellNode) {
-    int32_t length;
-    rv = mDocShellNode->GetChildCount(&length);
+  aFound = false;
+  NS_ENSURE_TRUE(mDocShellNode, nullptr);
 
-    *aLength = length;
+  nsCOMPtr<nsIDocShellTreeItem> item;
+  mDocShellNode->GetChildAt(aIndex, getter_AddRefs(item));
+
+  if (!item) {
+    return nullptr;
   }
 
-  return rv;
+  nsCOMPtr<nsIDOMWindow> window = do_GetInterface(item);
+  MOZ_ASSERT(window);
+
+  aFound = true;
+  return window.forget();
 }
 
 NS_IMETHODIMP 
 nsDOMWindowList::Item(uint32_t aIndex, nsIDOMWindow** aReturn)
 {
-  nsCOMPtr<nsIDocShellTreeItem> item;
-
-  *aReturn = nullptr;
-
-  EnsureFresh();
-
-  if (mDocShellNode) {
-    mDocShellNode->GetChildAt(aIndex, getter_AddRefs(item));
-
-    nsCOMPtr<nsIScriptGlobalObject> globalObject(do_GetInterface(item));
-    NS_ASSERTION(!item || (item && globalObject),
-                 "Couldn't get to the globalObject");
-
-    if (globalObject) {
-      CallQueryInterface(globalObject, aReturn);
-    }
-  }
+  bool found;
+  nsCOMPtr<nsIDOMWindow> window = IndexedGetter(aIndex, found);
+  window.forget(aReturn);
   return NS_OK;
 }
 
 NS_IMETHODIMP 
 nsDOMWindowList::NamedItem(const nsAString& aName, nsIDOMWindow** aReturn)
 {
   nsCOMPtr<nsIDocShellTreeItem> item;
 
--- a/dom/base/nsDOMWindowList.h
+++ b/dom/base/nsDOMWindowList.h
@@ -1,32 +1,37 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef nsDOMWindowList_h___
 #define nsDOMWindowList_h___
 
+#include "nsCOMPtr.h"
 #include "nsISupports.h"
 #include "nsIDOMWindowCollection.h"
 #include "nsString.h"
+#include "mozilla/StandardInteger.h"
 
 class nsIDocShellTreeNode;
 class nsIDocShell;
 class nsIDOMWindow;
 
 class nsDOMWindowList : public nsIDOMWindowCollection
 {
 public:
   nsDOMWindowList(nsIDocShell *aDocShell);
   virtual ~nsDOMWindowList();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMWINDOWCOLLECTION
 
+  uint32_t GetLength();
+  already_AddRefed<nsIDOMWindow> IndexedGetter(uint32_t aIndex, bool& aFound);
+
   //local methods
   NS_IMETHOD SetDocShell(nsIDocShell* aDocShell);
 
 protected:
   // Note: this function may flush and cause mDocShellNode to become null.
   void EnsureFresh();
 
   nsIDocShellTreeNode* mDocShellNode; //Weak Reference
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -2006,19 +2006,17 @@ nsGlobalWindow::SetNewDocument(nsIDocume
       {
         JSAutoCompartment ac(cx, mJSObject);
 
         JS_SetParent(cx, mJSObject, newInnerWindow->mJSObject);
 
         rv = SetOuterObject(cx, mJSObject);
         NS_ENSURE_SUCCESS(rv, rv);
 
-        JSCompartment *compartment = js::GetObjectCompartment(mJSObject);
-        xpc::CompartmentPrivate *priv =
-          static_cast<xpc::CompartmentPrivate*>(JS_GetCompartmentPrivate(compartment));
+        xpc::CompartmentPrivate *priv = xpc::GetCompartmentPrivate(mJSObject);
         if (priv && priv->waiverWrapperMap) {
           NS_ASSERTION(!JS_IsExceptionPending(cx),
                        "We might overwrite a pending exception!");
           priv->waiverWrapperMap->Reparent(cx, newInnerWindow->mJSObject);
         }
       }
     }
 
@@ -3258,35 +3256,51 @@ nsGlobalWindow::GetClosed(bool* aClosed)
 
   // 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) {
+    mFrames = new nsDOMWindowList(mDocShell);
+  }
+
+  return mFrames;
+}
+
 NS_IMETHODIMP
 nsGlobalWindow::GetFrames(nsIDOMWindowCollection** aFrames)
 {
   FORWARD_TO_OUTER(GetFrames, (aFrames), NS_ERROR_NOT_INITIALIZED);
 
-  *aFrames = nullptr;
-
-  if (!mFrames && mDocShell) {
-    mFrames = new nsDOMWindowList(mDocShell);
-    if (!mFrames) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-  }
-
-  *aFrames = static_cast<nsIDOMWindowCollection *>(mFrames);
+  *aFrames = GetWindowList();
   NS_IF_ADDREF(*aFrames);
   return NS_OK;
 }
 
+already_AddRefed<nsIDOMWindow>
+nsGlobalWindow::IndexedGetter(uint32_t aIndex, bool& aFound)
+{
+  aFound = false;
+
+  FORWARD_TO_OUTER(IndexedGetter, (aIndex, aFound), nullptr);
+
+  nsDOMWindowList* windows = GetWindowList();
+  NS_ENSURE_TRUE(windows, nullptr);
+
+  return windows->IndexedGetter(aIndex, aFound);
+}
+
 NS_IMETHODIMP
 nsGlobalWindow::GetApplicationCache(nsIDOMOfflineResourceList **aApplicationCache)
 {
   FORWARD_TO_INNER(GetApplicationCache, (aApplicationCache), NS_ERROR_UNEXPECTED);
 
   NS_ENSURE_ARG_POINTER(aApplicationCache);
 
   if (!mApplicationCache) {
@@ -4350,24 +4364,32 @@ nsGlobalWindow::GetScrollX(int32_t* aScr
 NS_IMETHODIMP
 nsGlobalWindow::GetScrollY(int32_t* aScrollY)
 {
   NS_ENSURE_ARG_POINTER(aScrollY);
   *aScrollY = 0;
   return GetScrollXY(nullptr, aScrollY, false);
 }
 
+uint32_t
+nsGlobalWindow::GetLength()
+{
+  FORWARD_TO_OUTER(GetLength, (), 0);
+
+  nsDOMWindowList* windows = GetWindowList();
+  NS_ENSURE_TRUE(windows, 0);
+
+  return windows->GetLength();
+}
+
 NS_IMETHODIMP
 nsGlobalWindow::GetLength(uint32_t* aLength)
 {
-  nsCOMPtr<nsIDOMWindowCollection> frames;
-  if (NS_SUCCEEDED(GetFrames(getter_AddRefs(frames))) && frames) {
-    return frames->GetLength(aLength);
-  }
-  return NS_ERROR_FAILURE;
+  *aLength = GetLength();
+  return NS_OK;
 }
 
 bool
 nsGlobalWindow::DispatchCustomEvent(const char *aEventName)
 {
   bool defaultActionEnabled = true;
   nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
   nsContentUtils::DispatchTrustedEvent(doc,
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -385,16 +385,20 @@ public:
   virtual NS_HIDDEN_(nsresult) SetFullScreenInternal(bool aIsFullScreen, bool aRequireTrust);
 
   // nsIDOMStorageIndexedDB
   NS_DECL_NSIDOMSTORAGEINDEXEDDB
 
   // nsIInterfaceRequestor
   NS_DECL_NSIINTERFACEREQUESTOR
 
+  // WebIDL interface.
+  uint32_t GetLength();
+  already_AddRefed<nsIDOMWindow> IndexedGetter(uint32_t aIndex, bool& aFound);
+
   // Object Management
   nsGlobalWindow(nsGlobalWindow *aOuterWindow);
 
   static nsGlobalWindow *FromSupports(nsISupports *supports)
   {
     // Make sure this matches the casts we do in QueryInterface().
     return (nsGlobalWindow *)(nsIScriptGlobalObject *)supports;
   }
@@ -916,16 +920,19 @@ protected:
                              nsCOMPtr<nsIDOMStorageEvent>& aEvent);
 
   // Implements Get{Real,Scriptable}Top.
   nsresult GetTopImpl(nsIDOMWindow **aWindow, bool aScriptable);
 
   // Helper for creating performance objects.
   void CreatePerformanceObjectIfNeeded();
 
+  // Outer windows only.
+  nsDOMWindowList* GetWindowList();
+
   // 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|.
 
   // This member is also used on both inner and outer windows, but
--- a/dom/base/nsWrapperCache.h
+++ b/dom/base/nsWrapperCache.h
@@ -7,18 +7,16 @@
 #define nsWrapperCache_h___
 
 #include "nsCycleCollectionParticipant.h"
 
 struct JSObject;
 struct JSContext;
 class XPCWrappedNativeScope;
 
-typedef uintptr_t PtrBits;
-
 namespace mozilla {
 namespace dom {
 namespace workers {
 
 class DOMBindingBase;
 
 } // namespace workers
 } // namespace dom
@@ -178,17 +176,17 @@ public:
 
 private:
   JSObject *GetJSObjectFromBits() const
   {
     return reinterpret_cast<JSObject*>(mWrapperPtrBits & ~kWrapperBitMask);
   }
   void SetWrapperBits(void *aWrapper)
   {
-    mWrapperPtrBits = reinterpret_cast<PtrBits>(aWrapper) |
+    mWrapperPtrBits = reinterpret_cast<uintptr_t>(aWrapper) |
                       (mWrapperPtrBits & WRAPPER_IS_DOM_BINDING);
   }
 
   /**
    * If this bit is set then we're preserving the wrapper, which in effect ties
    * the lifetime of the JS object stored in the cache to the lifetime of the
    * native object. We rely on the cycle collector to break the cycle that this
    * causes between the native object and the JS object, so it is important that
@@ -203,17 +201,17 @@ private:
   /**
    * If this bit is set then the wrapper for the native object is a DOM binding
    * (regular JS object or proxy).
    */
   enum { WRAPPER_IS_DOM_BINDING = 1 << 1 };
 
   enum { kWrapperBitMask = (WRAPPER_BIT_PRESERVED | WRAPPER_IS_DOM_BINDING) };
 
-  PtrBits mWrapperPtrBits;
+  uintptr_t mWrapperPtrBits;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsWrapperCache, NS_WRAPPERCACHE_IID)
 
 #define NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY                                   \
   if ( aIID.Equals(NS_GET_IID(nsWrapperCache)) ) {                            \
     *aInstancePtr = static_cast<nsWrapperCache*>(this);                       \
     return NS_OK;                                                             \
--- a/dom/tests/mochitest/bugs/test_bug370098.html
+++ b/dom/tests/mochitest/bugs/test_bug370098.html
@@ -12,34 +12,37 @@ https://bugzilla.mozilla.org/show_bug.cg
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=370098">Mozilla Bug 370098</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 /** Test for Bug 370098 **/
-var dom_protos =
-    [ "Document", "Element", "Image", "DOMParser", "XMLSerializer",
-      "XMLHttpRequest", "XPathEvaluator", "XSLTProcessor" ];
-for each (var dom_proto in dom_protos) {
-    var shouldthrow = typeof window[dom_proto] != "function";
+function test_constructor(dom_proto, shouldthrow) {
     var threw = false;
     try {
         window[dom_proto]();
     } catch (e) {
         threw = true;
     }
     is(threw, shouldthrow, "Calling |" + dom_proto + "()| should" + (shouldthrow ? " " : " not ") + "throw");
 
     threw = false;
     try {
         new window[dom_proto]();
     } catch (e) {
         threw = true;
     }
     is(threw, shouldthrow, "Calling |new " + dom_proto + "()| should" + (shouldthrow ? " " : " not ") + "throw");
 }
+var dom_protos = [ "Document", "Element" ];
+var dom_constructors = [ "Image", "DOMParser", "XMLSerializer",
+  "XMLHttpRequest", "XPathEvaluator", "XSLTProcessor" ];
+dom_protos.forEach(
+  function(p) { test_constructor(p, true); });
+dom_constructors.forEach(
+  function(p) { test_constructor(p, false); });
 </script>
 </pre>
 </body>
 </html>
 
--- a/dom/workers/DOMBindingBase.cpp
+++ b/dom/workers/DOMBindingBase.cpp
@@ -84,15 +84,15 @@ DOMBindingBase::GetJSObject() const
 
 void
 DOMBindingBase::SetJSObject(JSObject* aObject)
 {
   // Make sure that the public method results in the same bits as our private
   // method.
   SetWrapper(aObject);
 
-  PtrBits oldWrapperPtrBits = mWrapperPtrBits;
+  uintptr_t oldWrapperPtrBits = mWrapperPtrBits;
 
   SetWrapperBits(aObject);
 
   MOZ_ASSERT(oldWrapperPtrBits == mWrapperPtrBits);
 }
 #endif
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -2995,50 +2995,50 @@ gfxGlyphExtents::GetTightGlyphExtentsApp
     *aExtents = gfxRect(entry->x, entry->y, entry->width, entry->height);
     return true;
 }
 
 gfxGlyphExtents::GlyphWidths::~GlyphWidths()
 {
     uint32_t i, count = mBlocks.Length();
     for (i = 0; i < count; ++i) {
-        PtrBits bits = mBlocks[i];
+        uintptr_t bits = mBlocks[i];
         if (bits && !(bits & 0x1)) {
             delete[] reinterpret_cast<uint16_t *>(bits);
         }
     }
 }
 
 uint32_t
 gfxGlyphExtents::GlyphWidths::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
 {
     uint32_t i;
     uint32_t size = mBlocks.SizeOfExcludingThis(aMallocSizeOf);
     for (i = 0; i < mBlocks.Length(); ++i) {
-        PtrBits bits = mBlocks[i];
+        uintptr_t bits = mBlocks[i];
         if (bits && !(bits & 0x1)) {
             size += aMallocSizeOf(reinterpret_cast<void*>(bits));
         }
     }
     return size;
 }
 
 void
 gfxGlyphExtents::GlyphWidths::Set(uint32_t aGlyphID, uint16_t aWidth)
 {
     uint32_t block = aGlyphID >> BLOCK_SIZE_BITS;
     uint32_t len = mBlocks.Length();
     if (block >= len) {
-        PtrBits *elems = mBlocks.AppendElements(block + 1 - len);
+        uintptr_t *elems = mBlocks.AppendElements(block + 1 - len);
         if (!elems)
             return;
-        memset(elems, 0, sizeof(PtrBits)*(block + 1 - len));
-    }
-
-    PtrBits bits = mBlocks[block];
+        memset(elems, 0, sizeof(uintptr_t)*(block + 1 - len));
+    }
+
+    uintptr_t bits = mBlocks[block];
     uint32_t glyphOffset = aGlyphID & (BLOCK_SIZE - 1);
     if (!bits) {
         mBlocks[block] = MakeSingle(glyphOffset, aWidth);
         return;
     }
 
     uint16_t *newBlock;
     if (bits & 0x1) {
@@ -3047,17 +3047,17 @@ gfxGlyphExtents::GlyphWidths::Set(uint32
         newBlock = new uint16_t[BLOCK_SIZE];
         if (!newBlock)
             return;
         uint32_t i;
         for (i = 0; i < BLOCK_SIZE; ++i) {
             newBlock[i] = INVALID_WIDTH;
         }
         newBlock[GetGlyphOffset(bits)] = GetWidth(bits);
-        mBlocks[block] = reinterpret_cast<PtrBits>(newBlock);
+        mBlocks[block] = reinterpret_cast<uintptr_t>(newBlock);
     } else {
         newBlock = reinterpret_cast<uint16_t *>(bits);
     }
     newBlock[glyphOffset] = aWidth;
 }
 
 void
 gfxGlyphExtents::SetTightGlyphExtents(uint32_t aGlyphID, const gfxRect& aExtentsAppUnits)
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -1058,27 +1058,26 @@ private:
         HashEntry(KeyTypePointer aPtr) : nsUint32HashKey(aPtr) {}
         HashEntry(const HashEntry& toCopy) : nsUint32HashKey(toCopy) {
           x = toCopy.x; y = toCopy.y; width = toCopy.width; height = toCopy.height;
         }
 
         float x, y, width, height;
     };
 
-    typedef uintptr_t PtrBits;
     enum { BLOCK_SIZE_BITS = 7, BLOCK_SIZE = 1 << BLOCK_SIZE_BITS }; // 128-glyph blocks
 
     class GlyphWidths {
     public:
         void Set(uint32_t aIndex, uint16_t aValue);
         uint16_t Get(uint32_t aIndex) const {
             uint32_t block = aIndex >> BLOCK_SIZE_BITS;
             if (block >= mBlocks.Length())
                 return INVALID_WIDTH;
-            PtrBits bits = mBlocks[block];
+            uintptr_t bits = mBlocks[block];
             if (!bits)
                 return INVALID_WIDTH;
             uint32_t indexInBlock = aIndex & (BLOCK_SIZE - 1);
             if (bits & 0x1) {
                 if (GetGlyphOffset(bits) != indexInBlock)
                     return INVALID_WIDTH;
                 return GetWidth(bits);
             }
@@ -1086,29 +1085,29 @@ private:
             return widths[indexInBlock];
         }
 
         uint32_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
         
         ~GlyphWidths();
 
     private:
-        static uint32_t GetGlyphOffset(PtrBits aBits) {
+        static uint32_t GetGlyphOffset(uintptr_t aBits) {
             NS_ASSERTION(aBits & 0x1, "This is really a pointer...");
             return (aBits >> 1) & ((1 << BLOCK_SIZE_BITS) - 1);
         }
-        static uint32_t GetWidth(PtrBits aBits) {
+        static uint32_t GetWidth(uintptr_t aBits) {
             NS_ASSERTION(aBits & 0x1, "This is really a pointer...");
             return aBits >> (1 + BLOCK_SIZE_BITS);
         }
-        static PtrBits MakeSingle(uint32_t aGlyphOffset, uint16_t aWidth) {
+        static uintptr_t MakeSingle(uint32_t aGlyphOffset, uint16_t aWidth) {
             return (aWidth << (1 + BLOCK_SIZE_BITS)) + (aGlyphOffset << 1) + 1;
         }
 
-        nsTArray<PtrBits> mBlocks;
+        nsTArray<uintptr_t> mBlocks;
     };
 
     GlyphWidths             mContainedGlyphWidths;
     nsTHashtable<HashEntry> mTightGlyphExtents;
     uint32_t                mAppUnitsPerDevUnit;
 };
 
 /**
--- a/ipc/chromium/src/base/basictypes.h
+++ b/ipc/chromium/src/base/basictypes.h
@@ -1,34 +1,15 @@
 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 #ifndef BASE_BASICTYPES_H_
 #define BASE_BASICTYPES_H_
 
-// Chromium includes a prtypes.h also, but it has been modified to include
-// their build_config.h as well. We can therefore test for both to determine
-// if someone screws up the include order.
-#if defined(prtypes_h___) && !defined(BUILD_BUILD_CONFIG_H_)
-#error You_must_include_basictypes.h_before_prtypes.h!
-#endif
-
-#ifndef NO_NSPR_10_SUPPORT
-#define NO_NSPR_10_SUPPORT
-#define NO_NSPR_10_SUPPORT_SAVE
-#endif
-
-#include "prtypes.h"
-
-#ifdef NO_NSPR_10_SUPPORT_SAVE
-#undef NO_NSPR_10_SUPPORT_SAVE
-#undef NO_NSPR_10_SUPPORT
-#endif
-
 #include <limits.h>         // So we can set the bounds of our types
 #include <stddef.h>         // For size_t
 #include <string.h>         // for memcpy
 
 #include "base/port.h"    // Types that only need exist on certain systems
 
 #include "mozilla/StandardInteger.h"
 
--- a/js/xpconnect/idl/nsIXPConnect.idl
+++ b/js/xpconnect/idl/nsIXPConnect.idl
@@ -265,50 +265,35 @@ interface nsIXPCWrappedJSObjectGetter : 
  * interface pointer to use as the 'this' for the call. If the translator
  * returns a non-null interface pointer (which it should then have addref'd
  * since it is being returned as an out param), xpconnect will attempt to build
  * a wrapper around the pointer and get a JSObject from that wrapper to use
  * as the 'this' for the call.
  *
  * If a null interface pointer is returned then xpconnect will use the default
  * 'this' - the same JSObject as the function object it is calling.
- *
- * The translator can also return a non-null aIIDOfResult to tell xpconnect what
- * type of wrapper to build. If that is null then xpconnect will assume the
- * wrapper should be for nsISupports. For objects that support flattening -
- * i.e. expose nsIClassInfo and that interface's getInterfaces method - then
- * a flattened wrapper will be created and no iid was really necessary.
- *
- * XXX aHideFirstParamFromJS is intended to allow the trimming of that first
- * param (used to indicate 'this') from the actual call to the JS code. The JS
- * DOM does not require this functionality and it is **NOT YET IMPLEMENTED**
- *
  */
 
-[uuid(039ef260-2a0d-11d5-90a7-0010a4e73d9a)]
+[uuid(f5f84b70-92eb-41f1-a1dd-2eaac0ed564c)]
 interface nsIXPCFunctionThisTranslator : nsISupports
 {
-    nsISupports TranslateThis(in nsISupports        aInitialThis,
-                              in nsIInterfaceInfo   aInterfaceInfo,
-                              in uint16_t           aMethodIndex,
-                              out boolean            aHideFirstParamFromJS,
-                              out nsIIDPtr          aIIDOfResult);
+    nsISupports TranslateThis(in nsISupports aInitialThis);
 };
 
 /***************************************************************************/
 
 %{ C++
 // For use with the service manager
 // {CB6593E0-F9B2-11d2-BDD6-000064657374}
 #define NS_XPCONNECT_CID \
 { 0xcb6593e0, 0xf9b2, 0x11d2, \
     { 0xbd, 0xd6, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
 %}
 
-[uuid(bd300b18-1c34-4589-8285-23a12cc580ea)]
+[uuid(d94c13ae-7585-4e7b-b7ad-482976bc6f1b)]
 interface nsIXPConnect : nsISupports
 {
 %{ C++
   NS_DEFINE_STATIC_CID_ACCESSOR(NS_XPCONNECT_CID)
 %}
 
     /**
      * Initializes classes on a global object that has already been created.
@@ -524,20 +509,17 @@ interface nsIXPConnect : nsISupports
     * A new wrapper is *never* constructed.
     */
     nsIXPConnectWrappedNative
     getWrappedNativeOfNativeObject(in JSContextPtr aJSContext,
                                    in JSObjectPtr  aScope,
                                    in nsISupports  aCOMObj,
                                    in nsIIDRef     aIID);
 
-    nsIXPCFunctionThisTranslator
-    getFunctionThisTranslator(in nsIIDRef aIID);
-
-    nsIXPCFunctionThisTranslator
+    void
     setFunctionThisTranslator(in nsIIDRef aIID,
                               in nsIXPCFunctionThisTranslator aTranslator);
 
     nsIXPConnectJSObjectHolder
     reparentWrappedNativeIfFound(in JSContextPtr aJSContext,
                                  in JSObjectPtr  aScope,
                                  in JSObjectPtr  aNewParent,
                                  in nsISupports  aCOMObj);
--- a/js/xpconnect/shell/xpcshell.cpp
+++ b/js/xpconnect/shell/xpcshell.cpp
@@ -1585,29 +1585,23 @@ nsXPCFunctionThisTranslator::nsXPCFuncti
 nsXPCFunctionThisTranslator::~nsXPCFunctionThisTranslator()
 {
   /* destructor code */
 #ifdef DEBUG_jband
     printf("destroying nsXPCFunctionThisTranslator\n");
 #endif
 }
 
-/* nsISupports TranslateThis (in nsISupports aInitialThis, in nsIInterfaceInfo aInterfaceInfo, in uint16_t aMethodIndex, out bool aHideFirstParamFromJS, out nsIIDPtr aIIDOfResult); */
+/* nsISupports TranslateThis (in nsISupports aInitialThis); */
 NS_IMETHODIMP
 nsXPCFunctionThisTranslator::TranslateThis(nsISupports *aInitialThis,
-                                           nsIInterfaceInfo *aInterfaceInfo,
-                                           uint16_t aMethodIndex,
-                                           bool *aHideFirstParamFromJS,
-                                           nsIID * *aIIDOfResult,
                                            nsISupports **_retval)
 {
     NS_IF_ADDREF(aInitialThis);
     *_retval = aInitialThis;
-    *aHideFirstParamFromJS = false;
-    *aIIDOfResult = nullptr;
     return NS_OK;
 }
 
 #endif
 
 // ContextCallback calls are chained
 static JSContextCallback gOldJSContextCallback;
 
@@ -1840,17 +1834,17 @@ main(int argc, char **argv, char **envp)
         const JSSecurityCallbacks *scb = JS_GetSecurityCallbacks(rt);
         NS_ASSERTION(scb, "We are assuming that nsScriptSecurityManager::Init() has been run");
         shellSecurityCallbacks = *scb;
         JS_SetSecurityCallbacks(rt, &shellSecurityCallbacks);
 
 #ifdef TEST_TranslateThis
         nsCOMPtr<nsIXPCFunctionThisTranslator>
             translator(new nsXPCFunctionThisTranslator);
-        xpc->SetFunctionThisTranslator(NS_GET_IID(nsITestXPCFunctionCallback), translator, nullptr);
+        xpc->SetFunctionThisTranslator(NS_GET_IID(nsITestXPCFunctionCallback), translator);
 #endif
 
         nsCOMPtr<nsIJSContextStack> cxstack = do_GetService("@mozilla.org/js/xpc/ContextStack;1");
         if (!cxstack) {
             printf("failed to get the nsThreadJSContextStack service!\n");
             return 1;
         }
 
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -3051,25 +3051,16 @@ NS_IMPL_THREADSAFE_RELEASE(nsXPCComponen
 static bool
 WrapForSandbox(JSContext *cx, bool wantXrays, jsval *vp)
 {
     return wantXrays
            ? JS_WrapValue(cx, vp)
            : xpc::WrapperFactory::WaiveXrayAndWrap(cx, vp);
 }
 
-// Needed to distinguish multiple compartments with the same origin from each
-// other. The only thing we need out of identity objects are unique addresses.
-class Identity MOZ_FINAL : public nsISupports
-{
-    NS_DECL_ISUPPORTS
-};
-
-NS_IMPL_ISUPPORTS0(Identity)
-
 xpc::SandboxProxyHandler xpc::sandboxProxyHandler;
 
 // A proxy handler that lets us wrap callables and invoke them with
 // the correct this object, while forwarding all other operations down
 // to them directly.
 class SandboxCallableProxyHandler : public js::DirectWrapper {
 public:
     SandboxCallableProxyHandler() : js::DirectWrapper(0)
@@ -3265,19 +3256,18 @@ xpc_CreateSandboxObject(JSContext *cx, j
             return NS_ERROR_OUT_OF_MEMORY;
     }
 
     nsIPrincipal *principal = sop->GetPrincipal();
 
     JSCompartment *compartment;
     JSObject *sandbox;
 
-    nsRefPtr<Identity> identity = new Identity();
-    rv = xpc_CreateGlobalObject(cx, &SandboxClass, principal, identity,
-                                options.wantXrays, &sandbox, &compartment);
+    rv = xpc::CreateGlobalObject(cx, &SandboxClass, principal,
+                                 options.wantXrays, &sandbox, &compartment);
     NS_ENSURE_SUCCESS(rv, rv);
 
     JS::AutoObjectRooter tvr(cx, sandbox);
 
     {
         JSAutoCompartment ac(cx, sandbox);
 
         if (options.proto) {
@@ -4738,18 +4728,18 @@ nsXPCComponents::GetProperty(nsIXPConnec
         doResult = true;
     } else if (id == rt->GetStringID(XPCJSRuntime::IDX_RETURN_CODE)) {
         res = xpcc->GetPendingResult();
         doResult = true;
     }
 
     nsresult rv = NS_OK;
     if (doResult) {
-        // The two casts below is required since nsresult is an enum,
-        // and it can be interpreted as a signed integer if we directly
+        // The two casts below is required since nsresult is an enum,
+        // and it can be interpreted as a signed integer if we directly
         // cast to a double.
         *vp = JS_NumberValue((double)(uint32_t) res);
         rv = NS_SUCCESS_I_DID_SOMETHING;
     }
 
     return rv;
 }
 
--- a/js/xpconnect/src/XPCJSContextStack.cpp
+++ b/js/xpconnect/src/XPCJSContextStack.cpp
@@ -177,19 +177,19 @@ XPCJSContextStack::GetSafeJSContext()
     JSObject *glob;
     {
         // scoped JS Request
         JSAutoRequest req(mSafeJSContext);
 
         JS_SetErrorReporter(mSafeJSContext, mozJSLoaderErrorReporter);
 
         JSCompartment *compartment;
-        nsresult rv = xpc_CreateGlobalObject(mSafeJSContext, &global_class,
-                                             principal, principal, false,
-                                             &glob, &compartment);
+        nsresult rv = xpc::CreateGlobalObject(mSafeJSContext, &global_class,
+                                              principal, false, &glob,
+                                              &compartment);
         if (NS_FAILED(rv))
             glob = nullptr;
 
         if (glob) {
             // Make sure the context is associated with a proper compartment
             // and not the default compartment.
             JS_SetGlobalObject(mSafeJSContext, glob);
 
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -1211,41 +1211,29 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
                             mRuntime->GetThisTranslatorMap();
 
                         {
                             XPCAutoLock lock(mRuntime->GetMapLock()); // scoped lock
                             translator = map->Find(mIID);
                         }
 
                         if (translator) {
-                            bool hideFirstParamFromJS = false;
-                            nsIID* newWrapperIID = nullptr;
                             nsCOMPtr<nsISupports> newThis;
-
                             if (NS_FAILED(translator->
                                           TranslateThis((nsISupports*)nativeParams[0].val.p,
-                                                        mInfo, methodIndex,
-                                                        &hideFirstParamFromJS,
-                                                        &newWrapperIID,
                                                         getter_AddRefs(newThis)))) {
                                 goto pre_call_clean_up;
                             }
-                            if (hideFirstParamFromJS) {
-                                NS_ERROR("HideFirstParamFromJS not supported");
-                                goto pre_call_clean_up;
-                            }
                             if (newThis) {
                                 jsval v;
                                 xpcObjectHelper helper(newThis);
                                 JSBool ok =
-                                  XPCConvert::NativeInterface2JSObject(ccx,
-                                                                       &v, nullptr, helper, newWrapperIID,
-                                                                       nullptr, false, nullptr);
-                                if (newWrapperIID)
-                                    nsMemory::Free(newWrapperIID);
+                                  XPCConvert::NativeInterface2JSObject(
+                                      ccx, &v, nullptr, helper, nullptr,
+                                      nullptr, false, nullptr);
                                 if (!ok) {
                                     goto pre_call_clean_up;
                                 }
                                 thisObj = JSVAL_TO_OBJECT(v);
                                 if (!JS_WrapObject(cx, &thisObj))
                                     goto pre_call_clean_up;
                             }
                         }
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -280,18 +280,16 @@ FinishCreate(XPCCallContext& ccx,
 // very early on that we have an XPCWrappedNativeScope and corresponding global
 // JS object, which are the very things we need to create here. So we special-
 // case the logic and do some things in a different order.
 nsresult
 XPCWrappedNative::WrapNewGlobal(XPCCallContext &ccx, xpcObjectHelper &nativeHelper,
                                 nsIPrincipal *principal, bool initStandardClasses,
                                 XPCWrappedNative **wrappedGlobal)
 {
-    bool success;
-    nsresult rv;
     nsISupports *identity = nativeHelper.GetCanonical();
 
     // The object should specify that it's meant to be global.
     MOZ_ASSERT(nativeHelper.GetScriptableFlags() & nsIXPCScriptable::IS_GLOBAL_OBJECT);
 
     // We shouldn't be reusing globals.
     MOZ_ASSERT(!nativeHelper.GetWrapperCache() ||
                !nativeHelper.GetWrapperCache()->GetWrapperPreserveColor());
@@ -311,18 +309,18 @@ XPCWrappedNative::WrapNewGlobal(XPCCallC
 
     // Finally, we get to the JSClass.
     JSClass *clasp = si->GetJSClass();
     MOZ_ASSERT(clasp->flags & JSCLASS_IS_GLOBAL);
 
     // Create the global.
     JSObject *global;
     JSCompartment *compartment;
-    rv = xpc_CreateGlobalObject(ccx, clasp, principal, nullptr, false,
-                                &global, &compartment);
+    nsresult rv = xpc::CreateGlobalObject(ccx, clasp, principal, false, &global,
+                                          &compartment);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Immediately enter the global's compartment, so that everything else we
     // create ends up there.
     JSAutoCompartment ac(ccx, global);
 
     // If requested, immediately initialize the standard classes on the global.
     // We need to do this before creating a scope, because
@@ -342,17 +340,17 @@ XPCWrappedNative::WrapNewGlobal(XPCCallC
         XPCWrappedNativeProto::GetNewOrUsed(ccx, scope, nativeHelper.GetClassInfo(), &sciProto,
                                             UNKNOWN_OFFSETS, /* callPostCreatePrototype = */ false);
     if (!proto)
         return NS_ERROR_FAILURE;
     proto->CacheOffsets(identity);
 
     // Set up the prototype on the global.
     MOZ_ASSERT(proto->GetJSProtoObject());
-    success = JS_SplicePrototype(ccx, global, proto->GetJSProtoObject());
+    bool success = JS_SplicePrototype(ccx, global, proto->GetJSProtoObject());
     if (!success)
         return NS_ERROR_FAILURE;
 
     // Construct the wrapper.
     nsRefPtr<XPCWrappedNative> wrapper = new XPCWrappedNative(identity, proto);
 
     // The wrapper takes over the strong reference to the native object.
     nativeHelper.forgetCanonical();
--- a/js/xpconnect/src/dombindings.cpp
+++ b/js/xpconnect/src/dombindings.cpp
@@ -145,27 +145,16 @@ typename ListBase<LC>::Methods ListBase<
     { s_VOID_id, NULL, 0 }
 };
 template<class LC>
 size_t ListBase<LC>::sProtoMethodsCount = 0;
 
 template<class LC>
 ListBase<LC> ListBase<LC>::instance;
 
-bool
-DefineConstructor(JSContext *cx, JSObject *obj, DefineInterface aDefine, nsresult *aResult)
-{
-    bool enabled;
-    bool defined = aDefine(cx, obj, &enabled);
-    NS_ASSERTION(!defined || enabled,
-                 "We defined a constructor but the new bindings are disabled?");
-    *aResult = defined ? NS_OK : NS_ERROR_FAILURE;
-    return enabled;
-}
-
 template<class LC>
 typename ListBase<LC>::ListType*
 ListBase<LC>::getNative(JSObject *obj)
 {
     return static_cast<ListType*>(js::GetProxyPrivate(obj).toPrivate());
 }
 
 template<class LC>
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -1090,21 +1090,21 @@ CheckTypeInference(JSContext *cx, JSClas
 
     // Finally, do the damn assert.
     MOZ_ASSERT(JS_GetOptions(cx) & JSOPTION_TYPE_INFERENCE);
 }
 #else
 #define CheckTypeInference(cx, clasp, principal) {}
 #endif
 
+namespace xpc {
+
 nsresult
-xpc_CreateGlobalObject(JSContext *cx, JSClass *clasp,
-                       nsIPrincipal *principal, nsISupports *ptr,
-                       bool wantXrays, JSObject **global,
-                       JSCompartment **compartment)
+CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal,
+                   bool wantXrays, JSObject **global, JSCompartment **compartment)
 {
     // Make sure that Type Inference is enabled for everything non-chrome.
     // Sandboxes and compilation scopes are exceptions. See bug 744034.
     CheckTypeInference(cx, clasp, principal);
 
     NS_ABORT_IF_FALSE(NS_IsMainThread(), "using a principal off the main thread?");
 
     xpc::CompartmentPrivate *priv = new xpc::CompartmentPrivate(wantXrays);
@@ -1132,16 +1132,18 @@ xpc_CreateGlobalObject(JSContext *cx, JS
 
     if (clasp->flags & JSCLASS_DOM_GLOBAL) {
         AllocateProtoOrIfaceCache(*global);
     }
 
     return NS_OK;
 }
 
+} // namespace xpc
+
 NS_IMETHODIMP
 nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
                                              nsISupports *aCOMObj,
                                              nsIPrincipal * aPrincipal,
                                              uint32_t aFlags,
                                              nsIXPConnectJSObjectHolder **_retval)
 {
     NS_ASSERTION(aJSContext, "bad param");
@@ -1826,56 +1828,30 @@ nsXPConnect::GetCurrentNativeCallContext
 
 NS_IMETHODIMP
 nsXPConnect::SyncJSContexts(void)
 {
     // Do-nothing compatibility function
     return NS_OK;
 }
 
-/* nsIXPCFunctionThisTranslator setFunctionThisTranslator (in nsIIDRef aIID, in nsIXPCFunctionThisTranslator aTranslator); */
+/* void setFunctionThisTranslator (in nsIIDRef aIID, in nsIXPCFunctionThisTranslator aTranslator); */
 NS_IMETHODIMP
 nsXPConnect::SetFunctionThisTranslator(const nsIID & aIID,
-                                       nsIXPCFunctionThisTranslator *aTranslator,
-                                       nsIXPCFunctionThisTranslator **_retval)
+                                       nsIXPCFunctionThisTranslator *aTranslator)
 {
     XPCJSRuntime* rt = GetRuntime();
-    nsIXPCFunctionThisTranslator* old;
     IID2ThisTranslatorMap* map = rt->GetThisTranslatorMap();
-
     {
         XPCAutoLock lock(rt->GetMapLock()); // scoped lock
-        if (_retval) {
-            old = map->Find(aIID);
-            NS_IF_ADDREF(old);
-            *_retval = old;
-        }
         map->Add(aIID, aTranslator);
     }
     return NS_OK;
 }
 
-/* nsIXPCFunctionThisTranslator getFunctionThisTranslator (in nsIIDRef aIID); */
-NS_IMETHODIMP
-nsXPConnect::GetFunctionThisTranslator(const nsIID & aIID,
-                                       nsIXPCFunctionThisTranslator **_retval)
-{
-    XPCJSRuntime* rt = GetRuntime();
-    nsIXPCFunctionThisTranslator* old;
-    IID2ThisTranslatorMap* map = rt->GetThisTranslatorMap();
-
-    {
-        XPCAutoLock lock(rt->GetMapLock()); // scoped lock
-        old = map->Find(aIID);
-        NS_IF_ADDREF(old);
-        *_retval = old;
-    }
-    return NS_OK;
-}
-
 /* void clearAllWrappedNativeSecurityPolicies (); */
 NS_IMETHODIMP
 nsXPConnect::ClearAllWrappedNativeSecurityPolicies()
 {
     XPCCallContext ccx(NATIVE_CALLER);
     if (!ccx.IsValid())
         return UnexpectedFailure(NS_ERROR_FAILURE);
 
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -4416,18 +4416,17 @@ GetCompartmentPrivate(JSObject *object)
     JSCompartment *compartment = js::GetObjectCompartment(object);
 
     MOZ_ASSERT(compartment);
     return GetCompartmentPrivate(compartment);
 }
 
 inline bool IsUniversalXPConnectEnabled(JSCompartment *compartment)
 {
-    CompartmentPrivate *priv =
-      static_cast<CompartmentPrivate*>(JS_GetCompartmentPrivate(compartment));
+    CompartmentPrivate *priv = GetCompartmentPrivate(compartment);
     if (!priv)
         return false;
     return priv->universalXPConnectEnabled;
 }
 
 inline bool IsUniversalXPConnectEnabled(JSContext *cx)
 {
     JSCompartment *compartment = js::GetContextCompartment(cx);
@@ -4436,18 +4435,17 @@ inline bool IsUniversalXPConnectEnabled(
     return IsUniversalXPConnectEnabled(compartment);
 }
 
 inline bool EnableUniversalXPConnect(JSContext *cx)
 {
     JSCompartment *compartment = js::GetContextCompartment(cx);
     if (!compartment)
         return true;
-    CompartmentPrivate *priv =
-      static_cast<CompartmentPrivate*>(JS_GetCompartmentPrivate(compartment));
+    CompartmentPrivate *priv = GetCompartmentPrivate(compartment);
     if (!priv)
         return true;
     priv->universalXPConnectEnabled = true;
 
     // Recompute all the cross-compartment wrappers leaving the newly-privileged
     // compartment.
     return js::RecomputeWrappers(cx, js::SingleCompartment(compartment),
                                  js::AllCompartments());
--- a/js/xpconnect/src/xpcpublic.h
+++ b/js/xpconnect/src/xpcpublic.h
@@ -35,28 +35,22 @@ class nsScriptNameSpaceManager;
 namespace xpc {
 JSObject *
 TransplantObject(JSContext *cx, JSObject *origobj, JSObject *target);
 
 JSObject *
 TransplantObjectWithWrapper(JSContext *cx,
                             JSObject *origobj, JSObject *origwrapper,
                             JSObject *targetobj, JSObject *targetwrapper);
-} /* namespace xpc */
 
 nsresult
-xpc_CreateGlobalObject(JSContext *cx, JSClass *clasp,
-                       nsIPrincipal *principal, nsISupports *ptr,
-                       bool wantXrays, JSObject **global,
-                       JSCompartment **compartment);
-
-nsresult
-xpc_CreateMTGlobalObject(JSContext *cx, JSClass *clasp,
-                         nsISupports *ptr, JSObject **global,
-                         JSCompartment **compartment);
+CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal,
+                   bool wantXrays, JSObject **global,
+                   JSCompartment **compartment);
+} /* namespace xpc */
 
 #define XPCONNECT_GLOBAL_FLAGS                                                \
     JSCLASS_DOM_GLOBAL | JSCLASS_XPCONNECT_GLOBAL | JSCLASS_HAS_PRIVATE |     \
     JSCLASS_PRIVATE_IS_NSISUPPORTS | JSCLASS_IMPLEMENTS_BARRIERS |            \
     JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(3)
 
 void
 TraceXPCGlobal(JSTracer *trc, JSObject *obj);
@@ -68,58 +62,50 @@ xpc_LocalizeContext(JSContext *cx);
 nsresult
 xpc_MorphSlimWrapper(JSContext *cx, nsISupports *tomorph);
 
 static inline bool IS_WRAPPER_CLASS(js::Class* clazz)
 {
     return clazz->ext.isWrappedNative;
 }
 
-inline JSBool
-DebugCheckWrapperClass(JSObject* obj)
-{
-    NS_ASSERTION(IS_WRAPPER_CLASS(js::GetObjectClass(obj)),
-                 "Forgot to check if this is a wrapper?");
-    return true;
-}
-
 // If IS_WRAPPER_CLASS for the JSClass of an object is true, the object can be
 // a slim wrapper, holding a native in its private slot, or a wrappednative
 // wrapper, holding the XPCWrappedNative in its private slot. A slim wrapper
 // also holds a pointer to its XPCWrappedNativeProto in a reserved slot, we can
 // check that slot for a private value (i.e. a double) to distinguish between
 // the two. This allows us to store a JSObject in that slot for non-slim wrappers
 // while still being able to distinguish the two cases.
 
 // NB: This slot isn't actually reserved for us on globals, because SpiderMonkey
 // uses the first N slots on globals internally. The fact that we use it for
 // wrapped global objects is totally broken. But due to a happy coincidence, the
 // JS engine never uses that slot. This still needs fixing though. See bug 760095.
 #define WRAPPER_MULTISLOT 0
 
-// Only use these macros if IS_WRAPPER_CLASS(GetObjectClass(obj)) is true.
-#define IS_WN_WRAPPER_OBJECT(obj)                                             \
-    (DebugCheckWrapperClass(obj) && !js::GetReservedSlot(obj, WRAPPER_MULTISLOT).isDouble())
-#define IS_SLIM_WRAPPER_OBJECT(obj)                                           \
-    (DebugCheckWrapperClass(obj) && js::GetReservedSlot(obj, WRAPPER_MULTISLOT).isDouble())
+static inline bool IS_WN_WRAPPER_OBJECT(JSObject *obj)
+{
+    MOZ_ASSERT(IS_WRAPPER_CLASS(js::GetObjectClass(obj)));
+    return !js::GetReservedSlot(obj, WRAPPER_MULTISLOT).isDouble();
+}
+static inline bool IS_SLIM_WRAPPER_OBJECT(JSObject *obj)
+{
+    return !IS_WN_WRAPPER_OBJECT(obj);
+}
 
-// Use these macros if IS_WRAPPER_CLASS(GetObjectClass(obj)) might be false.
+// Use these functions if IS_WRAPPER_CLASS(GetObjectClass(obj)) might be false.
 // Avoid calling them if IS_WRAPPER_CLASS(GetObjectClass(obj)) can only be
 // true, as we'd do a redundant call to IS_WRAPPER_CLASS.
-#define IS_WN_WRAPPER(obj)                                                    \
-    (IS_WRAPPER_CLASS(js::GetObjectClass(obj)) && IS_WN_WRAPPER_OBJECT(obj))
-#define IS_SLIM_WRAPPER(obj)                                                  \
-    (IS_WRAPPER_CLASS(js::GetObjectClass(obj)) && IS_SLIM_WRAPPER_OBJECT(obj))
-
-inline JSObject *
-xpc_GetGlobalForObject(JSObject *obj)
+static inline bool IS_WN_WRAPPER(JSObject *obj)
 {
-    while (JSObject *parent = js::GetObjectParent(obj))
-        obj = parent;
-    return obj;
+    return IS_WRAPPER_CLASS(js::GetObjectClass(obj)) && IS_WN_WRAPPER_OBJECT(obj);
+}
+static inline bool IS_SLIM_WRAPPER(JSObject *obj)
+{
+    return IS_WRAPPER_CLASS(js::GetObjectClass(obj)) && IS_SLIM_WRAPPER_OBJECT(obj);
 }
 
 extern bool
 xpc_OkToHandOutWrapper(nsWrapperCache *cache);
 
 inline JSObject*
 xpc_FastGetCachedWrapper(nsWrapperCache *cache, JSObject *scope, jsval *vp)
 {
@@ -347,19 +333,16 @@ typedef bool
 
 typedef bool
 (*PrefEnabled)();
 
 extern bool
 DefineStaticJSVals(JSContext *cx);
 void
 Register(nsScriptNameSpaceManager* aNameSpaceManager);
-extern bool
-DefineConstructor(JSContext *cx, JSObject *obj, DefineInterface aDefine,
-                  nsresult *aResult);
 
 namespace oldproxybindings {
 
 inline bool instanceIsProxy(JSObject *obj)
 {
     return js::IsProxy(obj) &&
            js::GetProxyHandler(obj)->family() == ProxyFamily() &&
            !IsNewProxyBinding(js::GetProxyHandler(obj));
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -3865,17 +3865,17 @@ nsCSSFrameConstructor::CreateAnonymousFr
       ConstructFrame(aState, content, aParentFrame, aChildItems);
     }
   }
 
   return NS_OK;
 }
 
 static void
-SetFlagsOnSubtree(nsIContent *aNode, PtrBits aFlagsToSet)
+SetFlagsOnSubtree(nsIContent *aNode, uintptr_t aFlagsToSet)
 {
 #ifdef DEBUG
   // Make sure that the node passed to us doesn't have any XBL children
   {
     nsIDocument *doc = aNode->OwnerDoc();
     NS_ASSERTION(doc, "The node must be in a document");
     NS_ASSERTION(!doc->BindingManager()->GetXBLChildNodesFor(aNode),
                  "The node should not have any XBL children");
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -358,19 +358,19 @@ static bool gInitialized = false;
 nsresult
 Initialize()
 {
   if (gInitialized) {
     NS_RUNTIMEABORT("Recursive layout module initialization");
     return NS_ERROR_FAILURE;
   }
 
-  NS_ASSERTION(sizeof(PtrBits) == sizeof(void *),
-               "Eeek! You'll need to adjust the size of PtrBits to the size "
-               "of a pointer on your platform.");
+  MOZ_STATIC_ASSERT(sizeof(uintptr_t) == sizeof(void*),
+                    "Eeek! You'll need to adjust the size of uintptr_t to the "
+                    "size of a pointer on your platform.");
 
   gInitialized = true;
 
   nsresult rv;
   rv = xpcModuleCtor();
   if (NS_FAILED(rv))
     return rv;
 
--- a/mobile/android/chrome/content/aboutAddons.js
+++ b/mobile/android/chrome/content/aboutAddons.js
@@ -281,17 +281,19 @@ var Addons = {
         // Send an event so add-ons can prepopulate any non-preference based
         // settings
         let event = document.createEvent("Events");
         event.initEvent("AddonOptionsLoad", true, false);
         window.dispatchEvent(event);
 
         // Also send a notification to match the behavior of desktop Firefox
         let id = aListItem.getAttribute("addonID");
-        Services.obs.notifyObservers(document, "addon-options-displayed", id);
+        Services.obs.notifyObservers(document,
+                                     AddonManager.OPTIONS_NOTIFICATION_DISPLAYED,
+                                     id);
       }
     } catch (e) {
       Cu.reportError(e)
     }
 
     let list = document.querySelector("#addons-list");
     list.style.display = "none";
     let details = document.querySelector("#addons-details");
--- a/mobile/xul/chrome/content/bindings/extensions.xml
+++ b/mobile/xul/chrome/content/bindings/extensions.xml
@@ -150,17 +150,19 @@
             // Send an event so add-ons can prepopulate any non-preference based
             // settings
             let event = document.createEvent("Events");
             event.initEvent("AddonOptionsLoad", true, false);
             this.dispatchEvent(event);
 
             // Also send a notification to match the behavior of desktop Firefox
             let id = this.id.substring(17); // length of |urn:mozilla:item:|
-            Services.obs.notifyObservers(document, "addon-options-displayed", id);
+            Services.obs.notifyObservers(document,
+                                         AddonManager.OPTIONS_NOTIFICATION_DISPLAYED,
+                                         id);
           ]]>
         </body>
       </method>
     </implementation>
   </binding>
 
   <binding id="extension-searchplugin" extends="chrome://browser/content/bindings.xml#richlistitem">
     <content orient="vertical">
--- a/python/mach/mach/testing.py
+++ b/python/mach/mach/testing.py
@@ -22,16 +22,22 @@ class Testing(MozbuildObject, ArgumentPr
         s.run_suite(suite)
 
     def run_mochitest(self, test_file, flavor):
         from mozbuild.testing.mochitest import MochitestRunner
 
         mochitest = self._spawn(MochitestRunner)
         mochitest.run_mochitest_test(test_file, flavor)
 
+    def run_reftest(self, test_file, flavor):
+        from mozbuild.testing.reftest import ReftestRunner
+
+        reftest = self._spawn(ReftestRunner)
+        reftest.run_reftest_test(test_file, flavor)
+
     def run_xpcshell_test(self, **params):
         from mozbuild.testing.xpcshell import XPCShellRunner
 
         xpcshell = self._spawn(XPCShellRunner)
         xpcshell.run_test(**params)
 
     @staticmethod
     def populate_argparse(parser):
@@ -41,37 +47,61 @@ class Testing(MozbuildObject, ArgumentPr
         suites = set(['xpcshell', 'mochitest-plain', 'mochitest-chrome',
             'mochitest-browser', 'all'])
 
         group.add_argument('suite', default='all', choices=suites, nargs='?',
             help="Test suite to run.")
 
         group.set_defaults(cls=Testing, method='run_suite', suite='all')
 
+        # Mochitest-style
         mochitest_plain = parser.add_parser('mochitest-plain',
             help='Run a plain mochitest.')
-        mochitest_plain.add_argument('test_file', default='all', nargs='?',
+        mochitest_plain.add_argument('test_file', default=None, nargs='?',
             metavar='TEST', help=generic_help)
         mochitest_plain.set_defaults(cls=Testing, method='run_mochitest',
             flavor='plain')
 
         mochitest_chrome = parser.add_parser('mochitest-chrome',
             help='Run a chrome mochitest.')
-        mochitest_chrome.add_argument('test_file', default='all', nargs='?',
+        mochitest_chrome.add_argument('test_file', default=None, nargs='?',
             metavar='TEST', help=generic_help)
         mochitest_chrome.set_defaults(cls=Testing, method='run_mochitest',
             flavor='chrome')
 
         mochitest_browser = parser.add_parser('mochitest-browser',
             help='Run a mochitest with browser chrome.')
-        mochitest_browser.add_argument('test_file', default='all', nargs='?',
+        mochitest_browser.add_argument('test_file', default=None, nargs='?',
             metavar='TEST', help=generic_help)
         mochitest_browser.set_defaults(cls=Testing, method='run_mochitest',
             flavor='browser')
 
+        mochitest_a11y = parser.add_parser('mochitest-a11y',
+            help='Run an a11y mochitest.')
+        mochitest_a11y.add_argument('test_file', default=None, nargs='?',
+            metavar='TEST', help=generic_help)
+        mochitest_a11y.set_defaults(cls=Testing, method='run_mochitest',
+            flavor='a11y')
+
+        # Reftest-style
+        reftest = parser.add_parser('reftest',
+            help='Run a reftest.')
+        reftest.add_argument('test_file', default=None, nargs='?',
+            metavar='TEST', help=generic_help)
+        reftest.set_defaults(cls=Testing, method='run_reftest',
+            flavor='reftest')
+
+        crashtest = parser.add_parser('crashtest',
+            help='Run a crashtest.')
+        crashtest.add_argument('test_file', default=None, nargs='?',
+            metavar='TEST', help=generic_help)
+        crashtest.set_defaults(cls=Testing, method='run_reftest',
+            flavor='crashtest')
+
+        # XPCShell-style
         xpcshell = parser.add_parser('xpcshell-test',
             help="Run an individual xpcshell test.")
 
         xpcshell.add_argument('test_file', default='all', nargs='?',
             metavar='TEST', help=generic_help)
         xpcshell.add_argument('--debug', '-d', action='store_true',
             help='Run test in debugger.')
 
--- a/python/mozbuild/mozbuild/base.py
+++ b/python/mozbuild/mozbuild/base.py
@@ -3,24 +3,22 @@
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import unicode_literals
 
 import logging
 import multiprocessing
 import os
 import pymake.parser
-import shlex
 import sys
 import subprocess
 import which
 
 from mozprocess.processhandler import ProcessHandlerMixin
 from pymake.data import Makefile
-from tempfile import TemporaryFile
 
 from mozbuild.config import ConfigProvider
 from mozbuild.config import PositiveIntegerType
 
 
 # Perform detection of operating system environment. This is used by command
 # execution. We only do this once to save redundancy. Yes, this can fail module
 # loading. That is arguably OK.
@@ -186,18 +184,19 @@ class MozbuildObject(object):
         """Convert a relative path in the source directory to a full path."""
         return os.path.join(self.topsrcdir, path)
 
     def _get_objdir_path(self, path):
         """Convert a relative path in the object directory to a full path."""
         return os.path.join(self.topobjdir, path)
 
     def _run_make(self, directory=None, filename=None, target=None, log=True,
-            srcdir=False, allow_parallel=True, line_handler=None, env=None,
-            ignore_errors=False, silent=True, print_directory=True):
+            srcdir=False, allow_parallel=True, line_handler=None,
+            append_env=None, explicit_env=None, ignore_errors=False,
+            silent=True, print_directory=True):
         """Invoke make.
 
         directory -- Relative directory to look for Makefile in.
         filename -- Explicit makefile to run.
         target -- Makefile target(s) to make. Can be a string or iterable of
             strings.
         srcdir -- If True, invoke make from the source directory tree.
             Otherwise, make will be invoked from the object directory.
@@ -239,17 +238,18 @@ class MozbuildObject(object):
         fn = self._run_command_in_objdir
 
         if srcdir:
             fn = self._run_command_in_srcdir
 
         params = {
             'args': args,
             'line_handler': line_handler,
-            'explicit_env': env,
+            'append_env': append_env,
+            'explicit_env': explicit_env,
             'log_level': logging.INFO,
             'require_unix_environment': True,
             'ignore_errors': ignore_errors,
         }
 
         if log:
             params['log_name'] = 'make'
 
@@ -319,17 +319,19 @@ class MozbuildObject(object):
 
         use_env = {}
         if explicit_env:
             use_env = explicit_env
         else:
             use_env.update(os.environ)
 
             if append_env:
-                use_env.update(env)
+                use_env.update(append_env)
+
+        self.log(logging.DEBUG, 'process', {'env': use_env}, 'Environment: {env}')
 
         p = ProcessHandlerMixin(args, cwd=cwd, env=use_env,
             processOutputLine=[handleLine], universal_newlines=True)
         p.run()
         p.processOutput()
         status = p.wait()
 
         if status != 0 and not ignore_errors:
--- a/python/mozbuild/mozbuild/testing/mochitest.py
+++ b/python/mozbuild/mozbuild/testing/mochitest.py
@@ -1,20 +1,18 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import unicode_literals
 
-import os
-
-from mozbuild.base import MozbuildObject
+from mozbuild.testing.test import TestRunner
 
 
-class MochitestRunner(MozbuildObject):
+class MochitestRunner(TestRunner):
     """Easily run mochitests.
 
     This currently contains just the basics for running mochitests. We may want
     to hook up result parsing, etc.
     """
     def run_plain_suite(self):
         """Runs all plain mochitests."""
         # TODO hook up Python harness runner.
@@ -40,43 +38,31 @@ class MochitestRunner(MozbuildObject):
 
         test_file is a path to a test file. It can be a relative path from the
         top source directory, an absolute filename, or a directory containing
         test files.
 
         suite is the type of mochitest to run. It can be one of ('plain',
         'chrome', 'browser').
         """
-        if test_file is None:
-            raise Exception('test_file must be defined.')
-
-        parsed = self._parse_test_path(test_file)
 
         # TODO hook up harness via native Python
         target = None
         if suite == 'plain':
             target = 'mochitest-plain'
         elif suite == 'chrome':
             target = 'mochitest-chrome'
         elif suite == 'browser':
             target = 'mochitest-browser-chrome'
+        elif suite == 'a11y':
+            target = 'mochitest-a11y'
         else:
             raise Exception('None or unrecognized mochitest suite type.')
 
-        env = {'TEST_PATH': parsed['normalized']}
-
-        self._run_make(directory='.', target=target, env=env)
-
-    def _parse_test_path(self, test_path):
-        is_dir = os.path.isdir(test_path)
-
-        if is_dir and not test_path.endswith(os.path.sep):
-            test_path += os.path.sep
+        if test_file:
+            path = self._parse_test_path(test_file)['normalized']
+            if not os.path.exists(path):
+                raise Exception('No manifest file was found at %s.' % path)
+            env = {'TEST_PATH': path}
+        else:
+            env = {}
 
-        normalized = test_path
-
-        if test_path.startswith(self.topsrcdir):
-            normalized = test_path[len(self.topsrcdir):]
-
-        return {
-            'normalized': normalized,
-            'is_dir': is_dir,
-        }
+        self._run_make(directory='.', target=target, append_env=env)
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/testing/reftest.py
@@ -0,0 +1,62 @@
+# 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/.
+
+from __future__ import unicode_literals
+
+import os
+
+from mozbuild.testing.test import TestRunner
+
+
+class ReftestRunner(TestRunner):
+    """Easily run reftests.
+
+    This currently contains just the basics for running reftests. We may want
+    to hook up result parsing, etc.
+    """
+
+    def _manifest_file(self, suite):
+        """Returns the manifest file used for a given test suite."""
+        files = {
+          'reftest': 'reftest.list',
+          'crashtest': 'crashtests.list'
+        }
+        assert suite in files
+        return files[suite]
+
+    def _find_manifest(self, suite, test_file):
+        assert test_file
+        parsed = self._parse_test_path(test_file)
+        if parsed['is_dir']:
+            return os.path.join(parsed['normalized'], self._manifest_file(suite))
+
+        if parsed['normalized'].endswith('.list'):
+            return parsed['normalized']
+
+        raise Exception('Running a single test is not currently supported')
+
+    def run_reftest_test(self, test_file=None, suite=None):
+        """Runs a reftest.
+
+        test_file is a path to a test file. It can be a relative path from the
+        top source directory, an absolute filename, or a directory containing
+        test files.
+
+        suite is the type of reftest to run. It can be one of ('reftest',
+        'crashtest').
+        """
+
+        if suite not in ('reftest', 'crashtest'):
+            raise Exception('None or unrecognized reftest suite type.')
+
+        if test_file:
+            path = self._find_manifest(suite, test_file)
+            if not os.path.exists(path):
+                raise Exception('No manifest file was found at %s.' % path)
+            env = {'TEST_PATH': path}
+        else:
+            env = {}
+
+        # TODO hook up harness via native Python
+        self._run_make(directory='.', target=suite, append_env=env)
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/testing/test.py
@@ -0,0 +1,33 @@
+# 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/.
+
+from __future__ import unicode_literals
+
+import os
+
+from mozbuild.base import MozbuildObject
+
+
+class TestRunner(MozbuildObject):
+    """Base class to share code for parsing test paths."""
+
+    def _parse_test_path(self, test_path):
+        """Returns a dict containing:
+        * 'normalized': the normalized path, relative to the topsrcdir
+        * 'isdir': whether the path points to a directory
+        """
+        is_dir = os.path.isdir(test_path)
+
+        if is_dir and not test_path.endswith(os.path.sep):
+            test_path += os.path.sep
+
+        normalized = test_path
+
+        if test_path.startswith(self.topsrcdir):
+            normalized = test_path[len(self.topsrcdir):]
+
+        return {
+            'normalized': normalized,
+            'is_dir': is_dir,
+        }
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -2195,16 +2195,22 @@ var AddonManager = {
   // Constants for how Addon options should be shown.
   // Options will be opened in a new window
   OPTIONS_TYPE_DIALOG: 1,
   // Options will be displayed within the AM detail view
   OPTIONS_TYPE_INLINE: 2,
   // Options will be displayed in a new tab, if possible
   OPTIONS_TYPE_TAB: 3,
 
+  // Constants for displayed or hidden options notifications
+  // Options notification will be displayed
+  OPTIONS_NOTIFICATION_DISPLAYED: "addon-options-displayed",
+  // Options notification will be hidden
+  OPTIONS_NOTIFICATION_HIDDEN: "addon-options-hidden",
+
   // Constants for getStartupChanges, addStartupChange and removeStartupChange
   // Add-ons that were detected as installed during startup. Doesn't include
   // add-ons that were pending installation the last time the application ran.
   STARTUP_CHANGE_INSTALLED: "installed",
   // Add-ons that were detected as changed during startup. This includes an
   // add-on moving to a different location, changing version or just having
   // been detected as possibly changed.
   STARTUP_CHANGE_CHANGED: "changed",
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -2724,17 +2724,17 @@ var gDetailView = {
   },
 
   hide: function gDetailView_hide() {
     AddonManager.removeManagerListener(this);
     this.clearLoading();
     if (this._addon) {
       if (this._addon.optionsType == AddonManager.OPTIONS_TYPE_INLINE) {
         Services.obs.notifyObservers(document,
-                                     "addon-options-hidden",
+                                     AddonManager.OPTIONS_NOTIFICATION_HIDDEN,
                                      this._addon.id);
       }
 
       gEventManager.unregisterAddonListener(this, this._addon.id);
       gEventManager.unregisterInstallListener(this);
       this._addon = null;
 
       // Flush the preferences to disk so they survive any crash
@@ -2902,24 +2902,28 @@ var gDetailView = {
 
         // Ensure the page has loaded and force the XBL bindings to be synchronously applied,
         // then notify observers.
         if (gViewController.viewPort.selectedPanel.hasAttribute("loading")) {
           gDetailView.node.addEventListener("ViewChanged", function viewChangedEventListener() {
             gDetailView.node.removeEventListener("ViewChanged", viewChangedEventListener, false);
             if (firstSetting)
               firstSetting.clientTop;
-            Services.obs.notifyObservers(document, "addon-options-displayed", gDetailView._addon.id);
+            Services.obs.notifyObservers(document,
+                                         AddonManager.OPTIONS_NOTIFICATION_DISPLAYED,
+                                         gDetailView._addon.id);
             if (aScrollToPreferences)
               gDetailView.scrollToPreferencesRows();
           }, false);
         } else {
           if (firstSetting)
             firstSetting.clientTop;
-          Services.obs.notifyObservers(document, "addon-options-displayed", this._addon.id);
+          Services.obs.notifyObservers(document,
+                                       AddonManager.OPTIONS_NOTIFICATION_DISPLAYED,
+                                       this._addon.id);
           if (aScrollToPreferences)
             gDetailView.scrollToPreferencesRows();
         }
         if (aCallback)
           aCallback();
       }).bind(this);
       xhr.onerror = function fillSettingsRows_onerror(aEvent) {
         Cu.reportError("Error " + aEvent.target.status +
@@ -2964,17 +2968,17 @@ var gDetailView = {
     this.fillSettingsRows();
   },
 
   onDisabling: function gDetailView_onDisabling(aNeedsRestart) {
     this.updateState();
     if (!aNeedsRestart &&
         this._addon.optionsType == AddonManager.OPTIONS_TYPE_INLINE) {
       Services.obs.notifyObservers(document,
-                                   "addon-options-hidden",
+                                   AddonManager.OPTIONS_NOTIFICATION_HIDDEN,
                                    this._addon.id);
     }
   },
 
   onDisabled: function gDetailView_onDisabled() {
     this.updateState();
     this.emptySettingsRows();
   },
--- a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_inlinesettings.js
@@ -27,33 +27,33 @@ var observer = {
   checkHidden: function(aExpected) {
     is(this.lastHidden, aExpected, "'addon-options-hidden' notification should have fired");
     this.lastHidden = null;
   },
   checkNotHidden: function() {
     is(this.lastHidden, null, "'addon-options-hidden' notification should not have fired");
   },
   observe: function(aSubject, aTopic, aData) {
-    if (aTopic == "addon-options-displayed") {
+    if (aTopic == AddonManager.OPTIONS_NOTIFICATION_DISPLAYED) {
       this.lastDisplayed = aData;
       // Test if the binding has applied before the observers are notified. We test the second setting here,
       // because the code operates on the first setting and we want to check it applies to all.
       var setting = aSubject.querySelector("rows > setting[first-row] ~ setting");
       var input = gManagerWindow.document.getAnonymousElementByAttribute(setting, "class", "preferences-title");
       isnot(input, null, "XBL binding should be applied");
 
       // Add some extra height to the scrolling pane to ensure that it needs to scroll when appropriate.
       gManagerWindow.document.getElementById("detail-controls").style.marginBottom = "1000px";
 
       if (this.callback) {
         var tempCallback = this.callback;
         this.callback = null;
         tempCallback();
       }
-    } else if (aTopic == "addon-options-hidden") {
+    } else if (aTopic == AddonManager.OPTIONS_NOTIFICATION_HIDDEN) {
       this.lastHidden = aData;
     }
   }
 };
 
 function installAddon(aCallback) {
   AddonManager.getInstallForURL(TESTROOT + "addons/browser_inlinesettings1.xpi",
                                 function(aInstall) {
@@ -103,26 +103,31 @@ function test() {
     optionsURL: CHROMEROOT + "addon_prefs.xul"
   }]);
 
   installAddon(function () {
     open_manager("addons://list/extension", function(aWindow) {
       gManagerWindow = aWindow;
       gCategoryUtilities = new CategoryUtilities(gManagerWindow);
 
-      Services.obs.addObserver(observer, "addon-options-displayed", false);
-      Services.obs.addObserver(observer, "addon-options-hidden", false);
+      Services.obs.addObserver(observer,
+                               AddonManager.OPTIONS_NOTIFICATION_DISPLAYED,
+                               false);
+      Services.obs.addObserver(observer,
+                               AddonManager.OPTIONS_NOTIFICATION_HIDDEN,
+                               false);
 
       run_next_test();
     });
   });
 }
 
 function end_test() {
-  Services.obs.removeObserver(observer, "addon-options-displayed");
+  Services.obs.removeObserver(observer,
+                              AddonManager.OPTIONS_NOTIFICATION_DISPLAYED);
 
   Services.prefs.clearUserPref("extensions.inlinesettings1.bool");
   Services.prefs.clearUserPref("extensions.inlinesettings1.boolint");
   Services.prefs.clearUserPref("extensions.inlinesettings1.integer");
   Services.prefs.clearUserPref("extensions.inlinesettings1.string");
   Services.prefs.clearUserPref("extensions.inlinesettings1.color");
   Services.prefs.clearUserPref("extensions.inlinesettings1.file");
   Services.prefs.clearUserPref("extensions.inlinesettings1.directory");
@@ -130,17 +135,18 @@ function end_test() {
   Services.prefs.clearUserPref("extensions.inlinesettings3.radioInt");
   Services.prefs.clearUserPref("extensions.inlinesettings3.radioString");
   Services.prefs.clearUserPref("extensions.inlinesettings3.menulist");
 
   MockFilePicker.cleanup();
 
   close_manager(gManagerWindow, function() {
     observer.checkHidden("inlinesettings2@tests.mozilla.org");
-    Services.obs.removeObserver(observer, "addon-options-hidden");
+    Services.obs.removeObserver(observer,
+                                AddonManager.OPTIONS_NOTIFICATION_HIDDEN);
 
     AddonManager.getAddonByID("inlinesettings1@tests.mozilla.org", function(aAddon) {
       aAddon.uninstall();
       finish();
     });
   });
 }
 
--- a/xpcom/glue/nsTraceRefcnt.h
+++ b/xpcom/glue/nsTraceRefcnt.h
@@ -11,34 +11,34 @@
 
 #define NS_LOG_ADDREF(_p, _rc, _type, _size) \
   NS_LogAddRef((_p), (_rc), (_type), (uint32_t) (_size))
 
 #define NS_LOG_RELEASE(_p, _rc, _type) \
   NS_LogRelease((_p), (_rc), (_type))
 
 #define MOZ_COUNT_CTOR(_type)                                 \
-PR_BEGIN_MACRO                                                \
+do {                                                          \
   NS_LogCtor((void*)this, #_type, sizeof(*this));             \
-PR_END_MACRO
+} while (0)
 
 #define MOZ_COUNT_CTOR_INHERITED(_type, _base)                    \
-PR_BEGIN_MACRO                                                    \
+do {                                                              \
   NS_LogCtor((void*)this, #_type, sizeof(*this) - sizeof(_base)); \
-PR_END_MACRO
+} while (0)
 
 #define MOZ_COUNT_DTOR(_type)                                 \
-PR_BEGIN_MACRO                                                \
+do {                                                          \
   NS_LogDtor((void*)this, #_type, sizeof(*this));             \
-PR_END_MACRO
+} while (0)
 
 #define MOZ_COUNT_DTOR_INHERITED(_type, _base)                    \
-PR_BEGIN_MACRO                                                    \
+do {                                                              \
   NS_LogDtor((void*)this, #_type, sizeof(*this) - sizeof(_base)); \
-PR_END_MACRO
+} while (0)
 
 /* nsCOMPtr.h allows these macros to be defined by clients
  * These logging functions require dynamic_cast<void*>, so they don't
  * do anything useful if we don't have dynamic_cast<void*>. */
 #define NSCAP_LOG_ASSIGNMENT(_c, _p)                                \
   if (_p)                                                           \
     NS_LogCOMPtrAddRef((_c),static_cast<nsISupports*>(_p))
 
--- a/xpcom/glue/pldhash.h
+++ b/xpcom/glue/pldhash.h
@@ -5,16 +5,17 @@
 
 #ifndef pldhash_h___
 #define pldhash_h___
 /*
  * Double hashing, a la Knuth 6.
  *
  * Try to keep this file in sync with js/src/jsdhash.h.
  */
+#include "mozilla/Types.h"
 #include "nscore.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 #if defined(__GNUC__) && defined(__i386__) && (__GNUC__ >= 3) && !defined(XP_OS2)
 #define PL_DHASH_FASTCALL __attribute__ ((regparm (3),stdcall))
--- a/xpfe/appshell/src/nsChromeTreeOwner.cpp
+++ b/xpfe/appshell/src/nsChromeTreeOwner.cpp
@@ -253,18 +253,17 @@ NS_IMETHODIMP nsChromeTreeOwner::SizeShe
 }
 
 NS_IMETHODIMP
 nsChromeTreeOwner::SetPersistence(bool aPersistPosition,
                                   bool aPersistSize,
                                   bool aPersistSizeMode)
 {
   NS_ENSURE_STATE(mXULWindow);
-  nsCOMPtr<nsIDOMElement> docShellElement;
-  mXULWindow->GetWindowDOMElement(getter_AddRefs(docShellElement));
+  nsCOMPtr<nsIDOMElement> docShellElement = mXULWindow->GetWindowDOMElement();
   if (!docShellElement)
     return NS_ERROR_FAILURE;
 
   nsAutoString persistString;
   docShellElement->GetAttribute(gLiterals->kPersist, persistString);
 
   bool saveString = false;
   int32_t index;
@@ -291,18 +290,17 @@ nsChromeTreeOwner::SetPersistence(bool a
 }
 
 NS_IMETHODIMP
 nsChromeTreeOwner::GetPersistence(bool* aPersistPosition,
                                   bool* aPersistSize,
                                   bool* aPersistSizeMode)
 {
   NS_ENSURE_STATE(mXULWindow);
-  nsCOMPtr<nsIDOMElement> docShellElement;
-  mXULWindow->GetWindowDOMElement(getter_AddRefs(docShellElement));
+  nsCOMPtr<nsIDOMElement> docShellElement = mXULWindow->GetWindowDOMElement();
   if (!docShellElement) 
     return NS_ERROR_FAILURE;
 
   nsAutoString persistString;
   docShellElement->GetAttribute(gLiterals->kPersist, persistString);
 
   // data structure doesn't quite match the question, but it's close enough
   // for what we want (since this method is never actually called...)
--- a/xpfe/appshell/src/nsContentTreeOwner.cpp
+++ b/xpfe/appshell/src/nsContentTreeOwner.cpp
@@ -307,19 +307,18 @@ NS_IMETHODIMP nsContentTreeOwner::SizeSh
 }
 
 NS_IMETHODIMP
 nsContentTreeOwner::SetPersistence(bool aPersistPosition,
                                    bool aPersistSize,
                                    bool aPersistSizeMode)
 {
   NS_ENSURE_STATE(mXULWindow);
-  nsCOMPtr<nsIDOMElement> docShellElement;
-  mXULWindow->GetWindowDOMElement(getter_AddRefs(docShellElement));
-  if(!docShellElement)
+  nsCOMPtr<nsIDOMElement> docShellElement = mXULWindow->GetWindowDOMElement();
+  if (!docShellElement)
     return NS_ERROR_FAILURE;
 
   nsAutoString persistString;
   docShellElement->GetAttribute(NS_LITERAL_STRING("persist"), persistString);
 
   bool saveString = false;
   int32_t index;
 
@@ -376,19 +375,18 @@ nsContentTreeOwner::SetPersistence(bool 
 }
 
 NS_IMETHODIMP
 nsContentTreeOwner::GetPersistence(bool* aPersistPosition,
                                    bool* aPersistSize,
                                    bool* aPersistSizeMode)
 {
   NS_ENSURE_STATE(mXULWindow);
-  nsCOMPtr<nsIDOMElement> docShellElement;
-  mXULWindow->GetWindowDOMElement(getter_AddRefs(docShellElement));
-  if(!docShellElement) 
+  nsCOMPtr<nsIDOMElement> docShellElement = mXULWindow->GetWindowDOMElement();
+  if (!docShellElement)
     return NS_ERROR_FAILURE;
 
   nsAutoString persistString;
   docShellElement->GetAttribute(NS_LITERAL_STRING("persist"), persistString);
 
   // data structure doesn't quite match the question, but it's close enough
   // for what we want (since this method is never actually called...)
   if (aPersistPosition)
@@ -720,18 +718,17 @@ NS_IMETHODIMP nsContentTreeOwner::SetTit
   }
   else
     title.Assign(mWindowTitleModifier); // Title will just be plain "Mozilla"
 
   //
   // if there is no location bar we modify the title to display at least
   // the scheme and host (if any) as an anti-spoofing measure.
   //
-  nsCOMPtr<nsIDOMElement> docShellElement;
-  mXULWindow->GetWindowDOMElement(getter_AddRefs(docShellElement));
+  nsCOMPtr<nsIDOMElement> docShellElement = mXULWindow->GetWindowDOMElement();
 
   if (docShellElement) {
     nsAutoString chromeString;
     docShellElement->GetAttribute(NS_LITERAL_STRING("chromehidden"), chromeString);
     if (chromeString.Find(NS_LITERAL_STRING("location")) != kNotFound) {
       //
       // location bar is turned off, find the browser location
       //
@@ -951,21 +948,19 @@ private:
   nsCOMPtr<nsIDOMElement> mElement;
   nsString mTitleDefault;
 };
 #endif
 
 void nsContentTreeOwner::XULWindow(nsXULWindow* aXULWindow)
 {
    mXULWindow = aXULWindow;
-   if(mXULWindow && mPrimary)
-      {
+   if (mXULWindow && mPrimary) {
       // Get the window title modifiers
-      nsCOMPtr<nsIDOMElement> docShellElement;
-      mXULWindow->GetWindowDOMElement(getter_AddRefs(docShellElement));
+      nsCOMPtr<nsIDOMElement> docShellElement = mXULWindow->GetWindowDOMElement();
 
       nsAutoString   contentTitleSetting;
 
       if(docShellElement)  
          {
          docShellElement->GetAttribute(NS_LITERAL_STRING("contenttitlesetting"), contentTitleSetting);
          if(contentTitleSetting.EqualsLiteral("true"))
             {
--- a/xpfe/appshell/src/nsXULWindow.cpp
+++ b/xpfe/appshell/src/nsXULWindow.cpp
@@ -49,16 +49,17 @@
 #include "nsReadableUtils.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsContentUtils.h"
 #include "nsWebShellWindow.h" // get rid of this one, too...
 
 #include "prenv.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/dom/Element.h"
 
 using namespace mozilla;
 
 #define SIZEMODE_NORMAL     NS_LITERAL_STRING("normal")
 #define SIZEMODE_MAXIMIZED  NS_LITERAL_STRING("maximized")
 #define SIZEMODE_MINIMIZED  NS_LITERAL_STRING("minimized")
 #define SIZEMODE_FULLSCREEN NS_LITERAL_STRING("fullscreen")
 
@@ -998,21 +999,18 @@ bool nsXULWindow::LoadPositionFromXUL()
   nsresult rv;
   bool     gotPosition = false;
   
   // if we're the hidden window, don't try to validate our size/position. We're
   // special.
   if (mIsHiddenWindow)
     return false;
 
-  nsCOMPtr<nsIDOMElement> windowElement;
-  GetWindowDOMElement(getter_AddRefs(windowElement));
-  NS_ASSERTION(windowElement, "no xul:window");
-  if (!windowElement)
-    return false;
+  nsCOMPtr<nsIDOMElement> windowElement = GetWindowDOMElement();
+  NS_ENSURE_TRUE(windowElement, false);
 
   int32_t currX = 0;
   int32_t currY = 0;
   int32_t currWidth = 0;
   int32_t currHeight = 0;
   nsresult errorCode;
   int32_t temp;
 
@@ -1067,21 +1065,18 @@ bool nsXULWindow::LoadSizeFromXUL()
   nsresult rv;
   bool     gotSize = false;
   
   // if we're the hidden window, don't try to validate our size/position. We're
   // special.
   if (mIsHiddenWindow)
     return false;
 
-  nsCOMPtr<nsIDOMElement> windowElement;
-  GetWindowDOMElement(getter_AddRefs(windowElement));
-  NS_ASSERTION(windowElement, "no xul:window");
-  if (!windowElement)
-    return false;
+  nsCOMPtr<nsIDOMElement> windowElement = GetWindowDOMElement();
+  NS_ENSURE_TRUE(windowElement, false);
 
   int32_t currWidth = 0;
   int32_t currHeight = 0;
   nsresult errorCode;
   int32_t temp;
 
   GetSize(&currWidth, &currHeight);
 
@@ -1148,21 +1143,18 @@ bool nsXULWindow::LoadMiscPersistentAttr
   
   /* There are no misc attributes of interest to the hidden window.
      It's especially important not to try to validate that window's
      size or position, because some platforms (Mac OS X) need to
      make it visible and offscreen. */
   if (mIsHiddenWindow)
     return false;
 
-  nsCOMPtr<nsIDOMElement> windowElement;
-  GetWindowDOMElement(getter_AddRefs(windowElement));
-  NS_ASSERTION(windowElement, "no xul:window");
-  if (!windowElement)
-    return false;
+  nsCOMPtr<nsIDOMElement> windowElement = GetWindowDOMElement();
+  NS_ENSURE_TRUE(windowElement, false);
 
   nsAutoString stateString;
 
   // sizemode
   rv = windowElement->GetAttribute(NS_LITERAL_STRING("sizemode"), stateString);
   if (NS_SUCCEEDED(rv)) {
     int32_t sizeMode = nsSizeMode_Normal;
     /* ignore request to minimize, to not confuse novices
@@ -1238,18 +1230,20 @@ void nsXULWindow::StaggerPosition(int32_
   int      bouncedX = 0, // bounced off vertical edge of screen
            bouncedY = 0; // bounced off horizontal edge
 
   // look for any other windows of this type
   nsCOMPtr<nsIWindowMediator> wm(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
   if (!wm)
     return;
 
-  nsCOMPtr<nsIDOMElement> windowElement;
-  GetWindowDOMElement(getter_AddRefs(windowElement));
+  nsCOMPtr<nsIDOMElement> windowElement = GetWindowDOMElement();
+  if (!windowElement)
+    return;
+
   nsCOMPtr<nsIXULWindow> ourXULWindow(this);
 
   nsAutoString windowType;
   rv = windowElement->GetAttribute(WINDOWTYPE_ATTRIBUTE, windowType);
   if (NS_FAILED(rv))
     return;
 
   int32_t screenTop = 0,    // it's pointless to initialize these ...
@@ -1339,18 +1333,17 @@ void nsXULWindow::StaggerPosition(int32_
         }
       }
     } while(1);
   } while (keepTrying);
 }
 
 void nsXULWindow::SyncAttributesToWidget()
 {
-  nsCOMPtr<nsIDOMElement> windowElement;
-  GetWindowDOMElement(getter_AddRefs(windowElement));
+  nsCOMPtr<nsIDOMElement> windowElement = GetWindowDOMElement();
   if (!windowElement)
     return;
 
   nsAutoString attr;
 
   // "hidechrome" attribute
   nsresult rv = windowElement->GetAttribute(NS_LITERAL_STRING("hidechrome"), attr);
   if (NS_SUCCEEDED(rv) && attr.EqualsLiteral("true")) {
@@ -1405,18 +1398,17 @@ void nsXULWindow::SyncAttributesToWidget
 
 NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
 {
   // can happen when the persistence timer fires at an inopportune time
   // during window shutdown
   if (!mDocShell)
     return NS_ERROR_FAILURE;
 
-  nsCOMPtr<nsIDOMElement> docShellElement;
-  GetWindowDOMElement(getter_AddRefs(docShellElement));
+  nsCOMPtr<nsIDOMElement> docShellElement = GetWindowDOMElement();
   if (!docShellElement)
     return NS_ERROR_FAILURE;
 
   nsAutoString   persistString;
   docShellElement->GetAttribute(PERSIST_ATTRIBUTE, persistString);
   if (persistString.IsEmpty()) { // quick check which sometimes helps
     mPersistentAttributesDirty = 0;
     return NS_OK;
@@ -1532,35 +1524,32 @@ NS_IMETHODIMP nsXULWindow::GetWindowDOMW
     mDOMWindow = do_GetInterface(mDocShell);
   NS_ENSURE_TRUE(mDOMWindow, NS_ERROR_FAILURE);
 
   *aDOMWindow = mDOMWindow;
   NS_ADDREF(*aDOMWindow);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsXULWindow::GetWindowDOMElement(nsIDOMElement** aDOMElement)
+nsIDOMElement*
+nsXULWindow::GetWindowDOMElement() const
 {
-  NS_ENSURE_STATE(mDocShell);
-  NS_ENSURE_ARG_POINTER(aDOMElement);
-
-  *aDOMElement = nullptr;
+  NS_ENSURE_TRUE(mDocShell, nullptr);
 
   nsCOMPtr<nsIContentViewer> cv;
-
   mDocShell->GetContentViewer(getter_AddRefs(cv));
-  NS_ENSURE_TRUE(cv, NS_ERROR_FAILURE);
+  NS_ENSURE_TRUE(cv, nullptr);
 
-  nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(cv->GetDocument()));
-  NS_ENSURE_TRUE(domdoc, NS_ERROR_FAILURE);
+  const nsIDocument* document = cv->GetDocument();
+  NS_ENSURE_TRUE(document, nullptr);
 
-  domdoc->GetDocumentElement(aDOMElement);
-  NS_ENSURE_TRUE(*aDOMElement, NS_ERROR_FAILURE);
+  dom::Element* element = document->GetRootElement();
+  NS_ENSURE_TRUE(element, nullptr);
 
-  return NS_OK;
+  return static_cast<nsIDOMElement*>(element->AsDOMNode());
 }
 
 nsresult nsXULWindow::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
    bool aPrimary, bool aTargetable, const nsAString& aID)
 {
   nsContentShellInfo* shellInfo = nullptr;
 
   uint32_t i, count = mContentShells.Length();
@@ -1983,18 +1972,17 @@ bool nsXULWindow::GetContentScrollbarVis
 // during spinup, attributes that haven't been loaded yet can't be dirty
 void nsXULWindow::PersistentAttributesDirty(uint32_t aDirtyFlags)
 {
   mPersistentAttributesDirty |= aDirtyFlags & mPersistentAttributesMask;
 }
 
 NS_IMETHODIMP nsXULWindow::ApplyChromeFlags()
 {
-  nsCOMPtr<nsIDOMElement> window;
-  GetWindowDOMElement(getter_AddRefs(window));
+  nsCOMPtr<nsIDOMElement> window = GetWindowDOMElement();
   NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
 
   if (mChromeLoaded) {
     // The two calls in this block don't need to happen early because they
     // don't cause a global restyle on the document.  Not only that, but the
     // scrollbar stuff needs a content area to toggle the scrollbars on anyway.
     // So just don't do these until mChromeLoaded is true.
     
--- a/xpfe/appshell/src/nsXULWindow.h
+++ b/xpfe/appshell/src/nsXULWindow.h
@@ -86,17 +86,17 @@ protected:
                         int32_t aSpecWidth, int32_t aSpecHeight);
    bool       LoadPositionFromXUL();
    bool       LoadSizeFromXUL();
    bool       LoadMiscPersistentAttributesFromXUL();
    void       SyncAttributesToWidget();
    NS_IMETHOD SavePersistentAttributes();
 
    NS_IMETHOD GetWindowDOMWindow(nsIDOMWindow** aDOMWindow);
-   NS_IMETHOD GetWindowDOMElement(nsIDOMElement** aDOMElement);
+   nsIDOMElement* GetWindowDOMElement() const;
 
    // See nsIDocShellTreeOwner for docs on next two methods
    NS_HIDDEN_(nsresult) ContentShellAdded(nsIDocShellTreeItem* aContentShell,
                                           bool aPrimary, bool aTargetable,
                                           const nsAString& aID);
    NS_HIDDEN_(nsresult) ContentShellRemoved(nsIDocShellTreeItem* aContentShell);
    NS_IMETHOD SizeShellTo(nsIDocShellTreeItem* aShellItem, int32_t aCX, 
       int32_t aCY);