Merge m-c to autoland, a=merge
authorWes Kocher <wkocher@mozilla.com>
Fri, 27 Jan 2017 16:39:56 -0800
changeset 331459 f7722ba146bce06fef84c9bfbfa8231d8ef8351d
parent 331458 2492fd15497cc65221be1b76e72fb9329bcf77f6 (current diff)
parent 331438 dfb191cf603902107a80559996d0d5b37661287a (diff)
child 331460 8c317b40aa1085d5ca7f4f545f041521ef803720
push id31272
push userphilringnalda@gmail.com
push dateSat, 28 Jan 2017 21:07:30 +0000
treeherdermozilla-central@3ef3ab119a74 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge m-c to autoland, a=merge MozReview-Commit-ID: J5UyPvoy89k
security/nss/automation/release/nss-release-helper.py
security/nss/fuzz/cert_target.cc
security/nss/fuzz/initialize.cc
security/nss/fuzz/spki_target.cc
--- a/accessible/jsat/EventManager.jsm
+++ b/accessible/jsat/EventManager.jsm
@@ -111,17 +111,17 @@ this.EventManager.prototype = {
       {
         // the target could be an element, document or window
         let window = null;
         if (aEvent.target instanceof Ci.nsIDOMWindow)
           window = aEvent.target;
         else if (aEvent.target instanceof Ci.nsIDOMDocument)
           window = aEvent.target.defaultView;
         else if (aEvent.target instanceof Ci.nsIDOMElement)
-          window = aEvent.target.ownerDocument.defaultView;
+          window = aEvent.target.ownerGlobal;
         this.present(Presentation.viewportChanged(window));
         break;
       }
       }
     } catch (x) {
       Logger.logException(x, 'Error handling DOM event');
     }
   },
--- a/accessible/tests/mochitest/attributes.js
+++ b/accessible/tests/mochitest/attributes.js
@@ -28,17 +28,17 @@ function testAbsentAttrs(aAccOrElmOrID, 
 }
 
 /**
  * Test CSS based object attributes.
  */
 function testCSSAttrs(aID)
 {
   var node = document.getElementById(aID);
-  var computedStyle = document.defaultView.getComputedStyle(node, "");
+  var computedStyle = document.defaultView.getComputedStyle(node);
 
   var attrs = {
     "display": computedStyle.display,
     "text-align": computedStyle.textAlign,
     "text-indent": computedStyle.textIndent,
     "margin-left": computedStyle.marginLeft,
     "margin-right": computedStyle.marginRight,
     "margin-top": computedStyle.marginTop,
@@ -263,17 +263,17 @@ function fontFamily(aComputedStyle)
  * @param aID          [in] identifier of accessible
  * @param aFontSize    [in] font size
  * @param aFontWeight  [in, optional] kBoldFontWeight or kNormalFontWeight,
  *                      default value is kNormalFontWeight
  */
 function buildDefaultTextAttrs(aID, aFontSize, aFontWeight, aFontFamily)
 {
   var elm = getNode(aID);
-  var computedStyle = document.defaultView.getComputedStyle(elm, "");
+  var computedStyle = document.defaultView.getComputedStyle(elm);
   var bgColor = computedStyle.backgroundColor == "transparent" ?
     "rgb(255, 255, 255)" : computedStyle.backgroundColor;
 
   var defAttrs = {
     "font-style": computedStyle.fontStyle,
     "font-size": aFontSize,
     "background-color": bgColor,
     "font-weight": aFontWeight ? aFontWeight : kNormalFontWeight,
--- a/accessible/tests/mochitest/events.js
+++ b/accessible/tests/mochitest/events.js
@@ -107,17 +107,17 @@ function waitForEvent(aEventType, aTarge
 /**
  * Generate mouse move over image map what creates image map accessible (async).
  * See waitForImageMap() function.
  */
 function waveOverImageMap(aImageMapID)
 {
   var imageMapNode = getNode(aImageMapID);
   synthesizeMouse(imageMapNode, 10, 10, { type: "mousemove" },
-                  imageMapNode.ownerDocument.defaultView);
+                  imageMapNode.ownerGlobal);
 }
 
 /**
  * Call the given function when the tree of the given image map is built.
  */
 function waitForImageMap(aImageMapID, aTestFunc)
 {
   waveOverImageMap(aImageMapID);
@@ -1592,17 +1592,17 @@ function moveCaretToDOMPoint(aID, aDOMPo
   this.focus = aFocusTargetID ? getAccessible(aFocusTargetID) : null;
   this.focusNode = this.focus ? this.focus.DOMNode : null;
 
   this.invoke = function moveCaretToDOMPoint_invoke()
   {
     if (this.focusNode)
       this.focusNode.focus();
 
-    var selection = this.DOMPointNode.ownerDocument.defaultView.getSelection();
+    var selection = this.DOMPointNode.ownerGlobal.getSelection();
     var selRange = selection.getRangeAt(0);
     selRange.setStart(this.DOMPointNode, aDOMPointOffset);
     selRange.collapse(true);
 
     selection.removeRange(selRange);
     selection.addRange(selRange);
   }
 
--- a/accessible/tests/mochitest/events/test_focus_autocomplete.xul
+++ b/accessible/tests/mochitest/events/test_focus_autocomplete.xul
@@ -156,17 +156,17 @@
     function focusOnMouseOver(aIDFunc, aIDFuncArg)
     {
       this.eventSeq = [ new focusChecker(aIDFunc, aIDFuncArg) ];
 
       this.invoke = function focusOnMouseOver_invoke()
       {
         this.id = aIDFunc.call(null, aIDFuncArg);
         this.node = getNode(this.id);
-        this.window = this.node.ownerDocument.defaultView;
+        this.window = this.node.ownerGlobal;
 
         if (this.node.localName == "tree") {
           var tree = getAccessible(this.node);
           var accessible = getAccessible(this.id);
           if (tree != accessible) {
             var itemX = {}, itemY = {}, treeX = {}, treeY = {};
             accessible.getBounds(itemX, itemY, {}, {});
             tree.getBounds(treeX, treeY, {}, {});
@@ -214,17 +214,17 @@
                            aFocusTargetFunc, aFocusTargetFuncArg)
     {
       this.eventSeq = [ new focusChecker(aFocusTargetFunc, aFocusTargetFuncArg) ];
 
       this.invoke = function selectByClick_invoke()
       {
         var id = aIDFunc.call(null, aIDFuncArg);
         var node = getNode(id);
-        var targetWindow = node.ownerDocument.defaultView;
+        var targetWindow = node.ownerGlobal;
 
         var x = 0, y = 0;
         if (node.localName == "tree") {
           var tree = getAccessible(node);
           var accessible = getAccessible(id);
           if (tree != accessible) {
             var itemX = {}, itemY = {}, treeX = {}, treeY = {};
             accessible.getBounds(itemX, itemY, {}, {});
--- a/accessible/tests/mochitest/layout.js
+++ b/accessible/tests/mochitest/layout.js
@@ -230,17 +230,17 @@ function getBoundsForDOMElm(aID)
   else {
     var rect = elm.getBoundingClientRect();
     x = rect.left;
     y = rect.top;
     width = rect.width;
     height = rect.height;
   }
 
-  var elmWindow = elm.ownerDocument.defaultView;
+  var elmWindow = elm.ownerGlobal;
   return CSSToDevicePixels(elmWindow,
                            x + elmWindow.mozInnerScreenX,
                            y + elmWindow.mozInnerScreenY,
                            width,
                            height);
 }
 
 function CSSToDevicePixels(aWindow, aX, aY, aWidth, aHeight)
--- a/accessible/tests/mochitest/textattrs/test_general.html
+++ b/accessible/tests/mochitest/textattrs/test_general.html
@@ -48,17 +48,17 @@
 
       attrs = {};
       testTextAttrs(ID, 0, attrs, defAttrs, 0, 7);
 
       attrs = { "font-weight": kBoldFontWeight };
       testTextAttrs(ID, 7, attrs, defAttrs, 7, 12);
 
       var tempElem = getNode(ID).firstChild.nextSibling.firstChild.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = {"font-style": gComputedStyle.fontStyle,
                "font-weight": kBoldFontWeight };
       testTextAttrs(ID, 13, attrs, defAttrs, 12, 19);
 
       attrs = { "font-weight": kBoldFontWeight };
       testTextAttrs(ID, 20, attrs, defAttrs, 19, 23);
 
       attrs = {};
@@ -66,66 +66,66 @@
 
       //////////////////////////////////////////////////////////////////////////
       // area3
       ID = "area3";
       defAttrs = buildDefaultTextAttrs(ID, "12pt");
       testDefaultTextAttrs(ID, defAttrs);
 
       tempElem = getNode(ID).firstChild.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = {"color": gComputedStyle.color};
       testTextAttrs(ID, 0, attrs, defAttrs, 0, 6);
 
       tempElem = tempElem.firstChild.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = {"color": gComputedStyle.color};
       testTextAttrs(ID, 6, attrs, defAttrs, 6, 26);
 
       tempElem = tempElem.parentNode;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = {"color": gComputedStyle.color};
       testTextAttrs(ID, 26, attrs, defAttrs, 26, 27);
 
       tempElem = tempElem.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = {"color": gComputedStyle.color,
                "background-color": gComputedStyle.backgroundColor};
       testTextAttrs(ID, 27, attrs, defAttrs, 27, 50);
 
       //////////////////////////////////////////////////////////////////////////
       // area4
       ID = "area4";
       defAttrs = buildDefaultTextAttrs(ID, "12pt");
       testDefaultTextAttrs(ID, defAttrs);
 
       tempElem = getNode(ID).firstChild.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = {"color": gComputedStyle.color};
       testTextAttrs(ID, 0, attrs, defAttrs, 0, 16);
 
       tempElem = tempElem.nextSibling.firstChild.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = {"color": gComputedStyle.color};
       testTextAttrs(ID, 16, attrs, defAttrs, 16, 33);
 
       tempElem = tempElem.parentNode;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = {"color": gComputedStyle.color};
       testTextAttrs(ID, 34, attrs, defAttrs, 33, 46);
 
       //////////////////////////////////////////////////////////////////////////
       // area5: "Green!*!RedNormal"
       ID = "area5";
       defAttrs = buildDefaultTextAttrs(ID, "12pt");
       testDefaultTextAttrs(ID, defAttrs);
 
       // Green
       tempElem = getNode(ID).firstChild.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = {"color": gComputedStyle.color};
       testTextAttrs(ID, 0, attrs, defAttrs, 0, 5);
 
       // br
       attrs = {};
       testTextAttrs(ID, 5, attrs, defAttrs, 5, 6);
 
       // img, embedded accessible, no attributes
@@ -133,17 +133,17 @@
       testTextAttrs(ID, 6, attrs, {}, 6, 7);
 
       // br
       attrs = {};
       testTextAttrs(ID, 7, attrs, defAttrs, 7, 8);
 
       // Red
       tempElem = tempElem.nextSibling.nextSibling.nextSibling.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = {"color": gComputedStyle.color};
       testTextAttrs(ID, 9, attrs, defAttrs, 8, 11);
 
       // Normal
       attrs = {};
       testTextAttrs(ID, 11, attrs, defAttrs, 11, 18);
 
       //////////////////////////////////////////////////////////////////////////
@@ -210,45 +210,45 @@
 
       attrs = {"language": "ru"};
       testTextAttrs(ID, 0, attrs, defAttrs, 0, 6);
 
       attrs = {};
       testTextAttrs(ID, 6, attrs, defAttrs, 6, 7);
 
       tempElem = getNode(ID).firstChild.nextSibling.nextSibling.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = { "background-color": gComputedStyle.backgroundColor};
       testTextAttrs(ID, 13, attrs, defAttrs, 7, 20);
 
       attrs = {};
       testTextAttrs(ID, 20, attrs, defAttrs, 20, 21);
 
       attrs = {"language": "de"};
       testTextAttrs(ID, 21, attrs, defAttrs, 21, 36);
 
       attrs = {};
       testTextAttrs(ID, 36, attrs, defAttrs, 36, 44);
 
       attrs = {};
       testTextAttrs(ID, 37, attrs, defAttrs, 36, 44);
 
       tempElem = tempElem.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = {"color": gComputedStyle.color};
       testTextAttrs(ID, 44, attrs, defAttrs, 44, 51);
 
       tempElem = tempElem.firstChild.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = {"font-weight": kBoldFontWeight,
                "color": gComputedStyle.color};
       testTextAttrs(ID, 51, attrs, defAttrs, 51, 55);
 
       tempElem = tempElem.parentNode;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = {"color": gComputedStyle.color};
       testTextAttrs(ID, 55, attrs, defAttrs, 55, 62);
 
       //////////////////////////////////////////////////////////////////////////
       // area9, different single style spans in styled paragraph
       ID = "area9";
       defAttrs = buildDefaultTextAttrs(ID, "10pt");
       testDefaultTextAttrs(ID, defAttrs);
@@ -259,35 +259,35 @@
       attrs = { "font-size": "12pt" };
       testTextAttrs(ID, 7, attrs, defAttrs, 6, 12);
 
       attrs = {};
       testTextAttrs(ID, 13, attrs, defAttrs, 12, 21);
 
       // Walk to the span with the different background color
       tempElem = getNode(ID).firstChild.nextSibling.nextSibling.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = { "background-color": gComputedStyle.backgroundColor };
       testTextAttrs(ID, 22, attrs, defAttrs, 21, 36);
 
       attrs = {};
       testTextAttrs(ID, 37, attrs, defAttrs, 36, 44);
 
       // Walk from the background color span to the one with font-style
       tempElem = tempElem.nextSibling.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = { "font-style": gComputedStyle.fontStyle };
       testTextAttrs(ID, 45, attrs, defAttrs, 44, 61);
 
       attrs = {};
       testTextAttrs(ID, 62, attrs, defAttrs, 61, 69);
 
       // Walk from span with font-style to the one with font-family.
       tempElem = tempElem.nextSibling.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = { "font-family": kMonospaceFontFamily };
       testTextAttrs(ID, 70, attrs, defAttrs, 69, 83);
 
       attrs = {};
       testTextAttrs(ID, 84, attrs, defAttrs, 83, 91);
 
       attrs = {
         "text-underline-style": "solid",
@@ -337,35 +337,35 @@
       attrs = { "font-size": "14pt" };
       testTextAttrs(ID, 7, attrs, defAttrs, 7, 13);
 
       attrs = {};
       testTextAttrs(ID, 13, attrs, defAttrs, 13, 22);
 
       // Walk to the span with the different background color
       tempElem = getNode(ID).firstChild.nextSibling.nextSibling.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = { "background-color": gComputedStyle.backgroundColor };
       testTextAttrs(ID, 23, attrs, defAttrs, 22, 37);
 
       attrs = {};
       testTextAttrs(ID, 38, attrs, defAttrs, 37, 45);
 
       // Walk from the background color span to the one with font-style
       tempElem = tempElem.nextSibling.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = {"font-style": gComputedStyle.fontStyle};
       testTextAttrs(ID, 46, attrs, defAttrs, 45, 62);
 
       attrs = {};
       testTextAttrs(ID, 63, attrs, defAttrs, 62, 70);
 
       // Walk from span with font-style to the one with font-family.
       tempElem = tempElem.nextSibling.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = { "font-family": kMonospaceFontFamily };
       testTextAttrs(ID, 71, attrs, defAttrs, 70, 84);
 
       attrs = {};
       testTextAttrs(ID, 85, attrs, defAttrs, 84, 92);
 
       attrs = {
         "text-underline-style": "solid",
@@ -550,17 +550,17 @@
       // text enclosed in mark tag will have a different background color
       ID = "area19";
       defAttrs = buildDefaultTextAttrs(ID, "12pt");
 
       attrs = {};
       testTextAttrs(ID, 0, attrs, defAttrs, 0, 10);
       
       tempElem = getNode(ID).firstChild.nextSibling;
-      gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
+      gComputedStyle = document.defaultView.getComputedStyle(tempElem);
       attrs = { "background-color": gComputedStyle.backgroundColor };
       testTextAttrs(ID, 11, attrs, defAttrs, 10, 17);
 
       attrs = {};
       testTextAttrs(ID, 18, attrs, defAttrs, 17, 28);
 
        //////////////////////////////////////////////////////////////////////////
       // area20, "aOffset as -1 (Mozilla Bug 789621)" test
--- a/addon-sdk/source/lib/framescript/context-menu.js
+++ b/addon-sdk/source/lib/framescript/context-menu.js
@@ -57,21 +57,21 @@ const SVG_NS = "http://www.w3.org/2000/s
 // directly. If the media is actually audio, be smarter and provide a
 // context menu with audio operations.
 // Source: https://github.com/mozilla/gecko-dev/blob/28c2fca3753c5371643843fc2f2f205146b083b7/browser/base/content/nsContextMenu.js#L632-L637
 const isVideoLoadingAudio = node =>
   node.readyState >= node.HAVE_METADATA &&
     (node.videoWidth == 0 || node.videoHeight == 0)
 
 const isVideo = node =>
-  node instanceof node.ownerDocument.defaultView.HTMLVideoElement &&
+  node instanceof node.ownerGlobal.HTMLVideoElement &&
   !isVideoLoadingAudio(node);
 
 const isAudio = node => {
-  const {HTMLVideoElement, HTMLAudioElement} = node.ownerDocument.defaultView;
+  const {HTMLVideoElement, HTMLAudioElement} = node.ownerGlobal;
   return node instanceof HTMLAudioElement ? true :
          node instanceof HTMLVideoElement ? isVideoLoadingAudio(node) :
          false;
 };
 
 const isImage = ({namespaceURI, localName}) =>
   namespaceURI === HTML_NS && localName === "img" ? true :
   namespaceURI === XUL_NS && localName === "image" ? true :
@@ -160,22 +160,22 @@ const nonPageElements = ["a", "applet", 
 const nonPageSelector = nonPageElements.
                           concat(nonPageElements.map(tag => `${tag} *`)).
                           join(", ");
 
 // Note: isPageContext implementation could have actually used SelectorMatch reader,
 // but old implementation was also checked for collapsed selection there for to keep
 // the behavior same we end up implementing a new reader.
 parsers["reader/isPage()"] = constant(node =>
-  node.ownerDocument.defaultView.getSelection().isCollapsed &&
+  node.ownerGlobal.getSelection().isCollapsed &&
   !node.matches(nonPageSelector));
 
 // Reads `true` if node is in an iframe otherwise returns true.
 parsers["reader/isFrame()"] = constant(node =>
-  !!node.ownerDocument.defaultView.frameElement);
+  !!node.ownerGlobal.frameElement);
 
 parsers["reader/isEditable()"] = constant(node => {
   const selection = getInputSelection(node);
   return selection ? !node.readOnly && !node.disabled : node.isContentEditable;
 });
 
 
 // TODO: Add some reader to read out tab id.
--- a/addon-sdk/source/lib/framescript/util.js
+++ b/addon-sdk/source/lib/framescript/util.js
@@ -16,10 +16,10 @@ const windowToMessageManager = window =>
     getInterface(Ci.nsIDocShell).
     sameTypeRootTreeItem.
     QueryInterface(Ci.nsIDocShell).
     QueryInterface(Ci.nsIInterfaceRequestor).
     getInterface(Ci.nsIContentFrameMessageManager);
 exports.windowToMessageManager = windowToMessageManager;
 
 const nodeToMessageManager = node =>
-  windowToMessageManager(node.ownerDocument.defaultView);
+  windowToMessageManager(node.ownerGlobal);
 exports.nodeToMessageManager = nodeToMessageManager;
--- a/addon-sdk/source/lib/sdk/content/context-menu.js
+++ b/addon-sdk/source/lib/sdk/content/context-menu.js
@@ -127,17 +127,17 @@ var Context = Class({
 
 // Matches when the context-clicked node doesn't have any of
 // NON_PAGE_CONTEXT_ELTS in its ancestors
 CONTEXTS.PageContext = Class({
   extends: Context,
 
   getState: function(popupNode) {
     // If there is a selection in the window then this context does not match
-    if (!popupNode.ownerDocument.defaultView.getSelection().isCollapsed)
+    if (!popupNode.ownerGlobal.getSelection().isCollapsed)
       return false;
 
     // If the clicked node or any of its ancestors is one of the blocked
     // NON_PAGE_CONTEXT_ELTS then this context does not match
     while (!(popupNode instanceof Ci.nsIDOMDocument)) {
       if (NON_PAGE_CONTEXT_ELTS.some(type => popupNode instanceof type))
         return false;
 
@@ -148,17 +148,17 @@ CONTEXTS.PageContext = Class({
   }
 });
 
 // Matches when there is an active selection in the window
 CONTEXTS.SelectionContext = Class({
   extends: Context,
 
   getState: function(popupNode) {
-    if (!popupNode.ownerDocument.defaultView.getSelection().isCollapsed)
+    if (!popupNode.ownerGlobal.getSelection().isCollapsed)
       return true;
 
     try {
       // The node may be a text box which has selectionStart and selectionEnd
       // properties. If not this will throw.
       let { selectionStart, selectionEnd } = popupNode;
       return !isNaN(selectionStart) && !isNaN(selectionEnd) &&
              selectionStart !== selectionEnd;
@@ -206,17 +206,17 @@ CONTEXTS.URLContext = Class({
   }
 });
 
 // Matches when the user-supplied predicate returns true
 CONTEXTS.PredicateContext = Class({
   extends: Context,
 
   getState: function(node) {
-    let window = node.ownerDocument.defaultView;
+    let window = node.ownerGlobal;
     let data = {};
 
     data.documentType = node.ownerDocument.contentType;
 
     data.documentURL = node.ownerDocument.location.href;
     data.targetName = node.nodeName.toLowerCase();
     data.targetID = node.id || null ;
 
@@ -320,17 +320,17 @@ var RemoteItem = Class({
   destroy: function() {
     for (let worker of this.workerMap.values()) {
       worker.destroy();
     }
     keepAlive.delete(this.id);
   },
 
   activate: function(popupNode, data) {
-    let worker = getItemWorkerForWindow(this, popupNode.ownerDocument.defaultView);
+    let worker = getItemWorkerForWindow(this, popupNode.ownerGlobal);
     if (!worker)
       return;
 
     for (let context of this.contexts)
       popupNode = context.adjustPopupNode(popupNode);
 
     worker.fireClick(popupNode, data);
   },
@@ -339,17 +339,17 @@ var RemoteItem = Class({
   getContextState: function(popupNode, addonInfo) {
     if (!(self.id in addonInfo)) {
       addonInfo[self.id] = {
         processID: process.id,
         items: {}
       };
     }
 
-    let worker = getItemWorkerForWindow(this, popupNode.ownerDocument.defaultView);
+    let worker = getItemWorkerForWindow(this, popupNode.ownerGlobal);
     let contextStates = {};
     for (let context of this.contexts)
       contextStates[context.id] = context.getState(popupNode);
 
     addonInfo[self.id].items[this.id] = {
       // It isn't ideal to create a PageContext for every item but there isn't
       // a good shared place to do it.
       pageContext: (new CONTEXTS.PageContext()).getState(popupNode),
--- a/addon-sdk/source/lib/sdk/context-menu.js
+++ b/addon-sdk/source/lib/sdk/context-menu.js
@@ -991,17 +991,17 @@ var MenuWrapper = Class({
       if (internal(this.items).children.length == 0)
         return;
 
       if (!this.populated) {
         this.populated = true;
         this.populate(this.items);
       }
 
-      let mainWindow = event.target.ownerDocument.defaultView;
+      let mainWindow = event.target.ownerGlobal;
       this.contextMenuContentData = mainWindow.gContextMenuContentData
       if (!(self.id in this.contextMenuContentData.addonInfo)) {
         console.warn("No context menu state data was provided.");
         return;
       }
       let addonInfo = this.contextMenuContentData.addonInfo[self.id];
       lastContextProcessId = addonInfo.processID;
       this.setVisibility(this.items, addonInfo.items, true);
--- a/addon-sdk/source/lib/sdk/dom/events.js
+++ b/addon-sdk/source/lib/sdk/dom/events.js
@@ -152,17 +152,17 @@ function emit(element, type, { category,
   }
 };
 exports.emit = emit;
 
 // Takes DOM `element` and returns promise which is resolved
 // when given element is removed from it's parent node.
 const removed = element => {
   return new Promise(resolve => {
-    const { MutationObserver } = element.ownerDocument.defaultView;
+    const { MutationObserver } = element.ownerGlobal;
     const observer = new MutationObserver(mutations => {
       for (let mutation of mutations) {
         for (let node of mutation.removedNodes || []) {
           if (node === element) {
             observer.disconnect();
             resolve(element);
           }
         }
--- a/addon-sdk/source/lib/sdk/event/dom.js
+++ b/addon-sdk/source/lib/sdk/event/dom.js
@@ -16,17 +16,17 @@ var listeners = new WeakMap();
 
 const { Cu } = require("chrome");
 const { ShimWaiver } = Cu.import("resource://gre/modules/ShimWaiver.jsm");
 const { ThreadSafeChromeUtils } = Cu.import("resource://gre/modules/Services.jsm", {});
 
 var getWindowFrom = x =>
                     x instanceof Ci.nsIDOMWindow ? x :
                     x instanceof Ci.nsIDOMDocument ? x.defaultView :
-                    x instanceof Ci.nsIDOMNode ? x.ownerDocument.defaultView :
+                    x instanceof Ci.nsIDOMNode ? x.ownerGlobal :
                     null;
 
 function removeFromListeners() {
   ShimWaiver.getProperty(this, "removeEventListener")("DOMWindowClose", removeFromListeners);
   for (let cleaner of listeners.get(this))
     cleaner();
 
   listeners.delete(this);
--- a/addon-sdk/source/lib/sdk/keyboard/observer.js
+++ b/addon-sdk/source/lib/sdk/keyboard/observer.js
@@ -45,14 +45,13 @@ const Observer = Class({
   /**
    * Function handles all the supported events on all the windows that are
    * observed. Method is used to proxy events to the listeners registered on
    * this event emitter.
    * @param {Event} event
    *    Keyboard event being emitted.
    */
   handleEvent(event) {
-    emit(this, event.type, event, event.target.ownerDocument ? event.target.ownerDocument.defaultView
-                                                             : undefined);
+    emit(this, event.type, event, event.target.ownerGlobal || undefined);
   }
 });
 
 exports.observer = new Observer();
--- a/addon-sdk/source/lib/sdk/panel/utils.js
+++ b/addon-sdk/source/lib/sdk/panel/utils.js
@@ -133,17 +133,17 @@ function display(panel, options, anchor)
     let viewportRect = document.defaultView.gBrowser.getBoundingClientRect();
 
     ({x, y, width, height} = calculateRegion(options, viewportRect));
   }
   else {
     // The XUL Panel has an arrow, so the margin needs to be reset
     // to the default value.
     panel.style.margin = "";
-    let { CustomizableUI, window } = anchor.ownerDocument.defaultView;
+    let { CustomizableUI, window } = anchor.ownerGlobal;
 
     // In Australis, widgets may be positioned in an overflow panel or the
     // menu panel.
     // In such cases clicking this widget will hide the overflow/menu panel,
     // and the widget's panel will show instead.
     // If `CustomizableUI` is not available, it means the anchor is not in a
     // chrome browser window, and therefore there is no need for this check.
     if (CustomizableUI) {
--- a/addon-sdk/source/lib/sdk/selection.js
+++ b/addon-sdk/source/lib/sdk/selection.js
@@ -140,17 +140,17 @@ function getFocusedWindow() {
  * Returns the focused element in the most recent focused window
  * if private browsing window is most recent and not supported,
  * then ignore it and return `null`, because the focused element
  * can't be targeted.
  */
 function getFocusedElement() {
   let element = winUtils.getFocusedElement();
 
-  if (!element || ignoreWindow(element.ownerDocument.defaultView))
+  if (!element || ignoreWindow(element.ownerGlobal))
     return null;
 
   return element;
 }
 
 /**
  * Returns the current selection from most recent content window. Depending on
  * the specified |type|, the value returned can be a string of text, stringified
--- a/addon-sdk/source/lib/sdk/tab/events.js
+++ b/addon-sdk/source/lib/sdk/tab/events.js
@@ -63,12 +63,12 @@ function makeEvents() {
   // to cover all tab events on all windows that will open.
   return merge([eventsFromInteractive, eventsFromFuture]);
 }
 
 // Map events to Fennec format if necessary
 exports.events = map(makeEvents(), function (event) {
   return !isFennec ? event : {
     type: event.type,
-    target: event.target.ownerDocument.defaultView.BrowserApp
+    target: event.target.ownerGlobal.BrowserApp
             .getTabForBrowser(event.target)
   };
 });
--- a/addon-sdk/source/lib/sdk/tabs/tab-firefox.js
+++ b/addon-sdk/source/lib/sdk/tabs/tab-firefox.js
@@ -62,17 +62,17 @@ const Tab = Class({
       // Note that activate is defered and so will run after any open event
       // is sent out
       if (!options.inBackground)
         this.activate();
     }
 
     getURL.implement(this, tab => tab.url);
     isPrivate.implement(this, tab => {
-      return isWindowPrivate(viewsFor.get(tab).ownerDocument.defaultView);
+      return isWindowPrivate(viewsFor.get(tab).ownerGlobal);
     });
   },
 
   get id() {
     return isDestroyed(this) ? undefined : getTabId(viewsFor.get(this));
   },
 
   get title() {
@@ -118,17 +118,17 @@ const Tab = Class({
 
   get window() {
     if (isClosed(this))
       return undefined;
 
     // TODO: Remove the dependency on the windows module, see bug 792670
     require('../windows');
     let tabElement = viewsFor.get(this);
-    let domWindow = tabElement.ownerDocument.defaultView;
+    let domWindow = tabElement.ownerGlobal;
     return modelFor(domWindow);
   },
 
   get readyState() {
     return isDestroyed(this) ? undefined : this[remoteReadyStateCached] || "uninitialized";
   },
 
   pin: function() {
@@ -251,17 +251,17 @@ function maybeWindowFor(domWindow) {
 function tabEmit(tab, event, ...args) {
   // Don't emit events for destroyed tabs
   if (isDestroyed(tab))
     return;
 
   // If the windows module was never loaded this will return null. We don't need
   // to emit to the window.tabs object in this case as nothing can be listening.
   let tabElement = viewsFor.get(tab);
-  let window = maybeWindowFor(tabElement.ownerDocument.defaultView);
+  let window = maybeWindowFor(tabElement.ownerGlobal);
   if (window)
     emit(window.tabs, event, tab, ...args);
 
   emit(tabEvents, event, tab, ...args);
   emit(tab, event, tab, ...args);
 }
 
 function windowClosed(domWindow) {
@@ -276,17 +276,17 @@ windowObserver.on('close', windowClosed)
 
 // Don't want to send close events after unloaded
 when(_ => {
   windowObserver.off('close', windowClosed);
 });
 
 // Listen for tabbrowser events
 function tabEventListener(event, tabElement, ...args) {
-  let domWindow = tabElement.ownerDocument.defaultView;
+  let domWindow = tabElement.ownerGlobal;
 
   if (ignoreWindow(domWindow))
     return;
 
   // Don't send events for tabs that are already closing
   if (event != "close" && (tabElement.closing || !tabElement.parentNode))
     return;
 
--- a/addon-sdk/source/lib/sdk/tabs/utils.js
+++ b/addon-sdk/source/lib/sdk/tabs/utils.js
@@ -101,17 +101,17 @@ exports.getTabs = getTabs;
 function getActiveTab(window) {
   return getSelectedTab(window);
 }
 exports.getActiveTab = getActiveTab;
 
 function getOwnerWindow(tab) {
   // normal case
   if (tab.ownerDocument)
-    return tab.ownerDocument.defaultView;
+    return tab.ownerGlobal;
 
   // try fennec case
   return getWindowHoldingTab(tab);
 }
 exports.getOwnerWindow = getOwnerWindow;
 
 // fennec
 function getWindowHoldingTab(rawTab) {
--- a/addon-sdk/source/lib/sdk/ui/button/view.js
+++ b/addon-sdk/source/lib/sdk/ui/button/view.js
@@ -46,17 +46,17 @@ const buttonListener = {
 
       if (placement)
         emit(viewEvents, 'data', { type: 'update', target: id, window: window });
     }
   },
   onWidgetAfterDOMChange: (node, nextNode, container) => {
     let { id } = node;
     let view = views.get(id);
-    let window = node.ownerDocument.defaultView;
+    let window = node.ownerGlobal;
 
     if (view) {
       emit(viewEvents, 'data', { type: 'update', target: id, window: window });
     }
   }
 };
 
 CustomizableUI.addListener(buttonListener);
--- a/addon-sdk/source/lib/sdk/window/helpers.js
+++ b/addon-sdk/source/lib/sdk/window/helpers.js
@@ -66,16 +66,15 @@ function startup(window) {
   return result;
 }
 exports.startup = startup;
 
 function promise(target, evt, capture) {
   let deferred = defer();
   capture = !!capture;
 
-  target.addEventListener(evt, function eventHandler() {
-    target.removeEventListener(evt, eventHandler, capture);
+  target.addEventListener(evt, function() {
     deferred.resolve(target);
-  }, capture);
+  }, {capture, once: true});
 
   return deferred.promise;
 }
 exports.promise = promise;
--- a/addon-sdk/source/lib/sdk/window/utils.js
+++ b/addon-sdk/source/lib/sdk/window/utils.js
@@ -410,17 +410,17 @@ function getScreenPixelsPerCSSPixel(wind
                 getInterface(Ci.nsIDOMWindowUtils).screenPixelsPerCSSPixel;
 }
 exports.getScreenPixelsPerCSSPixel = getScreenPixelsPerCSSPixel;
 
 function getOwnerBrowserWindow(node) {
   /**
   Takes DOM node and returns browser window that contains it.
   **/
-  let window = getToplevelWindow(node.ownerDocument.defaultView);
+  let window = getToplevelWindow(node.ownerGlobal);
   // If anchored window is browser then it's target browser window.
   return isBrowser(window) ? window : null;
 }
 exports.getOwnerBrowserWindow = getOwnerBrowserWindow;
 
 function getParentWindow(window) {
   try {
     return window.QueryInterface(Ci.nsIInterfaceRequestor)
--- a/addon-sdk/source/test/addons/e10s-content/lib/test-content-worker.js
+++ b/addon-sdk/source/test/addons/e10s-content/lib/test-content-worker.js
@@ -45,20 +45,19 @@ function makeWindow() {
 
   return Cc["@mozilla.org/embedcomp/window-watcher;1"].
          getService(Ci.nsIWindowWatcher).
          openWindow(null, url, null, features.join(","), null);
 }
 
 // Listen for only first one occurence of DOM event
 function listenOnce(node, eventName, callback) {
-  node.addEventListener(eventName, function onevent(event) {
-    node.removeEventListener(eventName, onevent, true);
+  node.addEventListener(eventName, function(event) {
     callback(node);
-  }, true);
+  }, {capture: true, once: true});
 }
 
 // Load a given url in a given browser and fires the callback when it is loaded
 function loadAndWait(browser, url, callback) {
   listenOnce(browser, "load", callback);
   // We have to wait before calling `loadURI` otherwise, if we call
   // `loadAndWait` during browser load event, the history will be broken
   setTimeout(function () {
--- a/addon-sdk/source/test/addons/private-browsing-supported/sidebar/utils.js
+++ b/addon-sdk/source/test/addons/private-browsing-supported/sidebar/utils.js
@@ -35,27 +35,27 @@ function getExtraSidebarMenuitems() {
 exports.getExtraSidebarMenuitems = getExtraSidebarMenuitems;
 
 function makeID(id) {
   return 'jetpack-sidebar-' + id;
 }
 exports.makeID = makeID;
 
 function simulateCommand(ele) {
-  let window = ele.ownerDocument.defaultView;
+  let window = ele.ownerGlobal;
   let { document } = window;
   var evt = document.createEvent('XULCommandEvent');
   evt.initCommandEvent('command', true, true, window,
     0, false, false, false, false, null);
   ele.dispatchEvent(evt);
 }
 exports.simulateCommand = simulateCommand;
 
 function simulateClick(ele) {
-  let window = ele.ownerDocument.defaultView;
+  let window = ele.ownerGlobal;
   let { document } = window;
   let evt = document.createEvent('MouseEvents');
   evt.initMouseEvent('click', true, true, window,
     0, 0, 0, 0, 0, false, false, false, false, 0, null);
   ele.dispatchEvent(evt);
 }
 exports.simulateClick = simulateClick;
 
--- a/addon-sdk/source/test/context-menu/util.js
+++ b/addon-sdk/source/test/context-menu/util.js
@@ -37,23 +37,23 @@ exports.openTab = openTab;
 
 const openContextMenu = (selector, tab=getActiveTab()) => {
   const browser = tabUtils.getBrowserForTab(tab);
   browser.
     messageManager.
     sendAsyncMessage("sdk/test/context-menu/open",
                      {target: selector});
 
-  return when(tab.ownerDocument.defaultView, "popupshown").
+  return when(tab.ownerGlobal, "popupshown").
           then(_target);
 };
 exports.openContextMenu = openContextMenu;
 
 const closeContextMenu = (menu) => {
-  const result = when(menu.ownerDocument.defaultView, "popuphidden").
+  const result = when(menu.ownerGlobal, "popuphidden").
                   then(_target);
 
   menu.hidePopup();
   return result;
 };
 exports.closeContextMenu = closeContextMenu;
 
 const closeTab = (tab) => {
--- a/addon-sdk/source/test/event/helpers.js
+++ b/addon-sdk/source/test/event/helpers.js
@@ -34,20 +34,19 @@ const wait = function(target, type, capt
   }
   else if (typeof(target) === "number") {
     setTimeout(resolve, target);
   }
   else if (typeof(target.once) === "function") {
     target.once(type, resolve);
   }
   else if (typeof(target.addEventListener) === "function") {
-    target.addEventListener(type, function listener(...args) {
-      this.removeEventListener(type, listener, capture);
+    target.addEventListener(type, function(...args) {
       resolve(...args);
-    }, capture);
+    }, {capture, once: true});
   }
   else if (typeof(target) === "object" && target !== null) {
     once(target, type, resolve);
   }
   else {
     reject('Invalid target given.');
   }
 
--- a/addon-sdk/source/test/sidebar/utils.js
+++ b/addon-sdk/source/test/sidebar/utils.js
@@ -42,27 +42,27 @@ function getExtraSidebarMenuitems() {
 exports.getExtraSidebarMenuitems = getExtraSidebarMenuitems;
 
 function makeID(id) {
   return 'jetpack-sidebar-' + id;
 }
 exports.makeID = makeID;
 
 function simulateCommand(ele) {
-  let window = ele.ownerDocument.defaultView;
+  let window = ele.ownerGlobal;
   let { document } = window;
   var evt = document.createEvent('XULCommandEvent');
   evt.initCommandEvent('command', true, true, window,
     0, false, false, false, false, null);
   ele.dispatchEvent(evt);
 }
 exports.simulateCommand = simulateCommand;
 
 function simulateClick(ele) {
-  let window = ele.ownerDocument.defaultView;
+  let window = ele.ownerGlobal;
   let { document } = window;
   let evt = document.createEvent('MouseEvents');
   evt.initMouseEvent('click', true, true, window,
     0, 0, 0, 0, 0, false, false, false, false, 0, null);
   ele.dispatchEvent(evt);
 }
 exports.simulateClick = simulateClick;
 
--- a/addon-sdk/source/test/test-content-sync-worker.js
+++ b/addon-sdk/source/test/test-content-sync-worker.js
@@ -44,20 +44,19 @@ function makeWindow() {
 
   return Cc["@mozilla.org/embedcomp/window-watcher;1"].
          getService(Ci.nsIWindowWatcher).
          openWindow(null, url, null, features.join(","), null);
 }
 
 // Listen for only first one occurence of DOM event
 function listenOnce(node, eventName, callback) {
-  node.addEventListener(eventName, function onevent(event) {
-    node.removeEventListener(eventName, onevent, true);
+  node.addEventListener(eventName, function(event) {
     callback(node);
-  }, true);
+  }, {capture: true, once: true});
 }
 
 // Load a given url in a given browser and fires the callback when it is loaded
 function loadAndWait(browser, url, callback) {
   listenOnce(browser, "load", callback);
   // We have to wait before calling `loadURI` otherwise, if we call
   // `loadAndWait` during browser load event, the history will be broken
   setTimeout(function () {
--- a/addon-sdk/source/test/test-content-worker.js
+++ b/addon-sdk/source/test/test-content-worker.js
@@ -45,20 +45,19 @@ function makeWindow() {
 
   return Cc["@mozilla.org/embedcomp/window-watcher;1"].
          getService(Ci.nsIWindowWatcher).
          openWindow(null, url, null, features.join(","), null);
 }
 
 // Listen for only first one occurence of DOM event
 function listenOnce(node, eventName, callback) {
-  node.addEventListener(eventName, function onevent(event) {
-    node.removeEventListener(eventName, onevent, true);
+  node.addEventListener(eventName, function(event) {
     callback(node);
-  }, true);
+  }, {capture: true, once: true});
 }
 
 // Load a given url in a given browser and fires the callback when it is loaded
 function loadAndWait(browser, url, callback) {
   listenOnce(browser, "load", callback);
   // We have to wait before calling `loadURI` otherwise, if we call
   // `loadAndWait` during browser load event, the history will be broken
   setTimeout(function () {
--- a/addon-sdk/source/test/test-ui-action-button.js
+++ b/addon-sdk/source/test/test-ui-action-button.js
@@ -830,17 +830,17 @@ exports['test button icon set'] = functi
       '5': './icon5.png',
       '16': './icon16.png',
       '32': './icon32.png',
       '64': './icon64.png'
     }
   });
 
   let { node, id: widgetId } = getWidget(button.id);
-  let { devicePixelRatio } = node.ownerDocument.defaultView;
+  let { devicePixelRatio } = node.ownerGlobal;
 
   let size = 16 * devicePixelRatio;
 
   assert.equal(node.getAttribute('image'), data.url(button.icon[size].substr(2)),
     'the icon is set properly in navbar');
 
   size = 32 * devicePixelRatio;
 
@@ -1120,17 +1120,17 @@ exports['test button badge property'] = 
 
   assert.equal(button.badge, 123456,
     'badge is set');
 
   assert.equal(button.badgeColor, undefined,
     'badge color is not set');
 
   let { node } = getWidget(button.id);
-  let { getComputedStyle } = node.ownerDocument.defaultView;
+  let { getComputedStyle } = node.ownerGlobal;
   let badgeNode = badgeNodeFor(node);
 
   assert.equal('1234', node.getAttribute('badge'),
     'badge text is displayed up to four characters');
 
   assert.equal(getComputedStyle(badgeNode).backgroundColor, 'rgb(217, 0, 0)',
     'badge color is the default one');
 
@@ -1163,17 +1163,17 @@ exports['test button badge color'] = fun
     badge: '+1',
     badgeColor: 'blue'
   });
 
   assert.equal(button.badgeColor, 'blue',
     'badge color is set');
 
   let { node } = getWidget(button.id);
-  let { getComputedStyle } = node.ownerDocument.defaultView;
+  let { getComputedStyle } = node.ownerGlobal;
   let badgeNode = badgeNodeFor(node);
 
   assert.equal(badgeNodeFor(node).style.backgroundColor, 'blue',
     'badge color is displayed properly');
   assert.equal(getComputedStyle(badgeNode).backgroundColor, 'rgb(0, 0, 255)',
     'badge color overrides the default one');
 
   loader.unload();
--- a/addon-sdk/source/test/test-ui-toggle-button.js
+++ b/addon-sdk/source/test/test-ui-toggle-button.js
@@ -810,17 +810,17 @@ exports['test button icon set'] = functi
       '5': './icon5.png',
       '16': './icon16.png',
       '32': './icon32.png',
       '64': './icon64.png'
     }
   });
 
   let { node, id: widgetId } = getWidget(button.id);
-  let { devicePixelRatio } = node.ownerDocument.defaultView;
+  let { devicePixelRatio } = node.ownerGlobal;
 
   let size = 16 * devicePixelRatio;
 
   assert.equal(node.getAttribute('image'), data.url(button.icon[size].substr(2)),
     'the icon is set properly in navbar');
 
   size = 32 * devicePixelRatio;
 
@@ -1099,17 +1099,17 @@ exports['test button badge property'] = 
 
   assert.equal(button.badge, 123456,
     'badge is set');
 
   assert.equal(button.badgeColor, undefined,
     'badge color is not set');
 
   let { node } = getWidget(button.id);
-  let { getComputedStyle } = node.ownerDocument.defaultView;
+  let { getComputedStyle } = node.ownerGlobal;
   let badgeNode = badgeNodeFor(node);
 
   assert.equal('1234', node.getAttribute('badge'),
     'badge text is displayed up to four characters');
 
   assert.equal(getComputedStyle(badgeNode).backgroundColor, 'rgb(217, 0, 0)',
     'badge color is the default one');
 
@@ -1142,17 +1142,17 @@ exports['test button badge color'] = fun
     badge: '+1',
     badgeColor: 'blue'
   });
 
   assert.equal(button.badgeColor, 'blue',
     'badge color is set');
 
   let { node } = getWidget(button.id);
-  let { getComputedStyle } = node.ownerDocument.defaultView;
+  let { getComputedStyle } = node.ownerGlobal;
   let badgeNode = badgeNodeFor(node);
 
   assert.equal(badgeNodeFor(node).style.backgroundColor, 'blue',
     'badge color is displayed properly');
   assert.equal(getComputedStyle(badgeNode).backgroundColor, 'rgb(0, 0, 255)',
     'badge color overrides the default one');
 
   loader.unload();
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -70,20 +70,19 @@ window.performance.measure('gecko-shell-
 
 function debug(str) {
   dump(' -*- Shell.js: ' + str + '\n');
 }
 
 const once = event => {
   let target = shell.contentBrowser;
   return new Promise((resolve, reject) => {
-    target.addEventListener(event, function gotEvent(evt) {
-      target.removeEventListener(event, gotEvent);
+    target.addEventListener(event, function(evt) {
       resolve(evt);
-    });
+    }, {once: true});
   });
 }
 
 function clearCache() {
   let cache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
                 .getService(Ci.nsICacheStorageService);
   cache.clear();
 }
@@ -556,17 +555,17 @@ var shell = {
         this.sendChromeEvent({
           type: 'scrollviewchange',
           detail: evt.detail,
         });
         break;
       case 'mozbrowsercaretstatechanged':
         {
           let elt = evt.target;
-          let win = elt.ownerDocument.defaultView;
+          let win = elt.ownerGlobal;
           let offsetX = win.mozInnerScreenX - window.mozInnerScreenX;
           let offsetY = win.mozInnerScreenY - window.mozInnerScreenY;
 
           let rect = elt.getBoundingClientRect();
           offsetX += rect.left;
           offsetY += rect.top;
 
           let data = evt.detail;
--- a/b2g/components/ContentPermissionPrompt.js
+++ b/b2g/components/ContentPermissionPrompt.js
@@ -292,20 +292,20 @@ ContentPermissionPrompt.prototype = {
     // In both cases the message needs to be dispatched to the top-level
     // <iframe mozbrowser> container in the system app.
     // So the above code iterates over window.realFrameElement in order
     // to crosss mozbrowser iframes boundaries and find the top-level
     // one in the system app.
     // window.realFrameElement will be |null| if the code try to cross
     // content -> chrome boundaries.
     let targetElement = request.element;
-    let targetWindow = request.window || targetElement.ownerDocument.defaultView;
+    let targetWindow = request.window || targetElement.ownerGlobal;
     while (targetWindow.realFrameElement) {
       targetElement = targetWindow.realFrameElement;
-      targetWindow = targetElement.ownerDocument.defaultView;
+      targetWindow = targetElement.ownerGlobal;
     }
 
     SystemAppProxy.dispatchEvent(details, targetElement);
   },
 
   classID: Components.ID("{8c719f03-afe0-4aac-91ff-6c215895d467}"),
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionPrompt])
--- a/b2g/components/ContentRequestHelper.jsm
+++ b/b2g/components/ContentRequestHelper.jsm
@@ -28,37 +28,32 @@ this.ContentRequestHelper = function() {
 ContentRequestHelper.prototype = {
 
   contentRequest: function(aContentEventName, aChromeEventName,
                            aInternalEventName, aData) {
     let deferred = Promise.defer();
 
     let id = uuidgen.generateUUID().toString();
 
-    SystemAppProxy.addEventListener(aContentEventName,
-                                    function onContentEvent(result) {
-      SystemAppProxy.removeEventListener(aContentEventName,
-                                         onContentEvent);
+    SystemAppProxy.addEventListener(aContentEventName, function(result) {
       let msg = result.detail;
       if (!msg || !msg.id || msg.id != id) {
         deferred.reject("InternalErrorWrongContentEvent " +
                         JSON.stringify(msg));
-        SystemAppProxy.removeEventListener(aContentEventName,
-                                           onContentEvent);
         return;
       }
 
       debug("Got content event " + JSON.stringify(msg));
 
       if (msg.error) {
         deferred.reject(msg.error);
       } else {
         deferred.resolve(msg.result);
       }
-    });
+    }, {once: true});
 
     let detail = {
        eventName: aInternalEventName,
        id: id,
        data: aData
     };
     debug("Send chrome event " + JSON.stringify(detail));
     SystemAppProxy._sendCustomEvent(aChromeEventName, detail);
--- a/b2g/components/ErrorPage.jsm
+++ b/b2g/components/ErrorPage.jsm
@@ -130,17 +130,17 @@ SSLExceptions.prototype = {
     this._temporary = aTemporary;
     this._checkCert();
   }
 };
 
 var ErrorPage = {
   _addCertException: function(aMessage) {
     let frameLoaderOwner = aMessage.target.QueryInterface(Ci.nsIFrameLoaderOwner);
-    let win = frameLoaderOwner.ownerDocument.defaultView;
+    let win = frameLoaderOwner.ownerGlobal;
     let mm = frameLoaderOwner.frameLoader.messageManager;
 
     let uri = Services.io.newURI(aMessage.data.url);
     let sslExceptions = new SSLExceptions((function() {
       mm.sendAsyncMessage('ErrorPage:ReloadPage');
     }).bind(this), uri, win);
     try {
       sslExceptions.addException(!aMessage.data.isPermanent);
--- a/b2g/components/Screenshot.jsm
+++ b/b2g/components/Screenshot.jsm
@@ -10,17 +10,17 @@ Cu.import('resource://gre/modules/XPCOMU
 
 XPCOMUtils.defineLazyModuleGetter(this, "SystemAppProxy", "resource://gre/modules/SystemAppProxy.jsm");
 
 this.EXPORTED_SYMBOLS = ['Screenshot'];
 
 var Screenshot = {
   get: function screenshot_get() {
     let systemAppFrame = SystemAppProxy.getFrame();
-    let window = systemAppFrame.ownerDocument.defaultView;
+    let window = systemAppFrame.ownerGlobal;
     let document = window.document;
 
     var canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
     var docRect = document.body.getBoundingClientRect();
     var width = docRect.width;
     var height = docRect.height;
 
     // Convert width and height from CSS pixels (potentially fractional)
--- a/browser/base/content/aboutSocialError.xhtml
+++ b/browser/base/content/aboutSocialError.xhtml
@@ -49,17 +49,17 @@
       let searchParams = new URLSearchParams(document.documentURI.split("?")[1]);
       let mode = searchParams.get("mode");
       config.origin = searchParams.get("origin");
       let encodedURL = searchParams.get("url");
       let url = decodeURIComponent(encodedURL);
       // directory does not have origin set, in that case use the url origin for
       // the error message.
       if (!config.origin) {
-        let URI = Services.io.newURI(url, null, null);
+        let URI = Services.io.newURI(url);
         config.origin =
           Services.scriptSecurityManager.createCodebasePrincipal(URI, {}).origin;
       }
 
       switch (mode) {
         case "compactInfo":
           document.getElementById("btnTryAgain").style.display = 'none';
           break;
--- a/browser/base/content/browser-gestureSupport.js
+++ b/browser/base/content/browser-gestureSupport.js
@@ -532,17 +532,17 @@ var gGestureSupport = {
     // Bug 863514 - Make gesture support work in electrolysis
     if (gMultiProcessBrowser)
       return;
 
     if (!(content.document instanceof ImageDocument))
       return;
 
     let contentElement = content.document.body.firstElementChild;
-    let transformValue = content.window.getComputedStyle(contentElement, null)
+    let transformValue = content.window.getComputedStyle(contentElement)
                                        .transform;
 
     if (transformValue == "none") {
       this.rotation = 0;
       return;
     }
 
     // transformValue is a rotation matrix--split it and do mathemagic to
--- a/browser/base/content/newtab/transformations.js
+++ b/browser/base/content/newtab/transformations.js
@@ -10,17 +10,17 @@
  * convenience methods to work with a site's DOM node.
  */
 var gTransformation = {
   /**
    * Returns the width of the left and top border of a cell. We need to take it
    * into account when measuring and comparing site and cell positions.
    */
   get _cellBorderWidths() {
-    let cstyle = window.getComputedStyle(gGrid.cells[0].node, null);
+    let cstyle = window.getComputedStyle(gGrid.cells[0].node);
     let widths = {
       left: parseInt(cstyle.getPropertyValue("border-left-width")),
       top: parseInt(cstyle.getPropertyValue("border-top-width"))
     };
 
     // Cache this value, overwrite the getter.
     Object.defineProperty(this, "_cellBorderWidths",
                           {value: widths, enumerable: true});
@@ -218,17 +218,17 @@ var gTransformation = {
   },
 
   /**
    * Gets a given node's opacity value.
    * @param aNode The node to get the opacity value from.
    * @return The node's opacity value.
    */
   _getNodeOpacity: function Transformation_getNodeOpacity(aNode) {
-    let cstyle = window.getComputedStyle(aNode, null);
+    let cstyle = window.getComputedStyle(aNode);
     return cstyle.getPropertyValue("opacity");
   },
 
   /**
    * Sets a given node's opacity.
    * @param aNode The node to set the opacity value for.
    * @param aOpacity The opacity value to set.
    * @param aCallback The callback to call when finished.
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -891,25 +891,23 @@ nsContextMenu.prototype = {
              node.tagName == "label" &&
              node.classList.contains('text-link') &&
              node.href;
     }
   },
 
   // Returns the computed style attribute for the given element.
   getComputedStyle: function(aElem, aProp) {
-    return aElem.ownerDocument
-                .defaultView
-                .getComputedStyle(aElem, "").getPropertyValue(aProp);
+    return aElem.ownerGlobal
+                .getComputedStyle(aElem).getPropertyValue(aProp);
   },
 
   // Returns a "url"-type computed style attribute value, with the url() stripped.
   getComputedURL: function(aElem, aProp) {
-    var url = aElem.ownerDocument
-                   .defaultView.getComputedStyle(aElem, "")
+    var url = aElem.ownerGlobal.getComputedStyle(aElem)
                    .getPropertyCSSValue(aProp);
     if (url instanceof CSSValueList) {
       if (url.length != 1)
         throw "found multiple URLs";
       url = url[0];
     }
     return url.primitiveType == CSSPrimitiveValue.CSS_URI ?
            url.getStringValue() : null;
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2831,33 +2831,33 @@
       <method name="swapBrowsersAndCloseOther">
         <parameter name="aOurTab"/>
         <parameter name="aOtherTab"/>
         <body>
           <![CDATA[
             // Do not allow transfering a private tab to a non-private window
             // and vice versa.
             if (PrivateBrowsingUtils.isWindowPrivate(window) !=
-                PrivateBrowsingUtils.isWindowPrivate(aOtherTab.ownerDocument.defaultView))
+                PrivateBrowsingUtils.isWindowPrivate(aOtherTab.ownerGlobal))
               return;
 
             let ourBrowser = this.getBrowserForTab(aOurTab);
             let otherBrowser = aOtherTab.linkedBrowser;
 
             // Can't swap between chrome and content processes.
             if (ourBrowser.isRemoteBrowser != otherBrowser.isRemoteBrowser)
               return;
 
             // Keep the userContextId if set on other browser
             if (otherBrowser.hasAttribute("usercontextid")) {
               ourBrowser.setAttribute("usercontextid", otherBrowser.getAttribute("usercontextid"));
             }
 
             // That's gBrowser for the other window, not the tab's browser!
-            var remoteBrowser = aOtherTab.ownerDocument.defaultView.gBrowser;
+            var remoteBrowser = aOtherTab.ownerGlobal.gBrowser;
             var isPending = aOtherTab.hasAttribute("pending");
 
             let otherTabListener = remoteBrowser._tabListeners.get(aOtherTab);
             let stateFlags = otherTabListener.mStateFlags;
 
             // Expedite the removal of the icon if it was already scheduled.
             if (aOtherTab._soundPlayingAttrRemovalTimer) {
               clearTimeout(aOtherTab._soundPlayingAttrRemovalTimer);
@@ -3000,17 +3000,17 @@
             ourBrowser.webProgress.removeProgressListener(filter);
             filter.removeProgressListener(tabListener);
 
             // Make sure to unregister any open URIs.
             this._swapRegisteredOpenURIs(ourBrowser, aOtherBrowser);
 
             // Unmap old outerWindowIDs.
             this._outerWindowIDBrowserMap.delete(ourBrowser.outerWindowID);
-            let remoteBrowser = aOtherBrowser.ownerDocument.defaultView.gBrowser;
+            let remoteBrowser = aOtherBrowser.ownerGlobal.gBrowser;
             if (remoteBrowser) {
               remoteBrowser._outerWindowIDBrowserMap.delete(aOtherBrowser.outerWindowID);
             }
 
             // If switcher is active, it will intercept swap events and
             // react as needed.
             if (!this._switcher) {
               aOtherBrowser.docShellIsActive = this.shouldActivateDocShell(ourBrowser);
@@ -3503,17 +3503,17 @@
           ]]>
         </body>
       </method>
 
       <method name="moveTabOver">
         <parameter name="aEvent"/>
         <body>
           <![CDATA[
-            var direction = window.getComputedStyle(this.parentNode, null).direction;
+            var direction = window.getComputedStyle(this.parentNode).direction;
             if ((direction == "ltr" && aEvent.keyCode == KeyEvent.DOM_VK_RIGHT) ||
                 (direction == "rtl" && aEvent.keyCode == KeyEvent.DOM_VK_LEFT))
               this.moveTabForward();
             else
               this.moveTabBackward();
           ]]>
         </body>
       </method>
@@ -4115,17 +4115,17 @@
               }
             },
 
             onSwapDocShells(ourBrowser, otherBrowser) {
               // This event fires before the swap. ourBrowser is from
               // our window. We save the state of otherBrowser since ourBrowser
               // needs to take on that state at the end of the swap.
 
-              let otherTabbrowser = otherBrowser.ownerDocument.defaultView.gBrowser;
+              let otherTabbrowser = otherBrowser.ownerGlobal.gBrowser;
               let otherState;
               if (otherTabbrowser && otherTabbrowser._switcher) {
                 let otherTab = otherTabbrowser.getTabForBrowser(otherBrowser);
                 otherState = otherTabbrowser._switcher.getTabState(otherTab);
               } else {
                 otherState = (otherBrowser.docShellIsActive
                               ? this.STATE_LOADED
                               : this.STATE_UNLOADED);
@@ -4610,17 +4610,17 @@
             if (!aEvent.metaKey)
               return;
 
             var offset = 1;
             switch (aEvent.charCode) {
               case "}".charCodeAt(0):
                 offset = -1;
               case "{".charCodeAt(0):
-                if (window.getComputedStyle(this, null).direction == "ltr")
+                if (window.getComputedStyle(this).direction == "ltr")
                   offset *= -1;
                 this.tabContainer.advanceSelectedTab(offset, true);
                 aEvent.preventDefault();
             }
           }
         ]]></body>
       </method>
 
@@ -5398,17 +5398,17 @@
       </method>
       <field name="_tabMarginLeft">null</field>
       <field name="_tabMarginRight">null</field>
       <method name="_calcTabMargins">
         <parameter name="aTab"/>
         <body><![CDATA[
           if (this._tabMarginLeft === null || this._tabMarginRight === null) {
             let tabMiddle = document.getAnonymousElementByAttribute(aTab, "class", "tab-background-middle");
-            let tabMiddleStyle = window.getComputedStyle(tabMiddle, null);
+            let tabMiddleStyle = window.getComputedStyle(tabMiddle);
             this._tabMarginLeft = parseFloat(tabMiddleStyle.marginLeft);
             this._tabMarginRight = parseFloat(tabMiddleStyle.marginRight);
           }
         ]]></body>
       </method>
       <method name="_adjustElementStartAndEnd">
         <parameter name="aTab"/>
         <parameter name="tabStart"/>
@@ -6140,17 +6140,17 @@
       </method>
 
       <method name="_getDropIndex">
         <parameter name="event"/>
         <parameter name="isLink"/>
         <body><![CDATA[
           var tabs = this.childNodes;
           var tab = this._getDragTargetTab(event, isLink);
-          if (window.getComputedStyle(this, null).direction == "ltr") {
+          if (window.getComputedStyle(this).direction == "ltr") {
             for (let i = tab ? tab._tPos : 0; i < tabs.length; i++)
               if (event.screenX < tabs[i].boxObject.screenX + tabs[i].boxObject.width / 2)
                 return i;
           } else {
             for (let i = tab ? tab._tPos : 0; i < tabs.length; i++)
               if (event.screenX > tabs[i].boxObject.screenX + tabs[i].boxObject.width / 2)
                 return i;
           }
@@ -6164,27 +6164,27 @@
           var dt = event.dataTransfer;
           if (dt.mozItemCount == 1) {
             var types = dt.mozTypesAt(0);
             // tabs are always added as the first type
             if (types[0] == TAB_DROP_TYPE) {
               let sourceNode = dt.mozGetDataAt(TAB_DROP_TYPE, 0);
               if (sourceNode instanceof XULElement &&
                   sourceNode.localName == "tab" &&
-                  sourceNode.ownerDocument.defaultView instanceof ChromeWindow &&
+                  sourceNode.ownerGlobal instanceof ChromeWindow &&
                   sourceNode.ownerDocument.documentElement.getAttribute("windowtype") == "navigator:browser" &&
-                  sourceNode.ownerDocument.defaultView.gBrowser.tabContainer == sourceNode.parentNode) {
+                  sourceNode.ownerGlobal.gBrowser.tabContainer == sourceNode.parentNode) {
                 // Do not allow transfering a private tab to a non-private window
                 // and vice versa.
                 if (PrivateBrowsingUtils.isWindowPrivate(window) !=
-                    PrivateBrowsingUtils.isWindowPrivate(sourceNode.ownerDocument.defaultView))
+                    PrivateBrowsingUtils.isWindowPrivate(sourceNode.ownerGlobal))
                   return "none";
 
                 if (window.gMultiProcessBrowser !=
-                    sourceNode.ownerDocument.defaultView.gMultiProcessBrowser)
+                    sourceNode.ownerGlobal.gMultiProcessBrowser)
                   return "none";
 
                 return dt.dropEffect == "copy" ? "copy" : "move";
               }
             }
           }
 
           if (browserDragAndDrop.canDropLink(event)) {
@@ -6417,17 +6417,17 @@
           // be because they intend to open a new tab, but it could also be
           // because they just removed a tab and they now middleclicked on the
           // resulting space while that tab is closing. In that case, we don't
           // want to open a tab. So if we're removing one or more tabs, and
           // the tab click is before the end of the last visible tab, we do
           // nothing.
           if (this.tabbrowser._removingTabs.length) {
             let visibleTabs = this.tabbrowser.visibleTabs;
-            let ltr = (window.getComputedStyle(this, null).direction == "ltr");
+            let ltr = (window.getComputedStyle(this).direction == "ltr");
             let lastTab = visibleTabs[visibleTabs.length - 1];
             let endOfTab = lastTab.getBoundingClientRect()[ltr ? "right" : "left"];
             if ((ltr && event.clientX > endOfTab) ||
                 (!ltr && event.clientX < endOfTab)) {
               BrowserOpenTab();
             }
           } else {
             BrowserOpenTab();
@@ -6584,17 +6584,17 @@
         if (effects == "" || effects == "none") {
           ind.collapsed = true;
           return;
         }
         event.preventDefault();
         event.stopPropagation();
 
         var tabStrip = this.mTabstrip;
-        var ltr = (window.getComputedStyle(this, null).direction == "ltr");
+        var ltr = (window.getComputedStyle(this).direction == "ltr");
 
         // autoscroll the tab strip if we drag over the scroll
         // buttons, even if we aren't dragging a tab, but then
         // return to avoid drawing the drop indicator
         var pixelsToScroll = 0;
         if (this.getAttribute("overflow") == "true") {
           var targetAnonid = event.originalTarget.getAttribute("anonid");
           switch (targetAnonid) {
--- a/browser/base/content/test/alerts/browser_notification_tab_switching.js
+++ b/browser/base/content/test/alerts/browser_notification_tab_switching.js
@@ -22,20 +22,19 @@ add_task(function* test_notificationPrev
     yield BrowserTestUtils.switchTab(gBrowser, originalTab);
     isnot(gBrowser.selectedBrowser, aBrowser, "Notification page loaded as a background tab");
 
     // First, show a notification that will be have the tab-switching prevented.
     function promiseNotificationEvent(evt) {
       return ContentTask.spawn(aBrowser, evt, function* (contentEvt) {
         return yield new Promise(resolve => {
           let contentNotification = content.wrappedJSObject._notification;
-          contentNotification.addEventListener(contentEvt, function l(event) {
-            contentNotification.removeEventListener(contentEvt, l);
+          contentNotification.addEventListener(contentEvt, function(event) {
             resolve({ defaultPrevented: event.defaultPrevented });
-          });
+          }, {once: true});
         });
       });
     }
     yield openNotification(aBrowser, "showNotification1");
     info("Notification alert showing");
     let alertWindow = Services.wm.getMostRecentWindow("alert:alert");
     if (!alertWindow) {
       ok(true, "Notifications don't use XUL windows on all platforms.");
--- a/browser/base/content/test/chrome/test_aboutCrashed.xul
+++ b/browser/base/content/test/chrome/test_aboutCrashed.xul
@@ -45,18 +45,18 @@
                                            Ci.nsIWebProgress.NOTIFY_LOCATION);
       });
     }
 
   function doTest() {
     (async function testBody() {
       let frame1 = document.getElementById("frame1");
       let frame2 = document.getElementById("frame2");
-      let uri1 = Services.io.newURI("http://www.example.com/1", null, null);
-      let uri2 = Services.io.newURI("http://www.example.com/2", null, null);
+      let uri1 = Services.io.newURI("http://www.example.com/1");
+      let uri2 = Services.io.newURI("http://www.example.com/2");
 
       let errorPageReady = waitForErrorPage(frame1);
       frame1.docShell.chromeEventHandler.setAttribute("crashedPageTitle", "pageTitle");
       frame1.docShell.displayLoadError(Components.results.NS_ERROR_CONTENT_CRASHED, uri1, null);
 
       await errorPageReady;
       frame1.docShell.chromeEventHandler.removeAttribute("crashedPageTitle");
 
--- a/browser/base/content/test/general/browser_aboutHealthReport.js
+++ b/browser/base/content/test/general/browser_aboutHealthReport.js
@@ -113,22 +113,21 @@ function test() {
 
     finish();
   });
 }
 
 function promiseNewTabLoadEvent(aUrl, aEventType = "load") {
   let deferred = Promise.defer();
   let tab = gBrowser.selectedTab = gBrowser.addTab(aUrl);
-  tab.linkedBrowser.addEventListener(aEventType, function load(event) {
-    tab.linkedBrowser.removeEventListener(aEventType, load, true);
+  tab.linkedBrowser.addEventListener(aEventType, function(event) {
     let iframe = tab.linkedBrowser.contentDocument.getElementById("remote-report");
       iframe.addEventListener("load", function frameLoad(e) {
         if (iframe.contentWindow.location.href == "about:blank" ||
             e.target != iframe) {
           return;
         }
         iframe.removeEventListener("load", frameLoad);
         deferred.resolve(iframe);
       });
-    }, true);
+    }, {capture: true, once: true});
   return deferred.promise;
 }
--- a/browser/base/content/test/general/browser_addCertException.js
+++ b/browser/base/content/test/general/browser_addCertException.js
@@ -22,23 +22,23 @@ add_task(function* () {
 // Check for the correct icons in the identity box and control center.
 function checkControlPanelIcons() {
   let { gIdentityHandler } = gBrowser.ownerGlobal;
   gIdentityHandler._identityBox.click();
   document.getElementById("identity-popup-security-expander").click();
 
   is_element_visible(document.getElementById("connection-icon"), "Should see connection icon");
   let connectionIconImage = gBrowser.ownerGlobal
-        .getComputedStyle(document.getElementById("connection-icon"), "")
+        .getComputedStyle(document.getElementById("connection-icon"))
         .getPropertyValue("list-style-image");
   let securityViewBG = gBrowser.ownerGlobal
-        .getComputedStyle(document.getElementById("identity-popup-securityView"), "")
+        .getComputedStyle(document.getElementById("identity-popup-securityView"))
         .getPropertyValue("background-image");
   let securityContentBG = gBrowser.ownerGlobal
-        .getComputedStyle(document.getElementById("identity-popup-security-content"), "")
+        .getComputedStyle(document.getElementById("identity-popup-security-content"))
         .getPropertyValue("background-image");
   is(connectionIconImage,
      "url(\"chrome://browser/skin/connection-mixed-passive-loaded.svg#icon\")",
      "Using expected icon image in the identity block");
   is(securityViewBG,
      "url(\"chrome://browser/skin/connection-mixed-passive-loaded.svg#icon\")",
      "Using expected icon image in the Control Center main view");
   is(securityContentBG,
--- a/browser/base/content/test/general/browser_fxaccounts.js
+++ b/browser/base/content/test/general/browser_fxaccounts.js
@@ -188,26 +188,16 @@ function promiseObserver(topic, count = 
         Services.obs.removeObserver(obs, aTopic);
         resolve(aSubject);
       }
     }
     Services.obs.addObserver(obs, topic, false);
   });
 }
 
-// Stolen from browser_aboutHome.js
-function promiseWaitForEvent(node, type, capturing) {
-  return new Promise((resolve) => {
-    node.addEventListener(type, function listener(event) {
-      node.removeEventListener(type, listener, capturing);
-      resolve(event);
-    }, capturing);
-  });
-}
-
 var promiseTabOpen = Task.async(function*(urlBase) {
   info("Waiting for tab to open...");
   let event = yield promiseWaitForEvent(gBrowser.tabContainer, "TabOpen", true);
   let tab = event.target;
   yield promiseTabLoadEvent(tab);
   ok(tab.linkedBrowser.currentURI.spec.startsWith(urlBase),
      "Got " + tab.linkedBrowser.currentURI.spec + ", expecting " + urlBase);
   let whenUnloaded = promiseTabUnloaded(tab);
--- a/browser/base/content/test/general/browser_gestureSupport.js
+++ b/browser/base/content/test/general/browser_gestureSupport.js
@@ -502,17 +502,17 @@ function test_swipeGestures() {
   test_removeCommand(cmdLeft);
   test_removeCommand(cmdRight);
 }
 
 
 function test_rotateHelperGetImageRotation(aImageElement) {
   // Get the true image rotation from the transform matrix, bounded
   // to 0 <= result < 360
-  let transformValue = content.window.getComputedStyle(aImageElement, null)
+  let transformValue = content.window.getComputedStyle(aImageElement)
                                      .transform;
   if (transformValue == "none")
     return 0;
 
   transformValue = transformValue.split("(")[1]
                                  .split(")")[0]
                                  .split(",");
   var rotation = Math.round(Math.atan2(transformValue[1], transformValue[0]) *
--- a/browser/base/content/test/general/browser_insecureLoginForms.js
+++ b/browser/base/content/test/general/browser_insecureLoginForms.js
@@ -38,23 +38,23 @@ add_task(function* test_simple() {
 
     let { gIdentityHandler } = gBrowser.ownerGlobal;
     gIdentityHandler._identityBox.click();
     document.getElementById("identity-popup-security-expander").click();
 
     if (expectWarning) {
       is_element_visible(document.getElementById("connection-icon"));
       let connectionIconImage = gBrowser.ownerGlobal
-            .getComputedStyle(document.getElementById("connection-icon"), "")
+            .getComputedStyle(document.getElementById("connection-icon"))
             .getPropertyValue("list-style-image");
       let securityViewBG = gBrowser.ownerGlobal
-            .getComputedStyle(document.getElementById("identity-popup-securityView"), "")
+            .getComputedStyle(document.getElementById("identity-popup-securityView"))
             .getPropertyValue("background-image");
       let securityContentBG = gBrowser.ownerGlobal
-            .getComputedStyle(document.getElementById("identity-popup-security-content"), "")
+            .getComputedStyle(document.getElementById("identity-popup-security-content"))
             .getPropertyValue("background-image");
       is(connectionIconImage,
          "url(\"chrome://browser/skin/connection-mixed-active-loaded.svg#icon\")",
          "Using expected icon image in the identity block");
       is(securityViewBG,
          "url(\"chrome://browser/skin/controlcenter/mcb-disabled.svg\")",
          "Using expected icon image in the Control Center main view");
       is(securityContentBG,
--- a/browser/base/content/test/general/browser_pinnedTabs.js
+++ b/browser/base/content/test/general/browser_pinnedTabs.js
@@ -12,27 +12,23 @@ function indexTest(tab, expectedIndex, m
     msg = diag;
   is(index(tabs[tab]), expectedIndex, msg);
 }
 
 function PinUnpinHandler(tab, eventName) {
   this.eventCount = 0;
   var self = this;
   tab.addEventListener(eventName, function() {
-    tab.removeEventListener(eventName, arguments.callee, true);
-
     self.eventCount++;
-  }, true);
+  }, {capture: true, once: true});
   gBrowser.tabContainer.addEventListener(eventName, function(e) {
-    gBrowser.tabContainer.removeEventListener(eventName, arguments.callee, true);
-
     if (e.originalTarget == tab) {
       self.eventCount++;
     }
-  }, true);
+  }, {capture: true, once: true});
 }
 
 function test() {
   tabs = [gBrowser.selectedTab, gBrowser.addTab(), gBrowser.addTab(), gBrowser.addTab()];
   indexTest(0, 0);
   indexTest(1, 1);
   indexTest(2, 2);
   indexTest(3, 3);
--- a/browser/base/content/test/general/browser_tabkeynavigation.js
+++ b/browser/base/content/test/general/browser_tabkeynavigation.js
@@ -56,17 +56,17 @@ add_task(function* test() {
   EventUtils.synthesizeKey("VK_PAGE_UP", { ctrlKey: true });
   is(gBrowser.selectedTab, tab1,
      "Tab1 should be activated by pressing Ctrl+PageUp on Tab2");
 
   if (gBrowser.mTabBox._handleMetaAltArrows) {
     gBrowser.selectedTab = tab1;
     browser1.focus();
 
-    let ltr = window.getComputedStyle(gBrowser.mTabBox, "").direction == "ltr";
+    let ltr = window.getComputedStyle(gBrowser.mTabBox).direction == "ltr";
     let advanceKey = ltr ? "VK_RIGHT" : "VK_LEFT";
     let reverseKey = ltr ? "VK_LEFT" : "VK_RIGHT";
 
     is(gBrowser.selectedTab, tab1,
        "Tab1 should be activated");
     EventUtils.synthesizeKey(advanceKey, { altKey: true, metaKey: true });
     is(gBrowser.selectedTab, tab2,
        "Tab2 should be activated by pressing Ctrl+" + advanceKey + " on Tab1");
@@ -104,17 +104,17 @@ add_task(function* test() {
 
   if (navigator.platform.indexOf("Mac") == 0) {
     gBrowser.selectedTab = tab1;
     browser1.focus();
 
     // XXX Currently, Command + "{" and "}" don't work if keydown event is
     //     consumed because following keypress event isn't fired.
 
-    let ltr = window.getComputedStyle(gBrowser.mTabBox, "").direction == "ltr";
+    let ltr = window.getComputedStyle(gBrowser.mTabBox).direction == "ltr";
     let advanceKey = ltr ? "}" : "{";
     let reverseKey = ltr ? "{" : "}";
 
     is(gBrowser.selectedTab, tab1,
        "Tab1 should be activated");
 
     EventUtils.synthesizeKey(advanceKey, { metaKey: true });
     is(gBrowser.selectedTab, tab2,
--- a/browser/base/content/test/general/browser_windowactivation.js
+++ b/browser/base/content/test/general/browser_windowactivation.js
@@ -164,16 +164,16 @@ function childFunction() {
       return;
     }
 
     let area = content.document.getElementById("area");
     if (!area) {
       return; /* hasn't loaded yet */
     }
 
-    let color = content.getComputedStyle(area, "").backgroundColor;
+    let color = content.getComputedStyle(area).backgroundColor;
     if (oldColor != color || !ifChanged) {
       expectingResponse = false;
       oldColor = color;
       sendAsyncMessage("Test:BackgroundColorChanged", { color });
     }
   }, 20);
 }
--- a/browser/base/content/test/general/head.js
+++ b/browser/base/content/test/general/head.js
@@ -854,20 +854,19 @@ function is_element_hidden(element, msg)
 function promisePopupEvent(popup, eventSuffix) {
   let endState = {shown: "open", hidden: "closed"}[eventSuffix];
 
   if (popup.state == endState)
     return Promise.resolve();
 
   let eventType = "popup" + eventSuffix;
   let deferred = Promise.defer();
-  popup.addEventListener(eventType, function onPopupShown(event) {
-    popup.removeEventListener(eventType, onPopupShown);
+  popup.addEventListener(eventType, function(event) {
     deferred.resolve();
-  });
+  }, {once: true});
 
   return deferred.promise;
 }
 
 function promisePopupShown(popup) {
   return promisePopupEvent(popup, "shown");
 }
 
--- a/browser/base/content/test/plugins/plugin_syncRemoved.html
+++ b/browser/base/content/test/plugins/plugin_syncRemoved.html
@@ -1,15 +1,15 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
 <html>
 <head>
 <meta charset="utf-8">
 <body>
 <script type="text/javascript">
   // create an embed, insert it in the doc and immediately remove it
   var embed = document.createElement("embed");
   embed.setAttribute("id", "test");
   embed.setAttribute("type", "application/x-test");
   embed.setAttribute("style", "width: 0px; height: 0px;");
   document.body.appendChild(embed);
-  window.getComputedStyle(embed, null).top;
+  window.getComputedStyle(embed).top;
   document.body.remove(embed);
 </script>
--- a/browser/base/content/test/urlbar/head.js
+++ b/browser/base/content/test/urlbar/head.js
@@ -134,20 +134,19 @@ function is_element_hidden(element, msg)
 function promisePopupEvent(popup, eventSuffix) {
   let endState = {shown: "open", hidden: "closed"}[eventSuffix];
 
   if (popup.state == endState)
     return Promise.resolve();
 
   let eventType = "popup" + eventSuffix;
   let deferred = Promise.defer();
-  popup.addEventListener(eventType, function onPopupShown(event) {
-    popup.removeEventListener(eventType, onPopupShown);
+  popup.addEventListener(eventType, function(event) {
     deferred.resolve();
-  });
+  }, {once: true});
 
   return deferred.promise;
 }
 
 function promisePopupShown(popup) {
   return promisePopupEvent(popup, "shown");
 }
 
--- a/browser/base/content/test/webrtc/head.js
+++ b/browser/base/content/test/webrtc/head.js
@@ -162,20 +162,19 @@ function* assertWebRTCIndicatorStatus(ex
 function promisePopupEvent(popup, eventSuffix) {
   let endState = {shown: "open", hidden: "closed"}[eventSuffix];
 
   if (popup.state == endState)
     return Promise.resolve();
 
   let eventType = "popup" + eventSuffix;
   let deferred = Promise.defer();
-  popup.addEventListener(eventType, function onPopupShown(event) {
-    popup.removeEventListener(eventType, onPopupShown);
+  popup.addEventListener(eventType, function(event) {
     deferred.resolve();
-  });
+  }, {once: true});
 
   return deferred.promise;
 }
 
 function promiseNotificationShown(notification) {
   let win = notification.browser.ownerGlobal;
   if (win.PopupNotifications.panel.state == "open") {
     return Promise.resolve();
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -1558,17 +1558,17 @@ file, You can obtain one at http://mozil
           this.view = aInput.controller.QueryInterface(Components.interfaces.nsITreeView);
           this._invalidate();
 
           var rect = window.document.documentElement.getBoundingClientRect();
           var width = rect.right - rect.left;
           this.setAttribute("width", width);
 
           // Adjust the direction of the autocomplete popup list based on the textbox direction, bug 649840
-          var popupDirection = aElement.ownerDocument.defaultView.getComputedStyle(aElement).direction;
+          var popupDirection = aElement.ownerGlobal.getComputedStyle(aElement).direction;
           this.style.direction = popupDirection;
 
           // Make the popup's starting margin negative so that the leading edge
           // of the popup aligns with the window border.
           let elementRect = aElement.getBoundingClientRect();
           if (popupDirection == "rtl") {
             let offset = elementRect.right - rect.right
             this.style.marginRight = offset + "px";
--- a/browser/components/contextualidentity/test/browser/browser_eme.js
+++ b/browser/components/contextualidentity/test/browser/browser_eme.js
@@ -18,17 +18,17 @@ const USER_ID_DEFAULT = 0;
 const USER_ID_PERSONAL = 1;
 
 function* openTabInUserContext(uri, userContextId) {
   // Open the tab in the correct userContextId.
   let tab = gBrowser.addTab(uri, {userContextId});
 
   // Select tab and make sure its browser is focused.
   gBrowser.selectedTab = tab;
-  tab.ownerDocument.defaultView.focus();
+  tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   yield BrowserTestUtils.browserLoaded(browser);
   return {tab, browser};
 }
 
 function HexToBase64(hex) {
   var bin = "";
--- a/browser/components/contextualidentity/test/browser/browser_imageCache.js
+++ b/browser/components/contextualidentity/test/browser/browser_imageCache.js
@@ -38,17 +38,17 @@ add_task(function* setup() {
 // opens `uri' in a new tab with the provided userContextId and focuses it.
 // returns the newly opened tab
 function* openTabInUserContext(uri, userContextId) {
   // open the tab in the correct userContextId
   let tab = gBrowser.addTab(uri, {userContextId});
 
   // select tab and make sure its browser is focused
   gBrowser.selectedTab = tab;
-  tab.ownerDocument.defaultView.focus();
+  tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   yield BrowserTestUtils.browserLoaded(browser);
   return tab;
 }
 
 add_task(function* test() {
   for (let userContextId = 0; userContextId < NUM_USER_CONTEXTS; userContextId++) {
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -1696,17 +1696,17 @@ CustomizeMode.prototype = {
         dragValue = "after";
       } else {
         dragOverItem = targetParent.children[position];
         if (!targetIsToolbar) {
           dragValue = "before";
         } else {
           // Check if the aDraggedItem is hovered past the first half of dragOverItem
           let window = dragOverItem.ownerGlobal;
-          let direction = window.getComputedStyle(dragOverItem, null).direction;
+          let direction = window.getComputedStyle(dragOverItem).direction;
           let itemRect = dragOverItem.getBoundingClientRect();
           let dropTargetCenter = itemRect.left + (itemRect.width / 2);
           let existingDir = dragOverItem.getAttribute("dragover");
           if ((existingDir == "before") == (direction == "ltr")) {
             dropTargetCenter += (parseInt(dragOverItem.style.borderLeftWidth) || 0) / 2;
           } else {
             dropTargetCenter -= (parseInt(dragOverItem.style.borderRightWidth) || 0) / 2;
           }
--- a/browser/components/customizableui/content/panelUI.xml
+++ b/browser/components/customizableui/content/panelUI.xml
@@ -258,28 +258,28 @@
         <body><![CDATA[
           if (aAnchor) {
             // We need to find the edge of the anchor, relative to the main panel.
             // Then we need to add half the width of the anchor. This is the target
             // that we need to transition to.
             let anchorRect = aAnchor.getBoundingClientRect();
             let mainViewRect = this._mainViewContainer.getBoundingClientRect();
             let center = aAnchor.clientWidth / 2;
-            let direction = aAnchor.ownerDocument.defaultView.getComputedStyle(aAnchor, null).direction;
+            let direction = aAnchor.ownerGlobal.getComputedStyle(aAnchor).direction;
             let edge;
             if (direction == "ltr") {
               edge = anchorRect.left - mainViewRect.left;
             } else {
               edge = mainViewRect.right - anchorRect.right;
             }
 
             // If the anchor is an element on the far end of the mainView we
             // don't want to shift the mainView too far, we would reveal empty
             // space otherwise.
-            let cstyle = window.getComputedStyle(document.documentElement, null);
+            let cstyle = window.getComputedStyle(document.documentElement);
             let exitSubViewGutterWidth =
               cstyle.getPropertyValue("--panel-ui-exit-subview-gutter-width");
             let maxShift = mainViewRect.width - parseInt(exitSubViewGutterWidth);
             let target = Math.min(maxShift, edge + center);
 
             let neg = direction == "ltr" ? "-" : "";
             this._mainViewContainer.style.transform = `translateX(${neg}${target}px)`;
             aAnchor.setAttribute("panel-multiview-anchor", true);
@@ -468,17 +468,17 @@
             }
             if (elementCS) {
               // Include margins - but not borders or paddings because they
               // were dealt with above.
               height += parseFloat(elementCS.marginTop) + parseFloat(elementCS.marginBottom);
             }
             return height;
           }
-          let win = aSubview.ownerDocument.defaultView;
+          let win = aSubview.ownerGlobal;
           let body = aSubview.querySelector(".panel-subview-body");
           let height = getFullHeight(body || aSubview);
           if (body) {
             let header = aSubview.querySelector(".panel-subview-header");
             let footer = aSubview.querySelector(".panel-subview-footer");
             height += (header ? getFullHeight(header) : 0) +
                       (footer ? getFullHeight(footer) : 0);
           }
--- a/browser/components/extensions/ext-browserAction.js
+++ b/browser/components/extensions/ext-browserAction.js
@@ -181,17 +181,17 @@ BrowserAction.prototype = {
       widget.node.dispatchEvent(event);
     } else {
       this.emit("click");
     }
   }),
 
   handleEvent(event) {
     let button = event.target;
-    let window = button.ownerDocument.defaultView;
+    let window = button.ownerGlobal;
 
     switch (event.type) {
       case "mousedown":
         if (event.button == 0) {
           // Begin pre-loading the browser for the popup, so it's more likely to
           // be ready by the time we get a complete click.
           let tab = window.gBrowser.selectedTab;
           let popupURL = this.getProperty(tab, "popup");
--- a/browser/components/extensions/ext-commands.js
+++ b/browser/components/extensions/ext-commands.js
@@ -121,20 +121,20 @@ CommandList.prototype = {
     // and it is currently ignored when set to the empty string.
     keyElement.setAttribute("oncommand", "//");
 
     /* eslint-disable mozilla/balanced-listeners */
     // We remove all references to the key elements when the extension is shutdown,
     // therefore the listeners for these elements will be garbage collected.
     keyElement.addEventListener("command", (event) => {
       if (name == "_execute_page_action") {
-        let win = event.target.ownerDocument.defaultView;
+        let win = event.target.ownerGlobal;
         pageActionFor(this.extension).triggerAction(win);
       } else if (name == "_execute_browser_action") {
-        let win = event.target.ownerDocument.defaultView;
+        let win = event.target.ownerGlobal;
         browserActionFor(this.extension).triggerAction(win);
       } else {
         TabManager.for(this.extension)
                   .addActiveTabPermission(TabManager.activeTab);
         this.emit("command", name);
       }
     });
     /* eslint-enable mozilla/balanced-listeners */
--- a/browser/components/extensions/ext-devtools.js
+++ b/browser/components/extensions/ext-devtools.js
@@ -73,17 +73,17 @@ global.getDevToolsTargetForContext = (co
  */
 global.getTargetTabIdForToolbox = (toolbox) => {
   let {target} = toolbox;
 
   if (!target.isLocalTab) {
     throw new Error("Unexpected target type: only local tabs are currently supported.");
   }
 
-  let parentWindow = target.tab.linkedBrowser.ownerDocument.defaultView;
+  let parentWindow = target.tab.linkedBrowser.ownerGlobal;
   let tab = parentWindow.gBrowser.getTabForBrowser(target.tab.linkedBrowser);
 
   return TabManager.getId(tab);
 };
 
 /**
  * The DevToolsPage represents the "devtools_page" related to a particular
  * Toolbox and WebExtension.
--- a/browser/components/extensions/ext-pageAction.js
+++ b/browser/components/extensions/ext-pageAction.js
@@ -149,17 +149,17 @@ PageAction.prototype = {
   triggerAction(window) {
     let pageAction = pageActionMap.get(this.extension);
     if (pageAction.getProperty(window.gBrowser.selectedTab, "show")) {
       pageAction.handleClick(window);
     }
   },
 
   handleEvent(event) {
-    const window = event.target.ownerDocument.defaultView;
+    const window = event.target.ownerGlobal;
 
     switch (event.type) {
       case "click":
         if (event.button === 0) {
           this.handleClick(window);
         }
         break;
 
--- a/browser/components/extensions/test/browser/head.js
+++ b/browser/components/extensions/test/browser/head.js
@@ -64,17 +64,17 @@ var focusWindow = Task.async(function* f
   win.focus();
   yield promise;
 });
 
 let img = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==";
 var imageBuffer = Uint8Array.from(atob(img), byte => byte.charCodeAt(0)).buffer;
 
 function getListStyleImage(button) {
-  let style = button.ownerDocument.defaultView.getComputedStyle(button);
+  let style = button.ownerGlobal.getComputedStyle(button);
 
   let match = /^url\("(.*)"\)$/.exec(style.listStyleImage);
 
   return match && match[1];
 }
 
 function promisePopupShown(popup) {
   return new Promise(resolve => {
--- a/browser/components/places/content/browserPlacesViews.js
+++ b/browser/components/places/content/browserPlacesViews.js
@@ -750,17 +750,17 @@ PlacesViewBase.prototype = {
     delete this._viewElt._placesView;
   },
 
   get isRTL() {
     if ("_isRTL" in this)
       return this._isRTL;
 
     return this._isRTL = document.defaultView
-                                 .getComputedStyle(this.viewElt, "")
+                                 .getComputedStyle(this.viewElt)
                                  .direction == "rtl";
   },
 
   get ownerWindow() {
     return window;
   },
 
   /**
--- a/browser/components/places/content/sidebarUtils.js
+++ b/browser/components/places/content/sidebarUtils.js
@@ -19,17 +19,17 @@ var SidebarUtils = {
     var mouseInGutter = false;
     if (aGutterSelect) {
       var rect = tbo.getCoordsForCellItem(cell.row, cell.col, "image");
       // getCoordsForCellItem returns the x coordinate in logical coordinates
       // (i.e., starting from the left and right sides in LTR and RTL modes,
       // respectively.)  Therefore, we make sure to exclude the blank area
       // before the tree item icon (that is, to the left or right of it in
       // LTR and RTL modes, respectively) from the click target area.
-      var isRTL = window.getComputedStyle(aTree, null).direction == "rtl";
+      var isRTL = window.getComputedStyle(aTree).direction == "rtl";
       if (isRTL)
         mouseInGutter = aEvent.clientX > rect.x;
       else
         mouseInGutter = aEvent.clientX < rect.x;
     }
 
     var metaKey = AppConstants.platform === "macosx" ? aEvent.metaKey
                                                      : aEvent.ctrlKey;
--- a/browser/components/places/tests/chrome/test_bug485100-change-case-loses-tag.xul
+++ b/browser/components/places/tests/chrome/test_bug485100-change-case-loses-tag.xul
@@ -37,17 +37,17 @@
   <![CDATA[
 
     function runTest() {
       SimpleTest.waitForExplicitFinish();
 
       Task.spawn(function* () {
         let testTag = "foo";
         let testTagUpper = "Foo";
-        let testURI = Services.io.newURI("http://www.example.com/", null, null);
+        let testURI = Services.io.newURI("http://www.example.com/");
 
         // Add a bookmark.
         let bm = yield PlacesUtils.bookmarks.insert({
           parentGuid: PlacesUtils.bookmarks.toolbarGuid,
           index: PlacesUtils.bookmarks.DEFAULT_INDEX,
           type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
           title: "mozilla",
           url: testURI
--- a/browser/components/places/tests/chrome/test_bug549192.xul
+++ b/browser/components/places/tests/chrome/test_bug549192.xul
@@ -53,21 +53,21 @@
         function newTimeInMicroseconds() {
           timeInMicroseconds = timeInMicroseconds + 1000;
           return timeInMicroseconds;
         }
 
         let vtime = Date.now() * 1000;
         const ttype = PlacesUtils.history.TRANSITION_TYPED;
         let places =
-          [{ uri: Services.io.newURI("http://example.tld/", null, null),
+          [{ uri: Services.io.newURI("http://example.tld/"),
              visitDate: newTimeInMicroseconds(), transition: ttype },
-           { uri: Services.io.newURI("http://example2.tld/", null, null),
+           { uri: Services.io.newURI("http://example2.tld/"),
              visitDate: newTimeInMicroseconds(), transition: ttype },
-           { uri: Services.io.newURI("http://example3.tld/", null, null),
+           { uri: Services.io.newURI("http://example3.tld/"),
              visitDate: newTimeInMicroseconds(), transition: ttype }];
 
         yield PlacesTestUtils.addVisits(places);
 
         // Make a history query.
         let query = PlacesUtils.history.getNewQuery();
         let opts = PlacesUtils.history.getNewQueryOptions();
         opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
--- a/browser/components/places/tests/chrome/test_bug549491.xul
+++ b/browser/components/places/tests/chrome/test_bug549491.xul
@@ -46,17 +46,17 @@
 
     function runTest() {
       SimpleTest.waitForExplicitFinish();
 
       Task.spawn(function* () {
         yield PlacesTestUtils.clearHistory();
 
         yield PlacesTestUtils.addVisits({
-          uri: Services.io.newURI("http://example.tld/", null, null),
+          uri: Services.io.newURI("http://example.tld/"),
           transition: PlacesUtils.history.TRANSITION_TYPED
         });
 
         // Make a history query.
         let query = PlacesUtils.history.getNewQuery();
         let opts = PlacesUtils.history.getNewQueryOptions();
         let queryURI = PlacesUtils.history.queriesToQueryString([query], 1, opts);
 
--- a/browser/components/places/tests/chrome/test_bug631374_tags_selector_scroll.xul
+++ b/browser/components/places/tests/chrome/test_bug631374_tags_selector_scroll.xul
@@ -45,28 +45,28 @@
 
       Task.spawn(function* () {
         let bs = PlacesUtils.bookmarks;
 
         let tags = ["a", "b", "c", "d", "e", "f", "g",
                     "h", "i", "l", "m", "n", "o", "p"];
 
         // Add a bookmark and tag it.
-        let uri1 = Services.io.newURI("http://www1.mozilla.org/", null, null);
+        let uri1 = Services.io.newURI("http://www1.mozilla.org/");
         let bm1 = yield bs.insert({
           parentGuid: bs.toolbarGuid,
           index: bs.DEFAULT_INDEX,
           type: bs.TYPE_BOOKMARK,
           title: "mozilla",
           url: uri1.spec
         });
         PlacesUtils.tagging.tagURI(uri1, tags);
 
         // Add a second bookmark so that tags won't disappear when unchecked.
-        let uri2 = Services.io.newURI("http://www2.mozilla.org/", null, null);
+        let uri2 = Services.io.newURI("http://www2.mozilla.org/");
         let bm2 = yield bs.insert({
           parentGuid: bs.toolbarGuid,
           index: bs.DEFAULT_INDEX,
           type: bs.TYPE_BOOKMARK,
           title: "mozilla",
           url: uri2.spec
         });
         PlacesUtils.tagging.tagURI(uri2, tags);
--- a/browser/components/places/tests/chrome/test_editBookmarkOverlay_tags_liveUpdate.xul
+++ b/browser/components/places/tests/chrome/test_editBookmarkOverlay_tags_liveUpdate.xul
@@ -51,18 +51,18 @@
            "Tag is correctly marked");
       });
     }
 
     function runTest() {
       SimpleTest.waitForExplicitFinish();
 
       Task.spawn(function* () {
-        const TEST_URI = Services.io.newURI("http://www.test.me/", null, null);
-        const TEST_URI2 = Services.io.newURI("http://www.test.again.me/", null, null);
+        const TEST_URI = Services.io.newURI("http://www.test.me/");
+        const TEST_URI2 = Services.io.newURI("http://www.test.again.me/");
         const TEST_TAG = "test-tag";
 
         ok(gEditItemOverlay, "Sanity check: gEditItemOverlay is in context");
 
         // Open the tags selector.
         document.getElementById("editBMPanel_tagsSelectorRow").collapsed = false;
 
         // Add a bookmark.
--- a/browser/components/places/tests/chrome/test_treeview_date.xul
+++ b/browser/components/places/tests/chrome/test_treeview_date.xul
@@ -49,17 +49,17 @@
      *
      * Ensures that date in places treeviews is correctly formatted.
      */
 
     function runTest() {
       SimpleTest.waitForExplicitFinish();
 
       function uri(spec) {
-        return Services.io.newURI(spec, null, null);
+        return Services.io.newURI(spec);
       }
 
       Task.spawn(function* () {
         yield PlacesTestUtils.clearHistory();
 
         let midnight = new Date();
         midnight.setHours(0);
         midnight.setMinutes(0);
--- a/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js
+++ b/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js
@@ -1,10 +1,13 @@
 const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
 
+const {Utils} = Cu.import("resource://gre/modules/sessionstore/Utils.jsm", {});
+const triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL;
+
 add_task(function* () {
   waitForExplicitFinish();
 
   const tabURL = getRootDirectory(gTestPath) + "browser_bug1184989_prevent_scrolling_when_preferences_flipped.xul";
 
   yield BrowserTestUtils.withNewTab({ gBrowser, url: tabURL }, function* (browser) {
     let doc = browser.contentDocument;
     let container = doc.getElementById("container");
@@ -54,17 +57,17 @@ add_task(function* () {
   const CRASH_URL = "about:mozilla";
   const CRASH_FAVICON = "chrome://branding/content/icon32.png";
   const CRASH_SHENTRY = {url: CRASH_URL};
   const CRASH_TAB = {entries: [CRASH_SHENTRY], image: CRASH_FAVICON};
   const CRASH_STATE = {windows: [{tabs: [CRASH_TAB]}]};
 
   const TAB_URL = "about:sessionrestore";
   const TAB_FORMDATA = {url: TAB_URL, id: {sessionData: CRASH_STATE}};
-  const TAB_SHENTRY = {url: TAB_URL};
+  const TAB_SHENTRY = {url: TAB_URL, triggeringPrincipal_base64};
   const TAB_STATE = {entries: [TAB_SHENTRY], formdata: TAB_FORMDATA};
 
   let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
 
   // Fake a post-crash tab
   ss.setTabState(tab, JSON.stringify(TAB_STATE));
 
   yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
--- a/browser/components/preferences/in-content/tests/browser_subdialogs.js
+++ b/browser/components/preferences/in-content/tests/browser_subdialogs.js
@@ -37,17 +37,17 @@ function* open_subdialog_and_test_generi
       if (index >= 0) {
         expectedStyleSheetURLs.splice(index, 1);
       }
     }
 
     Assert.ok(!!subdialog._frame.contentWindow, "The dialog should be non-null");
     Assert.notEqual(subdialog._frame.contentWindow.location.toString(), "about:blank",
       "Subdialog URL should not be about:blank");
-    Assert.equal(win.getComputedStyle(subdialog._overlay, "").visibility, "visible",
+    Assert.equal(win.getComputedStyle(subdialog._overlay).visibility, "visible",
       "Overlay should be visible");
     Assert.equal(expectedStyleSheetURLs.length, 0,
       "No stylesheets that were expected are missing");
     return result;
   });
 }
 
 function* close_subdialog_and_test_generic_end_state(browser, closingFn, closingButton, acceptCount, options) {
@@ -60,17 +60,17 @@ function* close_subdialog_and_test_gener
       yield ContentTaskUtils.waitForEvent(frame.contentWindow, "dialogclosing");
     let contentClosingButton = closingEvent.detail.button;
     let actualAcceptCount = frame.contentWindow.arguments &&
                             frame.contentWindow.arguments[0].acceptCount;
 
     info("waiting for about:blank load");
     yield ContentTaskUtils.waitForEvent(frame, "load");
 
-    Assert.notEqual(win.getComputedStyle(subdialog._overlay, "").visibility, "visible",
+    Assert.notEqual(win.getComputedStyle(subdialog._overlay).visibility, "visible",
       "overlay is not visible");
     Assert.equal(frame.getAttribute("style"), "", "inline styles should be cleared");
     Assert.equal(frame.contentWindow.location.href.toString(), "about:blank",
       "sub-dialog should be unloaded");
     Assert.equal(contentClosingButton, expectations.closingButton,
       "closing event should indicate button was '" + expectations.closingButton + "'");
     Assert.equal(actualAcceptCount, expectations.acceptCount,
       "should be 1 if accepted, 0 if canceled, undefined if closed w/out button");
--- a/browser/components/sessionstore/SessionHistory.jsm
+++ b/browser/components/sessionstore/SessionHistory.jsm
@@ -101,17 +101,20 @@ var SessionHistoryInternal = {
       let body = webNavigation.document.body;
       // We landed here because the history is inaccessible or there are no
       // history entries. In that case we should at least record the docShell's
       // current URL as a single history entry. If the URL is not about:blank
       // or it's a blank tab that was modified (like a custom newtab page),
       // record it. For about:blank we explicitly want an empty array without
       // an 'index' property to denote that there are no history entries.
       if (uri != "about:blank" || (body && body.hasChildNodes())) {
-        data.entries.push({ url: uri });
+        data.entries.push({
+          url: uri,
+          triggeringPrincipal_base64: Utils.SERIALIZED_SYSTEMPRINCIPAL
+        });
         data.index = 1;
       }
     }
 
     // Check if we should discard some of the entries which didn't change
     if (aFromIdx > -1) {
       data.entries.splice(0, aFromIdx + 1);
     }
--- a/browser/components/sessionstore/SessionMigration.jsm
+++ b/browser/components/sessionstore/SessionMigration.jsm
@@ -6,33 +6,36 @@
 
 this.EXPORTED_SYMBOLS = ["SessionMigration"];
 
 const Cu = Components.utils;
 Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
 Cu.import("resource://gre/modules/Task.jsm", this);
 Cu.import("resource://gre/modules/osfile.jsm", this);
 
+XPCOMUtils.defineLazyModuleGetter(this, "Utils",
+  "resource://gre/modules/sessionstore/Utils.jsm");
+
 // An encoder to UTF-8.
 XPCOMUtils.defineLazyGetter(this, "gEncoder", function () {
   return new TextEncoder();
 });
 
 // A decoder.
 XPCOMUtils.defineLazyGetter(this, "gDecoder", function () {
   return new TextDecoder();
 });
 
 var SessionMigrationInternal = {
   /**
    * Convert the original session restore state into a minimal state. It will
    * only contain:
    * - open windows
    *   - with tabs
-   *     - with history entries with only title, url
+   *     - with history entries with only title, url, triggeringPrincipal
    *     - with pinned state
    *     - with tab group info (hidden + group id)
    *     - with selected tab info
    *   - with selected window info
    *
    * The complete state is then wrapped into the "about:welcomeback" page as
    * form field info to be restored when restoring the state.
    */
@@ -40,32 +43,35 @@ var SessionMigrationInternal = {
     let state = {
       selectedWindow: aStateObj.selectedWindow,
       _closedWindows: []
     };
     state.windows = aStateObj.windows.map(function(oldWin) {
       var win = {extData: {}};
       win.tabs = oldWin.tabs.map(function(oldTab) {
         var tab = {};
-        // Keep only titles and urls for history entries
+        // Keep only titles, urls and triggeringPrincipals for history entries
         tab.entries = oldTab.entries.map(function(entry) {
-          return {url: entry.url, title: entry.title};
+          return { url: entry.url,
+                   triggeringPrincipal_base64: entry.triggeringPrincipal_base64,
+                   title: entry.title };
         });
         tab.index = oldTab.index;
         tab.hidden = oldTab.hidden;
         tab.pinned = oldTab.pinned;
         return tab;
       });
       win.selected = oldWin.selected;
       win._closedTabs = [];
       return win;
     });
     let url = "about:welcomeback";
     let formdata = {id: {sessionData: state}, url};
-    return {windows: [{tabs: [{entries: [{url}], formdata}]}]};
+    let entry = { url, triggeringPrincipal_base64: Utils.SERIALIZED_SYSTEMPRINCIPAL };
+    return { windows: [{ tabs: [{ entries: [ entry ], formdata}]}]};
   },
   /**
    * Asynchronously read session restore state (JSON) from a path
    */
   readState: function(aPath) {
     return Task.spawn(function*() {
       let bytes = yield OS.File.read(aPath);
       let text = gDecoder.decode(bytes);
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -623,22 +623,24 @@ var SessionStoreInternal = {
           if (ss.previousSessionCrashed) {
             this._recentCrashes = (state.session &&
                                    state.session.recentCrashes || 0) + 1;
 
             if (this._needsRestorePage(state, this._recentCrashes)) {
               // replace the crashed session with a restore-page-only session
               let url = "about:sessionrestore";
               let formdata = {id: {sessionData: state}, url};
-              state = { windows: [{ tabs: [{ entries: [{url}], formdata }] }] };
+              let entry = {url, triggeringPrincipal_base64: Utils.SERIALIZED_SYSTEMPRINCIPAL };
+              state = { windows: [{ tabs: [{ entries: [entry], formdata }] }] };
             } else if (this._hasSingleTabWithURL(state.windows,
                                                  "about:welcomeback")) {
               // On a single about:welcomeback URL that crashed, replace about:welcomeback
               // with about:sessionrestore, to make clear to the user that we crashed.
               state.windows[0].tabs[0].entries[0].url = "about:sessionrestore";
+              state.windows[0].tabs[0].entries[0].triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL;
             }
           }
 
           // Update the session start time using the restored session state.
           this._updateSessionStartTime(state);
 
           // make sure that at least the first window doesn't have anything hidden
           delete state.windows[0].hidden;
--- a/browser/components/sessionstore/test/browser_393716.js
+++ b/browser/components/sessionstore/test/browser_393716.js
@@ -34,17 +34,17 @@ add_task(function* test_set_tabstate() {
   // clean up
   gBrowser.removeTab(tab);
 });
 
 add_task(function* test_set_tabstate_and_duplicate() {
   let key2 = "key2";
   let value2 = "Value " + Math.random();
   let value3 = "Another value: " + Date.now();
-  let state = { entries: [{ url: URL }], extData: { key2: value2 } };
+  let state = {entries: [{ url: URL, triggeringPrincipal_base64}], extData: { key2: value2 }};
 
   // create a new tab
   let tab = gBrowser.addTab();
   // set the tab's state
   ss.setTabState(tab, JSON.stringify(state));
   yield promiseBrowserLoaded(tab.linkedBrowser);
 
   // verify the correctness of the restored tab
--- a/browser/components/sessionstore/test/browser_394759_purge.js
+++ b/browser/components/sessionstore/test/browser_394759_purge.js
@@ -29,61 +29,61 @@ function test() {
   let oldState = ss.getBrowserState();
   let oldState_wins = JSON.parse(oldState).windows.length;
   if (oldState_wins != 1)
     ok(false, "oldState in test_purge has " + oldState_wins + " windows instead of 1");
 
   // create a new state for testing
   const REMEMBER = Date.now(), FORGET = Math.random();
   let testState = {
-    windows: [ { tabs: [{ entries: [{ url: "http://example.com/" }] }], selected: 1 } ],
+    windows: [ { tabs: [{ entries: [{ url: "http://example.com/", triggeringPrincipal_base64 }] }], selected: 1 } ],
     _closedWindows : [
       // _closedWindows[0]
       {
         tabs: [
-          { entries: [{ url: "http://example.com/", title: REMEMBER }] },
-          { entries: [{ url: "http://mozilla.org/", title: FORGET }] }
+          { entries: [{ url: "http://example.com/", triggeringPrincipal_base64, title: REMEMBER }] },
+          { entries: [{ url: "http://mozilla.org/", triggeringPrincipal_base64, title: FORGET }] }
         ],
         selected: 2,
         title: "mozilla.org",
         _closedTabs: []
       },
       // _closedWindows[1]
       {
         tabs: [
-         { entries: [{ url: "http://mozilla.org/", title: FORGET }] },
-         { entries: [{ url: "http://example.com/", title: REMEMBER }] },
-         { entries: [{ url: "http://example.com/", title: REMEMBER }] },
-         { entries: [{ url: "http://mozilla.org/", title: FORGET }] },
-         { entries: [{ url: "http://example.com/", title: REMEMBER }] }
+         { entries: [{ url: "http://mozilla.org/", triggeringPrincipal_base64, title: FORGET }] },
+         { entries: [{ url: "http://example.com/", triggeringPrincipal_base64, title: REMEMBER }] },
+         { entries: [{ url: "http://example.com/", triggeringPrincipal_base64, title: REMEMBER }] },
+         { entries: [{ url: "http://mozilla.org/", triggeringPrincipal_base64, title: FORGET }] },
+         { entries: [{ url: "http://example.com/", triggeringPrincipal_base64, title: REMEMBER }] }
         ],
         selected: 5,
         _closedTabs: []
       },
       // _closedWindows[2]
       {
         tabs: [
-          { entries: [{ url: "http://example.com/", title: REMEMBER }] }
+          { entries: [{ url: "http://example.com/", triggeringPrincipal_base64, title: REMEMBER }] }
         ],
         selected: 1,
         _closedTabs: [
           {
             state: {
               entries: [
-                { url: "http://mozilla.org/", title: FORGET },
-                { url: "http://mozilla.org/again", title: "doesn't matter" }
+                { url: "http://mozilla.org/", triggeringPrincipal_base64, title: FORGET },
+                { url: "http://mozilla.org/again", triggeringPrincipal_base64, title: "doesn't matter" }
               ]
             },
             pos: 1,
             title: FORGET
           },
           {
             state: {
               entries: [
-                { url: "http://example.com", title: REMEMBER }
+                { url: "http://example.com", triggeringPrincipal_base64, title: REMEMBER }
               ]
             },
             title: REMEMBER
           }
         ]
       }
     ]
   };
--- a/browser/components/sessionstore/test/browser_447951.js
+++ b/browser/components/sessionstore/test/browser_447951.js
@@ -17,17 +17,17 @@ function test() {
     gPrefService.clearUserPref("browser.sessionstore.max_serialize_forward");
   });
 
   let tab = gBrowser.addTab();
   promiseBrowserLoaded(tab.linkedBrowser).then(() => {
     let tabState = { entries: [] };
     let max_entries = gPrefService.getIntPref("browser.sessionhistory.max_entries");
     for (let i = 0; i < max_entries; i++)
-      tabState.entries.push({ url: baseURL + i });
+      tabState.entries.push({ url: baseURL + i, triggeringPrincipal_base64});
 
     promiseTabState(tab, tabState).then(() => {
       return TabStateFlusher.flush(tab.linkedBrowser);
     }).then(() => {
       tabState = JSON.parse(ss.getTabState(tab));
       is(tabState.entries.length, max_entries, "session history filled to the limit");
       is(tabState.entries[0].url, baseURL + 0, "... but not more");
 
--- a/browser/components/sessionstore/test/browser_463205.js
+++ b/browser/components/sessionstore/test/browser_463205.js
@@ -29,12 +29,12 @@ add_task(function* test_check_urls_befor
   is(value, "", "value was not restored");
 
   // Cleanup.
   gBrowser.removeTab(tab);
 });
 
 function getState(url) {
   return JSON.stringify({
-    entries: [{url: URL}],
+    entries: [{url: URL, triggeringPrincipal_base64}],
     formdata: {url: url, id: {text: "foobar"}}
   });
 }
--- a/browser/components/sessionstore/test/browser_467409-backslashplosion.js
+++ b/browser/components/sessionstore/test/browser_467409-backslashplosion.js
@@ -13,24 +13,24 @@
 // 2a. Check that there are no backslashes in the formdata
 // 2b. Check that formdata doesn't require JSON.parse
 //
 // 3.  [backwards compat] Use a stringified state as formdata when opening about:sessionrestore
 // 3a. Make sure there are nodes in the tree on about:sessionrestore (skipped, checking formdata is sufficient)
 // 3b. Check that there are no backslashes in the formdata
 // 3c. Check that formdata doesn't require JSON.parse
 
-const CRASH_STATE = {windows: [{tabs: [{entries: [{url: "about:mozilla" }]}]}]};
+const CRASH_STATE = {windows: [{tabs: [{entries: [{url: "about:mozilla", triggeringPrincipal_base64 }]}]}]};
 const STATE = createEntries(CRASH_STATE);
 const STATE2 = createEntries({windows: [{tabs: [STATE]}]});
 const STATE3 = createEntries(JSON.stringify(CRASH_STATE));
 
 function createEntries(sessionData) {
   return {
-    entries: [{url: "about:sessionrestore"}],
+    entries: [{url: "about:sessionrestore", triggeringPrincipal_base64}],
     formdata: {id: {sessionData: sessionData}, url: "about:sessionrestore"}
   };
 }
 
 add_task(function* test_nested_about_sessionrestore() {
   // Prepare a blank tab.
   let tab = gBrowser.addTab("about:blank");
   let browser = tab.linkedBrowser;
--- a/browser/components/sessionstore/test/browser_490040.js
+++ b/browser/components/sessionstore/test/browser_490040.js
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Only windows with open tabs are restorable. Windows where a lone tab is
 // detached may have _closedTabs, but is left with just an empty tab.
 const STATES = [{
     shouldBeAdded: true,
     windowState: {
       windows: [{
-        tabs: [{ entries: [{ url: "http://example.com", title: "example.com" }] }],
+        tabs: [{ entries: [{ url: "http://example.com", triggeringPrincipal_base64, title: "example.com" }] }],
         selected: 1,
         _closedTabs: []
       }]
     }
   }, {
     shouldBeAdded: false,
     windowState: {
       windows: [{
@@ -21,17 +21,17 @@ const STATES = [{
         _closedTabs: []
       }]
     }
   }, {
     shouldBeAdded: false,
     windowState: {
       windows: [{
         tabs: [{ entries: [] }],
-        _closedTabs: [{ state: { entries: [{ url: "http://example.com", index: 1 }] } }]
+        _closedTabs: [{ state: { entries: [{ url: "http://example.com", triggeringPrincipal_base64, index: 1 }] } }]
       }]
     }
   }, {
     shouldBeAdded: false,
     windowState: {
       windows: [{
         tabs: [{ entries: [] }],
         _closedTabs: [],
--- a/browser/components/sessionstore/test/browser_491577.js
+++ b/browser/components/sessionstore/test/browser_491577.js
@@ -5,61 +5,61 @@
 function test() {
   /** Test for Bug 491577 **/
 
   // test setup
   waitForExplicitFinish();
 
   const REMEMBER = Date.now(), FORGET = Math.random();
   let test_state = {
-    windows: [ { tabs: [{ entries: [{ url: "http://example.com/" }] }], selected: 1 } ],
+    windows: [ { tabs: [{ entries: [{ url: "http://example.com/", triggeringPrincipal_base64 }] }], selected: 1 } ],
     _closedWindows : [
       // _closedWindows[0]
       {
         tabs: [
-          { entries: [{ url: "http://example.com/", title: "title" }] },
-          { entries: [{ url: "http://mozilla.org/", title: "title" }] }
+          { entries: [{ url: "http://example.com/", triggeringPrincipal_base64, title: "title" }] },
+          { entries: [{ url: "http://mozilla.org/", triggeringPrincipal_base64, title: "title" }] }
         ],
         selected: 2,
         title: FORGET,
         _closedTabs: []
       },
       // _closedWindows[1]
       {
         tabs: [
-         { entries: [{ url: "http://mozilla.org/", title: "title" }] },
-         { entries: [{ url: "http://example.com/", title: "title" }] },
-         { entries: [{ url: "http://mozilla.org/", title: "title" }] },
+         { entries: [{ url: "http://mozilla.org/", triggeringPrincipal_base64, title: "title" }] },
+         { entries: [{ url: "http://example.com/", triggeringPrincipal_base64, title: "title" }] },
+         { entries: [{ url: "http://mozilla.org/", triggeringPrincipal_base64, title: "title" }] },
         ],
         selected: 3,
         title: REMEMBER,
         _closedTabs: []
       },
       // _closedWindows[2]
       {
         tabs: [
-          { entries: [{ url: "http://example.com/", title: "title" }] }
+          { entries: [{ url: "http://example.com/", triggeringPrincipal_base64, title: "title" }] }
         ],
         selected: 1,
         title: FORGET,
         _closedTabs: [
           {
             state: {
               entries: [
-                { url: "http://mozilla.org/", title: "title" },
-                { url: "http://mozilla.org/again", title: "title" }
+                { url: "http://mozilla.org/", triggeringPrincipal_base64, title: "title" },
+                { url: "http://mozilla.org/again", triggeringPrincipal_base64, title: "title" }
               ]
             },
             pos: 1,
             title: "title"
           },
           {
             state: {
               entries: [
-                { url: "http://example.com", title: "title" }
+                { url: "http://example.com", triggeringPrincipal_base64, title: "title" }
               ]
             },
             title: "title"
           }
         ]
       }
     ]
   };
--- a/browser/components/sessionstore/test/browser_514751.js
+++ b/browser/components/sessionstore/test/browser_514751.js
@@ -6,17 +6,17 @@ function test() {
   /** Test for Bug 514751 (Wallpaper) **/
 
   waitForExplicitFinish();
 
   let state = {
     windows: [{
       tabs: [{
         entries: [
-          { url: "about:mozilla", title: "Mozilla" },
+          { url: "about:mozilla", triggeringPrincipal_base64, title: "Mozilla" },
           {}
         ]
       }]
     }]
   };
 
   var theWin = openDialog(location, "", "chrome,all,dialog=no");
   theWin.addEventListener("load", function () {
--- a/browser/components/sessionstore/test/browser_522545.js
+++ b/browser/components/sessionstore/test/browser_522545.js
@@ -10,17 +10,17 @@ function test() {
 
   // This tests the following use case:
   // User opens a new tab which gets focus. The user types something into the
   // address bar, then crashes or quits.
   function test_newTabFocused() {
     let state = {
       windows: [{
         tabs: [
-          { entries: [{ url: "about:mozilla" }] },
+          { entries: [{ url: "about:mozilla", triggeringPrincipal_base64 }] },
           { entries: [], userTypedValue: "example.com", userTypedClear: 0 }
         ],
         selected: 2
       }]
     };
 
     waitForBrowserState(state, function() {
       let browser = gBrowser.selectedBrowser;
@@ -42,17 +42,17 @@ function test() {
 
   // This tests the following use case:
   // User opens a new tab which gets focus. The user types something into the
   // address bar, switches back to the first tab, then crashes or quits.
   function test_newTabNotFocused() {
     let state = {
       windows: [{
         tabs: [
-          { entries: [{ url: "about:mozilla" }] },
+          { entries: [{ url: "about:mozilla", triggeringPrincipal_base64 }] },
           { entries: [], userTypedValue: "example.org", userTypedClear: 0 }
         ],
         selected: 1
       }]
     };
 
     waitForBrowserState(state, function() {
       let browser = gBrowser.getBrowserAtIndex(1);
@@ -74,17 +74,18 @@ function test() {
 
   // This tests the following use case:
   // User is in a tab with session history, then types something in the
   // address bar, then crashes or quits.
   function test_existingSHEnd_noClear() {
     let state = {
       windows: [{
         tabs: [{
-          entries: [{ url: "about:mozilla" }, { url: "about:config" }],
+          entries: [{ url: "about:mozilla", triggeringPrincipal_base64},
+                    { url: "about:config", triggeringPrincipal_base64 }],
           index: 2,
           userTypedValue: "example.com",
           userTypedClear: 0
         }]
       }]
     };
 
     waitForBrowserState(state, function() {
@@ -103,17 +104,18 @@ function test() {
 
   // This tests the following use case:
   // User is in a tab with session history, presses back at some point, then
   // types something in the address bar, then crashes or quits.
   function test_existingSHMiddle_noClear() {
     let state = {
       windows: [{
         tabs: [{
-          entries: [{ url: "about:mozilla" }, { url: "about:config" }],
+          entries: [{ url: "about:mozilla", triggeringPrincipal_base64 },
+                    { url: "about:config", triggeringPrincipal_base64 }],
           index: 1,
           userTypedValue: "example.org",
           userTypedClear: 0
         }]
       }]
     };
 
     waitForBrowserState(state, function() {
@@ -240,17 +242,17 @@ function test() {
 
   let tests = [test_newTabFocused, test_newTabNotFocused,
                test_existingSHEnd_noClear, test_existingSHMiddle_noClear,
                test_getBrowserState_lotsOfTabsOpening,
                test_getBrowserState_userTypedValue, test_userTypedClearLoadURI];
   let originalState = JSON.parse(ss.getBrowserState());
   let state = {
     windows: [{
-      tabs: [{ entries: [{ url: "about:blank" }] }]
+      tabs: [{ entries: [{ url: "about:blank", triggeringPrincipal_base64 }] }]
     }]
   };
   function runNextTest() {
     if (tests.length) {
       waitForBrowserState(state, function() {
         gBrowser.selectedBrowser.userTypedValue = null;
         URLBarSetURI();
         (tests.shift())();
--- a/browser/components/sessionstore/test/browser_586068-apptabs.js
+++ b/browser/components/sessionstore/test/browser_586068-apptabs.js
@@ -8,23 +8,23 @@ const PREF_RESTORE_ON_DEMAND = "browser.
 
 add_task(function* test() {
   Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, true);
   registerCleanupFunction(function () {
     Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
   });
 
   let state = { windows: [{ tabs: [
-    { entries: [{ url: "http://example.org/#1" }], extData: { "uniq": r() }, pinned: true },
-    { entries: [{ url: "http://example.org/#2" }], extData: { "uniq": r() }, pinned: true },
-    { entries: [{ url: "http://example.org/#3" }], extData: { "uniq": r() }, pinned: true },
-    { entries: [{ url: "http://example.org/#4" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org/#5" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org/#6" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org/#7" }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], extData: { "uniq": r() }, pinned: true },
+    { entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], extData: { "uniq": r() }, pinned: true },
+    { entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], extData: { "uniq": r() }, pinned: true },
+    { entries: [{ url: "http://example.org/#4", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#5", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#6", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#7", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
   ], selected: 5 }] };
 
   let loadCount = 0;
   let promiseRestoringTabs = new Promise(resolve => {
     gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
       loadCount++;
 
       // We'll make sure that the loads we get come from pinned tabs or the
--- a/browser/components/sessionstore/test/browser_586068-apptabs_ondemand.js
+++ b/browser/components/sessionstore/test/browser_586068-apptabs_ondemand.js
@@ -10,23 +10,23 @@ add_task(function* test() {
   Services.prefs.setBoolPref(PREF_RESTORE_PINNED_TABS_ON_DEMAND, true);
 
   registerCleanupFunction(function () {
     Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
     Services.prefs.clearUserPref(PREF_RESTORE_PINNED_TABS_ON_DEMAND);
   });
 
   let state = { windows: [{ tabs: [
-    { entries: [{ url: "http://example.org/#1" }], extData: { "uniq": r() }, pinned: true },
-    { entries: [{ url: "http://example.org/#2" }], extData: { "uniq": r() }, pinned: true },
-    { entries: [{ url: "http://example.org/#3" }], extData: { "uniq": r() }, pinned: true },
-    { entries: [{ url: "http://example.org/#4" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org/#5" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org/#6" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org/#7" }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], extData: { "uniq": r() }, pinned: true },
+    { entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], extData: { "uniq": r() }, pinned: true },
+    { entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], extData: { "uniq": r() }, pinned: true },
+    { entries: [{ url: "http://example.org/#4", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#5", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#6", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#7", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
   ], selected: 5 }] };
 
   let promiseRestoringTabs = new Promise(resolve => {
     gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
       // get the tab
       let tab;
       for (let i = 0; i < window.gBrowser.tabs.length; i++) {
         if (!tab && window.gBrowser.tabs[i].linkedBrowser == aBrowser)
--- a/browser/components/sessionstore/test/browser_586068-browser_state_interrupted.js
+++ b/browser/components/sessionstore/test/browser_586068-browser_state_interrupted.js
@@ -12,49 +12,49 @@ add_task(function* test() {
     Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
   });
 
   // The first state will be loaded using setBrowserState, followed by the 2nd
   // state also being loaded using setBrowserState, interrupting the first restore.
   let state1 = { windows: [
     {
       tabs: [
-        { entries: [{ url: "http://example.org#1" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.org#2" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.org#3" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.org#4" }], extData: { "uniq": r() } }
+        { entries: [{ url: "http://example.org#1", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.org#2", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.org#3", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.org#4", triggeringPrincipal_base64 }], extData: { "uniq": r() } }
       ],
       selected: 1
     },
     {
       tabs: [
-        { entries: [{ url: "http://example.com#1" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.com#2" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.com#3" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.com#4" }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#1", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#2", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#3", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#4", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
       ],
       selected: 3
     }
   ] };
   let state2 = { windows: [
     {
       tabs: [
-        { entries: [{ url: "http://example.org#5" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.org#6" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.org#7" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.org#8" }], extData: { "uniq": r() } }
+        { entries: [{ url: "http://example.org#5", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.org#6", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.org#7", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.org#8", triggeringPrincipal_base64 }], extData: { "uniq": r() } }
       ],
       selected: 3
     },
     {
       tabs: [
-        { entries: [{ url: "http://example.com#5" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.com#6" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.com#7" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.com#8" }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#5", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#6", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#7", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#8", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
       ],
       selected: 1
     }
   ] };
 
   // interruptedAfter will be set after the selected tab from each window have loaded.
   let interruptedAfter = 0;
   let loadedWindow1 = false;
--- a/browser/components/sessionstore/test/browser_586068-cascade.js
+++ b/browser/components/sessionstore/test/browser_586068-cascade.js
@@ -6,22 +6,22 @@ const PREF_RESTORE_ON_DEMAND = "browser.
 
 add_task(function* test() {
   Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, false);
   registerCleanupFunction(function () {
     Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
   });
 
   let state = { windows: [{ tabs: [
-    { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.com" }], extData: { "uniq": r() } }
+    { entries: [{ url: "http://example.com", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.com", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.com", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.com", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.com", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.com", triggeringPrincipal_base64 }], extData: { "uniq": r() } }
   ] }] };
 
   let expectedCounts = [
     [3, 3, 0],
     [2, 3, 1],
     [1, 3, 2],
     [0, 3, 3],
     [0, 2, 4],
--- a/browser/components/sessionstore/test/browser_586068-multi_window.js
+++ b/browser/components/sessionstore/test/browser_586068-multi_window.js
@@ -10,28 +10,28 @@ add_task(function* test() {
     Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
   });
 
   // The first window will be put into the already open window and the second
   // window will be opened with _openWindowWithState, which is the source of the problem.
   let state = { windows: [
     {
       tabs: [
-        { entries: [{ url: "http://example.org#0" }], extData: { "uniq": r() } }
+        { entries: [{ url: "http://example.org#0", triggeringPrincipal_base64 }], extData: { "uniq": r() } }
       ],
       selected: 1
     },
     {
       tabs: [
-        { entries: [{ url: "http://example.com#1" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.com#2" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.com#3" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.com#4" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.com#5" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.com#6" }], extData: { "uniq": r() } }
+        { entries: [{ url: "http://example.com#1", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#2", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#3", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#4", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#5", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#6", triggeringPrincipal_base64 }], extData: { "uniq": r() } }
       ],
       selected: 4
     }
   ] };
   let numTabs = state.windows[0].tabs.length + state.windows[1].tabs.length;
 
   let loadCount = 0;
   let promiseRestoringTabs = new Promise(resolve => {
--- a/browser/components/sessionstore/test/browser_586068-reload.js
+++ b/browser/components/sessionstore/test/browser_586068-reload.js
@@ -6,25 +6,25 @@ const PREF_RESTORE_ON_DEMAND = "browser.
 
 add_task(function* test() {
   Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, true);
   registerCleanupFunction(function () {
     Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
   });
 
   let state = { windows: [{ tabs: [
-    { entries: [{ url: "http://example.org/#1" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org/#2" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org/#3" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org/#4" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org/#5" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org/#6" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org/#7" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org/#8" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org/#9" }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#4", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#5", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#6", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#7", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#8", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org/#9", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
   ], selected: 1 }] };
 
   let loadCount = 0;
   let promiseRestoringTabs = new Promise(resolve => {
     gBrowser.tabContainer.addEventListener("SSTabRestored", function onRestored(event) {
       let tab = event.target;
       let browser = tab.linkedBrowser;
       let tabData = state.windows[0].tabs[loadCount++];
--- a/browser/components/sessionstore/test/browser_586068-select.js
+++ b/browser/components/sessionstore/test/browser_586068-select.js
@@ -6,22 +6,22 @@ const PREF_RESTORE_ON_DEMAND = "browser.
 
 add_task(function* test() {
   Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, true);
   registerCleanupFunction(function () {
     Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
   });
 
   let state = { windows: [{ tabs: [
-    { entries: [{ url: "http://example.org" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org" }], extData: { "uniq": r() } }
+    { entries: [{ url: "http://example.org", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org", triggeringPrincipal_base64 }], extData: { "uniq": r() } }
   ], selected: 1 }] };
 
   let expectedCounts = [
     [5, 1, 0],
     [4, 1, 1],
     [3, 1, 2],
     [2, 1, 3],
     [1, 1, 4],
--- a/browser/components/sessionstore/test/browser_586068-window_state.js
+++ b/browser/components/sessionstore/test/browser_586068-window_state.js
@@ -8,28 +8,28 @@ add_task(function* test() {
   Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, false);
   registerCleanupFunction(function () {
     Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
   });
 
   // We'll use 2 states so that we can make sure calling setWindowState doesn't
   // wipe out currently restoring data.
   let state1 = { windows: [{ tabs: [
-    { entries: [{ url: "http://example.com#1" }] },
-    { entries: [{ url: "http://example.com#2" }] },
-    { entries: [{ url: "http://example.com#3" }] },
-    { entries: [{ url: "http://example.com#4" }] },
-    { entries: [{ url: "http://example.com#5" }] },
+    { entries: [{ url: "http://example.com#1", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.com#2", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.com#3", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.com#4", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.com#5", triggeringPrincipal_base64 }] },
   ] }] };
   let state2 = { windows: [{ tabs: [
-    { entries: [{ url: "http://example.org#1" }] },
-    { entries: [{ url: "http://example.org#2" }] },
-    { entries: [{ url: "http://example.org#3" }] },
-    { entries: [{ url: "http://example.org#4" }] },
-    { entries: [{ url: "http://example.org#5" }] }
+    { entries: [{ url: "http://example.org#1", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.org#2", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.org#3", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.org#4", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.org#5", triggeringPrincipal_base64 }] }
   ] }] };
   let numTabs = state1.windows[0].tabs.length + state2.windows[0].tabs.length;
 
   let loadCount = 0;
   let promiseRestoringTabs = new Promise(resolve => {
     gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
       // When loadCount == 2, we'll also restore state2 into the window
       if (++loadCount == 2) {
--- a/browser/components/sessionstore/test/browser_586068-window_state_override.js
+++ b/browser/components/sessionstore/test/browser_586068-window_state_override.js
@@ -8,28 +8,28 @@ add_task(function* test() {
   Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, false);
   registerCleanupFunction(function () {
     Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
   });
 
   // We'll use 2 states so that we can make sure calling setWindowState doesn't
   // wipe out currently restoring data.
   let state1 = { windows: [{ tabs: [
-    { entries: [{ url: "http://example.com#1" }] },
-    { entries: [{ url: "http://example.com#2" }] },
-    { entries: [{ url: "http://example.com#3" }] },
-    { entries: [{ url: "http://example.com#4" }] },
-    { entries: [{ url: "http://example.com#5" }] },
+    { entries: [{ url: "http://example.com#1", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.com#2", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.com#3", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.com#4", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.com#5", triggeringPrincipal_base64 }] },
   ] }] };
   let state2 = { windows: [{ tabs: [
-    { entries: [{ url: "http://example.org#1" }] },
-    { entries: [{ url: "http://example.org#2" }] },
-    { entries: [{ url: "http://example.org#3" }] },
-    { entries: [{ url: "http://example.org#4" }] },
-    { entries: [{ url: "http://example.org#5" }] }
+    { entries: [{ url: "http://example.org#1", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.org#2", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.org#3", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.org#4", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.org#5", triggeringPrincipal_base64 }] }
   ] }] };
   let numTabs = 2 + state2.windows[0].tabs.length;
 
   let loadCount = 0;
   let promiseRestoringTabs = new Promise(resolve => {
     gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
       // When loadCount == 2, we'll also restore state2 into the window
       if (++loadCount == 2) {
--- a/browser/components/sessionstore/test/browser_588426.js
+++ b/browser/components/sessionstore/test/browser_588426.js
@@ -1,15 +1,15 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   let state = { windows: [{ tabs: [
-      {entries: [{url: "about:mozilla"}], hidden: true},
-      {entries: [{url: "about:rights"}], hidden: true}
+      {entries: [{url: "about:mozilla", triggeringPrincipal_base64}], hidden: true},
+      {entries: [{url: "about:rights", triggeringPrincipal_base64}], hidden: true}
   ] }] };
 
   waitForExplicitFinish();
 
   newWindowWithState(state, function (win) {
     registerCleanupFunction(() => BrowserTestUtils.closeWindow(win));
 
     is(win.gBrowser.tabs.length, 2, "two tabs were restored");
--- a/browser/components/sessionstore/test/browser_590268.js
+++ b/browser/components/sessionstore/test/browser_590268.js
@@ -20,17 +20,17 @@ function test() {
   let restoredTabsCount = 0;
   let uniq2 = { };
   let uniq2Count = 0;
   let state = { windows: [{ tabs: [] }] };
   // We're going to put a bunch of tabs into this state
   for (let i = 0; i < NUM_TABS; i++) {
     let uniq = r();
     let tabData = {
-      entries: [{ url: "http://example.com/#" + i }],
+      entries: [{ url: "http://example.com/#" + i, triggeringPrincipal_base64}],
       extData: { "uniq": uniq, "baz": "qux" }
     };
     state.windows[0].tabs.push(tabData);
     wasLoaded[uniq] = false;
   }
 
 
   function onSSTabRestoring(aEvent) {
--- a/browser/components/sessionstore/test/browser_590563.js
+++ b/browser/components/sessionstore/test/browser_590563.js
@@ -1,23 +1,23 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   let sessionData = {
     windows: [{
       tabs: [
-        { entries: [{ url: "about:mozilla" }], hidden: true },
-        { entries: [{ url: "about:blank" }], hidden: false }
+        { entries: [{ url: "about:mozilla", triggeringPrincipal_base64 }], hidden: true },
+        { entries: [{ url: "about:blank", triggeringPrincipal_base64 }], hidden: false }
       ]
     }]
   };
   let url = "about:sessionrestore";
   let formdata = {id: {sessionData}, url};
-  let state = { windows: [{ tabs: [{ entries: [{url}], formdata }] }] };
+  let state = { windows: [{ tabs: [{ entries: [{url, triggeringPrincipal_base64}], formdata }] }] };
 
   waitForExplicitFinish();
 
   newWindowWithState(state, function (win) {
     registerCleanupFunction(() => BrowserTestUtils.closeWindow(win));
 
     is(gBrowser.tabs.length, 1, "The total number of tabs should be 1");
     is(gBrowser.visibleTabs.length, 1, "The total number of visible tabs should be 1");
--- a/browser/components/sessionstore/test/browser_595601-restore_hidden.js
+++ b/browser/components/sessionstore/test/browser_595601-restore_hidden.js
@@ -1,20 +1,20 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 var state = {windows:[{tabs:[
-  {entries:[{url:"http://example.com#1"}]},
-  {entries:[{url:"http://example.com#2"}]},
-  {entries:[{url:"http://example.com#3"}]},
-  {entries:[{url:"http://example.com#4"}]},
-  {entries:[{url:"http://example.com#5"}], hidden: true},
-  {entries:[{url:"http://example.com#6"}], hidden: true},
-  {entries:[{url:"http://example.com#7"}], hidden: true},
-  {entries:[{url:"http://example.com#8"}], hidden: true}
+  {entries:[{url:"http://example.com#1", triggeringPrincipal_base64}]},
+  {entries:[{url:"http://example.com#2", triggeringPrincipal_base64}]},
+  {entries:[{url:"http://example.com#3", triggeringPrincipal_base64}]},
+  {entries:[{url:"http://example.com#4", triggeringPrincipal_base64}]},
+  {entries:[{url:"http://example.com#5", triggeringPrincipal_base64}], hidden: true},
+  {entries:[{url:"http://example.com#6", triggeringPrincipal_base64}], hidden: true},
+  {entries:[{url:"http://example.com#7", triggeringPrincipal_base64}], hidden: true},
+  {entries:[{url:"http://example.com#8", triggeringPrincipal_base64}], hidden: true}
 ]}]};
 
 function test() {
   waitForExplicitFinish();
   requestLongerTimeout(2);
 
   registerCleanupFunction(function () {
     Services.prefs.clearUserPref("browser.sessionstore.restore_hidden_tabs");
--- a/browser/components/sessionstore/test/browser_599909.js
+++ b/browser/components/sessionstore/test/browser_599909.js
@@ -17,20 +17,20 @@ function test() {
   /** Bug 599909 - to-be-reloaded tabs don't show up in switch-to-tab **/
   waitForExplicitFinish();
 
   // Set the pref to true so we know exactly how many tabs should be restoring at
   // any given time. This guarantees that a finishing load won't start another.
   Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
 
   let state = { windows: [{ tabs: [
-    { entries: [{ url: "http://example.org/#1" }] },
-    { entries: [{ url: "http://example.org/#2" }] },
-    { entries: [{ url: "http://example.org/#3" }] },
-    { entries: [{ url: "http://example.org/#4" }] }
+    { entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }] },
+    { entries: [{ url: "http://example.org/#4", triggeringPrincipal_base64 }] }
   ], selected: 1 }] };
 
   let tabsForEnsure = {};
   state.windows[0].tabs.forEach(function(tab) {
     tabsForEnsure[tab.entries[0].url] = 1;
   });
 
   let tabsRestoring = 0;
--- a/browser/components/sessionstore/test/browser_600545.js
+++ b/browser/components/sessionstore/test/browser_600545.js
@@ -26,28 +26,28 @@ function testBug600545() {
   // and browser.sessionstore.resume_from_crash preference is false,
   // tab session data for non-active window is stripped for non-pinned
   // tabs.  This occurs after "sessionstore-state-write-complete"
   // fires which will only fire in this case if there is at least one
   // pinned tab.
   let state = { windows: [
     {
       tabs: [
-        { entries: [{ url: "http://example.org#0" }], pinned:true },
-        { entries: [{ url: "http://example.com#1" }] },
-        { entries: [{ url: "http://example.com#2" }] },
+        { entries: [{ url: "http://example.org#0", triggeringPrincipal_base64 }], pinned:true },
+        { entries: [{ url: "http://example.com#1", triggeringPrincipal_base64 }] },
+        { entries: [{ url: "http://example.com#2", triggeringPrincipal_base64 }] },
       ],
       selected: 2
     },
     {
       tabs: [
-        { entries: [{ url: "http://example.com#3" }] },
-        { entries: [{ url: "http://example.com#4" }] },
-        { entries: [{ url: "http://example.com#5" }] },
-        { entries: [{ url: "http://example.com#6" }] }
+        { entries: [{ url: "http://example.com#3", triggeringPrincipal_base64 }] },
+        { entries: [{ url: "http://example.com#4", triggeringPrincipal_base64 }] },
+        { entries: [{ url: "http://example.com#5", triggeringPrincipal_base64 }] },
+        { entries: [{ url: "http://example.com#6", triggeringPrincipal_base64 }] }
       ],
       selected: 3
     }
   ] };
 
   waitForBrowserState(state, function() {
     // Need to wait for SessionStore's saveState function to be called
     // so that non-pinned tabs will be stripped from non-active window
--- a/browser/components/sessionstore/test/browser_607016.js
+++ b/browser/components/sessionstore/test/browser_607016.js
@@ -6,22 +6,22 @@ add_task(function* () {
   /** Bug 607016 - If a tab is never restored, attributes (eg. hidden) aren't updated correctly **/
   ignoreAllUncaughtExceptions();
 
   // Set the pref to true so we know exactly how many tabs should be restoring at
   // any given time. This guarantees that a finishing load won't start another.
   Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
 
   let state = { windows: [{ tabs: [
-    { entries: [{ url: "http://example.org#1" }], extData: { "uniq": r() } },
-    { entries: [{ url: "http://example.org#2" }], extData: { "uniq": r() } }, // overwriting
-    { entries: [{ url: "http://example.org#3" }], extData: { "uniq": r() } }, // hiding
-    { entries: [{ url: "http://example.org#4" }], extData: { "uniq": r() } }, // adding
-    { entries: [{ url: "http://example.org#5" }], extData: { "uniq": r() } }, // deleting
-    { entries: [{ url: "http://example.org#6" }] } // creating
+    { entries: [{ url: "http://example.org#1", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+    { entries: [{ url: "http://example.org#2", triggeringPrincipal_base64 }], extData: { "uniq": r() } }, // overwriting
+    { entries: [{ url: "http://example.org#3", triggeringPrincipal_base64 }], extData: { "uniq": r() } }, // hiding
+    { entries: [{ url: "http://example.org#4", triggeringPrincipal_base64 }], extData: { "uniq": r() } }, // adding
+    { entries: [{ url: "http://example.org#5", triggeringPrincipal_base64 }], extData: { "uniq": r() } }, // deleting
+    { entries: [{ url: "http://example.org#6", triggeringPrincipal_base64 }] } // creating
   ], selected: 1 }] };
 
   function* progressCallback() {
     let curState = JSON.parse(ss.getBrowserState());
     for (let i = 0; i < curState.windows[0].tabs.length; i++) {
       let tabState = state.windows[0].tabs[i];
       let tabCurState = curState.windows[0].tabs[i];
       if (tabState.extData) {
--- a/browser/components/sessionstore/test/browser_615394-SSWindowState_events.js
+++ b/browser/components/sessionstore/test/browser_615394-SSWindowState_events.js
@@ -1,37 +1,37 @@
 /* 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/. */
 
 const stateBackup = JSON.parse(ss.getBrowserState());
 const testState = {
   windows: [{
     tabs: [
-      { entries: [{ url: "about:blank" }] },
-      { entries: [{ url: "about:rights" }] }
+      { entries: [{ url: "about:blank", triggeringPrincipal_base64 }] },
+      { entries: [{ url: "about:rights", triggeringPrincipal_base64 }] }
     ]
   }]
 };
 const lameMultiWindowState = { windows: [
     {
       tabs: [
-        { entries: [{ url: "http://example.org#1" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.org#2" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.org#3" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.org#4" }], extData: { "uniq": r() } }
+        { entries: [{ url: "http://example.org#1", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.org#2", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.org#3", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.org#4", triggeringPrincipal_base64 }], extData: { "uniq": r() } }
       ],
       selected: 1
     },
     {
       tabs: [
-        { entries: [{ url: "http://example.com#1" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.com#2" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.com#3" }], extData: { "uniq": r() } },
-        { entries: [{ url: "http://example.com#4" }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#1", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#2", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#3", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
+        { entries: [{ url: "http://example.com#4", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
       ],
       selected: 3
     }
   ] };
 
 
 function getOuterWindowID(aWindow) {
   return aWindow.QueryInterface(Ci.nsIInterfaceRequestor).
@@ -79,17 +79,17 @@ function runNextTest() {
     waitForBrowserState(stateBackup, finish);
   }
 }
 
 /**  ACTUAL TESTS  **/
 
 function test_setTabState() {
   let tab = gBrowser.tabs[1];
-  let newTabState = JSON.stringify({ entries: [{ url: "http://example.org" }], extData: { foo: "bar" } });
+  let newTabState = JSON.stringify({ entries: [{ url: "http://example.org", triggeringPrincipal_base64 }], extData: { foo: "bar" } });
   let busyEventCount = 0;
   let readyEventCount = 0;
 
   function onSSWindowStateBusy(aEvent) {
     busyEventCount++;
   }
 
   function onSSWindowStateReady(aEvent) {
@@ -199,18 +199,18 @@ function test_undoCloseTab() {
   reopenedTab = ss.undoCloseTab(window, 0);
 }
 
 
 function test_setWindowState() {
   let testState = {
     windows: [{
       tabs: [
-        { entries: [{ url: "about:mozilla" }], extData: { "foo": "bar" } },
-        { entries: [{ url: "http://example.org" }], extData: { "baz": "qux" } }
+        { entries: [{ url: "about:mozilla", triggeringPrincipal_base64 }], extData: { "foo": "bar" } },
+        { entries: [{ url: "http://example.org", triggeringPrincipal_base64 }], extData: { "baz": "qux" } }
       ]
     }]
   };
 
   let busyEventCount = 0,
       readyEventCount = 0,
       tabRestoredCount = 0;
 
--- a/browser/components/sessionstore/test/browser_618151.js
+++ b/browser/components/sessionstore/test/browser_618151.js
@@ -1,18 +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/. */
 
 const stateBackup = ss.getBrowserState();
 const testState = {
   windows: [{
     tabs: [
-      { entries: [{ url: "about:blank" }] },
-      { entries: [{ url: "about:mozilla" }] }
+      { entries: [{ url: "about:blank", triggeringPrincipal_base64 }] },
+      { entries: [{ url: "about:mozilla", triggeringPrincipal_base64 }] }
     ]
   }]
 };
 
 
 function test() {
   /** Test for Bug 618151 - Overwriting state can lead to unrestored tabs **/
   waitForExplicitFinish();
@@ -50,16 +50,16 @@ function runNextTest() {
 function test_setup() {
   function onSSTabRestored(aEvent) {
     gBrowser.tabContainer.removeEventListener("SSTabRestored", onSSTabRestored);
     runNextTest();
   }
 
   gBrowser.tabContainer.addEventListener("SSTabRestored", onSSTabRestored);
   ss.setTabState(gBrowser.tabs[1], JSON.stringify({
-    entries: [{ url: "http://example.org" }],
+    entries: [{ url: "http://example.org", triggeringPrincipal_base64 }],
     extData: { foo: "bar" } }));
 }
 
 function test_hang() {
   ok(true, "test didn't time out");
   runNextTest();
 }
--- a/browser/components/sessionstore/test/browser_636279.js
+++ b/browser/components/sessionstore/test/browser_636279.js
@@ -1,22 +1,22 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 var stateBackup = ss.getBrowserState();
 
 var statePinned = {windows:[{tabs:[
-  {entries:[{url:"http://example.com#1"}], pinned: true}
+  {entries:[{url:"http://example.com#1", triggeringPrincipal_base64}], pinned: true}
 ]}]};
 
 var state = {windows:[{tabs:[
-  {entries:[{url:"http://example.com#1"}]},
-  {entries:[{url:"http://example.com#2"}]},
-  {entries:[{url:"http://example.com#3"}]},
-  {entries:[{url:"http://example.com#4"}]},
+  {entries:[{url:"http://example.com#1", triggeringPrincipal_base64}]},
+  {entries:[{url:"http://example.com#2", triggeringPrincipal_base64}]},
+  {entries:[{url:"http://example.com#3", triggeringPrincipal_base64}]},
+  {entries:[{url:"http://example.com#4", triggeringPrincipal_base64}]},
 ]}]};
 
 function test() {
   waitForExplicitFinish();
 
   registerCleanupFunction(function () {
     TabsProgressListener.uninit();
     ss.setBrowserState(stateBackup);
--- a/browser/components/sessionstore/test/browser_637020.js
+++ b/browser/components/sessionstore/test/browser_637020.js
@@ -2,23 +2,23 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const TEST_URL = "http://mochi.test:8888/browser/browser/components/" +
                  "sessionstore/test/browser_637020_slow.sjs";
 
 const TEST_STATE = {
   windows: [{
     tabs: [
-      { entries: [{ url: "about:mozilla" }] },
-      { entries: [{ url: "about:robots" }] }
+      { entries: [{ url: "about:mozilla", triggeringPrincipal_base64}] },
+      { entries: [{ url: "about:robots", triggeringPrincipal_base64}] }
     ]
   }, {
     tabs: [
-      { entries: [{ url: TEST_URL }] },
-      { entries: [{ url: TEST_URL }] }
+      { entries: [{ url: TEST_URL, triggeringPrincipal_base64}] },
+      { entries: [{ url: TEST_URL, triggeringPrincipal_base64}] }
     ]
   }]
 };
 
 /**
  * This test ensures that windows that have just been restored will be marked
  * as dirty, otherwise _getCurrentState() might ignore them when collecting
  * state for the first time and we'd just save them as empty objects.
--- a/browser/components/sessionstore/test/browser_644409-scratchpads.js
+++ b/browser/components/sessionstore/test/browser_644409-scratchpads.js
@@ -1,15 +1,15 @@
  /* Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const testState = {
   windows: [{
     tabs: [
-      { entries: [{ url: "about:blank" }] },
+      { entries: [{ url: "about:blank", triggeringPrincipal_base64 }] },
     ]
   }],
   scratchpads: [
     { text: "text1", executionContext: 1 },
     { text: "", executionContext: 2, filename: "test.js" }
   ]
 };
 
--- a/browser/components/sessionstore/test/browser_662743.js
+++ b/browser/components/sessionstore/test/browser_662743.js
@@ -58,17 +58,17 @@ function test() {
 }
 
 function testTabRestoreData(aFormData, aExpectedValue, aCallback) {
   let testURL =
     getRootDirectory(gTestPath) + "browser_662743_sample.html";
   let tab = gBrowser.addTab(testURL);
 
   aFormData.url = testURL;
-  let tabState = { entries: [{ url: testURL, }], formdata: aFormData };
+  let tabState = { entries: [{ url: testURL, triggeringPrincipal_base64 }], formdata: aFormData };
 
   promiseBrowserLoaded(tab.linkedBrowser).then(() => {
     promiseTabState(tab, tabState).then(() => {
       // Flush to make sure we have the latest form data.
       return TabStateFlusher.flush(tab.linkedBrowser);
     }).then(() => {
       let doc = tab.linkedBrowser.contentDocument;
       let select = doc.getElementById("select_id");
--- a/browser/components/sessionstore/test/browser_687710.js
+++ b/browser/components/sessionstore/test/browser_687710.js
@@ -9,30 +9,34 @@
 // there is no root, and we loop forever.
 
 var stateBackup = ss.getBrowserState();
 
 var state = {windows:[{tabs:[{entries:[
   {
     docIdentifier: 1,
     url: "http://example.com",
+    triggeringPrincipal_base64,
     children: [
       {
         docIdentifier: 2,
-        url: "http://example.com"
+        url: "http://example.com",
+        triggeringPrincipal_base64,
       }
     ]
   },
   {
     docIdentifier: 2,
     url: "http://example.com",
+    triggeringPrincipal_base64,
     children: [
       {
         docIdentifier: 1,
-        url: "http://example.com"
+        url: "http://example.com",
+        triggeringPrincipal_base64,
       }
     ]
   }
 ]}]}]}
 
 function test() {
   registerCleanupFunction(function () {
     ss.setBrowserState(stateBackup);
--- a/browser/components/sessionstore/test/browser_687710_2.js
+++ b/browser/components/sessionstore/test/browser_687710_2.js
@@ -5,24 +5,28 @@
 // cousins should be able to share bfcache entries.
 
 var stateBackup = ss.getBrowserState();
 
 var state = {entries:[
   {
     docIdentifier: 1,
     url: "http://example.com?1",
+    triggeringPrincipal_base64,
     children: [{ docIdentifier: 10,
-                 url: "http://example.com?10" }]
+                 url: "http://example.com?10",
+                 triggeringPrincipal_base64 }]
   },
   {
     docIdentifier: 1,
     url: "http://example.com?1#a",
+    triggeringPrincipal_base64,
     children: [{ docIdentifier: 10,
-                 url: "http://example.com?10#aa" }]
+                 url: "http://example.com?10#aa",
+                 triggeringPrincipal_base64 }]
   }
 ]};
 
 function test()
 {
   waitForExplicitFinish();
 
   registerCleanupFunction(function () {
--- a/browser/components/sessionstore/test/browser_694378.js
+++ b/browser/components/sessionstore/test/browser_694378.js
@@ -5,17 +5,17 @@
 // 1.  call ss.setWindowState with a broken state
 // 1a. ensure that it doesn't throw.
 
 function test() {
   waitForExplicitFinish();
 
   let brokenState = {
     windows: [
-      { tabs: [{ entries: [{ url: "about:mozilla" }] }] }
+      { tabs: [{ entries: [{ url: "about:mozilla", triggeringPrincipal_base64 }] }] }
     ],
     selectedWindow: 2
   };
   let brokenStateString = JSON.stringify(brokenState);
 
   let gotError = false;
   try {
     ss.setWindowState(window, brokenStateString, true);
@@ -23,11 +23,11 @@ function test() {
   catch (ex) {
     gotError = true;
     info(ex);
   }
 
   ok(!gotError, "ss.setWindowState did not throw an error");
 
   // Make sure that we reset the state. Use a full state just in case things get crazy.
-  let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank" }] }]}]};
+  let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank", triggeringPrincipal_base64 }] }]}]};
   waitForBrowserState(blankState, finish);
 }
--- a/browser/components/sessionstore/test/browser_701377.js
+++ b/browser/components/sessionstore/test/browser_701377.js
@@ -1,14 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 var state = {windows:[{tabs:[
-  {entries:[{url:"http://example.com#1"}]},
-  {entries:[{url:"http://example.com#2"}], hidden: true}
+  {entries:[{url:"http://example.com#1", triggeringPrincipal_base64}]},
+  {entries:[{url:"http://example.com#2", triggeringPrincipal_base64}], hidden: true}
 ]}]};
 
 function test() {
   waitForExplicitFinish();
 
   newWindowWithState(state, function (aWindow) {
     let tab = aWindow.gBrowser.tabs[1];
     ok(tab.hidden, "the second tab is hidden");
--- a/browser/components/sessionstore/test/browser_705597.js
+++ b/browser/components/sessionstore/test/browser_705597.js
@@ -1,13 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 var tabState = {
-  entries: [{url: "about:robots", children: [{url: "about:mozilla"}]}]
+  entries: [{
+    url: "about:robots",
+    triggeringPrincipal_base64,
+    children: [{url: "about:mozilla", triggeringPrincipal_base64}]}]
 };
 
 function test() {
   waitForExplicitFinish();
   requestLongerTimeout(2);
 
   Services.prefs.setIntPref("browser.sessionstore.interval", 4000);
   registerCleanupFunction(function () {
@@ -28,17 +31,18 @@ function test() {
         promiseBrowserLoaded(browser).then(() => {
           return TabStateFlusher.flush(browser);
         }).then(() => {
           let {entries} = JSON.parse(ss.getTabState(tab));
           is(entries.length, 1, "tab has one history entry");
           ok(!entries[0].children, "history entry has no subframes");
 
           // Make sure that we reset the state.
-          let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank" }] }]}]};
+          let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank",
+                                                              triggeringPrincipal_base64}] }]}]};
           waitForBrowserState(blankState, finish);
         });
 
         // reload the browser to deprecate the subframes
         browser.reload();
       });
 
       // create a dynamic subframe
--- a/browser/components/sessionstore/test/browser_707862.js
+++ b/browser/components/sessionstore/test/browser_707862.js
@@ -1,13 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 var tabState = {
-  entries: [{url: "about:robots", children: [{url: "about:mozilla"}]}]
+  entries: [{
+    url: "about:robots",
+    triggeringPrincipal_base64,
+    children: [{url: "about:mozilla", triggeringPrincipal_base64,}]}]
 };
 
 function test() {
   waitForExplicitFinish();
   requestLongerTimeout(2);
 
   Services.prefs.setIntPref("browser.sessionstore.interval", 4000);
   registerCleanupFunction(function () {
@@ -26,17 +29,18 @@ function test() {
     whenChildCount(entry, 1, function () {
       whenChildCount(entry, 2, function () {
         promiseBrowserLoaded(browser).then(() => {
           let sessionHistory = browser.sessionHistory;
           let entry = sessionHistory.getEntryAtIndex(0, false);
 
           whenChildCount(entry, 0, function () {
             // Make sure that we reset the state.
-            let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank" }] }]}]};
+            let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank",
+                                                                triggeringPrincipal_base64 }] }]}]};
             waitForBrowserState(blankState, finish);
           });
         });
 
         // reload the browser to deprecate the subframes
         browser.reload();
       });
 
--- a/browser/components/sessionstore/test/browser_739805.js
+++ b/browser/components/sessionstore/test/browser_739805.js
@@ -1,14 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 var url = "data:text/html;charset=utf-8,<input%20id='foo'>";
 var tabState = {
-  entries: [{ url }], formdata: { id: { "foo": "bar" }, url }
+  entries: [{ url, triggeringPrincipal_base64 }], formdata: { id: { "foo": "bar" }, url }
 };
 
 function test() {
   waitForExplicitFinish();
   Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
 
   registerCleanupFunction(function () {
     if (gBrowser.tabs.length > 1)
--- a/browser/components/sessionstore/test/browser_aboutSessionRestore.js
+++ b/browser/components/sessionstore/test/browser_aboutSessionRestore.js
@@ -1,22 +1,22 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const CRASH_URL = "about:mozilla";
 const CRASH_FAVICON = "chrome://branding/content/icon32.png";
-const CRASH_SHENTRY = {url: CRASH_URL};
+const CRASH_SHENTRY = {url: CRASH_URL, triggeringPrincipal_base64};
 const CRASH_TAB = {entries: [CRASH_SHENTRY], image: CRASH_FAVICON};
 const CRASH_STATE = {windows: [{tabs: [CRASH_TAB]}]};
 
 const TAB_URL = "about:sessionrestore";
 const TAB_FORMDATA = {url: TAB_URL, id: {sessionData: CRASH_STATE}};
-const TAB_SHENTRY = {url: TAB_URL};
+const TAB_SHENTRY = {url: TAB_URL, triggeringPrincipal_base64};
 const TAB_STATE = {entries: [TAB_SHENTRY], formdata: TAB_FORMDATA};
 
 const FRAME_SCRIPT = "data:," +
                      "content.document.getElementById('errorTryAgain').click()";
 
 add_task(function* () {
   // Prepare a blank tab.
   let tab = gBrowser.addTab("about:blank");
--- a/browser/components/sessionstore/test/browser_attributes.js
+++ b/browser/components/sessionstore/test/browser_attributes.js
@@ -39,17 +39,17 @@ add_task(function* test() {
   tab.setAttribute("custom", "foobar");
   ss.persistTabAttribute("custom");
 
   ({attributes} = JSON.parse(ss.getTabState(tab)));
   is(attributes.custom, "foobar", "'custom' attribute is correct");
 
   // Make sure we're backwards compatible and restore old 'image' attributes.
   let state = {
-    entries: [{url: "about:mozilla"}],
+    entries: [{url: "about:mozilla", triggeringPrincipal_base64 }],
     attributes: {custom: "foobaz"},
     image: gBrowser.getIcon(tab)
   };
 
   // Prepare a pending tab waiting to be restored.
   let promise = promiseTabRestoring(tab);
   ss.setTabState(tab, JSON.stringify(state));
   yield promise;
--- a/browser/components/sessionstore/test/browser_capabilities.js
+++ b/browser/components/sessionstore/test/browser_capabilities.js
@@ -36,17 +36,17 @@ add_task(function* docshell_capabilities
   // Check that we correctly save disallowed features.
   let disallowedState = JSON.parse(ss.getTabState(tab));
   let disallow = new Set(disallowedState.disallow.split(","));
   ok(disallow.has("Images"), "images not allowed");
   ok(disallow.has("MetaRedirects"), "meta redirects not allowed");
   is(disallow.size, 2, "two capabilities disallowed");
 
   // Reuse the tab to restore a new, clean state into it.
-  yield promiseTabState(tab, {entries: [{url: "about:robots"}]});
+  yield promiseTabState(tab, {entries: [{url: "about:robots", triggeringPrincipal_base64}]});
 
   // Flush to make sure chrome received all data.
   yield TabStateFlusher.flush(browser);
 
   // After restoring disallowed features must be available again.
   state = JSON.parse(ss.getTabState(tab));
   ok(!("disallow" in state), "everything allowed again");
   ok(flags.every(f => docShell[f]), "all flags set to true");
--- a/browser/components/sessionstore/test/browser_formdata.js
+++ b/browser/components/sessionstore/test/browser_formdata.js
@@ -67,17 +67,17 @@ add_task(function* test_url_check() {
 
   // Create a tab with an iframe containing an input field.
   let tab = gBrowser.addTab(URL);
   let browser = tab.linkedBrowser;
   yield promiseBrowserLoaded(browser);
 
   // Restore a tab state with a given form data url.
   function restoreStateWithURL(url) {
-    let state = {entries: [{url: URL}], formdata: {id: {input: VALUE}}};
+    let state = {entries: [{url: URL, triggeringPrincipal_base64}], formdata: {id: {input: VALUE}}};
 
     if (url) {
       state.formdata.url = url;
     }
 
     return promiseTabState(tab, state).then(() => getInputValue(browser, "input"));
   }
 
--- a/browser/components/sessionstore/test/browser_formdata_format.js
+++ b/browser/components/sessionstore/test/browser_formdata_format.js
@@ -63,17 +63,17 @@ function test() {
 }
 
 async function testTabRestoreData(aFormData, aExpectedValue) {
   let URL = ROOT + "browser_formdata_format_sample.html";
   let tab = gBrowser.addTab("about:blank");
   let browser = tab.linkedBrowser;
 
   aFormData.url = URL;
-  let tabState = { entries: [{ url: URL }], formdata: aFormData };
+  let tabState = { entries: [{ url: URL, triggeringPrincipal_base64 }], formdata: aFormData };
 
   await promiseBrowserLoaded(tab.linkedBrowser);
   await promiseTabState(tab, tabState);
 
   await TabStateFlusher.flush(tab.linkedBrowser);
   let restoredTabState = JSON.parse(ss.getTabState(tab));
   let restoredFormData = restoredTabState.formdata;
 
--- a/browser/components/sessionstore/test/browser_frame_history.js
+++ b/browser/components/sessionstore/test/browser_frame_history.js
@@ -97,17 +97,17 @@ add_task(function*() {
   gBrowser.removeTab(newTab);
 });
 
 // Now, test that we don't record history if the iframe is added dynamically
 add_task(function*() {
   // Start with an empty history
     let blankState = JSON.stringify({
       windows: [{
-        tabs: [{ entries: [{ url: "about:blank" }] }],
+        tabs: [{ entries: [{ url: "about:blank", triggeringPrincipal_base64 }] }],
         _closedTabs: []
       }],
       _closedWindows: []
     });
     ss.setBrowserState(blankState);
 
   let testURL = getRootDirectory(gTestPath) + "browser_frame_history_index_blank.html";
   let tab = gBrowser.addTab(testURL);
--- a/browser/components/sessionstore/test/browser_global_store.js
+++ b/browser/components/sessionstore/test/browser_global_store.js
@@ -10,17 +10,17 @@ add_task(function* () {
 
   let global = {};
   global[key1] = value1;
 
   const testState = {
     windows: [
       {
         tabs: [
-          { entries: [{ url: "about:blank" }] },
+          { entries: [{ url: "about:blank", triggeringPrincipal_base64 }] },
         ]
       }
     ],
     global: global
   };
 
   function testRestoredState() {
     is(ss.getGlobalValue(key1), value1, "restored state has global value");
--- a/browser/components/sessionstore/test/browser_merge_closed_tabs.js
+++ b/browser/components/sessionstore/test/browser_merge_closed_tabs.js
@@ -4,34 +4,34 @@
 /**
  * This test ensures that closed tabs are merged when restoring
  * a window state without overwriting tabs.
  */
 add_task(function* () {
   const initialState = {
     windows: [{
       tabs: [
-        { entries: [{ url: "about:blank" }] }
+        { entries: [{ url: "about:blank", triggeringPrincipal_base64 }] }
       ],
       _closedTabs: [
-        { state: { entries: [{ ID: 1000, url: "about:blank" }]} },
-        { state: { entries: [{ ID: 1001, url: "about:blank" }]} }
+        { state: { entries: [{ ID: 1000, url: "about:blank", triggeringPrincipal_base64 }]} },
+        { state: { entries: [{ ID: 1001, url: "about:blank", triggeringPrincipal_base64 }]} }
       ]
     }]
   }
 
   const restoreState = {
     windows: [{
       tabs: [
-        { entries: [{ url: "about:robots" }] }
+        { entries: [{ url: "about:robots", triggeringPrincipal_base64 }] }
       ],
       _closedTabs: [
-        { state: { entries: [{ ID: 1002, url: "about:robots" }]} },
-        { state: { entries: [{ ID: 1003, url: "about:robots" }]} },
-        { state: { entries: [{ ID: 1004, url: "about:robots" }]} }
+        { state: { entries: [{ ID: 1002, url: "about:robots", triggeringPrincipal_base64 }]} },
+        { state: { entries: [{ ID: 1003, url: "about:robots", triggeringPrincipal_base64 }]} },
+        { state: { entries: [{ ID: 1004, url: "about:robots", triggeringPrincipal_base64 }]} }
       ]
     }]
   }
 
   const maxTabsUndo = 4;
   gPrefService.setIntPref("browser.sessionstore.max_tabs_undo", maxTabsUndo);
 
   // Open a new window and restore it to an initial state.
--- a/browser/components/sessionstore/test/browser_pending_tabs.js
+++ b/browser/components/sessionstore/test/browser_pending_tabs.js
@@ -1,12 +1,14 @@
 "use strict";
 
 const TAB_STATE = {
-  entries: [{ url: "about:mozilla" }, { url: "about:robots" }],
+  entries: [
+  { url: "about:mozilla", triggeringPrincipal_base64 },
+  { url: "about:robots", triggeringPrincipal_base64 }],
   index: 1,
 };
 
 add_task(function* () {
   // Create a background tab.
   let tab = gBrowser.addTab("about:blank");
   let browser = tab.linkedBrowser;
   yield promiseBrowserLoaded(browser);
--- a/browser/components/sessionstore/test/browser_purge_shistory.js
+++ b/browser/components/sessionstore/test/browser_purge_shistory.js
@@ -2,17 +2,18 @@
 
 /**
  * This test checks that pending tabs are treated like fully loaded tabs when
  * purging session history. Just like for fully loaded tabs we want to remove
  * every but the current shistory entry.
  */
 
 const TAB_STATE = {
-  entries: [{url: "about:mozilla"}, {url: "about:robots"}],
+  entries: [{url: "about:mozilla", triggeringPrincipal_base64},
+            {url: "about:robots", triggeringPrincipal_base64}],
   index: 1,
 };
 
 function checkTabContents(browser) {
   return ContentTask.spawn(browser, null, function* () {
     let Ci = Components.interfaces;
     let webNavigation = docShell.QueryInterface(Ci.nsIWebNavigation);
     let history = webNavigation.sessionHistory.QueryInterface(Ci.nsISHistoryInternal);
--- a/browser/components/sessionstore/test/browser_remoteness_flip_on_restore.js
+++ b/browser/components/sessionstore/test/browser_remoteness_flip_on_restore.js
@@ -32,29 +32,29 @@ function prepareState(state, selected) {
 
   return {
     windows: [ copy ],
   };
 }
 
 const SIMPLE_STATE = {
   tabs: [
-    { entries: [{ url: "http://example.com/", title: "title" }] },
-    { entries: [{ url: "http://example.com/", title: "title" }] },
-    { entries: [{ url: "http://example.com/", title: "title" }] },
+    { entries: [{ url: "http://example.com/", triggeringPrincipal_base64, title: "title" }] },
+    { entries: [{ url: "http://example.com/", triggeringPrincipal_base64, title: "title" }] },
+    { entries: [{ url: "http://example.com/", triggeringPrincipal_base64, title: "title" }] },
   ],
   title: "",
   _closedTabs: [],
 };
 
 const PINNED_STATE = {
   tabs: [
-    { entries: [{ url: "http://example.com/", title: "title" }], pinned: true },
-    { entries: [{ url: "http://example.com/", title: "title" }], pinned: true },
-    { entries: [{ url: "http://example.com/", title: "title" }] },
+    { entries: [{ url: "http://example.com/", triggeringPrincipal_base64, title: "title" }], pinned: true },
+    { entries: [{ url: "http://example.com/", triggeringPrincipal_base64, title: "title" }], pinned: true },
+    { entries: [{ url: "http://example.com/", triggeringPrincipal_base64, title: "title" }] },
   ],
   title: "",
   _closedTabs: [],
 };
 
 /**
  * This is where most of the action is happening. This function takes
  * an Array of "test scenario" Objects and runs them. For each scenario, a
--- a/browser/components/sessionstore/test/browser_restore_cookies_noOriginAttributes.js
+++ b/browser/components/sessionstore/test/browser_restore_cookies_noOriginAttributes.js
@@ -6,124 +6,127 @@
 
 const TEST_HOST = "www.example.com";
 const COOKIE =
 {
   name: "test1",
   value: "yes1",
   path: "/browser/browser/components/sessionstore/test/"
 };
-const SESSION_DATA = `
+const SESSION_DATA = JSON.stringify(
 {
-  "version": ["sessionrestore", 1],
-  "windows": [{
-    "tabs": [{
-      "entries": [],
-      "lastAccessed": 1463893009797,
-      "hidden": false,
-      "attributes": {},
-      "image": null
+  version: ["sessionrestore", 1],
+  windows: [{
+    tabs: [{
+      entries: [],
+      lastAccessed: 1463893009797,
+      hidden: false,
+      attributes: {},
+      image: null
     }, {
-      "entries": [{
-        "url": "http://www.example.com/browser/browser/components/sessionstore/test/browser_1267910_page.html",
-        \"charset": "UTF-8",
-        "ID": 0,
-        "docshellID": 2,
-        "originalURI": "http://www.example.com/browser/browser/components/sessionstore/test/browser_1267910_page.html",
-        \"docIdentifier": 0,
-        "persist": true
+      entries: [{
+        url: "http://www.example.com/browser/browser/components/sessionstore/test/browser_1267910_page.html",
+        triggeringPrincipal_base64: triggeringPrincipal_base64,
+        charset: "UTF-8",
+        ID: 0,
+        docshellID: 2,
+        originalURI: "http://www.example.com/browser/browser/components/sessionstore/test/browser_1267910_page.html",
+        docIdentifier: 0,
+        persist: true
       }],
-      "lastAccessed": 1463893009321,
-      "hidden": false,
-      "attributes": {},
-      "userContextId": 0,
-      "index": 1,
-      "image": "http://www.example.com/favicon.ico"
+      lastAccessed: 1463893009321,
+      hidden: false,
+      attributes: {},
+      userContextId: 0,
+      index: 1,
+      image: "http://www.example.com/favicon.ico"
     }],
-    "selected": 1,
-    "_closedTabs": [],
-    "busy": false,
-    "width": 1024,
-    "height": 768,
-    "screenX": 4,
-    "screenY": 23,
-    "sizemode": "normal",
-    "cookies": [{
-      "host": "www.example.com",
-      "value": "yes1",
-      "path": "/browser/browser/components/sessionstore/test/",
-      "name": "test1"
+    selected: 1,
+    _closedTabs: [],
+    busy: false,
+    width: 1024,
+    height: 768,
+    screenX: 4,
+    screenY: 23,
+    sizemode: "normal",
+    cookies: [{
+      host: "www.example.com",
+      value: "yes1",
+      path: "/browser/browser/components/sessionstore/test/",
+      name: "test1"
     }]
   }],
-  "selectedWindow": 1,
-  "_closedWindows": [],
-  "session": {
-    "lastUpdate": 1463893009801,
-    "startTime": 1463893007134,
-    "recentCrashes": 0
+  selectedWindow: 1,
+  _closedWindows: [],
+  session: {
+    lastUpdate: 1463893009801,
+    startTime: 1463893007134,
+    recentCrashes: 0
   },
-  "global": {}
-}`;
-const SESSION_DATA_OA = `
+  global: {}
+});
+
+const SESSION_DATA_OA = JSON.stringify(
 {
-  "version": ["sessionrestore", 1],
-  "windows": [{
-    "tabs": [{
-      "entries": [],
-      "lastAccessed": 1463893009797,
-      "hidden": false,
-      "attributes": {},
-      "image": null
+  version: ["sessionrestore", 1],
+  windows: [{
+    tabs: [{
+      entries: [],
+      lastAccessed: 1463893009797,
+      hidden: false,
+      attributes: {},
+      image: null
     }, {
-      "entries": [{
-        "url": "http://www.example.com/browser/browser/components/sessionstore/test/browser_1267910_page.html",
-        \"charset": "UTF-8",
-        "ID": 0,
-        "docshellID": 2,
-        "originalURI": "http://www.example.com/browser/browser/components/sessionstore/test/browser_1267910_page.html",
-        \"docIdentifier": 0,
-        "persist": true
+      entries: [{
+        url: "http://www.example.com/browser/browser/components/sessionstore/test/browser_1267910_page.html",
+        triggeringPrincipal_base64: triggeringPrincipal_base64,
+        charset: "UTF-8",
+        ID: 0,
+        docshellID: 2,
+        originalURI: "http://www.example.com/browser/browser/components/sessionstore/test/browser_1267910_page.html",
+        docIdentifier: 0,
+        persist: true
       }],
-      "lastAccessed": 1463893009321,
-      "hidden": false,
-      "attributes": {},
-      "userContextId": 0,
-      "index": 1,
-      "image": "http://www.example.com/favicon.ico"
+      lastAccessed: 1463893009321,
+      hidden: false,
+      attributes: {},
+      userContextId: 0,
+      index: 1,
+      image: "http://www.example.com/favicon.ico"
     }],
-    "selected": 1,
-    "_closedTabs": [],
-    "busy": false,
-    "width": 1024,
-    "height": 768,
-    "screenX": 4,
-    "screenY": 23,
-    "sizemode": "normal",
-    "cookies": [{
-      "host": "www.example.com",
-      "value": "yes1",
-      "path": "/browser/browser/components/sessionstore/test/",
-      "name": "test1",
-      "originAttributes": {
-        "addonId": "",
-        "appId": 0,
-        "inIsolatedMozBrowser": false,
-        "userContextId": 0
+    selected: 1,
+    _closedTabs: [],
+    busy: false,
+    width: 1024,
+    height: 768,
+    screenX: 4,
+    screenY: 23,
+    sizemode: "normal",
+    cookies: [{
+      host: "www.example.com",
+      value: "yes1",
+      path: "/browser/browser/components/sessionstore/test/",
+      name: "test1",
+      originAttributes: {
+        addonId: "",
+        appId: 0,
+        inIsolatedMozBrowser: false,
+        userContextId: 0
       }
     }]
   }],
-  "selectedWindow": 1,
-  "_closedWindows": [],
-  "session": {
-    "lastUpdate": 1463893009801,
-    "startTime": 1463893007134,
-    "recentCrashes": 0
+  selectedWindow: 1,
+  _closedWindows: [],
+  session: {
+    lastUpdate: 1463893009801,
+    startTime: 1463893007134,
+    recentCrashes: 0
   },
-  "global": {}
-}`;
+  global: {}
+});
 
 add_task(function* run_test() {
   // Wait until initialization is complete.
   yield SessionStore.promiseInitialized;
 
   // Clear cookies.
   Services.cookies.removeAll();
 
--- a/browser/components/sessionstore/test/browser_restore_redirect.js
+++ b/browser/components/sessionstore/test/browser_restore_redirect.js
@@ -3,17 +3,17 @@
 const BASE = "http://example.com/browser/browser/components/sessionstore/test/";
 const TARGET = BASE + "restore_redirect_target.html";
 
 /**
  * Ensure that a http redirect leaves a working tab.
  */
 add_task(function* check_http_redirect() {
   let state = {
-    entries: [{ url: BASE + "restore_redirect_http.html" }]
+    entries: [{ url: BASE + "restore_redirect_http.html", triggeringPrincipal_base64}]
   };
 
   // Open a new tab to restore into.
   let tab = gBrowser.addTab("about:blank");
   let browser = tab.linkedBrowser;
   yield promiseTabState(tab, state);
 
   info("Restored tab");
@@ -29,17 +29,17 @@ add_task(function* check_http_redirect()
   yield promiseRemoveTab(tab);
 });
 
 /**
  * Ensure that a js redirect leaves a working tab.
  */
 add_task(function* check_js_redirect() {
   let state = {
-    entries: [{ url: BASE + "restore_redirect_js.html" }]
+    entries: [{ url: BASE + "restore_redirect_js.html", triggeringPrincipal_base64}]
   };
 
   let loadPromise = new Promise(resolve => {
     function listener(msg) {
       if (msg.data.url.endsWith("restore_redirect_target.html")) {
         window.messageManager.removeMessageListener("ss-test:loadEvent", listener);
         resolve();
       }
--- a/browser/components/sessionstore/test/browser_unrestored_crashedTabs.js
+++ b/browser/components/sessionstore/test/browser_unrestored_crashedTabs.js
@@ -27,17 +27,17 @@ add_task(function* test() {
     // since this is how SessionStore creates all browsers before
     // they are restored.
     let unrestoredTab = gBrowser.addTab("about:blank", {
       skipAnimation: true,
       forceNotRemote: true,
     });
 
     let state = {
-      entries: [{url: PAGE}],
+      entries: [{url: PAGE, triggeringPrincipal_base64}],
     };
 
     ss.setTabState(unrestoredTab, JSON.stringify(state));
 
     ok(!unrestoredTab.hasAttribute("crashed"), "tab is not crashed");
     ok(unrestoredTab.hasAttribute("pending"), "tab is pending");
 
     // Now crash the selected browser.
--- a/browser/components/sessionstore/test/head.js
+++ b/browser/components/sessionstore/test/head.js
@@ -1,12 +1,15 @@
 /* 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/. */
 
+const {Utils} = Cu.import("resource://gre/modules/sessionstore/Utils.jsm", {});
+const triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL;
+
 const TAB_STATE_NEEDS_RESTORE = 1;
 const TAB_STATE_RESTORING = 2;
 
 const ROOT = getRootDirectory(gTestPath);
 const HTTPROOT = ROOT.replace("chrome://mochitests/content/", "http://example.com/");
 const FRAME_SCRIPTS = [
   ROOT + "content.js",
   ROOT + "content-forms.js"
@@ -460,20 +463,19 @@ function whenDelayedStartupFinished(aWin
   }, "browser-delayed-startup-finished", false);
 }
 function promiseDelayedStartupFinished(aWindow) {
   return new Promise(resolve => whenDelayedStartupFinished(aWindow, resolve));
 }
 
 function promiseEvent(element, eventType, isCapturing = false) {
   return new Promise(resolve => {
-    element.addEventListener(eventType, function listener(event) {
-      element.removeEventListener(eventType, listener, isCapturing);
+    element.addEventListener(eventType, function(event) {
       resolve(event);
-    }, isCapturing);
+    }, {capture: isCapturing, once: true});
   });
 }
 
 function promiseTabRestored(tab) {
   return promiseEvent(tab, "SSTabRestored");
 }
 
 function promiseTabRestoring(tab) {
--- a/browser/extensions/mortar/host/common/ppapi-runtime.jsm
+++ b/browser/extensions/mortar/host/common/ppapi-runtime.jsm
@@ -369,17 +369,17 @@ class OffscreenCanvas {
   set heigth(height) {
     this._canvas.height = height;
   }
 
   getContext(contextId, contextOptions) {
     return this._canvas.getContext(contextId, contextOptions);
   }
   transferToImageBitmap() {
-    let window = this._canvas.ownerDocument.defaultView;
+    let window = this._canvas.ownerGlobal;
     return window.createImageBitmap(this._canvas);
   }
 }
 
 
 class ObjectCache {
   constructor(getkeyForLookup=(v) => v) {
     this.objects = [];
--- a/browser/extensions/mortar/host/flash/ppapi-content-sandbox.js
+++ b/browser/extensions/mortar/host/flash/ppapi-content-sandbox.js
@@ -7,17 +7,17 @@
 /**
  * This code runs in the sandbox in the content process where the page that
  * loaded the plugin lives. It communicates with the process where the PPAPI
  * implementation lives.
  */
 const { utils: Cu } = Components;
 
 let mm = pluginElement.frameLoader.messageManager;
-let containerWindow = pluginElement.ownerDocument.defaultView;
+let containerWindow = pluginElement.ownerGlobal;
 
 function mapValue(v, instance) {
   return instance.rt.toPP_Var(v, instance);
 }
 
 dump("<>>>>>>>>>>>>>>>>>>>> AHA <<<<<<<<<<<<<<<<<<<<<>\n");
 dump(`pluginElement: ${pluginElement.toSource()}\n`);
 dump(`pluginElement.frameLoader: ${pluginElement.frameLoader.toSource()}\n`);
--- a/browser/extensions/mortar/host/pdf/ppapi-content-sandbox.js
+++ b/browser/extensions/mortar/host/pdf/ppapi-content-sandbox.js
@@ -14,17 +14,17 @@ const { classes: Cc, interfaces: Ci, res
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
                                           "resource://gre/modules/NetUtil.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
                              "resource://gre/modules/PrivateBrowsingUtils.jsm");
 
 let mm = pluginElement.frameLoader.messageManager;
-let containerWindow = pluginElement.ownerDocument.defaultView;
+let containerWindow = pluginElement.ownerGlobal;
 // Prevent the drag event's default action on the element, to avoid dragging of
 // that element while the user selects text.
 pluginElement.addEventListener("dragstart",
                                function(event) { event.preventDefault(); });
 // For synthetic documents only, prevent the select event's default action on
 // the element, to avoid selecting the element and the copying of an empty
 // string into the clipboard. Don't do this for non-synthetic documents, as
 // users still need to be able to select text outside the plugin.
--- a/browser/modules/BrowserUsageTelemetry.jsm
+++ b/browser/modules/BrowserUsageTelemetry.jsm
@@ -147,17 +147,17 @@ let URICountListener = {
       // an unfiltered URI.
       Services.telemetry.scalarAdd(UNFILTERED_URI_COUNT_SCALAR_NAME, 1);
       return;
     }
 
 
     // Don't count about:blank and similar pages, as they would artificially
     // inflate the counts.
-    if (browser.ownerDocument.defaultView.gInitialPages.includes(uriSpec)) {
+    if (browser.ownerGlobal.gInitialPages.includes(uriSpec)) {
       return;
     }
 
     // If the URI we're loading is in the _restoredURIsMap, then it comes from a
     // restored tab. If so, let's skip it and remove it from the map as we want to
     // count page refreshes.
     if (this._restoredURIsMap.get(browser) === uriSpec) {
       this._restoredURIsMap.delete(browser);
--- a/browser/modules/FormSubmitObserver.jsm
+++ b/browser/modules/FormSubmitObserver.jsm
@@ -201,17 +201,17 @@ FormSubmitObserver.prototype =
     // and where the content begin for the other elements.
     let offset = 0;
 
     if (aElement.tagName == "INPUT" &&
         (aElement.type == "radio" || aElement.type == "checkbox")) {
       panelData.position = "bottomcenter topleft";
     } else {
       let win = aElement.ownerGlobal;
-      let style = win.getComputedStyle(aElement, null);
+      let style = win.getComputedStyle(aElement);
       if (style.direction == "rtl") {
         offset = parseInt(style.paddingRight) + parseInt(style.borderRightWidth);
       } else {
         offset = parseInt(style.paddingLeft) + parseInt(style.borderLeftWidth);
       }
       let zoomFactor = this._getWindowUtils().fullZoom;
       panelData.offset = Math.round(offset * zoomFactor);
       panelData.position = "after_start";
--- a/browser/modules/URLBarZoom.jsm
+++ b/browser/modules/URLBarZoom.jsm
@@ -15,17 +15,17 @@ var URLBarZoom = {
     // Register ourselves with the service so we know when the zoom prefs change.
     Services.obs.addObserver(updateZoomButton, "browser-fullZoom:zoomChange", false);
     Services.obs.addObserver(updateZoomButton, "browser-fullZoom:zoomReset", false);
     Services.obs.addObserver(updateZoomButton, "browser-fullZoom:location-change", false);
   },
 }
 
 function updateZoomButton(aSubject, aTopic) {
-  let win = aSubject.ownerDocument.defaultView;
+  let win = aSubject.ownerGlobal;
   let customizableZoomControls = win.document.getElementById("zoom-controls");
   let zoomResetButton = win.document.getElementById("urlbar-zoom-button");
   let zoomFactor = Math.round(win.ZoomManager.zoom * 100);
 
   // Ensure that zoom controls haven't already been added to browser in Customize Mode
   if (customizableZoomControls &&
       customizableZoomControls.getAttribute("cui-areatype") == "toolbar") {
     zoomResetButton.hidden = true;
--- a/browser/modules/test/browser_UsageTelemetry_private_and_restore.js
+++ b/browser/modules/test/browser_UsageTelemetry_private_and_restore.js
@@ -1,10 +1,13 @@
 "use strict";
 
+const {Utils} = Cu.import("resource://gre/modules/sessionstore/Utils.jsm", {});
+const triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL;
+
 const MAX_CONCURRENT_TABS = "browser.engagement.max_concurrent_tab_count";
 const TAB_EVENT_COUNT = "browser.engagement.tab_open_event_count";
 const MAX_CONCURRENT_WINDOWS = "browser.engagement.max_concurrent_window_count";
 const WINDOW_OPEN_COUNT = "browser.engagement.window_open_event_count";
 const TOTAL_URI_COUNT = "browser.engagement.total_uri_count";
 const UNFILTERED_URI_COUNT = "browser.engagement.unfiltered_uri_count";
 const UNIQUE_DOMAINS_COUNT = "browser.engagement.unique_domains_count";
 
@@ -52,17 +55,18 @@ add_task(function* test_sessionRestore()
   Services.telemetry.clearScalars();
 
   // The first window will be put into the already open window and the second
   // window will be opened with _openWindowWithState, which is the source of the problem.
   const state = {
     windows: [
       {
         tabs: [
-          { entries: [{ url: "http://example.org" }], extData: { "uniq": 3785 } }
+          { entries: [{ url: "http://example.org", triggeringPrincipal_base64}],
+            extData: { "uniq": 3785 } }
         ],
         selected: 1
       }
     ]
   };
 
   // Save the current session.
   let SessionStore =
--- a/caps/tests/mochitest/test_addonMayLoad.html
+++ b/caps/tests/mochitest/test_addonMayLoad.html
@@ -34,21 +34,21 @@ https://bugzilla.mozilla.org/show_bug.cg
               "  xhr.onreadystatechange = function() { if (xhr.readyState == XMLHttpRequest.DONE) { finish(xhr.status == 200); } };" +
               "  xhr.open('GET', '" + uri + "', true);" +
               "  xhr.send();" +
               "})() } catch (e) { error(e); }");
     });
     return p;
   }
 
-  let exampleCom_addonA = new Cu.Sandbox(ssm.createCodebasePrincipal(Services.io.newURI('http://example.com', null, null), {addonId: 'addonA'}),
+  let exampleCom_addonA = new Cu.Sandbox(ssm.createCodebasePrincipal(Services.io.newURI('http://example.com'), {addonId: 'addonA'}),
                                          {wantGlobalProperties: ['XMLHttpRequest']});
   let nullPrin_addonA = new Cu.Sandbox(ssm.createNullPrincipal({addonId: 'addonA'}),
                                        {wantGlobalProperties: ['XMLHttpRequest']});
-  let exampleCom_addonB = new Cu.Sandbox(ssm.createCodebasePrincipal(Services.io.newURI('http://example.com', null, null), {addonId: 'addonB'}),
+  let exampleCom_addonB = new Cu.Sandbox(ssm.createCodebasePrincipal(Services.io.newURI('http://example.com'), {addonId: 'addonB'}),
                                          {wantGlobalProperties: ['XMLHttpRequest']});
 
   function uriForDomain(d) { return d + '/tests/caps/tests/mochitest/file_data.txt' }
 
   tryLoad(exampleCom_addonA, uriForDomain('http://example.com'))
   .then(function(success) {
     ok(success, "same-origin load should succeed for addon A");
     return tryLoad(nullPrin_addonA, uriForDomain('http://example.com'));
--- a/caps/tests/mochitest/test_disableScript.xul
+++ b/caps/tests/mochitest/test_disableScript.xul
@@ -24,17 +24,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   /** Test for all the different ways that script can be disabled for a given global. **/
 
   SimpleTest.waitForExplicitFinish();
   const Cu = Components.utils;
   const Ci = Components.interfaces;
   Cu.import("resource://gre/modules/Promise.jsm");
   Cu.import("resource://gre/modules/Services.jsm");
   const ssm = Services.scriptSecurityManager;
-  function makeURI(uri) { return Services.io.newURI(uri, null, null); }
+  function makeURI(uri) { return Services.io.newURI(uri); }
   const path = "/tests/caps/tests/mochitest/file_disableScript.html";
   const uri = "http://www.example.com" + path;
   var rootFrame = document.getElementById('root');
   var chromeFrame = document.getElementById('chromeFrame');
   navigateFrame(rootFrame, uri + "?name=rootframe").then(function() {
     navigateFrame(chromeFrame, "file_disableScript.html").then(go);
   });
 
--- a/caps/tests/mochitest/test_disallowInheritPrincipal.html
+++ b/caps/tests/mochitest/test_disallowInheritPrincipal.html
@@ -29,17 +29,17 @@ var sysPrincipal = secMan.getSystemPrinc
 isnot(sysPrincipal, undefined, "Should have a principal");
 isnot(sysPrincipal, null, "Should have a non-null principal");
 is(secMan.isSystemPrincipal(sysPrincipal), true,
    "Should have system principal here");
 
 
 var ioService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"].
                 getService(SpecialPowers.Ci.nsIIOService);
-var inheritingURI = ioService.newURI("javascript:1+1", null, null);
+var inheritingURI = ioService.newURI("javascript:1+1");
 
 // First try a normal call to checkLoadURIWithPrincipal
 try {
   secMan.checkLoadURIWithPrincipal(sysPrincipal, inheritingURI,
                                    nsIScriptSecurityManager.STANDARD);
   ok(true, "checkLoadURI allowed the load");
 } catch (e) {
   ok(false, "checkLoadURI failed unexpectedly: " + e);
--- a/caps/tests/mochitest/test_extensionURL.html
+++ b/caps/tests/mochitest/test_extensionURL.html
@@ -28,42 +28,42 @@ https://bugzilla.mozilla.org/show_bug.cg
       aps.setExtensionURILoadCallback(oldLoadCallback);
       aps.setExtensionURIToAddonIdCallback(oldMapCallback);
   });
 
   addLoadEvent(function() {
 
     // First, get a file:// URI to something - open to suggestions on how to do
     //  this more easily.
-    var resURI = SpecialPowers.Services.io.newURI('resource://testing-common/resource_test_file.html', null, null);
+    var resURI = SpecialPowers.Services.io.newURI('resource://testing-common/resource_test_file.html');
     var filePath = resourceHandler.resolveURI(resURI);
     ok(filePath.startsWith('file://'), 'resource:// URI resolves where we expect: ' + filePath);
-    var fileURI = SpecialPowers.Services.io.newURI(filePath, null, null);
+    var fileURI = SpecialPowers.Services.io.newURI(filePath);
 
     // Register a moz-extension:// URI.
     extensionHandler.setSubstitution('cherise', fileURI);
 
     // Alias the above.
-    extensionHandler.setSubstitution('liebchen', SpecialPowers.Services.io.newURI('moz-extension://cherise', null, null));
+    extensionHandler.setSubstitution('liebchen', SpecialPowers.Services.io.newURI('moz-extension://cherise'));
 
     //
     // Make sure that non-file:// URIs don't work.
     //
 
     // resource://
     try {
       extensionHandler.setSubstitution('interdit', resURI);
       ok(false, "Should have thrown for mapping moz-extension to resource");
     } catch (e) {
       ok(true, "Threw correctly: " + e);
     }
 
     // chrome://
     try {
-      var chromeURI = SpecialPowers.Services.io.newURI('chrome://global/content/mozilla.xhtml', null, null);
+      var chromeURI = SpecialPowers.Services.io.newURI('chrome://global/content/mozilla.xhtml');
       extensionHandler.setSubstitution('verboten', chromeURI);
       ok(false, "Should have thrown for mapping moz-extension to chrome");
     } catch (e) {
       ok(true, "Threw correctly: " + e);
     }
 
     function navigateWithLocation(ifr, url) { ifr.contentWindow.location = url; }
     function navigateWithSrc(ifr, url) { ifr.setAttribute('src', url); }
--- a/devtools/client/inspector/markup/test/browser_markup_load_01.js
+++ b/devtools/client/inspector/markup/test/browser_markup_load_01.js
@@ -69,14 +69,13 @@ function* chooseWithInspectElementContex
     button: 2
   }, tab.linkedBrowser);
 
   yield EventUtils.synthesizeKey("Q", {});
 }
 
 function waitForLinkedBrowserEvent(tab, event) {
   let def = defer();
-  tab.linkedBrowser.addEventListener(event, function cb() {
-    tab.linkedBrowser.removeEventListener(event, cb, true);
+  tab.linkedBrowser.addEventListener(event, function () {
     def.resolve();
-  }, true);
+  }, {capture: true, once: true});
   return def.promise;
 }
--- a/devtools/client/inspector/markup/test/browser_markup_void_elements_html.js
+++ b/devtools/client/inspector/markup/test/browser_markup_void_elements_html.js
@@ -18,27 +18,27 @@ add_task(function* () {
   ok(!editor.elt.querySelector(".close").style.display !== "none",
     "h1 element tag is not hidden");
 
   info("check void element closing tag is hidden in HTML document");
   let container = yield getContainerForSelector("img", inspector);
   ok(container.editor.elt.classList.contains("void-element"),
     "img element has the expected class");
   let closeElement = container.editor.elt.querySelector(".close");
-  let computedStyle = win.getComputedStyle(closeElement, null);
+  let computedStyle = win.getComputedStyle(closeElement);
   ok(computedStyle.display === "none", "img closing tag is hidden");
 
   info("check void element with pseudo element");
   let hrNodeFront = yield getNodeFront("hr.before", inspector);
   container = getContainerForNodeFront(hrNodeFront, inspector);
   ok(container.editor.elt.classList.contains("void-element"),
     "hr element has the expected class");
   closeElement = container.editor.elt.querySelector(".close");
-  computedStyle = win.getComputedStyle(closeElement, null);
+  computedStyle = win.getComputedStyle(closeElement);
   ok(computedStyle.display === "none", "hr closing tag is hidden");
 
   info("check expanded void element closing tag is not hidden");
   yield inspector.markup.expandNode(hrNodeFront);
   yield waitForMultipleChildrenUpdates(inspector);
   ok(container.expanded, "hr container is expanded");
-  computedStyle = win.getComputedStyle(closeElement, null);
+  computedStyle = win.getComputedStyle(closeElement);
   ok(computedStyle.display === "none", "hr closing tag is not hidden anymore");
 });
--- a/devtools/client/inspector/markup/test/browser_markup_void_elements_xhtml.js
+++ b/devtools/client/inspector/markup/test/browser_markup_void_elements_xhtml.js
@@ -18,11 +18,11 @@ add_task(function* () {
   ok(!editor.elt.querySelector(".close").style.display !== "none",
     "h1 element tag is not hidden");
 
   info("check void element closing tag is not hidden in XHTML document");
   let container = yield getContainerForSelector("br", inspector);
   ok(!container.editor.elt.classList.contains("void-element"),
     "br element does not have void-element class");
   let closeElement = container.editor.elt.querySelector(".close");
-  let computedStyle = win.getComputedStyle(closeElement, null);
+  let computedStyle = win.getComputedStyle(closeElement);
   ok(computedStyle.display !== "none", "br closing tag is not hidden");
 });
--- a/devtools/client/inspector/test/browser_inspector_startup.js
+++ b/devtools/client/inspector/test/browser_inspector_startup.js
@@ -65,20 +65,19 @@ add_task(function* () {
 
   // We should then receive the page load event
   info("Wait for load");
   yield pageLoaded;
 });
 
 function waitForLinkedBrowserEvent(tab, event) {
   let def = defer();
-  tab.linkedBrowser.addEventListener(event, function cb() {
-    tab.linkedBrowser.removeEventListener(event, cb, true);
+  tab.linkedBrowser.addEventListener(event, function () {
     def.resolve();
-  }, true);
+  }, {capture: true, once: true});
   return def.promise;
 }
 
 function contentReadyState(tab) {
   return ContentTask.spawn(tab.linkedBrowser, null, function () {
     return content.document.readyState;
   });
 }
--- a/devtools/client/shared/test/test-actor.js
+++ b/devtools/client/shared/test/test-actor.js
@@ -426,20 +426,19 @@ var TestActor = exports.TestActor = prot
    * Wait for a specific event on a node matching the provided selector.
    * @param {String} eventName The name of the event to listen to
    * @param {String} selector Optional:  css selector of the node which should
    *        trigger the event. If ommitted, target will be the content window
    */
   waitForEventOnNode: function (eventName, selector) {
     return new Promise(resolve => {
       let node = selector ? this._querySelector(selector) : this.content;
-      node.addEventListener(eventName, function onEvent() {
-        node.removeEventListener(eventName, onEvent);
+      node.addEventListener(eventName, function () {
         resolve();
-      });
+      }, {once: true});
     });
   },
 
   /**
    * Change the zoom level of the page.
    * Optionally subscribe to the box-model highlighter's update event and waiting
    * for it to refresh before responding.
    * @param {Number} level The new zoom level
--- a/devtools/client/webconsole/test/browser_webconsole_bug_632817.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_632817.js
@@ -197,17 +197,17 @@ function testLiveFilteringOnSearchString
     "the string \"foo\"bar'baz\"boo'\"");
 }
 
 function countMessageNodes() {
   let messageNodes = hud.outputNode.querySelectorAll(".message");
   let displayedMessageNodes = 0;
   let view = hud.iframeWindow;
   for (let i = 0; i < messageNodes.length; i++) {
-    let computedStyle = view.getComputedStyle(messageNodes[i], null);
+    let computedStyle = view.getComputedStyle(messageNodes[i]);
     if (computedStyle.display !== "none") {
       displayedMessageNodes++;
     }
   }
 
   return displayedMessageNodes;
 }
 
--- a/devtools/client/webconsole/test/browser_webconsole_live_filtering_of_message_types.js
+++ b/devtools/client/webconsole/test/browser_webconsole_live_filtering_of_message_types.js
@@ -41,16 +41,16 @@ add_task(function* () {
     "corresponding filter is switched on");
 });
 
 function countMessageNodes(hud) {
   let messageNodes = hud.outputNode.querySelectorAll(".message");
   let displayedMessageNodes = 0;
   let view = hud.iframeWindow;
   for (let i = 0; i < messageNodes.length; i++) {
-    let computedStyle = view.getComputedStyle(messageNodes[i], null);
+    let computedStyle = view.getComputedStyle(messageNodes[i]);
     if (computedStyle.display !== "none") {
       displayedMessageNodes++;
     }
   }
 
   return displayedMessageNodes;
 }
--- a/devtools/client/webconsole/test/browser_webconsole_live_filtering_on_search_strings.js
+++ b/devtools/client/webconsole/test/browser_webconsole_live_filtering_on_search_strings.js
@@ -75,17 +75,17 @@ add_task(function* () {
 
 function countMessageNodes(hud) {
   let outputNode = hud.outputNode;
 
   let messageNodes = outputNode.querySelectorAll(".message");
   let displayedMessageNodes = 0;
   let view = hud.iframeWindow;
   for (let i = 0; i < messageNodes.length; i++) {
-    let computedStyle = view.getComputedStyle(messageNodes[i], null);
+    let computedStyle = view.getComputedStyle(messageNodes[i]);
     if (computedStyle.display !== "none") {
       displayedMessageNodes++;
     }
   }
 
   return displayedMessageNodes;
 }
 
--- a/devtools/client/webconsole/test/browser_webconsole_log_file_filter.js
+++ b/devtools/client/webconsole/test/browser_webconsole_log_file_filter.js
@@ -62,17 +62,17 @@ function testLiveFilteringOnSearchString
 function countMessageNodes() {
   let outputNode = hud.outputNode;
 
   let messageNodes = outputNode.querySelectorAll(".message");
   content.console.log(messageNodes.length);
   let displayedMessageNodes = 0;
   let view = hud.iframeWindow;
   for (let i = 0; i < messageNodes.length; i++) {
-    let computedStyle = view.getComputedStyle(messageNodes[i], null);
+    let computedStyle = view.getComputedStyle(messageNodes[i]);
     if (computedStyle.display !== "none") {
       displayedMessageNodes++;
     }
   }
 
   return displayedMessageNodes;
 }
 
--- a/devtools/server/actors/highlighters/auto-refresh.js
+++ b/devtools/server/actors/highlighters/auto-refresh.js
@@ -187,17 +187,17 @@ AutoRefreshHighlighter.prototype = {
 
   _hide: function () {
     // To be implemented by sub classes
     // When called, sub classes should actually hide the highlighter
     throw new Error("Custom highlighter class had to implement _hide method");
   },
 
   _startRefreshLoop: function () {
-    let win = this.currentNode.ownerDocument.defaultView;
+    let win = this.currentNode.ownerGlobal;
     this.rafID = win.requestAnimationFrame(this._startRefreshLoop.bind(this));
     this.rafWin = win;
     this.update();
   },
 
   _stopRefreshLoop: function () {
     if (this.rafID && !Cu.isDeadWrapper(this.rafWin)) {
       this.rafWin.cancelAnimationFrame(this.rafID);
--- a/devtools/server/actors/highlighters/box-model.js
+++ b/devtools/server/actors/highlighters/box-model.js
@@ -290,17 +290,17 @@ BoxModelHighlighter.prototype = extend(A
   },
 
   /**
    * Track the current node markup mutations so that the node info bar can be
    * updated to reflects the node's attributes
    */
   _trackMutations: function () {
     if (isNodeValid(this.currentNode)) {
-      let win = this.currentNode.ownerDocument.defaultView;
+      let win = this.currentNode.ownerGlobal;
       this.currentNodeObserver = new win.MutationObserver(this.update);
       this.currentNodeObserver.observe(this.currentNode, {attributes: true});
     }
   },
 
   _untrackMutations: function () {
     if (isNodeValid(this.currentNode) && this.currentNodeObserver) {
       this.currentNodeObserver.disconnect();
--- a/devtools/server/actors/highlighters/geometry-editor.js
+++ b/devtools/server/actors/highlighters/geometry-editor.js
@@ -87,17 +87,17 @@ var GeoProp = {
  *
  * node.offsetParent returns the nearest positioned ancestor but if it is
  * non-positioned itself, we just return null to let consumers know the node is
  * actually positioned relative to the viewport.
  *
  * @return {Object}
  */
 function getOffsetParent(node) {
-  let win = node.ownerDocument.defaultView;
+  let win = node.ownerGlobal;
 
   let offsetParent = node.offsetParent;
   if (offsetParent &&
       getComputedStyle(offsetParent).position === "static") {
     offsetParent = null;
   }
 
   let width, height;
@@ -638,17 +638,17 @@ GeometryEditorHighlighter.prototype = ex
         }
         return marginBox[side] - parseFloat(this.computedStyle[side]);
       }
 
       // In case the element is positioned in the viewport.
       if (GeoProp.isInverted(side)) {
         return this.offsetParent.dimension[GeoProp.mainAxisSize(side)];
       }
-      return -1 * this.currentNode.ownerDocument.defaultView["scroll" +
+      return -1 * this.currentNode.ownerGlobal["scroll" +
                                               GeoProp.axis(side).toUpperCase()];
     };
 
     for (let side of GeoProp.SIDES) {
       let sideProp = this.definedProperties.get(side);
       if (!sideProp) {
         continue;
       }
--- a/devtools/server/actors/highlighters/simple-outline.js
+++ b/devtools/server/actors/highlighters/simple-outline.js
@@ -43,17 +43,17 @@ SimpleOutlineHighlighter.prototype = {
   /**
    * Show the highlighter on a given node
    * @param {DOMNode} node
    */
   show: function (node) {
     if (isNodeValid(node) && (!this.currentNode || node !== this.currentNode)) {
       this.hide();
       this.currentNode = node;
-      installHelperSheet(node.ownerDocument.defaultView, SIMPLE_OUTLINE_SHEET);
+      installHelperSheet(node.ownerGlobal, SIMPLE_OUTLINE_SHEET);
       addPseudoClassLock(node, HIGHLIGHTED_PSEUDO_CLASS);
     }
     return true;
   },
 
   /**
    * Hide the highlighter, the outline and the infobar.
    */
--- a/devtools/server/actors/inspector.js
+++ b/devtools/server/actors/inspector.js
@@ -1820,17 +1820,17 @@ var WalkerActor = protocol.ActorClassWit
     this._queuePseudoClassMutation(node);
     return true;
   },
 
   _installHelperSheet: function (node) {
     if (!this.installedHelpers) {
       this.installedHelpers = new WeakMap();
     }
-    let win = node.rawNode.ownerDocument.defaultView;
+    let win = node.rawNode.ownerGlobal;
     if (!this.installedHelpers.has(win)) {
       let { Style } = require("sdk/stylesheet/style");
       let { attach } = require("sdk/content/mod");
       let style = Style({source: HELPER_SHEET, type: "agent" });
       attach(style, win);
       this.installedHelpers.set(win, style);
     }
   },
@@ -3120,17 +3120,17 @@ function nodeHasSize(node) {
  * @param {HTMLImageElement} image - The image element.
  * @param {Number} timeout - Maximum amount of time the image is allowed to load
  * before the waiting is aborted. Ignored if flags.testing is set.
  *
  * @return {Promise} that is fulfilled once the image has loaded. If the image
  * fails to load or the load takes too long, the promise is rejected.
  */
 function ensureImageLoaded(image, timeout) {
-  let { HTMLImageElement } = image.ownerDocument.defaultView;
+  let { HTMLImageElement } = image.ownerGlobal;
   if (!(image instanceof HTMLImageElement)) {
     return promise.reject("image must be an HTMLImageELement");
   }
 
   if (image.complete) {
     // The image has already finished loading.
     return promise.resolve();
   }
@@ -3175,17 +3175,17 @@ function ensureImageLoaded(image, timeou
  *     naturalWidth: 400,
  *     naturalHeight: 300,
  *     resized: true }
  *  }.
  *
  * If something goes wrong, the promise is rejected.
  */
 var imageToImageData = Task.async(function* (node, maxDim) {
-  let { HTMLCanvasElement, HTMLImageElement } = node.ownerDocument.defaultView;
+  let { HTMLCanvasElement, HTMLImageElement } = node.ownerGlobal;
 
   let isImg = node instanceof HTMLImageElement;
   let isCanvas = node instanceof HTMLCanvasElement;
 
   if (!isImg && !isCanvas) {
     throw new Error("node is not a <canvas> or <img> element.");
   }
 
--- a/devtools/server/actors/webbrowser.js
+++ b/devtools/server/actors/webbrowser.js
@@ -662,17 +662,17 @@ DevToolsUtils.makeInfallible(function (w
    */
   Services.tm.currentThread.dispatch(DevToolsUtils.makeInfallible(() => {
     /*
      * Scan the entire map for actors representing tabs that were in this
      * top-level window, and exit them.
      */
     for (let [browser, actor] of this._actorByBrowser) {
       /* The browser document of a closed window has no default view. */
-      if (!browser.ownerDocument.defaultView) {
+      if (!browser.ownerGlobal) {
         this._handleActorClose(actor, browser);
       }
     }
   }, "BrowserTabList.prototype.onCloseWindow's delayed body"), 0);
 }, "BrowserTabList.prototype.onCloseWindow");
 
 exports.BrowserTabList = BrowserTabList;
 
--- a/devtools/server/actors/webconsole.js
+++ b/devtools/server/actors/webconsole.js
@@ -1777,17 +1777,17 @@ WebConsoleActor.prototype =
    *         The XUL window that owns the content window.
    */
   chromeWindow: function WCA_chromeWindow()
   {
     let window = null;
     try {
       window = this.window.QueryInterface(Ci.nsIInterfaceRequestor)
              .getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell)
-             .chromeEventHandler.ownerDocument.defaultView;
+             .chromeEventHandler.ownerGlobal;
     }
     catch (ex) {
       // The above can fail because chromeEventHandler is not available for all
       // kinds of |this.window|.
     }
 
     return window;
   },
--- a/devtools/server/css-logic.js
+++ b/devtools/server/css-logic.js
@@ -677,24 +677,22 @@ CssLogic.getBindingElementAndPseudo = fu
  *
  * @param {Node}
  * @returns {CSSStyleDeclaration}
  */
 CssLogic.getComputedStyle = function (node) {
   if (!node ||
       Cu.isDeadWrapper(node) ||
       node.nodeType !== nodeConstants.ELEMENT_NODE ||
-      !node.ownerDocument ||
-      !node.ownerDocument.defaultView) {
+      !node.ownerGlobal) {
     return null;
   }
 
   let {bindingElement, pseudo} = CssLogic.getBindingElementAndPseudo(node);
-  return node.ownerDocument.defaultView.getComputedStyle(bindingElement,
-                                                         pseudo);
+  return node.ownerGlobal.getComputedStyle(bindingElement, pseudo);
 };
 
 /**
  * Get a source for a stylesheet, taking into account embedded stylesheets
  * for which we need to use document.defaultView.location.href rather than
  * sheet.href
  *
  * @param {CSSStyleSheet} sheet the DOM object for the style sheet.
--- a/devtools/shared/gcli/source/lib/gcli/mozui/inputter.js
+++ b/devtools/shared/gcli/source/lib/gcli/mozui/inputter.js
@@ -140,17 +140,17 @@ Inputter.prototype.onWindowResize = func
 /**
  * Make ourselves visually similar to the input element, and make the input
  * element transparent so our background shines through
  */
 Inputter.prototype.getDimensions = function() {
   var fixedLoc = {};
   var currentElement = this.element.parentNode;
   while (currentElement && currentElement.nodeName !== '#document') {
-    var style = this.document.defaultView.getComputedStyle(currentElement, '');
+    var style = this.document.defaultView.getComputedStyle(currentElement);
     if (style) {
       var position = style.getPropertyValue('position');
       if (position === 'absolute' || position === 'fixed') {
         var bounds = currentElement.getBoundingClientRect();
         fixedLoc.top = bounds.top;
         fixedLoc.left = bounds.left;
         break;
       }
--- a/devtools/shared/layout/utils.js
+++ b/devtools/shared/layout/utils.js
@@ -404,17 +404,17 @@ function safelyGetContentWindow(frame) {
  *        The frame.
  * @return {Array} [offsetTop, offsetLeft]
  *         offsetTop is the distance from the top of the frame and the top of
  *         the content document.
  *         offsetLeft is the distance from the left of the frame and the left
  *         of the content document.
  */
 function getFrameContentOffset(frame) {
-  let style = safelyGetContentWindow(frame).getComputedStyle(frame, null);
+  let style = safelyGetContentWindow(frame).getComputedStyle(frame);
 
   // In some cases, the computed style is null
   if (!style) {
     return [0, 0];
   }
 
   let paddingTop = parseInt(style.getPropertyValue("padding-top"), 10);
   let paddingLeft = parseInt(style.getPropertyValue("padding-left"), 10);
--- a/devtools/shared/webconsole/test/test_network_security-hpkp.html
+++ b/devtools/shared/webconsole/test/test_network_security-hpkp.html
@@ -49,17 +49,17 @@ function startTest()
 
     // Reset pinning state.
     let gSSService = Cc["@mozilla.org/ssservice;1"]
                        .getService(Ci.nsISiteSecurityService);
 
     let gIOService = Cc["@mozilla.org/network/io-service;1"]
                        .getService(Ci.nsIIOService);
     for (let {url} of TEST_CASES) {
-      let uri = gIOService.newURI(url, null, null);
+      let uri = gIOService.newURI(url);
       gSSService.removeState(Ci.nsISiteSecurityService.HEADER_HPKP, uri, 0);
     }
   });
 
   info("Test detection of Public Key Pinning.");
   removeEventListener("load", startTest);
   attachConsoleToTab(["NetworkActivity"], onAttach);
 }
--- a/devtools/shared/webconsole/test/test_network_security-hsts.html
+++ b/devtools/shared/webconsole/test/test_network_security-hsts.html
@@ -42,17 +42,17 @@ function startTest()
   SimpleTest.registerCleanupFunction(() => {
     // Reset HSTS state.
     let gSSService = Cc["@mozilla.org/ssservice;1"]
                        .getService(Ci.nsISiteSecurityService);
 
     let gIOService = Cc["@mozilla.org/network/io-service;1"]
                        .getService(Ci.nsIIOService);
 
-    let uri = gIOService.newURI(TEST_CASES[0].url, null, null);
+    let uri = gIOService.newURI(TEST_CASES[0].url);
     gSSService.removeState(Ci.nsISiteSecurityService.HEADER_HSTS, uri, 0);
   });
 
   info("Test detection of HTTP Strict Transport Security.");
   removeEventListener("load", startTest);
   attachConsoleToTab(["NetworkActivity"], onAttach);
 }
 
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -12582,22 +12582,21 @@ nsDocShell::LoadHistoryEntry(nsISHEntry*
   if (isSrcdoc) {
     aEntry->GetSrcdocData(srcdoc);
     aEntry->GetBaseURI(getter_AddRefs(baseURI));
     flags |= INTERNAL_LOAD_FLAGS_IS_SRCDOC;
   } else {
     srcdoc = NullString();
   }
 
-  // If there is no triggeringPrincipal we can fall back to using the
-  // SystemPrincipal as the triggeringPrincipal for loading the history
-  // entry, since the history entry can only end up in history if security
-  // checks passed in the initial loading phase.
+  // If there is no valid triggeringPrincipal, we deny the load
+  MOZ_ASSERT(triggeringPrincipal,
+             "need a valid triggeringPrincipal to load from history");
   if (!triggeringPrincipal) {
-    triggeringPrincipal = nsContentUtils::GetSystemPrincipal();
+    return NS_ERROR_FAILURE;
   }
 
   // Passing nullptr as aSourceDocShell gives the same behaviour as before
   // aSourceDocShell was introduced. According to spec we should be passing
   // the source browsing context that was used when the history entry was
   // first created. bug 947716 has been created to address this issue.
   rv = InternalLoad(uri,
                     originalURI,
--- a/docshell/shistory/nsSHEntry.cpp
+++ b/docshell/shistory/nsSHEntry.cpp
@@ -411,16 +411,19 @@ nsSHEntry::Create(nsIURI* aURI, const ns
                   nsIInputStream* aInputStream,
                   nsILayoutHistoryState* aLayoutHistoryState,
                   nsISupports* aCacheKey, const nsACString& aContentType,
                   nsIPrincipal* aTriggeringPrincipal,
                   nsIPrincipal* aPrincipalToInherit,
                   const nsID& aDocShellID,
                   bool aDynamicCreation)
 {
+  MOZ_ASSERT(aTriggeringPrincipal,
+             "need a valid triggeringPrincipal to create a session history entry");
+
   mURI = aURI;
   mTitle = aTitle;
   mPostData = aInputStream;
 
   // Set the LoadType by default to loadHistory during creation
   mLoadType = (uint32_t)nsIDocShellLoadInfo::loadHistory;
 
   mShared->mCacheKey = aCacheKey;
@@ -510,16 +513,20 @@ nsSHEntry::GetTriggeringPrincipal(nsIPri
 {
   NS_IF_ADDREF(*aTriggeringPrincipal = mShared->mTriggeringPrincipal);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHEntry::SetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal)
 {
+  MOZ_ASSERT(aTriggeringPrincipal, "need a valid triggeringPrincipal");
+  if (!aTriggeringPrincipal) {
+    return NS_ERROR_FAILURE;
+  }
   mShared->mTriggeringPrincipal = aTriggeringPrincipal;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHEntry::GetPrincipalToInherit(nsIPrincipal** aPrincipalToInherit)
 {
   NS_IF_ADDREF(*aPrincipalToInherit = mShared->mPrincipalToInherit);
--- a/dom/base/crashtests/326865-1.html
+++ b/dom/base/crashtests/326865-1.html
@@ -1,12 +1,12 @@
 <html>
 <head>
 <script>
 try {
-  window.getComputedStyle(null, null);
+  window.getComputedStyle(null);
 } catch (e) {
 }
 </script>
 </head>
 <body>
 </body>
 </html>
--- a/dom/base/crashtests/816253.html
+++ b/dom/base/crashtests/816253.html
@@ -17,15 +17,15 @@
         <div id="console"></div>
         <div id="parentDiv">
             <div id="left-to-right" dir="auto" class="testElement">
                 <input type="text" value="מקור השם עברית">Test test test
             </div>
         </div>
         <script id="des">
             var el = document.getElementById("left-to-right");
-            document.defaultView.getComputedStyle(el, null).getPropertyValue('border-right-color');
+            document.defaultView.getComputedStyle(el).getPropertyValue('border-right-color');
 
             document.getElementById("parentDiv").style.display = "none";
         </script>
 
     </body>
 </html>
--- a/dom/base/test/file_bug416317.xhtml
+++ b/dom/base/test/file_bug416317.xhtml
@@ -471,17 +471,17 @@
           if (needToggle) {
             if ((div.getAttribute("class") || "").toString().indexOf("skipWhenToggling") > -1) {
               continue;
             }
             window.frameElement.style.display = "";
             // make sure it kicks in immediately
             document.body.offsetWidth;
           }
-          var view = document.defaultView.getComputedStyle(div, null);
+          var view = document.defaultView.getComputedStyle(div);
           var bg = view.getPropertyValue("background-color") || div.style.backgroundColor;
           if (needToggle) {
             window.frameElement.style.display = "none";
             // make sure it kicks in immediately
             document.body.offsetWidth;
           }
 
           var pass = bg && bg.indexOf("(255, 0, 0") == -1 && bg.indexOf("#ff0000") == -1 && bg.indexOf("red") == -1;
--- a/dom/base/test/test_bug1008126.html
+++ b/dom/base/test/test_bug1008126.html
@@ -20,17 +20,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 </div>
 <pre id="test">
 <script type="application/javascript;version=1.7">
 function translateChrome(uriStr) {
   const { Cc, Ci } = SpecialPowers;
   let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
   let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
-  let uri = ios.newURI(uriStr, null, ios.newURI(document.baseURI, null, null));
+  let uri = ios.newURI(uriStr, null, ios.newURI(document.baseURI));
   return chromeReg.convertChromeURL(uri).spec;
 }
 
 function runTest() {
   var worker = new Worker("file_bug1008126_worker.js");
 
   worker.onmessage = function(event) {
     if (event.data.type == 'finish') {
--- a/dom/base/test/test_bug1268962.html
+++ b/dom/base/test/test_bug1268962.html
@@ -47,17 +47,17 @@ function testCancelPrefetchNotCrash(url)
 
   var link = document.createElement("LINK");
   link.setAttribute("rel", "prefetch");
   link.setAttribute("href", url);
   document.head.appendChild(link);
 
   // Not actually verifying any value, just to ensure cancelPrefetch
   // won't cause crash.
-  prefetch.cancelPrefetchURI(ios.newURI(url, null, null), link);
+  prefetch.cancelPrefetchURI(ios.newURI(url), link);
 }
 
 const SJS_PATH = window.location.pathname.replace(/[^/]+$/, "file_bug1268962.sjs");
 const SAME_ORIGIN = "http://mochi.test:8888" + SJS_PATH;
 const CROSS_ORIGIN = "http://example.com" + SJS_PATH;
 
 SimpleTest.waitForExplicitFinish();
 
--- a/dom/base/test/test_bug338679.html
+++ b/dom/base/test/test_bug338679.html
@@ -64,15 +64,15 @@ function test_1() {
 }
 
 function test_2() {
   e_new = "width: 15%;";
   testDiv.style.width = "15%";
 }
 
 function test_3() {
-  window.getComputedStyle(testDiv, null).width; // force style resolution
+  window.getComputedStyle(testDiv).width; // force style resolution
   e_new = "width: inherit;";
   testDiv.style.width = "inherit";
 }
 </script>
 </body>
 </html>
--- a/dom/base/test/test_bug368972.html
+++ b/dom/base/test/test_bug368972.html
@@ -81,17 +81,17 @@ function check_size(id, width, height) {
   var element = document.getElementById(id);
   ok(element, "Plugin element " + id + " did not exist");
   if (width != "auto") {
     width = width + "px";
   }
   if (height != "auto") {
     height = height + "px";
   }
-  var style = window.getComputedStyle(element, null);
+  var style = window.getComputedStyle(element);
   is(style.width, width, "Plugin element " + id + " had an incorrect width");
   is(style.height, height, "Plugin element " + id + " had an incorrect height");
 }
 
 check_size("embed1", "auto", "auto");
 check_size("embed2", 0, 0);
 check_size("embed3", 100, 100);
 check_size("embed4", "auto", 100);
--- a/dom/base/test/test_bug493881.js
+++ b/dom/base/test/test_bug493881.js
@@ -37,17 +37,17 @@ addLoadEvent( function() {
   // Verify that the legacy color properties still have their original values.
   for (var i = 0; i < legacyProps.length; i++) {
     is(document[legacyProps[i]], initialValues[i], "document[" + legacyProps[i] + "] altered after body load");
   }
   
   // Verify that legacy color properties applied before BODY are really ignored when rendering.
   // Save current computed style colors for later use.
   for (i = 0; i < idPropList.length; i++) {
-    var style = window.getComputedStyle(document.getElementById(idPropList[i].id), null);
+    var style = window.getComputedStyle(document.getElementById(idPropList[i].id));
     var color = style.getPropertyValue(idPropList[i].prop);
     idPropList[i].initialComputedColor = color;
     isnot(color, rgbTestColors[i], "element rendered using before-body style");
   }
   // XXX: Can't get links to visually activate via script events, so can't verify
   // that the alinkColor property was not applied.
   
   // Verify that setting legacy color props to undefined after BODY loads will cause them
@@ -56,17 +56,17 @@ addLoadEvent( function() {
     document[legacyProps[i]] = undefined;
     is(document[legacyProps[i]], "undefined", 
       "Unexpected value of " + legacyProps[i] + " after setting to undefined");
   }
   
   // Verify that setting legacy color props to undefined led to result
   // of parsing undefined as a color.
   for (i = 0; i < idPropList.length; i++) {
-    var style = window.getComputedStyle(document.getElementById(idPropList[i].id), null);
+    var style = window.getComputedStyle(document.getElementById(idPropList[i].id));
     var color = style.getPropertyValue(idPropList[i].prop);
     is(color, "rgb(0, 239, 14)", 
       "element's style should get result of parsing undefined as a color");
   }
 
   // Mark the test as finished.
   setTimeout(SimpleTest.finish, 0);
 });
--- a/dom/base/test/test_bug945152.html
+++ b/dom/base/test/test_bug945152.html
@@ -16,17 +16,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 </div>
 <pre id="test">
 <script type="application/javascript;version=1.7">
 function translateChrome(uriStr) {
   const { Cc, Ci } = SpecialPowers;
   let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
   let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
-  let uri = ios.newURI(uriStr, null, ios.newURI(document.baseURI, null, null));
+  let uri = ios.newURI(uriStr, null, ios.newURI(document.baseURI));
   return chromeReg.convertChromeURL(uri).spec;
 }
 
 function runTest() {
   var worker = new Worker("file_bug945152_worker.js");
 
   worker.onmessage = function(event) {
     if (event.data.type == 'finish') {
--- a/dom/base/test/test_html_colors_quirks.html
+++ b/dom/base/test/test_html_colors_quirks.html
@@ -683,18 +683,18 @@ var todos = {
 "  aliceblue   ": true,
 "H3<MOq'81C#\\nUjQc  xlsF@c2R<e);T~G]^N0_*M<j!jub~k,mgZ(.>GERhwS;kmmKC?1l} qQ&zcXK?g)S OmF^=E^TlTC)/": true,
 " $4X": true,
 "UGzLF+o3)Ezs=nMxqd^\"=q.Ik}Tk2I`X)R8]Zmy/WQp,|]TdbP)5  J+#Hm6SmWtQ+h?.MQ1W#oyp\\F,'JL>rLtjiHOA": true
 };
 
 var table0 = document.getElementById("table0");
 var table1 = document.getElementById("table1");
-var cs0 = document.defaultView.getComputedStyle(table0, "");
-var cs1 = document.defaultView.getComputedStyle(table1, "");
+var cs0 = document.defaultView.getComputedStyle(table0);
+var cs1 = document.defaultView.getComputedStyle(table1);
 var result;
 var reference;
 var log = "";
 var len = tests.length;
 is(tests.length, references.length, "array length mismatch");
 for (var i = 0; i < len; ++i) {
   table0.setAttribute("bgColor", tests[i]);
   table1.style.backgroundColor = references[i];
--- a/dom/base/test/test_html_colors_standards.html
+++ b/dom/base/test/test_html_colors_standards.html
@@ -684,18 +684,18 @@ var todos = {
 "  aliceblue   ": true,
 "H3<MOq'81C#\\nUjQc  xlsF@c2R<e);T~G]^N0_*M<j!jub~k,mgZ(.>GERhwS;kmmKC?1l} qQ&zcXK?g)S OmF^=E^TlTC)/": true,
 " $4X": true,
 "UGzLF+o3)Ezs=nMxqd^\"=q.Ik}Tk2I`X)R8]Zmy/WQp,|]TdbP)5  J+#Hm6SmWtQ+h?.MQ1W#oyp\\F,'JL>rLtjiHOA": true
 };
 
 var table0 = document.getElementById("table0");
 var table1 = document.getElementById("table1");
-var cs0 = document.defaultView.getComputedStyle(table0, "");
-var cs1 = document.defaultView.getComputedStyle(table1, "");
+var cs0 = document.defaultView.getComputedStyle(table0);
+var cs1 = document.defaultView.getComputedStyle(table1);
 var result;
 var reference;
 var log = "";
 var len = tests.length;
 is(tests.length, references.length, "array length mismatch");
 for (var i = 0; i < len; ++i) {
   table0.setAttribute("bgColor", tests[i]);
   table1.style.backgroundColor = references[i];
--- a/dom/bindings/Errors.msg
+++ b/dom/bindings/Errors.msg
@@ -83,16 +83,17 @@ MSG_DEF(MSG_NO_ACTIVE_WORKER, 1, JSEXN_T
 MSG_DEF(MSG_NOTIFICATION_PERMISSION_DENIED, 0, JSEXN_TYPEERR, "Permission to show Notification denied.")
 MSG_DEF(MSG_NOTIFICATION_NO_CONSTRUCTOR_IN_SERVICEWORKER, 0, JSEXN_TYPEERR, "Notification constructor cannot be used in ServiceWorkerGlobalScope. Use registration.showNotification() instead.")
 MSG_DEF(MSG_INVALID_SCOPE, 2, JSEXN_TYPEERR, "Invalid scope trying to resolve {0} with base URL {1}.")
 MSG_DEF(MSG_INVALID_KEYFRAME_OFFSETS, 0, JSEXN_TYPEERR, "Keyframes with specified offsets must be in order and all be in the range [0, 1].")
 MSG_DEF(MSG_IS_NOT_PROMISE, 1, JSEXN_TYPEERR, "{0} is not a Promise")
 MSG_DEF(MSG_SW_INSTALL_ERROR, 2, JSEXN_TYPEERR, "ServiceWorker script at {0} for scope {1} encountered an error during installation.")
 MSG_DEF(MSG_SW_SCRIPT_THREW, 2, JSEXN_TYPEERR, "ServiceWorker script at {0} for scope {1} threw an exception during script evaluation.")
 MSG_DEF(MSG_TYPEDARRAY_IS_SHARED, 1, JSEXN_TYPEERR, "{0} can't be a typed array on SharedArrayBuffer")
+MSG_DEF(MSG_TYPEDARRAY_IS_DETACHED, 1, JSEXN_TYPEERR, "{0} can't be a detached buffer")
 MSG_DEF(MSG_CACHE_ADD_FAILED_RESPONSE, 3, JSEXN_TYPEERR, "Cache got {0} response with bad status {1} while trying to add request {2}")
 MSG_DEF(MSG_SW_UPDATE_BAD_REGISTRATION, 2, JSEXN_TYPEERR, "Failed to update the ServiceWorker for scope {0} because the registration has been {1} since the update was scheduled.")
 MSG_DEF(MSG_INVALID_DURATION_ERROR, 1, JSEXN_TYPEERR, "Invalid duration '{0}'.")
 MSG_DEF(MSG_INVALID_EASING_ERROR, 1, JSEXN_TYPEERR, "Invalid easing '{0}'.")
 MSG_DEF(MSG_INVALID_SPACING_MODE_ERROR, 1, JSEXN_TYPEERR, "Invalid spacing '{0}'.")
 MSG_DEF(MSG_USELESS_SETTIMEOUT, 1, JSEXN_TYPEERR, "Useless {0} call (missing quotes around argument?)")
 MSG_DEF(MSG_TOKENLIST_NO_SUPPORTED_TOKENS, 2, JSEXN_TYPEERR, "{0} attribute of <{1}> does not define any supported tokens")
 MSG_DEF(MSG_CACHE_STREAM_CLOSED, 0, JSEXN_TYPEERR, "Response body is a cache file stream that has already been closed.")
--- a/dom/browser-element/BrowserElementChildPreload.js
+++ b/dom/browser-element/BrowserElementChildPreload.js
@@ -575,17 +575,17 @@ BrowserElementChild.prototype = {
     debug('Got manifestchanged: (' + e.target.href + ')');
     let manifest = { href: e.target.href };
     sendAsyncMsg('manifestchange', manifest);
 
   },
 
   // Processes the "rel" field in <link> tags and forward to specific handlers.
   _linkAddedHandler: function(e) {
-    let win = e.target.ownerDocument.defaultView;
+    let win = e.target.ownerGlobal;
     // Ignore links which don't come from the top-level
     // <iframe mozbrowser> window.
     if (win != content) {
       debug('Not top level!');
       return;
     }
 
     let handlers = {
@@ -601,17 +601,17 @@ BrowserElementChild.prototype = {
       let token = x.toLowerCase();
       if (handlers[token]) {
         handlers[token](e);
       }
     }, this);
   },
 
   _metaChangedHandler: function(e) {
-    let win = e.target.ownerDocument.defaultView;
+    let win = e.target.ownerGlobal;
     // Ignore metas which don't come from the top-level
     // <iframe mozbrowser> window.
     if (win != content) {
       debug('Not top level!');
       return;
     }
 
     var name = e.target.name;
--- a/dom/browser-element/BrowserElementCopyPaste.js
+++ b/dom/browser-element/BrowserElementCopyPaste.js
@@ -103,17 +103,17 @@ var CopyPasteAssistent = {
     // Get correct geometry information if we have nested iframe.
     let currentWindow = e.target.defaultView;
     while (currentWindow.realFrameElement) {
       let currentRect = currentWindow.realFrameElement.getBoundingClientRect();
       detail.rect.top += currentRect.top;
       detail.rect.bottom += currentRect.top;
       detail.rect.left += currentRect.left;
       detail.rect.right += currentRect.left;
-      currentWindow = currentWindow.realFrameElement.ownerDocument.defaultView;
+      currentWindow = currentWindow.realFrameElement.ownerGlobal;
 
       let targetDocShell = currentWindow
           .QueryInterface(Ci.nsIInterfaceRequestor)
           .getInterface(Ci.nsIWebNavigation);
       if(targetDocShell.isMozBrowser) {
         break;
       }
     }
--- a/dom/browser-element/BrowserElementParent.js
+++ b/dom/browser-element/BrowserElementParent.js
@@ -219,21 +219,21 @@ BrowserElementParent.prototype = {
 
   /**
    * You shouldn't touch this._frameElement or this._window if _isAlive is
    * false.  (You'll likely get an exception if you do.)
    */
   _isAlive: function() {
     return !Cu.isDeadWrapper(this._frameElement) &&
            !Cu.isDeadWrapper(this._frameElement.ownerDocument) &&
-           !Cu.isDeadWrapper(this._frameElement.ownerDocument.defaultView);
+           !Cu.isDeadWrapper(this._frameElement.ownerGlobal);
   },
 
   get _window() {
-    return this._frameElement.ownerDocument.defaultView;
+    return this._frameElement.ownerGlobal;
   },
 
   get _windowUtils() {
     return this._window.QueryInterface(Ci.nsIInterfaceRequestor)
                        .getInterface(Ci.nsIDOMWindowUtils);
   },
 
   promptAuth: function(authDetail, callback) {
--- a/dom/browser-element/mochitest/browserElement_CopyPaste.js
+++ b/dom/browser-element/mochitest/browserElement_CopyPaste.js
@@ -182,24 +182,23 @@ function isChildProcess() {
                          .getService(SpecialPowers.Ci.nsIXULRuntime)
                          .processType != SpecialPowers.Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
 }
 
 function testSelectAll(e) {
   // Skip mozbrowser test if we're at child process.
   if (!isChildProcess()) {
     let eventName = "mozbrowsercaretstatechanged";
-    iframeOuter.addEventListener(eventName, function caretchangeforselectall(e) {
-      iframeOuter.removeEventListener(eventName, caretchangeforselectall, true);
+    iframeOuter.addEventListener(eventName, function(e) {
       ok(true, "got mozbrowsercaretstatechanged event." + stateMeaning);
       ok(e.detail, "event.detail is not null." + stateMeaning);
       ok(e.detail.width != 0, "event.detail.width is not zero" + stateMeaning);
       ok(e.detail.height != 0, "event.detail.height is not zero" + stateMeaning);
       SimpleTest.executeSoon(function() { testCopy1(e); });
-    }, true);
+    }, {capture: true, once: true});
   }
 
   mm.addMessageListener('content-focus', function messageforfocus(msg) {
     mm.removeMessageListener('content-focus', messageforfocus);
     // test selectall command, after calling this the caretstatechanged event should be fired.
     doCommand('selectall');
     if (isChildProcess()) {
       SimpleTest.executeSoon(function() { testCopy1(e); });
--- a/dom/browser-element/mochitest/browserElement_Find.js
+++ b/dom/browser-element/mochitest/browserElement_Find.js
@@ -11,20 +11,19 @@ browserElementTestHelpers.setEnabledPref
 function runTest() {
 
   let iframe = document.createElement('iframe');
   iframe.setAttribute('mozbrowser', 'true');
   iframe.src = 'data:text/html,foo bar foo XXX Foo BAR foobar foobar';
 
   const once = (eventName) => {
     return new Promise((resolve) => {
-      iframe.addEventListener(eventName, function onEvent(...args) {
-        iframe.removeEventListener(eventName, onEvent);
+      iframe.addEventListener(eventName, function(...args) {
         resolve(...args);
-      });
+      }, {once: true});
     });
   }
 
   // Test if all key=>value pairs in o1 are present in o2.
   const c = (o1, o2) => Object.keys(o1).every(k => o1[k] == o2[k]);
 
   let testCount = 0;
 
--- a/dom/events/test/marionette/head.js
+++ b/dom/events/test/marionette/head.js
@@ -97,22 +97,20 @@ function setEmulatorOrientationValues(aA
  * @param aEventName
  *        A string event name.
  *
  * @return A deferred promise.
  */
 function waitForWindowEvent(aEventName) {
   let deferred = Promise.defer();
 
-  window.addEventListener(aEventName, function onevent(aEvent) {
-    window.removeEventListener(aEventName, onevent);
-
+  window.addEventListener(aEventName, function(aEvent) {
     ok(true, "Window event '" + aEventName + "' got.");
     deferred.resolve(aEvent);
-  });
+  }, {once: true});
 
   return deferred.promise;
 }
 
 /**
  * Wait for pending emulator transactions and call |finish()|.
  */
 function cleanUp() {
--- a/dom/events/test/test_bug591249.xul
+++ b/dom/events/test/test_bug591249.xul
@@ -24,17 +24,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 SimpleTest.waitForExplicitFinish();
 
 function completeTest(aBox) {
   ok(window.getComputedStyle(aBox).backgroundColor == "rgb(255, 0, 0)", "The -moz-drag-over style should be removed.");
   SimpleTest.finish();
 }
 
 function fireEvent(target, event) {
-  var win = target.ownerDocument.defaultView;
+  var win = target.ownerGlobal;
   var utils =
     win.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
         getInterface(Components.interfaces.nsIDOMWindowUtils);
   utils.dispatchDOMEventViaPresShell(target, event, true);
 }
 
 function RunTest() {
   var image = document.getElementById("image");
@@ -56,17 +56,17 @@ function RunTest() {
   window.addEventListener("dragstart", trapDrag, true);
   synthesizeMouse(image, 2, 2, { type: "mousedown" });
   synthesizeMouse(image, 11, 11, { type: "mousemove" });
   synthesizeMouse(image, 20, 20, { type: "mousemove" });
   window.removeEventListener("dragstart", trapDrag, true);
   synthesizeMouse(image, 20, 20, { type: "mouseup" });
 
   var event = document.createEvent("DragEvent");
-  event.initDragEvent("dragover", true, true, iBox.ownerDocument.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, iBox, dataTransfer);
+  event.initDragEvent("dragover", true, true, iBox.ownerGlobal, 0, 0, 0, 0, 0, false, false, false, false, 0, iBox, dataTransfer);
   fireEvent(iBox, event);
   synthesizeMouse(image, 3, 3, { type: "mousedown" });
   synthesizeMouse(image, 23, 23, { type: "mousemove" });
   synthesizeMouse(iBox, insideBoxX, insideBoxY, { type: "mousemove" });
   ok(window.getComputedStyle(iBox).backgroundColor == "rgb(255, 255, 0)", "The -moz-drag-over style should be applied.");
   synthesizeMouse(iBox, insideBoxX, insideBoxY, { type: "mouseup" });
   window.setTimeout(function () { completeTest(iBox); }, 40);
 }
--- a/dom/events/test/test_legacy_event.html
+++ b/dom/events/test/test_legacy_event.html
@@ -58,17 +58,17 @@ var gLegacyEventInfo = [
 // This function triggers a very short (1ms long) transition, which will cause
 // events to fire for the transition ending.
 function triggerShortTransition(node) {
   node.style.transition = "1ms color linear" ;
   node.style.color = "purple";
   // Flush style, so that the above assignment value actually takes effect
   // in the computed style, so that a transition will get triggered when it
   // changes.
-  window.getComputedStyle(node, "").color;
+  window.getComputedStyle(node).color;
   node.style.color = "teal";
 }
 
 // This function triggers a very short (1ms long) animation, which will cause
 // events to fire for the animation beginning & ending.
 function triggerShortAnimation(node) {
   node.style.animation = "anim1 1ms linear";
 }
--- a/dom/html/test/forms/test_maxlength_attribute.html
+++ b/dom/html/test/forms/test_maxlength_attribute.html
@@ -31,95 +31,95 @@ https://bugzilla.mozilla.org/show_bug.cg
  * related to constraint validation.
  */
 
 function checkTooLongValidity(element)
 {
   element.value = "foo";
   ok(!element.validity.tooLong,
     "Element should not be too long when maxlength is not set");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   ok(element.validity.valid, "Element should be valid");
   ok(element.checkValidity(), "The element should be valid");
 
   element.maxLength = 1;
   ok(!element.validity.tooLong,
     "Element should not be too long unless the user edits it");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   ok(element.validity.valid, "Element should be valid");
   ok(element.checkValidity(), "The element should be valid");
 
   element.focus();
 
   synthesizeKey("VK_BACK_SPACE", {});
   is(element.value, "fo", "value should have changed");
   ok(element.validity.tooLong,
     "Element should be too long after a user edit that does not make it short enough");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(255, 0, 0)", ":invalid pseudo-class should apply");
   ok(!element.validity.valid, "Element should be invalid");
   ok(!element.checkValidity(), "The element should not be valid");
   is(element.validationMessage,
           "Please shorten this text to 1 characters or less (you are currently using 2 characters).",
           "The validation message text is not correct");
 
   synthesizeKey("VK_BACK_SPACE", {});
   is(element.value, "f", "value should have changed");
   ok(!element.validity.tooLong,
     "Element should not be too long after a user edit makes it short enough");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   ok(element.validity.valid, "Element should be valid");
 
   element.maxLength = 2;
   ok(!element.validity.tooLong,
     "Element should remain valid if maxlength changes but maxlength > length");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   ok(element.validity.valid, "Element should be valid");
 
   element.maxLength = 1;
   ok(!element.validity.tooLong,
     "Element should remain valid if maxlength changes but maxlength = length");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   ok(element.validity.valid, "Element should be valid");
   ok(element.checkValidity(), "The element should be valid");
 
   element.maxLength = 0;
   ok(element.validity.tooLong,
     "Element should become invalid if maxlength changes and maxlength < length");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(255, 0, 0)", ":invalid pseudo-class should apply");
   ok(!element.validity.valid, "Element should be invalid");
   ok(!element.checkValidity(), "The element should not be valid");
   is(element.validationMessage,
           "Please shorten this text to 0 characters or less (you are currently using 1 characters).",
           "The validation message text is not correct");
 
   element.maxLength = 1;
   ok(!element.validity.tooLong,
     "Element should become valid if maxlength changes and maxlength = length");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   ok(element.validity.valid, "Element should be valid");
   ok(element.checkValidity(), "The element should be valid");
 
   element.value = "test";
   ok(!element.validity.tooLong,
     "Element should stay valid after programmatic edit (even if value is too long)");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   ok(element.validity.valid, "Element should be valid");
   ok(element.checkValidity(), "The element should be valid");
 
   element.setCustomValidity("custom message");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(255, 0, 0)", ":invalid pseudo-class should apply");
   is(element.validationMessage, "custom message",
     "Custom message should be shown instead of too long one");
 }
 
 checkTooLongValidity(document.getElementById('i'));
 checkTooLongValidity(document.getElementById('t'));
 
--- a/dom/html/test/forms/test_minlength_attribute.html
+++ b/dom/html/test/forms/test_minlength_attribute.html
@@ -31,95 +31,95 @@ https://bugzilla.mozilla.org/show_bug.cg
  * related to constraint validation.
  */
 
 function checkTooShortValidity(element)
 {
   element.value = "foo";
   ok(!element.validity.tooShort,
     "Element should not be too short when minlength is not set");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   ok(element.validity.valid, "Element should be valid");
   ok(element.checkValidity(), "The element should be valid");
 
   element.minLength = 5;
   ok(!element.validity.tooShort,
     "Element should not be too short unless the user edits it");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   ok(element.validity.valid, "Element should be valid");
   ok(element.checkValidity(), "The element should be valid");
 
   element.focus();
 
   synthesizeKey("o", {});
   is(element.value, "fooo", "value should have changed");
   ok(element.validity.tooShort,
     "Element should be too short after a user edit that does not make it short enough");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(255, 0, 0)", ":invalid pseudo-class should apply");
   ok(!element.validity.valid, "Element should be invalid");
   ok(!element.checkValidity(), "The element should not be valid");
   is(element.validationMessage,
           "Please use at least 5 characters (you are currently using 4 characters).",
           "The validation message text is not correct");
 
   synthesizeKey("o", {});
   is(element.value, "foooo", "value should have changed");
   ok(!element.validity.tooShort,
     "Element should not be too short after a user edit makes it long enough");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   ok(element.validity.valid, "Element should be valid");
 
   element.minLength = 2;
   ok(!element.validity.tooShort,
     "Element should remain valid if minlength changes but minlength < length");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   ok(element.validity.valid, "Element should be valid");
 
   element.minLength = 1;
   ok(!element.validity.tooShort,
     "Element should remain valid if minlength changes but minlength = length");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   ok(element.validity.valid, "Element should be valid");
   ok(element.checkValidity(), "The element should be valid");
 
   element.minLength = 6;
   ok(element.validity.tooShort,
     "Element should become invalid if minlength changes and minlength > length");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(255, 0, 0)", ":invalid pseudo-class should apply");
   ok(!element.validity.valid, "Element should be invalid");
   ok(!element.checkValidity(), "The element should not be valid");
   is(element.validationMessage,
           "Please use at least 6 characters (you are currently using 5 characters).",
           "The validation message text is not correct");
 
   element.minLength = 5;
   ok(!element.validity.tooShort,
     "Element should become valid if minlength changes and minlength = length");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   ok(element.validity.valid, "Element should be valid");
   ok(element.checkValidity(), "The element should be valid");
 
   element.value = "test";
   ok(!element.validity.tooShort,
     "Element should stay valid after programmatic edit (even if value is too short)");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   ok(element.validity.valid, "Element should be valid");
   ok(element.checkValidity(), "The element should be valid");
 
   element.setCustomValidity("custom message");
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(255, 0, 0)", ":invalid pseudo-class should apply");
   is(element.validationMessage, "custom message",
     "Custom message should be shown instead of too short one");
 }
 
 checkTooShortValidity(document.getElementById('i'));
 checkTooShortValidity(document.getElementById('t'));
 
--- a/dom/html/test/forms/test_pattern_attribute.html
+++ b/dom/html/test/forms/test_pattern_attribute.html
@@ -82,17 +82,17 @@ function checkValidPattern(element, comp
     ok(!element.validity.patternMismatch,
        "Element should not suffer from pattern mismatch");
     ok(element.validity.valid, "Element should be valid");
     ok(element.checkValidity(), "Element should be valid");
     ok(!gInvalid, "Invalid event shouldn't have been thrown");
     is(element.validationMessage, '',
        "Validation message should be the empty string");
     if (element.type != 'radio' && element.type != 'checkbox') {
-      is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+      is(window.getComputedStyle(element).getPropertyValue('background-color'),
          isBarred ? "rgb(0, 0, 0)" : "rgb(0, 255, 0)",
          "The pseudo-class is not correctly applied");
     }
   } else {
     ok(!element.validity.patternMismatch,
        "Element should not suffer from pattern mismatch");
   }
 }
@@ -111,17 +111,17 @@ function checkInvalidPattern(element, co
        "Please match the requested format.",
        "Validation message is not valid");
   } else {
     ok(element.validity.patternMismatch,
        "Element should suffer from pattern mismatch");
   }
 
   if (element.type != 'radio' && element.type != 'checkbox') {
-    is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+    is(window.getComputedStyle(element).getPropertyValue('background-color'),
        "rgb(255, 0, 0)", ":invalid pseudo-class should apply");
   }
 }
 
 function checkSyntaxError(element)
 {
     ok(!element.validity.patternMismatch,
        "On SyntaxError, element should not suffer");
--- a/dom/html/test/forms/test_validation.html
+++ b/dom/html/test/forms/test_validation.html
@@ -85,45 +85,45 @@ function checkConstraintValidationAPIDef
   ok(!element.validity.customError, "The element should not suffer from a constraint validation");
   ok(element.validity.valid, "The element should be valid by default");
 
   ok(element.checkValidity(), "The element should be valid by default");
 }
 
 function checkDefaultPseudoClass()
 {
-  is(window.getComputedStyle(document.getElementById('f'), null)
+  is(window.getComputedStyle(document.getElementById('f'))
        .getPropertyValue('background-color'), "rgb(0, 255, 0)",
      ":valid should apply");
 
-  is(window.getComputedStyle(document.getElementById('o'), null)
+  is(window.getComputedStyle(document.getElementById('o'))
        .getPropertyValue('background-color'), "rgb(0, 255, 0)",
      ":valid should apply");
 
-  is(window.getComputedStyle(document.getElementById('obj'), null)
+  is(window.getComputedStyle(document.getElementById('obj'))
        .getPropertyValue('background-color'), "rgb(0, 0, 0)",
      "Nor :valid and :invalid should apply");
 
-  todo_is(window.getComputedStyle(document.getElementById('k'), null)
+  todo_is(window.getComputedStyle(document.getElementById('k'))
        .getPropertyValue('background-color'), "rgb(0, 0, 0)",
      "Nor :valid and :invalid should apply");
 
-  is(window.getComputedStyle(document.getElementById('s'), null)
+  is(window.getComputedStyle(document.getElementById('s'))
        .getPropertyValue('background-color'), "rgb(0, 255, 0)",
      ":valid pseudo-class should apply");
 
-  is(window.getComputedStyle(document.getElementById('i'), null)
+  is(window.getComputedStyle(document.getElementById('i'))
        .getPropertyValue('background-color'), "rgb(0, 255, 0)",
      ":valid pseudo-class should apply");
 
-  is(window.getComputedStyle(document.getElementById('t'), null)
+  is(window.getComputedStyle(document.getElementById('t'))
        .getPropertyValue('background-color'), "rgb(0, 255, 0)",
      ":valid pseudo-class should apply");
 
-  is(window.getComputedStyle(document.getElementById('b'), null)
+  is(window.getComputedStyle(document.getElementById('b'))
        .getPropertyValue('background-color'), "rgb(0, 255, 0)",
      ":valid pseudo-class should apply");
 }
 
 function checkSpecificWillValidate()
 {
   // fieldset, output, object, keygen (TODO) and select elements
   ok(!document.getElementById('f').willValidate, "Fielset element should be barred from constraint validation");
@@ -131,92 +131,92 @@ function checkSpecificWillValidate()
   todo(!document.getElementById('k').willValidate, "Keygen element should be barred from constraint validation");
   ok(document.getElementById('o').willValidate, "Output element should not be barred from constraint validation");
   ok(document.getElementById('s').willValidate, "Select element should not be barred from constraint validation");
 
   // input element
   i = document.getElementById('i');
   i.type = "hidden";
   ok(!i.willValidate, "Hidden state input should be barred from constraint validation");
-  is(window.getComputedStyle(i, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(i).getPropertyValue('background-color'),
      "rgb(0, 0, 0)", "Nor :valid and :invalid should apply");
   i.type = "reset";
   ok(!i.willValidate, "Reset button state input should be barred from constraint validation");
-  is(window.getComputedStyle(i, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(i).getPropertyValue('background-color'),
      "rgb(0, 0, 0)", "Nor :valid and :invalid should apply");
   i.type = "button";
   ok(!i.willValidate, "Button state input should be barred from constraint validation");
-  is(window.getComputedStyle(i, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(i).getPropertyValue('background-color'),
      "rgb(0, 0, 0)", "Nor :valid and :invalid should apply");
   i.type = "image";
   ok(i.willValidate, "Image state input should not be barred from constraint validation");
-  is(window.getComputedStyle(i, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(i).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid and :invalid should apply");
   i.type = "submit";
   ok(i.willValidate, "Submit state input should not be barred from constraint validation");
-  is(window.getComputedStyle(i, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(i).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid and :invalid should apply");
   i.type = "number";
   ok(i.willValidate, "Number state input should not be barred from constraint validation");
-  is(window.getComputedStyle(i, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(i).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
   i.type = "";
   i.readOnly = 'true';
   ok(!i.willValidate, "Readonly input should be barred from constraint validation");
-  is(window.getComputedStyle(i, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(i).getPropertyValue('background-color'),
      "rgb(0, 0, 0)", "Nor :valid and :invalid should apply");
   i.removeAttribute('readOnly');
   ok(i.willValidate, "Default input element should not be barred from constraint validation");
-  is(window.getComputedStyle(i, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(i).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
 
   // button element
   b = document.getElementById('b');
   b.type = "reset";
   ok(!b.willValidate, "Reset state button should be barred from constraint validation");
-  is(window.getComputedStyle(b, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(b).getPropertyValue('background-color'),
      "rgb(0, 0, 0)", "Nor :valid and :invalid should apply");
   b.type = "button";
   ok(!b.willValidate, "Button state button should be barred from constraint validation");
-  is(window.getComputedStyle(b, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(b).getPropertyValue('background-color'),
      "rgb(0, 0, 0)", "Nor :valid and :invalid should apply");
   b.type = "submit";
   ok(b.willValidate, "Submit state button should not be barred from constraint validation");
-  is(window.getComputedStyle(b, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(b).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid and :invalid should apply");
   b.type = "";
   ok(b.willValidate, "Default button element should not be barred from constraint validation");
-  is(window.getComputedStyle(b, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(b).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
 
   // textarea element
   t = document.getElementById('t');
   t.readOnly = true;
   ok(!t.willValidate, "Readonly textarea should be barred from constraint validation");
-  is(window.getComputedStyle(t, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(t).getPropertyValue('background-color'),
      "rgb(0, 0, 0)", "Nor :valid and :invalid should apply");
   t.removeAttribute('readOnly');
   ok(t.willValidate, "Default textarea element should not be barred from constraint validation");
-  is(window.getComputedStyle(t, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(t).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
 
   // TODO: PROGRESS
   // TODO: METER
 }
 
 function checkCommonWillValidate(element)
 {
   // Not checking the default value because it has been checked previously.
 
   // Not checking output elements because they can't be disabled.
   if (element.tagName != 'OUTPUT') {
     element.disabled = true;
     ok(!element.willValidate, "Disabled element should be barred from constraint validation");
 
-    is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+    is(window.getComputedStyle(element).getPropertyValue('background-color'),
        "rgb(0, 0, 0)", "Nor :valid and :invalid should apply");
 
     element.removeAttribute('disabled');
   }
 
   // TODO: If an element has a datalist element ancestor, it is barred from constraint validation.
 }
 
@@ -229,32 +229,32 @@ function checkCustomError(element, isBar
   } else {
     is(element.validationMessage, "",
        "An element barred from constraint validation can't have a validation message");
   }
   ok(element.validity.customError, "The element should suffer from a custom error");
   ok(!element.validity.valid, "The element should not be valid with a custom error");
 
   if (element.tagName == "FIELDSET") {
-    is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+    is(window.getComputedStyle(element).getPropertyValue('background-color'),
        isBarred ? "rgb(0, 255, 0)" : "rgb(255, 0, 0)",
        ":invalid pseudo-classs should apply" + element.tagName);
   }
   else {
-    is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+    is(window.getComputedStyle(element).getPropertyValue('background-color'),
        isBarred ? "rgb(0, 0, 0)" : "rgb(255, 0, 0)",
        ":invalid pseudo-classs should apply" + element.tagName);
   }
 
   element.setCustomValidity("");
   is(element.validationMessage, "", "The element should not have a validation message when reseted");
   ok(!element.validity.customError, "The element should not suffer anymore from a custom error");
   ok(element.validity.valid, "The element should now be valid");
 
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      isBarred && element.tagName != "FIELDSET" ? "rgb(0, 0, 0)" : "rgb(0, 255, 0)",
      ":valid pseudo-classs should apply");
 }
 
 function checkCheckValidity(element)
 {
   element.setCustomValidity("message");
   ok(!element.checkValidity(), "checkValidity() should return false when the element is not valid");
--- a/dom/html/test/test_bug255820.html
+++ b/dom/html/test/test_bug255820.html
@@ -50,17 +50,17 @@ function f2Continue() {
   $("f2").
     setAttribute("onload",
                  "testFinished();");
   $("f2").contentWindow.location.reload();
 }
 
 function f3Continue() {
   var doc = $("f3").contentDocument;
-  is(doc.defaultView.getComputedStyle(doc.body, "").color, "rgb(0, 180, 0)",
+  is(doc.defaultView.getComputedStyle(doc.body).color, "rgb(0, 180, 0)",
      "Wrong color before reload");
   $("f3").
     setAttribute("onload",
                  'var doc = this.contentDocument; ' + 
                  'is(doc.defaultView.getComputedStyle(doc.body, "").color, ' +
                  '   "rgb(0, 180, 0)",' +
                  '   "Wrong color after reload");' +
                  "charsetTestFinished('f1', this.contentDocument, 'UTF-8')");
--- a/dom/html/test/test_bug442801.html
+++ b/dom/html/test/test_bug442801.html
@@ -36,28 +36,28 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 442801 **/
 
-is(window.getComputedStyle($("ce_true"), null).getPropertyValue("-moz-user-modify"), 
+is(window.getComputedStyle($("ce_true")).getPropertyValue("-moz-user-modify"), 
     "read-write", 
     "parent contenteditable is true, contenteditable is true; user-modify should be read-write");
-is(window.getComputedStyle($("ce_false"), null).getPropertyValue("-moz-user-modify"), 
+is(window.getComputedStyle($("ce_false")).getPropertyValue("-moz-user-modify"), 
     "read-only",
     "parent contenteditable is true, contenteditable is false; user-modify should be read-only");
-is(window.getComputedStyle($("ce_empty"), null).getPropertyValue("-moz-user-modify"), 
+is(window.getComputedStyle($("ce_empty")).getPropertyValue("-moz-user-modify"), 
     "read-write",
     "parent contenteditable is true, contenteditable is empty; user-modify should be read-write");
-is(window.getComputedStyle($("ce_inherit"), null).getPropertyValue("-moz-user-modify"), 
+is(window.getComputedStyle($("ce_inherit")).getPropertyValue("-moz-user-modify"), 
     "read-write",
     "parent contenteditable is true, contenteditable is inherit; user-modify should be read-write");
-is(window.getComputedStyle($("ce_none"), null).getPropertyValue("-moz-user-modify"), 
+is(window.getComputedStyle($("ce_none")).getPropertyValue("-moz-user-modify"), 
     "read-write",
     "parent contenteditable is true, contenteditable is none; user-modify should be read-write");
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/html/test/test_bug558788-1.html
+++ b/dom/html/test/test_bug558788-1.html
@@ -30,28 +30,28 @@ https://bugzilla.mozilla.org/show_bug.cg
  * Only <input> and <textarea> elements can have there validity changed by an
  * user input.
  */
 
 var gContent = document.getElementById('content');
 
 function checkValidApplies(elmt)
 {
-  is(window.getComputedStyle(elmt, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(elmt).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
 }
 
 function checkInvalidApplies(elmt, aTodo)
 {
   if (aTodo) {
-    todo_is(window.getComputedStyle(elmt, null).getPropertyValue('background-color'),
+    todo_is(window.getComputedStyle(elmt).getPropertyValue('background-color'),
             "rgb(255, 0, 0)", ":invalid pseudo-class should apply");
     return;
   }
-  is(window.getComputedStyle(elmt, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(elmt).getPropertyValue('background-color'),
      "rgb(255, 0, 0)", ":invalid pseudo-class should apply");
 }
 
 function checkMissing(elementName)
 {
   var element = document.createElement(elementName);
   element.required = true;
   gContent.appendChild(element);
--- a/dom/html/test/test_bug561640.html
+++ b/dom/html/test/test_bug561640.html
@@ -24,24 +24,24 @@ https://bugzilla.mozilla.org/show_bug.cg
 /** Test for Bug 561640 **/
 
 var elements = [ 'input', 'textarea' ];
 var content = document.getElementById('content');
 
 function checkValid(elmt)
 {
   ok(!elmt.validity.tooLong, "element should not be too long");
-  is(window.getComputedStyle(elmt, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(elmt).getPropertyValue('background-color'),
      "rgb(0, 255, 0)", ":valid pseudo-class should apply");
 }
 
 function checkInvalid(elmt)
 {
   todo(elmt.validity.tooLong, "element should be too long");
-  todo_is(window.getComputedStyle(elmt, null).getPropertyValue('background-color'),
+  todo_is(window.getComputedStyle(elmt).getPropertyValue('background-color'),
           "rgb(255, 0, 0)", ":invalid pseudo-class should apply");
 }
 
 for (var elmtName of elements) {
   var elmt = document.createElement(elmtName);
   content.appendChild(elmt);
 
   if (elmtName == 'textarea') {
--- a/dom/html/test/test_bug596511.html
+++ b/dom/html/test/test_bug596511.html
@@ -32,17 +32,17 @@ function checkNotSufferingFromBeingMissi
   ok(!element.validity.valueMissing,
     "Element should not suffer from value missing");
   ok(element.validity.valid, "Element should be valid");
   ok(element.checkValidity(), "Element should be valid");
 
   is(element.validationMessage, "",
     "Validation message should be the empty string");
 
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(0, 128, 0)", ":valid pseudo-class should apply");
 
   if (aTodo) {
     ok = SimpleTest.ok;
     is = SimpleTest.is;
   }
 }
 
@@ -55,17 +55,17 @@ function checkSufferingFromBeingMissing(
 
   ok(element.validity.valueMissing, "Element should suffer from value missing");
   ok(!element.validity.valid, "Element should not be valid");
   ok(!element.checkValidity(), "Element should not be valid");
 
   is(element.validationMessage, "Please select an item in the list.",
      "Validation message is wrong");
 
-  is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
+  is(window.getComputedStyle(element).getPropertyValue('background-color'),
      "rgb(255, 0, 0)", ":invalid pseudo-class should apply");
 
   if (aTodo) {
     ok = SimpleTest.ok;
     is = SimpleTest.is;
   }
 }
 
--- a/dom/indexedDB/test/unit/test_idle_maintenance.js
+++ b/dom/indexedDB/test/unit/test_idle_maintenance.js
@@ -4,17 +4,17 @@
  */
 
 var testGenerator = testSteps();
 
 function testSteps()
 {
   let uri = Cc["@mozilla.org/network/io-service;1"].
             getService(Ci.nsIIOService).
-            newURI("https://www.example.com", null, null);
+            newURI("https://www.example.com");
   let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
               .getService(Ci.nsIScriptSecurityManager);
   let principal = ssm.createCodebasePrincipal(uri, {});
 
   info("Setting permissions");
 
   let permMgr =
     Cc["@mozilla.org/permissionmanager;1"].getService(Ci.nsIPermissionManager);
--- a/dom/media/mediasource/test/mediasource.js
+++ b/dom/media/mediasource/test/mediasource.js
@@ -57,20 +57,19 @@ function range(start, end) {
   for (var i = start; i < end; ++i) {
     rv.push(i);
   }
   return rv;
 }
 
 function once(target, name, cb) {
   var p = new Promise(function(resolve, reject) {
-    target.addEventListener(name, function onceEvent() {
-      target.removeEventListener(name, onceEvent);
+    target.addEventListener(name, function() {
       resolve();
-    });
+    }, {once: true});
   });
   if (cb) {
     p.then(cb);
   }
   return p;
 }
 
 function timeRangeToString(r) {
--- a/dom/media/test/eme.js
+++ b/dom/media/test/eme.js
@@ -483,18 +483,17 @@ function fetchWithXHR(uri, onLoadFunctio
     p.then(onLoadFunction);
   }
 
   return p;
 };
 
 function once(target, name, cb) {
   var p = new Promise(function(resolve, reject) {
-    target.addEventListener(name, function onceEvent(arg) {
-      target.removeEventListener(name, onceEvent);
+    target.addEventListener(name, function(arg) {
       resolve(arg);
-    });
+    }, {once: true});
   });
   if (cb) {
     p.then(cb);
   }
   return p;
 }
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -1500,20 +1500,19 @@ function removeNodeAndSource(n) {
   n.src = "";
   while (n.firstChild) {
     n.removeChild(n.firstChild);
   }
 }
 
 function once(target, name, cb) {
   var p = new Promise(function(resolve, reject) {
-    target.addEventListener(name, function onceEvent() {
-      target.removeEventListener(name, onceEvent);
+    target.addEventListener(name, function() {
       resolve();
-    });
+    }, {once: true});
   });
   if (cb) {
     p.then(cb);
   }
   return p;
 }
 
 function TimeStamp(token) {
--- a/dom/media/webaudio/AudioContext.cpp
+++ b/dom/media/webaudio/AudioContext.cpp
@@ -516,16 +516,22 @@ AudioContext::DecodeAudioData(const Arra
   aBuffer.ComputeLengthAndData();
 
   if (aBuffer.IsShared()) {
     // Throw if the object is mapping shared memory (must opt in).
     aRv.ThrowTypeError<MSG_TYPEDARRAY_IS_SHARED>(NS_LITERAL_STRING("Argument of AudioContext.decodeAudioData"));
     return nullptr;
   }
 
+  if (!aBuffer.Data()) {
+    // Throw if the buffer is detached
+    aRv.ThrowTypeError<MSG_TYPEDARRAY_IS_DETACHED>(NS_LITERAL_STRING("Argument of AudioContext.decodeAudioData"));
+    return nullptr;
+  }
+
   // Detach the array buffer
   size_t length = aBuffer.Length();
   JS::RootedObject obj(cx, aBuffer.Obj());
 
   uint8_t* data = static_cast<uint8_t*>(JS_StealArrayBufferContents(cx, obj));
 
   // Sniff the content of the media.
   // Failed type sniffing will be handled by AsyncDecodeWebAudio.
--- a/dom/media/webaudio/test/mochitest.ini
+++ b/dom/media/webaudio/test/mochitest.ini
@@ -105,18 +105,19 @@ skip-if = (android_version == '18' && de
 [test_convolverNode.html]
 [test_convolverNode_mono_mono.html]
 [test_convolverNodeChannelCount.html]
 [test_convolverNodeDelay.html]
 [test_convolverNodeFiniteInfluence.html]
 [test_convolverNodePassThrough.html]
 [test_convolverNodeWithGain.html]
 [test_currentTime.html]
+[test_decodeAudioDataOnDetachedBuffer.html]
+[test_decodeAudioDataPromise.html]
 [test_decodeMultichannel.html]
-[test_decodeAudioDataPromise.html]
 [test_delayNode.html]
 [test_delayNodeAtMax.html]
 [test_delayNodeChannelChanges.html]
 skip-if = toolkit == 'android' # bug 1056706
 [test_delayNodeCycles.html]
 [test_delayNodePassThrough.html]
 [test_delayNodeSmallMaxDelay.html]
 [test_delayNodeTailIncrease.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/test_decodeAudioDataOnDetachedBuffer.html
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML>
+<html>
+  <meta charset=utf-8>
+<head>
+  <title>Bug 1308434 - Test DecodeAudioData on detached buffer</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<script type="text/javascript">
+var testDecodeAudioDataOnDetachedBuffer = function(buffer) {
+  var context = new AudioContext();
+
+  // make the buffer detached
+  context.decodeAudioData(buffer);
+
+  // check that the buffer is detached
+  is(buffer.byteLength, 0, "Buffer should be detached");
+
+  // call decodeAudioData on detached buffer
+  context.decodeAudioData(buffer).then(function(b) {
+    ok(false, "We should not be able to decode the detached buffer but we do");
+    SimpleTest.finish();
+  }, function(r) {
+    SimpleTest.isa(r, TypeError);
+    is(r.message, "Argument of AudioContext.decodeAudioData can't be a detached buffer", "Incorrect message");
+    SimpleTest.finish();
+  });
+};
+
+var filename = "small-shot.mp3";
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+  var xhr = new XMLHttpRequest();
+  xhr.open("GET", filename);
+  xhr.responseType = "arraybuffer";
+
+  xhr.onload = function() {
+    testDecodeAudioDataOnDetachedBuffer(xhr.response);
+  };
+
+  xhr.send();
+});
+</script>
+</pre>
+</body>
+</html>
\ No newline at end of file
--- a/dom/plugins/test/mochitest/browser_pluginscroll.js
+++ b/dom/plugins/test/mochitest/browser_pluginscroll.js
@@ -1,16 +1,16 @@
 var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
 
 /**
  * tests for plugin windows and scroll
  */
 
 function coordinatesRelativeToWindow(aX, aY, aElement) {
-  var targetWindow = aElement.ownerDocument.defaultView;
+  var targetWindow = aElement.ownerGlobal;
   var scale = targetWindow.devicePixelRatio;
   var rect = aElement.getBoundingClientRect();
   return {
     x: targetWindow.mozInnerScreenX + ((rect.left + aX) * scale),
     y: targetWindow.mozInnerScreenY + ((rect.top + aY) * scale)
   };
 }
 
--- a/dom/security/test/csp/test_hash_source.html
+++ b/dom/security/test/csp/test_hash_source.html
@@ -66,17 +66,17 @@ function checkInline () {
   }
 
   // Inline style tries to change an element's color to green. If blocked, the
   // element's color will be the default black.
   var green = "rgb(0, 128, 0)";
   var black = "rgb(0, 0, 0)";
 
   var getElementColorById = function (id) {
-    return window.getComputedStyle(cspframe.getElementById(id), null).color;
+    return window.getComputedStyle(cspframe.getElementById(id)).color;
   };
 
   var inlineStyleTests = {
     'inline-style-valid-hash': {
       shouldBe: green,
       message: 'Inline style with valid hash should be allowed'
     },
     'inline-style-invalid-hash': {
--- a/dom/security/test/csp/test_inlinestyle.html
+++ b/dom/security/test/csp/test_inlinestyle.html
@@ -24,70 +24,70 @@ var done = 0;
 // styles applied by <style> element, style attribute, and SMIL <animate> and <set> tags
 // (when it's not explicitly allowed.)
 function checkStyles(evt) {
   var cspframe = document.getElementById('cspframe1');
   var color;
 
   // black means the style wasn't applied.  green colors are used for styles
   //expected to be applied.  A color is red if a style is erroneously applied
-  color = window.getComputedStyle(cspframe.contentDocument.getElementById('linkstylediv'),null)['color'];
+  color = window.getComputedStyle(cspframe.contentDocument.getElementById('linkstylediv'))['color'];
   ok('rgb(0, 255, 0)' === color, 'External Stylesheet (' + color + ')');
-  color = window.getComputedStyle(cspframe.contentDocument.getElementById('inlinestylediv'),null)['color'];
+  color = window.getComputedStyle(cspframe.contentDocument.getElementById('inlinestylediv'))['color'];
   ok('rgb(0, 0, 0)' === color, 'Inline Style TAG (' + color + ')');
-  color = window.getComputedStyle(cspframe.contentDocument.getElementById('attrstylediv'),null)['color'];
+  color = window.getComputedStyle(cspframe.contentDocument.getElementById('attrstylediv'))['color'];
   ok('rgb(0, 0, 0)' === color, 'Style Attribute (' + color + ')');
-  color = window.getComputedStyle(cspframe.contentDocument.getElementById('csstextstylediv'),null)['color'];
+  color = window.getComputedStyle(cspframe.contentDocument.getElementById('csstextstylediv'))['color'];
   ok('rgb(0, 255, 0)' === color, 'cssText (' + color + ')');
   // SMIL tests
   color = window.getComputedStyle(cspframe.contentDocument.getElementById('xmlTest',null))['fill'];
   ok('rgb(0, 0, 0)' === color, 'XML Attribute styling (SMIL) (' + color + ')');
   color = window.getComputedStyle(cspframe.contentDocument.getElementById('cssOverrideTest',null))['fill'];
   ok('rgb(0, 0, 0)' === color, 'CSS Override styling (SMIL) (' + color + ')');
   color = window.getComputedStyle(cspframe.contentDocument.getElementById('cssOverrideTestById',null))['fill'];
   ok('rgb(0, 0, 0)' === color, 'CSS Override styling via ID lookup (SMIL) (' + color + ')');
   color = window.getComputedStyle(cspframe.contentDocument.getElementById('cssSetTestById',null))['fill'];
   ok('rgb(0, 0, 0)' === color, 'CSS Set Element styling via ID lookup (SMIL) (' + color + ')');
 
-  color = window.getComputedStyle(cspframe.contentDocument.getElementById('modifycsstextdiv'),null)['color'];
+  color = window.getComputedStyle(cspframe.contentDocument.getElementById('modifycsstextdiv'))['color'];
   ok('rgb(0, 255, 0)' === color, 'Modify loaded style sheet via cssText (' + color + ')');
 
   checkIfDone();
 }
 
 // When a CSP 1.0 compliant policy is specified we should allow inline
 // styles when it is explicitly allowed.
 function checkStylesAllowed(evt) {
   var cspframe = document.getElementById('cspframe2');
   var color;
 
   // black means the style wasn't applied.  green colors are used for styles
   // expected to be applied.  A color is red if a style is erroneously applied
-  color = window.getComputedStyle(cspframe.contentDocument.getElementById('linkstylediv'),null)['color'];
+  color = window.getComputedStyle(cspframe.contentDocument.getElementById('linkstylediv'))['color'];
   ok('rgb(0, 255, 0)' === color, 'External Stylesheet (' + color + ')');
-  color = window.getComputedStyle(cspframe.contentDocument.getElementById('inlinestylediv'),null)['color'];
+  color = window.getComputedStyle(cspframe.contentDocument.getElementById('inlinestylediv'))['color'];
   ok('rgb(0, 255, 0)' === color, 'Inline Style TAG (' + color + ')');
-  color = window.getComputedStyle(cspframe.contentDocument.getElementById('attrstylediv'),null)['color'];
+  color = window.getComputedStyle(cspframe.contentDocument.getElementById('attrstylediv'))['color'];
   ok('rgb(0, 255, 0)' === color, 'Style Attribute (' + color + ')');
 
   // Note that the below test will fail if "script-src: 'unsafe-inline'" breaks,
   // since it relies on executing script to set .cssText
-  color = window.getComputedStyle(cspframe.contentDocument.getElementById('csstextstylediv'),null)['color'];
+  color = window.getComputedStyle(cspframe.contentDocument.getElementById('csstextstylediv'))['color'];
   ok('rgb(0, 255, 0)' === color, 'style.cssText (' + color + ')');
   // SMIL tests
   color = window.getComputedStyle(cspframe.contentDocument.getElementById('xmlTest',null))['fill'];
   ok('rgb(0, 255, 0)' === color, 'XML Attribute styling (SMIL) (' + color + ')');
   color = window.getComputedStyle(cspframe.contentDocument.getElementById('cssOverrideTest',null))['fill'];
   ok('rgb(0, 255, 0)' === color, 'CSS Override styling (SMIL) (' + color + ')');
   color = window.getComputedStyle(cspframe.contentDocument.getElementById('cssOverrideTestById',null))['fill'];
   ok('rgb(0, 255, 0)' === color, 'CSS Override styling via ID lookup (SMIL) (' + color + ')');
   color = window.getComputedStyle(cspframe.contentDocument.getElementById('cssSetTestById',null))['fill'];
   ok('rgb(0, 255, 0)' === color, 'CSS Set Element styling via ID lookup (SMIL) (' + color + ')');
 
-  color = window.getComputedStyle(cspframe.contentDocument.getElementById('modifycsstextdiv'),null)['color'];
+  color = window.getComputedStyle(cspframe.contentDocument.getElementById('modifycsstextdiv'))['color'];
   ok('rgb(0, 255, 0)' === color, 'Modify loaded style sheet via cssText (' + color + ')');
 
   checkIfDone();
 }
 
 function checkIfDone() {
   done++;
   if (done == 2)
--- a/dom/security/test/csp/test_nonce_source.html
+++ b/dom/security/test/csp/test_nonce_source.html
@@ -71,17 +71,17 @@ function ranTests(num) {
     return;
   }
   cleanup();
 }
 
 function checkInlineScriptsAndStyles () {
   var cspframe = document.getElementById('cspframe');
   var getElementColorById = function (id) {
-    return window.getComputedStyle(cspframe.contentDocument.getElementById(id), null).color;
+    return window.getComputedStyle(cspframe.contentDocument.getElementById(id)).color;
   };
   // Inline style tries to change an element's color to green. If blocked, the
   // element's color will be the (unchanged) default black.
   var green = "rgb(0, 128, 0)";
   var red = "rgb(255,0,0)";
   var black = "rgb(0, 0, 0)";
 
   // inline script tests
--- a/dom/security/test/hsts/head.js
+++ b/dom/security/test/hsts/head.js
@@ -302,17 +302,17 @@ var Observer = {
 
 // opens `uri' in a new tab and focuses it.
 // returns the newly opened tab
 function openTab(uri) {
   let tab = gBrowser.addTab(uri);
 
   // select tab and make sure its browser is focused
   gBrowser.selectedTab = tab;
-  tab.ownerDocument.defaultView.focus();
+  tab.ownerGlobal.focus();
 
   return tab;
 }
 
 function clear_sts_data() {
   for (let test in test_servers) {
     SpecialPowers.cleanUpSTSData('http://'+test_servers[test].host);
   }
--- a/dom/security/test/mixedcontentblocker/file_main_bug803225.html
+++ b/dom/security/test/mixedcontentblocker/file_main_bug803225.html
@@ -134,17 +134,17 @@ https://bugzilla.mozilla.org/show_bug.cg
           }
         }
       };
       os.addObserver(observer, "content-document-global-created", false);
     }
 
     Services.ppmm.loadProcessScript(pScript, true);
 
-    var uri = ioService.newURI("mailto:foo@bar.com", null, null);
+    var uri = ioService.newURI("mailto:foo@bar.com");
     webHandler.launchWithURI(uri);
   });
 
   var mailto = false;
 
   mm.addMessageListener("Test:content-ready-forward", function contentReadyListener() {
     mm.removeMessageListener("Test:content-ready-forward", contentReadyListener);
     mailto = true;
--- a/dom/security/test/sri/iframe_style_crossdomain.html
+++ b/dom/security/test/sri/iframe_style_crossdomain.html
@@ -5,19 +5,19 @@
 <head>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
     function check_styles() {
       var redText = document.getElementById('red-text');
       var greenText = document.getElementById('green-text');
       var blueText = document.getElementById('blue-text');
-      var redTextColor = window.getComputedStyle(redText, null).getPropertyValue('color');
-      var greenTextColor = window.getComputedStyle(greenText, null).getPropertyValue('color');
-      var blueTextColor = window.getComputedStyle(blueText, null).getPropertyValue('color');
+      var redTextColor = window.getComputedStyle(redText).getPropertyValue('color');
+      var greenTextColor = window.getComputedStyle(greenText).getPropertyValue('color');
+      var blueTextColor = window.getComputedStyle(blueText).getPropertyValue('color');
       ok(redTextColor == 'rgb(255, 0, 0)', "The first part should be red.");
       ok(greenTextColor == 'rgb(0, 255, 0)', "The second part should be green.");
       ok(blueTextColor == 'rgb(0, 0, 255)', "The third part should be blue.");
     }
 
     SimpleTest.waitForExplicitFinish();
     window.onload = function() {
       check_styles();
--- a/dom/security/test/sri/iframe_style_sameorigin.html
+++ b/dom/security/test/sri/iframe_style_sameorigin.html
@@ -6,20 +6,20 @@
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
     function check_styles() {
       var redText = document.getElementById('red-text');
       var blueText = document.getElementById('blue-text-element');
       var blackText1 = document.getElementById('black-text');
       var blackText2 = document.getElementById('black-text-2');
-      var redTextColor = window.getComputedStyle(redText, null).getPropertyValue('color');
-      var blueTextColor = window.getComputedStyle(blueText, null).getPropertyValue('color');
-      var blackTextColor1 = window.getComputedStyle(blackText1, null).getPropertyValue('color');
-      var blackTextColor2 = window.getComputedStyle(blackText2, null).getPropertyValue('color');
+      var redTextColor = window.getComputedStyle(redText).getPropertyValue('color');
+      var blueTextColor = window.getComputedStyle(blueText).getPropertyValue('color');
+      var blackTextColor1 = window.getComputedStyle(blackText1).getPropertyValue('color');
+      var blackTextColor2 = window.getComputedStyle(blackText2).getPropertyValue('color');
       ok(redTextColor == 'rgb(255, 0, 0)', "The first part should be red.");
       ok(blueTextColor == 'rgb(0, 0, 255)', "The second part should be blue.");
       ok(blackTextColor1 == 'rgb(0, 0, 0)', "The second last part should still be black.");
       ok(blackTextColor2 == 'rgb(0, 0, 0)', "The last part should still be black.");
     }
 
     SimpleTest.waitForExplicitFinish();
     window.onload = function() {
--- a/dom/security/test/sri/test_csp_directive_style_imports.html
+++ b/dom/security/test/sri/test_csp_directive_style_imports.html
@@ -19,17 +19,17 @@
   SimpleTest.waitForExplicitFinish();
   function handler(event) {
     console.log(event);
     switch (event.data) {
       case 'finish':
         // need finish message from iframe_require-sri-for_main onload event and
         // from iframe_require-sri-for_no_csp, which spawns a Worker
         var importText = frame.contentDocument.getElementById('text-for-import-test');
-        var importColor = frame.contentWindow.getComputedStyle(importText, null).getPropertyValue('color');
+        var importColor = frame.contentWindow.getComputedStyle(importText).getPropertyValue('color');
         ok(importColor == 'rgb(0, 0, 255)', "The import should not work without integrity. The text is now red, but should not.");
         removeEventListener('message', handler);
         SimpleTest.finish();
         break;
       default:
         ok(false, 'Something is wrong here');
         break;
     }
--- a/dom/security/test/sri/test_require-sri-for_csp_directive.html
+++ b/dom/security/test/sri/test_require-sri-for_csp_directive.html
@@ -48,17 +48,17 @@
         ok(true, 'Worker continued after failed importScript due to require-sri-for');
         break;
       case 'finish':
         finished++;
         if (finished > 1) {
           // need finish message from iframe_require-sri-for_main onload event and
           // from iframe_require-sri-for_no_csp, which spawns a Worker
           var blackText = frame.contentDocument.getElementById('black-text');
-          var blackTextColor = frame.contentWindow.getComputedStyle(blackText, null).getPropertyValue('color');
+          var blackTextColor = frame.contentWindow.getComputedStyle(blackText).getPropertyValue('color');
           ok(blackTextColor == 'rgb(0, 0, 0)', "The second part should not be black.");
           removeEventListener('message', handler);
           SimpleTest.finish();
         }
         break;
       default:
         ok(false, 'Something is wrong here');
         break;
--- a/dom/security/test/sri/test_require-sri-for_csp_directive_disabled.html
+++ b/dom/security/test/sri/test_require-sri-for_csp_directive_disabled.html
@@ -24,17 +24,17 @@
       case 'bad_nonsriLoaded':
         ok(true, "Eligible non-SRI resource should be blocked by the CSP!");
         break;
       case 'good_nonsriBlocked':
         ok(false, "Eligible non-SRI resources was correctly blocked by the CSP.");
         break;
       case 'finish':
         var blackText = frame.contentDocument.getElementById('black-text');
-        var blackTextColor = frame.contentWindow.getComputedStyle(blackText, null).getPropertyValue('color');
+        var blackTextColor = frame.contentWindow.getComputedStyle(blackText).getPropertyValue('color');
         ok(blackTextColor != 'rgb(0, 0, 0)', "The second part should still be black.");
         removeEventListener('message', handler);
         SimpleTest.finish();
         break;
       default:
         ok(false, 'Something is wrong here');
         break;
     }
--- a/dom/smil/test/smilTestUtils.js
+++ b/dom/smil/test/smilTestUtils.js
@@ -30,17 +30,17 @@ var SMILUtil =
   {
     var elemList = document.getElementsByTagName(aTargetTag);
     return (elemList.length == 0 ? null : elemList[0]);
   },
 
   // Simple wrapper for getComputedStyle
   getComputedStyleSimple: function(elem, prop)
   {
-    return window.getComputedStyle(elem, null).getPropertyValue(prop);
+    return window.getComputedStyle(elem).getPropertyValue(prop);
   },
 
   getAttributeValue: function(elem, attr)
   {
     if (attr.attrName == SMILUtil.getMotionFakeAttributeName()) {
       // Fake motion "attribute" -- "computed value" is the element's CTM
       return elem.getCTM();
     }
--- a/dom/smil/test/test_smilKeyTimes.xhtml
+++ b/dom/smil/test/test_smilKeyTimes.xhtml
@@ -373,17 +373,17 @@ function checkSample(anim, expectedValue
 function checkLineCapSample(anim, expectedValue, sampleTime, caseDescr)
 {
   var msg = "Test case " + caseDescr +
     " (keyTimes: '" + anim.getAttribute('keyTimes') + "'" +
     " calcMode: " + anim.getAttribute('calcMode') + "), " +
     "t=" + sampleTime +
     ": Unexpected sample value:";
   var actualValue =
-    window.getComputedStyle(anim.targetElement, null).
+    window.getComputedStyle(anim.targetElement).
     getPropertyValue('stroke-linecap');
   is(actualValue, expectedValue, msg);
 }
 
 window.addEventListener("load", main);
 ]]>
 </script>
 </pre>
--- a/dom/svg/test/test_object-delayed-intrinsic-size.html
+++ b/dom/svg/test/test_object-delayed-intrinsic-size.html
@@ -15,17 +15,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 // This test checks for a race condition. If it fails intermittently then it
 // may actually be a full failure.
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest()
 {
   var object = document.querySelector("object");
-  var cs = document.defaultView.getComputedStyle(object, "");
+  var cs = document.defaultView.getComputedStyle(object);
   var width = cs.getPropertyValue("width");
   is(width, "70px", "Check that the &lt;object&gt; size updated");
   SimpleTest.finish();
 }
 
     </script>
   </head>
   <body onload="runTest();">
--- a/dom/svg/test/test_scientific.html
+++ b/dom/svg/test/test_scientific.html
@@ -23,61 +23,61 @@ https://bugzilla.mozilla.org/show_bug.cg
 	{
 	var doc = $("svg").contentWindow.document;
 	var rect = doc.getElementById("rect");
 	var text = doc.getElementById("text");
 
 	// ordinary
 
 	rect.setAttribute("stroke-width", "5");
-	is(doc.defaultView.getComputedStyle(rect, '').getPropertyValue("stroke-width"), "5", "Ordinary");
+	is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "5", "Ordinary");
 
 	// valid exponential notation
 
 	rect.setAttribute("stroke-width", "4E1");
-	is(doc.defaultView.getComputedStyle(rect, '').getPropertyValue("stroke-width"), "40", "Exponent");
+	is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "40", "Exponent");
 
 	rect.setAttribute("stroke-width", "6e1");
-	is(doc.defaultView.getComputedStyle(rect, '').getPropertyValue("stroke-width"), "60", "Lower-case Exponent");
+	is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "60", "Lower-case Exponent");
 
 	rect.setAttribute("stroke-width", "2E+1");
-	is(doc.defaultView.getComputedStyle(rect, '').getPropertyValue("stroke-width"), "20", "Positive Exponent");
+	is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "20", "Positive Exponent");
 
 	rect.setAttribute("stroke-width", "100E-1");
-	is(doc.defaultView.getComputedStyle(rect, '').getPropertyValue("stroke-width"), "10", "Negative Exponent");
+	is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "10", "Negative Exponent");
 
 	rect.setAttribute("stroke-width", "0.7E1");
-	is(doc.defaultView.getComputedStyle(rect, '').getPropertyValue("stroke-width"), "7", "Floating Point with Exponent");
+	is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "7", "Floating Point with Exponent");
 
 	rect.setAttribute("stroke-width", "50.0E-1");
-	is(doc.defaultView.getComputedStyle(rect, '').getPropertyValue("stroke-width"), "5", "Floating Point with Negative Exponent");
+	is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "5", "Floating Point with Negative Exponent");
 
 	rect.setAttribute("stroke-width", "0.8E+1");
-	is(doc.defaultView.getComputedStyle(rect, '').getPropertyValue("stroke-width"), "8", "Floating Point with Positive Exponent");
+	is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "8", "Floating Point with Positive Exponent");
 
 	rect.setAttribute("stroke-width", "4E1px");
-	is(doc.defaultView.getComputedStyle(rect, '').getPropertyValue("stroke-width"), "40px", "Units");
+	is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "40px", "Units");
 
 	// check units that begin with the letter e
 
-	var font_size = doc.defaultView.getComputedStyle(rect, '').getPropertyValue("font-size");
+	var font_size = doc.defaultView.getComputedStyle(rect).getPropertyValue("font-size");
 
 	rect.setAttribute("stroke-width", "1em");
-	is(doc.defaultView.getComputedStyle(rect, '').getPropertyValue("stroke-width"), font_size, "em Units");
+	is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), font_size, "em Units");
 
 	// invalid exponential notation
 
 	rect.setAttribute("stroke-width", "1E1.1");
-	is(doc.defaultView.getComputedStyle(rect, '').getPropertyValue("stroke-width"), "1px", "Floating Point Exponent");
+	is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "1px", "Floating Point Exponent");
 
 	rect.setAttribute("stroke-width", "E1");
-	is(doc.defaultView.getComputedStyle(rect, '').getPropertyValue("stroke-width"), "1px", "No Mantissa");
+	is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "1px", "No Mantissa");
 
 	rect.setAttribute("stroke-width", "1 e");
-	is(doc.defaultView.getComputedStyle(rect, '').getPropertyValue("stroke-width"), "1px", "Spaces");
+	is(doc.defaultView.getComputedStyle(rect).getPropertyValue("stroke-width"), "1px", "Spaces");
 
 	SimpleTest.finish();
 	}
 
 	window.addEventListener("load", runTests);
 </script>
 </pre>
 </body>
--- a/dom/tests/browser/browser_prerendering.js
+++ b/dom/tests/browser/browser_prerendering.js
@@ -1,17 +1,17 @@
 const URL = "https://example.com/browser/dom/tests/browser/prerender.html";
 const PRERENDERED_URL = "https://example.com/browser/dom/tests/browser/prerender_target.html";
 
 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
                                   "resource://gre/modules/PlacesUtils.jsm");
 
 // Returns a promise which resolves to whether or not PRERENDERED_URL has been visited.
 function prerenderedVisited() {
-  let uri = Services.io.newURI(PRERENDERED_URL, null, null);
+  let uri = Services.io.newURI(PRERENDERED_URL);
   return new Promise(resolve => {
     PlacesUtils.asyncHistory.isURIVisited(uri, (aUri, aIsVisited) => {
       resolve(aIsVisited);
     });
   });
 }
 
 // Wait for a process change and then fulfil the promise.
--- a/dom/tests/mochitest/chrome/window_focus.xul
+++ b/dom/tests/mochitest/chrome/window_focus.xul
@@ -88,17 +88,17 @@ function eventOccured(event)
     gEvents += " ";
   gEvents += event.type + ": " + id;
 }
 
 function expectFocusShift(callback, expectedWindow, expectedElement, focusChanged, testid)
 {
   if (expectedWindow == null)
     expectedWindow = expectedElement ?
-                     expectedElement.ownerDocument.defaultView :
+                     expectedElement.ownerGlobal :
                      gLastFocusWindow;
 
   var expectedEvents = "";
   if (focusChanged) {
     var id;
     if (getTopWindow(gLastFocusWindow) != getTopWindow(expectedWindow)) {
       id = getTopWindow(gLastFocusWindow).document.documentElement.id;
       expectedEvents += "deactivate: " + id + "-window";
@@ -303,30 +303,30 @@ function mouseWillTriggerFocus(element)
     return true;
   }
 
   return false;
 }
 
 function mouseOnElement(element, expectedElement, focusChanged, testid)
 {
-  var expectedWindow = (element.ownerDocument.defaultView == gChildWindow) ? gChildWindow : window;
+  var expectedWindow = (element.ownerGlobal == gChildWindow) ? gChildWindow : window;
   // on Mac, form elements are not focused when clicking, except for lists and textboxes.
   var noFocusOnMouse = !mouseWillTriggerFocus(element)
 
   if (noFocusOnMouse) {
     // no focus so the last focus method will be 0
     gLastFocusMethod = 0;
-    expectFocusShift(() => synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView),
+    expectFocusShift(() => synthesizeMouse(element, 4, 4, { }, element.ownerGlobal),
                      expectedWindow, null, true, testid);
     gLastFocusMethod = fm.FLAG_BYMOUSE;
   }
   else {
-    expectFocusShift(() => synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView),
-                     element.ownerDocument.defaultView,
+    expectFocusShift(() => synthesizeMouse(element, 4, 4, { }, element.ownerGlobal),
+                     element.ownerGlobal,
                      expectedElement, focusChanged, testid);
   }
 }
 
 function done()
 {
   var opener = window.opener;
   window.close();
@@ -451,17 +451,17 @@ function startTest()
       continue;
 
     var element = getById("t" + idx);
     // skip area elements, as getBoundingClientRect doesn't return their actual coordinates
     if (element.localName == "area")
       continue;
 
     mouseOnElement(element, getById("t" + idx), true, "mouse on element t" + idx);
-    var expectedWindow = (element.ownerDocument.defaultView == gChildWindow) ? gChildWindow : window;
+    var expectedWindow = (element.ownerGlobal == gChildWindow) ? gChildWindow : window;
     if (element.localName == "listbox" && expectedWindow == window &&
         navigator.platform.indexOf("Mac") == 0) {
       // after focusing a listbox on Mac, clear the focus before continuing.
       setFocusTo(null, window);
     }
   }
 
   ok(t19.selectionStart == t19.selectionEnd, "input focused from mouse selection");
@@ -482,17 +482,17 @@ function startTest()
     gLastFocusMethod = idx % 2 ? 0 : fm.FLAG_BYMOUSE;
 
     mouseOnElement(element, idx % 2 ? null: element, true, "mouse on unfocusable element n" + idx);
   }
 
   if (idx == kOverflowElementIndex) {
     gLastFocusMethod = fm.FLAG_BYMOUSE;
     var element = getById("t" + idx);
-    expectFocusShift(() => synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView),
+    expectFocusShift(() => synthesizeMouse(element, 4, 4, { }, element.ownerGlobal),
                      window, null, true, "mouse on scrollable element");
   }
 
   // focus() method
   gLastFocusMethod = 0;
   for (idx = kTabbableSteps; idx >= 1; idx--) {
     if ((navigator.platform.indexOf("Mac") == 0) && (idx == kBeforeTabboxIndex + 1))
       continue;
@@ -507,26 +507,26 @@ function startTest()
   $("t7").blur();
   ok(gEvents === "", "blurring element that is not focused");
   is(document.activeElement, $("t1"), "old element still focused after blur() on another element");
 
   // focus() method on elements that are not tabbable 
   for (idx = 1; idx <= kFocusSteps; idx++) {
     var expected = getById("o" + (idx % 2 ? idx : idx - 1));
     expectFocusShift(() => getById("o" + idx).focus(),
-                     expected.ownerDocument.defaultView,
+                     expected.ownerGlobal,
                      expected, idx % 2, "focus method on non-tabbable element o" + idx);
   }
 
   // focus() method on elements that are not tabbable and have user-focus: none
   // or are not focusable for other reasons (for instance, being disabled)
   for (idx = 1; idx <= kNoFocusSteps; idx++) {
     var expected = getById("o" + (idx % 2 ? idx : idx - 1));
     expectFocusShift(() => getById("o" + idx).focus(),
-                     expected.ownerDocument.defaultView,
+                     expected.ownerGlobal,
                      expected, idx % 2, "focus method on unfocusable element n" + idx);
   }
 
   // the focus() method on the legend element should focus the legend if it is
   // focusable, or the first element after the legend if it is not focusable.
   if (!gPartialTabbing) {
     gLastFocusMethod = fm.FLAG_BYMOVEFOCUS;
     var legend = getById("legend");
@@ -548,17 +548,17 @@ function startTest()
   for (var k = 0; k < keys.length; k++) {
     var key = String.fromCharCode(65 + k);
 
     // accesskeys D and G are for labels so get redirected
     gLastFocusMethod = (key == "D" || key == "G") ? fm.FLAG_BYMOVEFOCUS : fm.FLAG_BYKEY;
 
     // on Windows and Linux, the shift key must be pressed for content area access keys
     // and on Mac, the alt key must be pressed for content area access keys
-    var isContent = (getById(keys[k]).ownerDocument.defaultView == gChildWindow);
+    var isContent = (getById(keys[k]).ownerGlobal == gChildWindow);
     if (navigator.platform.indexOf("Mac") == -1) {
       accessKeyDetails.shiftKey = isContent;
     } else {
       accessKeyDetails.altKey = isContent;
     }
 
     expectFocusShift(() => synthesizeKey(key, accessKeyDetails),
                      null, getById(keys[k]), true, "accesskey " + key);
@@ -624,17 +624,17 @@ function startTest()
     gEvents = "";
     element.addEventListener("blur", eventListener, false);
     blurFunction();
     element.removeEventListener("blur", eventListener, false);
   }
 
   var functions = [
     element => element.focus(),
-    element => synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView)
+    element => synthesizeMouse(element, 4, 4, { }, element.ownerGlobal)
   ];
 
   // first, check cases where the focus is adjusted during the blur event. Iterate twice,
   // once with the focus method and then focusing by mouse clicking
   for  (var l = 0; l < 2; l++) {
     var adjustFocus = functions[l];
     var mod = (l == 1) ? " with mouse" : "";
 
@@ -1112,17 +1112,17 @@ function otherWindowFocused(otherWindow)
     if ((navigator.platform.indexOf("Mac") == 0) && (idx == kBeforeTabboxIndex + 1))
       continue;
 
     expectedElement.focus();
 
     is(fm.focusedElement.id, "other", "when lowered focusedElement t" + idx);
     is(fm.focusedWindow, otherWindow, "when lowered focusedWindow t" + idx);
 
-    var checkWindow = expectedElement.ownerDocument.defaultView;
+    var checkWindow = expectedElement.ownerGlobal;
     is(fm.getFocusedElementForWindow(checkWindow, false, {}).id, expectedElement.id,
        "when lowered getFocusedElementForWindow t" + idx);
     is(checkWindow.document.activeElement.id, expectedElement.id, "when lowered activeElement t" + idx);
     if (checkWindow != window) {
       is(fm.getFocusedElementForWindow(window, false, {}), $("childframe"),
          "when lowered parent getFocusedElementForWindow t" + idx);
       is(document.activeElement.id, "childframe",
          "when lowered parent activeElement t" + idx);
--- a/dom/tests/mochitest/general/test_focusrings.xul
+++ b/dom/tests/mochitest/general/test_focusrings.xul
@@ -135,26 +135,26 @@ function testHTMLElements(list, isMac, e
 
     var shouldFocus = !isMac || (elem.className == "canfocus");
     var ringSize = (shouldFocus ? (expectedNoRingsOnWin ? 2 : 1) : 0) + "px";
     if (elem.localName == "a")
       ringSize = "0px";
 
     synthesizeMouse(elem, 8, 8, { }, childwin);
     is(childdoc.activeElement, shouldFocus ? elem : childdoc.body, "mouse click on " + list[e]);
-    is(childwin.getComputedStyle(elem, "").outlineWidth, ringSize, "mouse click on " + list[e] + " ring");
+    is(childwin.getComputedStyle(elem).outlineWidth, ringSize, "mouse click on " + list[e] + " ring");
 
     if (childdoc.activeElement)
       childdoc.activeElement.blur();
 
     ringSize = (elem.localName == "a" ? "0" : (expectedNoRingsOnWin ? 2 : 1)) + "px";
 
     elem.focus();
     is(childdoc.activeElement, elem, "focus() on " + list[e]);
-    is(childwin.getComputedStyle(elem, "").outlineWidth, ringSize,
+    is(childwin.getComputedStyle(elem).outlineWidth, ringSize,
        "focus() on " + list[e] + " ring");
 
     childdoc.activeElement.blur();
   }
 }
 
 SimpleTest.waitForFocus(runTest);
 
--- a/dom/tests/mochitest/webcomponents/test_link_prefetch.html
+++ b/dom/tests/mochitest/webcomponents/test_link_prefetch.html
@@ -54,27 +54,27 @@ https://bugzilla.mozilla.org/show_bug.cg
   linkElem.href = "https://example.com/2";
   is(prefetch.hasMoreElements(), true,
      "Changing href, a new prefetch has been started.");
   // To check if "https://example.com/1" prefetch has been canceled, we try to
   // cancel it using PrefetService. Since the prefetch for
   // "https://example.com/1" does not exist, the cancel will throw.
   var cancelError = 0;
   try {
-    var uri = ios.newURI("https://example.com/1", null, null);
+    var uri = ios.newURI("https://example.com/1");
     prefetch.cancelPrefetchURI(uri, linkElem);
   } catch(e) {
     cancelError = 1;
   }
   is(cancelError, 1, "This prefetch has aleady been canceled");
 
   // Now cancel the right uri.
   cancelError = 0;
   try {
-    var uri = ios.newURI("https://example.com/2", null, null);
+    var uri = ios.newURI("https://example.com/2");
     prefetch.cancelPrefetchURI(uri, linkElem);
   } catch(e) {
     cancelError = 1;
   }
   is(cancelError, 0, "This prefetch has been canceled successfully");
 
   is(prefetch.hasMoreElements(), false, "The prefetch has already been canceled.");
 
--- a/dom/tests/mochitest/webcomponents/test_shadowroot_style_order.html
+++ b/dom/tests/mochitest/webcomponents/test_shadowroot_style_order.html
@@ -27,16 +27,16 @@ veryTallShadowStyle.innerHTML = ".tall {
 
 var divToStyle = document.createElement("div");
 divToStyle.setAttribute("class", "tall");
 root.appendChild(divToStyle);
 
 // Make sure the styles are applied in tree order.
 root.appendChild(tallShadowStyle);
 is(root.styleSheets.length, 1, "ShadowRoot should have one style sheet.");
-is(window.getComputedStyle(divToStyle, null).getPropertyValue("height"), "100px", "Style in ShadowRoot should apply to elements in ShadowRoot.");
+is(window.getComputedStyle(divToStyle).getPropertyValue("height"), "100px", "Style in ShadowRoot should apply to elements in ShadowRoot.");
 root.appendChild(veryTallShadowStyle);
 is(root.styleSheets.length, 2, "ShadowRoot should have two style sheets.");
-is(window.getComputedStyle(divToStyle, null).getPropertyValue("height"), "200px", "Style in ShadowRoot should apply to elements in ShadowRoot in tree order.");
+is(window.getComputedStyle(divToStyle).getPropertyValue("height"), "200px", "Style in ShadowRoot should apply to elements in ShadowRoot in tree order.");
 
 </script>
 </body>
 </html>
--- a/editor/AsyncSpellCheckTestHelper.jsm
+++ b/editor/AsyncSpellCheckTestHelper.jsm
@@ -26,17 +26,17 @@ const { classes: Cc, interfaces: Ci, uti
  * @param editableElement  The element being spell checked.
  * @param callback         Called when spell check has completed or enough turns
  *                         of the event loop have passed to determine it has not
  *                         started.
  */
 function onSpellCheck(editableElement, callback) {
   let editor = editableElement.editor;
   if (!editor) {
-    let win = editableElement.ownerDocument.defaultView;
+    let win = editableElement.ownerGlobal;
     editor = win.QueryInterface(Ci.nsIInterfaceRequestor).
                  getInterface(Ci.nsIWebNavigation).
                  QueryInterface(Ci.nsIInterfaceRequestor).
                  getInterface(Ci.nsIEditingSession).
                  getEditorForWindow(win);
   }
   if (!editor)
     throw new Error("Unable to find editor for element " + editableElement);
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -4260,44 +4260,32 @@ EditorBase::CreateTxnForComposition(cons
   //       class.
   RefPtr<CompositionTransaction> transaction =
     new CompositionTransaction(*mIMETextNode, mIMETextOffset, mIMETextLength,
                                mComposition->GetRanges(), aStringToInsert,
                                *this, &mRangeUpdater);
   return transaction.forget();
 }
 
-NS_IMETHODIMP
-EditorBase::CreateTxnForAddStyleSheet(StyleSheet* aSheet,
-                                      AddStyleSheetTransaction** aTransaction)
-{
-  RefPtr<AddStyleSheetTransaction> transaction = new AddStyleSheetTransaction();
-
-  nsresult rv = transaction->Init(this, aSheet);
-  if (NS_SUCCEEDED(rv)) {
-    transaction.forget(aTransaction);
-  }
-
-  return rv;
-}
-
-NS_IMETHODIMP
-EditorBase::CreateTxnForRemoveStyleSheet(
-              StyleSheet* aSheet,
-              RemoveStyleSheetTransaction** aTransaction)
+already_AddRefed<AddStyleSheetTransaction>
+EditorBase::CreateTxnForAddStyleSheet(StyleSheet* aSheet)
+{
+  RefPtr<AddStyleSheetTransaction> transaction =
+    new AddStyleSheetTransaction(*this, aSheet);
+
+  return transaction.forget();
+}
+
+already_AddRefed<RemoveStyleSheetTransaction>
+EditorBase::CreateTxnForRemoveStyleSheet(StyleSheet* aSheet)
 {
   RefPtr<RemoveStyleSheetTransaction> transaction =
-    new RemoveStyleSheetTransaction();
-
-  nsresult rv = transaction->Init(this, aSheet);
-  if (NS_SUCCEEDED(rv)) {
-    transaction.forget(aTransaction);
-  }
-
-  return rv;
+    new RemoveStyleSheetTransaction(*this, aSheet);
+
+  return transaction.forget();
 }
 
 nsresult
 EditorBase::CreateTxnForDeleteSelection(EDirection aAction,
                                         EditAggregateTransaction** aTransaction,
                                         nsINode** aNode,
                                         int32_t* aOffset,
                                         int32_t* aLength)
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -335,26 +335,24 @@ protected:
    * Never returns null.
    */
   already_AddRefed<mozilla::CompositionTransaction>
     CreateTxnForComposition(const nsAString& aStringToInsert);
 
   /**
    * Create a transaction for adding a style sheet.
    */
-  NS_IMETHOD CreateTxnForAddStyleSheet(
-               StyleSheet* aSheet,
-               AddStyleSheetTransaction** aTransaction);
+  already_AddRefed<mozilla::AddStyleSheetTransaction>
+    CreateTxnForAddStyleSheet(StyleSheet* aSheet);
 
   /**
    * Create a transaction for removing a style sheet.
    */
-  NS_IMETHOD CreateTxnForRemoveStyleSheet(
-               StyleSheet* aSheet,
-               RemoveStyleSheetTransaction** aTransaction);
+  already_AddRefed<mozilla::RemoveStyleSheetTransaction>
+    CreateTxnForRemoveStyleSheet(StyleSheet* aSheet);
 
   nsresult DeleteText(nsGenericDOMDataNode& aElement,
                       uint32_t aOffset, uint32_t aLength);
 
   already_AddRefed<DeleteTextTransaction>
     CreateTxnForDeleteText(nsGenericDOMDataNode& aElement,
                            uint32_t aOffset, uint32_t aLength);
 
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -2868,32 +2868,28 @@ HTMLEditor::ReplaceStyleSheet(const nsAS
 }
 
 NS_IMETHODIMP
 HTMLEditor::RemoveStyleSheet(const nsAString& aURL)
 {
   RefPtr<StyleSheet> sheet = GetStyleSheetForURL(aURL);
   NS_ENSURE_TRUE(sheet, NS_ERROR_UNEXPECTED);
 
-  RefPtr<RemoveStyleSheetTransaction> transaction;
-  nsresult rv =
-    CreateTxnForRemoveStyleSheet(sheet, getter_AddRefs(transaction));
+  RefPtr<RemoveStyleSheetTransaction> transaction =
+    CreateTxnForRemoveStyleSheet(sheet);
   if (!transaction) {
-    rv = NS_ERROR_NULL_POINTER;
-  }
+    return NS_ERROR_NULL_POINTER;
+  }
+
+  nsresult rv = DoTransaction(transaction);
   if (NS_SUCCEEDED(rv)) {
-    rv = DoTransaction(transaction);
-    if (NS_SUCCEEDED(rv)) {
-      mLastStyleSheetURL.Truncate();        // forget it
-    }
-    // Remove it from our internal list
-    rv = RemoveStyleSheetFromList(aURL);
-  }
-
-  return rv;
+    mLastStyleSheetURL.Truncate();        // forget it
+  }
+  // Remove it from our internal list
+  return RemoveStyleSheetFromList(aURL);
 }
 
 
 NS_IMETHODIMP
 HTMLEditor::AddOverrideStyleSheet(const nsAString& aURL)
 {
   // Enable existing sheet if already loaded.
   if (EnableExistingStyleSheet(aURL)) {
@@ -3470,41 +3466,39 @@ HTMLEditor::DebugUnitTests(int32_t* outN
 #endif
 }
 
 NS_IMETHODIMP
 HTMLEditor::StyleSheetLoaded(StyleSheet* aSheet,
                              bool aWasAlternate,
                              nsresult aStatus)
 {
-  nsresult rv = NS_OK;
   AutoEditBatch batchIt(this);
 
   if (!mLastStyleSheetURL.IsEmpty())
     RemoveStyleSheet(mLastStyleSheetURL);
 
-  RefPtr<AddStyleSheetTransaction> transaction;
-  rv = CreateTxnForAddStyleSheet(aSheet, getter_AddRefs(transaction));
+  RefPtr<AddStyleSheetTransaction> transaction =
+    CreateTxnForAddStyleSheet(aSheet);
   if (!transaction) {
-    rv = NS_ERROR_NULL_POINTER;
-  }
+    return NS_OK;
+  }
+
+  nsresult rv = DoTransaction(transaction);
   if (NS_SUCCEEDED(rv)) {
-    rv = DoTransaction(transaction);
+    // Get the URI, then url spec from the sheet
+    nsAutoCString spec;
+    rv = aSheet->GetSheetURI()->GetSpec(spec);
+
     if (NS_SUCCEEDED(rv)) {
-      // Get the URI, then url spec from the sheet
-      nsAutoCString spec;
-      rv = aSheet->GetSheetURI()->GetSpec(spec);
-
-      if (NS_SUCCEEDED(rv)) {
-        // Save it so we can remove before applying the next one
-        mLastStyleSheetURL.AssignWithConversion(spec.get());
-
-        // Also save in our arrays of urls and sheets
-        AddNewStyleSheetToList(mLastStyleSheetURL, aSheet);
-      }
+      // Save it so we can remove before applying the next one
+      mLastStyleSheetURL.AssignWithConversion(spec.get());
+
+      // Also save in our arrays of urls and sheets
+      AddNewStyleSheetToList(mLastStyleSheetURL, aSheet);
     }
   }
 
   return NS_OK;
 }
 
 /**
  * All editor operations which alter the doc should be prefaced
--- a/editor/libeditor/StyleSheetTransactions.cpp
+++ b/editor/libeditor/StyleSheetTransactions.cpp
@@ -8,145 +8,119 @@
 #include <stddef.h>                     // for nullptr
 
 #include "nsAString.h"
 #include "nsCOMPtr.h"                   // for nsCOMPtr, do_QueryInterface, etc.
 #include "mozilla/StyleSheet.h"   // for mozilla::StyleSheet
 #include "mozilla/StyleSheetInlines.h"
 #include "nsDebug.h"                    // for NS_ENSURE_TRUE
 #include "nsError.h"                    // for NS_OK, etc.
-#include "nsIDOMDocument.h"             // for nsIDOMDocument
 #include "nsIDocument.h"                // for nsIDocument
 #include "nsIDocumentObserver.h"        // for UPDATE_STYLE
-#include "nsIEditor.h"                  // for nsIEditor
 
 namespace mozilla {
 
 static void
-AddStyleSheet(nsIEditor* aEditor, StyleSheet* aSheet)
+AddStyleSheet(EditorBase& aEditor, StyleSheet* aSheet)
 {
-  nsCOMPtr<nsIDOMDocument> domDoc;
-  aEditor->GetDocument(getter_AddRefs(domDoc));
-  nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
+  nsCOMPtr<nsIDocument> doc = aEditor.GetDocument();
   if (doc) {
     doc->BeginUpdate(UPDATE_STYLE);
     doc->AddStyleSheet(aSheet);
     doc->EndUpdate(UPDATE_STYLE);
   }
 }
 
 static void
-RemoveStyleSheet(nsIEditor* aEditor, StyleSheet* aSheet)
+RemoveStyleSheet(EditorBase& aEditor, StyleSheet* aSheet)
 {
-  nsCOMPtr<nsIDOMDocument> domDoc;
-  aEditor->GetDocument(getter_AddRefs(domDoc));
-  nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
+  nsCOMPtr<nsIDocument> doc = aEditor.GetDocument();
   if (doc) {
     doc->BeginUpdate(UPDATE_STYLE);
     doc->RemoveStyleSheet(aSheet);
     doc->EndUpdate(UPDATE_STYLE);
   }
 }
 
 /******************************************************************************
  * AddStyleSheetTransaction
  ******************************************************************************/
 
-AddStyleSheetTransaction::AddStyleSheetTransaction()
-  : mEditor(nullptr)
+AddStyleSheetTransaction::AddStyleSheetTransaction(EditorBase& aEditor,
+                                                   StyleSheet* aSheet)
+  : mEditor(aEditor)
+  , mSheet(aSheet)
 {
+  MOZ_ASSERT(aSheet);
 }
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(AddStyleSheetTransaction,
                                    EditTransactionBase,
                                    mSheet)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AddStyleSheetTransaction)
 NS_INTERFACE_MAP_END_INHERITING(EditTransactionBase)
 
 NS_IMETHODIMP
-AddStyleSheetTransaction::Init(nsIEditor* aEditor,
-                               StyleSheet* aSheet)
-{
-  NS_ENSURE_TRUE(aEditor && aSheet, NS_ERROR_INVALID_ARG);
-
-  mEditor = aEditor;
-  mSheet = aSheet;
-
-  return NS_OK;
-}
-
-
-NS_IMETHODIMP
 AddStyleSheetTransaction::DoTransaction()
 {
-  NS_ENSURE_TRUE(mEditor && mSheet, NS_ERROR_NOT_INITIALIZED);
+  NS_ENSURE_TRUE(mSheet, NS_ERROR_NOT_INITIALIZED);
 
   AddStyleSheet(mEditor, mSheet);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 AddStyleSheetTransaction::UndoTransaction()
 {
-  NS_ENSURE_TRUE(mEditor && mSheet, NS_ERROR_NOT_INITIALIZED);
+  NS_ENSURE_TRUE(mSheet, NS_ERROR_NOT_INITIALIZED);
 
   RemoveStyleSheet(mEditor, mSheet);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 AddStyleSheetTransaction::GetTxnDescription(nsAString& aString)
 {
   aString.AssignLiteral("AddStyleSheetTransaction");
   return NS_OK;
 }
 
 /******************************************************************************
  * RemoveStyleSheetTransaction
  ******************************************************************************/
 
-RemoveStyleSheetTransaction::RemoveStyleSheetTransaction()
-  : mEditor(nullptr)
+RemoveStyleSheetTransaction::RemoveStyleSheetTransaction(EditorBase& aEditor,
+                                                         StyleSheet* aSheet)
+  : mEditor(aEditor)
+  , mSheet(aSheet)
 {
+  MOZ_ASSERT(aSheet);
 }
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(RemoveStyleSheetTransaction,
                                    EditTransactionBase,
                                    mSheet)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(RemoveStyleSheetTransaction)
 NS_INTERFACE_MAP_END_INHERITING(EditTransactionBase)
 
 NS_IMETHODIMP
-RemoveStyleSheetTransaction::Init(nsIEditor* aEditor,
-                                  StyleSheet* aSheet)
-{
-  NS_ENSURE_TRUE(aEditor && aSheet, NS_ERROR_INVALID_ARG);
-
-  mEditor = aEditor;
-  mSheet = aSheet;
-
-  return NS_OK;
-}
-
-
-NS_IMETHODIMP
 RemoveStyleSheetTransaction::DoTransaction()
 {
-  NS_ENSURE_TRUE(mEditor && mSheet, NS_ERROR_NOT_INITIALIZED);
+  NS_ENSURE_TRUE(mSheet, NS_ERROR_NOT_INITIALIZED);
 
   RemoveStyleSheet(mEditor, mSheet);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 RemoveStyleSheetTransaction::UndoTransaction()
 {
-  NS_ENSURE_TRUE(mEditor && mSheet, NS_ERROR_NOT_INITIALIZED);
+  NS_ENSURE_TRUE(mSheet, NS_ERROR_NOT_INITIALIZED);
 
   AddStyleSheet(mEditor, mSheet);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 RemoveStyleSheetTransaction::GetTxnDescription(nsAString& aString)
 {
--- a/editor/libeditor/StyleSheetTransactions.h
+++ b/editor/libeditor/StyleSheetTransactions.h
@@ -1,73 +1,66 @@
 /* -*- 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 StylesheetTransactions_h
 #define StylesheetTransactions_h
 
+#include "mozilla/EditorBase.h"         // mEditor
 #include "mozilla/EditTransactionBase.h" // for EditTransactionBase, etc.
 #include "mozilla/StyleSheet.h"   // for mozilla::StyleSheet
 #include "nsCycleCollectionParticipant.h"
 #include "nsID.h"                       // for REFNSIID
 #include "nscore.h"                     // for NS_IMETHOD
 
-class nsIEditor;
-
 namespace mozilla {
 
 class AddStyleSheetTransaction final : public EditTransactionBase
 {
 public:
   /**
-   * Initialize the transaction.
    * @param aEditor     The object providing core editing operations
    * @param aSheet      The stylesheet to add
     */
-  NS_IMETHOD Init(nsIEditor* aEditor, StyleSheet* aSheet);
-
-  AddStyleSheetTransaction();
+  AddStyleSheetTransaction(EditorBase& aEditor, StyleSheet* aSheet);
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AddStyleSheetTransaction,
                                            EditTransactionBase)
   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
 
   NS_DECL_EDITTRANSACTIONBASE
 
 protected:
   // The editor that created this transaction.
-  nsIEditor* mEditor;
+  EditorBase& mEditor;
   // The style sheet to add.
   RefPtr<mozilla::StyleSheet> mSheet;
 };
 
 
 class RemoveStyleSheetTransaction final : public EditTransactionBase
 {
 public:
   /**
-   * Initialize the transaction.
    * @param aEditor     The object providing core editing operations.
    * @param aSheet      The stylesheet to remove.
    */
-  NS_IMETHOD Init(nsIEditor* aEditor, StyleSheet* aSheet);
-
-  RemoveStyleSheetTransaction();
+  RemoveStyleSheetTransaction(EditorBase& aEditor, StyleSheet* aSheet);
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(RemoveStyleSheetTransaction,
                                            EditTransactionBase)
   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
 
   NS_DECL_EDITTRANSACTIONBASE
 
 protected:
   // The editor that created this transaction.
-  nsIEditor* mEditor;
+  EditorBase& mEditor;
   // The style sheet to remove.
   RefPtr<StyleSheet> mSheet;
 
 };
 
 } // namespace mozilla
 
 #endif // #ifndef StylesheetTransactions_h
--- a/editor/libeditor/tests/test_bug372345.html
+++ b/editor/libeditor/tests/test_bug372345.html
@@ -27,17 +27,17 @@ addLoadEvent(function() {
   var link = content.querySelector("a");
   function testCursor(post) {
     setTimeout(function() {
       var link = document.createElement("a");
       link.href = "http://mozilla.org/";
       link.textContent = "link";
       link.style.cursor = "pointer";
       content.appendChild(link);
-      is(iframe.contentWindow.getComputedStyle(link, null).cursor, "pointer", "Make sure that the cursor is set to pointer");
+      is(iframe.contentWindow.getComputedStyle(link).cursor, "pointer", "Make sure that the cursor is set to pointer");
       setTimeout(post, 0);
     }, 0);
   }
   testCursor(function() {
     doc.designMode = "on";
     testCursor(function() {
       doc.designMode = "off";
       testCursor(function() {
--- a/image/test/mochitest/test_bug415761.html
+++ b/image/test/mochitest/test_bug415761.html
@@ -16,17 +16,17 @@ SimpleTest.waitForExplicitFinish();
 // We want to make sure that moz-icon URIs with non-ascii characters work. To that
 // end, we compare the rendering of an icon without non-ascii characters to that
 // of one that does include such characters.
 
 // First, obtain the file URI to the ourselves:
 var chromeURI = location.href;
 var io = Components.classes['@mozilla.org/network/io-service;1']
            .getService(Components.interfaces.nsIIOService);
-chromeURI = io.newURI(chromeURI, null, null);
+chromeURI = io.newURI(chromeURI);
 var chromeReg = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
                   .getService(Components.interfaces.nsIChromeRegistry);
 fileURI = chromeReg.convertChromeURL(chromeURI);
 fileURI.QueryInterface(Components.interfaces.nsIFileURL);
 var self = fileURI.file;
 
 // Check if the non-ascii-named icon is still hanging around from a previous test
 var dest = self.parent;
--- a/js/src/jit/none/Architecture-none.h
+++ b/js/src/jit/none/Architecture-none.h
@@ -6,16 +6,18 @@
 
 #ifndef jit_none_Architecture_none_h
 #define jit_none_Architecture_none_h
 
 // JitSpewer.h is included through MacroAssembler implementations for other
 // platforms, so include it here to avoid inadvertent build bustage.
 #include "jit/JitSpewer.h"
 
+#include "jit/shared/Architecture-shared.h"
+
 namespace js {
 namespace jit {
 
 static const bool SupportsSimd = false;
 static const uint32_t SimdMemoryAlignment = 4; // Make it 4 to avoid a bunch of div-by-zero warnings
 static const uint32_t WasmStackAlignment = 8;
 
 // Does this architecture support SIMD conversions between Uint32x4 and Float32x4?
@@ -126,16 +128,30 @@ struct FloatRegister
     bool aliases(FloatRegister) const { MOZ_CRASH(); }
     uint32_t numAliased() const { MOZ_CRASH(); }
     void aliased(uint32_t, FloatRegister*) { MOZ_CRASH(); }
     bool equiv(FloatRegister) const { MOZ_CRASH(); }
     uint32_t size() const { MOZ_CRASH(); }
     uint32_t numAlignedAliased() const { MOZ_CRASH(); }
     void alignedAliased(uint32_t, FloatRegister*) { MOZ_CRASH(); }
     SetType alignedOrDominatedAliasedSet() const { MOZ_CRASH(); }
+
+    static constexpr RegTypeName DefaultType = RegTypeName::Float64;
+
+    template <RegTypeName = DefaultType>
+    static SetType LiveAsIndexableSet(SetType s) {
+        return SetType(0);
+    }
+
+    template <RegTypeName Name = DefaultType>
+    static SetType AllocatableAsIndexableSet(SetType s) {
+        static_assert(Name != RegTypeName::Any, "Allocatable set are not iterable");
+        return SetType(0);
+    }
+
     template <typename T> static T ReduceSetForPush(T) { MOZ_CRASH(); }
     uint32_t getRegisterDumpOffsetInBytes() { MOZ_CRASH(); }
     static uint32_t SetSize(SetType x) { MOZ_CRASH(); }
     static Code FromName(const char* name) { MOZ_CRASH(); }
 
     // This is used in static initializers, so produce a bogus value instead of crashing.
     static uint32_t GetPushSizeInBytes(const TypedRegisterSet<FloatRegister>&) { return 0; }
 };
--- a/js/src/jscompartment.cpp
+++ b/js/src/jscompartment.cpp
@@ -112,16 +112,23 @@ JSCompartment::~JSCompartment()
     js_delete(scriptCountsMap);
     js_delete(debugScriptMap);
     js_delete(debugEnvs);
     js_delete(objectMetadataTable);
     js_delete(lazyArrayBuffers);
     js_delete(nonSyntacticLexicalEnvironments_),
     js_free(enumerators);
 
+#ifdef DEBUG
+    // Avoid assertion destroying the unboxed layouts list if the embedding
+    // leaked GC things.
+    if (!rt->gc.shutdownCollectedEverything())
+        unboxedLayouts.clear();
+#endif
+
     runtime_->numCompartments--;
 }
 
 bool
 JSCompartment::init(JSContext* maybecx)
 {
     /*
      * maybecx is null when called to create the atoms compartment from
--- a/js/src/wasm/WasmBaselineCompile.cpp
+++ b/js/src/wasm/WasmBaselineCompile.cpp
@@ -428,28 +428,16 @@ class BaseCompiler
         }
 
         void bind(MacroAssembler& masm) {
             MOZ_ASSERT(framePushed_ != UINT32_MAX);
             masm.bind(&entry_);
             masm.setFramePushed(framePushed_);
         }
 
-        // Save volatile registers but not ReturnReg.
-
-        void saveVolatileReturnGPR(MacroAssembler& masm) {
-            masm.PushRegsInMask(BaseCompiler::VolatileReturnGPR);
-        }
-
-        // Restore volatile registers but not ReturnReg.
-
-        void restoreVolatileReturnGPR(MacroAssembler& masm) {
-            masm.PopRegsInMask(BaseCompiler::VolatileReturnGPR);
-        }
-
         // The generate() method must be careful about register use
         // because it will be invoked when there is a register
         // assignment in the BaseCompiler that does not correspond
         // to the available registers when the generated OOL code is
         // executed.  The register allocator *must not* be called.
         //
         // The best strategy is for the creator of the OOL object to
         // allocate all temps that the OOL code will need.
@@ -2473,38 +2461,26 @@ class BaseCompiler
         CallSiteDesc desc(call.lineOrBytecode, CallSiteDesc::Symbolic);
         masm.call(callee);
     }
 
     // Precondition: sync()
 
     void callIndirect(uint32_t sigIndex, Stk& indexVal, const FunctionCall& call)
     {
+        const SigWithId& sig = env_.sigs[sigIndex];
+        MOZ_ASSERT(sig.id.kind() != SigIdDesc::Kind::None);
+
+        MOZ_ASSERT(env_.tables.length() == 1);
+        const TableDesc& table = env_.tables[0];
+
         loadI32(WasmTableCallIndexReg, indexVal);
 
-        const SigWithId& sig = env_.sigs[sigIndex];
-
-        CalleeDesc callee;
-        if (isCompilingAsmJS()) {
-            MOZ_ASSERT(sig.id.kind() == SigIdDesc::Kind::None);
-            const TableDesc& table = env_.tables[env_.asmJSSigToTableIndex[sigIndex]];
-
-            MOZ_ASSERT(IsPowerOfTwo(table.limits.initial));
-            masm.andPtr(Imm32((table.limits.initial - 1)), WasmTableCallIndexReg);
-
-            callee = CalleeDesc::asmJSTable(table);
-        } else {
-            MOZ_ASSERT(sig.id.kind() != SigIdDesc::Kind::None);
-            MOZ_ASSERT(env_.tables.length() == 1);
-            const TableDesc& table = env_.tables[0];
-
-            callee = CalleeDesc::wasmTable(table, sig.id);
-        }
-
         CallSiteDesc desc(call.lineOrBytecode, CallSiteDesc::Dynamic);
+        CalleeDesc callee = CalleeDesc::wasmTable(table, sig.id);
         masm.wasmCallIndirect(desc, callee);
     }
 
     // Precondition: sync()
 
     void callImport(unsigned globalDataOffset, const FunctionCall& call)
     {
         CallSiteDesc desc(call.lineOrBytecode, CallSiteDesc::Dynamic);
@@ -2678,52 +2654,38 @@ class BaseCompiler
         *r0 = popI64ToSpecific(specific_rax);
         freeI64(specific_rdx);
 #else
         pop2xI64(r0, r1);
 #endif
     }
 
     void checkDivideByZeroI32(RegI32 rhs, RegI32 srcDest, Label* done) {
-        if (isCompilingAsmJS()) {
-            // Truncated division by zero is zero (Infinity|0 == 0)
-            Label notDivByZero;
-            masm.branchTest32(Assembler::NonZero, rhs, rhs, &notDivByZero);
-            masm.move32(Imm32(0), srcDest);
-            masm.jump(done);
-            masm.bind(&notDivByZero);
-        } else {
-            masm.branchTest32(Assembler::Zero, rhs, rhs, trap(Trap::IntegerDivideByZero));
-        }
+        masm.branchTest32(Assembler::Zero, rhs, rhs, trap(Trap::IntegerDivideByZero));
     }
 
     void checkDivideByZeroI64(RegI64 r) {
-        MOZ_ASSERT(!isCompilingAsmJS());
         ScratchI32 scratch(*this);
         masm.branchTest64(Assembler::Zero, r, r, scratch, trap(Trap::IntegerDivideByZero));
     }
 
     void checkDivideSignedOverflowI32(RegI32 rhs, RegI32 srcDest, Label* done, bool zeroOnOverflow) {
         Label notMin;
         masm.branch32(Assembler::NotEqual, srcDest, Imm32(INT32_MIN), &notMin);
         if (zeroOnOverflow) {
             masm.branch32(Assembler::NotEqual, rhs, Imm32(-1), &notMin);
             masm.move32(Imm32(0), srcDest);
             masm.jump(done);
-        } else if (isCompilingAsmJS()) {
-            // (-INT32_MIN)|0 == INT32_MIN and INT32_MIN is already in srcDest.
-            masm.branch32(Assembler::Equal, rhs, Imm32(-1), done);
         } else {
             masm.branch32(Assembler::Equal, rhs, Imm32(-1), trap(Trap::IntegerOverflow));
         }
         masm.bind(&notMin);
     }
 
     void checkDivideSignedOverflowI64(RegI64 rhs, RegI64 srcDest, Label* done, bool zeroOnOverflow) {
-        MOZ_ASSERT(!isCompilingAsmJS());
         Label notmin;
         masm.branch64(Assembler::NotEqual, srcDest, Imm64(INT64_MIN), &notmin);
         masm.branch64(Assembler::NotEqual, rhs, Imm64(-1), &notmin);
         if (zeroOnOverflow) {
             masm.xor64(srcDest, srcDest);
             masm.jump(done);
         } else {
             masm.jump(trap(Trap::IntegerOverflow));
@@ -2925,112 +2887,86 @@ class BaseCompiler
         MOZ_CRASH("BaseCompiler platform hook: extendU32ToI64");
 #endif
     }
 
     class OutOfLineTruncateF32OrF64ToI32 : public OutOfLineCode
     {
         AnyReg src;
         RegI32 dest;
-        bool isAsmJS;
         bool isUnsigned;
         TrapOffset off;
 
       public:
-        OutOfLineTruncateF32OrF64ToI32(AnyReg src, RegI32 dest, bool isAsmJS, bool isUnsigned,
-                                       TrapOffset off)
+        OutOfLineTruncateF32OrF64ToI32(AnyReg src, RegI32 dest, bool isUnsigned, TrapOffset off)
           : src(src),
             dest(dest),
-            isAsmJS(isAsmJS),
             isUnsigned(isUnsigned),
             off(off)
-        {
-            MOZ_ASSERT_IF(isAsmJS, !isUnsigned);
-        }
+        {}
 
         virtual void generate(MacroAssembler& masm) {
             bool isFloat = src.tag == AnyReg::F32;
             FloatRegister fsrc = isFloat ? static_cast<FloatRegister>(src.f32())
                                          : static_cast<FloatRegister>(src.f64());
-            if (isAsmJS) {
-                saveVolatileReturnGPR(masm);
-                masm.outOfLineTruncateSlow(fsrc, dest, isFloat, /* isAsmJS */ true);
-                restoreVolatileReturnGPR(masm);
-                masm.jump(rejoin());
-            } else {
 #if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64)
-                if (isFloat)
-                    masm.outOfLineWasmTruncateFloat32ToInt32(fsrc, isUnsigned, off, rejoin());
-                else
-                    masm.outOfLineWasmTruncateDoubleToInt32(fsrc, isUnsigned, off, rejoin());
+            if (isFloat)
+                masm.outOfLineWasmTruncateFloat32ToInt32(fsrc, isUnsigned, off, rejoin());
+            else
+                masm.outOfLineWasmTruncateDoubleToInt32(fsrc, isUnsigned, off, rejoin());
 #elif defined(JS_CODEGEN_ARM)
-                masm.outOfLineWasmTruncateToIntCheck(fsrc,
-                                                     isFloat ? MIRType::Float32 : MIRType::Double,
-                                                     MIRType::Int32, isUnsigned, rejoin(), off);
+            masm.outOfLineWasmTruncateToIntCheck(fsrc,
+                                                 isFloat ? MIRType::Float32 : MIRType::Double,
+                                                 MIRType::Int32, isUnsigned, rejoin(), off);
 #else
-                (void)isUnsigned; // Suppress warnings
-                (void)off;        //  for unused private
-                MOZ_CRASH("BaseCompiler platform hook: OutOfLineTruncateF32OrF64ToI32 wasm");
+            (void)isUnsigned;
+            (void)off;
+            (void)isFloat;
+            (void)fsrc;
+            MOZ_CRASH("BaseCompiler platform hook: OutOfLineTruncateF32OrF64ToI32 wasm");
 #endif
-            }
         }
     };
 
     MOZ_MUST_USE bool truncateF32ToI32(RegF32 src, RegI32 dest, bool isUnsigned) {
         TrapOffset off = trapOffset();
         OutOfLineCode* ool;
-        if (isCompilingAsmJS()) {
-            ool = new(alloc_) OutOfLineTruncateF32OrF64ToI32(AnyReg(src), dest, true, false, off);
-            ool = addOutOfLineCode(ool);
-            if (!ool)
-                return false;
-            masm.branchTruncateFloat32ToInt32(src, dest, ool->entry());
-        } else {
 #if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64) || defined(JS_CODEGEN_ARM)
-            ool = new(alloc_) OutOfLineTruncateF32OrF64ToI32(AnyReg(src), dest, false, isUnsigned,
-                                                             off);
-            ool = addOutOfLineCode(ool);
-            if (!ool)
-                return false;
-            if (isUnsigned)
-                masm.wasmTruncateFloat32ToUInt32(src, dest, ool->entry());
-            else
-                masm.wasmTruncateFloat32ToInt32(src, dest, ool->entry());
+        ool = new(alloc_) OutOfLineTruncateF32OrF64ToI32(AnyReg(src), dest, isUnsigned, off);
+        ool = addOutOfLineCode(ool);
+        if (!ool)
+            return false;
+        if (isUnsigned)
+            masm.wasmTruncateFloat32ToUInt32(src, dest, ool->entry());
+        else
+            masm.wasmTruncateFloat32ToInt32(src, dest, ool->entry());
 #else
-            MOZ_CRASH("BaseCompiler platform hook: truncateF32ToI32 wasm");
+        (void)off;
+        MOZ_CRASH("BaseCompiler platform hook: truncateF32ToI32 wasm");
 #endif
-        }
         masm.bind(ool->rejoin());
         return true;
     }
 
     MOZ_MUST_USE bool truncateF64ToI32(RegF64 src, RegI32 dest, bool isUnsigned) {
         TrapOffset off = trapOffset();
         OutOfLineCode* ool;
-        if (isCompilingAsmJS()) {
-            ool = new(alloc_) OutOfLineTruncateF32OrF64ToI32(AnyReg(src), dest, true, false, off);
-            ool = addOutOfLineCode(ool);
-            if (!ool)
-                return false;
-            masm.branchTruncateDoubleToInt32(src, dest, ool->entry());
-        } else {
 #if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64) || defined(JS_CODEGEN_ARM)
-            ool = new(alloc_) OutOfLineTruncateF32OrF64ToI32(AnyReg(src), dest, false, isUnsigned,
-                                                             off);
-            ool = addOutOfLineCode(ool);
-            if (!ool)
-                return false;
-            if (isUnsigned)
-                masm.wasmTruncateDoubleToUInt32(src, dest, ool->entry());
-            else
-                masm.wasmTruncateDoubleToInt32(src, dest, ool->entry());
+        ool = new(alloc_) OutOfLineTruncateF32OrF64ToI32(AnyReg(src), dest, isUnsigned, off);
+        ool = addOutOfLineCode(ool);
+        if (!ool)
+            return false;
+        if (isUnsigned)
+            masm.wasmTruncateDoubleToUInt32(src, dest, ool->entry());
+        else
+            masm.wasmTruncateDoubleToInt32(src, dest, ool->entry());
 #else
-            MOZ_CRASH("BaseCompiler platform hook: truncateF64ToI32 wasm");
+        (void)off;
+        MOZ_CRASH("BaseCompiler platform hook: truncateF64ToI32 wasm");
 #endif
-        }
         masm.bind(ool->rejoin());
         return true;
     }
 
     // This does not generate a value; if the truncation failed then it traps.
 
     class OutOfLineTruncateCheckF32OrF64ToI64 : public OutOfLineCode
     {
@@ -3334,65 +3270,16 @@ class BaseCompiler
         MOZ_CRASH("BaseCompiler platform hook: storeGlobalVarF64");
 #endif
     }
 
     //////////////////////////////////////////////////////////////////////
     //
     // Heap access.
 
-#ifndef WASM_HUGE_MEMORY
-    class AsmJSLoadOOB : public OutOfLineCode
-    {
-        Scalar::Type viewType;
-        AnyRegister dest;
-
-      public:
-        AsmJSLoadOOB(Scalar::Type viewType, AnyRegister dest)
-          : viewType(viewType),
-            dest(dest)
-        {}
-
-        void generate(MacroAssembler& masm) {
-# if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_ARM)
-            switch (viewType) {
-              case Scalar::Float32x4:
-              case Scalar::Int32x4:
-              case Scalar::Int8x16:
-              case Scalar::Int16x8:
-              case Scalar::MaxTypedArrayViewType:
-                MOZ_CRASH("unexpected array type");
-              case Scalar::Float32:
-                masm.loadConstantFloat32(float(GenericNaN()), dest.fpu());
-                break;
-              case Scalar::Float64:
-                masm.loadConstantDouble(GenericNaN(), dest.fpu());
-                break;
-              case Scalar::Int8:
-              case Scalar::Uint8:
-              case Scalar::Int16:
-              case Scalar::Uint16:
-              case Scalar::Int32:
-              case Scalar::Uint32:
-              case Scalar::Uint8Clamped:
-                masm.movePtr(ImmWord(0), dest.gpr());
-                break;
-              case Scalar::Int64:
-                MOZ_CRASH("unexpected array type");
-            }
-            masm.jump(rejoin());
-# else
-            Unused << viewType;
-            Unused << dest;
-            MOZ_CRASH("Compiler bug: Unexpected platform.");
-# endif
-        }
-    };
-#endif
-
     void checkOffset(MemoryAccessDesc* access, RegI32 ptr) {
         if (access->offset() >= OffsetGuardLimit) {
             masm.branchAdd32(Assembler::CarrySet, Imm32(access->offset()), ptr,
                              trap(Trap::OutOfBounds));
             access->clearOffset();
         }
     }
 
@@ -3419,27 +3306,18 @@ class BaseCompiler
     // This may destroy ptr even if ptr and dest are not the same.
     MOZ_MUST_USE bool load(MemoryAccessDesc& access, RegI32 ptr, bool omitBoundsCheck, AnyReg dest,
                            RegI32 tmp1, RegI32 tmp2, RegI32 tmp3)
     {
         checkOffset(&access, ptr);
 
         OutOfLineCode* ool = nullptr;
 #ifndef WASM_HUGE_MEMORY
-        if (!omitBoundsCheck) {
-            if (access.isPlainAsmJS()) {
-                ool = new (alloc_) AsmJSLoadOOB(access.type(), dest.any());
-                if (!addOutOfLineCode(ool))
-                    return false;
-
-                masm.wasmBoundsCheck(Assembler::AboveOrEqual, ptr, ool->entry());
-            } else {
-                masm.wasmBoundsCheck(Assembler::AboveOrEqual, ptr, trap(Trap::OutOfBounds));
-            }
-        }
+        if (!omitBoundsCheck)
+            masm.wasmBoundsCheck(Assembler::AboveOrEqual, ptr, trap(Trap::OutOfBounds));
 #endif
 
 #if defined(JS_CODEGEN_X64)
         Operand srcAddr(HeapReg, ptr, TimesOne, access.offset());
 
         if (dest.tag == AnyReg::I64)
             masm.wasmLoadI64(access, srcAddr, dest.i64());
         else
@@ -3505,22 +3383,18 @@ class BaseCompiler
     // This may destroy ptr but will not destroy src.
     MOZ_MUST_USE bool store(MemoryAccessDesc access, RegI32 ptr, bool omitBoundsCheck, AnyReg src,
                             RegI32 tmp)
     {
         checkOffset(&access, ptr);
 
         Label rejoin;
 #ifndef WASM_HUGE_MEMORY
-        if (!omitBoundsCheck) {
-            if (access.isPlainAsmJS())
-                masm.wasmBoundsCheck(Assembler::AboveOrEqual, ptr, &rejoin);
-            else
-                masm.wasmBoundsCheck(Assembler::AboveOrEqual, ptr, trap(Trap::OutOfBounds));
-        }
+        if (!omitBoundsCheck)
+            masm.wasmBoundsCheck(Assembler::AboveOrEqual, ptr, trap(Trap::OutOfBounds));
 #endif
 
         // Emit the store
 #if defined(JS_CODEGEN_X64)
         Operand dstAddr(HeapReg, ptr, TimesOne, access.offset());
 
         masm.wasmStore(access, src.any(), dstAddr);
 #elif defined(JS_CODEGEN_X86)
@@ -3670,28 +3544,20 @@ class BaseCompiler
             return func_.callSiteLineNums()[lastReadCallSite_++];
         return trapOffset().bytecodeOffset;
     }
 
     bool done() const {
         return iter_.done();
     }
 
-    bool isCompilingAsmJS() const {
-        return env_.kind == ModuleKind::AsmJS;
-    }
-
     TrapOffset trapOffset() const {
         return iter_.trapOffset();
     }
 
-    Maybe<TrapOffset> trapIfNotAsmJS() const {
-        return isCompilingAsmJS() ? Nothing() : Some(trapOffset());
-    }
-
     TrapDesc trap(Trap t) const {
         return TrapDesc(trapOffset(), t, masm.framePushed());
     }
 
     ////////////////////////////////////////////////////////////
     //
     // Machinery for optimized conditional branches.
     //
@@ -4433,83 +4299,75 @@ BaseCompiler::emitMinMaxI32(Assembler::C
     pushI32(r0);
 }
 
 void
 BaseCompiler::emitMinF32()
 {
     RegF32 r0, r1;
     pop2xF32(&r0, &r1);
-    if (!isCompilingAsmJS()) {
-        // Convert signaling NaN to quiet NaNs.
-        //
-        // TODO / OPTIMIZE (bug 1316824): Don't do this if one of the operands
-        // is known to be a constant.
-        ScratchF32 zero(*this);
-        masm.loadConstantFloat32(0.f, zero);
-        masm.subFloat32(zero, r0);
-        masm.subFloat32(zero, r1);
-    }
+    // Convert signaling NaN to quiet NaNs.
+    //
+    // TODO / OPTIMIZE (bug 1316824): Don't do this if one of the operands
+    // is known to be a constant.
+    ScratchF32 zero(*this);
+    masm.loadConstantFloat32(0.f, zero);
+    masm.subFloat32(zero, r0);
+    masm.subFloat32(zero, r1);
     masm.minFloat32(r1, r0, HandleNaNSpecially(true));
     freeF32(r1);
     pushF32(r0);
 }
 
 void
 BaseCompiler::emitMaxF32()
 {
     RegF32 r0, r1;
     pop2xF32(&r0, &r1);
-    if (!isCompilingAsmJS()) {
-        // Convert signaling NaN to quiet NaNs.
-        //
-        // TODO / OPTIMIZE (bug 1316824): see comment in emitMinF32.
-        ScratchF32 zero(*this);
-        masm.loadConstantFloat32(0.f, zero);
-        masm.subFloat32(zero, r0);
-        masm.subFloat32(zero, r1);
-    }
+    // Convert signaling NaN to quiet NaNs.
+    //
+    // TODO / OPTIMIZE (bug 1316824): see comment in emitMinF32.
+    ScratchF32 zero(*this);
+    masm.loadConstantFloat32(0.f, zero);
+    masm.subFloat32(zero, r0);
+    masm.subFloat32(zero, r1);
     masm.maxFloat32(r1, r0, HandleNaNSpecially(true));
     freeF32(r1);
     pushF32(r0);
 }
 
 void
 BaseCompiler::emitMinF64()
 {
     RegF64 r0, r1;
     pop2xF64(&r0, &r1);
-    if (!isCompilingAsmJS()) {
-        // Convert signaling NaN to quiet NaNs.
-        //
-        // TODO / OPTIMIZE (bug 1316824): see comment in emitMinF32.
-        ScratchF64 zero(*this);
-        masm.loadConstantDouble(0, zero);
-        masm.subDouble(zero, r0);
-        masm.subDouble(zero, r1);
-    }
+    // Convert signaling NaN to quiet NaNs.
+    //
+    // TODO / OPTIMIZE (bug 1316824): see comment in emitMinF32.
+    ScratchF64 zero(*this);
+    masm.loadConstantDouble(0, zero);
+    masm.subDouble(zero, r0);
+    masm.subDouble(zero, r1);
     masm.minDouble(r1, r0, HandleNaNSpecially(true));
     freeF64(r1);
     pushF64(r0);
 }
 
 void
 BaseCompiler::emitMaxF64()
 {
     RegF64 r0, r1;
     pop2xF64(&r0, &r1);
-    if (!isCompilingAsmJS()) {
-        // Convert signaling NaN to quiet NaNs.
-        //
-        // TODO / OPTIMIZE (bug 1316824): see comment in emitMinF32.
-        ScratchF64 zero(*this);
-        masm.loadConstantDouble(0, zero);
-        masm.subDouble(zero, r0);
-        masm.subDouble(zero, r1);
-    }
+    // Convert signaling NaN to quiet NaNs.
+    //
+    // TODO / OPTIMIZE (bug 1316824): see comment in emitMinF32.
+    ScratchF64 zero(*this);
+    masm.loadConstantDouble(0, zero);
+    masm.subDouble(zero, r0);
+    masm.subDouble(zero, r1);
     masm.maxDouble(r1, r0, HandleNaNSpecially(true));
     freeF64(r1);
     pushF64(r0);
 }
 
 void
 BaseCompiler::emitCopysignF32()
 {
@@ -6454,19 +6312,16 @@ BaseCompiler::emitTeeGlobal()
 // code by not moving a constant address with a zero offset into a register.
 
 BaseCompiler::RegI32
 BaseCompiler::popMemoryAccess(MemoryAccessDesc* access, bool* omitBoundsCheck)
 {
     // Caller must initialize.
     MOZ_ASSERT(!*omitBoundsCheck);
 
-    if (isCompilingAsmJS())
-        return popI32();
-
     int32_t addrTmp;
     if (popConstI32(addrTmp)) {
         uint32_t addr = addrTmp;
 
         // We can eliminate the bounds check if the sum of the constant address
         // and the known offset are below the sum of the minimum memory length
         // and the offset guard length.
 
@@ -6497,17 +6352,17 @@ BaseCompiler::emitLoad(ValType type, Sca
     LinearMemoryAddress<Nothing> addr;
     if (!iter_.readLoad(type, Scalar::byteSize(viewType), &addr))
         return false;
 
     if (deadCode_)
         return true;
 
     bool omitBoundsCheck = false;
-    MemoryAccessDesc access(viewType, addr.align, addr.offset, trapIfNotAsmJS());
+    MemoryAccessDesc access(viewType, addr.align, addr.offset, Some(trapOffset()));
 
     size_t temps = loadTemps(access);
     RegI32 tmp1 = temps >= 1 ? needI32() : invalidI32();
     RegI32 tmp2 = temps >= 2 ? needI32() : invalidI32();
     RegI32 tmp3 = temps >= 3 ? needI32() : invalidI32();
 
     switch (type) {
       case ValType::I32: {
@@ -6578,17 +6433,17 @@ template<bool isStore>
 bool
 BaseCompiler::emitStoreOrTeeStore(ValType resultType, Scalar::Type viewType,
                                   LinearMemoryAddress<Nothing> addr)
 {
     if (deadCode_)
         return true;
 
     bool omitBoundsCheck = false;
-    MemoryAccessDesc access(viewType, addr.align, addr.offset, trapIfNotAsmJS());
+    MemoryAccessDesc access(viewType, addr.align, addr.offset, Some(trapOffset()));
 
     size_t temps = storeTemps(access);
     RegI32 tmp1 = temps >= 1 ? needI32() : invalidI32();
 
     switch (resultType) {
       case ValType::I32: {
         RegI32 rv = popI32();
         RegI32 rp = popMemoryAccess(&access, &omitBoundsCheck);
@@ -6819,17 +6674,17 @@ BaseCompiler::emitTeeStoreWithCoercion(V
 
     if (deadCode_)
         return true;
 
     // TODO / OPTIMIZE (bug 1316831): Disable bounds checking on constant
     // accesses below the minimum heap length.
 
     bool omitBoundsCheck = false;
-    MemoryAccessDesc access(viewType, addr.align, addr.offset, trapIfNotAsmJS());
+    MemoryAccessDesc access(viewType, addr.align, addr.offset, Some(trapOffset()));
 
     size_t temps = storeTemps(access);
     RegI32 tmp1 = temps >= 1 ? needI32() : invalidI32();
 
     if (resultType == ValType::F32 && viewType == Scalar::Float64) {
         RegF32 rv = popF32();
         RegF64 rw = needF64();
         masm.convertFloat32ToDouble(rv, rw);
@@ -7796,33 +7651,23 @@ BaseCompiler::finish()
     MOZ_ASSERT(done(), "all bytes must be consumed");
     MOZ_ASSERT(func_.callSiteLineNums().length() == lastReadCallSite_);
 
     masm.flushBuffer();
 
     return offsets_;
 }
 
-static LiveRegisterSet
-volatileReturnGPR()
-{
-    GeneralRegisterSet rtn;
-    rtn.addAllocatable(ReturnReg);
-    return LiveRegisterSet(RegisterSet::VolatileNot(RegisterSet(rtn, FloatRegisterSet())));
-}
-
-LiveRegisterSet BaseCompiler::VolatileReturnGPR = volatileReturnGPR();
-
 } // wasm
 } // js
 
 bool
 js::wasm::BaselineCanCompile()
 {
-    // On all platforms we require signals for AsmJS/Wasm.
+    // On all platforms we require signals for Wasm.
     // If we made it this far we must have signals.
     MOZ_RELEASE_ASSERT(wasm::HaveSignalHandlers());
 
 #if defined(JS_CODEGEN_ARM)
     // Simplifying assumption: require SDIV and UDIV.
     //
     // I have no good data on ARM populations allowing me to say that
     // X% of devices in the market implement SDIV and UDIV.  However,
@@ -7838,16 +7683,17 @@ js::wasm::BaselineCanCompile()
     return false;
 #endif
 }
 
 bool
 js::wasm::BaselineCompileFunction(CompileTask* task, FuncCompileUnit* unit, UniqueChars *error)
 {
     MOZ_ASSERT(task->mode() == CompileMode::Baseline);
+    MOZ_ASSERT(task->env().kind == ModuleKind::Wasm);
 
     const FuncBytes& func = unit->func();
     uint32_t bodySize = func.bytes().length();
 
     Decoder d(func.bytes(), error);
 
     if (!ValidateFunctionBody(task->env(), func.index(), bodySize, d))
         return false;
--- a/js/xpconnect/tests/chrome/test_paris_weakmap_keys.xul
+++ b/js/xpconnect/tests/chrome/test_paris_weakmap_keys.xul
@@ -43,17 +43,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   }
 
   make_live_map();
 
   // RGBColor is a non-nsISupports refCounted class using WebIDL bindings.
 
   // non-nsISupports cycle-collected classes should fail as weak map keys.
-  let context = window.getComputedStyle(document.documentElement, null).getPropertyCSSValue("color").getRGBColorValue();
+  let context = window.getComputedStyle(document.documentElement).getPropertyCSSValue("color").getRGBColorValue();
   let contextFail = false;
   try {
     live_map.set(context, 2);
   } catch (e) {
     contextFail = true;
   }
 
   ok(contextFail, "Cycle collected non-nsISupports classes aren't allowed as weak map keys.");
--- a/layout/base/tests/test_bug435293-scale.html
+++ b/layout/base/tests/test_bug435293-scale.html
@@ -64,40 +64,40 @@ https://bugzilla.mozilla.org/show_bug.cg
   </div>
 </div>
 
 <pre id="test">
 <script type="application/javascript">
 runtests();
 
 function runtests() {
-  var style = window.getComputedStyle(document.getElementById("test1"), "");
+  var style = window.getComputedStyle(document.getElementById("test1"));
   is(style.getPropertyValue("-moz-transform"), "matrix(0.5, 0, 0, 1, 0, 0)",
      "Scalex proper matrix is applied");
 
-  style = window.getComputedStyle(document.getElementById("test2"), "");
+  style = window.getComputedStyle(document.getElementById("test2"));
   is(style.getPropertyValue("-moz-transform"), "matrix(1, 0, 0, 0.5, 0, 0)",
      "Scaley proper matrix is applied");
 
-  style = window.getComputedStyle(document.getElementById("test3"), "");
+  style = window.getComputedStyle(document.getElementById("test3"));
   is(style.getPropertyValue("-moz-transform"), "matrix(0.5, 0, 0, 0.5, 0, 0)",
      "Scale proper matrix is applied");
 
-  style = window.getComputedStyle(document.getElementById("test4"), "");
+  style = window.getComputedStyle(document.getElementById("test4"));
   is(style.getPropertyValue("-moz-transform"), "none",
      "Three dimensional scale should be ignored");
 
-  style = window.getComputedStyle(document.getElementById("test5"), "");
+  style = window.getComputedStyle(document.getElementById("test5"));
   is(style.getPropertyValue("-moz-transform"), "none",
      "Percent values in scale should be ignored");
 
-  style = window.getComputedStyle(document.getElementById("test6"), "");
+  style = window.getComputedStyle(document.getElementById("test6"));
   is(style.getPropertyValue("-moz-transform"), "matrix(640000, 0, 0, 1e-19, 0, 0)",
      "Ensure wacky values are accepted");
 
-  style = window.getComputedStyle(document.getElementById("test7"), "");
+  style = window.getComputedStyle(document.getElementById("test7"));
   is(style.getPropertyValue("-moz-transform"), "none",
      "No unit values allowed in scale");
 }
 </script>
 </pre>
 </body>
 </html>
--- a/layout/base/tests/test_bug435293-skew.html
+++ b/layout/base/tests/test_bug435293-skew.html
@@ -87,82 +87,82 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script type="application/javascript">
 runtests();
 
 function runtests() {
   // For test 1 we need to handle the contingency that different systems may
   // round differently.  We will parse out the values and compare them
   // individually.  The matrix should be: matrix(1, 0, 0.57735, 1, 0, 0)
-  var style = window.getComputedStyle(document.getElementById("test1"), "");
+  var style = window.getComputedStyle(document.getElementById("test1"));
   var tformStyle = style.getPropertyValue("-moz-transform");
   var tformValues = tformStyle.substring(tformStyle.indexOf('(') + 1,
                                          tformStyle.indexOf(')')).split(',');
   is((+tformValues[0]), 1, "Test1: skewx: param 0 is 1");
   is((+tformValues[1]), 0, "Test1: skewx: param 1 is 0");
   ok(verifyRounded(tformValues[2], 0.57735), "Test1: skewx: Rounded param 2 is in bounds");
   is((+tformValues[3]), 1, "Test1: skewx: param 3 is 1");
   is((+tformValues[4]), 0, "Test1: skewx: param 4 is 0");
   is((+tformValues[5]), 0, "Test1: skewx: param 5 is 0");
 
   // Again, handle rounding for test 2, proper matrix should be:
   // matrix(1, 1.73205, 0, 1, 0, 0)
-  style = window.getComputedStyle(document.getElementById("test2"), "");
+  style = window.getComputedStyle(document.getElementById("test2"));
   tformStyle = style.getPropertyValue("-moz-transform");
   tformValues = tformStyle.substring(tformStyle.indexOf('(') + 1,
                                      tformStyle.indexOf(')')).split(',');
   is((+tformValues[0]), 1, "Test2: skewy: param 0 is 1");
   ok(verifyRounded(tformValues[1], 1.73205), "Test2: skewy: Rounded param 1 is in bounds");
   is((+tformValues[2]), 0, "Test2: skewy: param 2 is 0");
   is((+tformValues[3]), 1, "Test2: skewy: param 3 is 1");
   is((+tformValues[4]), 0, "Test2: skewy: param 4 is 0");
   is((+tformValues[5]), 0, "Test2: skewy: param 5 is 0");
 
-  style = window.getComputedStyle(document.getElementById("test3"), "");
+  style = window.getComputedStyle(document.getElementById("test3"));
   is(style.getPropertyValue("-moz-transform"), "matrix(1, 1, 1, 1, 0, 0)",
      "Test3: Skew proper matrix is applied");
 
-  style = window.getComputedStyle(document.getElementById("test4"), "");
+  style = window.getComputedStyle(document.getElementById("test4"));
   is(style.getPropertyValue("-moz-transform"), "matrix(1, 1, 0, 1, 0, 0)",
      "Test4: Skew angle wrap: proper matrix is applied");
 
-  style = window.getComputedStyle(document.getElementById("test5"), "");
+  style = window.getComputedStyle(document.getElementById("test5"));
   is(style.getPropertyValue("-moz-transform"), "matrix(1, -1, 1, 1, 0, 0)",
      "Test5: Skew mixing deg and grad");
 
-  style = window.getComputedStyle(document.getElementById("test6"), "");
+  style = window.getComputedStyle(document.getElementById("test6"));
   is(style.getPropertyValue("-moz-transform"), "none",
      "Test6: Skew with invalid units");
 
-  style = window.getComputedStyle(document.getElementById("test7"), "");
+  style = window.getComputedStyle(document.getElementById("test7"));
   is(style.getPropertyValue("-moz-transform"), "none",
      "Test7: Skew with more invalid units");
 
   // Test 8: skew with negative degrees, here again we must handle rounding.
   // The matrix should be: matrix(1, 3.73206, -1, 1, 0, 0)
-  style = window.getComputedStyle(document.getElementById("test8"), "");
+  style = window.getComputedStyle(document.getElementById("test8"));
   tformStyle = style.getPropertyValue("-moz-transform");
   tformValues = tformStyle.substring(tformStyle.indexOf('(') + 1,
                                      tformStyle.indexOf(')')).split(',');
   is((+tformValues[0]), 1, "Test8: Test skew with negative degrees-param 0 is 1");
   ok(verifyRounded(tformValues[1], 3.73206), "Test8: Rounded param 1 is in bounds");
   is((+tformValues[2]), -1, "Test8: param 2 is -1");
   is((+tformValues[3]), 1, "Test8: param 3 is 1");
   is((+tformValues[4]), 0, "Test8: param 4 is 0");
   is((+tformValues[5]), 0, "Test8: param 5 is 0");
 
-  style = window.getComputedStyle(document.getElementById("test9"), "");
+  style = window.getComputedStyle(document.getElementById("test9"));
   is(style.getPropertyValue("-moz-transform"), "none",
      "Test9: Skew in 3d should be ignored");
 
-  style = window.getComputedStyle(document.getElementById("test10"), "");
+  style = window.getComputedStyle(document.getElementById("test10"));
   is(style.getPropertyValue("-moz-transform"), "matrix(1, -10000, 1, 1, 0, 0)",
      "Test10: Skew with nearly infinite numbers");
 
-  style = window.getComputedStyle(document.getElementById("test11"), "");
+  style = window.getComputedStyle(document.getElementById("test11"));
   is(style.getPropertyValue("-moz-transform"), "matrix(1, -10000, 10000, 1, 0, 0)",
      "Test11: Skew with more infinite numbers");
 }
 
 // Verifies that aVal is +/- 0.00001 of aTrueVal
 // Returns true if so, false if not
 function verifyRounded(aVal, aTrueVal) {
   return (Math.abs(aVal - aTrueVal).toFixed(5) <= 0.00001);
--- a/layout/forms/test/test_bug287446.html
+++ b/layout/forms/test/test_bug287446.html
@@ -28,34 +28,34 @@ addLoadEvent(function() {
   try {
     $("i").contentDocument.documentElement;
     accessed = true;
   } catch(e) {}
   is(accessed, false, "Shouldn't be able to access cross-site");
 
   $("i").style.display = "none";
   document.body.offsetWidth;
-  is(document.defaultView.getComputedStyle($("i"), "").display, "none",
+  is(document.defaultView.getComputedStyle($("i")).display, "none",
      "toggling display failed");
   $("i").style.display = "";
   document.body.offsetWidth;
-  is(document.defaultView.getComputedStyle($("i"), "").display, "inline",
+  is(document.defaultView.getComputedStyle($("i")).display, "inline",
      "toggling display back failed");
 
   $("i").contentWindow.postMessage("start", "*");
 });
 
 function continueTest() {
   $("i").style.display = "none";
   document.body.offsetWidth;
-  is(document.defaultView.getComputedStyle($("i"), "").display, "none",
+  is(document.defaultView.getComputedStyle($("i")).display, "none",
      "toggling display second time failed");
   $("i").style.display = "";
   document.body.offsetWidth;
-  is(document.defaultView.getComputedStyle($("i"), "").display, "inline",
+  is(document.defaultView.getComputedStyle($("i")).display, "inline",
      "toggling display back second time failed");
 
 $("i").contentWindow.postMessage("continue", "*");
 }
 
 window.addEventListener("message",
   function(evt) {
     var arr = evt.data.split(/ /).map(decodeURIComponent);
--- a/layout/forms/test/test_bug477531.html
+++ b/layout/forms/test/test_bug477531.html
@@ -25,41 +25,41 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 <input type="checkbox" id="s" />
 
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 477531 **/
-is(document.defaultView.getComputedStyle($("s"), null).getPropertyValue("margin-left"),
+is(document.defaultView.getComputedStyle($("s")).getPropertyValue("margin-left"),
    "10px",
    "Non-indeterminate checkbox should have a margin of 10px");
 
 $("s").indeterminate = true;
 
-is(document.defaultView.getComputedStyle($("s"), null).getPropertyValue("margin-left"),
+is(document.defaultView.getComputedStyle($("s")).getPropertyValue("margin-left"),
    "30px",
    "Indeterminate checkbox should have a margin of 30px");
 
 $("s").setAttribute("type", "radio");
 
-is(document.defaultView.getComputedStyle($("s"), null).getPropertyValue("margin-left"),
+is(document.defaultView.getComputedStyle($("s")).getPropertyValue("margin-left"),
    "30px",
    "Setting an indeterminate element to type radio should give it indeterminate styles");
 
 $("s").setAttribute("type", "checkbox");
 
-is(document.defaultView.getComputedStyle($("s"), null).getPropertyValue("margin-left"),
+is(document.defaultView.getComputedStyle($("s")).getPropertyValue("margin-left"),
    "30px",
    "Setting an indeterminate element to type checkbox should give it indeterminate styles");
 
 $("s").indeterminate = false;
 
-is(document.defaultView.getComputedStyle($("s"), null).getPropertyValue("margin-left"),
+is(document.defaultView.getComputedStyle($("s")).getPropertyValue("margin-left"),
    "10px",
    "Newly non-indeterminate checkbox should have a margin of 10px");
 
 </script>
 </pre>
 </body>
 </html>
 
--- a/layout/forms/test/test_bug477700.html
+++ b/layout/forms/test/test_bug477700.html
@@ -28,21 +28,21 @@ addLoadEvent(function() {
   try {
     $("i").contentDocument.documentElement;
     accessed = true;
   } catch(e) {}
   is(accessed, false, "Shouldn't be able to access cross-site");
 
   $("i").style.display = "none";
   document.body.offsetWidth;
-  is(document.defaultView.getComputedStyle($("i"), "").display, "none",
+  is(document.defaultView.getComputedStyle($("i")).display, "none",
      "toggling display failed");
   $("i").style.display = "";
   document.body.offsetWidth;
-  is(document.defaultView.getComputedStyle($("i"), "").display, "inline",
+  is(document.defaultView.getComputedStyle($("i")).display, "inline",
      "toggling display back failed");
 
   $("i").contentWindow.postMessage("start", "*");
 });
 
 window.addEventListener("message",
   function(evt) {
     var arr = evt.data.split(/ /).map(decodeURIComponent);
--- a/layout/generic/crashtests/641724.html
+++ b/layout/generic/crashtests/641724.html
@@ -102,17 +102,17 @@
             for (e in d)
                 if (a.call(d[e], e, d[e]) === false)
             for (var b = d[0]; i < length; b = d[++i]) { }
             return d
         },
         curCSS: function (f, l, k)
         {
             l = l.replace(/([A-Z])/g, "-$1").toLowerCase();
-            var c = document.defaultView.getComputedStyle(f, null);
+            var c = document.defaultView.getComputedStyle(f);
             c.getPropertyValue(l);
         },
         clean: function (l, h)
         {
             var k = [];
             D.each(l, function (i, d)
             {
                 var div = document.createElement("div");
--- a/layout/generic/test/test_bug323656.html
+++ b/layout/generic/test/test_bug323656.html
@@ -35,17 +35,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 323656 **/
-var s = document.defaultView.getComputedStyle($("testOption"), "");
+var s = document.defaultView.getComputedStyle($("testOption"));
 is(s.borderRightColor, "rgb(0, 128, 0)", "Inheritance broken");
 
 
 </script>
 </pre>
 </body>
 </html>
 
--- a/layout/generic/test/test_bug522632.html
+++ b/layout/generic/test/test_bug522632.html
@@ -19,14 +19,14 @@ https://bugzilla.mozilla.org/show_bug.cg
       </td>
     <tr>
   </table>  
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 522632 **/
-is(document.defaultView.getComputedStyle($("foo"), "").height, "100px",
+is(document.defaultView.getComputedStyle($("foo")).height, "100px",
    "Unexpected computed height");
 </script>
 </pre>
 </body>
 </html>
--- a/layout/reftests/bugs/371041-1.html
+++ b/layout/reftests/bugs/371041-1.html
@@ -37,13 +37,12 @@
 <div id="source10" class="source2" style="line-height: normal">TEST</div>
 <div id="source11" class="source2" style="line-height: 150%">TEST</div>
 <div id="source12" class="source2" style="line-height: 0.5">TEST</div>
 
 <script>
   var d = document;
   for (var i = 1; i <= 12; ++i) {
     d.getElementById("test" + i).style.height =
-      d.defaultView.getComputedStyle(d.getElementById("source" + i),
-                                     "").lineHeight;
+      d.defaultView.getComputedStyle(d.getElementById("source" + i)).lineHeight;
   }
 </script>
 </html>
--- a/layout/reftests/bugs/371043-1.html
+++ b/layout/reftests/bugs/371043-1.html
@@ -2,13 +2,12 @@
 <body>
   <div id="source" style="font-size: 10px; -moz-column-gap: 2ch">
     <span id="test"
           style="background: green; display: inline-block; height: 30px;
                  padding: 0 2px">
     </span>
     <script>
       document.getElementById("test").style.width =
-        document.defaultView.getComputedStyle(document.getElementById("source"),
-                                              "").MozColumnGap;
+        document.defaultView.getComputedStyle(document.getElementById("source")).MozColumnGap;
     </script>
   </div>
 </body>
--- a/layout/reftests/bugs/391909-1-ref.html
+++ b/layout/reftests/bugs/391909-1-ref.html
@@ -3,12 +3,12 @@
  <body>
    <div id="source" style="width: 3ch"></div>
    <div id="target" style="width: 0">
     This is a test
    </div>
    <script>
     document.getElementById("target").style.lineHeight =
       document.defaultView
-              .getComputedStyle(document.getElementById("source"), "").width;
+              .getComputedStyle(document.getElementById("source")).width;
    </script>
  </body>
 </html>
--- a/layout/reftests/cssom/computed-style-cross-window-ref.html
+++ b/layout/reftests/cssom/computed-style-cross-window-ref.html
@@ -19,32 +19,32 @@ function run() {
   var pout = document.getElementById("out");
   var poutnone = document.getElementById("outnone");
   var poutdet = document.createElement("p");
   var pin = i.contentDocument.getElementsByTagName("p")[0];
   var pinnone = i.contentDocument.getElementsByTagName("p")[1];
   var pindet = i.contentDocument.createElement("p");
 
   document.getElementById("res1").style.color =
-    window.getComputedStyle(pin, "").color;
+    window.getComputedStyle(pin).color;
 
   document.getElementById("res2").style.color =
-    i.contentWindow.getComputedStyle(pout, "").color;
+    i.contentWindow.getComputedStyle(pout).color;
 
   document.getElementById("res3").style.color =
-    window.getComputedStyle(pinnone, "").color;
+    window.getComputedStyle(pinnone).color;
 
   document.getElementById("res4").style.color =
-    i.contentWindow.getComputedStyle(poutnone, "").color;
+    i.contentWindow.getComputedStyle(poutnone).color;
 
   document.getElementById("res5").style.color =
-    window.getComputedStyle(pindet, "").color;
+    window.getComputedStyle(pindet).color;
 
   document.getElementById("res6").style.color =
-    i.contentWindow.getComputedStyle(poutdet, "").color;
+    i.contentWindow.getComputedStyle(poutdet).color;
 }
 
 </script>
 <body onload="run()">
 
 <p id="out">This is a paragraph outside the iframe.</p>
 <div style="display:none"><p id="outnone">This is a paragraph outside the iframe.</p></div>
 
--- a/layout/reftests/cssom/computed-style-cross-window.html
+++ b/layout/reftests/cssom/computed-style-cross-window.html
@@ -20,32 +20,32 @@ function run() {
   var pout = document.getElementById("out");
   var poutnone = document.getElementById("outnone");
   var poutdet = document.createElement("p");
   var pin = i.contentDocument.getElementsByTagName("p")[0];
   var pinnone = i.contentDocument.getElementsByTagName("p")[1];
   var pindet = i.contentDocument.createElement("p");
 
   document.getElementById("res1").style.color =
-    window.getComputedStyle(pin, "").color;
+    window.getComputedStyle(pin).color;
 
   document.getElementById("res2").style.color =
-    i.contentWindow.getComputedStyle(pout, "").color;
+    i.contentWindow.getComputedStyle(pout).color;
 
   document.getElementById("res3").style.color =
-    window.getComputedStyle(pinnone, "").color;
+    window.getComputedStyle(pinnone).color;
 
   document.getElementById("res4").style.color =
-    i.contentWindow.getComputedStyle(poutnone, "").color;
+    i.contentWindow.getComputedStyle(poutnone).color;
 
   document.getElementById("res5").style.color =
-    window.getComputedStyle(pindet, "").color;
+    window.getComputedStyle(pindet).color;
 
   document.getElementById("res6").style.color =
-    i.contentWindow.getComputedStyle(poutdet, "").color;
+    i.contentWindow.getComputedStyle(poutdet).color;
 
   document.documentElement.removeAttribute("class");
 }
 
 </script>
 <body onload="run()">
 
 <p id="out">This is a paragraph outside the iframe.</p>
--- a/layout/reftests/font-face/download-3-notref.html
+++ b/layout/reftests/font-face/download-3-notref.html
@@ -9,18 +9,18 @@
 	</style>
 </head>
 <body>
 
 <div id="t" style="visibility:hidden; width: -moz-fit-content">ABC</div>
 <script>
   document.body.offsetWidth;
   var n = document.getElementById("t");
-  var w = document.defaultView.getComputedStyle(n, "").width;
-  var h = document.defaultView.getComputedStyle(n, "").height;
+  var w = document.defaultView.getComputedStyle(n).width;
+  var h = document.defaultView.getComputedStyle(n).height;
   var d = document.createElement("div");
   d.style.width = w;
   d.style.height = h;
   d.style.backgroundColor = "green";
   n.parentNode.removeChild(n);
   document.body.appendChild(d);
 </script>
 </body>
--- a/layout/reftests/font-face/download-3-ref.html
+++ b/layout/reftests/font-face/download-3-ref.html
@@ -19,18 +19,18 @@
 
 <div id="t" style="visibility:hidden; width: -moz-fit-content">ABC</div>
 <script>
   // Force a reflow to make sure we start our font download now
   document.body.offsetWidth;
   window.addEventListener("load",
     function() {
       var n = document.getElementById("t");
-      var w = document.defaultView.getComputedStyle(n, "").width;
-      var h = document.defaultView.getComputedStyle(n, "").height;
+      var w = document.defaultView.getComputedStyle(n).width;
+      var h = document.defaultView.getComputedStyle(n).height;
       var d = document.createElement("div");
       d.style.width = w;
       d.style.height = h;
       d.style.backgroundColor = "green";
       n.parentNode.removeChild(n);
       document.body.appendChild(d);
     });
 </script>
--- a/layout/reftests/font-face/download-3.html
+++ b/layout/reftests/font-face/download-3.html
@@ -21,18 +21,18 @@
 <script>
   // Make sure to show our stuff as late as we can, so we only get reflows
   // from onload.  
   window.addEventListener("DOMContentLoaded",
     function() { document.documentElement.style.display = ""; })
   window.addEventListener("load",
     function() {
       var n = document.getElementById("t");
-      var w = document.defaultView.getComputedStyle(n, "").width;
-      var h = document.defaultView.getComputedStyle(n, "").height;
+      var w = document.defaultView.getComputedStyle(n).width;
+      var h = document.defaultView.getComputedStyle(n).height;
       var d = document.createElement("div");
       d.style.width = w;
       d.style.height = h;
       d.style.backgroundColor = "green";
       n.parentNode.removeChild(n);
       document.body.appendChild(d);
     });
 </script>
--- a/layout/reftests/text-overflow/scroll-rounding-ref.html
+++ b/layout/reftests/text-overflow/scroll-rounding-ref.html
@@ -1,9 +1,9 @@
-<!DOCTYPE HTML>
+<!DOCTYPE HTML>
 <!--
     Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/licenses/publicdomain/
 
     Test: 1px scroll rounding at the end position
 -->
 <html class="reftest-wait"><head>
 <title>text-overflow: scroll rounding</title>
--- a/layout/reftests/text-overflow/scroll-rounding.html
+++ b/layout/reftests/text-overflow/scroll-rounding.html
@@ -1,9 +1,9 @@
-<!DOCTYPE HTML>
+<!DOCTYPE HTML>
 <!--
     Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/licenses/publicdomain/
 
     Test: 1px scroll rounding at the end position
 -->
 <html class="reftest-wait"><head>
 <title>text-overflow: scroll rounding</title>
--- a/layout/reftests/text/lineheight-percentage-1.html
+++ b/layout/reftests/text/lineheight-percentage-1.html
@@ -1,6 +1,6 @@
 <!DOCTYPE html>
 <body style="font-size: 50px">
 <p style="line-height: 41%">
 <script>
-document.write(window.getComputedStyle(document.getElementsByTagName("p")[0], "").lineHeight);
+document.write(window.getComputedStyle(document.getElementsByTagName("p")[0]).lineHeight);
 </script>
--- a/layout/reftests/text/text-align-unsafe.html
+++ b/layout/reftests/text/text-align-unsafe.html
@@ -51,18 +51,18 @@
 </div>
 
 <div class=test5>
  <p>Lorem ipsum dolor sit amet.</p>
 </div>
 
 <script>
   var elem = document.querySelector('.test5 p');
-  var a = window.getComputedStyle(elem,null).getPropertyValue("text-align");
+  var a = window.getComputedStyle(elem).getPropertyValue("text-align");
   document.body.appendChild(document.createTextNode(a +"|"));
-  a = window.getComputedStyle(elem,null).getPropertyValue("text-align-last");
+  a = window.getComputedStyle(elem).getPropertyValue("text-align-last");
   document.body.appendChild(document.createTextNode(a));
 
   document.documentElement.removeAttribute('class');
 </script>
 
 </body>
 </html>
--- a/layout/style/crashtests/363950.html
+++ b/layout/style/crashtests/363950.html
@@ -5,16 +5,16 @@
 <body>
 This page should not crash Mozilla
 <script>
 var properties = ['margin-left','margin-right','margin-top','padding-bottom','padding-left','padding-right','padding-top'];
 
 function removestyles(i, j){
 if (j>=properties.length)
    j = 0;
-document.defaultView.getComputedStyle(document.getElementsByTagName('head')[0], null).getPropertyValue(properties[j]);
+document.defaultView.getComputedStyle(document.getElementsByTagName('head')[0]).getPropertyValue(properties[j]);
 j++;
 setTimeout(removestyles,50,j);
 }
 setTimeout(removestyles,500,0,0);
 </script>
 </body>
 </html>
--- a/layout/style/crashtests/368740.html
+++ b/layout/style/crashtests/368740.html
@@ -11,15 +11,15 @@ height: 400px;
 </head>
 <body>
 This page should not crash Mozilla<br>
 <iframe id="content" src="data:text/html;charset=utf-8,%3Chtml%3E%3Chead%3E%3C/head%3E%3Cbody%3E%0A%3Cbutton%3E%3C/button%3E%0A%3C/body%3E%3C/html%3E"></iframe>
 
 <script>
 function getComputedStyles(){
 var x=document.getElementById('content').contentDocument.getElementsByTagName('button')[0];
-var style = document.defaultView.getComputedStyle(x, null).getPropertyValue('border-left-width');
+var style = document.defaultView.getComputedStyle(x).getPropertyValue('border-left-width');
 }
 setTimeout(getComputedStyles,300);
 </script>
 
 </body>
 </html>
\ No newline at end of file
--- a/layout/style/crashtests/448161-2.html
+++ b/layout/style/crashtests/448161-2.html
@@ -1,9 +1,9 @@
 <html>
   <body>
     <script>
       var node = document.createElement("a");
       node.href = "http://www.mozilla.org";
-      document.defaultView.getComputedStyle(node, "").color
+      document.defaultView.getComputedStyle(node).color
     </script>
   </body>
 </html>
--- a/layout/style/crashtests/524252-1.html
+++ b/layout/style/crashtests/524252-1.html
@@ -1,10 +1,10 @@
 <html>
 <head><script>
 function boom()
 {
   var f = document.getElementById("f");
-  window.getComputedStyle(f, null).getPropertyValue("text-decoration");
+  window.getComputedStyle(f).getPropertyValue("text-decoration");
 }
 </script></head>
 <body onload="boom();"><font id="f" color="black">a</font></body>
 </html>
--- a/layout/style/crashtests/580685.html
+++ b/layout/style/crashtests/580685.html
@@ -1,10 +1,10 @@
 <html>
 <head></head>
 <body style="outline-offset: 0.1rem; ">
 <script>
 var body = document.body;
 document.removeChild(document.documentElement);
-var compstyle = window.getComputedStyle(body, null).getPropertyValue('outline-offset');
+var compstyle = window.getComputedStyle(body).getPropertyValue('outline-offset');
 </script>
 </body>
 </html>
\ No newline at end of file
--- a/layout/style/crashtests/822842.html
+++ b/layout/style/crashtests/822842.html
@@ -1,13 +1,13 @@
 <html>
   <head></head>
   <body></body>
   <script type="text/javascript">
-    window.x = window.getComputedStyle(document.documentElement, null).getPropertyCSSValue("transition-timing-function");
-    window.x = window.getComputedStyle(document.documentElement, null).getPropertyCSSValue("color");
+    window.x = window.getComputedStyle(document.documentElement).getPropertyCSSValue("transition-timing-function");
+    window.x = window.getComputedStyle(document.documentElement).getPropertyCSSValue("color");
     x.z = x.getRGBColorValue().blue;
     x.getRGBColor().blue.d = x;
     x= null;
     SpecialPowers.forceGC();
     SpecialPowers.forceCC();
   </script>
 </html>
--- a/layout/style/crashtests/840898.html
+++ b/layout/style/crashtests/840898.html
@@ -1,16 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
 <script>
 
 function boom()
 {
-  var styleDeclaration = window.getComputedStyle(document.createElement('div'), null);
+  var styleDeclaration = window.getComputedStyle(document.createElement('div'));
   var cursorValue = styleDeclaration.getPropertyCSSValue('cursor');
   cursorValue.item(1000);
 }
 
 </script>
 </head>
 
 <body onload="boom();"></body>
--- a/layout/style/test/bug453896_iframe.html
+++ b/layout/style/test/bug453896_iframe.html
@@ -8,17 +8,17 @@
   <script type="application/javascript; version=1.7">
 
 function run(test_window)
 {
   var subdoc = document.getElementById("subdoc").contentDocument;
   var subwin = document.getElementById("subdoc").contentWindow;
   var style = subdoc.getElementById("style");
   var iframe_style = document.getElementById("subdoc").style;
-  var body_cs = subdoc.defaultView.getComputedStyle(subdoc.body, "");
+  var body_cs = subdoc.defaultView.getComputedStyle(subdoc.body);
 
   function query_applies(q) {
     style.setAttribute("media", q);
     return body_cs.getPropertyValue("text-decoration") == "underline";
   }
 
   function should_apply(q) {
     test_window.ok(query_applies(q), q + " should apply");
--- a/layout/style/test/chrome/test_bug535806.xul
+++ b/layout/style/test/chrome/test_bug535806.xul
@@ -27,17 +27,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     }, false);
 
   function htmlLoaded() {
     $("f").setAttribute("src", "bug535806-xul.xul");
   }
 
   function xulLoaded() {
     var doc = $("f").contentDocument;
-    is(doc.defaultView.getComputedStyle(doc.getElementById("s"), null).color,
+    is(doc.defaultView.getComputedStyle(doc.getElementById("s")).color,
        "rgb(0, 128, 0)");
     SimpleTest.finish();
   }
 
 
   ]]>
   </script>
 </window>
--- a/layout/style/test/chrome/test_display_mode.html
+++ b/layout/style/test/chrome/test_display_mode.html
@@ -14,30 +14,29 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript">
 
 /** Test for Display Mode **/
 SimpleTest.waitForExplicitFinish();
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 function waitOneEvent(element, name) {
   return new Promise(function(resolve, reject) {
-    element.addEventListener(name, function listener() {
-      element.removeEventListener(name, listener);
+    element.addEventListener(name, function() {
       resolve();
-    });
+    }, {once: true});
   });
 }
 
 add_task(function* () {
   yield waitOneEvent(window, "load");
 
   var iframe = document.getElementById("subdoc");
   var subdoc = iframe.contentDocument;
   var style = subdoc.getElementById("style");
-  var bodyComputedStyled = subdoc.defaultView.getComputedStyle(subdoc.body, "");
+  var bodyComputedStyled = subdoc.defaultView.getComputedStyle(subdoc.body);
   var win = Services.wm.getMostRecentWindow("navigator:browser");
 
   function queryApplies(q) {
     style.setAttribute("media", q);
     return bodyComputedStyled.getPropertyValue("text-decoration") == "underline";
   }
 
   function shouldApply(q) {
--- a/layout/style/test/chrome/test_display_mode_reflow.html
+++ b/layout/style/test/chrome/test_display_mode_reflow.html
@@ -14,30 +14,29 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript">
 
 /** Test for Display Mode **/
 SimpleTest.waitForExplicitFinish();
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 function waitOneEvent(element, name) {
   return new Promise(function(resolve, reject) {
-    element.addEventListener(name, function listener() {
-      element.removeEventListener(name, listener);
+    element.addEventListener(name, function() {
       resolve();
-    });
+    }, {once: true});
   });
 }
 
 add_task(function* () {
   yield waitOneEvent(window, "load");
 
   var iframe = document.getElementById("subdoc");
   var subdoc = iframe.contentDocument;
   var style = subdoc.getElementById("style");
-  var bodyComputedStyled = subdoc.defaultView.getComputedStyle(subdoc.body, "");
+  var bodyComputedStyled = subdoc.defaultView.getComputedStyle(subdoc.body);
   var win = Services.wm.getMostRecentWindow("navigator:browser");
 
   var secondDiv = subdoc.getElementById("b");
   var offsetTop = secondDiv.offsetTop;
 
   // Test entering the OS's fullscreen mode.
   var fullScreenEntered = waitOneEvent(win, "sizemodechange");
   synthesizeKey("VK_F11", {});
--- a/layout/style/test/chrome/test_moz_document_rules.html
+++ b/layout/style/test/chrome/test_moz_document_rules.html
@@ -17,31 +17,31 @@ var [gStyleSheetService, gIOService] = (
             Components.classes["@mozilla.org/content/style-sheet-service;1"]
                 .getService(Components.interfaces.nsIStyleSheetService),
             Components.classes["@mozilla.org/network/io-service;1"]
                 .getService(Components.interfaces.nsIIOService)
            ];
 })();
 function set_user_sheet(sheeturi)
 {
-    var uri = gIOService.newURI(sheeturi, null, null);
+    var uri = gIOService.newURI(sheeturi);
     gStyleSheetService.loadAndRegisterSheet(uri, gStyleSheetService.USER_SHEET);
 }
 function remove_user_sheet(sheeturi)
 {
-    var uri = gIOService.newURI(sheeturi, null, null);
+    var uri = gIOService.newURI(sheeturi);
     gStyleSheetService.unregisterSheet(uri, gStyleSheetService.USER_SHEET);
 }
 
 function run()
 {
     var iframe = document.getElementById("iframe");
     var subdoc = iframe.contentDocument;
     var subwin = iframe.contentWindow;
-    var cs = subwin.getComputedStyle(subdoc.getElementById("display"), "");
+    var cs = subwin.getComputedStyle(subdoc.getElementById("display"));
     var zIndexCounter = 0;
 
     function test_document_rule(urltests, shouldapply)
     {
         var zIndex = ++zIndexCounter;
         var encodedRule = encodeURI("@-moz-document " + urltests + " { ") +
                           "%23" + // encoded hash character for "#display"
                           encodeURI("display { z-index: " + zIndex + " } }");
--- a/layout/style/test/newtab_share_rule_processors.html
+++ b/layout/style/test/newtab_share_rule_processors.html
@@ -10,13 +10,13 @@ var Ci = Components.interfaces;
 var sss = Cc["@mozilla.org/content/style-sheet-service;1"]
   .getService(Ci.nsIStyleSheetService);
 var io = Cc["@mozilla.org/network/io-service;1"]
   .getService(Ci.nsIIOService);
 var winUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
   .getInterface(Ci.nsIDOMWindowUtils);
 
 function addAgentSheet() {
-  var sheetURI = io.newURI("data:text/css,p{background-color:yellow}", null, null);
+  var sheetURI = io.newURI("data:text/css,p{background-color:yellow}");
   var sheet = sss.preloadSheet(sheetURI, Ci.nsIStyleSheetService.AGENT_SHEET);
   winUtils.addSheet(sheet, Ci.nsIDOMWindowUtils.AGENT_SHEET);
 }
 </script>
--- a/layout/style/test/test_acid3_test46.html
+++ b/layout/style/test/test_acid3_test46.html
@@ -81,17 +81,17 @@ function runTest() {
 	var p = doc.createElement('p');
 	p.id = names[i];
 	doc.body.appendChild(p);
   }
   var count = 0;
   var check = function (c, e) {
 	count += 1;
 	var p = doc.getElementById(c);
-	is(doc.defaultView.getComputedStyle(p, '').textTransform, e ? 'uppercase' : 'none', "case " + c + " failed (index " + count + ")");
+	is(doc.defaultView.getComputedStyle(p).textTransform, e ? 'uppercase' : 'none', "case " + c + " failed (index " + count + ")");
   }
   check('a', true); // 1
   check('b', false);
   check('c', true);
   check('d', false);
   check('e', false);
   check('f', false); // true in old spec; commented out in real Acid3
   check('g', false);
--- a/layout/style/test/test_addSheet.html
+++ b/layout/style/test/test_addSheet.html
@@ -16,27 +16,27 @@
 
 let gIOService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
   .getService(SpecialPowers.Ci.nsIIOService);
 
 let gSSService = SpecialPowers.Cc["@mozilla.org/content/style-sheet-service;1"]
   .getService(SpecialPowers.Ci.nsIStyleSheetService);
 
 function test(win, sheet) {
-    let cs = win.getComputedStyle(win.document.body, null);
+    let cs = win.getComputedStyle(win.document.body);
     is(cs.getPropertyValue('color'), "rgb(0, 0, 0)", "should have default color");
     var windowUtils = SpecialPowers.wrap(win)
       .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
       .getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
     windowUtils.addSheet(sheet, SpecialPowers.Ci.nsIDOMWindowUtils.USER_SHEET);
     is(cs.getPropertyValue('color'), "rgb(255, 0, 0)", "should have changed color to red");
 }
 
 function run() {
-    var uri = gIOService.newURI("data:text/css,body{color:red;}", null, null);
+    var uri = gIOService.newURI("data:text/css,body{color:red;}");
     let sheet = gSSService.preloadSheet(uri, SpecialPowers.Ci.nsIStyleSheetService.USER_SHEET);
 
     test(document.getElementById("iframe1").contentWindow, sheet);
     test(document.getElementById("iframe2").contentWindow, sheet);
 
     SimpleTest.finish();
 }
 
--- a/layout/style/test/test_additional_sheets.html
+++ b/layout/style/test/test_additional_sheets.html
@@ -55,26 +55,26 @@ function removeAgentSheet(win, style)
 
 function removeAuthorSheet(win, style)
 {
   removeSheet(win, style, "AUTHOR_SHEET");
 }
 
 function loadSheet(win, style, type)
 {
-  var uri = gIOService.newURI(getUri(style), null, null);
+  var uri = gIOService.newURI(getUri(style));
   var windowUtils = SpecialPowers.wrap(win)
     .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
     .getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
   windowUtils.loadSheet(uri, windowUtils[type]);
 }
 
 function removeSheet(win, style, type)
 {
-  var uri = gIOService.newURI(getUri(style), null, null);
+  var uri = gIOService.newURI(getUri(style));
   var windowUtils = SpecialPowers.wrap(win)
     .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
     .getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
   windowUtils.removeSheet(uri, windowUtils[type]);
 }
 
 function loadAndRegisterUserSheet(win, style)
 {
@@ -103,24 +103,24 @@ function unregisterAgentSheet(win, style
 
 function unregisterAuthorSheet(win, style)
 {
   unregisterSheet(win, style, "AUTHOR_SHEET");
 }
 
 function loadAndRegisterSheet(win, style, type)
 {
-  uri = gIOService.newURI(getUri(style), null, null);
+  uri = gIOService.newURI(getUri(style));
   gSSService.loadAndRegisterSheet(uri, gSSService[type]);
   is(gSSService.sheetRegistered(uri, gSSService[type]), true);
 }
 
 function unregisterSheet(win, style, type)
 {
-  var uri = gIOService.newURI(getUri(style), null, null);
+  var uri = gIOService.newURI(getUri(style));
   gSSService.unregisterSheet(uri, gSSService[type]);
   is(gSSService.sheetRegistered(uri, gSSService[type]), false);
 }
 
 function setDocSheet(win, style)
 {
   var subdoc = win.document;
   var headID = subdoc.getElementsByTagName("head")[0];
@@ -190,17 +190,17 @@ var author = {
 function loadAndCheck(win, firstType, secondType, swap, result1, result2)
 {
   var firstStyle = getStyle(firstType.color, false);
   var secondStyle = getStyle(secondType.color, swap);
 
   firstType.addRules(win, firstStyle);
   secondType.addRules(win, secondStyle);
 
-  var cs = win.getComputedStyle(win.document.body, null);
+  var cs = win.getComputedStyle(win.document.body);
   is(cs.getPropertyValue('color'), result1,
     firstType.type + "(normal)" + " vs " + secondType.type + (swap ? "(important)" : "(normal)" ) + " 1");
   is(cs.getPropertyValue('background-color'), result2,
     firstType.type + "(important)" + " vs " + secondType.type + (swap ? "(normal)" : "(important)" ) + " 2");
 
   firstType.removeRules(win, firstStyle);
   secondType.removeRules(win, secondStyle);
 
--- a/layout/style/test/test_align_justify_computed_values.html
+++ b/layout/style/test/test_align_justify_computed_values.html
@@ -27,32 +27,32 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script type="application/javascript">
 "use strict";
 
 /*
  * Utility function for getting computed style of "align-self":
  */
 function getComputedAlignSelf(elem) {
-  return window.getComputedStyle(elem, "").alignSelf;
+  return window.getComputedStyle(elem).alignSelf;
 }
 function getComputedAlignItems(elem) {
-  return window.getComputedStyle(elem, "").alignItems;
+  return window.getComputedStyle(elem).alignItems;
 }
 function getComputedAlignContent(elem) {
-  return window.getComputedStyle(elem, "").alignContent;
+  return window.getComputedStyle(elem).alignContent;
 }
 function getComputedJustifySelf(elem) {
-  return window.getComputedStyle(elem, "").justifySelf;
+  return window.getComputedStyle(elem).justifySelf;
 }
 function getComputedJustifyItems(elem) {
-  return window.getComputedStyle(elem, "").justifyItems;
+  return window.getComputedStyle(elem).justifyItems;
 }
 function getComputedJustifyContent(elem) {
-  return window.getComputedStyle(elem, "").justifyContent;
+  return window.getComputedStyle(elem).justifyContent;
 }
 
 /**
  * Test behavior of 'align-self:auto' (Bug 696253 and Bug 1304012)
  * ===============================================
  *
  * In a previous revision of the CSS Alignment spec, align-self:auto
  * was required to actually *compute* to the parent's align-items value --
--- a/layout/style/test/test_bug1292447.html
+++ b/layout/style/test/test_bug1292447.html
@@ -272,17 +272,17 @@ doATest("height", "minmaxheight5-", 320,
 doATest("height", "minmaxheight6-", 320, 0, true);
 doATest("height", "minmaxheight7-", 600, 0, true);
 doATest("height", "minmaxheight8-", 200, 0, true);
 doATest("height", "minmaxheight9-", 200, 0, true);
 doATest("height", "minmaxheight10-", 600, 0, true);
 doATest("height", "minmaxheight11-", 600, 0, true);
 
 function style(id) {
-  return document.defaultView.getComputedStyle($(id), "");
+  return document.defaultView.getComputedStyle($(id));
 }
 
 function round(num, decimals) {
   return Math.round(num * Math.pow(10, decimals)) / Math.pow(10, decimals);
 }
 
 function coordValueTest(camelProp, cssProp, decl, coordVal, prettyName) {
   is(decl[camelProp], coordVal + "px", prettyName);
--- a/layout/style/test/test_bug319381.html
+++ b/layout/style/test/test_bug319381.html
@@ -15,22 +15,22 @@ https://bugzilla.mozilla.org/show_bug.cg
   <div id="t"></div>  
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 319381 **/
 
 function c() {
-  return document.defaultView.getComputedStyle($('t'), "").
+  return document.defaultView.getComputedStyle($('t')).
     getPropertyValue("overflow");
 }
 
 function cval() {
-  return document.defaultView.getComputedStyle($('t'), "").
+  return document.defaultView.getComputedStyle($('t')).
     getPropertyCSSValue("overflow");
 }
 
 var vals = ["visible", "hidden", "auto", "scroll"];
 var mozVals = ["-moz-scrollbars-vertical", "-moz-scrollbars-horizontal"];
 var i, j;
 
 for (i = 0; i < vals.length; ++i) {
--- a/layout/style/test/test_bug363146.html
+++ b/layout/style/test/test_bug363146.html
@@ -31,31 +31,31 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 </div>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
-var c = window.getComputedStyle(document.getElementById("t1"), "");
+var c = window.getComputedStyle(document.getElementById("t1"));
 is(c.width, "420px");
 is(c.height, "120px");
 is(c.left, "50px");
 is(c.top, "35px");
 is(c.borderLeftWidth, "10px");
 is(c.borderRightWidth, "10px");
 is(c.borderTopWidth, "10px");
 is(c.borderBottomWidth, "10px");
 is(c.marginLeft, "20px");
 is(c.marginRight, "20px");
 is(c.marginTop, "20px");
 is(c.marginBottom, "20px");
 
-var c2 = window.getComputedStyle(document.getElementById("t2"), "");
+var c2 = window.getComputedStyle(document.getElementById("t2"));
 is(c2.marginLeft, "20px");
 is(c2.marginRight, "20px");
 is(c2.marginTop, "20px");
 is(c2.marginBottom, "20px");
 
 </script>
 </pre>
 </body>
--- a/layout/style/test/test_bug379440.html
+++ b/layout/style/test/test_bug379440.html
@@ -48,17 +48,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 379440 **/
 
 function cur(id) {
-  return document.defaultView.getComputedStyle($(id), "").cursor;
+  return document.defaultView.getComputedStyle($(id)).cursor;
 }
 
 is(cur("t1"), 'url("file:///tmp/foo"), url("file:///c:/"), ' +
               'url("http://example.com/"), crosshair',
               "Serialize unloadable URLs using their specified value");
 is(cur("t2"), 'url("file:///tmp/foo"), url("file:///c:/"), crosshair',
               "Serialize unloadable URLs using their specified value");
 is(cur("t3"), 'url("http://example.com/"), crosshair', "URI + fallback");
--- a/layout/style/test/test_bug391034.html
+++ b/layout/style/test/test_bug391034.html
@@ -20,17 +20,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <div id="content" style="display: none">
   <div id="four" style="position: relative; left: 10%; bottom: 20%"></div>  
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 391034 **/
 function getComp(id) {
- return document.defaultView.getComputedStyle($(id), "");
+ return document.defaultView.getComputedStyle($(id));
 }
 
 is(getComp("one").top, "-" + getComp("width-ref2").width,
    "Incorrect computed top offset if specified in ch")
 is(getComp("one").right, "-" + getComp("width-ref").width,
    "Incorrect computed right offset if specified in ch")
 is(getComp("one").bottom, getComp("width-ref2").width,
    "Incorrect computed bottom offset if specified in ch")
--- a/layout/style/test/test_bug391221.html
+++ b/layout/style/test/test_bug391221.html
@@ -20,17 +20,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <div id="three" style="width: 1000ch; max-width: 2px"></div>
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 391221 **/
 function getComp(id) {
- return document.defaultView.getComputedStyle($(id), "");
+ return document.defaultView.getComputedStyle($(id));
 }
 
 is(getComp("one").width, getComp("width-ref").width,
    "max-width in ch units not working?");
 
 is(getComp("two").width, getComp("width-ref").width,
    "min-width in ch units not working?");
 
--- a/layout/style/test/test_bug397427.html
+++ b/layout/style/test/test_bug397427.html
@@ -32,29 +32,29 @@ https://bugzilla.mozilla.org/show_bug.cg
 /** Test for Bug 397427 **/
 SimpleTest.waitForExplicitFinish();
 
 addLoadEvent(function() {
   is($("a").sheet.href, null, "href should be null");
   is(typeof($("a").sheet.href), "object", "should be actual null");
 
   // Make sure the redirected sheets are loaded and have the right base URI
-  is(document.defaultView.getComputedStyle($("one"), "").color,
+  is(document.defaultView.getComputedStyle($("one")).color,
      "rgb(0, 128, 0)", "Redirect 1 did not work");
-  is(document.defaultView.getComputedStyle($("one"), "").backgroundImage,
+  is(document.defaultView.getComputedStyle($("one")).backgroundImage,
      "url(\"http://example.org/tests/layout/style/test/post-redirect-1.css#\")",
       "Redirect 1 did not get right base URI");
-  is(document.defaultView.getComputedStyle($("two"), "").color,
+  is(document.defaultView.getComputedStyle($("two")).color,
      "rgb(0, 128, 0)", "Redirect 2 did not work");
-  is(document.defaultView.getComputedStyle($("two"), "").backgroundImage,
+  is(document.defaultView.getComputedStyle($("two")).backgroundImage,
      "url(\"http://example.org/tests/layout/style/test/post-redirect-2.css#\")",
       "Redirect 2 did not get right base URI");
-  is(document.defaultView.getComputedStyle($("three"), "").color,
+  is(document.defaultView.getComputedStyle($("three")).color,
      "rgb(0, 128, 0)", "Redirect 3 did not work");
-  is(document.defaultView.getComputedStyle($("three"), "").backgroundImage,
+  is(document.defaultView.getComputedStyle($("three")).backgroundImage,
      "url(\"http://example.org/tests/layout/style/test/post-redirect-3.css#\")",
       "Redirect 3 did not get right base URI");
 
   var ruleList = $("a").sheet.cssRules;
 
   var redirHrefBase =
     window.location.href.replace(/test_bug397427.html$/,
       "redirect.sjs?http://example.org/tests/layout/style/test/post-");
--- a/layout/style/test/test_bug399349.html
+++ b/layout/style/test/test_bug399349.html
@@ -31,47 +31,47 @@ https://bugzilla.mozilla.org/show_bug.cg
                        position:relative;"></div>
 
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
-var a1 = window.getComputedStyle(document.getElementById("Aone"), "");
+var a1 = window.getComputedStyle(document.getElementById("Aone"));
 is(a1.width, "100px");
 is(a1.height, "400px");
 is(a1.top, "-100px");
 is(a1.left, "-200px");
 
-var a2 = window.getComputedStyle(document.getElementById("Atwo"), "");
+var a2 = window.getComputedStyle(document.getElementById("Atwo"));
 is(a2.width, "150.2px");
 is(a2.height, "450.25px");
 is(a2.top, "-150.2px");
 is(a2.left, "-450.25px");
 
-var a3 = window.getComputedStyle(document.getElementById("Athree"), "");
+var a3 = window.getComputedStyle(document.getElementById("Athree"));
 is(a3.width, "0.1px");
 is(a3.height, "0.3px");
 is(a3.top, "-0.1px");
 is(a3.left, "-0.3px");
 
-var a4 = window.getComputedStyle(document.getElementById("Afour"), "");
+var a4 = window.getComputedStyle(document.getElementById("Afour"));
 is(a4.width, "100.017px");
 is(a4.height, "400.017px");
 is(a4.top, "-0.116667px");
 is(a4.left, "-0.216667px");
 
-var a5 = window.getComputedStyle(document.getElementById("Afive"), "");
+var a5 = window.getComputedStyle(document.getElementById("Afive"));
 is(a5.width, "2345px");
 is(a5.height, "456px");
 is(a5.top, "-2123px");
 is(a5.left, "-6544px");
 
-var a6 = window.getComputedStyle(document.getElementById("Asix"), "");
+var a6 = window.getComputedStyle(document.getElementById("Asix"));
 is(a6.width, "12px");
 is(a6.height, "37.45px");
 is(a6.top, "-23px");
 is(a6.left, "-44.45px");
 
 </script>
 
 </script>
--- a/layout/style/test/test_bug412901.html
+++ b/layout/style/test/test_bug412901.html
@@ -18,25 +18,25 @@ https://bugzilla.mozilla.org/show_bug.cg
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 412901 **/
 
 var div = document.getElementById("testDiv");
-var computedStyle = document.defaultView.getComputedStyle(div, "");
+var computedStyle = document.defaultView.getComputedStyle(div);
 // we never round down to 0px, very small widths are rounded up to 1px
 is(computedStyle.borderLeftWidth, "1px");
 is(computedStyle.borderRightWidth, "0px");
 is(computedStyle.borderTopWidth, "2px");
 is(computedStyle.borderBottomWidth, "5px");
 
 var div2 = document.getElementById("testDiv2");
-var computedStyle2 = document.defaultView.getComputedStyle(div2, "");
+var computedStyle2 = document.defaultView.getComputedStyle(div2);
 is(computedStyle2.borderLeftWidth, "0px");
 is(computedStyle2.borderRightWidth, "0px");
 is(computedStyle2.borderTopWidth, "0px");
 is(computedStyle2.borderBottomWidth, "0px");
 </script>
 </pre>
 </body>
 </html>
--- a/layout/style/test/test_bug413958.html
+++ b/layout/style/test/test_bug413958.html
@@ -57,17 +57,17 @@ var results = [
       sourceLine: "200" } ],
 ];
 var curTest = -1;
 
 function doTest() {
   if (++curTest == tests.length) {
     var ss = document.getElementsByTagName("span");
     for (var i = 0; i < ss.length; i++) {
-      is(window.getComputedStyle(ss[i], "").color, "rgb(0, 0, 0)",
+      is(window.getComputedStyle(ss[i]).color, "rgb(0, 0, 0)",
          "recovery | " + ss[i].id);
     }
     SimpleTest.finish();
   } else {
     SimpleTest.expectConsoleMessages(tests[curTest], results[curTest], doTest);
   }
 }
 
--- a/layout/style/test/test_bug437915.html
+++ b/layout/style/test/test_bug437915.html
@@ -21,17 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 437915 **/
 
 var div = document.getElementById("content");
-var cs = document.defaultView.getComputedStyle(div, "");
+var cs = document.defaultView.getComputedStyle(div);
 
 var chars = {
   0x09: true, // tab
   0x0a: true, // newline
   0x0b: false, // vertical tab (MAY CHANGE IN FUTURE!)
   0x0c: true, // form feed
   0x0d: true, // carriage return
   0x0e: false,
--- a/layout/style/test/test_bug450191.html
+++ b/layout/style/test/test_bug450191.html
@@ -21,21 +21,21 @@ SimpleTest.waitForExplicitFinish();
 function run() {
   var iframe = document.getElementById("display");
   var subdoc = iframe.contentDocument;
   var subwin = iframe.contentWindow;
 
   var doctext = "<div style='font-size: 2em'>div text <table><tr><td id='t'>table text</td></tr></table></div>";
 
   function subdoc_body_font() {
-    return subwin.getComputedStyle(subdoc.body, "").fontSize;
+    return subwin.getComputedStyle(subdoc.body).fontSize;
   }
 
   function subdoc_cell_font() {
-    return subwin.getComputedStyle(subdoc.getElementById("t"), "").fontSize;
+    return subwin.getComputedStyle(subdoc.getElementById("t")).fontSize;
   }
 
   subdoc.open();
   subdoc.write(doctext);
   subdoc.close();
 
   is(subdoc_cell_font(), subdoc_body_font(),
         "Quirks style sheet should be applied.");
--- a/layout/style/test/test_bug470769.html
+++ b/layout/style/test/test_bug470769.html
@@ -17,15 +17,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 470769 **/
 
 var e = document.getElementById("display");
 e.setAttribute("style", "z-index: 2147483647"); // maximum signed 32-bit
 is(e.style.zIndex, "2147483647", "element.style should roundtrip correctly");
-is(window.getComputedStyle(e, "").zIndex, "2147483647",
+is(window.getComputedStyle(e).zIndex, "2147483647",
    "getComputedStyle should roundtrip correctly");
 
 </script>
 </pre>
 </body>
 </html>
--- a/layout/style/test/test_bug580685.html
+++ b/layout/style/test/test_bug580685.html
@@ -21,18 +21,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 <script type="application/javascript">
 
 /** Test for Bug 580685 **/
 SimpleTest.waitForExplicitFinish()
 addLoadEvent(function() {
   var doc = $("f").contentDocument;
   var b = doc.body;
   doc.removeChild(doc.documentElement);
-  is(doc.defaultView.getComputedStyle(b, "").outlineOffset,
-     doc.defaultView.getComputedStyle(b, "").fontSize,
+  is(doc.defaultView.getComputedStyle(b).outlineOffset,
+     doc.defaultView.getComputedStyle(b).fontSize,
      "1rem did not compute correctly");
   SimpleTest.finish();
 });
 
 
 
 
 </script>
--- a/layout/style/test/test_bug635286.html
+++ b/layout/style/test/test_bug635286.html
@@ -29,17 +29,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 window.addEventListener("load", function() {
   var cases = Array.slice(document.getElementsByTagName("div"));
   cases.forEach(function(aCase, aIndex) {
     aCase.className = "after";
   });
   window.setTimeout(function() {
     cases.forEach(function(aCase, aIndex) {
-      is(window.getComputedStyle(aCase, null)
+      is(window.getComputedStyle(aCase)
            .getPropertyValue("background-color"),
          "transparent",
          aCase.textContent);
     });
     SimpleTest.finish();
   }, 1);
 });
 
--- a/layout/style/test/test_bug652486.html
+++ b/layout/style/test/test_bug652486.html
@@ -18,17 +18,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <div id="t"></div>  
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 652486 and Bug 1039488 **/
 
 function c() {
-  return document.defaultView.getComputedStyle($('t'), "").
+  return document.defaultView.getComputedStyle($('t')).
            getPropertyValue("text-decoration");
 }
 
 var tests = [
   // When only text-decoration was specified, text-decoration should look like
   // a longhand property.
   { decoration: "none",
     line: null, color: null, style: null,
@@ -148,17 +148,17 @@ function makeDeclaration(aTest)
 }
 
 function clearStyleObject()
 {
   $('t').style.textDecoration = null;
 }
 
 function testCSSValue(testname, test, dec) {
-  var val = document.defaultView.getComputedStyle($('t'), "").
+  var val = document.defaultView.getComputedStyle($('t')).
               getPropertyCSSValue("text-decoration");
   isnot(val, null, testname + " (CSS value): " + dec);
 
   if (typeof test.expectedCSSValue == "string") {
     is(val.getStringValue(), test.expectedCSSValue, testname + " (CSS value): " + dec);
     return;
   }
 
--- a/layout/style/test/test_bug664955.html
+++ b/layout/style/test/test_bug664955.html
@@ -18,19 +18,19 @@ https://bugzilla.mozilla.org/show_bug.cg
 </span>
 </p>
 <div id="content" style="display: none">
 
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 /** Test for Bug 664955 **/
-var parentSize = document.defaultView.getComputedStyle($('display'), "").fontSize;
-var largerSize = document.defaultView.getComputedStyle($('larger'), "").fontSize;
-var largerAgainSize = document.defaultView.getComputedStyle($('larger-again'), "").fontSize;
+var parentSize = document.defaultView.getComputedStyle($('display')).fontSize;
+var largerSize = document.defaultView.getComputedStyle($('larger')).fontSize;
+var largerAgainSize = document.defaultView.getComputedStyle($('larger-again')).fontSize;