merge mozilla-inbound to mozilla-central a=merge
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Sun, 12 Jun 2016 11:26:13 +0200
changeset 341677 016e0f47e8ad66ba6eb11fe28958e3a69ef9e53d
parent 341506 9694e371363590c8dace6629dc4d57f1af7206f2 (current diff)
parent 341676 60b340e55efe365fb45afd8f5ca7f4b53a73b2dd (diff)
child 341684 6f78f70eb2ee57fb0b65b99ebc9a5a55ffd88f9f
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone50.0a1
first release with
nightly linux32
016e0f47e8ad / 50.0a1 / 20160612030220 / files
nightly linux64
016e0f47e8ad / 50.0a1 / 20160612030220 / files
nightly mac
016e0f47e8ad / 50.0a1 / 20160612030220 / files
nightly win32
016e0f47e8ad / 50.0a1 / 20160612030220 / files
nightly win64
016e0f47e8ad / 50.0a1 / 20160612030220 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
merge mozilla-inbound to mozilla-central a=merge
browser/themes/linux/browser.css
dom/plugins/ipc/TaskFactory.h
toolkit/mozapps/update/tests/data/complete_log_success
toolkit/mozapps/update/tests/data/partial_log_failure
toolkit/mozapps/update/tests/data/partial_log_success
tools/lint/mach_commands.py
tools/mercurial/hgsetup/__init__.py
tools/mercurial/hgsetup/config.py
tools/mercurial/hgsetup/update.py
tools/mercurial/hgsetup/wizard.py
tools/mercurial/mach_commands.py
--- a/accessible/atk/AccessibleWrap.cpp
+++ b/accessible/atk/AccessibleWrap.cpp
@@ -14,17 +14,16 @@
 #include "OuterDocAccessible.h"
 #include "ProxyAccessible.h"
 #include "RootAccessible.h"
 #include "TableAccessible.h"
 #include "TableCellAccessible.h"
 #include "nsMai.h"
 #include "nsMaiHyperlink.h"
 #include "nsString.h"
-#include "nsAutoPtr.h"
 #include "prprf.h"
 #include "nsStateMap.h"
 #include "mozilla/a11y/Platform.h"
 #include "Relation.h"
 #include "RootAccessible.h"
 #include "States.h"
 #include "nsISimpleEnumerator.h"
 
--- a/accessible/atk/ApplicationAccessibleWrap.cpp
+++ b/accessible/atk/ApplicationAccessibleWrap.cpp
@@ -3,17 +3,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ApplicationAccessibleWrap.h"
 
 #include "nsCOMPtr.h"
 #include "nsMai.h"
-#include "nsAutoPtr.h"
 #include "nsAccessibilityService.h"
 
 #include <gtk/gtk.h>
 #include <atk/atk.h>
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 
--- a/accessible/base/FocusManager.h
+++ b/accessible/base/FocusManager.h
@@ -1,17 +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/. */
 
 #ifndef mozilla_a11y_FocusManager_h_
 #define mozilla_a11y_FocusManager_h_
 
-#include "nsAutoPtr.h"
-
 class nsINode;
 class nsIDocument;
 class nsISupports;
 
 namespace mozilla {
 namespace a11y {
 
 class AccEvent;
--- a/accessible/base/SelectionManager.cpp
+++ b/accessible/base/SelectionManager.cpp
@@ -54,24 +54,22 @@ SelectionManager::ClearControlSelectionL
   const nsFrameSelection* frameSel = mCurrCtrlFrame->GetConstFrameSelection();
   NS_ASSERTION(frameSel, "No frame selection for the element!");
 
   mCurrCtrlFrame = nullptr;
   if (!frameSel)
     return;
 
   // Remove 'this' registered as selection listener for the normal selection.
-  Selection* normalSel =
-    frameSel->GetSelection(nsISelectionController::SELECTION_NORMAL);
+  Selection* normalSel = frameSel->GetSelection(SelectionType::eNormal);
   normalSel->RemoveSelectionListener(this);
 
   // Remove 'this' registered as selection listener for the spellcheck
   // selection.
-  Selection* spellSel =
-    frameSel->GetSelection(nsISelectionController::SELECTION_SPELLCHECK);
+  Selection* spellSel = frameSel->GetSelection(SelectionType::eSpellCheck);
   spellSel->RemoveSelectionListener(this);
 }
 
 void
 SelectionManager::SetControlSelectionListener(dom::Element* aFocusedElm)
 {
   // When focus moves such that the caret is part of a new frame selection
   // this removes the old selection listener and attaches a new one for
@@ -83,56 +81,50 @@ SelectionManager::SetControlSelectionLis
     return;
 
   const nsFrameSelection* frameSel = mCurrCtrlFrame->GetConstFrameSelection();
   NS_ASSERTION(frameSel, "No frame selection for focused element!");
   if (!frameSel)
     return;
 
   // Register 'this' as selection listener for the normal selection.
-  Selection* normalSel =
-    frameSel->GetSelection(nsISelectionController::SELECTION_NORMAL);
+  Selection* normalSel = frameSel->GetSelection(SelectionType::eNormal);
   normalSel->AddSelectionListener(this);
 
   // Register 'this' as selection listener for the spell check selection.
-  Selection* spellSel =
-    frameSel->GetSelection(nsISelectionController::SELECTION_SPELLCHECK);
+  Selection* spellSel = frameSel->GetSelection(SelectionType::eSpellCheck);
   spellSel->AddSelectionListener(this);
 }
 
 void
 SelectionManager::AddDocSelectionListener(nsIPresShell* aPresShell)
 {
   const nsFrameSelection* frameSel = aPresShell->ConstFrameSelection();
 
   // Register 'this' as selection listener for the normal selection.
-  Selection* normalSel =
-    frameSel->GetSelection(nsISelectionController::SELECTION_NORMAL);
+  Selection* normalSel = frameSel->GetSelection(SelectionType::eNormal);
   normalSel->AddSelectionListener(this);
 
   // Register 'this' as selection listener for the spell check selection.
-  Selection* spellSel =
-    frameSel->GetSelection(nsISelectionController::SELECTION_SPELLCHECK);
+  Selection* spellSel = frameSel->GetSelection(SelectionType::eSpellCheck);
   spellSel->AddSelectionListener(this);
 }
 
 void
 SelectionManager::RemoveDocSelectionListener(nsIPresShell* aPresShell)
 {
   const nsFrameSelection* frameSel = aPresShell->ConstFrameSelection();
 
   // Remove 'this' registered as selection listener for the normal selection.
-  Selection* normalSel =
-    frameSel->GetSelection(nsISelectionController::SELECTION_NORMAL);
+  Selection* normalSel = frameSel->GetSelection(SelectionType::eNormal);
   normalSel->RemoveSelectionListener(this);
 
   // Remove 'this' registered as selection listener for the spellcheck
   // selection.
-  Selection* spellSel =
-    frameSel->GetSelection(nsISelectionController::SELECTION_SPELLCHECK);
+  Selection* spellSel = frameSel->GetSelection(SelectionType::eSpellCheck);
   spellSel->RemoveSelectionListener(this);
 }
 
 void
 SelectionManager::ProcessTextSelChangeEvent(AccEvent* aEvent)
 {
   // Fire selection change event if it's not pure caret-move selection change,
   // i.e. the accessible has or had not collapsed selection.
@@ -220,20 +212,20 @@ SelectionManager::ProcessSelectionChange
   }
 
   HyperTextAccessible* text = nsAccUtils::GetTextContainer(cntrNode);
   if (!text) {
     NS_NOTREACHED("We must reach document accessible implementing text interface!");
     return;
   }
 
-  if (selection->GetType() == nsISelectionController::SELECTION_NORMAL) {
+  if (selection->GetType() == SelectionType::eNormal) {
     RefPtr<AccEvent> event =
       new AccTextSelChangeEvent(text, selection, aSelData->mReason);
     text->Document()->FireDelayedEvent(event);
 
-  } else if (selection->GetType() == nsISelectionController::SELECTION_SPELLCHECK) {
+  } else if (selection->GetType() == SelectionType::eSpellCheck) {
     // XXX: fire an event for container accessible of the focus/anchor range
     // of the spelcheck selection.
     text->Document()->FireDelayedEvent(nsIAccessibleEvent::EVENT_TEXT_ATTRIBUTE_CHANGED,
                                        text);
   }
 }
--- a/accessible/base/TextRange.h
+++ b/accessible/base/TextRange.h
@@ -3,17 +3,16 @@
 /* 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 mozilla_a11y_TextRange_h__
 #define mozilla_a11y_TextRange_h__
 
 #include "mozilla/Move.h"
-#include "nsAutoPtr.h"
 #include "nsCaseTreatment.h"
 #include "nsRect.h"
 #include "nsTArray.h"
 
  class nsIVariant;
 
 namespace mozilla {
 namespace a11y {
--- a/accessible/base/nsAccessiblePivot.h
+++ b/accessible/base/nsAccessiblePivot.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _nsAccessiblePivot_H_
 #define _nsAccessiblePivot_H_
 
 #include "nsIAccessiblePivot.h"
 
 #include "Accessible-inl.h"
-#include "nsAutoPtr.h"
 #include "nsTObserverArray.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Attributes.h"
 
 class RuleCache;
 
 /**
  * Class represents an accessible pivot.
--- a/accessible/generic/Accessible.h
+++ b/accessible/generic/Accessible.h
@@ -6,16 +6,17 @@
 #ifndef _Accessible_H_
 #define _Accessible_H_
 
 #include "mozilla/a11y/AccTypes.h"
 #include "mozilla/a11y/RelationType.h"
 #include "mozilla/a11y/Role.h"
 #include "mozilla/a11y/States.h"
 
+#include "nsAutoPtr.h"
 #include "nsIContent.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsRefPtrHashtable.h"
 #include "nsRect.h"
 
 struct nsRoleMapEntry;
 
--- a/accessible/generic/DocAccessible.h
+++ b/accessible/generic/DocAccessible.h
@@ -6,16 +6,17 @@
 #ifndef mozilla_a11y_DocAccessible_h__
 #define mozilla_a11y_DocAccessible_h__
 
 #include "nsIAccessiblePivot.h"
 
 #include "HyperTextAccessibleWrap.h"
 #include "AccEvent.h"
 
+#include "nsAutoPtr.h"
 #include "nsClassHashtable.h"
 #include "nsDataHashtable.h"
 #include "nsIDocument.h"
 #include "nsIDocumentObserver.h"
 #include "nsIEditor.h"
 #include "nsIObserver.h"
 #include "nsIScrollPositionListener.h"
 #include "nsITimer.h"
--- a/accessible/generic/HyperTextAccessible-inl.h
+++ b/accessible/generic/HyperTextAccessible-inl.h
@@ -164,18 +164,17 @@ HyperTextAccessible::FrameSelection() co
   nsIFrame* frame = GetFrame();
   return frame ? frame->GetFrameSelection() : nullptr;
 }
 
 inline dom::Selection*
 HyperTextAccessible::DOMSelection() const
 {
   RefPtr<nsFrameSelection> frameSelection = FrameSelection();
-  return frameSelection ?
-    frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL) :
-    nullptr;
+  return frameSelection ? frameSelection->GetSelection(SelectionType::eNormal) :
+                          nullptr;
 }
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif
 
--- a/accessible/generic/HyperTextAccessible.cpp
+++ b/accessible/generic/HyperTextAccessible.cpp
@@ -1438,18 +1438,17 @@ int32_t
 HyperTextAccessible::CaretLineNumber()
 {
   // Provide the line number for the caret, relative to the
   // currently focused node. Use a 1-based index
   RefPtr<nsFrameSelection> frameSelection = FrameSelection();
   if (!frameSelection)
     return -1;
 
-  dom::Selection* domSel =
-    frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL);
+  dom::Selection* domSel = frameSelection->GetSelection(SelectionType::eNormal);
   if (!domSel)
     return - 1;
 
   nsINode* caretNode = domSel->GetFocusNode();
   if (!caretNode || !caretNode->IsContent())
     return -1;
 
   nsIContent* caretContent = caretNode->AsContent();
@@ -1541,26 +1540,26 @@ HyperTextAccessible::GetCaretRect(nsIWid
   if (!charRect.IsEmpty()) {
     caretRect.height -= charRect.y - caretRect.y;
     caretRect.y = charRect.y;
   }
   return caretRect;
 }
 
 void
-HyperTextAccessible::GetSelectionDOMRanges(int16_t aType,
+HyperTextAccessible::GetSelectionDOMRanges(SelectionType aSelectionType,
                                            nsTArray<nsRange*>* aRanges)
 {
   // Ignore selection if it is not visible.
   RefPtr<nsFrameSelection> frameSelection = FrameSelection();
   if (!frameSelection ||
       frameSelection->GetDisplaySelection() <= nsISelectionController::SELECTION_HIDDEN)
     return;
 
-  dom::Selection* domSel = frameSelection->GetSelection(aType);
+  dom::Selection* domSel = frameSelection->GetSelection(aSelectionType);
   if (!domSel)
     return;
 
   nsCOMPtr<nsINode> startNode = GetNode();
 
   nsCOMPtr<nsIEditor> editor = GetEditor();
   if (editor) {
     nsCOMPtr<nsIDOMElement> editorRoot;
@@ -1586,29 +1585,29 @@ HyperTextAccessible::GetSelectionDOMRang
     }
   }
 }
 
 int32_t
 HyperTextAccessible::SelectionCount()
 {
   nsTArray<nsRange*> ranges;
-  GetSelectionDOMRanges(nsISelectionController::SELECTION_NORMAL, &ranges);
+  GetSelectionDOMRanges(SelectionType::eNormal, &ranges);
   return ranges.Length();
 }
 
 bool
 HyperTextAccessible::SelectionBoundsAt(int32_t aSelectionNum,
                                        int32_t* aStartOffset,
                                        int32_t* aEndOffset)
 {
   *aStartOffset = *aEndOffset = 0;
 
   nsTArray<nsRange*> ranges;
-  GetSelectionDOMRanges(nsISelectionController::SELECTION_NORMAL, &ranges);
+  GetSelectionDOMRanges(SelectionType::eNormal, &ranges);
 
   uint32_t rangeCount = ranges.Length();
   if (aSelectionNum < 0 || aSelectionNum >= static_cast<int32_t>(rangeCount))
     return false;
 
   nsRange* range = ranges[aSelectionNum];
 
   // Get start and end points.
@@ -2132,17 +2131,17 @@ HyperTextAccessible::GetSpellTextAttr(ns
                                       uint32_t* aStartOffset,
                                       uint32_t* aEndOffset,
                                       nsIPersistentProperties* aAttributes)
 {
   RefPtr<nsFrameSelection> fs = FrameSelection();
   if (!fs)
     return;
 
-  dom::Selection* domSel = fs->GetSelection(nsISelectionController::SELECTION_SPELLCHECK);
+  dom::Selection* domSel = fs->GetSelection(SelectionType::eSpellCheck);
   if (!domSel)
     return;
 
   int32_t rangeCount = domSel->RangeCount();
   if (rangeCount <= 0)
     return;
 
   uint32_t startOffset = 0, endOffset = 0;
--- a/accessible/generic/HyperTextAccessible.h
+++ b/accessible/generic/HyperTextAccessible.h
@@ -513,17 +513,18 @@ protected:
   /**
    * Return frame selection object for the accessible.
    */
   already_AddRefed<nsFrameSelection> FrameSelection() const;
 
   /**
    * Return selection ranges within the accessible subtree.
    */
-  void GetSelectionDOMRanges(int16_t aType, nsTArray<nsRange*>* aRanges);
+  void GetSelectionDOMRanges(SelectionType aSelectionType,
+                             nsTArray<nsRange*>* aRanges);
 
   nsresult SetSelectionRange(int32_t aStartPos, int32_t aEndPos);
 
   /**
    * Convert the given DOM point to a DOM point in non-generated contents.
    *
    * If aDOMPoint is in ::before, the result is immediately after it.
    * If aDOMPoint is in ::after, the result is immediately before it.
--- a/accessible/html/HTMLElementAccessibles.h
+++ b/accessible/html/HTMLElementAccessibles.h
@@ -2,17 +2,16 @@
 /* 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 mozilla_a11y_HTMLElementAccessibles_h__
 #define mozilla_a11y_HTMLElementAccessibles_h__
 
 #include "BaseAccessibles.h"
-#include "nsAutoPtr.h"
 
 namespace mozilla {
 namespace a11y {
 
 /**
  * Used for HTML hr element.
  */
 class HTMLHRAccessible : public LeafAccessible
--- a/accessible/interfaces/nsIAccessibilityService.h
+++ b/accessible/interfaces/nsIAccessibilityService.h
@@ -5,18 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _nsIAccessibilityService_h_
 #define _nsIAccessibilityService_h_
 
 #include "nsIAccessibleRetrieval.h"
 #include "nsIAccessibleEvent.h"
 
-#include "nsAutoPtr.h"
-
 namespace mozilla {
 namespace a11y {
 
 class Accessible;
 
 } // namespace a11y
 } // namespace mozilla
 
--- a/accessible/ipc/DocAccessibleParent.cpp
+++ b/accessible/ipc/DocAccessibleParent.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DocAccessibleParent.h"
-#include "nsAutoPtr.h"
 #include "mozilla/a11y/Platform.h"
 #include "ProxyAccessible.h"
 #include "mozilla/dom/TabParent.h"
 #include "xpcAccessibleDocument.h"
 #include "xpcAccEvents.h"
 #include "nsAccUtils.h"
 #include "nsCoreUtils.h"
 
--- a/accessible/mac/AccessibleWrap.h
+++ b/accessible/mac/AccessibleWrap.h
@@ -13,17 +13,16 @@
 #include <objc/objc.h>
 
 #include "Accessible.h"
 #include "States.h"
 
 #include "nsCOMPtr.h"
 
 #include "nsTArray.h"
-#include "nsAutoPtr.h"
 
 #if defined(__OBJC__)
 @class mozAccessible;
 #endif
 
 namespace mozilla {
 namespace a11y {
 
--- a/accessible/windows/sdn/sdnAccessible.cpp
+++ b/accessible/windows/sdn/sdnAccessible.cpp
@@ -14,18 +14,16 @@
 #include "nsIAccessibleTypes.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsNameSpaceManager.h"
 #include "nsServiceManagerUtils.h"
 #include "nsWinUtils.h"
 #include "nsRange.h"
 
-#include "nsAutoPtr.h"
-
 #include "mozilla/dom/Element.h"
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 
 STDMETHODIMP
 sdnAccessible::QueryInterface(REFIID aREFIID, void** aInstancePtr)
 {
--- a/b2g/app/B2GLoader.cpp
+++ b/b2g/app/B2GLoader.cpp
@@ -6,17 +6,16 @@
 
 #include "nsXULAppAPI.h"
 #include "application.ini.h"
 #include "nsXPCOMGlue.h"
 #include "nsStringGlue.h"
 #include "nsCOMPtr.h"
 #include "nsIFile.h"
 #include "BinaryPath.h"
-#include "nsAutoPtr.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 
--- a/browser/components/migration/nsIEHistoryEnumerator.h
+++ b/browser/components/migration/nsIEHistoryEnumerator.h
@@ -3,19 +3,19 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef iehistoryenumerator___h___
 #define iehistoryenumerator___h___
 
 #include <urlhist.h>
 
 #include "mozilla/Attributes.h"
+#include "nsCOMPtr.h"
 #include "nsISimpleEnumerator.h"
 #include "nsIWritablePropertyBag2.h"
-#include "nsAutoPtr.h"
 
 class nsIEHistoryEnumerator final : public nsISimpleEnumerator
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSISIMPLEENUMERATOR
 
   nsIEHistoryEnumerator();
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -239,17 +239,17 @@ class Automation(object):
     # enable non-local connections for the purposes of local testing.  Don't
     # override the user's choice here.  See bug 1049688.
     env.setdefault('MOZ_DISABLE_NONLOCAL_CONNECTIONS', '1')
 
     env['GNOME_DISABLE_CRASH_DIALOG'] = '1'
     env['XRE_NO_WINDOWS_CRASH_DIALOG'] = '1'
 
     # Set WebRTC logging in case it is not set yet
-    env.setdefault('NSPR_LOG_MODULES', 'signaling:3,mtransport:4,datachannel:4,jsep:4,MediaPipelineFactory:4')
+    env.setdefault('MOZ_LOG', 'signaling:3,mtransport:4,datachannel:4,jsep:4,MediaPipelineFactory:4')
     env.setdefault('R_LOG_LEVEL', '6')
     env.setdefault('R_LOG_DESTINATION', 'stderr')
     env.setdefault('R_LOG_VERBOSE', '1')
 
     # ASan specific environment stuff
     if self.IS_ASAN and (self.IS_LINUX or self.IS_MAC):
       # Symbolizer support
       llvmsym = os.path.join(xrePath, "llvm-symbolizer")
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -26,36 +26,16 @@ filesystem. The following directory will
 If you would like to use a different directory, hit CTRL+c and set the
 MOZBUILD_STATE_PATH environment variable to the directory you would like to
 use and re-run mach. For this change to take effect forever, you'll likely
 want to export this environment variable from your shell's init scripts.
 
 Press ENTER/RETURN to continue or CTRL+c to abort.
 '''.lstrip()
 
-NO_MERCURIAL_SETUP = '''
-*** MERCURIAL NOT CONFIGURED ***
-
-mach has detected that you have never run `{mach} mercurial-setup`.
-
-Running this command will ensure your Mercurial version control tool is up
-to date and optimally configured for a better, more productive experience
-when working on Mozilla projects.
-
-Please run `{mach} mercurial-setup` now.
-
-Note: `{mach} mercurial-setup` does not make any changes without prompting
-you first.
-
-You can disable this check by setting NO_MERCURIAL_SETUP_CHECK=1 in your
-environment.
-'''.strip()
-
-MERCURIAL_SETUP_FATAL_INTERVAL = 31 * 24 * 60 * 60
-
 
 # TODO Bug 794506 Integrate with the in-tree virtualenv configuration.
 SEARCH_PATHS = [
     'python/mach',
     'python/mozboot',
     'python/mozbuild',
     'python/mozlint',
     'python/mozversioncontrol',
@@ -137,17 +117,16 @@ MACH_MODULES = [
     'testing/marionette/mach_commands.py',
     'testing/mochitest/mach_commands.py',
     'testing/mozharness/mach_commands.py',
     'testing/talos/mach_commands.py',
     'testing/web-platform/mach_commands.py',
     'testing/xpcshell/mach_commands.py',
     'tools/docs/mach_commands.py',
     'tools/lint/mach_commands.py',
-    'tools/mercurial/mach_commands.py',
     'tools/mach_commands.py',
     'tools/power/mach_commands.py',
     'mobile/android/mach_commands.py',
 ]
 
 
 CATEGORIES = {
     'build': {
@@ -289,53 +268,16 @@ def bootstrap(topsrcdir, mozilla_dir=Non
             return True
 
         # The environment is likely a machine invocation.
         if sys.stdin.closed or not sys.stdin.isatty():
             return True
 
         return False
 
-    def pre_dispatch_handler(context, handler, args):
-        """Perform global checks before command dispatch.
-
-        Currently, our goal is to ensure developers periodically run
-        `mach mercurial-setup` (when applicable) to ensure their Mercurial
-        tools are up to date.
-        """
-        # Don't do anything when...
-        if should_skip_dispatch(context, handler):
-            return
-
-        # User has disabled first run check.
-        if 'I_PREFER_A_SUBOPTIMAL_MERCURIAL_EXPERIENCE' in os.environ:
-            return
-        if 'NO_MERCURIAL_SETUP_CHECK' in os.environ:
-            return
-
-        # Mercurial isn't managing this source checkout.
-        if not os.path.exists(os.path.join(topsrcdir, '.hg')):
-            return
-
-        state_dir = get_state_dir()[0]
-        last_check_path = os.path.join(state_dir, 'mercurial',
-                                       'setup.lastcheck')
-
-        mtime = None
-        try:
-            mtime = os.path.getmtime(last_check_path)
-        except OSError as e:
-            if e.errno != errno.ENOENT:
-                raise
-
-        # No last run file means mercurial-setup has never completed.
-        if mtime is None:
-            print(NO_MERCURIAL_SETUP.format(mach=sys.argv[0]), file=sys.stderr)
-            sys.exit(2)
-
     def post_dispatch_handler(context, handler, args):
         """Perform global operations after command dispatch.
 
 
         For now,  we will use this to handle build system telemetry.
         """
         # Don't do anything when...
         if should_skip_dispatch(context, handler):
@@ -382,19 +324,16 @@ def bootstrap(topsrcdir, mozilla_dir=Non
                     print('\nCreating default state directory: %s' % state_dir)
                     os.makedirs(state_dir, mode=0o770)
 
             return state_dir
 
         if key == 'topdir':
             return topsrcdir
 
-        if key == 'pre_dispatch_handler':
-            return pre_dispatch_handler
-
         if key == 'telemetry_handler':
             return telemetry_handler
 
         if key == 'post_dispatch_handler':
             return post_dispatch_handler
 
         raise AttributeError(key)
 
--- a/caps/nsNullPrincipalURI.h
+++ b/caps/nsNullPrincipalURI.h
@@ -8,17 +8,16 @@
  * This wraps nsSimpleURI so that all calls to it are done on the main thread.
  */
 
 #ifndef __nsNullPrincipalURI_h__
 #define __nsNullPrincipalURI_h__
 
 #include "nsIURI.h"
 #include "nsISizeOf.h"
-#include "nsAutoPtr.h"
 #include "nsString.h"
 #include "mozilla/Attributes.h"
 #include "nsIIPCSerializableURI.h"
 #include "mozilla/MemoryReporting.h"
 #include "nsNullPrincipal.h"
 #include "nsID.h"
 
 // {51fcd543-3b52-41f7-b91b-6b54102236e6}
--- a/caps/nsPrincipal.h
+++ b/caps/nsPrincipal.h
@@ -1,21 +1,19 @@
 /* -*- 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 nsPrincipal_h__
 #define nsPrincipal_h__
 
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsJSPrincipals.h"
 #include "nsTArray.h"
-#include "nsAutoPtr.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsIProtocolHandler.h"
 #include "nsNetUtil.h"
 #include "nsScriptSecurityManager.h"
 #include "mozilla/BasePrincipal.h"
 
 class nsPrincipal final : public mozilla::BasePrincipal
 {
--- a/caps/nsScriptSecurityManager.cpp
+++ b/caps/nsScriptSecurityManager.cpp
@@ -45,17 +45,16 @@
 #include "nsIScriptGlobalObject.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDocShell.h"
 #include "nsIPrompt.h"
 #include "nsIWindowWatcher.h"
 #include "nsIConsoleService.h"
 #include "nsIObserverService.h"
 #include "nsIContent.h"
-#include "nsAutoPtr.h"
 #include "nsDOMJSUtils.h"
 #include "nsAboutProtocolUtils.h"
 #include "nsIClassInfo.h"
 #include "nsIURIFixup.h"
 #include "nsCDefaultURIFixup.h"
 #include "nsIChromeRegistry.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
--- a/docshell/base/nsDSURIContentListener.cpp
+++ b/docshell/base/nsDSURIContentListener.cpp
@@ -8,17 +8,16 @@
 #include "nsDSURIContentListener.h"
 #include "nsIChannel.h"
 #include "nsServiceManagerUtils.h"
 #include "nsDocShellCID.h"
 #include "nsIWebNavigationInfo.h"
 #include "nsIDocument.h"
 #include "nsIDOMWindow.h"
 #include "nsNetUtil.h"
-#include "nsAutoPtr.h"
 #include "nsQueryObject.h"
 #include "nsIHttpChannel.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsError.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsDocShellLoadTypes.h"
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -660,59 +660,59 @@ DispatchPings(nsIDocShell* aDocShell,
   info.target = aTarget;
   info.referrer = aReferrer;
   info.referrerPolicy = aReferrerPolicy;
   info.docShell = aDocShell;
 
   ForEachPing(aContent, SendPing, &info);
 }
 
-static nsDOMPerformanceNavigationType
+static nsDOMNavigationTiming::Type
 ConvertLoadTypeToNavigationType(uint32_t aLoadType)
 {
   // Not initialized, assume it's normal load.
   if (aLoadType == 0) {
     aLoadType = LOAD_NORMAL;
   }
 
-  auto result = dom::PerformanceNavigation::TYPE_RESERVED;
+  auto result = nsDOMNavigationTiming::TYPE_RESERVED;
   switch (aLoadType) {
     case LOAD_NORMAL:
     case LOAD_NORMAL_EXTERNAL:
     case LOAD_NORMAL_BYPASS_CACHE:
     case LOAD_NORMAL_BYPASS_PROXY:
     case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE:
     case LOAD_NORMAL_REPLACE:
     case LOAD_NORMAL_ALLOW_MIXED_CONTENT:
     case LOAD_LINK:
     case LOAD_STOP_CONTENT:
     case LOAD_REPLACE_BYPASS_CACHE:
-      result = dom::PerformanceNavigation::TYPE_NAVIGATE;
+      result = nsDOMNavigationTiming::TYPE_NAVIGATE;
       break;
     case LOAD_HISTORY:
-      result = dom::PerformanceNavigation::TYPE_BACK_FORWARD;
+      result = nsDOMNavigationTiming::TYPE_BACK_FORWARD;
       break;
     case LOAD_RELOAD_NORMAL:
     case LOAD_RELOAD_CHARSET_CHANGE:
     case LOAD_RELOAD_BYPASS_CACHE:
     case LOAD_RELOAD_BYPASS_PROXY:
     case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
     case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
-      result = dom::PerformanceNavigation::TYPE_RELOAD;
+      result = nsDOMNavigationTiming::TYPE_RELOAD;
       break;
     case LOAD_STOP_CONTENT_AND_REPLACE:
     case LOAD_REFRESH:
     case LOAD_BYPASS_HISTORY:
     case LOAD_ERROR_PAGE:
     case LOAD_PUSHSTATE:
-      result = dom::PerformanceNavigation::TYPE_RESERVED;
+      result = nsDOMNavigationTiming::TYPE_RESERVED;
       break;
     default:
       // NS_NOTREACHED("Unexpected load type value");
-      result = dom::PerformanceNavigation::TYPE_RESERVED;
+      result = nsDOMNavigationTiming::TYPE_RESERVED;
       break;
   }
 
   return result;
 }
 
 static nsISHEntry* GetRootSHEntry(nsISHEntry* aEntry);
 
@@ -785,17 +785,16 @@ nsDocShell::nsDocShell()
   , mAllowAuth(true)
   , mAllowKeywordFixup(false)
   , mIsOffScreenBrowser(false)
   , mIsActive(true)
   , mDisableMetaRefreshWhenInactive(false)
   , mIsPrerendered(false)
   , mIsAppTab(false)
   , mUseGlobalHistory(false)
-  , mInPrivateBrowsing(false)
   , mUseRemoteTabs(false)
   , mDeviceSizeIsPageSize(false)
   , mWindowDraggingAllowed(false)
   , mInFrameSwap(false)
   , mCanExecuteScripts(false)
   , mFiredUnloadEvent(false)
   , mEODForCurrentDocument(false)
   , mURIResultedInDocument(false)
@@ -807,16 +806,17 @@ nsDocShell::nsDocShell()
   , mInEnsureScriptEnv(false)
 #endif
   , mAffectPrivateSessionLifetime(true)
   , mInvisible(false)
   , mHasLoadedNonBlankURI(false)
   , mDefaultLoadFlags(nsIRequest::LOAD_NORMAL)
   , mBlankTiming(false)
   , mFrameType(FRAME_TYPE_REGULAR)
+  , mPrivateBrowsingId(0)
   , mParentCharsetSource(0)
   , mJSRunToCompletionDepth(0)
 {
   AssertOriginAttributesMatchPrivateBrowsing();
   mHistoryID = ++gDocshellIDCounter;
   if (gDocShellCount++ == 0) {
     NS_ASSERTION(sURIFixup == nullptr,
                  "Huh, sURIFixup not null in first nsDocShell ctor!");
@@ -2177,17 +2177,17 @@ nsDocShell::SetAllowJavascript(bool aAll
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing)
 {
   NS_ENSURE_ARG_POINTER(aUsePrivateBrowsing);
   AssertOriginAttributesMatchPrivateBrowsing();
-  *aUsePrivateBrowsing = mInPrivateBrowsing;
+  *aUsePrivateBrowsing = mPrivateBrowsingId > 0;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
 {
   nsContentUtils::ReportToConsoleNonLocalized(
     NS_LITERAL_STRING("Only internal code is allowed to set the usePrivateBrowsing attribute"),
@@ -2196,21 +2196,23 @@ nsDocShell::SetUsePrivateBrowsing(bool a
     mContentViewer ? mContentViewer->GetDocument() : nullptr);
 
   return SetPrivateBrowsing(aUsePrivateBrowsing);
 }
 
 NS_IMETHODIMP
 nsDocShell::SetPrivateBrowsing(bool aUsePrivateBrowsing)
 {
-  bool changed = aUsePrivateBrowsing != mInPrivateBrowsing;
+  bool changed = aUsePrivateBrowsing != (mPrivateBrowsingId > 0);
   if (changed) {
-    mInPrivateBrowsing = aUsePrivateBrowsing;
-
-    mOriginAttributes.SyncAttributesWithPrivateBrowsing(mInPrivateBrowsing);
+    mPrivateBrowsingId = aUsePrivateBrowsing ? 1 : 0;
+
+    if (mItemType != typeChrome) {
+      mOriginAttributes.SyncAttributesWithPrivateBrowsing(aUsePrivateBrowsing);
+    }
 
     if (mAffectPrivateSessionLifetime) {
       if (aUsePrivateBrowsing) {
         IncreasePrivateDocShellCount();
       } else {
         DecreasePrivateDocShellCount();
       }
     }
@@ -2231,16 +2233,18 @@ nsDocShell::SetPrivateBrowsing(bool aUse
       nsCOMPtr<nsIPrivacyTransitionObserver> obs = do_QueryReferent(ref);
       if (!obs) {
         mPrivacyObservers.RemoveElement(ref);
       } else {
         obs->PrivateModeChanged(aUsePrivateBrowsing);
       }
     }
   }
+
+  AssertOriginAttributesMatchPrivateBrowsing();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::GetHasLoadedNonBlankURI(bool* aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
 
@@ -2270,17 +2274,17 @@ nsDocShell::SetRemoteTabs(bool aUseRemot
   mUseRemoteTabs = aUseRemoteTabs;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::SetAffectPrivateSessionLifetime(bool aAffectLifetime)
 {
   bool change = aAffectLifetime != mAffectPrivateSessionLifetime;
-  if (change && mInPrivateBrowsing) {
+  if (change && UsePrivateBrowsing()) {
     AssertOriginAttributesMatchPrivateBrowsing();
     if (aAffectLifetime) {
       IncreasePrivateDocShellCount();
     } else {
       DecreasePrivateDocShellCount();
     }
   }
   mAffectPrivateSessionLifetime = aAffectLifetime;
@@ -2967,21 +2971,21 @@ nsDocShell::GetSessionStorageForPrincipa
     return NS_ERROR_UNEXPECTED;
   }
 
   nsCOMPtr<nsPIDOMWindowOuter> domWin = GetWindow();
 
   AssertOriginAttributesMatchPrivateBrowsing();
   if (aCreate) {
     return manager->CreateStorage(domWin->GetCurrentInnerWindow(), aPrincipal,
-                                  aDocumentURI, mInPrivateBrowsing, aStorage);
+                                  aDocumentURI, UsePrivateBrowsing(), aStorage);
   }
 
   return manager->GetStorage(domWin->GetCurrentInnerWindow(), aPrincipal,
-                             mInPrivateBrowsing, aStorage);
+                             UsePrivateBrowsing(), aStorage);
 }
 
 nsresult
 nsDocShell::AddSessionStorage(nsIPrincipal* aPrincipal, nsIDOMStorage* aStorage)
 {
   RefPtr<DOMStorage> storage = static_cast<DOMStorage*>(aStorage);
   if (!storage) {
     return NS_ERROR_UNEXPECTED;
@@ -3661,17 +3665,24 @@ nsDocShell::FindItemWithName(const char1
       foundItem.swap(*aResult);
     }
     return NS_OK;
   }
 }
 
 void
 nsDocShell::AssertOriginAttributesMatchPrivateBrowsing() {
-  MOZ_ASSERT((mOriginAttributes.mPrivateBrowsingId != 0) == mInPrivateBrowsing);
+  // Chrome docshells must not have a private browsing OriginAttribute
+  // Content docshells must maintain the equality:
+  // mOriginAttributes.mPrivateBrowsingId == mPrivateBrowsingId
+  if (mItemType == typeChrome) {
+    MOZ_ASSERT(mOriginAttributes.mPrivateBrowsingId == 0);
+  } else {
+    MOZ_ASSERT(mOriginAttributes.mPrivateBrowsingId == mPrivateBrowsingId);
+  }
 }
 
 nsresult
 nsDocShell::DoFindItemWithName(const char16_t* aName,
                                nsISupports* aRequestor,
                                nsIDocShellTreeItem* aOriginalRequestor,
                                nsIDocShellTreeItem** aResult)
 {
@@ -4891,17 +4902,17 @@ nsDocShell::DisplayLoadError(nsresult aE
     if (!messageStr.IsEmpty()) {
       if (errorClass == nsINSSErrorsService::ERROR_CLASS_BAD_CERT) {
         error.AssignLiteral("nssBadCert");
 
         // If this is an HTTP Strict Transport Security host or a pinned host
         // and the certificate is bad, don't allow overrides (RFC 6797 section
         // 12.1, HPKP draft spec section 2.6).
         uint32_t flags =
-          mInPrivateBrowsing ? nsISocketProvider::NO_PERMANENT_STORAGE : 0;
+          UsePrivateBrowsing() ? nsISocketProvider::NO_PERMANENT_STORAGE : 0;
         bool isStsHost = false;
         bool isPinnedHost = false;
         if (XRE_IsParentProcess()) {
           nsCOMPtr<nsISiteSecurityService> sss =
             do_GetService(NS_SSSERVICE_CONTRACTID, &rv);
           NS_ENSURE_SUCCESS(rv, rv);
           rv = sss->IsSecureURI(nsISiteSecurityService::HEADER_HSTS, aURI,
                                 flags, &isStsHost);
@@ -5760,19 +5771,19 @@ nsDocShell::Destroy()
 
   // required to break ref cycle
   mSecurityUI = nullptr;
 
   // Cancel any timers that were set for this docshell; this is needed
   // to break the cycle between us and the timers.
   CancelRefreshURITimers();
 
-  if (mInPrivateBrowsing) {
-    mInPrivateBrowsing = false;
-    mOriginAttributes.SyncAttributesWithPrivateBrowsing(mInPrivateBrowsing);
+  if (UsePrivateBrowsing()) {
+    mPrivateBrowsingId = 0;
+    mOriginAttributes.SyncAttributesWithPrivateBrowsing(false);
     if (mAffectPrivateSessionLifetime) {
       DecreasePrivateDocShellCount();
     }
   }
 
   return NS_OK;
 }
 
@@ -6422,17 +6433,17 @@ nsDocShell::SetTitle(const char16_t* aTi
     nsCOMPtr<nsIBaseWindow> treeOwnerAsWin(do_QueryInterface(mTreeOwner));
     if (treeOwnerAsWin) {
       treeOwnerAsWin->SetTitle(aTitle);
     }
   }
 
   AssertOriginAttributesMatchPrivateBrowsing();
   if (mCurrentURI && mLoadType != LOAD_ERROR_PAGE && mUseGlobalHistory &&
-      !mInPrivateBrowsing) {
+      !UsePrivateBrowsing()) {
     nsCOMPtr<IHistory> history = services::GetHistoryService();
     if (history) {
       history->SetURITitle(mCurrentURI, mTitle);
     } else if (mGlobalHistory) {
       mGlobalHistory->SetPageTitle(mCurrentURI, nsString(mTitle));
     }
   }
 
@@ -7451,17 +7462,17 @@ nsDocShell::OnRedirectStateChange(nsICha
       nsCOMPtr<nsIScriptSecurityManager> secMan =
         do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
 
       if (secMan) {
         nsCOMPtr<nsIPrincipal> principal;
         secMan->GetDocShellCodebasePrincipal(newURI, this,
                                              getter_AddRefs(principal));
         appCacheChannel->SetChooseApplicationCache(
-          NS_ShouldCheckAppCache(principal, mInPrivateBrowsing));
+          NS_ShouldCheckAppCache(principal, UsePrivateBrowsing()));
       }
     }
   }
 
   if (!(aRedirectFlags & nsIChannelEventSink::REDIRECT_INTERNAL) &&
       mLoadType & (LOAD_CMD_RELOAD | LOAD_CMD_HISTORY)) {
     mLoadType = LOAD_NORMAL_REPLACE;
     SetHistoryEntry(&mLSHE, nullptr);
@@ -8807,17 +8818,17 @@ nsDocShell::RestoreFromHistory()
     bool allowContentRetargetingOnChildren =
       childShell->GetAllowContentRetargetingOnChildren();
 
     uint32_t defaultLoadFlags;
     childShell->GetDefaultLoadFlags(&defaultLoadFlags);
 
     // this.AddChild(child) calls child.SetDocLoaderParent(this), meaning that
     // the child inherits our state. Among other things, this means that the
-    // child inherits our mIsActive, mIsPrerendered and mInPrivateBrowsing,
+    // child inherits our mIsActive, mIsPrerendered and mPrivateBrowsingId,
     // which is what we want.
     AddChild(childItem);
 
     childShell->SetAllowPlugins(allowPlugins);
     childShell->SetAllowJavascript(allowJavascript);
     childShell->SetAllowMetaRedirects(allowRedirects);
     childShell->SetAllowSubframes(allowSubframes);
     childShell->SetAllowImages(allowImages);
@@ -10239,30 +10250,30 @@ nsDocShell::InternalLoad(nsIURI* aURI,
         nsCOMPtr<nsISHEntry> shEntry;
         mSessionHistory->GetEntryAtIndex(index, false, getter_AddRefs(shEntry));
         NS_ENSURE_TRUE(shEntry, NS_ERROR_FAILURE);
         shEntry->SetTitle(mTitle);
       }
 
       /* Set the title for the Global History entry for this anchor url.
        */
-      if (mUseGlobalHistory && !mInPrivateBrowsing) {
+      if (mUseGlobalHistory && !UsePrivateBrowsing()) {
         nsCOMPtr<IHistory> history = services::GetHistoryService();
         if (history) {
           history->SetURITitle(aURI, mTitle);
         } else if (mGlobalHistory) {
           mGlobalHistory->SetPageTitle(aURI, mTitle);
         }
       }
 
       SetDocCurrentStateObj(mOSHE);
 
       // Inform the favicon service that the favicon for oldURI also
       // applies to aURI.
-      CopyFavicon(currentURI, aURI, doc->NodePrincipal(), mInPrivateBrowsing);
+      CopyFavicon(currentURI, aURI, doc->NodePrincipal(), UsePrivateBrowsing());
 
       RefPtr<nsGlobalWindow> win = mScriptGlobal ?
         mScriptGlobal->GetCurrentInnerWindowInternal() : nullptr;
 
       // ScrollToAnchor doesn't necessarily cause us to scroll the window;
       // the function decides whether a scroll is appropriate based on the
       // arguments it receives.  But even if we don't end up scrolling,
       // ScrollToAnchor performs other important tasks, such as informing
@@ -10739,17 +10750,17 @@ nsDocShell::DoURILoad(nsIURI* aURI,
   nsSecurityFlags securityFlags = nsILoadInfo::SEC_NORMAL;
   if (inherit) {
     securityFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
   }
   if (isSandBoxed) {
     securityFlags |= nsILoadInfo::SEC_SANDBOXED;
   }
 
-  if (mInPrivateBrowsing) {
+  if (UsePrivateBrowsing()) {
     securityFlags |= nsILoadInfo::SEC_FORCE_PRIVATE_BROWSING;
   }
 
   nsCOMPtr<nsILoadInfo> loadInfo =
     (aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT) ?
       new LoadInfo(loadingWindow, triggeringPrincipal,
                    securityFlags) :
       new LoadInfo(loadingPrincipal, triggeringPrincipal, loadingNode,
@@ -10837,17 +10848,17 @@ nsDocShell::DoURILoad(nsIURI* aURI,
       nsCOMPtr<nsIScriptSecurityManager> secMan =
         do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
 
       if (secMan) {
         nsCOMPtr<nsIPrincipal> principal;
         secMan->GetDocShellCodebasePrincipal(aURI, this,
                                              getter_AddRefs(principal));
         appCacheChannel->SetChooseApplicationCache(
-          NS_ShouldCheckAppCache(principal, mInPrivateBrowsing));
+          NS_ShouldCheckAppCache(principal, UsePrivateBrowsing()));
       }
     }
   }
 
   // Make sure to give the caller a channel if we managed to create one
   // This is important for correct error page/session history interaction
   if (aRequest) {
     NS_ADDREF(*aRequest = channel);
@@ -11920,28 +11931,28 @@ nsDocShell::AddState(JS::Handle<JS::Valu
     if (mLoadType != LOAD_ERROR_PAGE) {
       FireDummyOnLocationChange();
     }
 
     AddURIVisit(newURI, oldURI, oldURI, 0);
 
     // AddURIVisit doesn't set the title for the new URI in global history,
     // so do that here.
-    if (mUseGlobalHistory && !mInPrivateBrowsing) {
+    if (mUseGlobalHistory && !UsePrivateBrowsing()) {
       nsCOMPtr<IHistory> history = services::GetHistoryService();
       if (history) {
         history->SetURITitle(newURI, mTitle);
       } else if (mGlobalHistory) {
         mGlobalHistory->SetPageTitle(newURI, mTitle);
       }
     }
 
     // Inform the favicon service that our old favicon applies to this new
     // URI.
-    CopyFavicon(oldURI, newURI, document->NodePrincipal(), mInPrivateBrowsing);
+    CopyFavicon(oldURI, newURI, document->NodePrincipal(), UsePrivateBrowsing());
   } else {
     FireDummyOnLocationChange();
   }
   document->SetStateObject(scContainer);
 
   return NS_OK;
 }
 
@@ -12832,17 +12843,17 @@ nsDocShell::AddURIVisit(nsIURI* aURI,
 {
   MOZ_ASSERT(aURI, "Visited URI is null!");
   MOZ_ASSERT(mLoadType != LOAD_ERROR_PAGE &&
              mLoadType != LOAD_BYPASS_HISTORY,
              "Do not add error or bypass pages to global history");
 
   // Only content-type docshells save URI visits.  Also don't do
   // anything here if we're not supposed to use global history.
-  if (mItemType != typeContent || !mUseGlobalHistory || mInPrivateBrowsing) {
+  if (mItemType != typeContent || !mUseGlobalHistory || UsePrivateBrowsing()) {
     return;
   }
 
   nsCOMPtr<IHistory> history = services::GetHistoryService();
 
   if (history) {
     uint32_t visitURIFlags = 0;
 
@@ -13369,17 +13380,17 @@ nsDocShell::IsAppOfType(uint32_t aAppTyp
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::IsTrackingProtectionOn(bool* aIsTrackingProtectionOn)
 {
   if (Preferences::GetBool("privacy.trackingprotection.enabled", false)) {
     *aIsTrackingProtectionOn = true;
-  } else if (mInPrivateBrowsing &&
+  } else if (UsePrivateBrowsing() &&
              Preferences::GetBool("privacy.trackingprotection.pbmode.enabled", false)) {
     *aIsTrackingProtectionOn = true;
   } else {
     *aIsTrackingProtectionOn = false;
   }
 
   return NS_OK;
 }
@@ -14158,18 +14169,27 @@ nsDocShell::SetOriginAttributes(const Do
       uri->GetSpec(uriSpec);
       MOZ_ASSERT(uriSpec.EqualsLiteral("about:blank"));
       if (!uriSpec.EqualsLiteral("about:blank")) {
         return NS_ERROR_FAILURE;
       }
     }
   }
 
+  AssertOriginAttributesMatchPrivateBrowsing();
   mOriginAttributes = aAttrs;
-  SetPrivateBrowsing(mOriginAttributes.mPrivateBrowsingId > 0);
+
+  bool isPrivate = mOriginAttributes.mPrivateBrowsingId > 0;
+  // Chrome docshell can not contain OriginAttributes.mPrivateBrowsingId
+  if (mItemType == typeChrome && isPrivate) {
+    mOriginAttributes.mPrivateBrowsingId = 0;
+  }
+
+  SetPrivateBrowsing(isPrivate);
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::SetOriginAttributesBeforeLoading(JS::Handle<JS::Value> aOriginAttributes)
 {
   if (!aOriginAttributes.isObject()) {
     return NS_ERROR_INVALID_ARG;
@@ -14345,17 +14365,17 @@ nsDocShell::MaybeNotifyKeywordSearchLoad
 }
 
 NS_IMETHODIMP
 nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNonSubresourceRequest,
                                       bool* aShouldIntercept)
 {
   *aShouldIntercept = false;
   // No in private browsing
-  if (mInPrivateBrowsing) {
+  if (UsePrivateBrowsing()) {
     return NS_OK;
   }
 
   if (mSandboxFlags) {
     // If we're sandboxed, don't intercept.
     return NS_OK;
   }
 
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -937,17 +937,16 @@ protected:
   bool mAllowAuth;
   bool mAllowKeywordFixup;
   bool mIsOffScreenBrowser;
   bool mIsActive;
   bool mDisableMetaRefreshWhenInactive;
   bool mIsPrerendered;
   bool mIsAppTab;
   bool mUseGlobalHistory;
-  bool mInPrivateBrowsing;
   bool mUseRemoteTabs;
   bool mDeviceSizeIsPageSize;
   bool mWindowDraggingAllowed;
   bool mInFrameSwap;
 
   // Because scriptability depends on the mAllowJavascript values of our
   // ancestors, we cache the effective scriptability and recompute it when
   // it might have changed;
@@ -996,16 +995,23 @@ protected:
   // This flag means that mTiming has been initialized but nulled out.
   // We will check the innerWin's timing before creating a new one
   // in MaybeInitTiming()
   bool mBlankTiming;
 
   // Are we a regular frame, a browser frame, or an app frame?
   uint32_t mFrameType;
 
+  // This represents the state of private browsing in the docshell.
+  // Currently treated as a binary value: 1 - in private mode, 0 - not private mode
+  // On content docshells mPrivateBrowsingId == mOriginAttributes.mPrivateBrowsingId
+  // On chrome docshells this value will be set, but not have the corresponding
+  // origin attribute set.
+  uint32_t mPrivateBrowsingId;
+
   nsString mPaymentRequestId;
 
   nsString GetInheritedPaymentRequestId();
 
   nsString mInterceptedDocumentId;
 
 private:
   nsCString mForcedCharset;
--- a/docshell/shistory/nsSHEntry.h
+++ b/docshell/shistory/nsSHEntry.h
@@ -4,17 +4,16 @@
  * 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 nsSHEntry_h
 #define nsSHEntry_h
 
 // Helper Classes
 #include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
 #include "nsCOMArray.h"
 #include "nsString.h"
 #include "mozilla/Attributes.h"
 
 // Interfaces needed
 #include "nsISHEntry.h"
 #include "nsISHContainer.h"
 
--- a/dom/animation/KeyframeEffect.h
+++ b/dom/animation/KeyframeEffect.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_KeyframeEffect_h
 #define mozilla_dom_KeyframeEffect_h
 
-#include "nsAutoPtr.h"
 #include "nsChangeHint.h"
 #include "nsCSSProperty.h"
 #include "nsCSSValue.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsTArray.h"
 #include "nsWrapperCache.h"
 #include "mozilla/AnimationPerformanceWarning.h"
 #include "mozilla/AnimationTarget.h"
--- a/dom/archivereader/ArchiveReaderCommon.h
+++ b/dom/archivereader/ArchiveReaderCommon.h
@@ -3,17 +3,16 @@
 /* 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 mozilla_dom_archivereader_archivereader_h
 #define mozilla_dom_archivereader_archivereader_h
 
 #include "mozilla/DOMEventTargetHelper.h"
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsDebug.h"
 #include "nsString.h"
 #include "nsTArray.h"
 
 #define BEGIN_ARCHIVEREADER_NAMESPACE \
   namespace mozilla { namespace dom { namespace archivereader {
--- a/dom/asmjscache/AsmJSCache.cpp
+++ b/dom/asmjscache/AsmJSCache.cpp
@@ -22,16 +22,17 @@
 #include "mozilla/dom/quota/QuotaObject.h"
 #include "mozilla/dom/quota/UsageInfo.h"
 #include "mozilla/HashFunctions.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/BackgroundParent.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/ipc/PBackgroundChild.h"
 #include "mozilla/unused.h"
+#include "nsAutoPtr.h"
 #include "nsIAtom.h"
 #include "nsIFile.h"
 #include "nsIIPCBackgroundChildCreateCallback.h"
 #include "nsIPermissionManager.h"
 #include "nsIPrincipal.h"
 #include "nsIRunnable.h"
 #include "nsISimpleEnumerator.h"
 #include "nsIThread.h"
--- a/dom/base/BarProps.h
+++ b/dom/base/BarProps.h
@@ -11,17 +11,16 @@
 */
 
 #ifndef mozilla_dom_BarProps_h
 #define mozilla_dom_BarProps_h
 
 #include "mozilla/Attributes.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
-#include "nsAutoPtr.h"
 #include "nsPIDOMWindow.h"
 
 class nsGlobalWindow;
 class nsIWebBrowserChrome;
 
 namespace mozilla {
 
 class ErrorResult;
--- a/dom/base/DOMMatrix.cpp
+++ b/dom/base/DOMMatrix.cpp
@@ -11,17 +11,16 @@
 #include "mozilla/dom/ToJSValue.h"
 
 #include "mozilla/dom/DOMPoint.h"
 #include "mozilla/dom/DOMMatrix.h"
 
 #include "SVGTransformListParser.h"
 #include "SVGTransform.h"
 
-#include "nsAutoPtr.h"
 #include <math.h>
 
 namespace mozilla {
 namespace dom {
 
 static const double radPerDegree = 2.0 * M_PI / 360.0;
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMMatrixReadOnly, mParent)
--- a/dom/base/DOMPoint.cpp
+++ b/dom/base/DOMPoint.cpp
@@ -3,17 +3,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/DOMPoint.h"
 
 #include "mozilla/dom/DOMPointBinding.h"
 #include "mozilla/dom/BindingDeclarations.h"
-#include "nsAutoPtr.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMPointReadOnly, mParent)
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMPointReadOnly, AddRef)
 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMPointReadOnly, Release)
--- a/dom/base/DOMQuad.h
+++ b/dom/base/DOMQuad.h
@@ -7,17 +7,16 @@
 #ifndef MOZILLA_DOMQUAD_H_
 #define MOZILLA_DOMQUAD_H_
 
 #include "nsWrapperCache.h"
 #include "nsISupports.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Attributes.h"
 #include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/ErrorResult.h"
 #include "Units.h"
 
 namespace mozilla {
 namespace dom {
 
 class DOMRectReadOnly;
--- a/dom/base/DOMRect.h
+++ b/dom/base/DOMRect.h
@@ -6,17 +6,16 @@
 
 #ifndef MOZILLA_DOMRECT_H_
 #define MOZILLA_DOMRECT_H_
 
 #include "nsIDOMClientRect.h"
 #include "nsIDOMClientRectList.h"
 #include "nsTArray.h"
 #include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
 #include "nsWrapperCache.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/ErrorResult.h"
 #include <algorithm>
 
 struct nsRect;
--- a/dom/base/EventSource.cpp
+++ b/dom/base/EventSource.cpp
@@ -10,16 +10,17 @@
 #include "mozilla/DebugOnly.h"
 #include "mozilla/LoadInfo.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/dom/EventSourceBinding.h"
 #include "mozilla/dom/MessageEvent.h"
 #include "mozilla/dom/MessageEventBinding.h"
 #include "mozilla/dom/ScriptSettings.h"
 
+#include "nsAutoPtr.h"
 #include "nsNetUtil.h"
 #include "nsIAuthPrompt.h"
 #include "nsIAuthPrompt2.h"
 #include "nsIInputStream.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsMimeTypes.h"
 #include "nsIPromptFactory.h"
 #include "nsIWindowWatcher.h"
--- a/dom/base/File.h
+++ b/dom/base/File.h
@@ -10,17 +10,16 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/GuardObjects.h"
 #include "mozilla/LinkedList.h"
 #include "mozilla/StaticMutex.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/Date.h"
-#include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsCOMPtr.h"
 #include "nsIDOMBlob.h"
 #include "nsIFile.h"
 #include "nsIMutable.h"
 #include "nsIXMLHttpRequest.h"
 #include "nsString.h"
 #include "nsTemporaryFileInputStream.h"
--- a/dom/base/MultipartBlobImpl.cpp
+++ b/dom/base/MultipartBlobImpl.cpp
@@ -4,17 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MultipartBlobImpl.h"
 #include "jsfriendapi.h"
 #include "mozilla/dom/BlobSet.h"
 #include "mozilla/dom/FileBinding.h"
 #include "mozilla/dom/UnionTypes.h"
-#include "nsAutoPtr.h"
 #include "nsDOMClassInfoID.h"
 #include "nsIMultiplexInputStream.h"
 #include "nsStringStream.h"
 #include "nsTArray.h"
 #include "nsJSUtils.h"
 #include "nsContentUtils.h"
 #include "nsIScriptError.h"
 #include "nsIXPConnect.h"
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -7,17 +7,16 @@
 #ifndef mozilla_dom_Navigator_h
 #define mozilla_dom_Navigator_h
 
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/Nullable.h"
 #include "mozilla/ErrorResult.h"
 #include "nsIDOMNavigator.h"
 #include "nsIMozNavigatorNetwork.h"
-#include "nsAutoPtr.h"
 #include "nsWrapperCache.h"
 #include "nsHashKeys.h"
 #include "nsInterfaceHashtable.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsWeakPtr.h"
 #ifdef MOZ_EME
 #include "mozilla/dom/MediaKeySystemAccessManager.h"
--- a/dom/base/NodeInfo.cpp
+++ b/dom/base/NodeInfo.cpp
@@ -19,17 +19,16 @@
 #include "nsNodeInfoManager.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsIAtom.h"
 #include "nsDOMString.h"
 #include "nsCRT.h"
 #include "nsContentUtils.h"
 #include "nsReadableUtils.h"
-#include "nsAutoPtr.h"
 #include "mozilla/Snprintf.h"
 #include "nsIDocument.h"
 #include "nsGkAtoms.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsNameSpaceManager.h"
 
 using namespace mozilla;
 using mozilla::dom::NodeInfo;
--- a/dom/base/NodeInfo.h
+++ b/dom/base/NodeInfo.h
@@ -16,17 +16,16 @@
  * automatically remove itself from its owner manager, and when all
  * NodeInfos have been removed from a nsNodeInfoManager and all external
  * references are released the nsNodeInfoManager deletes itself.
  */
 
 #ifndef mozilla_dom_NodeInfo_h___
 #define mozilla_dom_NodeInfo_h___
 
-#include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/dom/NameSpaceConstants.h"
 #include "nsStringGlue.h"
 #include "mozilla/Attributes.h"
 #include "nsIAtom.h"
 
 class nsIDocument;
 class nsNodeInfoManager;
--- a/dom/base/ResponsiveImageSelector.h
+++ b/dom/base/ResponsiveImageSelector.h
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_responsiveimageselector_h__
 #define mozilla_dom_responsiveimageselector_h__
 
+#include "nsAutoPtr.h"
 #include "nsISupports.h"
 #include "nsIContent.h"
 #include "nsString.h"
 #include "nsCycleCollectionParticipant.h"
 
 class nsMediaQuery;
 class nsCSSValue;
 
--- a/dom/base/TextInputProcessor.h
+++ b/dom/base/TextInputProcessor.h
@@ -6,17 +6,16 @@
 
 #ifndef mozilla_dom_textinputprocessor_h_
 #define mozilla_dom_textinputprocessor_h_
 
 #include "mozilla/Attributes.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/TextEventDispatcher.h"
 #include "mozilla/TextEventDispatcherListener.h"
-#include "nsAutoPtr.h"
 #include "nsITextInputProcessor.h"
 #include "nsITextInputProcessorCallback.h"
 #include "nsTArray.h"
 
 namespace mozilla {
 
 class TextInputProcessor final : public nsITextInputProcessor
                                , public widget::TextEventDispatcherListener
--- a/dom/base/ThirdPartyUtil.cpp
+++ b/dom/base/ThirdPartyUtil.cpp
@@ -16,17 +16,17 @@
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIURI.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Logging.h"
 
 NS_IMPL_ISUPPORTS(ThirdPartyUtil, mozIThirdPartyUtil)
 
 //
-// NSPR_LOG_MODULES=thirdPartyUtil:5
+// MOZ_LOG=thirdPartyUtil:5
 //
 static mozilla::LazyLogModule gThirdPartyLog("thirdPartyUtil");
 #undef LOG
 #define LOG(args)     MOZ_LOG(gThirdPartyLog, mozilla::LogLevel::Debug, args)
 
 nsresult
 ThirdPartyUtil::Init()
 {
--- a/dom/base/URL.h
+++ b/dom/base/URL.h
@@ -4,17 +4,16 @@
  * 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 URL_h___
 #define URL_h___
 
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/URLSearchParams.h"
 #include "nsCycleCollectionParticipant.h"
-#include "nsAutoPtr.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
 
 class nsISupports;
 class nsIURI;
 
 namespace mozilla {
 
--- a/dom/base/WebSocket.cpp
+++ b/dom/base/WebSocket.cpp
@@ -16,16 +16,17 @@
 #include "mozilla/dom/MessageEvent.h"
 #include "mozilla/dom/MessageEventBinding.h"
 #include "mozilla/dom/nsCSPContext.h"
 #include "mozilla/dom/nsCSPUtils.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/WorkerPrivate.h"
 #include "mozilla/dom/WorkerRunnable.h"
 #include "mozilla/dom/WorkerScope.h"
+#include "nsAutoPtr.h"
 #include "nsGlobalWindow.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIDOMWindow.h"
 #include "nsIDocument.h"
 #include "nsXPCOM.h"
 #include "nsIXPConnect.h"
 #include "nsContentUtils.h"
 #include "nsError.h"
--- a/dom/base/WebSocket.h
+++ b/dom/base/WebSocket.h
@@ -7,17 +7,16 @@
 #ifndef WebSocket_h__
 #define WebSocket_h__
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/TypedArray.h"
 #include "mozilla/dom/WebSocketBinding.h" // for BinaryType
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/ErrorResult.h"
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsISupports.h"
 #include "nsISupportsUtils.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
 
 #define DEFAULT_WS_SCHEME_PORT  80
--- a/dom/base/nsAttrAndChildArray.cpp
+++ b/dom/base/nsAttrAndChildArray.cpp
@@ -16,17 +16,16 @@
 #include "mozilla/MemoryReporting.h"
 
 #include "nsMappedAttributeElement.h"
 #include "nsString.h"
 #include "nsHTMLStyleSheet.h"
 #include "nsRuleWalker.h"
 #include "nsMappedAttributes.h"
 #include "nsUnicharUtils.h"
-#include "nsAutoPtr.h"
 #include "nsContentUtils.h" // nsAutoScriptBlocker
 
 using mozilla::CheckedUint32;
 
 /*
 CACHE_POINTER_SHIFT indicates how many steps to downshift the |this| pointer.
 It should be small enough to not cause collisions between adjecent arrays, and
 large enough to make sure that all indexes are used. The size below is based
--- a/dom/base/nsCopySupport.cpp
+++ b/dom/base/nsCopySupport.cpp
@@ -567,17 +567,18 @@ nsCopySupport::GetSelectionForCopy(nsIDo
       if (selCon) {
         selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, aSelection);
         return content;
       }
     }
   }
 
   // if no selection was found, use the main selection for the window
-  NS_IF_ADDREF(*aSelection = presShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL));
+  NS_IF_ADDREF(*aSelection =
+                 presShell->GetCurrentSelection(SelectionType::eNormal));
   return nullptr;
 }
 
 bool
 nsCopySupport::CanCopy(nsIDocument* aDocument)
 {
   if (!aDocument)
     return false;
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -65,17 +65,16 @@
 #include "nsIDOMXULPopupElement.h"
 
 // Event related includes
 #include "nsIDOMEventTarget.h"
 
 // CSS related includes
 #include "nsCSSRules.h"
 #include "nsIDOMCSSRule.h"
-#include "nsAutoPtr.h"
 #include "nsMemory.h"
 
 // includes needed for the prototype chain interfaces
 #include "nsIDOMCSSKeyframeRule.h"
 #include "nsIDOMCSSKeyframesRule.h"
 #include "nsIDOMCSSImportRule.h"
 #include "nsIDOMCSSMediaRule.h"
 #include "nsIDOMCSSFontFaceRule.h"
--- a/dom/base/nsDOMDataChannel.cpp
+++ b/dom/base/nsDOMDataChannel.cpp
@@ -14,17 +14,16 @@
 #include "nsIDOMDataChannel.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/MessageEvent.h"
 #include "mozilla/dom/MessageEventBinding.h"
 #include "mozilla/dom/ScriptSettings.h"
 
 #include "nsError.h"
-#include "nsAutoPtr.h"
 #include "nsContentUtils.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsProxyRelease.h"
 
 #include "DataChannel.h"
 #include "DataChannelLog.h"
 
--- a/dom/base/nsDOMMutationObserver.h
+++ b/dom/base/nsDOMMutationObserver.h
@@ -10,17 +10,16 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/Move.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsPIDOMWindow.h"
 #include "nsIScriptContext.h"
 #include "nsStubAnimationObserver.h"
 #include "nsCOMArray.h"
 #include "nsTArray.h"
-#include "nsAutoPtr.h"
 #include "nsIVariant.h"
 #include "nsContentList.h"
 #include "mozilla/dom/Element.h"
 #include "nsClassHashtable.h"
 #include "nsNodeUtils.h"
 #include "nsIDOMMutationEvent.h"
 #include "nsWrapperCache.h"
 #include "mozilla/dom/MutationObserverBinding.h"
--- a/dom/base/nsDOMNavigationTiming.cpp
+++ b/dom/base/nsDOMNavigationTiming.cpp
@@ -20,17 +20,17 @@ nsDOMNavigationTiming::nsDOMNavigationTi
 
 nsDOMNavigationTiming::~nsDOMNavigationTiming()
 {
 }
 
 void
 nsDOMNavigationTiming::Clear()
 {
-  mNavigationType = mozilla::dom::PerformanceNavigation::TYPE_RESERVED;
+  mNavigationType = TYPE_RESERVED;
   mNavigationStartHighRes = 0;
   mBeforeUnloadStart = 0;
   mUnloadStart = 0;
   mUnloadEnd = 0;
   mLoadEventStart = 0;
   mLoadEventEnd = 0;
   mDOMLoading = 0;
   mDOMInteractive = 0;
@@ -65,17 +65,17 @@ DOMTimeMilliSec nsDOMNavigationTiming::D
 void
 nsDOMNavigationTiming::NotifyNavigationStart()
 {
   mNavigationStartHighRes = (double)PR_Now() / PR_USEC_PER_MSEC;
   mNavigationStartTimeStamp = mozilla::TimeStamp::Now();
 }
 
 void
-nsDOMNavigationTiming::NotifyFetchStart(nsIURI* aURI, nsDOMPerformanceNavigationType aNavigationType)
+nsDOMNavigationTiming::NotifyFetchStart(nsIURI* aURI, Type aNavigationType)
 {
   mNavigationType = aNavigationType;
   // At the unload event time we don't really know the loading uri.
   // Need it for later check for unload timing access.
   mLoadedURI = aURI;
 }
 
 void
@@ -197,9 +197,8 @@ nsDOMNavigationTiming::GetUnloadEventEnd
 {
   nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
   nsresult rv = ssm->CheckSameOriginURI(mLoadedURI, mUnloadedURI, false);
   if (NS_SUCCEEDED(rv)) {
     return mUnloadEnd;
   }
   return 0;
 }
-
--- a/dom/base/nsDOMNavigationTiming.h
+++ b/dom/base/nsDOMNavigationTiming.h
@@ -10,63 +10,84 @@
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 #include "mozilla/TimeStamp.h"
 
 class nsIURI;
 
 typedef unsigned long long DOMTimeMilliSec;
 typedef double DOMHighResTimeStamp;
-typedef unsigned short nsDOMPerformanceNavigationType;
 
 class nsDOMNavigationTiming final
 {
 public:
+  enum Type {
+    TYPE_NAVIGATE = 0,
+    TYPE_RELOAD = 1,
+    TYPE_BACK_FORWARD = 2,
+    TYPE_RESERVED = 255,
+  };
+
   nsDOMNavigationTiming();
 
   NS_INLINE_DECL_REFCOUNTING(nsDOMNavigationTiming)
 
-  nsDOMPerformanceNavigationType GetType() const {
+  Type GetType() const
+  {
     return mNavigationType;
   }
-  inline DOMHighResTimeStamp GetNavigationStartHighRes() const {
+
+  inline DOMHighResTimeStamp GetNavigationStartHighRes() const
+  {
     return mNavigationStartHighRes;
   }
-  DOMTimeMilliSec GetNavigationStart() const {
+
+  DOMTimeMilliSec GetNavigationStart() const
+  {
     return static_cast<int64_t>(GetNavigationStartHighRes());
   }
-  mozilla::TimeStamp GetNavigationStartTimeStamp() const {
+
+  mozilla::TimeStamp GetNavigationStartTimeStamp() const
+  {
     return mNavigationStartTimeStamp;
   }
+
   DOMTimeMilliSec GetUnloadEventStart();
   DOMTimeMilliSec GetUnloadEventEnd();
-  DOMTimeMilliSec GetDomLoading() const {
+  DOMTimeMilliSec GetDomLoading() const
+  {
     return mDOMLoading;
   }
-  DOMTimeMilliSec GetDomInteractive() const {
+  DOMTimeMilliSec GetDomInteractive() const
+  {
     return mDOMInteractive;
   }
-  DOMTimeMilliSec GetDomContentLoadedEventStart() const {
+  DOMTimeMilliSec GetDomContentLoadedEventStart() const
+  {
     return mDOMContentLoadedEventStart;
   }
-  DOMTimeMilliSec GetDomContentLoadedEventEnd() const {
+  DOMTimeMilliSec GetDomContentLoadedEventEnd() const
+  {
     return mDOMContentLoadedEventEnd;
   }
-  DOMTimeMilliSec GetDomComplete() const {
+  DOMTimeMilliSec GetDomComplete() const
+  {
     return mDOMComplete;
   }
-  DOMTimeMilliSec GetLoadEventStart() const {
+  DOMTimeMilliSec GetLoadEventStart() const
+  {
     return mLoadEventStart;
   }
-  DOMTimeMilliSec GetLoadEventEnd() const {
+  DOMTimeMilliSec GetLoadEventEnd() const
+  {
     return mLoadEventEnd;
   }
 
   void NotifyNavigationStart();
-  void NotifyFetchStart(nsIURI* aURI, nsDOMPerformanceNavigationType aNavigationType);
+  void NotifyFetchStart(nsIURI* aURI, Type aNavigationType);
   void NotifyBeforeUnload();
   void NotifyUnloadAccepted(nsIURI* aOldURI);
   void NotifyUnloadEventStart();
   void NotifyUnloadEventEnd();
   void NotifyLoadEventStart();
   void NotifyLoadEventEnd();
 
   // Document changes state to 'loading' before connecting to timing
@@ -88,17 +109,17 @@ private:
   nsDOMNavigationTiming(const nsDOMNavigationTiming &) = delete;
   ~nsDOMNavigationTiming();
 
   void Clear();
 
   nsCOMPtr<nsIURI> mUnloadedURI;
   nsCOMPtr<nsIURI> mLoadedURI;
 
-  nsDOMPerformanceNavigationType mNavigationType;
+  Type mNavigationType;
   DOMHighResTimeStamp mNavigationStartHighRes;
   mozilla::TimeStamp mNavigationStartTimeStamp;
   DOMTimeMilliSec DurationFromStart();
 
   DOMTimeMilliSec mBeforeUnloadStart;
   DOMTimeMilliSec mUnloadStart;
   DOMTimeMilliSec mUnloadEnd;
   DOMTimeMilliSec mLoadEventStart;
--- a/dom/base/nsDOMSerializer.h
+++ b/dom/base/nsDOMSerializer.h
@@ -6,17 +6,16 @@
 
 #ifndef nsDOMSerializer_h_
 #define nsDOMSerializer_h_
 
 #include "nsIDOMSerializer.h"
 #include "nsWrapperCache.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/XMLSerializerBinding.h"
-#include "nsAutoPtr.h"
 
 class nsINode;
 
 class nsDOMSerializer final : public nsIDOMSerializer,
                               public nsWrapperCache
 {
 public:
   nsDOMSerializer();
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -2245,18 +2245,18 @@ nsFocusManager::UpdateCaret(bool aMoveCa
 
 void
 nsFocusManager::MoveCaretToFocus(nsIPresShell* aPresShell, nsIContent* aContent)
 {
   // domDoc is a document interface we can create a range with
   nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(aPresShell->GetDocument());
   if (domDoc) {
     RefPtr<nsFrameSelection> frameSelection = aPresShell->FrameSelection();
-    nsCOMPtr<nsISelection> domSelection = frameSelection->
-      GetSelection(nsISelectionController::SELECTION_NORMAL);
+    nsCOMPtr<nsISelection> domSelection =
+      frameSelection->GetSelection(SelectionType::eNormal);
     if (domSelection) {
       nsCOMPtr<nsIDOMNode> currentFocusNode(do_QueryInterface(aContent));
       // First clear the selection. This way, if there is no currently focused
       // content, the selection will just be cleared.
       domSelection->RemoveAllRanges();
       if (currentFocusNode) {
         nsCOMPtr<nsIDOMRange> newRange;
         nsresult rv = domDoc->CreateRange(getter_AddRefs(newRange));
@@ -2306,18 +2306,18 @@ nsFocusManager::SetCaretVisible(nsIPresS
     if (focusFrame)
       frameSelection = focusFrame->GetFrameSelection();
   }
 
   RefPtr<nsFrameSelection> docFrameSelection = aPresShell->FrameSelection();
 
   if (docFrameSelection && caret &&
      (frameSelection == docFrameSelection || !aContent)) {
-    nsISelection* domSelection = docFrameSelection->
-      GetSelection(nsISelectionController::SELECTION_NORMAL);
+    nsISelection* domSelection =
+      docFrameSelection->GetSelection(SelectionType::eNormal);
     if (domSelection) {
       nsCOMPtr<nsISelectionController> selCon(do_QueryInterface(aPresShell));
       if (!selCon) {
         return NS_ERROR_FAILURE;
       }
       // First, hide the caret to prevent attempting to show it in SetCaretDOMSelection
       selCon->SetCaretEnabled(false);
 
@@ -2349,18 +2349,17 @@ nsFocusManager::GetSelectionLocation(nsI
 
   nsPresContext* presContext = aPresShell->GetPresContext();
   NS_ASSERTION(presContext, "mPresContent is null!!");
 
   RefPtr<nsFrameSelection> frameSelection = aPresShell->FrameSelection();
 
   nsCOMPtr<nsISelection> domSelection;
   if (frameSelection) {
-    domSelection = frameSelection->
-      GetSelection(nsISelectionController::SELECTION_NORMAL);
+    domSelection = frameSelection->GetSelection(SelectionType::eNormal);
   }
 
   nsCOMPtr<nsIDOMNode> startNode, endNode;
   bool isCollapsed = false;
   nsCOMPtr<nsIContent> startContent, endContent;
   int32_t startOffset = 0;
   if (domSelection) {
     domSelection->GetIsCollapsed(&isCollapsed);
--- a/dom/base/nsFrameLoader.h
+++ b/dom/base/nsFrameLoader.h
@@ -13,17 +13,16 @@
 #define nsFrameLoader_h_
 
 #include "nsIDocShell.h"
 #include "nsStringFwd.h"
 #include "nsIFrameLoader.h"
 #include "nsPoint.h"
 #include "nsSize.h"
 #include "nsIURI.h"
-#include "nsAutoPtr.h"
 #include "nsFrameMessageManager.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/Attributes.h"
 #include "nsStubMutationObserver.h"
 #include "Units.h"
 #include "nsIWebBrowserPersistable.h"
 #include "nsIFrame.h"
 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -120,17 +120,16 @@
 #include "nsDOMWindowUtils.h"
 #include "nsIWindowWatcher.h"
 #include "nsPIWindowWatcher.h"
 #include "nsIContentViewer.h"
 #include "nsIScriptError.h"
 #include "nsIControllers.h"
 #include "nsIControllerContext.h"
 #include "nsGlobalWindowCommands.h"
-#include "nsAutoPtr.h"
 #include "nsQueryObject.h"
 #include "nsContentUtils.h"
 #include "nsCSSProps.h"
 #include "nsIDOMFileList.h"
 #include "nsIURIFixup.h"
 #ifndef DEBUG
 #include "nsIAppStartup.h"
 #include "nsToolkitCompsCID.h"
@@ -9424,17 +9423,18 @@ nsGlobalWindow::GetSelectionOuter()
     return nullptr;
   }
 
   nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
   if (!presShell) {
     return nullptr;
   }
 
-  return static_cast<Selection*>(presShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL));
+  return static_cast<Selection*>(
+           presShell->GetCurrentSelection(SelectionType::eNormal));
 }
 
 Selection*
 nsGlobalWindow::GetSelection(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetSelectionOuter, (), aError, nullptr);
 }
 
--- a/dom/base/nsGlobalWindowCommands.cpp
+++ b/dom/base/nsGlobalWindowCommands.cpp
@@ -538,17 +538,17 @@ nsClipboardCommand::DoCommand(const char
   bool actionTaken = false;
   bool notCancelled =
     nsCopySupport::FireClipboardEvent(eventMessage,
                                       nsIClipboard::kGlobalClipboard,
                                       presShell, nullptr, &actionTaken);
 
   if (notCancelled && !strcmp(aCommandName, "cmd_copyAndCollapseToEnd")) {
     dom::Selection *sel =
-      presShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL);
+      presShell->GetCurrentSelection(SelectionType::eNormal);
     NS_ENSURE_TRUE(sel, NS_ERROR_FAILURE);
     sel->CollapseToEnd();
   }
 
   if (actionTaken) {
     return NS_OK;
   }
   return NS_ERROR_FAILURE;
--- a/dom/base/nsHostObjectURI.cpp
+++ b/dom/base/nsHostObjectURI.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsHostObjectURI.h"
 
-#include "nsAutoPtr.h"
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/ipc/URIUtils.h"
 
 static NS_DEFINE_CID(kHOSTOBJECTURICID, NS_HOSTOBJECTURI_CID);
 
--- a/dom/base/nsISelectionController.idl
+++ b/dom/base/nsISelectionController.idl
@@ -2,41 +2,42 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 #include "nsISelectionDisplay.idl"
 
 %{C++
-typedef short SelectionType;
 typedef short SelectionRegion;
 %}
 
 interface nsIContent;
 interface nsIDOMNode;
 interface nsISelection;
 interface nsISelectionDisplay;
 
 [scriptable, uuid(3801c9d4-8e69-4bfc-9edb-b58278621f8f)]
 interface nsISelectionController : nsISelectionDisplay
 {
+   // RawSelectionType values:
    const short SELECTION_NONE=0;
    const short SELECTION_NORMAL=1;
    const short SELECTION_SPELLCHECK=2;
    const short SELECTION_IME_RAWINPUT=4;
    const short SELECTION_IME_SELECTEDRAWTEXT=8;
    const short SELECTION_IME_CONVERTEDTEXT=16;
    const short SELECTION_IME_SELECTEDCONVERTEDTEXT=32;
    const short SELECTION_ACCESSIBILITY=64; // For accessibility API usage
    const short SELECTION_FIND=128;
    const short SELECTION_URLSECONDARY=256;
    const short SELECTION_URLSTRIKEOUT=512;
    const short NUM_SELECTIONTYPES=11;
 
+   // SelectionRegion values:
    const short SELECTION_ANCHOR_REGION = 0;
    const short SELECTION_FOCUS_REGION = 1;
    const short SELECTION_WHOLE_SELECTION = 2;
    const short NUM_SELECTION_REGIONS = 3;
 
    const short SELECTION_OFF = 0;
    const short SELECTION_HIDDEN =1;//>HIDDEN displays selection
    const short SELECTION_ON = 2;
@@ -52,32 +53,34 @@ interface nsISelectionController : nsISe
    * GetDisplaySelection will get the display mode for the selection. OFF,ON,DISABLED
    */
     short   getDisplaySelection();
 
    /**
    * GetSelection will return the selection that the presentation
    *  shell may implement.
    *
-   * @param aType will hold the type of selection //SelectionType
+   * @param aType This will hold the type of selection.  This value must be one
+   *              of RawSelectionType values.
    * @param _return will hold the return value
    */
     nsISelection getSelection(in short type);
 
    const short SCROLL_SYNCHRONOUS = 1<<1;
    const short SCROLL_FIRST_ANCESTOR_ONLY = 1<<2;
    const short SCROLL_CENTER_VERTICALLY = 1<<4;
    const short SCROLL_OVERFLOW_HIDDEN = 1<<5;
    const short SCROLL_FOR_CARET_MOVE = 1<<6;
 
    /**
    * ScrollSelectionIntoView scrolls a region of the selection,
    * so that it is visible in the scrolled view.
    *
-   * @param aType the selection to scroll into view. //SelectionType
+   * @param aType the selection to scroll into view.  This value must be one
+   *              of RawSelectionType values.
    * @param aRegion the region inside the selection to scroll into view. //SelectionRegion
    * @param aFlags the scroll flags.  Valid bits include:
    * SCROLL_SYNCHRONOUS: when set, scrolls the selection into view
    * before returning. If not set, posts a request which is processed
    * at some point after the method returns.
    * SCROLL_FIRST_ANCESTOR_ONLY: if set, only the first ancestor will be scrolled
    * into view.
    * SCROLL_OVERFLOW_HIDDEN: if set, scrolls even if the overflow is specified
@@ -270,9 +273,50 @@ interface nsISelectionController : nsISe
    */
     boolean checkVisibility(in nsIDOMNode node, in short startOffset, in short endOffset);
     [noscript,nostdcall] boolean checkVisibilityContent(in nsIContent node, in short startOffset, in short endOffset);
 };
 %{ C++
    #define NS_ISELECTIONCONTROLLER_CID \
    { 0x513b9460, 0xd56a, 0x4c4e, \
    { 0xb6, 0xf9, 0x0b, 0x8a, 0xe4, 0x37, 0x2a, 0x3b }}
+
+namespace mozilla {
+
+typedef short RawSelectionType;
+enum class SelectionType : RawSelectionType
+{
+  eInvalid = -1,
+  eNone = nsISelectionController::SELECTION_NONE,
+  eNormal = nsISelectionController::SELECTION_NORMAL,
+  eSpellCheck = nsISelectionController::SELECTION_SPELLCHECK,
+  eIMERawClause = nsISelectionController::SELECTION_IME_RAWINPUT,
+  eIMESelectedRawClause = nsISelectionController::SELECTION_IME_SELECTEDRAWTEXT,
+  eIMEConvertedClause = nsISelectionController::SELECTION_IME_CONVERTEDTEXT,
+  eIMESelectedClause =
+    nsISelectionController::SELECTION_IME_SELECTEDCONVERTEDTEXT,
+  eAccessibility = nsISelectionController::SELECTION_ACCESSIBILITY,
+  eFind = nsISelectionController::SELECTION_FIND,
+  eURLSecondary = nsISelectionController::SELECTION_URLSECONDARY,
+  eURLStrikeout = nsISelectionController::SELECTION_URLSTRIKEOUT,
+};
+
+// Using anonymous enum to define constants because these constants may be
+// used at defining fixed size array in some header files (e.g.,
+// nsFrameSelection.h).  So, the values needs to be defined here, but we cannot
+// use static/const even with extern since it causes failing to link or
+// initializes them after such headers.
+enum : size_t
+{
+  // kSelectionTypeCount is number of SelectionType.
+  kSelectionTypeCount = nsISelectionController::NUM_SELECTIONTYPES,
+  // kPresentSelectionTypeCount is number of SelectionType except "none".
+  kPresentSelectionTypeCount = kSelectionTypeCount - 1
+};
+
+const char* ToChar(SelectionType aSelectionType);
+SelectionType ToSelectionType(RawSelectionType aRawSelectionType);
+RawSelectionType ToRawSelectionType(SelectionType aSelectionType);
+bool operator &(SelectionType aSelectionType,
+                RawSelectionType aRawSelectionTypes);
+
+} // namespace mozilla
 %}
--- a/dom/base/nsImageLoadingContent.cpp
+++ b/dom/base/nsImageLoadingContent.cpp
@@ -6,17 +6,16 @@
 
 /*
  * A base class which implements nsIImageLoadingContent and can be
  * subclassed by various content nodes that want to provide image
  * loading functionality (eg <img>, <object>, etc).
  */
 
 #include "nsImageLoadingContent.h"
-#include "nsAutoPtr.h"
 #include "nsError.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIDOMWindow.h"
 #include "nsServiceManagerUtils.h"
 #include "nsContentPolicyUtils.h"
 #include "nsIURI.h"
--- a/dom/base/nsImageLoadingContent.h
+++ b/dom/base/nsImageLoadingContent.h
@@ -17,17 +17,16 @@
 #include "imgIOnloadBlocker.h"
 #include "mozilla/CORSMode.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/TimeStamp.h"
 #include "nsCOMPtr.h"
 #include "nsIImageLoadingContent.h"
 #include "nsIRequest.h"
 #include "mozilla/ErrorResult.h"
-#include "nsAutoPtr.h"
 #include "nsIContentPolicy.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/net/ReferrerPolicy.h"
 
 class nsIURI;
 class nsIDocument;
 class nsPresContext;
 class nsIContent;
--- a/dom/base/nsMimeTypeArray.h
+++ b/dom/base/nsMimeTypeArray.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsMimeTypeArray_h___
 #define nsMimeTypeArray_h___
 
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsWrapperCache.h"
-#include "nsAutoPtr.h"
 #include "nsPIDOMWindow.h"
 
 class nsMimeType;
 class nsPluginElement;
 
 class nsMimeTypeArray final : public nsISupports,
                               public nsWrapperCache
 {
--- a/dom/base/nsNameSpaceManager.cpp
+++ b/dom/base/nsNameSpaceManager.cpp
@@ -7,17 +7,16 @@
 /*
  * A class for managing namespace IDs and mapping back and forth
  * between namespace IDs and namespace URIs.
  */
 
 #include "nsNameSpaceManager.h"
 
 #include "nscore.h"
-#include "nsAutoPtr.h"
 #include "mozilla/dom/NodeInfo.h"
 #include "nsCOMArray.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsGkAtoms.h"
 #include "nsString.h"
 #include "mozilla/dom/NodeInfo.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/dom/XBLChildrenElement.h"
--- a/dom/base/nsNodeInfoManager.h
+++ b/dom/base/nsNodeInfoManager.h
@@ -8,17 +8,16 @@
  * A class for handing out nodeinfos and ensuring sharing of them as needed.
  */
 
 #ifndef nsNodeInfoManager_h___
 #define nsNodeInfoManager_h___
 
 #include "mozilla/Attributes.h"           // for final
 #include "nsCOMPtr.h"                     // for member
-#include "nsAutoPtr.h"                    // for nsRefPtr
 #include "nsCycleCollectionParticipant.h" // for NS_DECL_CYCLE_*
 #include "plhash.h"                       // for typedef PLHashNumber
 
 class nsAString;
 class nsBindingManager;
 class nsIAtom;
 class nsIDocument;
 class nsIDOMDocumentType;
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -44,17 +44,16 @@
 #include "nsIScriptError.h"
 
 #include "nsError.h"
 
 // Util headers
 #include "prenv.h"
 #include "mozilla/Logging.h"
 
-#include "nsAutoPtr.h"
 #include "nsCURILoader.h"
 #include "nsContentPolicyUtils.h"
 #include "nsContentUtils.h"
 #include "nsDocShellCID.h"
 #include "nsGkAtoms.h"
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
 #include "nsMimeTypes.h"
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -6,17 +6,16 @@
 
 #ifndef nsPIDOMWindow_h__
 #define nsPIDOMWindow_h__
 
 #include "nsIDOMWindow.h"
 #include "mozIDOMWindow.h"
 
 #include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "mozilla/dom/EventTarget.h"
 #include "js/TypeDecls.h"
 #include "nsRefPtrHashtable.h"
 
 // Only fired for inner windows.
 #define DOM_WINDOW_DESTROYED_TOPIC "dom-window-destroyed"
 #define DOM_WINDOW_FROZEN_TOPIC "dom-window-frozen"
--- a/dom/base/nsPlainTextSerializer.h
+++ b/dom/base/nsPlainTextSerializer.h
@@ -9,17 +9,16 @@
  * nsIDocumentEncoder to convert a DOM into plaintext in a nice way
  * (eg for copy/paste as plaintext).
  */
 
 #ifndef nsPlainTextSerializer_h__
 #define nsPlainTextSerializer_h__
 
 #include "mozilla/Attributes.h"
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsIAtom.h"
 #include "nsIContentSerializer.h"
 #include "nsIDocumentEncoder.h"
 #include "nsILineBreaker.h"
 #include "nsString.h"
 #include "nsTArray.h"
 
--- a/dom/base/nsReferencedElement.h
+++ b/dom/base/nsReferencedElement.h
@@ -7,17 +7,16 @@
 #ifndef NSREFERENCEDELEMENT_H_
 #define NSREFERENCEDELEMENT_H_
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/Element.h"
 #include "nsIAtom.h"
 #include "nsIDocument.h"
 #include "nsThreadUtils.h"
-#include "nsAutoPtr.h"
 
 class nsIURI;
 
 /**
  * Class to track what element is referenced by a given ID.
  * 
  * To use it, call Reset() to set it up to watch a given URI. Call get()
  * anytime to determine the referenced element (which may be null if
--- a/dom/base/nsScriptElement.cpp
+++ b/dom/base/nsScriptElement.cpp
@@ -7,17 +7,16 @@
 #include "nsScriptElement.h"
 #include "mozilla/BasicEvents.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/dom/Element.h"
 #include "nsContentUtils.h"
 #include "nsPresContext.h"
 #include "nsScriptLoader.h"
 #include "nsIParser.h"
-#include "nsAutoPtr.h"
 #include "nsGkAtoms.h"
 #include "nsContentSink.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 NS_IMETHODIMP
 nsScriptElement::ScriptAvailable(nsresult aResult,
--- a/dom/base/nsSyncLoadService.cpp
+++ b/dom/base/nsSyncLoadService.cpp
@@ -18,17 +18,16 @@
 #include "nsString.h"
 #include "nsWeakReference.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIPrincipal.h"
 #include "nsContentUtils.h" // for kLoadAsData
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
-#include "nsAutoPtr.h"
 #include "nsStreamUtils.h"
 #include <algorithm>
 
 using mozilla::net::ReferrerPolicy;
 
 /**
  * This class manages loading a single XML document
  */
--- a/dom/base/nsWindowMemoryReporter.h
+++ b/dom/base/nsWindowMemoryReporter.h
@@ -8,17 +8,16 @@
 #define nsWindowMemoryReporter_h__
 
 #include "nsGlobalWindow.h"
 #include "nsIMemoryReporter.h"
 #include "nsIObserver.h"
 #include "nsITimer.h"
 #include "nsDataHashtable.h"
 #include "nsWeakReference.h"
-#include "nsAutoPtr.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/TimeStamp.h"
 #include "nsArenaMemoryStats.h"
 
 class nsWindowSizes {
--- a/dom/base/nsWindowRoot.h
+++ b/dom/base/nsWindowRoot.h
@@ -10,17 +10,16 @@
 class nsIDOMEvent;
 class nsIGlobalObject;
 
 #include "mozilla/Attributes.h"
 #include "mozilla/EventListenerManager.h"
 #include "nsIDOMEventTarget.h"
 #include "nsPIWindowRoot.h"
 #include "nsCycleCollectionParticipant.h"
-#include "nsAutoPtr.h"
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 
 class nsWindowRoot final : public nsPIWindowRoot
 {
 public:
   explicit nsWindowRoot(nsPIDOMWindowOuter* aWindow);
 
--- a/dom/base/nsXMLHttpRequest.h
+++ b/dom/base/nsXMLHttpRequest.h
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsXMLHttpRequest_h__
 #define nsXMLHttpRequest_h__
 
+#include "nsAutoPtr.h"
 #include "nsIXMLHttpRequest.h"
 #include "nsISupportsUtils.h"
 #include "nsString.h"
 #include "nsIURI.h"
 #include "nsIHttpChannel.h"
 #include "nsIDocument.h"
 #include "nsIStreamListener.h"
 #include "nsWeakReference.h"
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -24,16 +24,17 @@
 #include "mozilla/dom/NonRefcountedDOMObject.h"
 #include "mozilla/dom/Nullable.h"
 #include "mozilla/dom/RootedDictionary.h"
 #include "mozilla/SegmentedVector.h"
 #include "mozilla/dom/workers/Workers.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MemoryReporting.h"
+#include "nsAutoPtr.h"
 #include "nsIDocument.h"
 #include "nsIGlobalObject.h"
 #include "nsIXPConnect.h"
 #include "nsJSUtils.h"
 #include "nsISupportsImpl.h"
 #include "qsObjectHelper.h"
 #include "xpcpublic.h"
 #include "nsIVariant.h"
--- a/dom/broadcastchannel/BroadcastChannel.h
+++ b/dom/broadcastchannel/BroadcastChannel.h
@@ -4,16 +4,17 @@
  * 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 mozilla_dom_BroadcastChannel_h
 #define mozilla_dom_BroadcastChannel_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/DOMEventTargetHelper.h"
+#include "nsAutoPtr.h"
 #include "nsIIPCBackgroundChildCreateCallback.h"
 #include "nsIObserver.h"
 #include "nsTArray.h"
 #include "mozilla/RefPtr.h"
 
 class nsPIDOMWindowInner;
 
 namespace mozilla {
--- a/dom/cache/Context.h
+++ b/dom/cache/Context.h
@@ -3,17 +3,16 @@
 /* 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 mozilla_dom_cache_Context_h
 #define mozilla_dom_cache_Context_h
 
 #include "mozilla/dom/cache/Types.h"
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsISupportsImpl.h"
 #include "nsProxyRelease.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsTObserverArray.h"
 
 class nsIEventTarget;
--- a/dom/cache/Manager.cpp
+++ b/dom/cache/Manager.cpp
@@ -17,17 +17,16 @@
 #include "mozilla/dom/cache/FileUtils.h"
 #include "mozilla/dom/cache/ManagerId.h"
 #include "mozilla/dom/cache/CacheTypes.h"
 #include "mozilla/dom/cache/SavedTypes.h"
 #include "mozilla/dom/cache/StreamList.h"
 #include "mozilla/dom/cache/Types.h"
 #include "mozilla/ipc/BackgroundParent.h"
 #include "mozStorageHelper.h"
-#include "nsAutoPtr.h"
 #include "nsIInputStream.h"
 #include "nsID.h"
 #include "nsIFile.h"
 #include "nsIThread.h"
 #include "nsThreadUtils.h"
 #include "nsTObserverArray.h"
 
 
--- a/dom/camera/DOMCameraCapabilities.h
+++ b/dom/camera/DOMCameraCapabilities.h
@@ -3,17 +3,16 @@
 /* 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 mozilla_dom_CameraCapabilities_h__
 #define mozilla_dom_CameraCapabilities_h__
 
 #include "nsString.h"
-#include "nsAutoPtr.h"
 #include "base/basictypes.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/CameraManagerBinding.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "nsPIDOMWindow.h"
 #include "nsHashKeys.h"
--- a/dom/camera/DOMCameraControl.h
+++ b/dom/camera/DOMCameraControl.h
@@ -1,17 +1,16 @@
 /* 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 DOM_CAMERA_DOMCAMERACONTROL_H
 #define DOM_CAMERA_DOMCAMERACONTROL_H
 
 #include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/dom/CameraControlBinding.h"
 #include "mozilla/dom/Promise.h"
 #include "ICameraControl.h"
 #include "CameraCommon.h"
 #include "DOMMediaStream.h"
 #include "AudioChannelAgent.h"
 #include "nsProxyRelease.h"
--- a/dom/camera/DOMCameraManager.cpp
+++ b/dom/camera/DOMCameraManager.cpp
@@ -34,18 +34,18 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCameraManager)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCameraManager)
 
 /**
  * Global camera logging object
  *
- * Set the NSPR_LOG_MODULES environment variable to enable logging
- * in a debug build, e.g. NSPR_LOG_MODULES=Camera:5
+ * Set the MOZ_LOG environment variable to enable logging
+ * in a debug build, e.g. MOZ_LOG=Camera:5
  */
 LogModule*
 GetCameraLog()
 {
   static LazyLogModule sLog("Camera");
   return sLog;
 }
 
--- a/dom/camera/DOMCameraManager.h
+++ b/dom/camera/DOMCameraManager.h
@@ -5,17 +5,16 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef DOM_CAMERA_DOMCAMERAMANAGER_H
 #define DOM_CAMERA_DOMCAMERAMANAGER_H
 
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/Promise.h"
 #include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
 #include "nsIObserver.h"
 #include "nsHashKeys.h"
 #include "nsWrapperCache.h"
 #include "nsWeakReference.h"
 #include "nsClassHashtable.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Attributes.h"
 
--- a/dom/camera/GonkCameraControl.cpp
+++ b/dom/camera/GonkCameraControl.cpp
@@ -27,17 +27,16 @@
 #include <media/mediaplayer.h>
 #include <media/MediaProfiles.h>
 #include "GrallocImages.h"
 #include "imgIEncoder.h"
 #include "libyuv.h"
 #include "nsNetUtil.h" // for NS_ReadInputStreamToBuffer
 #endif
 #include "nsNetCID.h" // for NS_STREAMTRANSPORTSERVICE_CONTRACTID
-#include "nsAutoPtr.h" // for nsAutoArrayPtr
 #include "nsCOMPtr.h"
 #include "nsMemory.h"
 #include "nsThread.h"
 #include "nsITimer.h"
 #include "mozilla/FileUtils.h"
 #include "mozilla/Services.h"
 #include "mozilla/unused.h"
 #include "mozilla/ipc/FileDescriptorUtils.h"
--- a/dom/camera/ICameraControl.h
+++ b/dom/camera/ICameraControl.h
@@ -2,17 +2,16 @@
  * 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 DOM_CAMERA_ICAMERACONTROL_H
 #define DOM_CAMERA_ICAMERACONTROL_H
 
 #include "nsCOMPtr.h"
 #include "nsString.h"
-#include "nsAutoPtr.h"
 #include "nsISupportsImpl.h"
 #include "base/basictypes.h"
 
 struct DeviceStorageFileDescriptor;
 
 namespace mozilla {
 
 class CameraControlListener;
--- a/dom/camera/TestGonkCameraHardware.h
+++ b/dom/camera/TestGonkCameraHardware.h
@@ -13,17 +13,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 #ifndef DOM_CAMERA_TESTGONKCAMERAHARDWARE_H
 #define DOM_CAMERA_TESTGONKCAMERAHARDWARE_H
 
 #include "GonkCameraHwMgr.h"
-#include "nsAutoPtr.h"
 #include "nsIDOMEventListener.h"
 #include "mozilla/CondVar.h"
 
 namespace mozilla {
 
 class TestGonkCameraHardware : public android::GonkCameraHardware
 {
 #ifndef MOZ_WIDGET_GONK
--- a/dom/canvas/CanvasImageCache.cpp
+++ b/dom/canvas/CanvasImageCache.cpp
@@ -1,14 +1,15 @@
 /* -*- 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/. */
 
 #include "CanvasImageCache.h"
+#include "nsAutoPtr.h"
 #include "nsIImageLoadingContent.h"
 #include "nsExpirationTracker.h"
 #include "imgIRequest.h"
 #include "mozilla/dom/Element.h"
 #include "nsTHashtable.h"
 #include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsContentUtils.h"
 #include "mozilla/Preferences.h"
@@ -262,17 +263,17 @@ ImageCache::ImageCache()
   : nsExpirationTracker<ImageCacheEntryData,4>(GENERATION_MS, "ImageCache")
   , mTotal(0)
 {
   if (!sPrefsInitialized) {
     sPrefsInitialized = true;
     Preferences::AddIntVarCache(&sCanvasImageCacheLimit, "canvas.image.cache.limit", 0);
   }
   mImageCacheObserver = new ImageCacheObserver(this);
-  MOZ_RELEASE_ASSERT(mImageCacheObserver, "Can't alloc ImageCacheObserver");
+  MOZ_RELEASE_ASSERT(mImageCacheObserver, "GFX: Can't alloc ImageCacheObserver");
 }
 
 ImageCache::~ImageCache() {
   AgeAllGenerations();
   mImageCacheObserver->Destroy();
 }
 
 static already_AddRefed<imgIContainer>
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -3,16 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "CanvasRenderingContext2D.h"
 
 #include "mozilla/gfx/Helpers.h"
 #include "nsXULElement.h"
 
+#include "nsAutoPtr.h"
 #include "nsIServiceManager.h"
 #include "nsMathUtils.h"
 #include "SVGImageContext.h"
 
 #include "nsContentUtils.h"
 
 #include "nsIDocument.h"
 #include "mozilla/dom/HTMLCanvasElement.h"
@@ -43,17 +44,16 @@
 #include "nsFocusManager.h"
 
 #include "nsTArray.h"
 
 #include "ImageEncoder.h"
 #include "ImageRegion.h"
 
 #include "gfxContext.h"
-#include "gfxASurface.h"
 #include "gfxImageSurface.h"
 #include "gfxPlatform.h"
 #include "gfxFont.h"
 #include "gfxBlur.h"
 #include "gfxPrefs.h"
 #include "gfxUtils.h"
 
 #include "nsFrameLoader.h"
@@ -891,17 +891,17 @@ public:
     : nsSVGFilterChainObserver(aFilters, aCanvasElement)
     , mContext(aContext)
   {
   }
 
   virtual void DoUpdate() override
   {
     if (!mContext) {
-      MOZ_CRASH("This should never be called without a context");
+      MOZ_CRASH("GFX: This should never be called without a context");
     }
     // Refresh the cached FilterDescription in mContext->CurrentState().filter.
     // If this filter is not at the top of the state stack, we'll refresh the
     // wrong filter, but that's ok, because we'll refresh the right filter
     // when we pop the state stack in CanvasRenderingContext2D::Restore().
     mContext->UpdateFilter();
   }
 
@@ -2351,17 +2351,17 @@ GetFontStyleContext(Element* aElement, c
     GetFontParentStyleContext(aElement, aPresShell, aError);
 
   if (aError.Failed()) {
     aError.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   MOZ_RELEASE_ASSERT(parentContext,
-                     "GetFontParentStyleContext should have returned an error if it couldn't get a parent context.");
+                     "GFX: GetFontParentStyleContext should have returned an error if it couldn't get a parent context.");
 
   MOZ_ASSERT(!aPresShell->IsDestroying(),
              "GetFontParentStyleContext should have returned an error if the presshell is being destroyed.");
 
   nsTArray<nsCOMPtr<nsIStyleRule>> rules;
   rules.AppendElement(decl);
   // add a rule to prevent text zoom from affecting the style
   rules.AppendElement(new nsDisableTextZoomStyleRule);
@@ -4011,17 +4011,17 @@ CanvasRenderingContext2D::DrawOrMeasureT
     // fall through; best we can do with the information available
   case TextBaseline::ALPHABETIC:
     baselineAnchor = 0;
     break;
   case TextBaseline::BOTTOM:
     baselineAnchor = -fontMetrics.emDescent;
     break;
   default:
-    MOZ_CRASH("unexpected TextBaseline");
+    MOZ_CRASH("GFX: unexpected TextBaseline");
   }
 
   // We can't query the textRun directly, as it may not have been created yet;
   // so instead we check the flags that will be used to initialize it.
   uint16_t runOrientation =
     (processor.mTextRunFlags & gfxTextRunFactory::TEXT_ORIENT_MASK);
   if (runOrientation != gfxTextRunFactory::TEXT_ORIENT_HORIZONTAL) {
     if (runOrientation == gfxTextRunFactory::TEXT_ORIENT_VERTICAL_MIXED ||
@@ -4905,20 +4905,23 @@ CanvasRenderingContext2D::GetGlobalCompo
 void
 CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& aWindow, double aX,
                                      double aY, double aW, double aH,
                                      const nsAString& aBgColor,
                                      uint32_t aFlags, ErrorResult& aError)
 {
   MOZ_ASSERT(aWindow.IsInnerWindow());
 
+  if (int32_t(aW) == 0 || int32_t(aH) == 0) {
+    return;
+  }
+
   // protect against too-large surfaces that will cause allocation
   // or overflow issues
-  if (!gfxASurface::CheckSurfaceSize(gfx::IntSize(int32_t(aW), int32_t(aH)),
-                                     0xffff)) {
+  if (!Factory::CheckSurfaceSize(IntSize(int32_t(aW), int32_t(aH)), 0xffff)) {
     aError.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   EnsureTarget();
   // We can't allow web apps to call this until we fix at least the
   // following potential security issues:
   // -- rendering cross-domain IFRAMEs and then extracting the results
@@ -5108,17 +5111,17 @@ CanvasRenderingContext2D::AsyncDrawXULEl
     }
 
     return DrawWindow(window->GetCurrentInnerWindow(), aX, aY, aW, aH,
                       aBgColor, aFlags);
   }
 
   // protect against too-large surfaces that will cause allocation
   // or overflow issues
-  if (!gfxASurface::CheckSurfaceSize(gfx::IntSize(aW, aH), 0xffff)) {
+  if (!Factory::CheckSurfaceSize(IntSize(aW, aH), 0xffff)) {
     aError.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   bool flush =
     (aFlags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_DO_NOT_FLUSH) == 0;
 
   uint32_t renderDocFlags = nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING;
--- a/dom/canvas/CanvasRenderingContext2D.h
+++ b/dom/canvas/CanvasRenderingContext2D.h
@@ -756,20 +756,16 @@ protected:
 
   /**
    * Flag to avoid unnecessary surface copies to FrameCaptureListeners in the
    * case when the canvas is not currently being drawn into and not rendered
    * but canvas capturing is still ongoing.
    */
   bool mIsCapturedFrameInvalid;
 
-  // This is stored after GetThebesSurface has been called once to avoid
-  // excessive ThebesSurface initialization overhead.
-  RefPtr<gfxASurface> mThebesSurface;
-
   /**
     * We also have a device space pathbuilder. The reason for this is as
     * follows, when a path is being built, but the transform changes, we
     * can no longer keep a single path in userspace, considering there's
     * several 'user spaces' now. We therefore transform the current path
     * into device space, and add all operations to this path in device
     * space.
     *
--- a/dom/canvas/OffscreenCanvas.cpp
+++ b/dom/canvas/OffscreenCanvas.cpp
@@ -85,20 +85,20 @@ OffscreenCanvas::ClearResources()
 {
   if (mCanvasClient) {
     mCanvasClient->Clear();
     ImageBridgeChild::DispatchReleaseCanvasClient(mCanvasClient);
     mCanvasClient = nullptr;
 
     if (mCanvasRenderer) {
       nsCOMPtr<nsIThread> activeThread = mCanvasRenderer->GetActiveThread();
-      MOZ_RELEASE_ASSERT(activeThread);
+      MOZ_RELEASE_ASSERT(activeThread, "GFX: failed to get active thread.");
       bool current;
       activeThread->IsOnCurrentThread(&current);
-      MOZ_RELEASE_ASSERT(current);
+      MOZ_RELEASE_ASSERT(current, "GFX: active thread is not current thread.");
       mCanvasRenderer->SetCanvasClient(nullptr);
       mCanvasRenderer->mContext = nullptr;
       mCanvasRenderer->mGLContext = nullptr;
       mCanvasRenderer->ResetActiveThread();
     }
   }
 }
 
--- a/dom/canvas/WebGL2ContextFramebuffers.cpp
+++ b/dom/canvas/WebGL2ContextFramebuffers.cpp
@@ -342,17 +342,17 @@ WebGL2Context::FramebufferTextureLayer(G
         fb = mBoundDrawFramebuffer;
         break;
 
     case LOCAL_GL_READ_FRAMEBUFFER:
         fb = mBoundReadFramebuffer;
         break;
 
     default:
-        MOZ_CRASH("Bad target.");
+        MOZ_CRASH("GFX: Bad target.");
     }
 
     if (!fb) {
         return ErrorInvalidOperation("framebufferTextureLayer: cannot modify"
                                      " framebuffer 0.");
     }
 
     fb->FramebufferTextureLayer(attachment, texture, level, layer);
@@ -424,17 +424,17 @@ WebGL2Context::InvalidateFramebuffer(GLe
         break;
 
     case LOCAL_GL_READ_FRAMEBUFFER:
         fb = mBoundReadFramebuffer;
         isDefaultFB = gl->Screen()->IsReadFramebufferDefault();
         break;
 
     default:
-        MOZ_CRASH("Bad target.");
+        MOZ_CRASH("GFX: Bad target.");
     }
 
     const bool badColorAttachmentIsInvalidOp = true;
     for (size_t i = 0; i < attachments.Length(); i++) {
         if (!ValidateFramebufferAttachment(fb, attachments[i], funcName,
                                            badColorAttachmentIsInvalidOp))
         {
             return;
@@ -491,17 +491,17 @@ WebGL2Context::InvalidateSubFramebuffer(
         break;
 
     case LOCAL_GL_READ_FRAMEBUFFER:
         fb = mBoundReadFramebuffer;
         isDefaultFB = gl->Screen()->IsReadFramebufferDefault();
         break;
 
     default:
-        MOZ_CRASH("Bad target.");
+        MOZ_CRASH("GFX: Bad target.");
     }
 
     const bool badColorAttachmentIsInvalidOp = true;
     for (size_t i = 0; i < attachments.Length(); i++) {
         if (!ValidateFramebufferAttachment(fb, attachments[i], funcName,
                                            badColorAttachmentIsInvalidOp))
         {
             return;
--- a/dom/canvas/WebGL2ContextQueries.cpp
+++ b/dom/canvas/WebGL2ContextQueries.cpp
@@ -67,17 +67,17 @@ WebGLContext::GetQuerySlotByTarget(GLenu
     case LOCAL_GL_ANY_SAMPLES_PASSED:
     case LOCAL_GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
         return mActiveOcclusionQuery;
 
     case LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
         return mActiveTransformFeedbackQuery;
 
     default:
-        MOZ_CRASH("Should not get here.");
+        MOZ_CRASH("GFX: Should not get here.");
     }
 }
 
 
 // -------------------------------------------------------------------------
 // Query Objects
 
 already_AddRefed<WebGLQuery>
--- a/dom/canvas/WebGLActiveInfo.cpp
+++ b/dom/canvas/WebGLActiveInfo.cpp
@@ -67,17 +67,17 @@ ElemSizeFromType(GLenum elemType)
     case LOCAL_GL_FLOAT_MAT3x4:
     case LOCAL_GL_FLOAT_MAT4x3:
         return 12;
 
     case LOCAL_GL_FLOAT_MAT4:
         return 16;
 
     default:
-        MOZ_CRASH("Bad `elemType`.");
+        MOZ_CRASH("GFX: Bad `elemType`.");
     }
 }
 
 WebGLActiveInfo::WebGLActiveInfo(WebGLContext* webgl, GLint elemCount, GLenum elemType,
                                  bool isArray, const nsACString& baseUserName,
                                  const nsACString& baseMappedName)
     : mWebGL(webgl)
     , mElemCount(elemCount)
--- a/dom/canvas/WebGLBuffer.cpp
+++ b/dom/canvas/WebGLBuffer.cpp
@@ -47,17 +47,17 @@ WebGLBuffer::BindTo(GLenum target)
     case LOCAL_GL_COPY_READ_BUFFER:
     case LOCAL_GL_COPY_WRITE_BUFFER:
         if (mContent == Kind::Undefined) {
           mContent = Kind::OtherData;
         }
         break;
 
     default:
-        MOZ_CRASH();
+        MOZ_CRASH("GFX: invalid target");
     }
 }
 
 void
 WebGLBuffer::Delete()
 {
     mContext->MakeContextCurrent();
     mContext->gl->fDeleteBuffers(1, &mGLName);
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -679,17 +679,17 @@ WebGLContext::CreateAndInitGLWith(FnCrea
                                   const gl::SurfaceCaps& baseCaps,
                                   gl::CreateContextFlags flags,
                                   nsACString* const out_failReason,
                                   nsACString* const out_failureId)
 {
     std::queue<gl::SurfaceCaps> fallbackCaps;
     PopulateCapFallbackQueue(baseCaps, &fallbackCaps);
 
-    MOZ_RELEASE_ASSERT(!gl);
+    MOZ_RELEASE_ASSERT(!gl, "GFX: Already have a context.");
     gl = nullptr;
     while (!fallbackCaps.empty()) {
         gl::SurfaceCaps& caps = fallbackCaps.front();
 
         gl = fnCreateGL(caps, flags, this, out_failReason, out_failureId);
         if (gl)
             break;
 
@@ -1330,17 +1330,17 @@ WebGLContext::Commit()
         mOffscreenCanvas->CommitFrameToCompositor();
     }
 }
 
 void
 WebGLContext::GetCanvas(Nullable<dom::OwningHTMLCanvasElementOrOffscreenCanvas>& retval)
 {
     if (mCanvasElement) {
-        MOZ_RELEASE_ASSERT(!mOffscreenCanvas);
+        MOZ_RELEASE_ASSERT(!mOffscreenCanvas, "GFX: Canvas is offscreen.");
 
         if (mCanvasElement->IsInNativeAnonymousSubtree()) {
           retval.SetNull();
         } else {
           retval.SetValue().SetAsHTMLCanvasElement() = mCanvasElement;
         }
     } else if (mOffscreenCanvas) {
         retval.SetValue().SetAsOffscreenCanvas() = mOffscreenCanvas;
@@ -2061,17 +2061,17 @@ ZeroTexImageWithClear(WebGLContext* webg
     }
 
     if (format->hasStencil) {
         attachPoint = (format->hasDepth ? LOCAL_GL_DEPTH_STENCIL_ATTACHMENT
                                         : LOCAL_GL_STENCIL_ATTACHMENT);
         clearBits |= LOCAL_GL_STENCIL_BUFFER_BIT;
     }
 
-    MOZ_RELEASE_ASSERT(attachPoint && clearBits);
+    MOZ_RELEASE_ASSERT(attachPoint && clearBits, "GFX: No bits cleared.");
 
     {
         gl::GLContext::LocalErrorScope errorScope(*gl);
         gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, attachPoint, target.get(), tex,
                                   level);
         if (errorScope.GetError()) {
             MOZ_ASSERT(false);
             return false;
@@ -2115,21 +2115,21 @@ ZeroTextureData(WebGLContext* webgl, con
                            " slow.",
                            funcName);
 
     gl::GLContext* gl = webgl->GL();
     gl->MakeCurrent();
 
     auto compression = usage->format->compression;
     if (compression) {
-        MOZ_RELEASE_ASSERT(!xOffset && !yOffset && !zOffset);
-        MOZ_RELEASE_ASSERT(!respecifyTexture);
+        MOZ_RELEASE_ASSERT(!xOffset && !yOffset && !zOffset, "GFX: Can't zero compressed texture with offsets.");
+        MOZ_RELEASE_ASSERT(!respecifyTexture, "GFX: respecifyTexture is set to true.");
 
         auto sizedFormat = usage->format->sizedFormat;
-        MOZ_RELEASE_ASSERT(sizedFormat);
+        MOZ_RELEASE_ASSERT(sizedFormat, "GFX: texture sized format not set");
 
         const auto fnSizeInBlocks = [](CheckedUint32 pixels, uint8_t pixelsPerBlock) {
             return RoundUpToMultipleOf(pixels, pixelsPerBlock) / pixelsPerBlock;
         };
 
         const auto widthBlocks = fnSizeInBlocks(width, compression->blockWidth);
         const auto heightBlocks = fnSizeInBlocks(height, compression->blockHeight);
 
@@ -2156,17 +2156,17 @@ ZeroTextureData(WebGLContext* webgl, con
                                                byteCount, zeros.get());
         if (error)
             return false;
 
         return true;
     }
 
     const auto driverUnpackInfo = usage->idealUnpack;
-    MOZ_RELEASE_ASSERT(driverUnpackInfo);
+    MOZ_RELEASE_ASSERT(driverUnpackInfo, "GFX: ideal unpack info not set.");
 
     if (usage->isRenderable && depth == 1 &&
         !xOffset && !yOffset && !zOffset)
     {
         // While we would like to skip the extra complexity of trying to zero with an FB
         // clear, ANGLE_depth_texture requires this.
         do {
             if (respecifyTexture) {
@@ -2202,17 +2202,17 @@ ZeroTextureData(WebGLContext* webgl, con
     if (!zeros)
         return false;
 
     ScopedUnpackReset scopedReset(webgl);
     gl->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 1); // Don't bother with striding it well.
 
     GLenum error;
     if (respecifyTexture) {
-        MOZ_RELEASE_ASSERT(!xOffset && !yOffset && !zOffset);
+        MOZ_RELEASE_ASSERT(!xOffset && !yOffset && !zOffset, "GFX: texture data, offsets, not zeroed.");
         error = DoTexImage(gl, target, level, driverUnpackInfo, width, height, depth,
                            zeros.get());
     } else {
         error = DoTexSubImage(gl, target, level, xOffset, yOffset, zOffset, width, height,
                               depth, packing, zeros.get());
     }
     if (error)
         return false;
--- a/dom/canvas/WebGLContextBuffers.cpp
+++ b/dom/canvas/WebGLContextBuffers.cpp
@@ -559,17 +559,17 @@ WebGLContext::GetBufferSlotByTarget(GLen
 
     case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER:
         return mBoundTransformFeedbackBuffer;
 
     case LOCAL_GL_UNIFORM_BUFFER:
         return mBoundUniformBuffer;
 
     default:
-        MOZ_CRASH("Should not get here.");
+        MOZ_CRASH("GFX: Should not get here.");
     }
 }
 
 WebGLRefPtr<WebGLBuffer>&
 WebGLContext::GetBufferSlotByTargetIndexed(GLenum target, GLuint index)
 {
     /* This function assumes that target has been validated for either WebGL1 or WebGL. */
     switch (target) {
@@ -577,17 +577,17 @@ WebGLContext::GetBufferSlotByTargetIndex
         MOZ_ASSERT(index < mGLMaxTransformFeedbackSeparateAttribs);
         return mBoundTransformFeedbackBuffers[index];
 
     case LOCAL_GL_UNIFORM_BUFFER:
         MOZ_ASSERT(index < mGLMaxUniformBufferBindings);
         return mBoundUniformBuffers[index];
 
     default:
-        MOZ_CRASH("Should not get here.");
+        MOZ_CRASH("GFX: Should not get here.");
     }
 }
 
 GLenum
 WebGLContext::GetCurrentBinding(WebGLBuffer* buffer) const
 {
     if (mBoundArrayBuffer == buffer)
         return LOCAL_GL_ARRAY_BUFFER;
--- a/dom/canvas/WebGLContextDraw.cpp
+++ b/dom/canvas/WebGLContextDraw.cpp
@@ -130,17 +130,17 @@ WebGLContext::BindFakeBlack(uint32_t tex
 
         default:
             return nullptr;
         }
     };
 
     UniquePtr<FakeBlackTexture>* slot = fnGetSlot();
     if (!slot) {
-        MOZ_CRASH("fnGetSlot failed.");
+        MOZ_CRASH("GFX: fnGetSlot failed.");
     }
     UniquePtr<FakeBlackTexture>& fakeBlackTex = *slot;
 
     if (!fakeBlackTex) {
         fakeBlackTex.reset(new FakeBlackTexture(gl, target, fakeBlack));
     }
 
     gl->fActiveTexture(LOCAL_GL_TEXTURE0 + texUnit);
@@ -822,17 +822,17 @@ WebGLContext::FakeBlackTexture::FakeBlac
         texFormat = LOCAL_GL_RGBA;
         break;
 
     case FakeBlackType::RGBA0001:
         texFormat = LOCAL_GL_RGB;
         break;
 
     default:
-        MOZ_CRASH("bad type");
+        MOZ_CRASH("GFX: bad type");
     }
 
     gl::ScopedBindTexture scopedBind(mGL, mGLName, target.get());
 
     mGL->fTexParameteri(target.get(), LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_NEAREST);
     mGL->fTexParameteri(target.get(), LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_NEAREST);
 
     // We allocate our zeros on the heap, and we overallocate (16 bytes instead of 4) to
@@ -851,30 +851,30 @@ WebGLContext::FakeBlackTexture::FakeBlac
                                             zeros.get());
             if (error) {
                 const nsPrintfCString text("DoTexImage failed with `error`: 0x%04x, "
                                            "for `curTarget`: 0x%04x, "
                                            "`dui`: {0x%04x, 0x%04x, 0x%04x}.",
                                            error, curTarget.get(), dui.internalFormat,
                                            dui.unpackFormat, dui.unpackType);
                 gfxCriticalError() << text.BeginReading();
-                MOZ_CRASH("Unexpected error during cube map FakeBlack creation.");
+                MOZ_CRASH("GFX: Unexpected error during cube map FakeBlack creation.");
             }
         }
     } else {
         const GLenum error = DoTexImage(mGL, target.get(), 0, &dui, 1, 1, 1,
                                         zeros.get());
         if (error) {
             const nsPrintfCString text("DoTexImage failed with `error`: 0x%04x, "
                                        "for `target`: 0x%04x, "
                                        "`dui`: {0x%04x, 0x%04x, 0x%04x}.",
                                        error, target.get(), dui.internalFormat,
                                        dui.unpackFormat, dui.unpackType);
             gfxCriticalError() << text.BeginReading();
-            MOZ_CRASH("Unexpected error during FakeBlack creation.");
+            MOZ_CRASH("GFX: Unexpected error during FakeBlack creation.");
         }
     }
 }
 
 WebGLContext::FakeBlackTexture::~FakeBlackTexture()
 {
     mGL->MakeCurrent();
     mGL->fDeleteTextures(1, &mGLName);
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -264,17 +264,17 @@ WebGLContext::CheckFramebufferStatus(GLe
         fb = mBoundDrawFramebuffer;
         break;
 
     case LOCAL_GL_READ_FRAMEBUFFER:
         fb = mBoundReadFramebuffer;
         break;
 
     default:
-        MOZ_CRASH("Bad target.");
+        MOZ_CRASH("GFX: Bad target.");
     }
 
     if (!fb)
         return LOCAL_GL_FRAMEBUFFER_COMPLETE;
 
     nsCString fbErrorInfo;
     return fb->CheckFramebufferStatus(&fbErrorInfo).get();
 }
@@ -496,17 +496,17 @@ WebGLContext::FramebufferRenderbuffer(GL
         fb = mBoundDrawFramebuffer;
         break;
 
     case LOCAL_GL_READ_FRAMEBUFFER:
         fb = mBoundReadFramebuffer;
         break;
 
     default:
-        MOZ_CRASH("Bad target.");
+        MOZ_CRASH("GFX: Bad target.");
     }
 
     if (!fb) {
         return ErrorInvalidOperation("framebufferRenderbuffer: cannot modify"
                                      " framebuffer 0.");
     }
 
     if (rbtarget != LOCAL_GL_RENDERBUFFER) {
@@ -585,17 +585,17 @@ WebGLContext::FramebufferTexture2D(GLenu
         fb = mBoundDrawFramebuffer;
         break;
 
     case LOCAL_GL_READ_FRAMEBUFFER:
         fb = mBoundReadFramebuffer;
         break;
 
     default:
-        MOZ_CRASH("Bad target.");
+        MOZ_CRASH("GFX: Bad target.");
     }
 
     if (!fb) {
         return ErrorInvalidOperation("framebufferTexture2D: cannot modify"
                                      " framebuffer 0.");
     }
 
     if (!ValidateFramebufferAttachment(fb, attachment, "framebufferTexture2D"))
@@ -738,17 +738,17 @@ WebGLContext::GetFramebufferAttachmentPa
         fb = mBoundDrawFramebuffer;
         break;
 
     case LOCAL_GL_READ_FRAMEBUFFER:
         fb = mBoundReadFramebuffer;
         break;
 
     default:
-        MOZ_CRASH("Bad target.");
+        MOZ_CRASH("GFX: Bad target.");
     }
 
     MakeContextCurrent();
 
     if (fb)
         return fb->GetAttachmentParameter(funcName, cx, target, attachment, pname, &rv);
 
     ////////////////////////////////////
@@ -1259,17 +1259,17 @@ WebGLContext::DoReadPixelsAndConvert(GLi
 
         const GLenum error = errorScope.GetError();
         if (error == LOCAL_GL_OUT_OF_MEMORY) {
             ErrorOutOfMemory("readPixels: Driver ran out of memory.");
             return false;
         }
 
         if (error) {
-            MOZ_RELEASE_ASSERT(false, "Unexpected driver error.");
+            MOZ_RELEASE_ASSERT(false, "GFX: Unexpected driver error.");
             return false;
         }
 
         size_t channelsPerRow = std::min(readStride.value() / sizeof(uint16_t),
                                          destStride.value() / sizeof(float));
 
         const uint8_t* srcRow = (uint8_t*)(readBuffer.get()) + readOffset.value();
         uint8_t* dstRow = (uint8_t*)(destBytes) + destOffset.value();
@@ -1470,17 +1470,17 @@ WebGLContext::ReadPixels(GLint x, GLint 
     case LOCAL_GL_RGB_INTEGER:
         channels = 3;
         break;
     case LOCAL_GL_RGBA:
     case LOCAL_GL_RGBA_INTEGER:
         channels = 4;
         break;
     default:
-        MOZ_CRASH("bad `format`");
+        MOZ_CRASH("GFX: bad `format`");
     }
 
 
     // Check the type param
     int bytesPerPixel;
     int requiredDataType;
     switch (type) {
     case LOCAL_GL_BYTE:
@@ -1531,17 +1531,17 @@ WebGLContext::ReadPixels(GLint x, GLint 
 
     case LOCAL_GL_HALF_FLOAT:
     case LOCAL_GL_HALF_FLOAT_OES:
         bytesPerPixel = 2*channels;
         requiredDataType = js::Scalar::Uint16;
         break;
 
     default:
-        MOZ_CRASH("bad `type`");
+        MOZ_CRASH("GFX: bad `type`");
     }
 
     const auto& view = pixels.Value();
 
     // Compute length and data.  Don't reenter after this point, lest the
     // precomputed go out of sync with the instant length/data.
     view.ComputeLengthAndData();
     void* data = view.DataAllowShared();
--- a/dom/canvas/WebGLContextLossHandler.cpp
+++ b/dom/canvas/WebGLContextLossHandler.cpp
@@ -204,17 +204,17 @@ WebGLContextLossHandler::DisableTimer()
     if (mIsDisabled)
         return;
 
     mIsDisabled = true;
 
     if (mFeatureAdded) {
         dom::workers::WorkerPrivate* workerPrivate =
             dom::workers::GetCurrentThreadWorkerPrivate();
-        MOZ_RELEASE_ASSERT(workerPrivate);
+        MOZ_RELEASE_ASSERT(workerPrivate, "GFX: No private worker created.");
         workerPrivate->RemoveFeature(this);
         mFeatureAdded = false;
     }
 
     // We can't just Cancel() the timer, as sometimes we end up
     // receiving a callback after calling Cancel(). This could cause us
     // to receive the callback after object destruction.
 
--- a/dom/canvas/WebGLContextState.cpp
+++ b/dom/canvas/WebGLContextState.cpp
@@ -125,17 +125,17 @@ WebGLContext::GetChannelBits(const char*
             }
             break;
 
         case LOCAL_GL_STENCIL_BITS:
             *out_val = (mOptions.stencil ? 8 : 0);
             break;
 
         default:
-            MOZ_CRASH("bad pname");
+            MOZ_CRASH("GFX: bad pname");
         }
         return true;
     }
 
     if (!gl->IsCoreProfile()) {
         gl->fGetIntegerv(pname, out_val);
         return true;
     }
@@ -169,17 +169,17 @@ WebGLContext::GetChannelBits(const char*
         break;
 
     case LOCAL_GL_STENCIL_BITS:
         fbAttachment = LOCAL_GL_STENCIL_ATTACHMENT;
         fbPName = LOCAL_GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE;
         break;
 
     default:
-        MOZ_CRASH("bad pname");
+        MOZ_CRASH("GFX: bad pname");
     }
 
     gl->fGetFramebufferAttachmentParameteriv(LOCAL_GL_DRAW_FRAMEBUFFER, fbAttachment,
                                              fbPName, out_val);
     return true;
 }
 
 JS::Value
@@ -296,17 +296,17 @@ WebGLContext::GetParameter(JSContext* cx
                     overridePref = "webgl.renderer-string-override";
                     driverEnum = LOCAL_GL_RENDERER;
                     break;
                 case UNMASKED_VENDOR_WEBGL:
                     overridePref = "webgl.vendor-string-override";
                     driverEnum = LOCAL_GL_VENDOR;
                     break;
                 default:
-                    MOZ_CRASH("bad `pname`");
+                    MOZ_CRASH("GFX: bad `pname`");
                 }
 
                 bool hasRetVal = false;
 
                 nsAutoString ret;
                 if (overridePref) {
                     nsresult res = Preferences::GetString(overridePref, &ret);
                     if (NS_SUCCEEDED(res) && ret.Length() > 0)
--- a/dom/canvas/WebGLContextUtils.cpp
+++ b/dom/canvas/WebGLContextUtils.cpp
@@ -826,25 +826,25 @@ InfoFrom(WebGLTexImageFunc func, WebGLTe
         switch (func) {
         case WebGLTexImageFunc::TexImage:        return "texImage2D";
         case WebGLTexImageFunc::TexSubImage:     return "texSubImage2D";
         case WebGLTexImageFunc::CopyTexImage:    return "copyTexImage2D";
         case WebGLTexImageFunc::CopyTexSubImage: return "copyTexSubImage2D";
         case WebGLTexImageFunc::CompTexImage:    return "compressedTexImage2D";
         case WebGLTexImageFunc::CompTexSubImage: return "compressedTexSubImage2D";
         default:
-            MOZ_CRASH();
+            MOZ_CRASH("GFX: invalid 2D TexDimensions");
         }
     case WebGLTexDimensions::Tex3D:
         switch (func) {
         case WebGLTexImageFunc::TexImage:        return "texImage3D";
         case WebGLTexImageFunc::TexSubImage:     return "texSubImage3D";
         case WebGLTexImageFunc::CopyTexSubImage: return "copyTexSubImage3D";
         case WebGLTexImageFunc::CompTexSubImage: return "compressedTexSubImage3D";
         default:
-            MOZ_CRASH();
+            MOZ_CRASH("GFX: invalid 3D TexDimensions");
         }
     default:
-        MOZ_CRASH();
+        MOZ_CRASH("GFX: invalid TexDimensions");
     }
 }
 
 } // namespace mozilla
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -645,17 +645,17 @@ FloorPOT(int32_t x)
         pot *= 2;
     }
     return pot;
 }
 
 bool
 WebGLContext::InitAndValidateGL(nsACString* const out_failReason, nsACString* const out_failureId)
 {
-    MOZ_RELEASE_ASSERT(gl);
+    MOZ_RELEASE_ASSERT(gl, "GFX: GL not initialized");
 
     // Unconditionally create a new format usage authority. This is
     // important when restoring contexts and extensions need to add
     // formats back into the authority.
     mFormatUsage = CreateFormatUsage(gl);
     if (!mFormatUsage) {
         *out_failureId = "FEATURE_FAILURE_WEBGL_FORMAT";
         out_failReason->AssignLiteral("Failed to create mFormatUsage.");
--- a/dom/canvas/WebGLFormats.cpp
+++ b/dom/canvas/WebGLFormats.cpp
@@ -157,17 +157,17 @@ AddFormatInfo(EffectiveFormat format, co
         break;
 
     case UnsizedFormat::DS:
         hasDepth = true;
         hasStencil = true;
         break;
 
     default:
-        MOZ_CRASH("Missing UnsizedFormat case.");
+        MOZ_CRASH("GFX: Missing UnsizedFormat case.");
     }
 
     const CompressedFormatInfo* compressedFormatInfo = GetCompressedFormatInfo(format);
     MOZ_ASSERT(!bytesPerPixel == bool(compressedFormatInfo));
 
     const FormatInfo info = { format, name, sizedFormat, unsizedFormat, componentType,
                               bytesPerPixel, isColorFormat, isSRGB, hasAlpha, hasDepth,
                               hasStencil, compressedFormatInfo };
@@ -370,17 +370,17 @@ BytesPerPixel(const PackingInfo& packing
 
     case LOCAL_GL_INT:
     case LOCAL_GL_UNSIGNED_INT:
     case LOCAL_GL_FLOAT:
         bytesPerChannel = 4;
         break;
 
     default:
-        MOZ_CRASH("invalid PackingInfo");
+        MOZ_CRASH("GFX: invalid PackingInfo");
     }
 
     uint8_t channels;
     switch (packing.format) {
     case LOCAL_GL_RG:
     case LOCAL_GL_RG_INTEGER:
     case LOCAL_GL_LUMINANCE_ALPHA:
         channels = 2;
@@ -957,17 +957,17 @@ FormatUsageAuthority::GetUnsizedTexUsage
 
 FormatUsageInfo*
 FormatUsageAuthority::EditUsage(EffectiveFormat format)
 {
     auto itr = mUsageMap.find(format);
 
     if (itr == mUsageMap.end()) {
         const FormatInfo* formatInfo = GetFormat(format);
-        MOZ_RELEASE_ASSERT(formatInfo);
+        MOZ_RELEASE_ASSERT(formatInfo, "GFX: no format info set.");
 
         FormatUsageInfo usage(formatInfo);
 
         auto res = mUsageMap.insert({ format, usage });
         DebugOnly<bool> didInsert = res.second;
         MOZ_ASSERT(didInsert);
 
         itr = res.first;
--- a/dom/canvas/WebGLFramebuffer.cpp
+++ b/dom/canvas/WebGLFramebuffer.cpp
@@ -408,17 +408,17 @@ WebGLFBAttachPoint::FinalizeAttachment(g
         return;
     }
 
     if (Renderbuffer()) {
         Renderbuffer()->DoFramebufferRenderbuffer(attachment);
         return;
     }
 
-    MOZ_CRASH();
+    MOZ_CRASH("GFX: invalid render buffer");
 }
 
 JS::Value
 WebGLFBAttachPoint::GetParameter(const char* funcName, WebGLContext* webgl, JSContext* cx,
                                  GLenum target, GLenum attachment, GLenum pname,
                                  ErrorResult* const out_error)
 {
     const bool hasAttachment = (mTexturePtr || mRenderbufferPtr);
--- a/dom/canvas/WebGLProgram.cpp
+++ b/dom/canvas/WebGLProgram.cpp
@@ -170,17 +170,17 @@ QueryProgramInfo(WebGLProgram* prog, gl:
         const bool isArray = false;
         AddActiveInfo(prog->mContext, elemCount, elemType, isArray, userName, mappedName,
                       &info->activeAttribs, &info->attribMap);
 
         // Collect active locations:
         GLint loc = gl->fGetAttribLocation(prog->mGLName, mappedName.BeginReading());
         if (loc == -1) {
             if (mappedName != "gl_InstanceID")
-                MOZ_CRASH("Active attrib has no location.");
+                MOZ_CRASH("GFX: Active attrib has no location.");
         } else {
             info->activeAttribLocs.insert(loc);
         }
     }
 
     // Uniforms
 
     const bool needsCheckForArrays = gl->WorkAroundDriverBugs();
@@ -200,17 +200,17 @@ QueryProgramInfo(WebGLProgram* prog, gl:
                               &elemCount, &elemType, mappedName.BeginWriting());
 
         mappedName.SetLength(lengthWithoutNull);
 
         nsAutoCString baseMappedName;
         bool isArray;
         size_t arrayIndex;
         if (!ParseName(mappedName, &baseMappedName, &isArray, &arrayIndex))
-            MOZ_CRASH("Failed to parse `mappedName` received from driver.");
+            MOZ_CRASH("GFX: Failed to parse `mappedName` received from driver.");
 
         // Note that for good drivers, `isArray` should already be correct.
         // However, if FindUniform succeeds, it will be validator-guaranteed correct.
 
         nsAutoCString baseUserName;
         if (!prog->FindUniformByMappedName(baseMappedName, &baseUserName, &isArray)) {
             baseUserName = baseMappedName;
 
@@ -254,17 +254,17 @@ QueryProgramInfo(WebGLProgram* prog, gl:
             gl->fGetActiveUniformBlockiv(prog->mGLName, i, LOCAL_GL_UNIFORM_BLOCK_NAME_LENGTH, &lengthWithoutNull);
             gl->fGetActiveUniformBlockName(prog->mGLName, i, maxUniformBlockLenWithNull, &lengthWithoutNull, mappedName.BeginWriting());
             mappedName.SetLength(lengthWithoutNull);
 
             nsAutoCString baseMappedName;
             bool isArray;
             size_t arrayIndex;
             if (!ParseName(mappedName, &baseMappedName, &isArray, &arrayIndex))
-                MOZ_CRASH("Failed to parse `mappedName` received from driver.");
+                MOZ_CRASH("GFX: Failed to parse `mappedName` received from driver.");
 
             nsAutoCString baseUserName;
             if (!prog->FindUniformBlockByMappedName(baseMappedName, &baseUserName,
                                                     &isArray))
             {
                 baseUserName = baseMappedName;
 
                 if (needsCheckForArrays && !isArray) {
@@ -308,17 +308,17 @@ QueryProgramInfo(WebGLProgram* prog, gl:
                                              &lengthWithoutNull, &size, &type,
                                              mappedName.BeginWriting());
             mappedName.SetLength(lengthWithoutNull);
 
             nsAutoCString baseMappedName;
             bool isArray;
             size_t arrayIndex;
             if (!ParseName(mappedName, &baseMappedName, &isArray, &arrayIndex))
-                MOZ_CRASH("Failed to parse `mappedName` received from driver.");
+                MOZ_CRASH("GFX: Failed to parse `mappedName` received from driver.");
 
             nsAutoCString baseUserName;
             if (!prog->FindVaryingByMappedName(mappedName, &baseUserName, &isArray)) {
                 baseUserName = baseMappedName;
 
                 if (needsCheckForArrays && !isArray) {
                     std::string mappedNameStr = baseMappedName.BeginReading();
                     mappedNameStr += "[0]";
@@ -1056,17 +1056,17 @@ WebGLProgram::LinkAndUpdate()
     empty.swap(mTempMappedVaryings);
 
     GLint ok = 0;
     gl->fGetProgramiv(mGLName, LOCAL_GL_LINK_STATUS, &ok);
     if (!ok)
         return;
 
     mMostRecentLinkInfo = QueryProgramInfo(this, gl);
-    MOZ_RELEASE_ASSERT(mMostRecentLinkInfo);
+    MOZ_RELEASE_ASSERT(mMostRecentLinkInfo, "GFX: most rent link info not set.");
 }
 
 bool
 WebGLProgram::FindActiveOutputMappedNameByUserName(const nsACString& userName,
                                                    nsCString* const out_mappedName) const
 {
     if (mFragShader->FindActiveOutputMappedNameByUserName(userName, out_mappedName)) {
         return true;
--- a/dom/canvas/WebGLRenderbuffer.cpp
+++ b/dom/canvas/WebGLRenderbuffer.cpp
@@ -110,17 +110,17 @@ DoRenderbufferStorageMaybeMultisample(gl
     case LOCAL_GL_DEPTH_COMPONENT16:
         if (!gl->IsGLES() || gl->IsExtensionSupported(gl::GLContext::OES_depth24))
             internalFormat = LOCAL_GL_DEPTH_COMPONENT24;
         else if (gl->IsSupported(gl::GLFeature::packed_depth_stencil))
             internalFormat = LOCAL_GL_DEPTH24_STENCIL8;
         break;
 
     case LOCAL_GL_DEPTH_STENCIL:
-        MOZ_CRASH("GL_DEPTH_STENCIL is not valid here.");
+        MOZ_CRASH("GFX: GL_DEPTH_STENCIL is not valid here.");
         break;
 
     default:
         break;
     }
 
     gl::GLContext::LocalErrorScope errorScope(*gl);
 
--- a/dom/canvas/WebGLSampler.cpp
+++ b/dom/canvas/WebGLSampler.cpp
@@ -81,17 +81,17 @@ WebGLSampler::SamplerParameter1i(GLenum 
         mCompareMode = param;
         break;
 
     case LOCAL_GL_TEXTURE_COMPARE_FUNC:
         mCompareFunc = param;
         break;
 
     default:
-        MOZ_CRASH("Unhandled pname");
+        MOZ_CRASH("GFX: Unhandled pname");
         break;
     }
 
     for (uint32_t i = 0; i < mContext->mBoundSamplers.Length(); ++i) {
         if (this == mContext->mBoundSamplers[i])
             mContext->InvalidateResolveCacheForTextureWithTexUnit(i);
     }
 }
@@ -104,17 +104,17 @@ WebGLSampler::SamplerParameter1f(GLenum 
         mMinLod = param;
         break;
 
     case LOCAL_GL_TEXTURE_MAX_LOD:
         mMaxLod = param;
         break;
 
     default:
-        MOZ_CRASH("Unhandled pname");
+        MOZ_CRASH("GFX: Unhandled pname");
         break;
     }
 
     for (uint32_t i = 0; i < mContext->mBoundSamplers.Length(); ++i) {
         if (this == mContext->mBoundSamplers[i])
             mContext->InvalidateResolveCacheForTextureWithTexUnit(i);
     }
 }
--- a/dom/canvas/WebGLShader.cpp
+++ b/dom/canvas/WebGLShader.cpp
@@ -96,17 +96,17 @@ TranslateWithoutValidation(const nsACStr
         /* According to ARB_ES2_compatibility extension glsl
          * should accept #version 100 for ES 2 shaders. */
         reversionedSource.insert(versionStrStart, "#version 100\n");
         break;
     case 300:
         reversionedSource.insert(versionStrStart, "#version 330\n");
         break;
     default:
-        MOZ_CRASH("Bad `glesslVersion`.");
+        MOZ_CRASH("GFX: Bad `glesslVersion`.");
     }
 
     out_translatedSource->Assign(reversionedSource.c_str(),
                                  reversionedSource.length());
     return true;
 }
 
 static void
--- a/dom/canvas/WebGLShaderValidator.cpp
+++ b/dom/canvas/WebGLShaderValidator.cpp
@@ -112,17 +112,17 @@ ShaderOutput(gl::GLContext* gl)
         case 330: return SH_GLSL_330_CORE_OUTPUT;
         case 400: return SH_GLSL_400_CORE_OUTPUT;
         case 410: return SH_GLSL_410_CORE_OUTPUT;
         case 420: return SH_GLSL_420_CORE_OUTPUT;
         case 430: return SH_GLSL_430_CORE_OUTPUT;
         case 440: return SH_GLSL_440_CORE_OUTPUT;
         case 450: return SH_GLSL_450_CORE_OUTPUT;
         default:
-            MOZ_CRASH("Unexpected GLSL version.");
+            MOZ_CRASH("GFX: Unexpected GLSL version.");
         }
     }
 
     return SH_GLSL_COMPATIBILITY_OUTPUT;
 }
 
 webgl::ShaderValidator*
 WebGLContext::CreateShaderValidator(GLenum shaderType) const
--- a/dom/canvas/WebGLTexture.cpp
+++ b/dom/canvas/WebGLTexture.cpp
@@ -524,17 +524,17 @@ WebGLTexture::GetFakeBlackType(const cha
 static void
 SetSwizzle(gl::GLContext* gl, TexTarget target, const GLint* swizzle)
 {
     static const GLint kNoSwizzle[4] = { LOCAL_GL_RED, LOCAL_GL_GREEN, LOCAL_GL_BLUE,
                                          LOCAL_GL_ALPHA };
     if (!swizzle) {
         swizzle = kNoSwizzle;
     } else if (!gl->IsSupported(gl::GLFeature::texture_swizzle)) {
-        MOZ_CRASH("Needs swizzle feature to swizzle!");
+        MOZ_CRASH("GFX: Needs swizzle feature to swizzle!");
     }
 
     gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_SWIZZLE_R, swizzle[0]);
     gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_SWIZZLE_G, swizzle[1]);
     gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_SWIZZLE_B, swizzle[2]);
     gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_SWIZZLE_A, swizzle[3]);
 }
 
@@ -826,17 +826,17 @@ WebGLTexture::GetTexParameter(TexTarget 
 
     case LOCAL_GL_TEXTURE_MAX_ANISOTROPY_EXT:
     case LOCAL_GL_TEXTURE_MAX_LOD:
     case LOCAL_GL_TEXTURE_MIN_LOD:
         mContext->gl->fGetTexParameterfv(texTarget.get(), pname, &f);
         return JS::NumberValue(float(f));
 
     default:
-        MOZ_CRASH("Unhandled pname.");
+        MOZ_CRASH("GFX: Unhandled pname.");
     }
 }
 
 bool
 WebGLTexture::IsTexture() const
 {
     return HasEverBeenBound() && !IsDeleted();
 }
--- a/dom/canvas/WebGLTextureUpload.cpp
+++ b/dom/canvas/WebGLTextureUpload.cpp
@@ -641,17 +641,17 @@ DoTexStorage(gl::GLContext* gl, TexTarge
         break;
 
     case LOCAL_GL_TEXTURE_3D:
     case LOCAL_GL_TEXTURE_2D_ARRAY:
         gl->fTexStorage3D(target.get(), levels, sizedFormat, width, height, depth);
         break;
 
     default:
-        MOZ_CRASH("bad target");
+        MOZ_CRASH("GFX: bad target");
     }
 
     return errorScope.GetError();
 }
 
 static bool
 Is3D(TexImageTarget target)
 {
@@ -665,17 +665,17 @@ Is3D(TexImageTarget target)
     case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
         return false;
 
     case LOCAL_GL_TEXTURE_3D:
     case LOCAL_GL_TEXTURE_2D_ARRAY:
         return true;
 
     default:
-        MOZ_CRASH("bad target");
+        MOZ_CRASH("GFX: bad target");
     }
 }
 
 GLenum
 DoTexImage(gl::GLContext* gl, TexImageTarget target, GLint level,
            const webgl::DriverUnpackInfo* dui, GLsizei width, GLsizei height,
            GLsizei depth, const void* data)
 {
@@ -986,17 +986,17 @@ WebGLTexture::TexStorage(const char* fun
                                 height, depth);
 
     if (error == LOCAL_GL_OUT_OF_MEMORY) {
         mContext->ErrorOutOfMemory("%s: Ran out of memory during texture allocation.",
                                    funcName);
         return;
     }
     if (error) {
-        MOZ_RELEASE_ASSERT(false, "We should have caught all other errors.");
+        MOZ_RELEASE_ASSERT(false, "GFX: We should have caught all other errors.");
         mContext->ErrorInvalidOperation("%s: Unexpected error during texture allocation.",
                                         funcName);
         return;
     }
 
     ////////////////////////////////////
     // Update our specification data.
 
@@ -1331,17 +1331,17 @@ WebGLTexture::CompressedTexImage(const c
     // Warning: Possibly shared memory.  See bug 1225033.
     GLenum error = DoCompressedTexImage(mContext->gl, target, level, internalFormat,
                                         width, height, depth, border, dataSize, data);
     if (error == LOCAL_GL_OUT_OF_MEMORY) {
         mContext->ErrorOutOfMemory("%s: Ran out of memory during upload.", funcName);
         return;
     }
     if (error) {
-        MOZ_RELEASE_ASSERT(false, "We should have caught all other errors.");
+        MOZ_RELEASE_ASSERT(false, "GFX: We should have caught all other errors.");
         mContext->GenerateWarning("%s: Unexpected error during texture upload. Context"
                                   " lost.",
                                   funcName);
         mContext->ForceLoseContext();
         return;
     }
 
     ////////////////////////////////////
@@ -1476,17 +1476,17 @@ WebGLTexture::CompressedTexSubImage(cons
     GLenum error = DoCompressedTexSubImage(mContext->gl, target, level, xOffset, yOffset,
                                            zOffset, width, height, depth,
                                            sizedUnpackFormat, dataSize, data);
     if (error == LOCAL_GL_OUT_OF_MEMORY) {
         mContext->ErrorOutOfMemory("%s: Ran out of memory during upload.", funcName);
         return;
     }
     if (error) {
-        MOZ_RELEASE_ASSERT(false, "We should have caught all other errors.");
+        MOZ_RELEASE_ASSERT(false, "GFX: We should have caught all other errors.");
         mContext->GenerateWarning("%s: Unexpected error during texture upload. Context"
                                   " lost.",
                                   funcName);
         mContext->ForceLoseContext();
         return;
     }
 
     ////////////////////////////////////
@@ -1586,20 +1586,20 @@ ScopedCopyTexImageSource::ScopedCopyTexI
             sizedFormat = LOCAL_GL_RGBA32F;
             break;
         }
 
         if (webgl->IsExtensionEnabled(WebGLExtensionID::EXT_color_buffer_half_float)) {
             sizedFormat = LOCAL_GL_RGBA16F;
             break;
         }
-        MOZ_CRASH("Should be able to request CopyTexImage from Float.");
+        MOZ_CRASH("GFX: Should be able to request CopyTexImage from Float.");
 
     default:
-        MOZ_CRASH("Should be able to request CopyTexImage from this type.");
+        MOZ_CRASH("GFX: Should be able to request CopyTexImage from this type.");
     }
 
     gl::ScopedTexture scopedTex(gl);
     gl::ScopedBindTexture scopedBindTex(gl, scopedTex.Texture(), LOCAL_GL_TEXTURE_2D);
 
     gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_NEAREST);
     gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_NEAREST);
 
@@ -1614,17 +1614,17 @@ ScopedCopyTexImageSource::ScopedCopyTexI
         break;
 
     case webgl::UnsizedFormat::LA:
         blitSwizzle[0] = LOCAL_GL_RED;
         blitSwizzle[1] = LOCAL_GL_ALPHA;
         break;
 
     default:
-        MOZ_CRASH("Unhandled unsizedFormat.");
+        MOZ_CRASH("GFX: Unhandled unsizedFormat.");
     }
 
     gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_SWIZZLE_R, blitSwizzle[0]);
     gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_SWIZZLE_G, blitSwizzle[1]);
     gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_SWIZZLE_B, blitSwizzle[2]);
     gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_SWIZZLE_A, blitSwizzle[3]);
 
     gl->fCopyTexImage2D(LOCAL_GL_TEXTURE_2D, 0, sizedFormat, 0, 0, srcWidth,
@@ -1640,17 +1640,17 @@ ScopedCopyTexImageSource::ScopedCopyTexI
     GLuint rgbaFB = 0;
     gl->fGenFramebuffers(1, &rgbaFB);
     gl->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, rgbaFB);
     gl->fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_COLOR_ATTACHMENT0,
                                  LOCAL_GL_RENDERBUFFER, rgbaRB);
 
     const GLenum status = gl->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
     if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
-        MOZ_CRASH("Temp framebuffer is not complete.");
+        MOZ_CRASH("GFX: Temp framebuffer is not complete.");
     }
 
     // Restore RB binding.
     scopedRB.Unwrap(); // This function should really have a better name.
 
     // Draw-blit rgbaTex into rgbaFB.
     const gfx::IntSize srcSize(srcWidth, srcHeight);
     gl->BlitHelper()->DrawBlitTextureToFramebuffer(scopedTex.Texture(), rgbaFB,
@@ -1827,17 +1827,17 @@ WebGLTexture::CopyTexImage2D(TexImageTar
     }
 
     if (error == LOCAL_GL_OUT_OF_MEMORY) {
         mContext->ErrorOutOfMemory("%s: Ran out of memory during texture copy.",
                                    funcName);
         return;
     }
     if (error) {
-        MOZ_RELEASE_ASSERT(false, "We should have caught all other errors.");
+        MOZ_RELEASE_ASSERT(false, "GFX: We should have caught all other errors.");
         mContext->GenerateWarning("%s: Unexpected error during texture copy. Context"
                                   " lost.",
                                   funcName);
         mContext->ForceLoseContext();
         return;
     }
 
     ////////////////////////////////////
@@ -1937,17 +1937,17 @@ WebGLTexture::CopyTexSubImage(const char
                                      rwHeight);
 
     if (error == LOCAL_GL_OUT_OF_MEMORY) {
         mContext->ErrorOutOfMemory("%s: Ran out of memory during texture copy.",
                                    funcName);
         return;
     }
     if (error) {
-        MOZ_RELEASE_ASSERT(false, "We should have caught all other errors.");
+        MOZ_RELEASE_ASSERT(false, "GFX: We should have caught all other errors.");
         mContext->GenerateWarning("%s: Unexpected error during texture copy. Context"
                                   " lost.",
                                   funcName);
         mContext->ForceLoseContext();
         return;
     }
 
     ////////////////////////////////////
--- a/dom/canvas/WebGLUniformLocation.cpp
+++ b/dom/canvas/WebGLUniformLocation.cpp
@@ -110,17 +110,17 @@ IsUniformSetterTypeValid(GLenum setterTy
 
     case LOCAL_GL_UNSIGNED_INT_SAMPLER_2D:
     case LOCAL_GL_UNSIGNED_INT_SAMPLER_3D:
     case LOCAL_GL_UNSIGNED_INT_SAMPLER_CUBE:
     case LOCAL_GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
         return setterType == LOCAL_GL_INT;
 
     default:
-        MOZ_CRASH("Bad `uniformType`.");
+        MOZ_CRASH("GFX: Bad `uniformType`.");
     }
 }
 
 bool
 WebGLUniformLocation::ValidateSizeAndType(uint8_t setterElemSize, GLenum setterType,
                                           WebGLContext* webgl, const char* funcName) const
 {
     MOZ_ASSERT(mLinkInfo);
@@ -312,17 +312,17 @@ WebGLUniformLocation::GetUniform(JSConte
             if (!obj) {
                 webgl->ErrorOutOfMemory("getUniform: out of memory");
                 return JS::NullValue();
             }
             return JS::ObjectOrNullValue(obj);
         }
 
     default:
-        MOZ_CRASH("Invalid elemType.");
+        MOZ_CRASH("GFX: Invalid elemType.");
     }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 JSObject*
 WebGLUniformLocation::WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto)
 {
--- a/dom/canvas/WebGLVertexArrayObject.cpp
+++ b/dom/canvas/WebGLVertexArrayObject.cpp
@@ -14,17 +14,17 @@ namespace mozilla {
 namespace dom {
 
 WebGLVertexArray*
 WebGLVertexArrayObject::Create(WebGLContext* webgl)
 {
   // WebGL 2: This is core in GL ES 3. If support is missing something
   // is very wrong.
   bool vaoSupport = webgl->GL()->IsSupported(gl::GLFeature::vertex_array_object);
-  MOZ_RELEASE_ASSERT(vaoSupport, "Vertex Array Objects aren't supported.");
+  MOZ_RELEASE_ASSERT(vaoSupport, "GFX: Vertex Array Objects aren't supported.");
   if (vaoSupport)
     return new WebGLVertexArrayObject(webgl);
 
   return nullptr;
 }
 
 JSObject*
 WebGLVertexArrayObject::WrapObject(JSContext* cx,
--- a/dom/canvas/compiledtest/TestWebGLElementArrayCache.cpp
+++ b/dom/canvas/compiledtest/TestWebGLElementArrayCache.cpp
@@ -111,17 +111,17 @@ void CheckValidateAllTypes(mozilla::WebG
 template<typename T>
 void
 CheckSanity()
 {
   const size_t numElems = 64; // should be significantly larger than tree leaf size to
                         // ensure we exercise some nontrivial tree-walking
   T data[numElems] = {1,0,3,1,2,6,5,4}; // intentionally specify only 8 elements for now
   size_t numBytes = numElems * sizeof(T);
-  MOZ_RELEASE_ASSERT(numBytes == sizeof(data));
+  MOZ_RELEASE_ASSERT(numBytes == sizeof(data), "GFX: number of bytes from size of each element * number of elements equals size of data.");
 
   GLenum type = GLType<T>();
 
   mozilla::WebGLElementArrayCache c;
   c.BufferData(data, numBytes);
   CheckValidate(true,  c, type, 6, 0, 8);
   CheckValidate(false, c, type, 5, 0, 8);
   CheckValidate(true,  c, type, 3, 0, 3);
@@ -135,34 +135,34 @@ CheckSanity()
 
   // now test a somewhat larger size to ensure we exceed the size of a tree leaf
   for(size_t i = 0; i < numElems; i++)
     data[i] = numElems - i;
   c.BufferData(data, numBytes);
   CheckValidate(true,  c, type, numElems,     0, numElems);
   CheckValidate(false, c, type, numElems - 1, 0, numElems);
 
-  MOZ_RELEASE_ASSERT(numElems > 10);
+  MOZ_RELEASE_ASSERT(numElems > 10, "GFX: Less than 10 elements in array cache");
   CheckValidate(true,  c, type, numElems - 10, 10, numElems - 10);
   CheckValidate(false, c, type, numElems - 11, 10, numElems - 10);
 }
 
 template<typename T>
 void
 CheckUintOverflow()
 {
   // This test is only for integer types smaller than uint32_t
   static_assert(sizeof(T) < sizeof(uint32_t), "This test is only for integer types \
                 smaller than uint32_t");
 
   const size_t numElems = 64; // should be significantly larger than tree leaf size to
                               // ensure we exercise some nontrivial tree-walking
   T data[numElems];
   size_t numBytes = numElems * sizeof(T);
-  MOZ_RELEASE_ASSERT(numBytes == sizeof(data));
+  MOZ_RELEASE_ASSERT(numBytes == sizeof(data), "GFX: size of data doesnt equal number of bytes of each element multiplied by number of elements.");
 
   GLenum type = GLType<T>();
 
   mozilla::WebGLElementArrayCache c;
 
   for(size_t i = 0; i < numElems; i++)
     data[i] = numElems - i;
   c.BufferData(data, numBytes);
--- a/dom/canvas/nsICanvasRenderingContextInternal.h
+++ b/dom/canvas/nsICanvasRenderingContextInternal.h
@@ -15,17 +15,16 @@
 #include "mozilla/dom/OffscreenCanvas.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
 
 #define NS_ICANVASRENDERINGCONTEXTINTERNAL_IID \
 { 0xb84f2fed, 0x9d4b, 0x430b, \
   { 0xbd, 0xfb, 0x85, 0x57, 0x8a, 0xc2, 0xb4, 0x4b } }
 
-class gfxASurface;
 class nsDisplayListBuilder;
 
 namespace mozilla {
 namespace layers {
 class CanvasLayer;
 class Layer;
 class LayerManager;
 } // namespace layers
--- a/dom/cellbroadcast/CellBroadcastMessage.h
+++ b/dom/cellbroadcast/CellBroadcastMessage.h
@@ -3,17 +3,16 @@
 /* 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 mozilla_dom_cellbroadcast_CellBroadcastMessage_h
 #define mozilla_dom_cellbroadcast_CellBroadcastMessage_h
 
 #include "mozilla/dom/MozCellBroadcastMessageBinding.h"
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
 
 class nsPIDOMWindowInner;
 
 namespace mozilla {
 namespace dom {
--- a/dom/devicestorage/DeviceStorage.h
+++ b/dom/devicestorage/DeviceStorage.h
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef DeviceStorage_h
 #define DeviceStorage_h
 
+#include "nsAutoPtr.h"
 #include "nsIFile.h"
 #include "nsIPrincipal.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/dom/DOMRequest.h"
 #include "nsWeakReference.h"
 
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -24,17 +24,16 @@
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/EventListenerManager.h"
 #include "mozilla/LazyIdleThread.h"
 #include "mozilla/Scoped.h"
 #include "mozilla/Services.h"
 #include "mozilla/ipc/BackgroundUtils.h" // for PrincipalInfoToPrincipal
 
 #include "nsArrayUtils.h"
-#include "nsAutoPtr.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsGlobalWindow.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIFile.h"
 #include "nsIDirectoryEnumerator.h"
 #include "nsNetUtil.h"
 #include "nsIOutputStream.h"
 #include "nsCycleCollectionParticipant.h"
--- a/dom/devicestorage/nsDeviceStorage.h
+++ b/dom/devicestorage/nsDeviceStorage.h
@@ -9,17 +9,16 @@
 
 #include "mozilla/Atomics.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Logging.h"
 #include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
 
 #include "DOMRequest.h"
 #include "DOMCursor.h"
-#include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsDOMClassInfoID.h"
 #include "nsIClassInfo.h"
 #include "nsIDOMWindow.h"
 #include "nsIURI.h"
 #include "nsIPrincipal.h"
 #include "nsString.h"
 #include "nsWeakPtr.h"
--- a/dom/encoding/TextDecoder.h
+++ b/dom/encoding/TextDecoder.h
@@ -5,16 +5,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_textdecoder_h_
 #define mozilla_dom_textdecoder_h_
 
 #include "mozilla/dom/NonRefcountedDOMObject.h"
 #include "mozilla/dom/TextDecoderBinding.h"
 #include "mozilla/dom/TypedArray.h"
+#include "nsAutoPtr.h"
 #include "nsIUnicodeDecoder.h"
 
 namespace mozilla {
 
 class ErrorResult;
 
 namespace dom {
 
--- a/dom/events/DataTransfer.h
+++ b/dom/events/DataTransfer.h
@@ -11,17 +11,16 @@
 #include "nsTArray.h"
 #include "nsIVariant.h"
 #include "nsIPrincipal.h"
 #include "nsIDOMDataTransfer.h"
 #include "nsIDOMElement.h"
 #include "nsIDragService.h"
 #include "nsCycleCollectionParticipant.h"
 
-#include "nsAutoPtr.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/dom/File.h"
 
 class nsINode;
 class nsITransferable;
 class nsISupportsArray;
 class nsILoadContext;
--- a/dom/events/Event.h
+++ b/dom/events/Event.h
@@ -10,17 +10,16 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/BasicEvents.h"
 #include "nsIDOMEvent.h"
 #include "nsISupports.h"
 #include "nsCOMPtr.h"
 #include "nsPIDOMWindow.h"
 #include "nsPoint.h"
 #include "nsCycleCollectionParticipant.h"
-#include "nsAutoPtr.h"
 #include "mozilla/dom/EventBinding.h"
 #include "nsIScriptGlobalObject.h"
 #include "Units.h"
 #include "js/TypeDecls.h"
 #include "nsIGlobalObject.h"
 
 class nsIContent;
 class nsIDOMEventTarget;
--- a/dom/events/IMEContentObserver.cpp
+++ b/dom/events/IMEContentObserver.cpp
@@ -11,17 +11,16 @@
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TextComposition.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/dom/Element.h"
-#include "nsAutoPtr.h"
 #include "nsContentUtils.h"
 #include "nsGkAtoms.h"
 #include "nsIAtom.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMRange.h"
 #include "nsIEditorIMESupport.h"
--- a/dom/events/Touch.h
+++ b/dom/events/Touch.h
@@ -7,17 +7,16 @@
 #ifndef mozilla_dom_Touch_h_
 #define mozilla_dom_Touch_h_
 
 #include "mozilla/Attributes.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/dom/TouchBinding.h"
 #include "nsWrapperCache.h"
-#include "nsAutoPtr.h"
 #include "Units.h"
 
 class nsPresContext;
 
 namespace mozilla {
 namespace dom {
 
 class EventTarget;
--- a/dom/fetch/Fetch.h
+++ b/dom/fetch/Fetch.h
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_Fetch_h
 #define mozilla_dom_Fetch_h
 
+#include "nsAutoPtr.h"
 #include "nsIInputStreamPump.h"
 #include "nsIStreamLoader.h"
 
 #include "nsCOMPtr.h"
 #include "nsError.h"
 #include "nsProxyRelease.h"
 #include "nsString.h"
 
--- a/dom/fetch/FetchDriver.h
+++ b/dom/fetch/FetchDriver.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_FetchDriver_h
 #define mozilla_dom_FetchDriver_h
 
-#include "nsAutoPtr.h"
 #include "nsIChannelEventSink.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIStreamListener.h"
 #include "nsIThreadRetargetableStreamListener.h"
 #include "mozilla/RefPtr.h"
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/net/ReferrerPolicy.h"
--- a/dom/filehandle/ActorsChild.h
+++ b/dom/filehandle/ActorsChild.h
@@ -6,17 +6,16 @@
 #define mozilla_dom_filehandle_ActorsChild_h
 
 #include "js/RootingAPI.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/FileHandleCommon.h"
 #include "mozilla/dom/PBackgroundFileHandleChild.h"
 #include "mozilla/dom/PBackgroundFileRequestChild.h"
 #include "mozilla/dom/PBackgroundMutableFileChild.h"
-#include "nsAutoPtr.h"
 
 class nsCString;
 
 namespace mozilla {
 namespace dom {
 
 class FileHandleBase;
 class FileRequestBase;
--- a/dom/filehandle/ActorsParent.cpp
+++ b/dom/filehandle/ActorsParent.cpp
@@ -9,16 +9,17 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/unused.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/FileHandleCommon.h"
 #include "mozilla/dom/PBackgroundFileHandleParent.h"
 #include "mozilla/dom/PBackgroundFileRequestParent.h"
 #include "mozilla/dom/indexedDB/ActorsParent.h"
 #include "mozilla/dom/ipc/BlobParent.h"
+#include "nsAutoPtr.h"
 #include "nsComponentManagerUtils.h"
 #include "nsDebug.h"
 #include "nsError.h"
 #include "nsIEventTarget.h"
 #include "nsIFileStreams.h"
 #include "nsIInputStream.h"
 #include "nsIOutputStream.h"
 #include "nsIRunnable.h"
--- a/dom/filesystem/CreateDirectoryTask.h
+++ b/dom/filesystem/CreateDirectoryTask.h
@@ -3,17 +3,16 @@
 /* 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 mozilla_dom_CreateDirectoryTask_h
 #define mozilla_dom_CreateDirectoryTask_h
 
 #include "mozilla/dom/FileSystemTaskBase.h"
-#include "nsAutoPtr.h"
 #include "mozilla/ErrorResult.h"
 
 namespace mozilla {
 namespace dom {
 
 class FileSystemCreateDirectoryParams;
 class Promise;
 
--- a/dom/filesystem/CreateFileTask.h
+++ b/dom/filesystem/CreateFileTask.h
@@ -3,17 +3,16 @@
 /* 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 mozilla_dom_CreateFileTask_h
 #define mozilla_dom_CreateFileTask_h
 
 #include "mozilla/dom/FileSystemTaskBase.h"
-#include "nsAutoPtr.h"
 #include "mozilla/ErrorResult.h"
 
 class nsIInputStream;
 
 namespace mozilla {
 namespace dom {
 
 class Blob;
--- a/dom/filesystem/Directory.h
+++ b/dom/filesystem/Directory.h
@@ -6,17 +6,16 @@
 
 #ifndef mozilla_dom_Directory_h
 #define mozilla_dom_Directory_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/File.h"
-#include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 
 // Resolve the name collision of Microsoft's API name with macros defined in
 // Windows header files. Undefine the macro of CreateDirectory to avoid
 // Directory#CreateDirectory being replaced by Directory#CreateDirectoryW.
 #ifdef CreateDirectory
 #undef CreateDirectory
--- a/dom/filesystem/FileSystemBase.h
+++ b/dom/filesystem/FileSystemBase.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_FileSystemBase_h
 #define mozilla_dom_FileSystemBase_h
 
-#include "nsAutoPtr.h"
 #include "nsString.h"
 #include "Directory.h"
 
 namespace mozilla {
 namespace dom {
 
 class BlobImpl;
 
--- a/dom/filesystem/FileSystemPermissionRequest.h
+++ b/dom/filesystem/FileSystemPermissionRequest.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_FileSystemPermissionRequest_h
 #define mozilla_dom_FileSystemPermissionRequest_h
 
-#include "nsAutoPtr.h"
 #include "nsIRunnable.h"
 #include "nsIContentPermissionPrompt.h"
 #include "nsString.h"
 
 class nsPIDOMWindowInner;
 
 namespace mozilla {
 namespace dom {
--- a/dom/filesystem/GetDirectoryListingTask.h
+++ b/dom/filesystem/GetDirectoryListingTask.h
@@ -5,17 +5,16 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_GetDirectoryListing_h
 #define mozilla_dom_GetDirectoryListing_h
 
 #include "mozilla/dom/Directory.h"
 #include "mozilla/dom/FileSystemTaskBase.h"
 #include "mozilla/ErrorResult.h"
-#include "nsAutoPtr.h"
 
 namespace mozilla {
 namespace dom {
 
 class BlobImpl;
 
 class GetDirectoryListingTaskChild final : public FileSystemTaskChildBase
 {
--- a/dom/filesystem/GetFileOrDirectoryTask.h
+++ b/dom/filesystem/GetFileOrDirectoryTask.h
@@ -4,17 +4,16 @@
  * 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 mozilla_dom_GetFileOrDirectory_h
 #define mozilla_dom_GetFileOrDirectory_h
 
 #include "mozilla/dom/Directory.h"
 #include "mozilla/dom/FileSystemTaskBase.h"
-#include "nsAutoPtr.h"
 #include "mozilla/ErrorResult.h"
 
 namespace mozilla {
 namespace dom {
 
 class BlobImpl;
 
 class GetFileOrDirectoryTaskChild final : public FileSystemTaskChildBase
--- a/dom/filesystem/GetFilesTask.h
+++ b/dom/filesystem/GetFilesTask.h
@@ -5,17 +5,16 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_GetFilesTask_h
 #define mozilla_dom_GetFilesTask_h
 
 #include "mozilla/dom/Directory.h"
 #include "mozilla/dom/FileSystemTaskBase.h"
 #include "mozilla/ErrorResult.h"
-#include "nsAutoPtr.h"
 
 namespace mozilla {
 namespace dom {
 
 class BlobImpl;
 
 class GetFilesTaskChild final : public FileSystemTaskChildBase
 {
--- a/dom/filesystem/RemoveTask.h
+++ b/dom/filesystem/RemoveTask.h
@@ -3,17 +3,16 @@
 /* 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 mozilla_dom_RemoveTask_h
 #define mozilla_dom_RemoveTask_h
 
 #include "mozilla/dom/FileSystemTaskBase.h"
-#include "nsAutoPtr.h"
 #include "mozilla/ErrorResult.h"
 
 namespace mozilla {
 namespace dom {
 
 class BlobImpl;
 class Promise;
 
--- a/dom/gamepad/Gamepad.cpp
+++ b/dom/gamepad/Gamepad.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "Gamepad.h"
-#include "nsAutoPtr.h"
 #include "nsPIDOMWindow.h"
 #include "nsTArray.h"
 #include "nsVariant.h"
 #include "mozilla/dom/GamepadBinding.h"
 
 namespace mozilla {
 namespace dom {
 
--- a/dom/gamepad/GamepadService.cpp
+++ b/dom/gamepad/GamepadService.cpp
@@ -11,17 +11,16 @@
 #include "mozilla/dom/GamepadButtonEvent.h"
 #include "mozilla/dom/GamepadEvent.h"
 #include "mozilla/dom/GamepadMonitoring.h"
 
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/StaticPtr.h"
 
-#include "nsAutoPtr.h"
 #include "nsIDOMEvent.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMWindow.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsIServiceManager.h"
 #include "nsITimer.h"
 #include "nsThreadUtils.h"
--- a/dom/gamepad/GamepadService.h
+++ b/dom/gamepad/GamepadService.h
@@ -3,17 +3,16 @@
 /* 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 mozilla_dom_GamepadService_h_
 #define mozilla_dom_GamepadService_h_
 
 #include <stdint.h>
-#include "nsAutoPtr.h"
 #include "nsCOMArray.h"
 #include "nsIGamepadServiceTest.h"
 #include "nsGlobalWindow.h"
 #include "nsIFocusManager.h"
 #include "nsIObserver.h"
 #include "nsITimer.h"
 #include "nsTArray.h"
 // Needed for GamepadMappingType
--- a/dom/geolocation/nsGeoPosition.h
+++ b/dom/geolocation/nsGeoPosition.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsGeoPosition_h
 #define nsGeoPosition_h
 
-#include "nsAutoPtr.h"
 #include "nsIDOMGeoPositionCoords.h"
 #include "nsIDOMGeoPosition.h"
 #include "nsString.h"
 #include "mozilla/Attributes.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "mozilla/dom/Nullable.h"
 #include "js/TypeDecls.h"
--- a/dom/geolocation/nsGeolocation.cpp
+++ b/dom/geolocation/nsGeolocation.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsXULAppAPI.h"
 
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/Telemetry.h"
 
+#include "nsAutoPtr.h"
 #include "nsISettingsService.h"
 
 #include "nsGeolocation.h"
 #include "nsDOMClassInfoID.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsContentUtils.h"
 #include "nsContentPermissionHelper.h"
--- a/dom/geolocation/nsGeolocation.h
+++ b/dom/geolocation/nsGeolocation.h
@@ -7,17 +7,16 @@
 #ifndef nsGeoLocation_h
 #define nsGeoLocation_h
 
 // Microsoft's API Name hackery sucks
 #undef CreateEvent
 
 #include "mozilla/StaticPtr.h"
 #include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "nsITimer.h"
 #include "nsIObserver.h"
 #include "nsWrapperCache.h"
 
 #include "nsWeakPtr.h"
 #include "nsCycleCollectionParticipant.h"
 
--- a/dom/html/HTMLAllCollection.h
+++ b/dom/html/HTMLAllCollection.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_HTMLAllCollection_h
 #define mozilla_dom_HTMLAllCollection_h
 
-#include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsISupportsImpl.h"
 #include "nsRefPtrHashtable.h"
 #include "nsWrapperCache.h"
 
 #include <stdint.h>
 
 class nsContentList;
--- a/dom/html/HTMLContentElement.h
+++ b/dom/html/HTMLContentElement.h
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_HTMLContentElement_h__
 #define mozilla_dom_HTMLContentElement_h__
 
+#include "nsAutoPtr.h"
 #include "nsINodeList.h"
 #include "nsGenericHTMLElement.h"
 
 struct nsCSSSelectorList;
 
 namespace mozilla {
 namespace dom {
 
--- a/dom/html/HTMLFormElement.h
+++ b/dom/html/HTMLFormElement.h
@@ -4,16 +4,17 @@
  * 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 mozilla_dom_HTMLFormElement_h
 #define mozilla_dom_HTMLFormElement_h
 
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/Attributes.h"
+#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsIForm.h"
 #include "nsIFormControl.h"
 #include "nsFormSubmission.h"
 #include "nsGenericHTMLElement.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIWebProgressListener.h"
 #include "nsIRadioGroupContainer.h"
--- a/dom/html/HTMLMapElement.h
+++ b/dom/html/HTMLMapElement.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_HTMLMapElement_h
 #define mozilla_dom_HTMLMapElement_h
 
 #include "mozilla/Attributes.h"
 #include "nsGenericHTMLElement.h"
 #include "nsIDOMHTMLMapElement.h"
-#include "nsAutoPtr.h"
 #include "nsGkAtoms.h"
 
 class nsContentList;
 
 namespace mozilla {
 namespace dom {
 
 class HTMLMapElement final : public nsGenericHTMLElement,
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef mozilla_dom_HTMLMediaElement_h
 #define mozilla_dom_HTMLMediaElement_h
 
+#include "nsAutoPtr.h"
 #include "nsIDOMHTMLMediaElement.h"
 #include "nsGenericHTMLElement.h"
 #include "MediaDecoderOwner.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIObserver.h"
 #include "mozilla/CORSMode.h"
 #include "DecoderTraits.h"
 #include "nsIAudioChannelAgent.h"
--- a/dom/html/HTMLObjectElement.cpp
+++ b/dom/html/HTMLObjectElement.cpp
@@ -3,17 +3,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/EventStates.h"
 #include "mozilla/dom/HTMLObjectElement.h"
 #include "mozilla/dom/HTMLObjectElementBinding.h"
 #include "mozilla/dom/ElementInlines.h"
-#include "nsAutoPtr.h"
 #include "nsAttrValueInlines.h"
 #include "nsGkAtoms.h"
 #include "nsError.h"
 #include "nsIDocument.h"
 #include "nsIPluginDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsFormSubmission.h"
 #include "nsIObjectFrame.h"
--- a/dom/html/ImageDocument.cpp
+++ b/dom/html/ImageDocument.cpp
@@ -22,17 +22,16 @@
 #include "nsGkAtoms.h"
 #include "imgIRequest.h"
 #include "imgILoader.h"
 #include "imgIContainer.h"
 #include "imgINotificationObserver.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsStyleContext.h"
-#include "nsAutoPtr.h"
 #include "nsIChannel.h"
 #include "nsIContentPolicy.h"
 #include "nsContentPolicyUtils.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsError.h"
 #include "nsURILoader.h"
--- a/dom/html/MediaDocument.h
+++ b/dom/html/MediaDocument.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_MediaDocument_h
 #define mozilla_dom_MediaDocument_h
 
 #include "mozilla/Attributes.h"
 #include "nsHTMLDocument.h"
 #include "nsGenericHTMLElement.h"
-#include "nsAutoPtr.h"
 #include "nsIStringBundle.h"
 
 #define NSMEDIADOCUMENT_PROPERTIES_URI "chrome://global/locale/layout/MediaDocument.properties"
 
 namespace mozilla {
 namespace dom {
 
 class MediaDocument : public nsHTMLDocument
--- a/dom/html/TimeRanges.h
+++ b/dom/html/TimeRanges.h
@@ -2,22 +2,22 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_TimeRanges_h_
 #define mozilla_dom_TimeRanges_h_
 
+#include "nsCOMPtr.h"
 #include "nsIDOMTimeRanges.h"
 #include "nsISupports.h"
 #include "nsTArray.h"
 #include "nsWrapperCache.h"
 #include "mozilla/ErrorResult.h"
-#include "nsAutoPtr.h"
 
 namespace mozilla {
 namespace dom {
 
 class TimeRanges;
 
 } // namespace dom
 
--- a/dom/html/UndoManager.cpp
+++ b/dom/html/UndoManager.cpp
@@ -23,17 +23,16 @@
 
 #include "mozilla/ErrorResult.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/Preferences.h"
 
 // Includes for mutation observer.
 #include "nsIDOMHTMLElement.h"
 #include "nsStubMutationObserver.h"
-#include "nsAutoPtr.h"
 #include "nsTransactionManager.h"
 
 // Includes for attribute changed transaction.
 #include "nsITransaction.h"
 #include "nsIContent.h"
 #include "nsIDOMMutationEvent.h"
 #include "mozilla/dom/Element.h"
 
--- a/dom/html/nsDOMStringMap.h
+++ b/dom/html/nsDOMStringMap.h
@@ -3,17 +3,16 @@
 /* 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 nsDOMStringMap_h
 #define nsDOMStringMap_h
 
 #include "nsCycleCollectionParticipant.h"
-#include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
 #include "nsGenericHTMLElement.h"
 #include "jsfriendapi.h" // For js::ExpandoAndGeneration
 
 namespace mozilla {
 class ErrorResult;
--- a/dom/html/nsHTMLDNSPrefetch.h
+++ b/dom/html/nsHTMLDNSPrefetch.h
@@ -3,17 +3,16 @@
 /* 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 nsHTMLDNSPrefetch_h___
 #define nsHTMLDNSPrefetch_h___
 
 #include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
 #include "nsString.h"
 
 #include "nsIDNSListener.h"
 #include "nsIWebProgressListener.h"
 #include "nsWeakReference.h"
 #include "nsIObserver.h"
 
 class nsIDocument;
--- a/dom/html/nsIConstraintValidation.h
+++ b/dom/html/nsIConstraintValidation.h
@@ -3,17 +3,16 @@
 /* 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 nsIConstraintValidition_h___
 #define nsIConstraintValidition_h___
 
 #include "nsISupports.h"
-#include "nsAutoPtr.h"
 #include "nsString.h"
 
 class nsIDOMValidityState;
 
 namespace mozilla {
 namespace dom {
 class ValidityState;
 } // namespace dom
--- a/dom/html/nsRadioVisitor.cpp
+++ b/dom/html/nsRadioVisitor.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsRadioVisitor.h"
-#include "nsAutoPtr.h"
 #include "mozilla/dom/HTMLInputElement.h"
 #include "nsIConstraintValidation.h"
 
 using namespace mozilla::dom;
 
 NS_IMPL_ISUPPORTS(nsRadioVisitor, nsIRadioVisitor)
 
 bool
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -223,20 +223,23 @@ public:
   nsFrameSelection* GetConstFrameSelection()
     { return mFrameSelection; }
 
   //NSISELECTIONCONTROLLER INTERFACES
   NS_IMETHOD SetDisplaySelection(int16_t toggle) override;
   NS_IMETHOD GetDisplaySelection(int16_t* _retval) override;
   NS_IMETHOD SetSelectionFlags(int16_t aInEnable) override;
   NS_IMETHOD GetSelectionFlags(int16_t *aOutEnable) override;
-  NS_IMETHOD GetSelection(int16_t type, nsISelection** _retval) override;
-  NS_IMETHOD ScrollSelectionIntoView(int16_t aType, int16_t aRegion, int16_t aFlags) override;
-  NS_IMETHOD RepaintSelection(int16_t type) override;
-  NS_IMETHOD RepaintSelection(nsPresContext* aPresContext, SelectionType aSelectionType);
+  NS_IMETHOD GetSelection(RawSelectionType aRawSelectionType,
+                          nsISelection** aSelection) override;
+  NS_IMETHOD ScrollSelectionIntoView(RawSelectionType aRawSelectionType,
+                                     int16_t aRegion, int16_t aFlags) override;
+  NS_IMETHOD RepaintSelection(RawSelectionType aRawSelectionType) override;
+  nsresult RepaintSelection(nsPresContext* aPresContext,
+                            SelectionType aSelectionType);
   NS_IMETHOD SetCaretEnabled(bool enabled) override;
   NS_IMETHOD SetCaretReadOnly(bool aReadOnly) override;
   NS_IMETHOD GetCaretEnabled(bool* _retval) override;
   NS_IMETHOD GetCaretVisible(bool* _retval) override;
   NS_IMETHOD SetCaretVisibilityDuringSelection(bool aVisibility) override;
   NS_IMETHOD PhysicalMove(int16_t aDirection, int16_t aAmount, bool aExtend) override;
   NS_IMETHOD CharacterMove(bool aForward, bool aExtend) override;
   NS_IMETHOD CharacterExtendForDelete() override;
@@ -330,50 +333,60 @@ nsTextInputSelectionImpl::SetSelectionFl
 NS_IMETHODIMP
 nsTextInputSelectionImpl::GetSelectionFlags(int16_t *aOutEnable)
 {
   *aOutEnable = nsISelectionDisplay::DISPLAY_TEXT;
   return NS_OK; 
 }
 
 NS_IMETHODIMP
-nsTextInputSelectionImpl::GetSelection(int16_t type, nsISelection **_retval)
+nsTextInputSelectionImpl::GetSelection(RawSelectionType aRawSelectionType,
+                                       nsISelection** aSelection)
 {
   if (!mFrameSelection)
     return NS_ERROR_NULL_POINTER;
-    
-  *_retval = mFrameSelection->GetSelection(type);
-  
-  if (!(*_retval))
-    return NS_ERROR_FAILURE;
+
+  *aSelection =
+    mFrameSelection->GetSelection(ToSelectionType(aRawSelectionType));
 
-  NS_ADDREF(*_retval);
+  // GetSelection() fails only when aRawSelectionType is invalid value.
+  if (!(*aSelection)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  NS_ADDREF(*aSelection);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsTextInputSelectionImpl::ScrollSelectionIntoView(int16_t aType, int16_t aRegion, int16_t aFlags)
+nsTextInputSelectionImpl::ScrollSelectionIntoView(
+                            RawSelectionType aRawSelectionType,
+                            int16_t aRegion,
+                            int16_t aFlags)
 {
   if (!mFrameSelection) 
     return NS_ERROR_FAILURE; 
 
-  return mFrameSelection->ScrollSelectionIntoView(aType, aRegion, aFlags);
+  return mFrameSelection->ScrollSelectionIntoView(
+                            ToSelectionType(aRawSelectionType),
+                            aRegion, aFlags);
 }
 
 NS_IMETHODIMP
-nsTextInputSelectionImpl::RepaintSelection(int16_t type)
+nsTextInputSelectionImpl::RepaintSelection(RawSelectionType aRawSelectionType)
 {
   if (!mFrameSelection)
     return NS_ERROR_FAILURE;
 
-  return mFrameSelection->RepaintSelection(type);
+  return mFrameSelection->RepaintSelection(ToSelectionType(aRawSelectionType));
 }
 
-NS_IMETHODIMP
-nsTextInputSelectionImpl::RepaintSelection(nsPresContext* aPresContext, SelectionType aSelectionType)
+nsresult
+nsTextInputSelectionImpl::RepaintSelection(nsPresContext* aPresContext,
+                                           SelectionType aSelectionType)
 {
   if (!mFrameSelection)
     return NS_ERROR_FAILURE;
 
   return mFrameSelection->RepaintSelection(aSelectionType);
 }
 
 NS_IMETHODIMP
@@ -398,18 +411,18 @@ nsTextInputSelectionImpl::SetCaretReadOn
 {
   if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
   nsresult result;
   nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShellWeak, &result);
   if (shell)
   {
     RefPtr<nsCaret> caret = shell->GetCaret();
     if (caret) {
-      nsISelection* domSel = mFrameSelection->
-        GetSelection(nsISelectionController::SELECTION_NORMAL);
+      nsISelection* domSel =
+        mFrameSelection->GetSelection(SelectionType::eNormal);
       if (domSel)
         caret->SetCaretReadOnly(aReadOnly);
       return NS_OK;
     }
   }
   return NS_ERROR_FAILURE;
 }
 
@@ -441,18 +454,18 @@ nsTextInputSelectionImpl::SetCaretVisibi
 {
   if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
   nsresult result;
   nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShellWeak, &result);
   if (shell)
   {
     RefPtr<nsCaret> caret = shell->GetCaret();
     if (caret) {
-      nsISelection* domSel = mFrameSelection->
-        GetSelection(nsISelectionController::SELECTION_NORMAL);
+      nsISelection* domSel =
+        mFrameSelection->GetSelection(SelectionType::eNormal);
       if (domSel)
         caret->SetVisibilityDuringSelection(aVisibility);
       return NS_OK;
     }
   }
   return NS_ERROR_FAILURE;
 }
 
--- a/dom/html/nsTextEditorState.h
+++ b/dom/html/nsTextEditorState.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsTextEditorState_h__
 #define nsTextEditorState_h__
 
-#include "nsAutoPtr.h"
 #include "nsString.h"
 #include "nsITextControlElement.h"
 #include "nsITextControlFrame.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/WeakPtr.h"
--- a/dom/icc/IccListener.h
+++ b/dom/icc/IccListener.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_IccListener_h
 #define mozilla_dom_IccListener_h
 
-#include "nsAutoPtr.h"
 #include "nsIIccService.h"
 
 namespace mozilla {
 namespace dom {
 
 class IccManager;
 class Icc;
 
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -53,16 +53,17 @@
 #include "mozilla/dom/quota/QuotaManager.h"
 #include "mozilla/dom/quota/UsageInfo.h"
 #include "mozilla/ipc/BackgroundParent.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/ipc/InputStreamParams.h"
 #include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/ipc/PBackground.h"
 #include "mozilla/storage/Variant.h"
+#include "nsAutoPtr.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsClassHashtable.h"
 #include "nsCOMPtr.h"
 #include "nsDataHashtable.h"
 #include "nsEscape.h"
 #include "nsHashKeys.h"
 #include "nsNetUtil.h"
 #include "nsISimpleEnumerator.h"
--- a/dom/indexedDB/FileInfo.h
+++ b/dom/indexedDB/FileInfo.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_indexeddb_fileinfo_h__
 #define mozilla_dom_indexeddb_fileinfo_h__
 
-#include "nsAutoPtr.h"
 #include "nsISupportsImpl.h"
 
 namespace mozilla {
 namespace dom {
 namespace indexedDB {
 
 class FileManager;
 
--- a/dom/indexedDB/FileSnapshot.h
+++ b/dom/indexedDB/FileSnapshot.h
@@ -4,17 +4,16 @@
  * 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 mozilla_dom_indexeddb_filesnapshot_h__
 #define mozilla_dom_indexeddb_filesnapshot_h__
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/File.h"
-#include "nsAutoPtr.h"
 #include "nsISupports.h"
 #include "nsWeakPtr.h"
 
 #define FILEIMPLSNAPSHOT_IID \
   {0x0dfc11b1, 0x75d3, 0x473b, {0x8c, 0x67, 0xb7, 0x23, 0xf4, 0x67, 0xd6, 0x73}}
 
 class PIBlobImplSnapshot : public nsISupports
 {
--- a/dom/indexedDB/IDBCursor.h
+++ b/dom/indexedDB/IDBCursor.h
@@ -7,17 +7,16 @@
 #ifndef mozilla_dom_idbcursor_h__
 #define mozilla_dom_idbcursor_h__
 
 #include "IndexedDatabase.h"
 #include "js/RootingAPI.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/IDBCursorBinding.h"
 #include "mozilla/dom/indexedDB/Key.h"
-#include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 
 class nsPIDOMWindowInner;
 
 namespace mozilla {
 
 class ErrorResult;
--- a/dom/indexedDB/IDBDatabase.cpp
+++ b/dom/indexedDB/IDBDatabase.cpp
@@ -33,16 +33,17 @@
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/dom/ipc/BlobChild.h"
 #include "mozilla/dom/ipc/nsIRemoteBlob.h"
 #include "mozilla/dom/quota/QuotaManager.h"
 #include "mozilla/ipc/FileDescriptor.h"
 #include "mozilla/ipc/InputStreamParams.h"
 #include "mozilla/ipc/InputStreamUtils.h"
+#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsIDocument.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsIScriptError.h"
 #include "nsISupportsPrimitives.h"
 #include "nsThreadUtils.h"
 #include "ProfilerHelpers.h"
--- a/dom/indexedDB/IDBFileRequest.h
+++ b/dom/indexedDB/IDBFileRequest.h
@@ -6,17 +6,16 @@
 
 #ifndef mozilla_dom_idbfilerequest_h__
 #define mozilla_dom_idbfilerequest_h__
 
 #include "DOMRequest.h"
 #include "js/TypeDecls.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/FileRequestBase.h"
-#include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 
 template <class> struct already_AddRefed;
 class nsPIDOMWindowInner;
 
 namespace mozilla {
 
 class EventChainPreVisitor;
--- a/dom/indexedDB/IDBMutableFile.h
+++ b/dom/indexedDB/IDBMutableFile.h
@@ -8,17 +8,16 @@
 #define mozilla_dom_idbmutablefile_h__
 
 #include "js/TypeDecls.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/dom/FileModeBinding.h"
 #include "mozilla/dom/MutableFileBase.h"
-#include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsHashKeys.h"
 #include "nsString.h"
 #include "nsTHashtable.h"
 
 class nsPIDOMWindowInner;
 
 namespace mozilla {
--- a/dom/indexedDB/IDBTransaction.cpp
+++ b/dom/indexedDB/IDBTransaction.cpp
@@ -11,16 +11,17 @@
 #include "IDBEvents.h"
 #include "IDBObjectStore.h"
 #include "IDBRequest.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/dom/DOMError.h"
 #include "mozilla/dom/DOMStringList.h"
 #include "mozilla/ipc/BackgroundChild.h"
+#include "nsAutoPtr.h"
 #include "nsPIDOMWindow.h"
 #include "nsServiceManagerUtils.h"
 #include "nsTHashtable.h"
 #include "ProfilerHelpers.h"
 #include "ReportInternalError.h"
 #include "WorkerFeature.h"
 #include "WorkerPrivate.h"
 
--- a/dom/indexedDB/IndexedDatabase.h
+++ b/dom/indexedDB/IndexedDatabase.h
@@ -3,17 +3,16 @@
 /* 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 mozilla_dom_indexeddatabase_h__
 #define mozilla_dom_indexeddatabase_h__
 
 #include "js/StructuredClone.h"
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsTArray.h"
 
 namespace mozilla {
 namespace dom {
 
 class Blob;
 class IDBDatabase;
--- a/dom/ipc/BlobParent.h
+++ b/dom/ipc/BlobParent.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_ipc_BlobParent_h
 #define mozilla_dom_ipc_BlobParent_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/dom/PBlobParent.h"
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsTArray.h"
 
 template <class, class> class nsDataHashtable;
 class nsIDHashKey;
 class nsIEventTarget;
 class nsIRemoteBlob;
 template <class> class nsRevocableEventPtr;
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -55,16 +55,17 @@
 #include "mozilla/net/NeckoChild.h"
 #include "mozilla/plugins/PluginInstanceParent.h"
 #include "mozilla/plugins/PluginModuleParent.h"
 #include "mozilla/widget/WidgetMessageUtils.h"
 #include "nsBaseDragService.h"
 #include "mozilla/media/MediaChild.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/WebBrowserPersistDocumentChild.h"
+#include "imgLoader.h"
 
 #if defined(MOZ_CONTENT_SANDBOX)
 #if defined(XP_WIN)
 #define TARGET_SANDBOX_EXPORTS
 #include "mozilla/sandboxTarget.h"
 #elif defined(XP_LINUX)
 #include "mozilla/Sandbox.h"
 #include "mozilla/SandboxInfo.h"
@@ -2239,16 +2240,26 @@ ContentChild::RecvRegisterChromeItem(con
       MOZ_ASSERT(false, "bad chrome item");
       return false;
   }
 
   return true;
 }
 
 bool
+ContentChild::RecvClearImageCache(const bool& privateLoader, const bool& chrome)
+{
+  imgLoader* loader = privateLoader ? imgLoader::PrivateBrowsingLoader() :
+                                      imgLoader::NormalLoader();
+
+  loader->ClearCache(chrome);
+  return true;
+}
+
+bool
 ContentChild::RecvSetOffline(const bool& offline)
 {
   nsCOMPtr<nsIIOService> io (do_GetIOService());
   NS_ASSERTION(io, "IO Service can not be null");
 
   io->SetOffline(offline);
 
   return true;
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -7,16 +7,17 @@
 #ifndef mozilla_dom_ContentChild_h
 #define mozilla_dom_ContentChild_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/ContentBridgeParent.h"
 #include "mozilla/dom/nsIContentChild.h"
 #include "mozilla/dom/PBrowserOrId.h"
 #include "mozilla/dom/PContentChild.h"
+#include "nsAutoPtr.h"
 #include "nsHashKeys.h"
 #include "nsIObserver.h"
 #include "nsTHashtable.h"
 
 #include "nsWeakPtr.h"
 #include "nsIWindowProvider.h"
 
 
@@ -382,16 +383,19 @@ public:
 
   virtual bool RecvRegisterChrome(InfallibleTArray<ChromePackage>&& packages,
                                   InfallibleTArray<SubstitutionMapping>&& resources,
                                   InfallibleTArray<OverrideMapping>&& overrides,
                                   const nsCString& locale,
                                   const bool& reset) override;
   virtual bool RecvRegisterChromeItem(const ChromeRegistryItem& item) override;
 
+  virtual bool RecvClearImageCache(const bool& privateLoader,
+                                   const bool& chrome) override;
+
   virtual mozilla::jsipc::PJavaScriptChild* AllocPJavaScriptChild() override;
 
   virtual bool DeallocPJavaScriptChild(mozilla::jsipc::PJavaScriptChild*) override;
 
   virtual PRemoteSpellcheckEngineChild* AllocPRemoteSpellcheckEngineChild() override;
 
   virtual bool DeallocPRemoteSpellcheckEngineChild(PRemoteSpellcheckEngineChild*) override;
 
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -104,17 +104,16 @@
 #endif
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/WebBrowserPersistDocumentParent.h"
 #include "mozilla/unused.h"
 #include "nsAnonymousTemporaryFile.h"
 #include "nsAppRunner.h"
-#include "nsAutoPtr.h"
 #include "nsCDefaultURIFixup.h"
 #include "nsCExternalHandlerService.h"
 #include "nsCOMPtr.h"
 #include "nsChromeRegistryChrome.h"
 #include "nsConsoleMessage.h"
 #include "nsConsoleService.h"
 #include "nsContentUtils.h"
 #include "nsDebugImpl.h"
@@ -1396,39 +1395,27 @@ ContentParent::CreateContentBridgeParent
   return parent;
 }
 
 void
 ContentParent::GetAll(nsTArray<ContentParent*>& aArray)
 {
   aArray.Clear();
 
-  if (!sContentParents) {
-    return;
-  }
-
-  for (ContentParent* cp = sContentParents->getFirst(); cp;
-     cp = cp->LinkedListElement<ContentParent>::getNext()) {
-    if (cp->mIsAlive) {
-      aArray.AppendElement(cp);
-    }
+  for (auto* cp : AllProcesses(eLive)) {
+    aArray.AppendElement(cp);
   }
 }
 
 void
 ContentParent::GetAllEvenIfDead(nsTArray<ContentParent*>& aArray)
 {
   aArray.Clear();
 
-  if (!sContentParents) {
-    return;
-  }
-
-  for (ContentParent* cp = sContentParents->getFirst(); cp;
-     cp = cp->LinkedListElement<ContentParent>::getNext()) {
+  for (auto* cp : AllProcesses(eAll)) {
     aArray.AppendElement(cp);
   }
 }
 
 void
 ContentParent::Init()
 {
   nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
@@ -5105,27 +5092,24 @@ ContentParent::IgnoreIPCPrincipal()
                                  "dom.testing.ignore_ipc_principal", false);
   }
   return sIgnoreIPCPrincipal;
 }
 
 void
 ContentParent::NotifyUpdatedDictionaries()
 {
-  AutoTArray<ContentParent*, 8> processes;
-  GetAll(processes);
-
   nsCOMPtr<nsISpellChecker> spellChecker(do_GetService(NS_SPELLCHECKER_CONTRACTID));
   MOZ_ASSERT(spellChecker, "No spell checker?");
 
   InfallibleTArray<nsString> dictionaries;
   spellChecker->GetDictionaryList(&dictionaries);
 
-  for (size_t i = 0; i < processes.Length(); ++i) {
-    Unused << processes[i]->SendUpdateDictionaryList(dictionaries);
+  for (auto* cp : AllProcesses(eLive)) {
+    Unused << cp->SendUpdateDictionaryList(dictionaries);
   }
 }
 
 /*static*/ TabId
 ContentParent::AllocateTabId(const TabId& aOpenerTabId,
                              const IPCTabContext& aContext,
                              const ContentParentId& aCpId)
 {
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -161,16 +161,71 @@ public:
   CreateBrowserOrApp(const TabContext& aContext,
                      Element* aFrameElement,
                      ContentParent* aOpenerContentParent);
 
   static void GetAll(nsTArray<ContentParent*>& aArray);
 
   static void GetAllEvenIfDead(nsTArray<ContentParent*>& aArray);
 
+  enum CPIteratorPolicy {
+    eLive,
+    eAll
+  };
+
+  class ContentParentIterator {
+  private:
+    ContentParent* mCurrent;
+    CPIteratorPolicy mPolicy;
+
+  public:
+    ContentParentIterator(CPIteratorPolicy aPolicy, ContentParent* aCurrent)
+      : mCurrent(aCurrent),
+        mPolicy(aPolicy)
+    {
+    }
+
+    ContentParentIterator begin()
+    {
+      return *this;
+    }
+    ContentParentIterator end()
+    {
+      return ContentParentIterator(mPolicy, nullptr);
+    }
+
+    const ContentParentIterator& operator++()
+    {
+      MOZ_ASSERT(mCurrent);
+      do {
+        mCurrent = mCurrent->LinkedListElement<ContentParent>::getNext();
+      } while (mPolicy != eAll && mCurrent && !mCurrent->mIsAlive);
+
+      return *this;
+    }
+
+    bool operator!=(const ContentParentIterator& aOther)
+    {
+      MOZ_ASSERT(mPolicy == aOther.mPolicy);
+      return mCurrent != aOther.mCurrent;
+    }
+
+    ContentParent* operator*()
+    {
+      return mCurrent;
+    }
+  };
+
+  static ContentParentIterator AllProcesses(CPIteratorPolicy aPolicy)
+  {
+    ContentParent* first =
+      sContentParents ? sContentParents->getFirst() : nullptr;
+    return ContentParentIterator(aPolicy, first);
+  }
+
   static bool IgnoreIPCPrincipal();
 
   static void NotifyUpdatedDictionaries();
 
 #if defined(XP_WIN)
   /**
    * Windows helper for firing off an update window request to a plugin
    * instance.
--- a/dom/ipc/CrashReporterParent.cpp
+++ b/dom/ipc/CrashReporterParent.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #include "CrashReporterParent.h"
 #include "mozilla/Snprintf.h"
 #include "mozilla/dom/ContentParent.h"
+#include "nsAutoPtr.h"
 #include "nsXULAppAPI.h"
 #include <time.h>
 
 #include "mozilla/Telemetry.h"
 
 #ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
 #include "nsICrashService.h"
@@ -106,22 +107,16 @@ CrashReporterParent::GenerateCrashReport
   }
 
   bool result = GenerateChildData(processNotes);
   FinalizeChildData();
   return result;
 }
 
 bool
-CrashReporterParent::UseMinidump(nsIFile* aMinidump)
-{
-  return CrashReporter::GetIDFromMinidump(aMinidump, mChildDumpID);
-}
-
-bool
 CrashReporterParent::GenerateChildData(const AnnotationTable* processNotes)
 {
   MOZ_ASSERT(mInitialized);
 
   if (mChildDumpID.IsEmpty()) {
     NS_WARNING("problem with GenerateChildData: no child dump id yet!");
     return false;
   }
--- a/dom/ipc/CrashReporterParent.h
+++ b/dom/ipc/CrashReporterParent.h
@@ -64,25 +64,16 @@ public:
    * @returns true if successful, false otherwise.
    */
   template<class Toplevel>
   bool
   GenerateMinidumpAndPair(Toplevel* aTopLevel, nsIFile* aMinidump,
                           const nsACString& aPairName);
 
   /**
-   * Uses the specified minidump instead of taking a new one.
-   *
-   * @param aMinidump - the minidump to use for this crashreport.
-   * @returns true if successful, false otherwise.
-   */
-  bool
-  UseMinidump(nsIFile* aMinidump);
-
-  /**
    * Apply child process annotations to an existing paired mindump generated
    * with GeneratePairedMinidump.
    *
    * Be careful about calling generate apis immediately after this call,
    * see FinalizeChildData.
    *
    * @param processNotes (optional) - Additional notes to append. Annotations
    *   stored in mNotes will also be applied. processNotes can be null.
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -509,16 +509,18 @@ child:
     async PTestShell();
 
     async PAPZ(TabId tabId);
 
     async RegisterChrome(ChromePackage[] packages, SubstitutionMapping[] substitutions,
                          OverrideMapping[] overrides, nsCString locale, bool reset);
     async RegisterChromeItem(ChromeRegistryItem item);
 
+    async ClearImageCache(bool privateLoader, bool chrome);
+
     async SetOffline(bool offline);
     async SetConnectivity(bool connectivity);
 
     async NotifyVisited(URIParams uri);
 
     async SystemMemoryAvailable(uint64_t getterId, uint32_t memoryAvailable);
 
     async PreferenceUpdate(PrefSetting pref);
--- a/dom/ipc/PProcessHangMonitor.ipdl
+++ b/dom/ipc/PProcessHangMonitor.ipdl
@@ -16,17 +16,16 @@ struct SlowScriptData
   nsCString filename;
   uint32_t lineno;
 };
 
 struct PluginHangData
 {
   uint32_t pluginId;
   ProcessId contentProcessId;
-  ProcessId pluginProcessId;
 };
 
 union HangData
 {
   SlowScriptData;
   PluginHangData;
 };
 
--- a/dom/ipc/ProcessHangMonitor.cpp
+++ b/dom/ipc/ProcessHangMonitor.cpp
@@ -82,17 +82,17 @@ class HangMonitorChild
                                     unsigned aLineNo);
   void NotifySlowScriptAsync(TabId aTabId,
                              const nsCString& aFileName,
                              unsigned aLineNo);
 
   bool IsDebuggerStartupComplete();
 
   void NotifyPluginHang(uint32_t aPluginId);
-  void NotifyPluginHangAsync(uint32_t aPluginId, ProcessId aPid);
+  void NotifyPluginHangAsync(uint32_t aPluginId);
 
   void ClearHang();
   void ClearHangAsync();
 
   virtual bool RecvTerminateScript() override;
   virtual bool RecvBeginStartingDebugger() override;
   virtual bool RecvEndStartingDebugger() override;
 
@@ -204,18 +204,16 @@ public:
   void BeginStartingDebugger();
   void EndStartingDebugger();
   void CleanupPluginHang(uint32_t aPluginId, bool aRemoveFiles);
 
   MessageLoop* MonitorLoop() { return mHangMonitor->MonitorLoop(); }
 
  private:
   void ShutdownOnThread();
-  void GenerateMinidumps(uint32_t aPluginId, ProcessId aPluginPid,
-                         ProcessId aContentPid, nsString& aCrashId);
 
   const RefPtr<ProcessHangMonitor> mHangMonitor;
 
   // This field is read-only after construction.
   bool mReportHangs;
 
   // This field is only accessed on the hang thread.
   bool mIPCOpen;
@@ -400,34 +398,31 @@ HangMonitorChild::IsDebuggerStartupCompl
 void
 HangMonitorChild::NotifyPluginHang(uint32_t aPluginId)
 {
   // main thread in the child
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
 
   mSentReport = true;
 
-  base::ProcessId pluginPid = plugins::PluginProcessId(aPluginId);
   // bounce to background thread
-  MonitorLoop()->PostTask(
-    NewNonOwningRunnableMethod<uint32_t, uint32_t>(this,
-                                                   &HangMonitorChild::NotifyPluginHangAsync,
-                                                   aPluginId, pluginPid));
+  MonitorLoop()->PostTask(NewNonOwningRunnableMethod<uint32_t>(this,
+                                                               &HangMonitorChild::NotifyPluginHangAsync,
+                                                               aPluginId));
 }
 
 void
-HangMonitorChild::NotifyPluginHangAsync(uint32_t aPluginId,
-                                        base::ProcessId aPid)
+HangMonitorChild::NotifyPluginHangAsync(uint32_t aPluginId)
 {
   MOZ_RELEASE_ASSERT(MessageLoop::current() == MonitorLoop());
 
   // bounce back to parent on background thread
   if (mIPCOpen) {
     Unused << SendHangEvidence(PluginHangData(aPluginId,
-                                              base::GetCurrentProcId(), aPid));
+                                              base::GetCurrentProcId()));
   }
 }
 
 void
 HangMonitorChild::ClearHang()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -566,64 +561,16 @@ public:
   }
 
 private:
   RefPtr<HangMonitoredProcess> mProcess;
   HangData mHangData;
   nsAutoString mBrowserDumpId;
 };
 
-void
-HangMonitorParent::GenerateMinidumps(uint32_t aPluginId, ProcessId aPluginPid,
-                                     ProcessId aContentPid, nsString& aCrashId)
-{
-#ifdef MOZ_CRASHREPORTER
-  if (mBrowserCrashDumpIds.Get(aPluginId, &aCrashId)) {
-    return; // We already have a dump for this hang
-  }
-
-  nsCOMPtr<nsIFile> browserDump;
-  if (!CrashReporter::TakeMinidump(getter_AddRefs(browserDump), true)) {
-    NS_WARNING("Failed to generate a minidump for the browser process");
-    return;
-  }
-
-  nsCOMPtr<nsIFile> pluginDump;
-  mozilla::ipc::ScopedProcessHandle pluginHandle;
-  if (!base::OpenPrivilegedProcessHandle(aPluginPid, &pluginHandle.rwget()) ||
-      !CrashReporter::CreateMinidumpsAndPair(pluginHandle, 0,
-                                             NS_LITERAL_CSTRING("browser"),
-                                             browserDump,
-                                             getter_AddRefs(pluginDump))) {
-    browserDump->Remove(false);
-    NS_WARNING("Failed to generate a minidump for the plugin process");
-    return;
-  }
-
-  if (!CrashReporter::GetIDFromMinidump(pluginDump, aCrashId) ||
-      aCrashId.IsEmpty()) {
-    pluginDump->Remove(false);
-    return;
-  }
-
-  mBrowserCrashDumpIds.Put(aPluginId, aCrashId);
-
-  mozilla::ipc::ScopedProcessHandle contentHandle;
-  if (!base::OpenPrivilegedProcessHandle(aContentPid, &contentHandle.rwget()) ||
-      !CrashReporter::CreateAdditionalChildMinidump(contentHandle,
-                                                    0, pluginDump,
-                                                    NS_LITERAL_CSTRING("content"))) {
-    NS_WARNING("Failed to generate a minidump for the content process");
-    return;
-  }
-
-  return;
-#endif
-}
-
 bool
 HangMonitorParent::RecvHangEvidence(const HangData& aHangData)
 {
   // chrome process, background thread
   MOZ_RELEASE_ASSERT(MessageLoop::current() == MonitorLoop());
 
   if (!mReportHangs) {
     return true;
@@ -639,18 +586,27 @@ HangMonitorParent::RecvHangEvidence(cons
 
   // Before we wake up the browser main thread we want to take a
   // browser minidump.
   nsAutoString crashId;
 #ifdef MOZ_CRASHREPORTER
   if (aHangData.type() == HangData::TPluginHangData) {
     MutexAutoLock lock(mBrowserCrashDumpHashLock);
     const PluginHangData& phd = aHangData.get_PluginHangData();
-    GenerateMinidumps(phd.pluginId(), phd.pluginProcessId(),
-                           phd.contentProcessId(), crashId);
+    if (!mBrowserCrashDumpIds.Get(phd.pluginId(), &crashId)) {
+      nsCOMPtr<nsIFile> browserDump;
+      if (CrashReporter::TakeMinidump(getter_AddRefs(browserDump), true)) {
+        if (!CrashReporter::GetIDFromMinidump(browserDump, crashId) || crashId.IsEmpty()) {
+          browserDump->Remove(false);
+          NS_WARNING("Failed to generate timely browser stack, this is bad for plugin hang analysis!");
+        } else {
+          mBrowserCrashDumpIds.Put(phd.pluginId(), crashId);
+        }
+      }
+    }
   }
 #endif
 
   mHangMonitor->InitiateCPOWTimeout();
 
   MonitorAutoLock lock(mMonitor);
 
   nsCOMPtr<nsIRunnable> notifier =
--- a/dom/json/nsJSON.cpp
+++ b/dom/json/nsJSON.cpp
@@ -17,17 +17,16 @@
 #include "nsIUnicodeDecoder.h"
 #include "nsXPCOMStrings.h"
 #include "nsNetUtil.h"
 #include "nsIURI.h"
 #include "nsComponentManagerUtils.h"
 #include "nsContentUtils.h"
 #include "nsIScriptError.h"
 #include "nsCRTGlue.h"
-#include "nsAutoPtr.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsNullPrincipal.h"
 #include "mozilla/Maybe.h"
 #include <algorithm>
 
 using mozilla::dom::EncodingUtils;
 
 #define JSON_STREAM_BUFSIZE 4096
--- a/dom/jsurl/nsJSProtocolHandler.cpp
+++ b/dom/jsurl/nsJSProtocolHandler.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* vim: set ts=4 sw=4 et tw=78: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
 #include "jsapi.h"
 #include "jswrapper.h"
 #include "nsCRT.h"
 #include "nsError.h"
 #include "nsXPIDLString.h"
 #include "nsReadableUtils.h"
 #include "nsJSProtocolHandler.h"
 #include "nsStringStream.h"
--- a/dom/locales/en-US/chrome/layout/css.properties
+++ b/dom/locales/en-US/chrome/layout/css.properties
@@ -170,8 +170,11 @@ PEInvalidVariableTokenFallback=Found invalid token ‘%1$S’ at top level of variable reference fallback.
 PEExpectedVariableNameEOF=identifier for variable name
 PEExpectedVariableName=Expected identifier for variable name but found ‘%1$S’.
 PEExpectedVariableFallback=Expected variable reference fallback after ‘,’.
 PEExpectedVariableCommaOrCloseParen=Expected ‘,’ or ‘)’ after variable name in variable reference but found ‘%1$S’.
 PESubgridNotSupported=Support for the ‘subgrid’ keyword of CSS Grid is not enabled.
 PEMoreThanOneGridRepeatAutoFillInNameList=Only one repeat(auto-fill, …) is allowed in a name list for a subgrid.
 PEMoreThanOneGridRepeatAutoFillFitInTrackList=Only one repeat(auto-fill, …) or repeat(auto-fit, …) is allowed in a track list.
 PEMoreThanOneGridRepeatTrackSize=Only one track size is allowed inside repeat(auto-fit/auto-fill, …).
+
+TooLargeDashedRadius=Border radius is too large for ‘dashed’ style (the limit is 100000px). Rendering as solid.
+TooLargeDottedRadius=Border radius is too large for ‘dotted’ style (the limit is 100000px). Rendering as solid.
--- a/dom/media/ADTSDemuxer.cpp
+++ b/dom/media/ADTSDemuxer.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ADTSDemuxer.h"
 
 #include <inttypes.h>
 
+#include "nsAutoPtr.h"
 #include "VideoUtils.h"
 #include "TimeUnits.h"
 #include "prenv.h"
 
 #ifdef PR_LOGGING
 mozilla::LazyLogModule gADTSDemuxerLog("ADTSDemuxer");
 #define ADTSLOG(msg, ...) \
   MOZ_LOG(gADTSDemuxerLog, LogLevel::Debug, ("ADTSDemuxer " msg, ##__VA_ARGS__))
--- a/dom/media/DOMMediaStream.h
+++ b/dom/media/DOMMediaStream.h
@@ -3,16 +3,17 @@
  * 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 NSDOMMEDIASTREAM_H_
 #define NSDOMMEDIASTREAM_H_
 
 #include "ImageContainer.h"
 
+#include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "StreamTracks.h"
 #include "nsIDOMWindow.h"
 #include "nsIPrincipal.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "PrincipalChangeObserver.h"
 
--- a/dom/media/GraphDriver.h
+++ b/dom/media/GraphDriver.h
@@ -1,17 +1,16 @@
 /* -*- 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 GRAPHDRIVER_H_
 #define GRAPHDRIVER_H_
 
-#include "nsAutoPtr.h"
 #include "nsAutoRef.h"
 #include "AudioBufferUtils.h"
 #include "AudioMixer.h"
 #include "AudioSegment.h"
 #include "SelfRef.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/SharedThreadPool.h"
 #include "mozilla/StaticPtr.h"
--- a/dom/media/MP3Demuxer.cpp
+++ b/dom/media/MP3Demuxer.cpp
@@ -6,16 +6,17 @@
 
 #include "MP3Demuxer.h"
 
 #include <inttypes.h>
 #include <algorithm>
 
 #include "mozilla/Assertions.h"
 #include "mozilla/EndianUtils.h"
+#include "nsAutoPtr.h"
 #include "VideoUtils.h"
 #include "TimeUnits.h"
 #include "prenv.h"
 
 #ifdef PR_LOGGING
 mozilla::LazyLogModule gMP3DemuxerLog("MP3Demuxer");
 #define MP3LOG(msg, ...) \
   MOZ_LOG(gMP3DemuxerLog, LogLevel::Debug, ("MP3Demuxer " msg, ##__VA_ARGS__))
--- a/dom/media/MediaDecoderOwner.h
+++ b/dom/media/MediaDecoderOwner.h
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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 MediaDecoderOwner_h_
 #define MediaDecoderOwner_h_
 #include "AbstractMediaDecoder.h"
+#include "nsAutoPtr.h"
 
 namespace mozilla {
 
 class VideoFrameContainer;
 
 namespace dom {
 class HTMLMediaElement;
 } // namespace dom
--- a/dom/media/MediaDecoderReader.h
+++ b/dom/media/MediaDecoderReader.h
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #if !defined(MediaDecoderReader_h_)
 #define MediaDecoderReader_h_
 
 #include "mozilla/EnumSet.h"
 #include "mozilla/MozPromise.h"
+#include "nsAutoPtr.h"
 
 #include "AbstractMediaDecoder.h"
 #include "MediaInfo.h"
 #include "MediaData.h"
 #include "MediaMetadataManager.h"
 #include "MediaQueue.h"
 #include "MediaTimer.h"
 #include "AudioCompactor.h"
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -81,16 +81,17 @@ hardware (via AudioStream).
 */
 #if !defined(MediaDecoderStateMachine_h__)
 #define MediaDecoderStateMachine_h__
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "mozilla/StateMirroring.h"
 
+#include "nsAutoPtr.h"
 #include "nsThreadUtils.h"
 #include "MediaCallbackID.h"
 #include "MediaDecoder.h"
 #include "MediaDecoderReader.h"
 #include "MediaDecoderOwner.h"
 #include "MediaEventSource.h"
 #include "MediaMetadataManager.h"
 #include "MediaStatistics.h"
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -9,16 +9,17 @@
 
 #include "mozilla/Atomics.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/TaskQueue.h"
 #include "mozilla/Monitor.h"
 
 #include "MediaDataDemuxer.h"
 #include "MediaDecoderReader.h"
+#include "nsAutoPtr.h"
 #include "PDMFactory.h"
 
 namespace mozilla {
 
 class CDMProxy;
 
 class MediaFormatReader final : public MediaDecoderReader
 {
--- a/dom/media/MediaManager.h
+++ b/dom/media/MediaManager.h
@@ -3,16 +3,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_MEDIAMANAGER_H
 #define MOZILLA_MEDIAMANAGER_H
 
 #include "MediaEngine.h"
 #include "mozilla/Services.h"
 #include "mozilla/unused.h"
+#include "nsAutoPtr.h"
 #include "nsIMediaManager.h"
 
 #include "nsHashKeys.h"
 #include "nsGlobalWindow.h"
 #include "nsClassHashtable.h"
 #include "nsRefPtrHashtable.h"
 #include "nsIObserver.h"
 #include "nsIPrefService.h"
--- a/dom/media/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -14,16 +14,17 @@
 #include "mozilla/StaticPtr.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/AudioStreamTrack.h"
 #include "mozilla/dom/BlobEvent.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/RecordErrorEvent.h"
 #include "mozilla/dom/VideoStreamTrack.h"
+#include "nsAutoPtr.h"
 #include "nsContentUtils.h"
 #include "nsError.h"
 #include "nsIDocument.h"
 #include "nsIPermissionManager.h"
 #include "nsIPrincipal.h"
 #include "nsIScriptError.h"
 #include "nsMimeTypes.h"
 #include "nsProxyRelease.h"
--- a/dom/media/MediaStreamGraph.h
+++ b/dom/media/MediaStreamGraph.h
@@ -15,16 +15,17 @@
 #include "AudioSegment.h"
 #include "AudioStream.h"
 #include "nsTArray.h"
 #include "nsIRunnable.h"
 #include "StreamTracks.h"
 #include "VideoFrameContainer.h"
 #include "VideoSegment.h"
 #include "MainThreadUtils.h"
+#include "nsAutoPtr.h"
 #include "nsAutoRef.h"
 #include <speex/speex_resampler.h>
 #include "DOMMediaStream.h"
 
 class nsIRunnable;
 
 template <>
 class nsAutoRefTraits<SpeexResamplerState> : public nsPointerRefTraits<SpeexResamplerState>
--- a/dom/media/RtspMediaResource.h
+++ b/dom/media/RtspMediaResource.h
@@ -3,16 +3,17 @@
  * 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/. */
 
 #if !defined(RtspMediaResource_h_)
 #define RtspMediaResource_h_
 
 #include "MediaResource.h"
 #include "mozilla/Monitor.h"
+#include "nsAutoPtr.h"
 #include "nsITimer.h"
 #include "VideoUtils.h"
 
 namespace mozilla {
 
 class RtspTrackBuffer;
 
 /* RtspMediaResource
--- a/dom/media/SharedBuffer.h
+++ b/dom/media/SharedBuffer.h
@@ -4,17 +4,16 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_SHAREDBUFFER_H_
 #define MOZILLA_SHAREDBUFFER_H_
 
 #include "mozilla/CheckedInt.h"
 #include "mozilla/mozalloc.h"
 #include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
 
 namespace mozilla {
 
 class AudioBlockBuffer;
 
 /**
  * Base class for objects with a thread-safe refcount and a virtual
  * destructor.
--- a/dom/media/TextTrackRegion.h
+++ b/dom/media/TextTrackRegion.h
@@ -2,17 +2,16 @@
 /* vim:set ts=2 sw=2 et tw=78: */
 /* 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 mozilla_dom_TextTrackRegion_h
 #define mozilla_dom_TextTrackRegion_h
 
-#include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/TextTrack.h"
 #include "mozilla/Preferences.h"
 
 namespace mozilla {
--- a/dom/media/TrackUnionStream.h
+++ b/dom/media/TrackUnionStream.h
@@ -2,16 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_TRACKUNIONSTREAM_H_
 #define MOZILLA_TRACKUNIONSTREAM_H_
 
 #include "MediaStreamGraph.h"
+#include "nsAutoPtr.h"
 #include <algorithm>
 
 namespace mozilla {
 
 /**
  * See MediaStreamGraph::CreateTrackUnionStream.
  */
 class TrackUnionStream : public ProcessedMediaStream {
--- a/dom/media/VideoFrameContainer.h
+++ b/dom/media/VideoFrameContainer.h
@@ -6,17 +6,16 @@
 
 #ifndef VIDEOFRAMECONTAINER_H_
 #define VIDEOFRAMECONTAINER_H_
 
 #include "mozilla/Mutex.h"
 #include "mozilla/TimeStamp.h"
 #include "gfxPoint.h"
 #include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
 #include "ImageContainer.h"
 #include "MediaSegment.h"
 
 namespace mozilla {
 
 namespace dom {
 class HTMLMediaElement;
 } // namespace dom
--- a/dom/media/VideoSegment.h
+++ b/dom/media/VideoSegment.h
@@ -4,17 +4,16 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_VIDEOSEGMENT_H_
 #define MOZILLA_VIDEOSEGMENT_H_
 
 #include "MediaSegment.h"
 #include "nsCOMPtr.h"
 #include "gfxPoint.h"
-#include "nsAutoPtr.h"
 #include "ImageContainer.h"
 
 namespace mozilla {
 
 namespace layers {
 class Image;
 } // namespace layers
 
--- a/dom/media/VideoUtils.h
+++ b/dom/media/VideoUtils.h
@@ -8,16 +8,17 @@
 #define VideoUtils_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/MozPromise.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "mozilla/RefPtr.h"
 
+#include "nsAutoPtr.h"
 #include "nsIThread.h"
 #include "nsSize.h"
 #include "nsRect.h"
 
 #include "nsThreadUtils.h"
 #include "prtime.h"
 #include "AudioSampleFormat.h"
 #include "TimeUnits.h"
--- a/dom/media/WebVTTListener.h
+++ b/dom/media/WebVTTListener.h
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_WebVTTLoadListener_h
 #define mozilla_dom_WebVTTLoadListener_h
 
 #include "nsIWebVTTListener.h"
 #include "nsIStreamListener.h"
 #include "nsIChannelEventSink.h"
-#include "nsAutoPtr.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsCycleCollectionParticipant.h"
 
 class nsIWebVTTParserWrapper;
 
 namespace mozilla {
 namespace dom {
 
--- a/dom/media/android/AndroidMediaPluginHost.cpp
+++ b/dom/media/android/AndroidMediaPluginHost.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 #include "mozilla/Preferences.h"
 #include "MediaResource.h"
 #include "mozilla/dom/HTMLMediaElement.h"
 #include "mozilla/Services.h"
 #include "AndroidMediaPluginHost.h"
+#include "nsAutoPtr.h"
 #include "nsXPCOMStrings.h"
 #include "nsISeekableStream.h"
 #include "nsIGfxInfo.h"
 #include "gfxCrashReporterUtils.h"
 #include "prmem.h"
 #include "prlink.h"
 #include "AndroidMediaResourceServer.h"
 #include "nsServiceManagerUtils.h"
--- a/dom/media/android/AndroidMediaReader.h
+++ b/dom/media/android/AndroidMediaReader.h
@@ -5,17 +5,16 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 #if !defined(AndroidMediaReader_h_)
 #define AndroidMediaReader_h_
 
 #include "mozilla/Attributes.h"
 #include "MediaResource.h"
 #include "MediaDecoderReader.h"
 #include "ImageContainer.h"
-#include "nsAutoPtr.h"
 #include "mozilla/layers/SharedRGBImage.h"
 
 #include "MPAPI.h"
 
 class nsACString;
 
 namespace mozilla {
 
--- a/dom/media/directshow/DirectShowUtils.cpp
+++ b/dom/media/directshow/DirectShowUtils.cpp
@@ -2,17 +2,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DirectShowUtils.h"
 #include "dmodshow.h"
 #include "wmcodecdsp.h"
 #include "dmoreg.h"
-#include "nsAutoPtr.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/RefPtr.h"
 #include "nsPrintfCString.h"
 
 #define WARN(...) NS_WARNING(nsPrintfCString(__VA_ARGS__).get())
 
 namespace mozilla {
 
--- a/dom/media/directshow/SampleSink.h
+++ b/dom/media/directshow/SampleSink.h
@@ -4,17 +4,16 @@
  * 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/. */
 
 #if !defined(SampleSink_h_)
 #define SampleSink_h_
 
 #include "BaseFilter.h"
 #include "DirectShowUtils.h"
-#include "nsAutoPtr.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/ReentrantMonitor.h"
 
 namespace mozilla {
 
 class SampleSink {
 public:
   SampleSink();
--- a/dom/media/eme/CDMCaps.h
+++ b/dom/media/eme/CDMCaps.h
@@ -3,17 +3,16 @@
 /* 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 CDMCaps_h_
 #define CDMCaps_h_
 
 #include "nsString.h"
-#include "nsAutoPtr.h"
 #include "mozilla/Monitor.h"
 #include "nsIThread.h"
 #include "nsTArray.h"
 #include "mozilla/Attributes.h"
 #include "SamplesWaitingForKey.h"
 #include "gmp-decryption.h"
 
 namespace mozilla {
--- a/dom/media/encoder/ContainerWriter.h
+++ b/dom/media/encoder/ContainerWriter.h
@@ -2,17 +2,16 @@
 /* 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 ContainerWriter_h_
 #define ContainerWriter_h_
 
 #include "nsTArray.h"
-#include "nsAutoPtr.h"
 #include "EncodedFrameContainer.h"
 #include "TrackMetadataBase.h"
 
 namespace mozilla {
 /**
  * ContainerWriter packs encoded track data into a specific media container.
  */
 class ContainerWriter {
--- a/dom/media/encoder/EncodedFrameContainer.h
+++ b/dom/media/encoder/EncodedFrameContainer.h
@@ -1,17 +1,16 @@
 /* -*- 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 EncodedFrameContainer_H_
 #define EncodedFrameContainer_H_
 
-#include "nsAutoPtr.h"
 #include "nsTArray.h"
 
 namespace mozilla {
 
 class EncodedFrame;
 
 /*
  * This container is used to carry video or audio encoded data from encoder to muxer.
--- a/dom/media/encoder/MediaEncoder.h
+++ b/dom/media/encoder/MediaEncoder.h
@@ -5,16 +5,17 @@
 
 #ifndef MediaEncoder_h_
 #define MediaEncoder_h_
 
 #include "mozilla/DebugOnly.h"
 #include "TrackEncoder.h"
 #include "ContainerWriter.h"
 #include "MediaStreamGraph.h"
+#include "nsAutoPtr.h"
 #include "nsIMemoryReporter.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Atomics.h"
 
 namespace mozilla {
 
 /**
  * MediaEncoder is the framework of encoding module, it controls and manages
--- a/dom/media/encoder/OmxTrackEncoder.h
+++ b/dom/media/encoder/OmxTrackEncoder.h
@@ -1,16 +1,17 @@
 /* -*- 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 OmxTrackEncoder_h_
 #define OmxTrackEncoder_h_
 
+#include "nsAutoPtr.h"
 #include "TrackEncoder.h"
 
 namespace android {
 class OMXVideoEncoder;
 class OMXAudioEncoder;
 }
 
 /**
--- a/dom/media/encoder/fmp4_muxer/AVCBox.h
+++ b/dom/media/encoder/fmp4_muxer/AVCBox.h
@@ -2,17 +2,16 @@
 /* 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 AVCBox_h_
 #define AVCBox_h_
 
 #include "nsTArray.h"
-#include "nsAutoPtr.h"
 #include "ISOMediaBoxes.h"
 
 namespace mozilla {
 
 class ISOControl;
 
 // 14496-12 8.5.2.2
 #define resolution_72_dpi 0x00480000
--- a/dom/media/encoder/fmp4_muxer/ISOMediaWriter.h
+++ b/dom/media/encoder/fmp4_muxer/ISOMediaWriter.h
@@ -2,16 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef ISOMediaWriter_h_
 #define ISOMediaWriter_h_
 
 #include "ContainerWriter.h"
+#include "nsAutoPtr.h"
 #include "nsIRunnable.h"
 
 namespace mozilla {
 
 class ISOControl;
 class FragmentBuffer;
 
 class ISOMediaWriter : public ContainerWriter
--- a/dom/media/fmp4/MP4Demuxer.cpp
+++ b/dom/media/fmp4/MP4Demuxer.cpp
@@ -15,16 +15,18 @@
 #include "mp4_demuxer/BufferStream.h"
 #include "mp4_demuxer/Index.h"
 
 // Used for telemetry
 #include "mozilla/Telemetry.h"
 #include "mp4_demuxer/AnnexB.h"
 #include "mp4_demuxer/H264.h"
 
+#include "nsAutoPtr.h"
+
 mozilla::LogModule* GetDemuxerLog() {
   static mozilla::LazyLogModule log("MP4Demuxer");
   return log;
 }
 
 namespace mozilla {
 
 class MP4TrackDemuxer : public MediaTrackDemuxer
--- a/dom/media/gmp/GMPEncryptedBufferDataImpl.h
+++ b/dom/media/gmp/GMPEncryptedBufferDataImpl.h
@@ -2,16 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GMPEncryptedBufferDataImpl_h_
 #define GMPEncryptedBufferDataImpl_h_
 
 #include "gmp-decryption.h"
+#include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "mozilla/gmp/GMPTypes.h"
 
 namespace mozilla {
 class CryptoSample;
 
 namespace gmp {
 
--- a/dom/media/gmp/GMPPlatform.cpp
+++ b/dom/media/gmp/GMPPlatform.cpp
@@ -2,17 +2,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "GMPPlatform.h"
 #include "GMPStorageChild.h"
 #include "GMPTimerChild.h"
 #include "mozilla/Monitor.h"
-#include "nsAutoPtr.h"
 #include "GMPChild.h"
 #include <ctime>
 
 namespace mozilla {
 namespace gmp {
 
 static MessageLoop* sMainLoop = nullptr;
 static GMPChild* sChild = nullptr;
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -5,16 +5,17 @@
 
 #include "GMPServiceParent.h"
 #include "GMPService.h"
 #include "prio.h"
 #include "base/task.h"
 #include "mozilla/Logging.h"
 #include "GMPParent.h"
 #include "GMPVideoDecoderParent.h"
+#include "nsAutoPtr.h"
 #include "nsIObserverService.h"
 #include "GeckoChildProcessHost.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/SyncRunnable.h"
 #include "nsXPCOMPrivate.h"
 #include "mozilla/Services.h"
 #include "nsNativeCharsetUtils.h"
--- a/dom/media/gmp/GMPTimerParent.cpp
+++ b/dom/media/gmp/GMPTimerParent.cpp
@@ -1,16 +1,17 @@
 /* -*- 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/. */
 
 #include "GMPTimerParent.h"
 #include "nsComponentManagerUtils.h"
 #include "mozilla/unused.h"
+#include "nsAutoPtr.h"
 
 namespace mozilla {
 
 #ifdef LOG
 #undef LOG
 #endif
 
 extern LogModule* GetGMPLog();
--- a/dom/media/gmp/GMPTimerParent.h
+++ b/dom/media/gmp/GMPTimerParent.h
@@ -6,17 +6,16 @@
 #ifndef GMPTimerParent_h_
 #define GMPTimerParent_h_
 
 #include "mozilla/gmp/PGMPTimerParent.h"
 #include "nsITimer.h"
 #include "nsCOMPtr.h"
 #include "nsClassHashtable.h"
 #include "nsHashKeys.h"
-#include "nsAutoPtr.h"
 #include "mozilla/Monitor.h"
 #include "nsIThread.h"
 
 namespace mozilla {
 namespace gmp {
 
 class GMPTimerParent : public PGMPTimerParent {
 public:
--- a/dom/media/gmp/GMPVideoEncodedFrameImpl.h
+++ b/dom/media/gmp/GMPVideoEncodedFrameImpl.h
@@ -31,16 +31,17 @@
 #ifndef GMPVideoEncodedFrameImpl_h_
 #define GMPVideoEncodedFrameImpl_h_
 
 #include "gmp-errors.h"
 #include "gmp-video-frame.h"
 #include "gmp-video-frame-encoded.h"
 #include "gmp-decryption.h"
 #include "mozilla/ipc/Shmem.h"
+#include "nsAutoPtr.h"
 
 namespace mozilla {
 class CryptoSample;
 
 namespace gmp {
 
 class GMPVideoHostImpl;
 class GMPVideoEncodedFrameData;
--- a/dom/media/gtest/MockMediaDecoderOwner.h
+++ b/dom/media/gtest/MockMediaDecoderOwner.h
@@ -1,16 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOCK_MEDIA_DECODER_OWNER_H_
 #define MOCK_MEDIA_DECODER_OWNER_H_
 
 #include "MediaDecoderOwner.h"
+#include "nsAutoPtr.h"
 
 namespace mozilla
 {
 
 class MockMediaDecoderOwner : public MediaDecoderOwner
 {
 public:
   nsresult DispatchAsyncEvent(const nsAString& aName) override
--- a/dom/media/gtest/TestGMPCrossOrigin.cpp
+++ b/dom/media/gtest/TestGMPCrossOrigin.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "gtest/gtest.h"
+#include "nsAutoPtr.h"
 #include "nsIObserverService.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "GMPTestMonitor.h"
 #include "GMPVideoDecoderProxy.h"
 #include "GMPVideoEncoderProxy.h"
 #include "GMPDecryptorProxy.h"
 #include "GMPServiceParent.h"
--- a/dom/media/mediasource/ContainerParser.cpp
+++ b/dom/media/mediasource/ContainerParser.cpp
@@ -13,16 +13,17 @@
 #include "mozilla/Logging.h"
 #include "mozilla/Maybe.h"
 #include "MediaData.h"
 #ifdef MOZ_FMP4
 #include "MP4Stream.h"
 #include "mp4_demuxer/AtomType.h"
 #include "mp4_demuxer/ByteReader.h"
 #endif
+#include "nsAutoPtr.h"
 #include "SourceBufferResource.h"
 
 extern mozilla::LogModule* GetMediaSourceSamplesLog();
 
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
 #define MSE_DEBUG(name, arg, ...) MOZ_LOG(GetMediaSourceSamplesLog(), mozilla::LogLevel::Debug, (TOSTRING(name) "(%p:%s)::%s: " arg, this, mType.get(), __func__, ##__VA_ARGS__))
 #define MSE_DEBUGV(name, arg, ...) MOZ_LOG(GetMediaSourceSamplesLog(), mozilla::LogLevel::Verbose, (TOSTRING(name) "(%p:%s)::%s: " arg, this, mType.get(), __func__, ##__VA_ARGS__))
--- a/dom/media/mediasource/SourceBuffer.h
+++ b/dom/media/mediasource/SourceBuffer.h
@@ -13,17 +13,16 @@
 #include "mozilla/Assertions.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/dom/SourceBufferBinding.h"
 #include "mozilla/dom/TypedArray.h"
 #include "mozilla/mozalloc.h"
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionNoteChild.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsISupports.h"
 #include "nsString.h"
 #include "nscore.h"
 #include "TrackBuffersManager.h"
 #include "SourceBufferTask.h"
--- a/dom/media/mediasource/TrackBuffersManager.h
+++ b/dom/media/mediasource/TrackBuffersManager.h
@@ -13,16 +13,17 @@
 #include "AutoTaskQueue.h"
 #include "mozilla/dom/SourceBufferBinding.h"
 
 #include "MediaData.h"
 #include "MediaDataDemuxer.h"
 #include "MediaSourceDecoder.h"
 #include "SourceBufferTask.h"
 #include "TimeUnits.h"
+#include "nsAutoPtr.h"
 #include "nsProxyRelease.h"
 #include "nsString.h"
 #include "nsTArray.h"
 
 namespace mozilla {
 
 class ContainerParser;
 class MediaByteBuffer;
--- a/dom/media/ogg/OggCodecState.h
+++ b/dom/media/ogg/OggCodecState.h
@@ -14,16 +14,17 @@
 #include <vorbis/codec.h>
 #endif
 #include <opus/opus.h>
 #include "opus/opus_multistream.h"
 // For MOZ_SAMPLE_TYPE_*
 #include "mozilla/dom/HTMLMediaElement.h"
 #include "MediaDecoderStateMachine.h"
 #include "MediaDecoderReader.h"
+#include <nsAutoPtr.h>
 #include <nsAutoRef.h>
 #include <nsDeque.h>
 #include <nsTArray.h>
 #include <nsClassHashtable.h>
 #include "VideoUtils.h"
 
 #include <stdint.h>
 
--- a/dom/media/ogg/OggReader.cpp
+++ b/dom/media/ogg/OggReader.cpp
@@ -15,16 +15,17 @@
 #include <algorithm>
 #include "opus/opus.h"
 extern "C" {
 #include "opus/opus_multistream.h"
 }
 #include "mozilla/TimeStamp.h"
 #include "VorbisUtils.h"
 #include "MediaMetadataManager.h"
+#include "nsAutoPtr.h"
 #include "nsISeekableStream.h"
 #include "gfx2DGlue.h"
 #include "mozilla/Telemetry.h"
 #include "nsPrintfCString.h"
 
 using namespace mozilla::gfx;
 using namespace mozilla::media;
 
--- a/dom/media/omx/MediaOmxCommonDecoder.h
+++ b/dom/media/omx/MediaOmxCommonDecoder.h
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MEDIA_OMX_COMMON_DECODER_H
 #define MEDIA_OMX_COMMON_DECODER_H
 
 #include "MediaDecoder.h"
+#include "nsAutoPtr.h"
 
 namespace android {
 struct MOZ_EXPORT MediaSource;
 } // namespace android
 
 namespace mozilla {
 
 class AudioOffloadPlayerBase;
--- a/dom/media/omx/MediaStreamSource.h
+++ b/dom/media/omx/MediaStreamSource.h
@@ -8,17 +8,16 @@
 #define MEDIA_STREAM_SOURCE_H
 
 #include <stdint.h>
 
 #include <stagefright/DataSource.h>
 #include <stagefright/MediaSource.h>
 
 #include "MediaResource.h"
-#include "nsAutoPtr.h"
 
 namespace android {
 
 // MediaStreamSource is a DataSource that reads from a MPAPI media stream.
 class MediaStreamSource : public DataSource {
   typedef mozilla::MediaResource MediaResource;
   typedef mozilla::MediaResourceIndex MediaResourceIndex;
 
--- a/dom/media/omx/OMXCodecWrapper.cpp
+++ b/dom/media/omx/OMXCodecWrapper.cpp
@@ -17,16 +17,17 @@
 
 #include "AudioChannelFormat.h"
 #include "GrallocImages.h"
 #include "LayersLogging.h"
 #include "libyuv.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/layers/GrallocTextureClient.h"
+#include "nsAutoPtr.h"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 
 #define INPUT_BUFFER_TIMEOUT_US (5 * 1000ll)
 // AMR NB kbps
 #define AMRNB_BITRATE 12200
--- a/dom/media/omx/RtspExtractor.cpp
+++ b/dom/media/omx/RtspExtractor.cpp
@@ -2,16 +2,17 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "RtspExtractor.h"
 
 #include "mozilla/ReentrantMonitor.h"
+#include "nsAutoPtr.h"
 
 using namespace android;
 
 #define FRAME_DEFAULT_SIZE 1024
 
 namespace mozilla {
 
 /* class RtspMediaSource : implements MediaSource for OMX.
--- a/dom/media/platforms/agnostic/BlankDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/BlankDecoderModule.cpp
@@ -6,16 +6,17 @@
 
 #include "ImageContainer.h"
 #include "MediaDecoderReader.h"
 #include "MediaInfo.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/mozalloc.h" // for operator new, and new (fallible)
 #include "mozilla/RefPtr.h"
 #include "mozilla/TaskQueue.h"
+#include "nsAutoPtr.h"
 #include "nsRect.h"
 #include "PlatformDecoderModule.h"
 #include "TimeUnits.h"
 #include "VideoUtils.h"
 
 namespace mozilla {
 
 // Decoder that uses a passed in object's Create function to create blank
--- a/dom/media/platforms/agnostic/VorbisDecoder.cpp
+++ b/dom/media/platforms/agnostic/VorbisDecoder.cpp
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "VorbisDecoder.h"
 #include "VorbisUtils.h"
 #include "XiphExtradata.h"
 
 #include "mozilla/PodOperations.h"
 #include "mozilla/SyncRunnable.h"
-#include "nsAutoPtr.h"
 
 #undef LOG
 #define LOG(type, msg) MOZ_LOG(sPDMLog, type, msg)
 
 namespace mozilla {
 
 ogg_packet InitVorbisPacket(const unsigned char* aData, size_t aLength,
                          bool aBOS, bool aEOS,
--- a/dom/media/platforms/agnostic/WAVDecoder.cpp
+++ b/dom/media/platforms/agnostic/WAVDecoder.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WAVDecoder.h"
 #include "AudioSampleFormat.h"
-#include "nsAutoPtr.h"
 #include "mozilla/SyncRunnable.h"
 
 using mp4_demuxer::ByteReader;
 
 namespace mozilla {
 
 int16_t
 DecodeALawSample(uint8_t aValue)
--- a/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp
@@ -6,16 +6,17 @@
 
 #include "EMEDecoderModule.h"
 #include "EMEAudioDecoder.h"
 #include "EMEVideoDecoder.h"
 #include "MediaDataDecoderProxy.h"
 #include "mozIGeckoMediaPluginService.h"
 #include "mozilla/CDMProxy.h"
 #include "mozilla/unused.h"
+#include "nsAutoPtr.h"
 #include "nsServiceManagerUtils.h"
 #include "MediaInfo.h"
 #include "nsClassHashtable.h"
 #include "GMPDecoderModule.h"
 
 namespace mozilla {
 
 typedef MozPromiseRequestHolder<CDMProxy::DecryptPromise> DecryptPromiseRequestHolder;
--- a/dom/media/platforms/agnostic/gmp/GMPAudioDecoder.h
+++ b/dom/media/platforms/agnostic/gmp/GMPAudioDecoder.h
@@ -6,16 +6,17 @@
 
 #if !defined(GMPAudioDecoder_h_)
 #define GMPAudioDecoder_h_
 
 #include "GMPAudioDecoderProxy.h"
 #include "MediaDataDecoderProxy.h"
 #include "PlatformDecoderModule.h"
 #include "mozIGeckoMediaPluginService.h"
+#include "nsAutoPtr.h"
 
 namespace mozilla {
 
 class AudioCallbackAdapter : public GMPAudioDecoderCallbackProxy {
 public:
   explicit AudioCallbackAdapter(MediaDataDecoderCallbackProxy* aCallback)
    : mCallback(aCallback)
    , mLastStreamOffset(0)
--- a/dom/media/platforms/android/AndroidDecoderModule.cpp
+++ b/dom/media/platforms/android/AndroidDecoderModule.cpp
@@ -7,17 +7,16 @@
 #include "AndroidSurfaceTexture.h"
 #include "GLImages.h"
 
 #include "MediaData.h"
 #include "MediaInfo.h"
 #include "VPXDecoder.h"
 
 #include "nsThreadUtils.h"
-#include "nsAutoPtr.h"
 #include "nsPromiseFlatString.h"
 #include "nsIGfxInfo.h"
 
 #include "prlog.h"
 
 #include <jni.h>
 
 static PRLogModuleInfo* AndroidDecoderModuleLog()
--- a/dom/media/platforms/apple/AppleVDADecoder.cpp
+++ b/dom/media/platforms/apple/AppleVDADecoder.cpp
@@ -11,17 +11,16 @@
 #include "AppleVDADecoder.h"
 #include "AppleVDALinker.h"
 #include "MediaInfo.h"
 #include "mp4_demuxer/H264.h"
 #include "MP4Decoder.h"
 #include "MediaData.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/SyncRunnable.h"
-#include "nsAutoPtr.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Logging.h"
 #include "VideoUtils.h"
 #include <algorithm>
 #include "gfxPlatform.h"
 
 #ifndef MOZ_WIDGET_UIKIT
 #include "nsCocoaFeatures.h"
--- a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp
@@ -180,18 +180,17 @@ FFmpegDataDecoder<LIBAV_VER>::ProcessShu
   if (mCodecContext) {
     mLib->avcodec_close(mCodecContext);
     mLib->av_freep(&mCodecContext);
 #if LIBAVCODEC_VERSION_MAJOR >= 55
     mLib->av_frame_free(&mFrame);
 #elif LIBAVCODEC_VERSION_MAJOR == 54
     mLib->avcodec_free_frame(&mFrame);
 #else
-    delete mFrame;
-    mFrame = nullptr;
+    mLib->av_freep(&mFrame);
 #endif
   }
 }
 
 AVFrame*
 FFmpegDataDecoder<LIBAV_VER>::PrepareFrame()
 {
   MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
@@ -203,19 +202,18 @@ FFmpegDataDecoder<LIBAV_VER>::PrepareFra
   }
 #elif LIBAVCODEC_VERSION_MAJOR == 54
   if (mFrame) {
     mLib->avcodec_get_frame_defaults(mFrame);
   } else {
     mFrame = mLib->avcodec_alloc_frame();
   }
 #else
-  delete mFrame;
-  mFrame = new AVFrame;
-  mLib->avcodec_get_frame_defaults(mFrame);
+  mLib->av_freep(&mFrame);
+  mFrame = mLib->avcodec_alloc_frame();
 #endif
   return mFrame;
 }
 
 /* static */ AVCodec*
 FFmpegDataDecoder<LIBAV_VER>::FindAVCodec(FFmpegLibWrapper* aLib,
                                           AVCodecID aCodec)
 {
--- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp
@@ -104,22 +104,22 @@ FFmpegLibWrapper::Link()
   AV_FUNC(avcodec_find_decoder, AV_FUNC_AVCODEC_ALL)
   AV_FUNC(avcodec_flush_buffers, AV_FUNC_AVCODEC_ALL)
   AV_FUNC(avcodec_open2, AV_FUNC_AVCODEC_ALL)
   AV_FUNC(avcodec_register_all, AV_FUNC_AVCODEC_ALL)
   AV_FUNC(av_init_packet, AV_FUNC_AVCODEC_ALL)
   AV_FUNC(av_parser_init, AV_FUNC_AVCODEC_ALL)
   AV_FUNC(av_parser_close, AV_FUNC_AVCODEC_ALL)
   AV_FUNC(av_parser_parse2, AV_FUNC_AVCODEC_ALL)
+  AV_FUNC(avcodec_alloc_frame, (AV_FUNC_53 | AV_FUNC_54))
   AV_FUNC(avcodec_get_frame_defaults, (AV_FUNC_53 | AV_FUNC_54))
+  AV_FUNC(avcodec_free_frame, AV_FUNC_54)
   AV_FUNC(av_log_set_level, AV_FUNC_AVUTIL_ALL)
   AV_FUNC(av_malloc, AV_FUNC_AVUTIL_ALL)
   AV_FUNC(av_freep, AV_FUNC_AVUTIL_ALL)
-  AV_FUNC(avcodec_alloc_frame, AV_FUNC_AVUTIL_54)
-  AV_FUNC(avcodec_free_frame, AV_FUNC_AVUTIL_54)
   AV_FUNC(av_frame_alloc, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57))
   AV_FUNC(av_frame_free, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57))
   AV_FUNC(av_frame_unref, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57))
 #undef AV_FUNC
 
   avcodec_register_all();
 #ifdef DEBUG
   av_log_set_level(AV_LOG_DEBUG);
--- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h
+++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h
@@ -47,27 +47,26 @@ struct FFmpegLibWrapper
   int (*avcodec_open2)(AVCodecContext *avctx, const AVCodec* codec, AVDictionary** options);
   void (*avcodec_register_all)();
   void (*av_init_packet)(AVPacket* pkt);
   AVCodecParserContext* (*av_parser_init)(int codec_id);
   void (*av_parser_close)(AVCodecParserContext* s);
   int (*av_parser_parse2)(AVCodecParserContext* s, AVCodecContext* avctx, uint8_t** poutbuf, int* poutbuf_size, const uint8_t* buf, int buf_size, int64_t pts, int64_t dts, int64_t pos);
 
   // only used in libavcodec <= 54
+  AVFrame* (*avcodec_alloc_frame)();
   void (*avcodec_get_frame_defaults)(AVFrame* pic);
+  // libavcodec v54 only
+  void (*avcodec_free_frame)(AVFrame** frame);
 
   // libavutil
   void (*av_log_set_level)(int level);
   void*	(*av_malloc)(size_t size);
   void (*av_freep)(void *ptr);
 
-  // libavutil v54 only
-  AVFrame* (*avcodec_alloc_frame)();
-  void (*avcodec_free_frame)(AVFrame** frame);
-
   // libavutil v55 and later only
   AVFrame* (*av_frame_alloc)();
   void (*av_frame_free)(AVFrame** frame);
   void (*av_frame_unref)(AVFrame* frame);
 
   PRLibrary* mAVCodecLib;
   PRLibrary* mAVUtilLib;
 
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -2,17 +2,16 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/TaskQueue.h"
 
 #include "nsThreadUtils.h"
-#include "nsAutoPtr.h"
 #include "ImageContainer.h"
 
 #include "MediaInfo.h"
 
 #include "FFmpegVideoDecoder.h"
 #include "FFmpegLog.h"
 #include "mozilla/PodOperations.h"
 
--- a/dom/media/platforms/omx/GonkOmxPlatformLayer.h
+++ b/dom/media/platforms/omx/GonkOmxPlatformLayer.h
@@ -8,16 +8,17 @@
 #define GonkOmxPlatformLayer_h_
 
 #pragma GCC visibility push(default)
 
 #include <bitset>
 
 #include <utils/RefBase.h>
 #include <media/stagefright/OMXClient.h>
+#include "nsAutoPtr.h"
 
 #include "OMX_Component.h"
 
 #include "OmxPlatformLayer.h"
 
 class nsACString;
 
 namespace android {
--- a/dom/media/platforms/omx/OmxPromiseLayer.h
+++ b/dom/media/platforms/omx/OmxPromiseLayer.h
@@ -4,16 +4,17 @@
  * 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/. */
 
 #if !defined(OmxPromiseLayer_h_)
 #define OmxPromiseLayer_h_
 
 #include "mozilla/MozPromise.h"
 #include "mozilla/TaskQueue.h"
+#include "nsAutoPtr.h"
 
 #include "OMX_Core.h"
 #include "OMX_Types.h"
 
 namespace mozilla {
 
 namespace layers
 {
--- a/dom/media/platforms/wmf/WMFDecoderModule.cpp
+++ b/dom/media/platforms/wmf/WMFDecoderModule.cpp
@@ -7,16 +7,17 @@
 #include "WMF.h"
 #include "WMFDecoderModule.h"
 #include "WMFVideoMFTManager.h"
 #include "WMFAudioMFTManager.h"
 #include "MFTDecoder.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Services.h"
 #include "WMFMediaDataDecoder.h"
+#include "nsAutoPtr.h"
 #include "nsIWindowsRegKey.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIGfxInfo.h"
 #include "nsWindowsHelpers.h"
 #include "GfxDriverInfo.h"
 #include "gfxWindowsPlatform.h"
 #include "MediaInfo.h"
--- a/dom/media/platforms/wmf/WMFMediaDataDecoder.h
+++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.h
@@ -6,16 +6,17 @@
 
 #if !defined(WMFMediaDataDecoder_h_)
 #define WMFMediaDataDecoder_h_
 
 
 #include "WMF.h"
 #include "MFTDecoder.h"
 #include "mozilla/RefPtr.h"
+#include "nsAutoPtr.h"
 #include "PlatformDecoderModule.h"
 
 namespace mozilla {
 
 // Encapsulates the initialization of the MFTDecoder appropriate for decoding
 // a given stream, and the process of converting the IMFSample produced
 // by the MFT into a MediaData object.
 class MFTManager {
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.h
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h
@@ -4,16 +4,17 @@
  * 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/. */
 
 #if !defined(WMFVideoMFTManager_h_)
 #define WMFVideoMFTManager_h_
 
 #include "WMF.h"
 #include "MFTDecoder.h"
+#include "nsAutoPtr.h"
 #include "nsRect.h"
 #include "WMFMediaDataDecoder.h"
 #include "mozilla/RefPtr.h"
 
 namespace mozilla {
 
 class DXVA2Manager;
 
--- a/dom/media/systemservices/LoadManager.cpp
+++ b/dom/media/systemservices/LoadManager.cpp
@@ -13,17 +13,17 @@
 
 #include "nsString.h"
 #include "nsThreadUtils.h"
 #include "nsReadableUtils.h"
 #include "nsIObserverService.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/ArrayUtils.h"
 
-// NSPR_LOG_MODULES=LoadManager:5
+// MOZ_LOG=LoadManager:5
 mozilla::LazyLogModule gLoadManagerLog("LoadManager");
 #undef LOG
 #undef LOG_ENABLED
 #define LOG(args) MOZ_LOG(gLoadManagerLog, mozilla::LogLevel::Debug, args)
 #define LOG_ENABLED() MOZ_LOG_TEST(gLoadManagerLog, mozilla::LogLevel::Verbose)
 
 namespace mozilla {
 
--- a/dom/media/systemservices/LoadMonitor.cpp
+++ b/dom/media/systemservices/LoadMonitor.cpp
@@ -50,17 +50,17 @@
 #endif
 
 #ifdef XP_WIN
 #include <pdh.h>
 #include <tchar.h>
 #pragma comment(lib, "pdh.lib")
 #endif
 
-// NSPR_LOG_MODULES=LoadManager:5
+// MOZ_LOG=LoadManager:5
 #undef LOG
 #undef LOG_ENABLED
 #define LOG(args) MOZ_LOG(gLoadManagerLog, mozilla::LogLevel::Debug, args)
 #define LOG_ENABLED() MOZ_LOG_TEST(gLoadManagerLog, mozilla::LogLevel::Debug)
 #define LOG_MANY_ENABLED() MOZ_LOG_TEST(gLoadManagerLog, mozilla::LogLevel::Verbose)
 
 namespace mozilla {
 
--- a/dom/media/systemservices/LoadMonitor.h
+++ b/dom/media/systemservices/LoadMonitor.h
@@ -5,17 +5,16 @@
 
 #ifndef _LOADMONITOR_H_
 #define _LOADMONITOR_H_
 
 #include "mozilla/Mutex.h"
 #include "mozilla/CondVar.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/Atomics.h"
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsIThread.h"
 #include "nsIObserver.h"
 
 namespace mozilla {
 class LoadInfoCollectRunner;
 
 class LoadNotificationCallback
--- a/dom/media/systemservices/MediaParent.cpp
+++ b/dom/media/systemservices/MediaParent.cpp
@@ -7,16 +7,17 @@
 #include "MediaParent.h"
 
 #include "mozilla/Base64.h"
 #include <mozilla/StaticMutex.h>
 
 #include "MediaUtils.h"
 #include "MediaEngine.h"
 #include "VideoUtils.h"
+#include "nsAutoPtr.h"
 #include "nsThreadUtils.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 #include "nsIInputStream.h"
 #include "nsILineInputStream.h"
 #include "nsIOutputStream.h"
 #include "nsISafeOutputStream.h"
 #include "nsAppDirectoryServiceDefs.h"
--- a/dom/media/systemservices/MediaSystemResourceManager.h
+++ b/dom/media/systemservices/MediaSystemResourceManager.h
@@ -7,17 +7,16 @@
 #if !defined(MediaSystemResourceManager_h_)
 #define MediaSystemResourceManager_h_
 
 #include <queue>
 
 #include "MediaSystemResourceTypes.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "mozilla/StaticPtr.h"
-#include "nsAutoPtr.h"
 #include "nsDataHashtable.h"
 #include "nsISupportsImpl.h"
 
 namespace mozilla {
 
 namespace media {
 class MediaSystemResourceManagerChild;
 } // namespace media
--- a/dom/media/systemservices/MediaUtils.h
+++ b/dom/media/systemservices/MediaUtils.h
@@ -2,17 +2,16 @@
 /* vim: set sw=2 ts=8 et ft=cpp : */
 /* 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 mozilla_MediaUtils_h
 #define mozilla_MediaUtils_h
 
-#include "nsAutoPtr.h"
 #include "nsThreadUtils.h"
 #include "nsIAsyncShutdown.h"
 #include "mozilla/UniquePtr.h"
 #include "base/task.h"
 
 namespace mozilla {
 namespace media {
 
--- a/dom/media/systemservices/OpenSLESProvider.cpp
+++ b/dom/media/systemservices/OpenSLESProvider.cpp
@@ -6,17 +6,17 @@
 #include "OpenSLESProvider.h"
 #include "mozilla/Logging.h"
 #include "nsDebug.h"
 
 #include <dlfcn.h>
 #include <SLES/OpenSLES_Android.h>
 #include <SLES/OpenSLES_AndroidConfiguration.h>
 
-// NSPR_LOG_MODULES=OpenSLESProvider:5
+// MOZ_LOG=OpenSLESProvider:5
 #undef LOG
 #undef LOG_ENABLED
 mozilla::LazyLogModule gOpenSLESProviderLog("OpenSLESProvider");
 #define LOG(args) MOZ_LOG(gOpenSLESProviderLog, mozilla::LogLevel::Debug, args)
 #define LOG_ENABLED() MOZ_LOG_TEST(gOpenSLESProviderLog, mozilla::LogLevel::Debug)
 
 namespace mozilla {
 
--- a/dom/media/wave/WaveDemuxer.cpp
+++ b/dom/media/wave/WaveDemuxer.cpp
@@ -6,16 +6,17 @@
 
 #include "WaveDemuxer.h"
 
 #include <inttypes.h>
 #include <algorithm>
 
 #include "mozilla/Assertions.h"
 #include "mozilla/EndianUtils.h"
+#include "nsAutoPtr.h"
 #include "VideoUtils.h"
 #include "TimeUnits.h"
 #include "prenv.h"
 
 using mozilla::media::TimeUnit;
 using mozilla::media::TimeIntervals;
 using mp4_demuxer::ByteReader;
 
--- a/dom/media/wave/WaveReader.h
+++ b/dom/media/wave/WaveReader.h
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #if !defined(WaveReader_h_)
 #define WaveReader_h_
 
 #include "MediaDecoderReader.h"
 #include "MediaResource.h"
 
 #include "mozilla/dom/HTMLMediaElement.h"
+#include "nsAutoPtr.h"
 
 namespace mozilla {
 
 class WaveReader : public MediaDecoderReader
 {
 public:
   explicit WaveReader(AbstractMediaDecoder* aDecoder);
 
--- a/dom/media/webaudio/AudioBuffer.h
+++ b/dom/media/webaudio/AudioBuffer.h
@@ -7,17 +7,16 @@
 #ifndef AudioBuffer_h_
 #define AudioBuffer_h_
 
 #include "nsWrapperCache.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/StaticMutex.h"
-#include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "AudioContext.h"
 #include "js/TypeDecls.h"
 #include "mozilla/MemoryReporting.h"
 
 namespace mozilla {
 
 class ErrorResult;
--- a/dom/media/webaudio/AudioContext.h
+++ b/dom/media/webaudio/AudioContext.h
@@ -8,17 +8,16 @@
 #define AudioContext_h_
 
 #include "mozilla/dom/AudioChannelBinding.h"
 #include "MediaBufferDecoder.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/TypedArray.h"
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsHashKeys.h"
 #include "nsTHashtable.h"
 #include "js/TypeDecls.h"
 #include "nsIMemoryReporter.h"
 
 // X11 has a #define for CurrentTime. Unbelievable :-(.
--- a/dom/media/webaudio/AudioListener.h
+++ b/dom/media/webaudio/AudioListener.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef AudioListener_h_
 #define AudioListener_h_
 
 #include "nsWrapperCache.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Attributes.h"
-#include "nsAutoPtr.h"
 #include "ThreeDPoint.h"
 #include "AudioContext.h"
 #include "PannerNode.h"
 #include "WebAudioUtils.h"
 #include "js/TypeDecls.h"
 #include "mozilla/MemoryReporting.h"
 
 namespace mozilla {
--- a/dom/media/webaudio/AudioNode.h
+++ b/dom/media/webaudio/AudioNode.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef AudioNode_h_
 #define AudioNode_h_
 
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/dom/AudioNodeBinding.h"
 #include "nsCycleCollectionParticipant.h"
-#include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "AudioContext.h"
 #include "MediaStreamGraph.h"
 #include "WebAudioUtils.h"
 #include "mozilla/MemoryReporting.h"
 #include "nsWeakReference.h"
 #include "SelfRef.h"
 
--- a/dom/media/webaudio/AudioNodeStream.h
+++ b/dom/media/webaudio/AudioNodeStream.h
@@ -3,16 +3,17 @@
  * 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 MOZILLA_AUDIONODESTREAM_H_
 #define MOZILLA_AUDIONODESTREAM_H_
 
 #include "MediaStreamGraph.h"
 #include "mozilla/dom/AudioNodeBinding.h"
+#include "nsAutoPtr.h"
 #include "AlignedTArray.h"
 #include "AudioBlock.h"
 #include "AudioSegment.h"
 
 namespace mozilla {
 
 namespace dom {
 struct ThreeDPoint;
--- a/dom/media/webaudio/AudioParam.h
+++ b/dom/media/webaudio/AudioParam.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef AudioParam_h_
 #define AudioParam_h_
 
 #include "AudioParamTimeline.h"
 #include "nsWrapperCache.h"
 #include "nsCycleCollectionParticipant.h"
-#include "nsAutoPtr.h"
 #include "AudioNode.h"
 #include "mozilla/dom/TypedArray.h"
 #include "WebAudioUtils.h"
 #include "js/TypeDecls.h"
 
 namespace mozilla {
 
 namespace dom {
--- a/dom/media/webaudio/AudioParamTimeline.h
+++ b/dom/media/webaudio/AudioParamTimeline.h
@@ -4,17 +4,16 @@
  * 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 AudioParamTimeline_h_
 #define AudioParamTimeline_h_
 
 #include "AudioEventTimeline.h"
 #include "mozilla/ErrorResult.h"
-#include "nsAutoPtr.h"
 #include "MediaStreamGraph.h"
 #include "AudioSegment.h"
 
 namespace mozilla {
 
 namespace dom {
 
 // This helper class is used to represent the part of the AudioParam
--- a/dom/media/webaudio/ConvolverNode.cpp
+++ b/dom/media/webaudio/ConvolverNode.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ConvolverNode.h"
 #include "mozilla/dom/ConvolverNodeBinding.h"
+#include "nsAutoPtr.h"
 #include "AlignmentUtils.h"
 #include "AudioNodeEngine.h"
 #include "AudioNodeStream.h"
 #include "blink/Reverb.h"
 #include "PlayingRefChangeHandler.h"
 
 namespace mozilla {
 namespace dom {
--- a/dom/media/webaudio/DynamicsCompressorNode.cpp
+++ b/dom/media/webaudio/DynamicsCompressorNode.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DynamicsCompressorNode.h"
 #include "mozilla/dom/DynamicsCompressorNodeBinding.h"
+#include "nsAutoPtr.h"
 #include "AudioNodeEngine.h"
 #include "AudioNodeStream.h"
 #include "AudioDestinationNode.h"
 #include "WebAudioUtils.h"
 #include "blink/DynamicsCompressor.h"
 
 using WebCore::DynamicsCompressor;
 
--- a/dom/media/webaudio/IIRFilterNode.cpp
+++ b/dom/media/webaudio/IIRFilterNode.cpp
@@ -4,16 +4,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "IIRFilterNode.h"
 #include "AudioNodeEngine.h"
 
 #include "blink/IIRFilter.h"
 
+#include "nsGkAtoms.h"
+
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_ISUPPORTS_INHERITED0(IIRFilterNode, AudioNode)
 
 class IIRFilterNodeEngine final : public AudioNodeEngine
 {
 public:
--- a/dom/media/webaudio/MediaBufferDecoder.cpp
+++ b/dom/media/webaudio/MediaBufferDecoder.cpp
@@ -11,17 +11,16 @@
 #include <speex/speex_resampler.h>
 #include "nsXPCOMCIDInternal.h"
 #include "nsComponentManagerUtils.h"
 #include "MediaDecoderReader.h"
 #include "BufferMediaResource.h"
 #include "DecoderTraits.h"
 #include "AudioContext.h"
 #include "AudioBuffer.h"
-#include "nsAutoPtr.h"
 #include "nsContentUtils.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIScriptError.h"
 #include "nsMimeTypes.h"
 #include "VideoUtils.h"
 #include "WebAudioUtils.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/Telemetry.h"
--- a/dom/media/webaudio/PannerNode.cpp
+++ b/dom/media/webaudio/PannerNode.cpp
@@ -8,16 +8,17 @@
 #include "AudioNodeEngine.h"
 #include "AudioNodeStream.h"
 #include "AudioListener.h"
 #include "PanningUtils.h"
 #include "AudioBufferSourceNode.h"
 #include "PlayingRefChangeHandler.h"
 #include "blink/HRTFPanner.h"
 #include "blink/HRTFDatabaseLoader.h"
+#include "nsAutoPtr.h"
 
 using WebCore::HRTFDatabaseLoader;
 using WebCore::HRTFPanner;
 
 namespace mozilla {
 namespace dom {
 
 using namespace std;
--- a/dom/media/webaudio/ScriptProcessorNode.cpp
+++ b/dom/media/webaudio/ScriptProcessorNode.cpp
@@ -10,16 +10,17 @@
 #include "AudioDestinationNode.h"
 #include "AudioNodeEngine.h"
 #include "AudioNodeStream.h"
 #include "AudioProcessingEvent.h"
 #include "WebAudioUtils.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/PodOperations.h"
+#include "nsAutoPtr.h"
 #include <deque>
 
 namespace mozilla {
 namespace dom {
 
 // The maximum latency, in seconds, that we can live with before dropping
 // buffers.
 static const float MAX_LATENCY_S = 0.5;
--- a/dom/media/webaudio/ScriptProcessorNode.h
+++ b/dom/media/webaudio/ScriptProcessorNode.h
@@ -3,17 +3,16 @@
 /* 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 ScriptProcessorNode_h_
 #define ScriptProcessorNode_h_
 
 #include "AudioNode.h"
-#include "nsAutoPtr.h"
 
 namespace mozilla {
 namespace dom {
 
 class AudioContext;
 class SharedBuffers;
 
 class ScriptProcessorNode final : public AudioNode
--- a/dom/media/webaudio/blink/Biquad.cpp
+++ b/dom/media/webaudio/blink/Biquad.cpp
@@ -105,32 +105,29 @@ void Biquad::setLowpassParams(double cut
 
     if (cutoff == 1) {
         // When cutoff is 1, the z-transform is 1.
         setNormalizedCoefficients(1, 0, 0,
                                   1, 0, 0);
     } else if (cutoff > 0) {
         // Compute biquad coefficients for lowpass filter
         resonance = std::max(0.0, resonance); // can't go negative
-        double g = pow(10.0, 0.05 * resonance);
-        double d = sqrt((4 - sqrt(16 - 16 / (g * g))) / 2);
+        double g = pow(10.0, -0.05 * resonance);
+        double w0 = M_PI * cutoff;
+        double cos_w0 = cos(w0);
+        double alpha = 0.5 * sin(w0) * g;
 
-        double theta = M_PI * cutoff;
-        double sn = 0.5 * d * sin(theta);
-        double beta = 0.5 * (1 - sn) / (1 + sn);
-        double gamma = (0.5 + beta) * cos(theta);
-        double alpha = 0.25 * (0.5 + beta - gamma);
+        double b1 = 1.0 - cos_w0;
+        double b0 = 0.5 * b1;
+        double b2 = b0;
+        double a0 = 1.0 + alpha;
+        double a1 = -2.0 * cos_w0;
+        double a2 = 1.0 - alpha;
 
-        double b0 = 2 * alpha;
-        double b1 = 2 * 2 * alpha;
-        double b2 = 2 * alpha;
-        double a1 = 2 * -gamma;
-        double a2 = 2 * beta;
-
-        setNormalizedCoefficients(b0, b1, b2, 1, a1, a2);
+        setNormalizedCoefficients(b0, b1, b2, a0, a1, a2);
     } else {
         // When cutoff is zero, nothing gets through the filter, so set
         // coefficients up correctly.
         setNormalizedCoefficients(0, 0, 0,
                                   1, 0, 0);
     }
 }
 
@@ -141,32 +138,29 @@ void Biquad::setHighpassParams(double cu
 
     if (cutoff == 1) {
         // The z-transform is 0.
         setNormalizedCoefficients(0, 0, 0,
                                   1, 0, 0);
     } else if (cutoff > 0) {
         // Compute biquad coefficients for highpass filter
         resonance = std::max(0.0, resonance); // can't go negative
-        double g = pow(10.0, 0.05 * resonance);
-        double d = sqrt((4 - sqrt(16 - 16 / (g * g))) / 2);
+        double g = pow(10.0, -0.05 * resonance);
+        double w0 = M_PI * cutoff;
+        double cos_w0 = cos(w0);
+        double alpha = 0.5 * sin(w0) * g;
 
-        double theta = M_PI * cutoff;
-        double sn = 0.5 * d * sin(theta);
-        double beta = 0.5 * (1 - sn) / (1 + sn);
-        double gamma = (0.5 + beta) * cos(theta);
-        double alpha = 0.25 * (0.5 + beta + gamma);
+        double b1 = -1.0 - cos_w0;
+        double b0 = -0.5 * b1;
+        double b2 = b0;
+        double a0 = 1.0 + alpha;
+        double a1 = -2.0 * cos_w0;
+        double a2 = 1.0 - alpha;
 
-        double b0 = 2 * alpha;
-        double b1 = 2 * -2 * alpha;
-        double b2 = 2 * alpha;
-        double a1 = 2 * -gamma;
-        double a2 = 2 * beta;
-
-        setNormalizedCoefficients(b0, b1, b2, 1, a1, a2);
+        setNormalizedCoefficients(b0, b1, b2, a0, a1, a2);
     } else {
       // When cutoff is zero, we need to be careful because the above
       // gives a quadratic divided by the same quadratic, with poles
       // and zeros on the unit circle in the same place. When cutoff
       // is zero, the z-transform is 1.
         setNormalizedCoefficients(1, 0, 0,
                                   1, 0, 0);
     }
--- a/dom/media/webaudio/blink/DynamicsCompressorKernel.h
+++ b/dom/media/webaudio/blink/DynamicsCompressorKernel.h
@@ -25,17 +25,16 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifndef DynamicsCompressorKernel_h
 #define DynamicsCompressorKernel_h
 
 #include "nsTArray.h"
-#include "nsAutoPtr.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/UniquePtr.h"
 
 namespace WebCore {
 
 class DynamicsCompressorKernel {
 public:
     DynamicsCompressorKernel(float sampleRate, unsigned numberOfChannels);
--- a/dom/media/webaudio/blink/ReverbConvolverStage.h
+++ b/dom/media/webaudio/blink/ReverbConvolverStage.h
@@ -26,16 +26,17 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifndef ReverbConvolverStage_h
 #define ReverbConvolverStage_h
 
 #include "FFTConvolver.h"
 
+#include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "mozilla/FFTBlock.h"
 #include "mozilla/MemoryReporting.h"
 
 namespace WebCore {
 
 using mozilla::FFTBlock;
 
--- a/dom/media/webaudio/test/blink/biquad-filters.js
+++ b/dom/media/webaudio/test/blink/biquad-filters.js
@@ -7,86 +7,84 @@
 // http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt.
 
 
 // Lowpass filter.
 function createLowpassFilter(freq, q, gain) {
     var b0;
     var b1;
     var b2;
+    var a0;
     var a1;
     var a2;
 
     if (freq == 1) {
         // The formula below works, except for roundoff.  When freq = 1,
         // the filter is just a wire, so hardwire the coefficients.
         b0 = 1;
         b1 = 0;
         b2 = 0;
+        a0 = 1;
         a1 = 0;
         a2 = 0;
     } else {
-        var g = Math.pow(10, q / 20);
-        var d = Math.sqrt((4 - Math.sqrt(16 - 16 / (g * g))) / 2);
-        var theta = Math.PI * freq;
-        var sn = d * Math.sin(theta) / 2;
-        var beta = 0.5 * (1 - sn) / (1 + sn);
-        var gamma = (0.5 + beta) * Math.cos(theta);
-        var alpha = 0.25 * (0.5 + beta - gamma);
+        var w0 = Math.PI * freq;
+        var alpha = 0.5 * Math.sin(w0) / Math.pow(10, q / 20);
+        var cos_w0 = Math.cos(w0);
 
-        b0 = 2 * alpha;
-        b1 = 4 * alpha;
-        b2 = 2 * alpha;
-        a1 = 2 * (-gamma);
-        a2 = 2 * beta;
+        b0 = 0.5 * (1 - cos_w0);
+        b1 = 1 - cos_w0;
+        b2 = b0;
+        a0 = 1 + alpha;
+        a1 = -2.0 * cos_w0;
+        a2 = 1 - alpha;
     }
 
-    return {b0 : b0, b1 : b1, b2 : b2, a1 : a1, a2 : a2};
+    return normalizeFilterCoefficients(b0, b1, b2, a0, a1, a2);
 }
 
 function createHighpassFilter(freq, q, gain) {
     var b0;
     var b1;
     var b2;
     var a1;
     var a2;
 
     if (freq == 1) {
         // The filter is 0
         b0 = 0;
         b1 = 0;
         b2 = 0;
+        a0 = 1;
         a1 = 0;
         a2 = 0;
     } else if (freq == 0) {
         // The filter is 1.  Computation of coefficients below is ok, but
         // there's a pole at 1 and a zero at 1, so round-off could make
         // the filter unstable.
         b0 = 1;
         b1 = 0;
         b2 = 0;
+        a0 = 1;
         a1 = 0;
         a2 = 0;
     } else {
-        var g = Math.pow(10, q / 20);
-        var d = Math.sqrt((4 - Math.sqrt(16 - 16 / (g * g))) / 2);
-        var theta = Math.PI * freq;
-        var sn = d * Math.sin(theta) / 2;
-        var beta = 0.5 * (1 - sn) / (1 + sn);
-        var gamma = (0.5 + beta) * Math.cos(theta);
-        var alpha = 0.25 * (0.5 + beta + gamma);
+        var w0 = Math.PI * freq;
+        var alpha = 0.5 * Math.sin(w0) / Math.pow(10, q / 20);
+        var cos_w0 = Math.cos(w0);
 
-        b0 = 2 * alpha;
-        b1 = -4 * alpha;
-        b2 = 2 * alpha;
-        a1 = 2 * (-gamma);
-        a2 = 2 * beta;
+        b0 = 0.5 * (1 + cos_w0);
+        b1 = -1 - cos_w0;
+        b2 = b0;
+        a0 = 1 + alpha;
+        a1 = -2.0 * cos_w0;
+        a2 = 1 - alpha;
     }
 
-    return {b0 : b0, b1 : b1, b2 : b2, a1 : a1, a2 : a2};
+    return normalizeFilterCoefficients(b0, b1, b2, a0, a1, a2);
 }
 
 function normalizeFilterCoefficients(b0, b1, b2, a0, a1, a2) {
     var scale = 1 / a0;
 
     return {b0 : b0 * scale,
             b1 : b1 * scale,
             b2 : b2 * scale,
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/blink/biquad-testing.js
@@ -0,0 +1,153 @@
+// Globals, to make testing and debugging easier.
+var context;
+var filter;
+var signal;
+var renderedBuffer;
+var renderedData;
+
+var sampleRate = 44100.0;
+var pulseLengthFrames = .1 * sampleRate;
+
+// Maximum allowed error for the test to succeed.  Experimentally determined.
+var maxAllowedError = 5.9e-8;
+
+// This must be large enough so that the filtered result is
+// essentially zero.  See comments for createTestAndRun.
+var timeStep = .1;
+
+// Maximum number of filters we can process (mostly for setting the
+// render length correctly.)
+var maxFilters = 5;
+
+// How long to render.  Must be long enough for all of the filters we
+// want to test.
+var renderLengthSeconds = timeStep * (maxFilters + 1) ;
+
+var renderLengthSamples = Math.round(renderLengthSeconds * sampleRate);
+
+// Number of filters that will be processed.
+var nFilters;
+
+function createImpulseBuffer(context, length) {
+    var impulse = context.createBuffer(1, length, context.sampleRate);
+    var data = impulse.getChannelData(0);
+    for (var k = 1; k < data.length; ++k) {
+        data[k] = 0;
+    }
+    data[0] = 1;
+
+    return impulse;
+}
+
+
+function createTestAndRun(context, filterType, filterParameters) {
+    // To test the filters, we apply a signal (an impulse) to each of
+    // the specified filters, with each signal starting at a different
+    // time.  The output of the filters is summed together at the
+    // output.  Thus for filter k, the signal input to the filter
+    // starts at time k * timeStep.  For this to work well, timeStep
+    // must be large enough for the output of each filter to have
+    // decayed to zero with timeStep seconds.  That way the filter
+    // outputs don't interfere with each other.
+
+    nFilters = Math.min(filterParameters.length, maxFilters);
+
+    signal = new Array(nFilters);
+    filter = new Array(nFilters);
+
+    impulse = createImpulseBuffer(context, pulseLengthFrames);
+
+    // Create all of the signal sources and filters that we need.
+    for (var k = 0; k < nFilters; ++k) {
+        signal[k] = context.createBufferSource();
+        signal[k].buffer = impulse;
+
+        filter[k] = context.createBiquadFilter();
+        filter[k].type = filterType;
+        filter[k].frequency.value = context.sampleRate / 2 * filterParameters[k].cutoff;
+        filter[k].detune.value = (filterParameters[k].detune === undefined) ? 0 : filterParameters[k].detune;
+        filter[k].Q.value = filterParameters[k].q;
+        filter[k].gain.value = filterParameters[k].gain;
+
+        signal[k].connect(filter[k]);
+        filter[k].connect(context.destination);
+
+        signal[k].start(timeStep * k);
+    }
+
+    context.oncomplete = checkFilterResponse(filterType, filterParameters);
+    context.startRendering();
+}
+
+function addSignal(dest, src, destOffset) {
+    // Add src to dest at the given dest offset.
+    for (var k = destOffset, j = 0; k < dest.length, j < src.length; ++k, ++j) {
+        dest[k] += src[j];
+    }
+}
+
+function generateReference(filterType, filterParameters) {
+    var result = new Array(renderLengthSamples);
+    var data = new Array(renderLengthSamples);
+    // Initialize the result array and data.
+    for (var k = 0; k < result.length; ++k) {
+        result[k] = 0;
+        data[k] = 0;
+    }
+    // Make data an impulse.
+    data[0] = 1;
+
+    for (var k = 0; k < nFilters; ++k) {
+        // Filter an impulse
+        var detune = (filterParameters[k].detune === undefined) ? 0 : filterParameters[k].detune;
+        var frequency = filterParameters[k].cutoff * Math.pow(2, detune / 1200); // Apply detune, converting from Cents.
+
+        var filterCoef = createFilter(filterType,
+                                      frequency,
+                                      filterParameters[k].q,
+                                      filterParameters[k].gain);
+        var y = filterData(filterCoef, data, renderLengthSamples);
+
+        // Accumulate this filtered data into the final output at the desired offset.
+        addSignal(result, y, timeToSampleFrame(timeStep * k, sampleRate));
+    }
+
+    return result;
+}
+
+function checkFilterResponse(filterType, filterParameters) {
+    return function(event) {
+        renderedBuffer = event.renderedBuffer;
+        renderedData = renderedBuffer.getChannelData(0);
+
+        reference = generateReference(filterType, filterParameters);
+
+        var len = Math.min(renderedData.length, reference.length);
+
+        var success = true;
+
+        // Maximum error between rendered data and expected data
+        var maxError = 0;
+
+        // Sample offset where the maximum error occurred.
+        var maxPosition = 0;
+
+        // Number of infinities or NaNs that occurred in the rendered data.
+        var invalidNumberCount = 0;
+
+        ok(nFilters == filterParameters.length, "Test wanted " + filterParameters.length + " filters but only " + maxFilters + " allowed.");
+
+        compareChannels(renderedData, reference, len, 0, 0, true);
+
+        // Check for bad numbers in the rendered output too.
+        // There shouldn't be any.
+        for (var k = 0; k < len; ++k) {
+            if (!isValidNumber(renderedData[k])) {
+                ++invalidNumberCount;
+            }
+        }
+
+        ok(invalidNumberCount == 0, "Rendered output has " + invalidNumberCount + " infinities or NaNs.");
+        SimpleTest.finish();
+    }
+}
--- a/dom/media/webaudio/test/blink/mochitest.ini
+++ b/dom/media/webaudio/test/blink/mochitest.ini
@@ -1,11 +1,24 @@
 [DEFAULT]
 tags=msg
 tags = webaudio
 subsuite = media
 skip-if = ((buildapp == 'b2g') && (toolkit != 'gonk' || debug)) #b2g-debug,b2g-desktop(bug 916135)
 support-files =
   biquad-filters.js
+  biquad-testing.js
   ../webaudio.js
 
+[test_biquadFilterNodeAllPass.html]
+[test_biquadFilterNodeAutomation.html]
+skip-if = true # Known problems with Biquad automation, e.g. Bug 1155709
+[test_biquadFilterNodeBandPass.html]
+[test_biquadFilterNodeGetFrequencyResponse.html]
+[test_biquadFilterNodeHighPass.html]
+[test_biquadFilterNodeHighShelf.html]
+[test_biquadFilterNodeLowPass.html]
+[test_biquadFilterNodeLowShelf.html]
+[test_biquadFilterNodeNotch.html]
+[test_biquadFilterNodePeaking.html]
+[test_biquadFilterNodeTail.html]
 [test_iirFilterNode.html]
 [test_iirFilterNodeGetFrequencyResponse.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/blink/test_biquadFilterNodeAllPass.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test BiquadFilterNode All Pass Filter</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 src="audio-testing.js"></script>
+<script src="biquad-filters.js"></script>
+<script src="biquad-testing.js"></script>
+<script src="webaudio.js" type="text/javascript"></script>
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+    // Create offline audio context.
+    var context = new OfflineAudioContext(2, sampleRate * renderLengthSeconds, sampleRate);
+
+    var filterParameters = [{cutoff : 0,    q : 10, gain : 1 },
+                            {cutoff : 1,    q : 10, gain : 1 },
+                            {cutoff : .5,   q :  0, gain : 1 },
+                            {cutoff : 0.25, q : 10, gain : 1 },
+                           ];
+    createTestAndRun(context, "allpass", filterParameters);
+});
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/blink/test_biquadFilterNodeAutomation.html
@@ -0,0 +1,351 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test BiquadFilterNode All Pass Filter</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 src="audio-testing.js"></script>
+<script src="biquad-filters.js"></script>
+<script src="biquad-testing.js"></script>
+<script src="webaudio.js" type="text/javascript"></script>
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+  // Don't need to run these tests at high sampling rate, so just use a low one to reduce memory
+  // usage and complexity.
+  var sampleRate = 16000;
+
+  // How long to render for each test.
+  var renderDuration = 1;
+
+  // The definition of the linear ramp automation function.
+  function linearRamp(t, v0, v1, t0, t1) {
+    return v0 + (v1 - v0) * (t - t0) / (t1 - t0);
+  }
+
+  // Generate the filter coefficients for the specified filter using the given parameters for
+  // the given duration.  |filterTypeFunction| is a function that returns the filter
+  // coefficients for one set of parameters.  |parameters| is a property bag that contains the
+  // start and end values (as an array) for each of the biquad attributes.  The properties are
+  // |freq|, |Q|, |gain|, and |detune|.  |duration| is the number of seconds for which the
+  // coefficients are generated.
+  //
+  // A property bag with properties |b0|, |b1|, |b2|, |a1|, |a2|.  Each propery is an array
+  // consisting of the coefficients for the time-varying biquad filter.
+  function generateFilterCoefficients(filterTypeFunction, parameters, duration) {
+     var endFrame = Math.ceil(duration * sampleRate);
+     var nCoef = endFrame;
+     var b0 = new Float64Array(nCoef);
+     var b1 = new Float64Array(nCoef);
+     var b2 = new Float64Array(nCoef);
+     var a1 = new Float64Array(nCoef);
+     var a2 = new Float64Array(nCoef);
+
+     var k = 0;
+     // If the property is not given, use the defaults.
+     var freqs = parameters.freq || [350, 350];
+     var qs = parameters.Q || [1, 1];
+     var gains = parameters.gain || [0, 0];
+     var detunes = parameters.detune || [0, 0];
+
+     for (var frame = 0; frame < endFrame; ++frame) {
+        // Apply linear ramp at frame |frame|.
+        var f = linearRamp(frame / sampleRate, freqs[0], freqs[1], 0, duration);
+        var q = linearRamp(frame / sampleRate, qs[0], qs[1], 0, duration);
+        var g = linearRamp(frame / sampleRate, gains[0], gains[1], 0, duration);
+        var d = linearRamp(frame / sampleRate, detunes[0], detunes[1], 0, duration);
+
+        // Compute actual frequency parameter
+        f = f * Math.pow(2, d / 1200);
+
+        // Compute filter coefficients
+        var coef = filterTypeFunction(f / (sampleRate / 2), q, g);
+        b0[k] = coef.b0;
+        b1[k] = coef.b1;
+        b2[k] = coef.b2;
+        a1[k] = coef.a1;
+        a2[k] = coef.a2;
+        ++k;
+     }
+
+     return {b0: b0, b1: b1, b2: b2, a1: a1, a2: a2};
+  }
+
+  // Apply the given time-varying biquad filter to the given signal, |signal|.  |coef| should be
+  // the time-varying coefficients of the filter, as returned by |generateFilterCoefficients|.
+  function timeVaryingFilter(signal, coef) {
+    var length = signal.length;
+    // Use double precision for the internal computations.
+    var y = new Float64Array(length);
+
+    // Prime the pump. (Assumes the signal has length >= 2!)
+    y[0] = coef.b0[0] * signal[0];
+    y[1] = coef.b0[1] * signal[1] + coef.b1[1] * signal[0] - coef.a1[1] * y[0];
+
+    for (var n = 2; n < length; ++n) {
+      y[n] = coef.b0[n] * signal[n] + coef.b1[n] * signal[n-1] + coef.b2[n] * signal[n-2];
+      y[n] -= coef.a1[n] * y[n-1] + coef.a2[n] * y[n-2];
+    }
+
+    // But convert the result to single precision for comparison.
+    return y.map(Math.fround);
+  }
+
+  // Configure the audio graph using |context|.  Returns the biquad filter node and the
+  // AudioBuffer used for the source.
+  function configureGraph(context, toneFrequency) {
+    // The source is just a simple sine wave.
+    var src = context.createBufferSource();
+    var b = context.createBuffer(1, renderDuration * sampleRate, sampleRate);
+    var data = b.getChannelData(0);
+    var omega = 2 * Math.PI * toneFrequency / sampleRate;
+    for (var k = 0; k < data.length; ++k) {
+      data[k] = Math.sin(omega * k);
+    }
+    src.buffer = b;
+    var f = context.createBiquadFilter();
+    src.connect(f);
+    f.connect(context.destination);
+
+    src.start();
+
+    return {filter: f, source: b};
+  }
+
+  function createFilterVerifier(filterCreator, threshold, parameters, input, message) {
+    return function (resultBuffer) {
+      var actual = resultBuffer.getChannelData(0);
+      var coefs = generateFilterCoefficients(filterCreator, parameters, renderDuration);
+
+      reference = timeVaryingFilter(input, coefs);
+
+      compareChannels(actual, reference);
+    };
+  }
+
+  var testPromises = [];
+
+  // Automate just the frequency parameter.  A bandpass filter is used where the center
+  // frequency is swept across the source (which is a simple tone).
+  testPromises.push(function () {
+    var context = new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
+
+    // Center frequency of bandpass filter and also the frequency of the test tone.
+    var centerFreq = 10*440;
+
+    // Sweep the frequency +/- 9*440 Hz from the center.  This should cause the output to low at
+    // the beginning and end of the test where the done is outside the pass band of the filter,
+    // but high in the center where the tone is near the center of the pass band.
+    var parameters = {
+      freq: [centerFreq - 9*440, centerFreq + 9*440]
+    }
+    var graph = configureGraph(context, centerFreq);
+    var f = graph.filter;
+    var b = graph.source;
+
+    f.type = "bandpass";
+    f.frequency.setValueAtTime(parameters.freq[0], 0);
+    f.frequency.linearRampToValueAtTime(parameters.freq[1], renderDuration);
+
+    return context.startRendering()
+      .then(createFilterVerifier(createBandpassFilter, 5e-5, parameters, b.getChannelData(0),
+        "Output of bandpass filter with frequency automation"));
+  }());
+
+  // Automate just the Q parameter.  A bandpass filter is used where the Q of the filter is
+  // swept.
+  testPromises.push(function() {
+    var context = new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
+
+    // The frequency of the test tone.
+    var centerFreq = 440;
+
+    // Sweep the Q paramter between 1 and 200.  This will cause the output of the filter to pass
+    // most of the tone at the beginning to passing less of the tone at the end.  This is
+    // because we set center frequency of the bandpass filter to be slightly off from the actual
+    // tone.
+    var parameters = {
+      Q: [1, 200],
+      // Center frequency of the bandpass filter is just 25 Hz above the tone frequency.
+      freq: [centerFreq + 25, centerFreq + 25]
+    };
+    var graph = configureGraph(context, centerFreq);
+    var f = graph.filter;
+    var b = graph.source;
+
+    f.type = "bandpass";
+    f.frequency.value = parameters.freq[0];
+    f.Q.setValueAtTime(parameters.Q[0], 0);
+    f.Q.linearRampToValueAtTime(parameters.Q[1], renderDuration);
+
+    return context.startRendering()
+      .then(createFilterVerifier(createBandpassFilter, 1.4e-6, parameters, b.getChannelData(0),
+        "Output of bandpass filter with Q automation"));
+  }());
+
+  // Automate just the gain of the lowshelf filter.  A test tone will be in the lowshelf part of
+  // the filter.  The output will vary as the gain of the lowshelf is changed.
+  testPromises.push(function() {
+    var context = new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
+
+    // Frequency of the test tone.
+    var centerFreq = 440;
+
+    // Set the cutoff frequency of the lowshelf to be significantly higher than the test tone.
+    // Sweep the gain from 20 dB to -20 dB.  (We go from 20 to -20 to easily verify that the
+    // filter didn't go unstable.)
+    var parameters = {
+      freq: [3500, 3500],
+      gain: [20, -20]
+    }
+    var graph = configureGraph(context, centerFreq);
+    var f = graph.filter;
+    var b = graph.source;
+
+    f.type = "lowshelf";
+    f.frequency.value = parameters.freq[0];
+    f.gain.setValueAtTime(parameters.gain[0], 0);
+    f.gain.linearRampToValueAtTime(parameters.gain[1], renderDuration);
+
+    context.startRendering()
+      .then(createFilterVerifier(createLowShelfFilter, 8e-6, parameters, b.getChannelData(0),
+        "Output of lowshelf filter with gain automation"));
+  }());
+
+  // Automate just the detune parameter.  Basically the same test as for the frequncy parameter
+  // but we just use the detune parameter to modulate the frequency parameter.
+  testPromises.push(function() {
+    var context = new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
+    var centerFreq = 10*440;
+    var parameters = {
+      freq: [centerFreq, centerFreq],
+      detune: [-10*1200, 10*1200]
+    };
+    var graph = configureGraph(context, centerFreq);
+    var f = graph.filter;
+    var b = graph.source;
+
+    f.type = "bandpass";
+    f.frequency.value = parameters.freq[0];
+    f.detune.setValueAtTime(parameters.detune[0], 0);
+    f.detune.linearRampToValueAtTime(parameters.detune[1], renderDuration);
+
+    context.startRendering()
+      .then(createFilterVerifier(createBandpassFilter, 5e-6, parameters, b.getChannelData(0),
+        "Output of bandpass filter with detune automation"));
+  }());
+
+  // Automate all of the filter parameters at once.  This is a basic check that everything is
+  // working.  A peaking filter is used because it uses all of the parameters.
+  testPromises.push(function() {
+    var context = new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
+    var graph = configureGraph(context, 10*440);
+    var f = graph.filter;
+    var b = graph.source;
+
+    // Sweep all of the filter parameters.  These are pretty much arbitrary.
+    var parameters = {
+      freq: [10000, 100],
+      Q: [f.Q.value, .0001],
+      gain: [f.gain.value, 20],
+      detune: [2400, -2400]
+    };
+
+    f.type = "peaking";
+    // Set starting points for all parameters of the filter.  Start at 10 kHz for the center
+    // frequency, and the defaults for Q and gain.
+    f.frequency.setValueAtTime(parameters.freq[0], 0);
+    f.Q.setValueAtTime(parameters.Q[0], 0);
+    f.gain.setValueAtTime(parameters.gain[0], 0);
+    f.detune.setValueAtTime(parameters.detune[0], 0);
+
+    // Linear ramp each parameter
+    f.frequency.linearRampToValueAtTime(parameters.freq[1], renderDuration);
+    f.Q.linearRampToValueAtTime(parameters.Q[1], renderDuration);
+    f.gain.linearRampToValueAtTime(parameters.gain[1], renderDuration);
+    f.detune.linearRampToValueAtTime(parameters.detune[1], renderDuration);
+
+    context.startRendering()
+      .then(createFilterVerifier(createPeakingFilter, 3.3e-4, parameters, b.getChannelData(0),
+        "Output of peaking filter with automation of all parameters"));
+  }());
+
+  // Test that modulation of the frequency parameter of the filter works.  A sinusoid of 440 Hz
+  // is the test signal that is applied to a bandpass biquad filter.  The frequency parameter of
+  // the filter is modulated by a sinusoid at 103 Hz, and the frequency modulation varies from
+  // 116 to 412 Hz.  (This test was taken from the description in
+  // https://github.com/WebAudio/web-audio-api/issues/509#issuecomment-94731355)
+  testPromises.push(function() {
+    var context = new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
+
+    // Create a graph with the sinusoidal source at 440 Hz as the input to a biquad filter.
+    var graph = configureGraph(context, 440);
+    var f = graph.filter;
+    var b = graph.source;
+
+    f.type = "bandpass";
+    f.Q.value = 5;
+    f.frequency.value = 264;
+
+    // Create the modulation source, a sinusoid with frequency 103 Hz and amplitude 148.  (The
+    // amplitude of 148 is added to the filter's frequency value of 264 to produce a sinusoidal
+    // modulation of the frequency parameter from 116 to 412 Hz.)
+    var mod = context.createBufferSource();
+    var mbuffer = context.createBuffer(1, renderDuration * sampleRate, sampleRate);
+    var d = mbuffer.getChannelData(0);
+    var omega = 2 * Math.PI * 103 / sampleRate;
+    for (var k = 0; k < d.length; ++k) {
+      d[k] = 148 * Math.sin(omega * k);
+    }
+    mod.buffer = mbuffer;
+
+    mod.connect(f.frequency);
+
+    mod.start();
+    return context.startRendering()
+      .then(function (resultBuffer) {
+         var actual = resultBuffer.getChannelData(0);
+         // Compute the filter coefficients using the mod sine wave
+
+         var endFrame = Math.ceil(renderDuration * sampleRate);
+         var nCoef = endFrame;
+         var b0 = new Float64Array(nCoef);
+         var b1 = new Float64Array(nCoef);
+         var b2 = new Float64Array(nCoef);
+         var a1 = new Float64Array(nCoef);
+         var a2 = new Float64Array(nCoef);
+
+         // Generate the filter coefficients when the frequency varies from 116 to 248 Hz using
+         // the 103 Hz sinusoid.
+         for (var k = 0; k < nCoef; ++k) {
+           var freq = f.frequency.value + d[k];
+           var c = createBandpassFilter(freq / (sampleRate / 2), f.Q.value, f.gain.value);
+           b0[k] = c.b0;
+           b1[k] = c.b1;
+           b2[k] = c.b2;
+           a1[k] = c.a1;
+           a2[k] = c.a2;
+         }
+         reference = timeVaryingFilter(b.getChannelData(0),
+           {b0: b0, b1: b1, b2: b2, a1: a1, a2: a2});
+
+         compareChannels(actual, reference);
+       });
+  }());
+
+  // Wait for all tests
+  Promise.all(testPromises).then(function () {
+    SimpleTest.finish();
+  }, function () {
+    SimpleTest.finish();
+  });
+});
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/blink/test_biquadFilterNodeBandPass.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test BiquadFilterNode Band Pass Filter</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 src="audio-testing.js"></script>
+<script src="biquad-filters.js"></script>
+<script src="biquad-testing.js"></script>
+<script src="webaudio.js" type="text/javascript"></script>
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+    // Create offline audio context.
+    var context = new OfflineAudioContext(2, sampleRate * renderLengthSeconds, sampleRate);
+
+    // The filters we want to test.
+    var filterParameters = [{cutoff : 0,    q : 0, gain : 1 },
+                            {cutoff : 1,    q : 0, gain : 1 },
+                            {cutoff : 0.5,  q : 0, gain : 1 },
+                            {cutoff : 0.25, q : 1, gain : 1 },
+                           ];
+
+    createTestAndRun(context, "bandpass", filterParameters);
+});
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/blink/test_biquadFilterNodeGetFrequencyResponse.html
@@ -0,0 +1,261 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test BiquadFilterNode All Pass Filter</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 src="audio-testing.js"></script>
+<script src="biquad-filters.js"></script>
+<script src="biquad-testing.js"></script>
+<script src="webaudio.js" type="text/javascript"></script>
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+// Test the frequency response of a biquad filter.  We compute the frequency response for a simple
+// peaking biquad filter and compare it with the expected frequency response.  The actual filter
+// used doesn't matter since we're testing getFrequencyResponse and not the actual filter output.
+// The filters are extensively tested in other biquad tests.
+
+var context;
+
+// The biquad filter node.
+var filter;
+
+// The magnitude response of the biquad filter.
+var magResponse;
+
+// The phase response of the biquad filter.
+var phaseResponse;
+
+// Number of frequency samples to take.
+var numberOfFrequencies = 1000;
+
+// The filter parameters.
+var filterCutoff = 1000; // Hz.
+var filterQ = 1;
+var filterGain = 5; // Decibels.
+
+// The maximum allowed error in the magnitude response.
+var maxAllowedMagError = 5.7e-7;
+
+// The maximum allowed error in the phase response.
+var maxAllowedPhaseError = 4.7e-8;
+
+// The magnitudes and phases of the reference frequency response.
+var magResponse;
+var phaseResponse;
+
+// The magnitudes and phases of the reference frequency response.
+var expectedMagnitudes;
+var expectedPhases;
+
+// Convert frequency in Hz to a normalized frequency between 0 to 1 with 1 corresponding to the
+// Nyquist frequency.
+function normalizedFrequency(freqHz, sampleRate)
+{
+    var nyquist = sampleRate / 2;
+    return freqHz / nyquist;
+}
+
+// Get the filter response at a (normalized) frequency |f| for the filter with coefficients |coef|.
+function getResponseAt(coef, f)
+{
+    var b0 = coef.b0;
+    var b1 = coef.b1;
+    var b2 = coef.b2;
+    var a1 = coef.a1;
+    var a2 = coef.a2;
+
+    // H(z) = (b0 + b1 / z + b2 / z^2) / (1 + a1 / z + a2 / z^2)
+    //
+    // Compute H(exp(i * pi * f)).  No native complex numbers in javascript, so break H(exp(i * pi * // f))
+    // in to the real and imaginary parts of the numerator and denominator.  Let omega = pi * f.
+    // Then the numerator is
+    //
+    // b0 + b1 * cos(omega) + b2 * cos(2 * omega) - i * (b1 * sin(omega) + b2 * sin(2 * omega))
+    //
+    // and the denominator is
+    //
+    // 1 + a1 * cos(omega) + a2 * cos(2 * omega) - i * (a1 * sin(omega) + a2 * sin(2 * omega))
+    //
+    // Compute the magnitude and phase from the real and imaginary parts.
+
+    var omega = Math.PI * f;
+    var numeratorReal = b0 + b1 * Math.cos(omega) + b2 * Math.cos(2 * omega);
+    var numeratorImag = -(b1 * Math.sin(omega) + b2 * Math.sin(2 * omega));
+    var denominatorReal = 1 + a1 * Math.cos(omega) + a2 * Math.cos(2 * omega);
+    var denominatorImag = -(a1 * Math.sin(omega) + a2 * Math.sin(2 * omega));
+
+    var magnitude = Math.sqrt((numeratorReal * numeratorReal + numeratorImag * numeratorImag)
+                              / (denominatorReal * denominatorReal + denominatorImag * denominatorImag));
+    var phase = Math.atan2(numeratorImag, numeratorReal) - Math.atan2(denominatorImag, denominatorReal);
+
+    if (phase >= Math.PI) {
+        phase -= 2 * Math.PI;
+    } else if (phase <= -Math.PI) {
+        phase += 2 * Math.PI;
+    }
+
+    return {magnitude : magnitude, phase : phase};
+}
+
+// Compute the reference frequency response for the biquad filter |filter| at the frequency samples
+// given by |frequencies|.
+function frequencyResponseReference(filter, frequencies)
+{
+    var sampleRate = filter.context.sampleRate;
+    var normalizedFreq = normalizedFrequency(filter.frequency.value, sampleRate);
+    var filterCoefficients = createFilter(filter.type, normalizedFreq, filter.Q.value, filter.gain.value);
+
+    var magnitudes = [];
+    var phases = [];
+
+    for (var k = 0; k < frequencies.length; ++k) {
+        var response = getResponseAt(filterCoefficients, normalizedFrequency(frequencies[k], sampleRate));
+        magnitudes.push(response.magnitude);
+        phases.push(response.phase);
+    }
+
+    return {magnitudes : magnitudes, phases : phases};
+}
+
+// Compute a set of linearly spaced frequencies.
+function createFrequencies(nFrequencies, sampleRate)
+{
+    var frequencies = new Float32Array(nFrequencies);
+    var nyquist = sampleRate / 2;
+    var freqDelta = nyquist / nFrequencies;
+
+    for (var k = 0; k < nFrequencies; ++k) {
+        frequencies[k] = k * freqDelta;
+    }
+
+    return frequencies;
+}
+
+function linearToDecibels(x)
+{
+    if (x) {
+        return 20 * Math.log(x) / Math.LN10;
+    } else {
+        return -1000;
+    }
+}
+
+// Look through the array and find any NaN or infinity. Returns the index of the first occurence or
+// -1 if none.
+function findBadNumber(signal)
+{
+    for (var k = 0; k < signal.length; ++k) {
+        if (!isValidNumber(signal[k])) {
+           return k;
+        }
+    }
+    return -1;
+}
+
+// Compute absolute value of the difference between phase angles, taking into account the wrapping
+// of phases.
+function absolutePhaseDifference(x, y)
+{
+    var diff = Math.abs(x - y);
+
+    if (diff > Math.PI) {
+        diff = 2 * Math.PI - diff;
+    }
+    return diff;
+}
+
+// Compare the frequency response with our expected response.
+function compareResponses(filter, frequencies, magResponse, phaseResponse)
+{
+    var expectedResponse = frequencyResponseReference(filter, frequencies);
+
+    expectedMagnitudes = expectedResponse.magnitudes;
+    expectedPhases = expectedResponse.phases;
+
+    var n = magResponse.length;
+    var success = true;
+    var badResponse = false;
+
+    var maxMagError = -1;
+    var maxMagErrorIndex = -1;
+
+    var k;
+    var hasBadNumber;
+
+    hasBadNumber = findBadNumber(magResponse);
+    ok (hasBadNumber < 0, "Magnitude response has NaN or infinity at " + hasBadNumber);
+
+    hasBadNumber = findBadNumber(phaseResponse);
+    ok (hasBadNumber < 0, "Phase response has NaN or infinity at " + hasBadNumber);
+
+    // These aren't testing the implementation itself.  Instead, these are sanity checks on the
+    // reference.  Failure here does not imply an error in the implementation.
+    hasBadNumber = findBadNumber(expectedMagnitudes);
+    ok (hasBadNumber < 0, "Expected magnitude response has NaN or infinity at " + hasBadNumber);
+
+    hasBadNumber = findBadNumber(expectedPhases);
+    ok (hasBadNumber < 0, "Expected phase response has NaN or infinity at " + hasBadNumber);
+
+    for (k = 0; k < n; ++k) {
+        var error = Math.abs(linearToDecibels(magResponse[k]) - linearToDecibels(expectedMagnitudes[k]));
+        if (error > maxMagError) {
+            maxMagError = error;
+            maxMagErrorIndex = k;
+        }
+    }
+
+    var message = "Magnitude error (" + maxMagError + " dB)";
+    message += " exceeded threshold at " + frequencies[maxMagErrorIndex];
+    message += " Hz.  Actual: " + linearToDecibels(magResponse[maxMagErrorIndex]);
+    message += " dB, expected: " + linearToDecibels(expectedMagnitudes[maxMagErrorIndex]) + " dB.";
+    ok(maxMagError < maxAllowedMagError, message);
+
+    var maxPhaseError = -1;
+    var maxPhaseErrorIndex = -1;
+
+    for (k = 0; k < n; ++k) {
+        var error = absolutePhaseDifference(phaseResponse[k], expectedPhases[k]);
+        if (error > maxPhaseError) {
+            maxPhaseError = error;
+            maxPhaseErrorIndex = k;
+        }
+    }
+
+    message = "Phase error (radians) (" + maxPhaseError;
+    message += ") exceeded threshold at " + frequencies[maxPhaseErrorIndex];
+    message += " Hz.  Actual: " + phaseResponse[maxPhaseErrorIndex];
+    message += " expected: " + expectedPhases[maxPhaseErrorIndex];
+
+    ok(maxPhaseError < maxAllowedPhaseError, message);
+}
+
+context = new AudioContext();
+
+filter = context.createBiquadFilter();
+
+// Arbitrarily test a peaking filter, but any kind of filter can be tested.
+filter.type = "peaking";
+filter.frequency.value = filterCutoff;
+filter.Q.value = filterQ;
+filter.gain.value = filterGain;
+
+var frequencies = createFrequencies(numberOfFrequencies, context.sampleRate);
+magResponse = new Float32Array(numberOfFrequencies);
+phaseResponse = new Float32Array(numberOfFrequencies);
+
+filter.getFrequencyResponse(frequencies, magResponse, phaseResponse);
+compareResponses(filter, frequencies, magResponse, phaseResponse);
+
+SimpleTest.finish();
+});
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/blink/test_biquadFilterNodeHighPass.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test BiquadFilterNode High Pass Filter</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 src="audio-testing.js"></script>
+<script src="biquad-filters.js"></script>
+<script src="biquad-testing.js"></script>
+<script src="webaudio.js" type="text/javascript"></script>
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+    // Create offline audio context.
+    var context = new OfflineAudioContext(2, sampleRate * renderLengthSeconds, sampleRate);
+
+    // The filters we want to test.
+    var filterParameters = [{cutoff : 0,    q : 1, gain : 1 },
+                            {cutoff : 1,    q : 1, gain : 1 },
+                            {cutoff : 0.25, q : 1, gain : 1 },
+                           ];
+
+    createTestAndRun(context, "highpass", filterParameters);
+});
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/blink/test_biquadFilterNodeHighShelf.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test BiquadFilterNode High Shelf Filter</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 src="audio-testing.js"></script>
+<script src="biquad-filters.js"></script>
+<script src="biquad-testing.js"></script>
+<script src="webaudio.js" type="text/javascript"></script>
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+    // Create offline audio context.
+    var context = new OfflineAudioContext(2, sampleRate * renderLengthSeconds, sampleRate);
+
+    // The filters we want to test.
+    var filterParameters = [{cutoff : 0,    q : 10, gain : 10 },
+                            {cutoff : 1,    q : 10, gain : 10 },
+                            {cutoff : 0.25, q : 10, gain : 10 },
+                           ];
+
+    createTestAndRun(context, "highshelf", filterParameters);
+});
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/blink/test_biquadFilterNodeLowPass.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test BiquadFilterNode Low Pass Filter</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 src="audio-testing.js"></script>
+<script src="biquad-filters.js"></script>
+<script src="biquad-testing.js"></script>
+<script src="webaudio.js" type="text/javascript"></script>
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+    // Create offline audio context.
+    var context = new OfflineAudioContext(2, sampleRate * renderLengthSeconds, sampleRate);
+
+    // The filters we want to test.
+    var filterParameters = [{cutoff : 0,    q : 1, gain : 1 },
+                            {cutoff : 1,    q : 1, gain : 1 },
+                            {cutoff : 0.25, q : 1, gain : 1 },
+                            {cutoff : 0.25, q : 1, gain : 1, detune : 100 },
+                            {cutoff : 0.01, q : 1, gain : 1, detune : -200 },
+                           ];
+    createTestAndRun(context, "lowpass", filterParameters);
+});
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/blink/test_biquadFilterNodeLowShelf.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test BiquadFilterNode Low Shelf Filter</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 src="audio-testing.js"></script>
+<script src="biquad-filters.js"></script>
+<script src="biquad-testing.js"></script>
+<script src="webaudio.js" type="text/javascript"></script>
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+ 
+    // Create offline audio context.
+    var context = new OfflineAudioContext(2, sampleRate * renderLengthSeconds, sampleRate);
+
+    // The filters we want to test.
+    var filterParameters = [{cutoff : 0,    q : 10, gain : 10 },
+                            {cutoff : 1,    q : 10, gain : 10 },
+                            {cutoff : 0.25, q : 10, gain : 10 },
+                           ];
+
+    createTestAndRun(context, "lowshelf", filterParameters);
+});
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/blink/test_biquadFilterNodeNotch.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test BiquadFilterNode Notch Filter</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 src="audio-testing.js"></script>
+<script src="biquad-filters.js"></script>
+<script src="biquad-testing.js"></script>
+<script src="webaudio.js" type="text/javascript"></script>
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+    // Create offline audio context.
+    var context = new OfflineAudioContext(2, sampleRate * renderLengthSeconds, sampleRate);
+
+    var filterParameters = [{cutoff : 0,    q : 10, gain : 1 },
+                            {cutoff : 1,    q : 10, gain : 1 },
+                            {cutoff : .5,   q :  0, gain : 1 },
+                            {cutoff : 0.25, q : 10, gain : 1 },
+                           ];
+
+    createTestAndRun(context, "notch", filterParameters);
+});
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/blink/test_biquadFilterNodePeaking.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test BiquadFilterNode Low Pass Filter</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 src="audio-testing.js"></script>
+<script src="biquad-filters.js"></script>
+<script src="biquad-testing.js"></script>
+<script src="webaudio.js" type="text/javascript"></script>
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+    // Create offline audio context.
+    var context = new OfflineAudioContext(2, sampleRate * renderLengthSeconds, sampleRate);
+
+    // The filters we want to test.
+    var filterParameters = [{cutoff : 0,    q : 10, gain : 10 },
+                            {cutoff : 1,    q : 10, gain : 10 },
+                            {cutoff : .5,   q :  0, gain : 10 },
+                            {cutoff : 0.25, q : 10, gain : 10 },
+                           ];
+
+    createTestAndRun(context, "peaking", filterParameters);
+});
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/blink/test_biquadFilterNodeTail.html
@@ -0,0 +1,76 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test BiquadFilterNode All Pass Filter</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 src="audio-testing.js"></script>
+<script src="biquad-filters.js"></script>
+<script src="biquad-testing.js"></script>
+<script src="webaudio.js" type="text/javascript"></script>
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+  // A high sample rate shows the issue more clearly.
+  var sampleRate = 192000;
+  // Some short duration because we don't need to run the test for very long.
+  var testDurationSec = 0.5;
+  var testDurationFrames = testDurationSec * sampleRate;
+
+  // Amplitude experimentally determined to give a biquad output close to 1. (No attempt was
+  // made to produce exactly 1; it's not needed.)
+  var sourceAmplitude = 100;
+
+  // The output of the biquad filter should not change by more than this much between output
+  // samples.  Threshold was determined experimentally.
+  var glitchThreshold = 0.01292;
+
+  // Test that a Biquad filter doesn't have it's output terminated because the input has gone
+  // away.  Generally, when a source node is finished, it disconnects itself from any downstream
+  // nodes.  This is the correct behavior.  Nodes that have no inputs (disconnected) are
+  // generally assumed to output zeroes.  This is also desired behavior.  However, biquad
+  // filters have memory so they should not suddenly output zeroes when the input is
+  // disconnected.  This test checks to see if the output doesn't suddenly change to zero.
+  var context = new OfflineAudioContext(1, testDurationFrames, sampleRate);
+
+  // Create an impulse source.
+  var buffer = context.createBuffer(1, 1, context.sampleRate);
+  buffer.getChannelData(0)[0] = sourceAmplitude;
+  var source = context.createBufferSource();
+  source.buffer = buffer;
+
+  // Create the biquad filter. It doesn't really matter what kind, so the default filter type
+  // and parameters is fine.  Connect the source to it.
+  var biquad = context.createBiquadFilter();
+  source.connect(biquad);
+  biquad.connect(context.destination);
+
+  source.start();
+
+  context.startRendering().then(function(result) {
+    // There should be no large discontinuities in the output
+    var buffer = result.getChannelData(0);
+    var maxGlitchIndex = 0;
+    var maxGlitchValue = 0.0;
+    for (var i = 1; i < buffer.length; i++) {
+      var diff = Math.abs(buffer[i-1] - buffer[i]);
+      if (diff >= glitchThreshold) {
+        if (diff > maxGlitchValue) {
+          maxGlitchIndex = i;
+          maxGlitchValue = diff;
+        }
+      }
+    }
+    ok(maxGlitchIndex == 0, 'glitches detected in biquad output: maximum glitch at ' + maxGlitchIndex + ' with diff of ' + maxGlitchValue);
+    SimpleTest.finish();
+  })
+});
+</script>
+</pre>
+</body>
+</html>
--- a/dom/media/webm/WebMDemuxer.cpp
+++ b/dom/media/webm/WebMDemuxer.cpp
@@ -10,16 +10,17 @@
 #include "MediaResource.h"
 #include "WebMDemuxer.h"
 #include "WebMBufferedParser.h"
 #include "gfx2DGlue.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/EndianUtils.h"
 #include "mozilla/SharedThreadPool.h"
 #include "MediaDataDemuxer.h"
+#include "nsAutoPtr.h"
 #include "nsAutoRef.h"
 #include "NesteggPacketHolder.h"
 #include "XiphExtradata.h"
 #include "prprf.h"           // leaving it for PR_vsnprintf()
 #include "mozilla/Snprintf.h"
 
 #include <algorithm>
 #include <stdint.h>
--- a/dom/media/webm/WebMWriter.h
+++ b/dom/media/webm/WebMWriter.h
@@ -2,16 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef WebMWriter_h_
 #define WebMWriter_h_
 
 #include "ContainerWriter.h"
+#include "nsAutoPtr.h"
 
 namespace mozilla {
 
 class EbmlComposer;
 
 // Vorbis meta data structure
 class VorbisMetadata : public TrackMetadataBase
 {
--- a/dom/media/webrtc/AudioOutputObserver.h
+++ b/dom/media/webrtc/AudioOutputObserver.h
@@ -1,16 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef AUDIOOUTPUTOBSERVER_H_
 #define AUDIOOUTPUTOBSERVER_H_
 
 #include "mozilla/StaticPtr.h"
+#include "nsAutoPtr.h"
 #include "AudioMixer.h"
 
 namespace webrtc {
 class SingleRwFifo;
 }
 
 namespace mozilla {
 
--- a/dom/media/webrtc/MediaEngineDefault.h
+++ b/dom/media/webrtc/MediaEngineDefault.h
@@ -2,16 +2,17 @@
  * 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 MEDIAENGINEDEFAULT_H_
 #define MEDIAENGINEDEFAULT_H_
 
 #include "nsITimer.h"
 
+#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "DOMMediaStream.h"
 #include "nsComponentManagerUtils.h"
 #include "mozilla/Monitor.h"
 
 #include "VideoUtils.h"
 #include "MediaEngine.h"
 #include "VideoSegment.h"
--- a/dom/media/webrtc/MediaEngineWebRTC.h
+++ b/dom/media/webrtc/MediaEngineWebRTC.h
@@ -11,16 +11,17 @@
 #include "nsIThread.h"
 #include "nsIRunnable.h"
 
 #include "mozilla/dom/File.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/StaticMutex.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/UniquePtr.h"
+#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsThreadUtils.h"
 #include "DOMMediaStream.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsComponentManagerUtils.h"
 #include "nsRefPtrHashtable.h"
 
 #include "VideoUtils.h"
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -3,16 +3,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MediaEngineWebRTC.h"
 #include <stdio.h>
 #include <algorithm>
 #include "mozilla/Assertions.h"
 #include "MediaTrackConstraints.h"
 #include "mtransport/runnable_utils.h"
+#include "nsAutoPtr.h"
 
 // scoped_ptr.h uses FF
 #ifdef FF
 #undef FF
 #endif
 #include "webrtc/modules/audio_device/opensl/single_rw_fifo.h"
 
 #define CHANNELS 1
--- a/dom/media/webrtc/WebrtcGlobal.h
+++ b/dom/media/webrtc/WebrtcGlobal.h
@@ -3,16 +3,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _WEBRTC_GLOBAL_H_
 #define _WEBRTC_GLOBAL_H_
 
 #include "ipc/IPCMessageUtils.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/RTCStatsReportBinding.h"
+#include "nsAutoPtr.h"
 
 typedef mozilla::dom::RTCStatsReportInternal StatsReport;
 typedef nsTArray< nsAutoPtr<StatsReport>> RTCReports;
 typedef mozilla::dom::Sequence<nsString> WebrtcGlobalLog;
 
 namespace IPC {
 
 template<typename T>
--- a/dom/media/webspeech/recognition/SpeechRecognitionAlternative.h
+++ b/dom/media/webspeech/recognition/SpeechRecognitionAlternative.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_SpeechRecognitionAlternative_h
 #define mozilla_dom_SpeechRecognitionAlternative_h
 
 #include "nsCycleCollectionParticipant.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
-#include "nsAutoPtr.h"
 #include "js/TypeDecls.h"
 
 #include "mozilla/Attributes.h"
 
 namespace mozilla {
 namespace dom {
 
 class SpeechRecognition;
--- a/dom/media/webspeech/recognition/SpeechRecognitionResult.h
+++ b/dom/media/webspeech/recognition/SpeechRecognitionResult.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_SpeechRecognitionResult_h
 #define mozilla_dom_SpeechRecognitionResult_h
 
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
-#include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "js/TypeDecls.h"
 
 #include "mozilla/Attributes.h"
 
 #include "SpeechRecognitionAlternative.h"
 
 namespace mozilla {
--- a/dom/media/webspeech/recognition/SpeechRecognitionResultList.h
+++ b/dom/media/webspeech/recognition/SpeechRecognitionResultList.h
@@ -4,17 +4,16 @@
  * 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 mozilla_dom_SpeechRecognitionResultList_h
 #define mozilla_dom_SpeechRecognitionResultList_h
 
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
-#include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "js/TypeDecls.h"
 
 #include "mozilla/Attributes.h"
 
 #include "SpeechRecognitionResult.h"
 
 namespace mozilla {
--- a/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerService.h
+++ b/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerService.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_OsxSpeechSynthesizerService_h
 #define mozilla_dom_OsxSpeechSynthesizerService_h
 
-#include "nsAutoPtr.h"
 #include "nsISpeechService.h"
 #include "nsIObserver.h"
 #include "mozilla/StaticPtr.h"
 
 namespace mozilla {
 namespace dom {
 
 class OSXSpeechSynthesizerService final : public nsISpeechService
--- a/dom/media/webspeech/synth/nsSynthVoiceRegistry.h
+++ b/dom/media/webspeech/synth/nsSynthVoiceRegistry.h
@@ -2,17 +2,16 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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 mozilla_dom_nsSynthVoiceRegistry_h
 #define mozilla_dom_nsSynthVoiceRegistry_h
 
-#include "nsAutoPtr.h"
 #include "nsISynthVoiceRegistry.h"
 #include "nsRefPtrHashtable.h"
 #include "nsTArray.h"
 #include "MediaStreamGraph.h"
 
 class nsISpeechService;
 
 namespace mozilla {
--- a/dom/media/webspeech/synth/speechd/SpeechDispatcherService.h
+++ b/dom/media/webspeech/synth/speechd/SpeechDispatcherService.h
@@ -3,17 +3,16 @@
 /* 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 mozilla_dom_SpeechDispatcherService_h
 #define mozilla_dom_SpeechDispatcherService_h
 
 #include "mozilla/StaticPtr.h"
-#include "nsAutoPtr.h"
 #include "nsIObserver.h"
 #include "nsISpeechService.h"
 #include "nsIThread.h"
 #include "nsRefPtrHashtable.h"
 #include "nsTArray.h"
 
 struct SPDConnection;
 
--- a/dom/media/webspeech/synth/test/nsFakeSynthServices.h
+++ b/dom/media/webspeech/synth/test/nsFakeSynthServices.h
@@ -2,17 +2,16 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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 nsFakeSynthServices_h
 #define nsFakeSynthServices_h
 
-#include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "nsIObserver.h"
 #include "nsIThread.h"
 #include "nsISpeechService.h"
 #include "nsRefPtrHashtable.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/Monitor.h"
 
--- a/dom/media/webspeech/synth/windows/SapiService.h
+++ b/dom/media/webspeech/synth/windows/SapiService.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_SapiService_h
 #define mozilla_dom_SapiService_h
 
-#include "nsAutoPtr.h"
 #include "nsISpeechService.h"
 #include "nsIObserver.h"
 #include "nsRefPtrHashtable.h"
 #include "nsTArray.h"
 #include "mozilla/StaticPtr.h"
 
 #include <windows.h>
 #include <sapi.h>
--- a/dom/messagechannel/MessagePort.h
+++ b/dom/messagechannel/MessagePort.h
@@ -4,16 +4,17 @@
  * 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 mozilla_dom_MessagePort_h
 #define mozilla_dom_MessagePort_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/DOMEventTargetHelper.h"
+#include "nsAutoPtr.h"
 #include "nsIIPCBackgroundChildCreateCallback.h"
 #include "nsTArray.h"
 
 #ifdef XP_WIN
 #undef PostMessage
 #endif
 
 class nsIGlobalObject;
--- a/dom/messagechannel/MessagePortList.h
+++ b/dom/messagechannel/MessagePortList.h
@@ -7,17 +7,16 @@
 #ifndef mozilla_dom_MessagePortList_h
 #define mozilla_dom_MessagePortList_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/dom/MessagePort.h"
 #include "nsWrapperCache.h"
-#include "nsAutoPtr.h"
 #include "nsTArray.h"
 
 namespace mozilla {
 namespace dom {
 
 class MessagePortList final : public nsISupports
                             , public nsWrapperCache
 {
--- a/dom/mobilemessage/MobileMessageCursorCallback.h
+++ b/dom/mobilemessage/MobileMessageCursorCallback.h
@@ -7,17 +7,16 @@
 #ifndef mozilla_dom_mobilemessage_MobileMessageCursorCallback_h
 #define mozilla_dom_mobilemessage_MobileMessageCursorCallback_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/DOMCursor.h"
 #include "nsIMobileMessageCursorCallback.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
 
 class nsICursorContinueCallback;
 
 namespace mozilla {
 namespace dom {
 
 class MobileMessageManager;
 
--- a/dom/network/TCPSocketParent.cpp
+++ b/dom/network/TCPSocketParent.cpp
@@ -30,17 +30,17 @@ DeserializeArrayBuffer(JSContext* aCx,
                        JS::MutableHandle<JS::Value> aVal);
 
 } // namespace IPC
 
 namespace mozilla {
 
 namespace net {
 //
-// set NSPR_LOG_MODULES=TCPSocket:5
+// set MOZ_LOG=TCPSocket:5
 //
 extern LazyLogModule gTCPSocketLog;
 #define TCPSOCKET_LOG(args)     MOZ_LOG(gTCPSocketLog, LogLevel::Debug, args)
 #define TCPSOCKET_LOG_ENABLED() MOZ_LOG_TEST(gTCPSocketLog, LogLevel::Debug)
 } // namespace net
 
 namespace dom {
 
--- a/dom/network/UDPSocket.h
+++ b/dom/network/UDPSocket.h
@@ -14,17 +14,17 @@
 #include "mozilla/dom/SocketCommonBinding.h"
 #include "nsIUDPSocket.h"
 #include "nsIUDPSocketChild.h"
 #include "nsTArray.h"
 
 struct JSContext;
 
 //
-// set NSPR_LOG_MODULES=UDPSocket:5
+// set MOZ_LOG=UDPSocket:5
 //
 
 namespace mozilla {
 namespace net {
 extern LazyLogModule gUDPSocketLog;
 #define UDPSOCKET_LOG(args)     MOZ_LOG(gUDPSocketLog, LogLevel::Debug, args)
 #define UDPSOCKET_LOG_ENABLED() MOZ_LOG_TEST(gUDPSocketLog, LogLevel::Debug)
 } // namespace net
--- a/dom/offline/nsDOMOfflineResourceList.cpp
+++ b/dom/offline/nsDOMOfflineResourceList.cpp
@@ -11,17 +11,16 @@
 #include "mozilla/dom/DOMStringList.h"
 #include "nsIPrefetchService.h"
 #include "nsCPrefetchService.h"
 #include "nsNetUtil.h"
 #include "nsNetCID.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIOfflineCacheUpdate.h"
-#include "nsAutoPtr.h"
 #include "nsContentUtils.h"
 #include "nsIObserverService.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIWebNavigation.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/OfflineResourceListBinding.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/Preferences.h"
--- a/dom/performance/PerformanceNavigation.h
+++ b/dom/performance/PerformanceNavigation.h
@@ -14,23 +14,16 @@
 
 namespace mozilla {
 namespace dom {
 
 // Script "performance.navigation" object
 class PerformanceNavigation final : public nsWrapperCache
 {
 public:
-  enum PerformanceNavigationType {
-    TYPE_NAVIGATE = 0,
-    TYPE_RELOAD = 1,
-    TYPE_BACK_FORWARD = 2,
-    TYPE_RESERVED = 255,
-  };
-
   explicit PerformanceNavigation(Performance* aPerformance);
 
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(PerformanceNavigation)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(PerformanceNavigation)
 
   nsDOMNavigationTiming* GetDOMTiming() const
   {
     return mPerformance->GetDOMTiming();
--- a/dom/plugins/base/android/ANPBase.h
+++ b/dom/plugins/base/android/ANPBase.h
@@ -1,16 +1,15 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <stdlib.h>
 #include "android_npapi.h"
-#include "nsAutoPtr.h"
 #include "nsISupportsImpl.h"
 
 #define NOT_IMPLEMENTED_FATAL() do {                                    \
     __android_log_print(ANDROID_LOG_ERROR, "GeckoPlugins",              \
                         "%s not implemented %s, %d",                    \
                         __PRETTY_FUNCTION__, __FILE__, __LINE__);       \
     abort();                                                            \
   } while(0)
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -3,16 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "base/basictypes.h"
 
 #include "jsfriendapi.h"
 #include "jswrapper.h"
 
+#include "nsAutoPtr.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsJSNPRuntime.h"
 #include "nsNPAPIPlugin.h"
 #include "nsNPAPIPluginInstance.h"
 #include "nsIGlobalObject.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptContext.h"
 #include "nsDOMJSUtils.h"
--- a/dom/plugins/base/nsNPAPIPluginInstance.h
+++ b/dom/plugins/base/nsNPAPIPluginInstance.h
@@ -14,17 +14,16 @@
 #include "nsIPluginInstanceOwner.h"
 #include "nsIURI.h"
 #include "nsIChannel.h"
 #include "nsHashKeys.h"
 #include <prinrval.h>
 #include "js/TypeDecls.h"
 #include "nsIAudioChannelAgent.h"
 #ifdef MOZ_WIDGET_ANDROID
-#include "nsAutoPtr.h"
 #include "nsIRunnable.h"
 #include "GLContextTypes.h"
 #include "AndroidSurfaceTexture.h"
 #include "AndroidBridge.h"
 #include <map>
 class PluginEventRunnable;
 #endif
 
--- a/dom/plugins/base/nsNPAPIPluginStreamListener.h
+++ b/dom/plugins/base/nsNPAPIPluginStreamListener.h
@@ -5,17 +5,16 @@
 
 #ifndef nsNPAPIPluginStreamListener_h_
 #define nsNPAPIPluginStreamListener_h_
 
 #include "nscore.h"
 #include "nsIHTTPHeaderListener.h"
 #include "nsIRequest.h"
 #include "nsITimer.h"
-#include "nsAutoPtr.h"
 #include "nsCOMArray.h"
 #include "nsIOutputStream.h"
 #include "nsIPluginInstanceOwner.h"
 #include "nsString.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "mozilla/PluginLibrary.h"
 
 #define MAX_PLUGIN_NECKO_BUFFER 16384
--- a/dom/plugins/base/nsPluginHost.h
+++ b/dom/plugins/base/nsPluginHost.h
@@ -9,17 +9,16 @@
 #include "nsIPluginHost.h"
 #include "nsIObserver.h"
 #include "nsCOMPtr.h"
 #include "prlink.h"
 #include "prclist.h"
 #include "nsIPluginTag.h"
 #include "nsPluginsDir.h"
 #include "nsPluginDirServiceProvider.h"
-#include "nsAutoPtr.h"
 #include "nsWeakPtr.h"
 #include "nsIPrompt.h"
 #include "nsWeakReference.h"
 #include "MainThreadUtils.h"
 #include "nsTArray.h"
 #include "nsTObserverArray.h"
 #include "nsITimer.h"
 #include "nsPluginTags.h"
--- a/dom/plugins/base/nsPluginLogging.h
+++ b/dom/plugins/base/nsPluginLogging.h
@@ -12,40 +12,40 @@
 
 #ifndef PLUGIN_LOGGING    // allow external override
 #define PLUGIN_LOGGING 1  // master compile-time switch for pluging logging
 #endif
 
 ////////////////////////////////////////////////////////////////////////////////
 // Basic Plugin Logging Usage Instructions
 //
-// 1. Set this environment variable: NSPR_LOG_MODULES=<name>:<level>
+// 1. Set this environment variable: MOZ_LOG=<name>:<level>
 
 // Choose the <name> and <level> from this list (no quotes):
 
 // Log Names            <name>
 #define NPN_LOG_NAME    "PluginNPN"
 #define NPP_LOG_NAME    "PluginNPP"
 #define PLUGIN_LOG_NAME "Plugin"
 
 // Levels                <level>
 #define PLUGIN_LOG_ALWAYS mozilla::LogLevel::Error
 #define PLUGIN_LOG_BASIC  mozilla::LogLevel::Info
 #define PLUGIN_LOG_NORMAL mozilla::LogLevel::Debug
 #define PLUGIN_LOG_NOISY  mozilla::LogLevel::Verbose
 
 // 2. You can combine logs and levels by separating them with a comma:
-//    My favorite Win32 Example: SET NSPR_LOG_MODULES=Plugin:5,PluginNPP:5,PluginNPN:5
+//    My favorite Win32 Example: SET MOZ_LOG=Plugin:5,PluginNPP:5,PluginNPN:5
 
 // 3. Instead of output going to the console, you can log to a file. Additionally, set the
-//    NSPR_LOG_FILE environment variable to point to the full path of a file.
-//    My favorite Win32 Example: SET NSPR_LOG_FILE=c:\temp\pluginLog.txt
+//    MOZ_LOG_FILE environment variable to point to the full path of a file.
+//    My favorite Win32 Example: SET MOZ_LOG_FILE=c:\temp\pluginLog.txt
 
-// 4. For complete information see the NSPR Reference: 
-//    http://www.mozilla.org/projects/nspr/reference/html/prlog.html
+// 4. For complete information see the Gecko Developer guide:
+// https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Gecko_Logging
 
 
 #ifdef PLUGIN_LOGGING
 
 class nsPluginLogging
 {
 public:
   static mozilla::LazyLogModule gNPNLog;  // 4.x NP API, calls into navigator
--- a/dom/plugins/base/nsPluginNativeWindow.h
+++ b/dom/plugins/base/nsPluginNativeWindow.h
@@ -2,17 +2,16 @@
 /* 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 _nsPluginNativeWindow_h_
 #define _nsPluginNativeWindow_h_
 
 #include "nscore.h"
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsISupportsImpl.h"
 #include "nsNPAPIPluginInstance.h"
 #include "npapi.h"
 #include "nsIWidget.h"
 
 /**
  * base class for native plugin window implementations
--- a/dom/plugins/base/nsPluginNativeWindowWin.cpp
+++ b/dom/plugins/base/nsPluginNativeWindowWin.cpp
@@ -16,17 +16,16 @@
 #undef GetNextSibling
 #undef GetPrevSibling
 
 #include "nsDebug.h"
 
 #include "nsWindowsDllInterceptor.h"
 #include "nsPluginNativeWindow.h"
 #include "nsThreadUtils.h"
-#include "nsAutoPtr.h"
 #include "nsTWeakRef.h"
 #include "nsCrashOnException.h"
 
 using namespace mozilla;
 
 #define NP_POPUP_API_VERSION 16
 
 #define nsMajorVersion(v)       (((int32_t)(v) >> 16) & 0xffff)
--- a/dom/plugins/base/nsPluginTags.h
+++ b/dom/plugins/base/nsPluginTags.h
@@ -3,17 +3,16 @@
  * 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 nsPluginTags_h_
 #define nsPluginTags_h_
 
 #include "mozilla/Attributes.h"
 #include "nscore.h"
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 #include "nsIPluginTag.h"
 #include "nsITimer.h"
 #include "nsString.h"
 
 class nsIURI;
 struct PRLibrary;
--- a/dom/plugins/ipc/PluginAsyncSurrogate.h
+++ b/dom/plugins/ipc/PluginAsyncSurrogate.h
@@ -6,17 +6,16 @@
 
 #ifndef dom_plugins_ipc_PluginAsyncSurrogate_h
 #define dom_plugins_ipc_PluginAsyncSurrogate_h
 
 #include "mozilla/UniquePtr.h"
 #include "npapi.h"
 #include "npfunctions.h"
 #include "npruntime.h"
-#include "nsAutoPtr.h"
 #include "nsISupportsImpl.h"
 #include "nsPluginHost.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "PluginDataResolver.h"
 
 namespace mozilla {
 namespace plugins {
--- a/dom/plugins/ipc/PluginBridge.h
+++ b/dom/plugins/ipc/PluginBridge.h
@@ -21,19 +21,16 @@ bool
 SetupBridge(uint32_t aPluginId, dom::ContentParent* aContentParent,
             bool aForceBridgeNow, nsresult* aResult, uint32_t* aRunID);
 
 nsresult
 FindPluginsForContent(uint32_t aPluginEpoch,
                       nsTArray<PluginTag>* aPlugins,
                       uint32_t* aNewPluginEpoch);
 
-base::ProcessId
-PluginProcessId(uint32_t aPluginId);
-
 void
 TerminatePlugin(uint32_t aPluginId,
                 base::ProcessId aContentProcessId,
                 const nsCString& aMonitorDescription,
                 const nsAString& aBrowserDumpId);
 
 } // namespace plugins
 } // namespace mozilla
--- a/dom/plugins/ipc/PluginInstanceParent.h
+++ b/dom/plugins/ipc/PluginInstanceParent.h
@@ -13,17 +13,16 @@
 #include "mozilla/gfx/SharedDIBWin.h"
 #include <d3d10_1.h>
 #include "nsRefPtrHashtable.h"
 #elif defined(MOZ_WIDGET_COCOA)
 #include "mozilla/gfx/QuartzSupport.h"
 #endif
 
 #include "npfunctions.h"
-#include "nsAutoPtr.h"
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 #include "nsRect.h"
 #include "PluginDataResolver.h"
 
 #include "mozilla/unused.h"
 #include "mozilla/EventForwards.h"
 
--- a/dom/plugins/ipc/PluginMessageUtils.h
+++ b/dom/plugins/ipc/PluginMessageUtils.h
@@ -13,17 +13,16 @@
 #include "mozilla/ipc/MessageChannel.h"
 #include "mozilla/ipc/CrossProcessMutex.h"
 #include "mozilla/UniquePtr.h"
 #include "gfxipc/ShadowLayerUtils.h"
 
 #include "npapi.h"
 #include "npruntime.h"
 #include "npfunctions.h"
-#include "nsAutoPtr.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "mozilla/Logging.h"
 #include "nsHashKeys.h"
 #ifdef MOZ_CRASHREPORTER
 #  include "nsExceptionHandler.h"
 #endif
 #ifdef XP_MACOSX
--- a/dom/plugins/ipc/PluginModuleChild.h
+++ b/dom/plugins/ipc/PluginModuleChild.h
@@ -14,17 +14,16 @@
 
 #include "base/basictypes.h"
 
 #include "prlink.h"
 
 #include "npapi.h"
 #include "npfunctions.h"
 
-#include "nsAutoPtr.h"
 #include "nsDataHashtable.h"
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 
 #ifdef MOZ_WIDGET_COCOA
 #include "PluginInterposeOSX.h"
 #endif
 
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -348,39 +348,16 @@ private:
 
 PRCList PluginModuleMapping::sModuleListHead =
     PR_INIT_STATIC_CLIST(&PluginModuleMapping::sModuleListHead);
 
 bool PluginModuleMapping::sIsLoadModuleOnStack = false;
 
 } // namespace
 
-base::ProcessId
-mozilla::plugins::PluginProcessId(uint32_t aPluginId)
-{
-  RefPtr<nsPluginHost> host = nsPluginHost::GetInst();
-  if (!host) {
-    return mozilla::ipc::kInvalidProcessId;
-  }
-
-  nsPluginTag* pluginTag = host->PluginWithId(aPluginId);
-  if (!pluginTag || !pluginTag->mPlugin) {
-      return mozilla::ipc::kInvalidProcessId;
-  }
-
-  RefPtr<nsNPAPIPlugin> plugin = pluginTag->mPlugin;
-  PluginModuleChromeParent* chromeParent =
-      static_cast<PluginModuleChromeParent*>(plugin->GetLibrary());
-  if (!chromeParent) {
-    return mozilla::ipc::kInvalidProcessId;
-  }
-
-  return chromeParent->OtherPid();
-}
-
 void
 mozilla::plugins::TerminatePlugin(uint32_t aPluginId,
                                   base::ProcessId aContentProcessId,
                                   const nsCString& aMonitorDescription,
                                   const nsAString& aBrowserDumpId)
 {
     MOZ_ASSERT(XRE_IsParentProcess());
 
@@ -1253,26 +1230,33 @@ PluginModuleChromeParent::TerminateChild
         }
     }
 #endif // XP_WIN
 
     bool reportsReady = false;
 
     // Check to see if we already have a browser dump id - with e10s plugin
     // hangs we take this earlier (see ProcessHangMonitor) from a background
-    // thread. It includes a content and plugin dump too.
+    // thread. We do this before we message the main thread about the hang
+    // since the posted message will trash our browser stack state.
     bool exists;
     nsCOMPtr<nsIFile> browserDumpFile;
     if (!aBrowserDumpId.IsEmpty() &&
         CrashReporter::GetMinidumpForID(aBrowserDumpId, getter_AddRefs(browserDumpFile)) &&
         browserDumpFile &&
         NS_SUCCEEDED(browserDumpFile->Exists(&exists)) && exists)
     {
-        crashReporter->UseMinidump(browserDumpFile);
-        reportsReady = true;
+        // We have a single browser report, generate a new plugin process parent
+        // report and pair it up with the browser report handed in.
+        reportsReady = crashReporter->GenerateMinidumpAndPair(this, browserDumpFile,
+                                                              NS_LITERAL_CSTRING("browser"));
+        if (!reportsReady) {
+          browserDumpFile = nullptr;
+          CrashReporter::DeleteMinidumpFilesForID(aBrowserDumpId);
+        }
     }
 
     // Generate crash report including plugin and browser process minidumps.
     // The plugin process is the parent report with additional dumps including
     // the browser process, content process when running under e10s, and
     // various flash subprocesses if we're the flash module.
     if (!reportsReady) {
         reportsReady = crashReporter->GeneratePairedMinidump(this);
@@ -1297,20 +1281,18 @@ PluginModuleChromeParent::TerminateChild
                 additionalDumps.AppendLiteral(",flash1");
             }
             if (CreatePluginMinidump(mFlashProcess2, 0, pluginDumpFile,
                                      NS_LITERAL_CSTRING("flash2"))) {
                 additionalDumps.AppendLiteral(",flash2");
             }
 #endif
             if (aContentPid != mozilla::ipc::kInvalidProcessId) {
-                // Include the content process minidump only if we don't have
-                // it already.
-                if (exists ||
-                    CreatePluginMinidump(aContentPid, 0,
+                // Include the content process minidump
+                if (CreatePluginMinidump(aContentPid, 0,
                                          pluginDumpFile,
                                          NS_LITERAL_CSTRING("content"))) {
                     additionalDumps.AppendLiteral(",content");
                 }
             }
         }
         crashReporter->AnnotateCrashReport(
             NS_LITERAL_CSTRING("additional_minidumps"),
--- a/dom/plugins/ipc/PluginModuleParent.h
+++ b/dom/plugins/ipc/PluginModuleParent.h
@@ -14,17 +14,16 @@
 #include "mozilla/plugins/PluginProcessParent.h"
 #include "mozilla/plugins/PPluginModuleParent.h"
 #include "mozilla/plugins/PluginMessageUtils.h"
 #include "mozilla/plugins/PluginTypes.h"
 #include "mozilla/plugins/TaskFactory.h"
 #include "mozilla/TimeStamp.h"
 #include "npapi.h"
 #include "npfunctions.h"
-#include "nsAutoPtr.h"
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 #include "nsIObserver.h"
 #ifdef XP_WIN
 #include "nsWindowsHelpers.h"
 #endif
 
 #ifdef MOZ_CRASHREPORTER
--- a/dom/plugins/ipc/PluginSurfaceParent.h
+++ b/dom/plugins/ipc/PluginSurfaceParent.h
@@ -2,17 +2,16 @@
 /* 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 dom_plugins_PluginSurfaceParent_h
 #define dom_plugins_PluginSurfaceParent_h
 
 #include "mozilla/plugins/PPluginSurfaceParent.h"
-#include "nsAutoPtr.h"
 #include "mozilla/plugins/PluginMessageUtils.h"
 
 #ifndef XP_WIN
 #error "This header is for Windows only."
 #endif
 
 class gfxASurface;
 
--- a/dom/plugins/ipc/PluginWidgetParent.h
+++ b/dom/plugins/ipc/PluginWidgetParent.h
@@ -1,16 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_plugins_PluginWidgetParent_h
 #define mozilla_plugins_PluginWidgetParent_h
 
 #include "mozilla/plugins/PPluginWidgetParent.h"
+#include "nsAutoPtr.h"
 #include "nsIWidget.h"
 #include "nsCOMPtr.h"
 
 #if defined(MOZ_WIDGET_GTK)
 class nsPluginNativeWindowGtk;
 #endif
 
 namespace mozilla {
--- a/dom/plugins/test/reftest/reftest.list
+++ b/dom/plugins/test/reftest/reftest.list
@@ -1,17 +1,18 @@
 # basic sanity checking
 random-if(!haveTestPlugin) != plugin-sanity.html about:blank
 fails-if(!haveTestPlugin) == plugin-sanity.html div-sanity.html
 fails-if(!haveTestPlugin) fuzzy-if(skiaContent,1,160000) == plugin-alpha-zindex.html div-alpha-zindex.html
 fails-if(!haveTestPlugin) fuzzy-if(skiaContent,1,164000) == plugin-alpha-opacity.html div-alpha-opacity.html
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == windowless-clipping-1.html windowless-clipping-1-ref.html # bug 631832
-random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == border-padding-1.html border-padding-1-ref.html # bug 629430
-random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == border-padding-2.html border-padding-2-ref.html # bug 629430
-random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) skip-if(!haveTestPlugin) skip-if(Android||B2G) == border-padding-3.html border-padding-3-ref.html # bug 629430 # bug 773482
+# fuzzy because of anti-aliasing in dashed border
+fuzzy(16,256) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == border-padding-1.html border-padding-1-ref.html # bug 629430
+fuzzy(16,256) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == border-padding-2.html border-padding-2-ref.html # bug 629430
+fuzzy(16,256) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) skip-if(!haveTestPlugin) skip-if(Android||B2G) == border-padding-3.html border-padding-3-ref.html # bug 629430 # bug 773482
 # The following two "pluginproblemui-direction" tests are unreliable on all platforms. They should be re-written or replaced.
 #random-if(cocoaWidget||d2d||/^Windows\x20NT\x205\.1/.test(http.oscpu)) fails-if(!haveTestPlugin&&!Android) == pluginproblemui-direction-1.html pluginproblemui-direction-1-ref.html # bug 567367
 #random-if(cocoaWidget) fails-if(!haveTestPlugin&&!Android) == pluginproblemui-direction-2.html pluginproblemui-direction-2-ref.html
 fails-if(!haveTestPlugin) fuzzy-if(skiaContent,1,160000) == plugin-canvas-alpha-zindex.html div-alpha-zindex.html
 fails-if(!haveTestPlugin) fuzzy-if(skiaContent,1,160000) == plugin-transform-alpha-zindex.html div-alpha-zindex.html
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) fuzzy-if(skiaContent,1,160000) == plugin-busy-alpha-zindex.html div-alpha-zindex.html
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) fuzzy-if(skiaContent,1,32400) == plugin-background.html plugin-background-ref.html
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) fuzzy-if(skiaContent,1,32400) == plugin-background-1-step.html plugin-background-ref.html
--- a/dom/presentation/PresentationLog.h
+++ b/dom/presentation/PresentationLog.h
@@ -3,17 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_PresentationLog_h
 #define mozilla_dom_PresentationLog_h
 
 /*
- * NSPR_LOG_MODULES=Presentation:5
+ * MOZ_LOG=Presentation:5
  * For detail, see PresentationService.cpp
  */
 namespace mozilla {
 namespace dom {
 extern mozilla::LazyLogModule gPresentationLog;
 }
 }
 
--- a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp
+++ b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MulticastDNSDeviceProvider.h"
 #include "MainThreadUtils.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/unused.h"
-#include "nsAutoPtr.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIObserverService.h"
 #include "nsServiceManagerUtils.h"
 #include "nsTCPDeviceInfo.h"
 #include "nsThreadUtils.h"
 
 #ifdef MOZ_WIDGET_ANDROID
 #include "nsIPropertyBag2.h"
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -935,16 +935,45 @@ Promise::MaybeReject(const RefPtr<MediaS
 void
 Promise::MaybeRejectWithNull()
 {
   NS_ASSERT_OWNINGTHREAD(Promise);
 
   MaybeSomething(JS::NullHandleValue, &Promise::MaybeReject);
 }
 
+
+#ifdef SPIDERMONKEY_PROMISE
+void
+Promise::ReportRejectedPromise(JSContext* aCx, JS::HandleObject aPromise)
+{
+  MOZ_ASSERT(!js::IsWrapper(aPromise));
+
+  MOZ_ASSERT(JS::GetPromiseState(aPromise) == JS::PromiseState::Rejected);
+
+  JS::Rooted<JS::Value> result(aCx, JS::GetPromiseResult(aPromise));
+
+  js::ErrorReport report(aCx);
+  if (!report.init(aCx, result, js::ErrorReport::NoSideEffects)) {
+    JS_ClearPendingException(aCx);
+    return;
+  }
+
+  RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
+  bool isMainThread = MOZ_LIKELY(NS_IsMainThread());
+  bool isChrome = isMainThread ? nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(aPromise))
+                               : GetCurrentThreadWorkerPrivate()->IsChromeWorker();
+  nsGlobalWindow* win = isMainThread ? xpc::WindowGlobalOrNull(aPromise) : nullptr;
+  xpcReport->Init(report.report(), report.message(), isChrome, win ? win->AsInner()->WindowID() : 0);
+
+  // Now post an event to do the real reporting async
+  NS_DispatchToMainThread(new AsyncErrorReporter(xpcReport));
+}
+#endif // defined(SPIDERMONKEY_PROMISE)
+
 bool
 Promise::PerformMicroTaskCheckpoint()
 {
   MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
 
   CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get();
 
   // On the main thread, we always use the main promise micro task queue.
--- a/dom/promise/Promise.h
+++ b/dom/promise/Promise.h
@@ -21,17 +21,17 @@
 #include "js/TypeDecls.h"
 #include "jspubtd.h"
 
 // Bug 1083361 introduces a new mechanism for tracking uncaught
 // rejections. This #define serves to track down the parts of code
 // that need to be removed once clients have been put together
 // to take advantage of the new mechanism. New code should not
 // depend on code #ifdefed to this #define.
-#define DOM_PROMISE_DEPRECATED_REPORTING 1
+#define DOM_PROMISE_DEPRECATED_REPORTING !SPIDERMONKEY_PROMISE
 
 #if defined(DOM_PROMISE_DEPRECATED_REPORTING)
 #include "mozilla/dom/workers/bindings/WorkerFeature.h"
 #endif // defined(DOM_PROMISE_DEPRECATED_REPORTING)
 
 class nsIGlobalObject;
 
 namespace mozilla {
@@ -107,16 +107,19 @@ public:
 
   // Promise creation tries to create a JS reflector for the Promise, so is
   // fallible.  Furthermore, we don't want to do JS-wrapping on a 0-refcount
   // object, so we addref before doing that and return the addrefed pointer
   // here.
 #ifdef SPIDERMONKEY_PROMISE
   static already_AddRefed<Promise>
   Create(nsIGlobalObject* aGlobal, ErrorResult& aRv);
+
+  // Reports a rejected Promise by sending an error report.
+  static void ReportRejectedPromise(JSContext* aCx, JS::HandleObject aPromise);
 #else
   static already_AddRefed<Promise>
   Create(nsIGlobalObject* aGlobal, ErrorResult& aRv,
          // Passing null for aDesiredProto will use Promise.prototype.
          JS::Handle<JSObject*> aDesiredProto = nullptr);
 #endif // SPIDERMONKEY_PROMISE
 
   typedef void (Promise::*MaybeFunc)(JSContext* aCx,
--- a/dom/promise/PromiseDebugging.cpp
+++ b/dom/promise/PromiseDebugging.cpp
@@ -225,21 +225,18 @@ PromiseDebugging::Init()
 PromiseDebugging::Shutdown()
 {
   sIDPrefix.SetIsVoid(true);
 }
 
 /* static */ void
 PromiseDebugging::FlushUncaughtRejections()
 {
-  // XXXbz figure out the plan
-#ifndef SPIDERMONKEY_PROMISE
   MOZ_ASSERT(!NS_IsMainThread());
   FlushRejections::FlushSync();
-#endif // SPIDERMONKEY_PROMISE
 }
 
 #ifndef SPIDERMONKEY_PROMISE
 
 /* static */ void
 PromiseDebugging::GetAllocationStack(GlobalObject&, JS::Handle<JSObject*> aPromise,
                                      JS::MutableHandle<JSObject*> aStack,
                                      ErrorResult& aRv)
@@ -337,17 +334,100 @@ PromiseDebugging::RemoveUncaughtRejectio
     if (*observer == aObserver) {
       observers.RemoveElementAt(i);
       return true;
     }
   }
   return false;
 }
 
-#ifndef SPIDERMONKEY_PROMISE
+#ifdef SPIDERMONKEY_PROMISE
+
+/* static */ void
+PromiseDebugging::AddUncaughtRejection(JS::HandleObject aPromise)
+{
+  // This might OOM, but won't set a pending exception, so we'll just ignore it.
+  if (CycleCollectedJSRuntime::Get()->mUncaughtRejections.append(aPromise)) {
+    FlushRejections::DispatchNeeded();
+  }
+}
+
+/* void */ void
+PromiseDebugging::AddConsumedRejection(JS::HandleObject aPromise)
+{
+  // If the promise is in our list of uncaught rejections, we haven't yet
+  // reported it as unhandled. In that case, just remove it from the list
+  // and don't add it to the list of consumed rejections.
+  auto& uncaughtRejections = CycleCollectedJSRuntime::Get()->mUncaughtRejections;
+  for (size_t i = 0; i < uncaughtRejections.length(); i++) {
+    if (uncaughtRejections[i] == aPromise) {
+      // To avoid large amounts of memmoves, we don't shrink the vector here.
+      // Instead, we filter out nullptrs when iterating over the vector later.
+      uncaughtRejections[i].set(nullptr);
+      return;
+    }
+  }
+  // This might OOM, but won't set a pending exception, so we'll just ignore it.
+  if (CycleCollectedJSRuntime::Get()->mConsumedRejections.append(aPromise)) {
+    FlushRejections::DispatchNeeded();
+  }
+}
+
+/* static */ void
+PromiseDebugging::FlushUncaughtRejectionsInternal()
+{
+  CycleCollectedJSRuntime* storage = CycleCollectedJSRuntime::Get();
+
+  auto& uncaught = storage->mUncaughtRejections;
+  auto& consumed = storage->mConsumedRejections;
+
+  AutoJSAPI jsapi;
+  jsapi.Init();
+  JSContext* cx = jsapi.cx();
+
+  // Notify observers of uncaught Promise.
+  auto& observers = storage->mUncaughtRejectionObservers;
+
+  for (size_t i = 0; i < uncaught.length(); i++) {
+    JS::RootedObject promise(cx, uncaught[i]);
+    // Filter out nullptrs which might've been added by
+    // PromiseDebugging::AddConsumedRejection.
+    if (!promise) {
+      continue;
+    }
+
+    for (size_t j = 0; j < observers.Length(); ++j) {
+      RefPtr<UncaughtRejectionObserver> obs =
+        static_cast<UncaughtRejectionObserver*>(observers[j].get());
+
+      IgnoredErrorResult err;
+      obs->OnLeftUncaught(promise, err);
+    }
+    JSAutoCompartment ac(cx, promise);
+    Promise::ReportRejectedPromise(cx, promise);
+  }
+  storage->mUncaughtRejections.clear();
+
+  // Notify observers of consumed Promise.
+
+  for (size_t i = 0; i < consumed.length(); i++) {
+    JS::RootedObject promise(cx, consumed[i]);
+
+    for (size_t j = 0; j < observers.Length(); ++j) {
+      RefPtr<UncaughtRejectionObserver> obs =
+        static_cast<UncaughtRejectionObserver*>(observers[j].get());
+
+      IgnoredErrorResult err;
+      obs->OnConsumed(promise, err);
+    }
+  }
+  storage->mConsumedRejections.clear();
+}
+
+#else
 
 /* static */ void
 PromiseDebugging::AddUncaughtRejection(Promise& aPromise)
 {
   CycleCollectedJSRuntime::Get()->mUncaughtRejections.AppendElement(&aPromise);
   FlushRejections::DispatchNeeded();
 }
 
@@ -367,23 +447,20 @@ PromiseDebugging::GetPromiseID(GlobalObj
   Promise* promise = UnwrapPromise(aPromise, aRv);
   if (aRv.Failed()) {
     return;
   }
   uint64_t promiseID = promise->GetID();
   aID = sIDPrefix;
   aID.AppendInt(promiseID);
 }
-#endif // SPIDERMONKEY_PROMISE
 
 /* static */ void
 PromiseDebugging::FlushUncaughtRejectionsInternal()
 {
-  // XXXbz talk to till about replacement for this stuff.
-#ifndef SPIDERMONKEY_PROMISE
   CycleCollectedJSRuntime* storage = CycleCollectedJSRuntime::Get();
 
   // The Promise that have been left uncaught (rejected and last in
   // their chain) since the last call to this function.
   nsTArray<nsCOMPtr<nsISupports>> uncaught;
   storage->mUncaughtRejections.SwapElements(uncaught);
 
   // The Promise that have been left uncaught at some point, but that
@@ -434,13 +511,13 @@ PromiseDebugging::FlushUncaughtRejection
     for (size_t j = 0; j < observers.Length(); ++j) {
       ErrorResult err;
       RefPtr<UncaughtRejectionObserver> obs =
         static_cast<UncaughtRejectionObserver*>(observers[j].get());
 
       obs->OnConsumed(*promise, err); // Ignore errors
     }
   }
+}
 #endif // SPIDERMONKEY_PROMISE
-}
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/promise/PromiseDebugging.h
+++ b/dom/promise/PromiseDebugging.h
@@ -21,16 +21,18 @@ class WorkerPrivate;
 } // namespace workers
 
 class Promise;
 struct PromiseDebuggingStateHolder;
 class GlobalObject;
 class UncaughtRejectionObserver;
 class FlushRejections;
 
+void TriggerFlushRejections();
+
 class PromiseDebugging
 {
 public:
   static void Init();
   static void Shutdown();
 
   static void GetState(GlobalObject&, JS::Handle<JSObject*> aPromise,
                        PromiseDebuggingStateHolder& aState,
@@ -58,32 +60,36 @@ public:
   static double GetPromiseLifetime(GlobalObject&,
                                    JS::Handle<JSObject*> aPromise,
                                    ErrorResult& aRv);
   static double GetTimeToSettle(GlobalObject&, JS::Handle<JSObject*> aPromise,
                                 ErrorResult& aRv);
 #endif // SPIDERMONKEY_PROMISE
 
   // Mechanism for watching uncaught instances of Promise.
-  // XXXbz figure out the plan
   static void AddUncaughtRejectionObserver(GlobalObject&,
                                            UncaughtRejectionObserver& aObserver);
   static bool RemoveUncaughtRejectionObserver(GlobalObject&,
                                               UncaughtRejectionObserver& aObserver);
 
-#ifndef SPIDERMONKEY_PROMISE
+#ifdef SPIDERMONKEY_PROMISE
+  // Mark a Promise as having been left uncaught at script completion.
+  static void AddUncaughtRejection(JS::HandleObject);
+  // Mark a Promise previously added with `AddUncaughtRejection` as
+  // eventually consumed.
+  static void AddConsumedRejection(JS::HandleObject);
+#else
   // Mark a Promise as having been left uncaught at script completion.
   static void AddUncaughtRejection(Promise&);
   // Mark a Promise previously added with `AddUncaughtRejection` as
   // eventually consumed.
   static void AddConsumedRejection(Promise&);
 #endif // SPIDERMONKEY_PROMISE
   // Propagate the informations from AddUncaughtRejection
   // and AddConsumedRejection to observers.
-  // XXXbz figure out the plan.
   static void FlushUncaughtRejections();
 
 protected:
   static void FlushUncaughtRejectionsInternal();
   friend class FlushRejections;
   friend class WorkerPrivate;
 private:
   // Identity of the process.
--- a/dom/quota/QuotaCommon.h
+++ b/dom/quota/QuotaCommon.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_quota_quotacommon_h__
 #define mozilla_dom_quota_quotacommon_h__
 
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsPrintfCString.h"
 #include "nsString.h"
 #include "nsTArray.h"
 
 #define BEGIN_QUOTA_NAMESPACE \
   namespace mozilla { namespace dom { namespace quota {
--- a/dom/quota/QuotaManagerService.h
+++ b/dom/quota/QuotaManagerService.h
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_quota_QuotaManagerService_h
 #define mozilla_dom_quota_QuotaManagerService_h
 
 #include "mozilla/dom/ipc/IdType.h"
+#include "nsAutoPtr.h"
 #include "nsIObserver.h"
 #include "nsIQuotaManagerService.h"
 
 #define QUOTAMANAGER_SERVICE_CONTRACTID \
   "@mozilla.org/dom/quota-manager-service;1"
 
 namespace mozilla {
 namespace ipc {
--- a/dom/smil/nsSMILAnimationFunction.cpp
+++ b/dom/smil/nsSMILAnimationFunction.cpp
@@ -13,17 +13,16 @@
 #include "nsSMILParserUtils.h"
 #include "nsSMILNullType.h"
 #include "nsSMILTimedElement.h"
 #include "nsAttrValueInlines.h"
 #include "nsGkAtoms.h"
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 #include "nsIContent.h"
-#include "nsAutoPtr.h"
 #include "nsContentUtils.h"
 #include "nsReadableUtils.h"
 #include "nsString.h"
 #include <math.h>
 #include <algorithm>
 
 using namespace mozilla::dom;
 
--- a/dom/smil/nsSMILAnimationFunction.h
+++ b/dom/smil/nsSMILAnimationFunction.h
@@ -9,17 +9,16 @@
 
 #include "nsISMILAttr.h"
 #include "nsGkAtoms.h"
 #include "nsString.h"
 #include "nsSMILTargetIdentifier.h"
 #include "nsSMILTimeValue.h"
 #include "nsSMILKeySpline.h"
 #include "nsSMILValue.h"
-#include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "nsAttrValue.h"
 #include "nsSMILTypes.h"
 
 namespace mozilla {
 namespace dom {
 class SVGAnimationElement;
 } // namespace dom
--- a/dom/smil/nsSMILCompositor.h
+++ b/dom/smil/nsSMILCompositor.h
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef NS_SMILCOMPOSITOR_H_
 #define NS_SMILCOMPOSITOR_H_
 
 #include "mozilla/Move.h"
+#include "nsAutoPtr.h"
 #include "nsTHashtable.h"
 #include "nsString.h"
 #include "nsSMILAnimationFunction.h"
 #include "nsSMILTargetIdentifier.h"
 #include "nsSMILCompositorTable.h"
 #include "PLDHashTable.h"
 
 //----------------------------------------------------------------------
--- a/dom/smil/nsSMILInstanceTime.h
+++ b/dom/smil/nsSMILInstanceTime.h
@@ -3,17 +3,16 @@
 /* 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 NS_SMILINSTANCETIME_H_
 #define NS_SMILINSTANCETIME_H_
 
 #include "nsSMILTimeValue.h"
-#include "nsAutoPtr.h"
 
 class nsSMILInterval;
 class nsSMILTimeContainer;
 class nsSMILTimeValueSpec;
 
 //----------------------------------------------------------------------
 // nsSMILInstanceTime
 //
--- a/dom/smil/nsSMILTargetIdentifier.h
+++ b/dom/smil/nsSMILTargetIdentifier.h
@@ -3,17 +3,16 @@
 /* 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 NS_SMILTARGETIDENTIFIER_H_
 #define NS_SMILTARGETIDENTIFIER_H_
 
 #include "mozilla/dom/Element.h"
-#include "nsAutoPtr.h"
 
 /**
  * Struct: nsSMILTargetIdentifier
  *
  * Tuple of: { Animated Element, Attribute Name, Attribute Type (CSS vs. XML) }
  *
  * Used in nsSMILAnimationController as hash key for mapping an animation
  * target to the nsSMILCompositor for that target.
--- a/dom/smil/nsSMILTimeContainer.h
+++ b/dom/smil/nsSMILTimeContainer.h
@@ -6,17 +6,16 @@
 
 #ifndef NS_SMILTIMECONTAINER_H_
 #define NS_SMILTIMECONTAINER_H_
 
 #include "mozilla/dom/SVGAnimationElement.h"
 #include "nscore.h"
 #include "nsSMILTypes.h"
 #include "nsTPriorityQueue.h"
-#include "nsAutoPtr.h"
 #include "nsSMILMilestone.h"
 
 class nsSMILTimeValue;
 
 //----------------------------------------------------------------------
 // nsSMILTimeContainer
 //
 // Common base class for a time base that can be paused, resumed, and sampled.
--- a/dom/smil/nsSMILTimeValueSpec.h
+++ b/dom/smil/nsSMILTimeValueSpec.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef NS_SMILTIMEVALUESPEC_H_
 #define NS_SMILTIMEVALUESPEC_H_
 
 #include "mozilla/Attributes.h"
 #include "nsSMILTimeValueSpecParams.h"
 #include "nsReferencedElement.h"
-#include "nsAutoPtr.h"
 #include "nsIDOMEventListener.h"
 
 class nsAString;
 class nsSMILTimeValue;
 class nsSMILTimedElement;
 class nsSMILTimeContainer;
 class nsSMILInstanceTime;
 class nsSMILInterval;
--- a/dom/smil/nsSMILTimeValueSpecParams.h
+++ b/dom/smil/nsSMILTimeValueSpecParams.h
@@ -3,17 +3,16 @@
 /* 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 NS_SMILTIMEVALUESPECPARAMS_H_
 #define NS_SMILTIMEVALUESPECPARAMS_H_
 
 #include "nsSMILTimeValue.h"
-#include "nsAutoPtr.h"
 #include "nsIAtom.h"
 
 //----------------------------------------------------------------------
 // nsSMILTimeValueSpecParams
 //
 // A simple data type for storing the result of parsing a single begin or end
 // value (e.g. the '5s' in begin="5s; indefinite; a.begin+2s").
 
--- a/dom/smil/nsSMILTimedElement.cpp
+++ b/dom/smil/nsSMILTimedElement.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/DebugOnly.h"
 
 #include "mozilla/ContentEvents.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/dom/SVGAnimationElement.h"
+#include "nsAutoPtr.h"
 #include "nsSMILTimedElement.h"
 #include "nsAttrValueInlines.h"
 #include "nsSMILAnimationFunction.h"
 #include "nsSMILTimeValue.h"
 #include "nsSMILTimeValueSpec.h"
 #include "nsSMILInstanceTime.h"
 #include "nsSMILParserUtils.h"
 #include "nsSMILTimeContainer.h"
--- a/dom/speakermanager/SpeakerManagerService.h
+++ b/dom/speakermanager/SpeakerManagerService.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_SpeakerManagerService_h__
 #define mozilla_dom_SpeakerManagerService_h__
 
-#include "nsAutoPtr.h"
 #include "nsIObserver.h"
 #include "nsTArray.h"
 #include "SpeakerManager.h"
 #include "nsIAudioManager.h"
 #include "nsCheapSets.h"
 #include "nsHashKeys.h"
 
 namespace mozilla {
--- a/dom/speakermanager/SpeakerManagerServiceChild.h
+++ b/dom/speakermanager/SpeakerManagerServiceChild.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_SpeakerManagerServicechild_h__
 #define mozilla_dom_SpeakerManagerServicechild_h__
 
-#include "nsAutoPtr.h"
 #include "nsISupports.h"
 #include "SpeakerManagerService.h"
 
 namespace mozilla {
 namespace dom {
 /* This class is used to do the IPC to enable/disable speaker status
    Also handle the application speaker competition problem
 */
--- a/dom/storage/DOMStorage.h
+++ b/dom/storage/DOMStorage.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsDOMStorage_h___
 #define nsDOMStorage_h___
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "nsIDOMStorage.h"
-#include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWeakReference.h"
 #include "nsWrapperCache.h"
 #include "nsISupports.h"
 
 class nsIPrincipal;
 class nsPIDOMWindowInner;
 
--- a/dom/storage/DOMStorageCache.cpp
+++ b/dom/storage/DOMStorageCache.cpp
@@ -6,16 +6,17 @@
 
 #include "DOMStorageCache.h"
 
 #include "DOMStorage.h"
 #include "DOMStorageDBThread.h"
 #include "DOMStorageIPC.h"
 #include "DOMStorageManager.h"
 
+#include "nsAutoPtr.h"
 #include "nsDOMString.h"
 #include "nsXULAppAPI.h"
 #include "mozilla/unused.h"
 #include "nsProxyRelease.h"
 #include "nsThreadUtils.h"
 
 namespace mozilla {
 namespace dom {
--- a/dom/storage/DOMStorageCache.h
+++ b/dom/storage/DOMStorageCache.h
@@ -11,17 +11,16 @@
 #include "nsITimer.h"
 
 #include "nsString.h"
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Atomics.h"
-#include "nsAutoPtr.h"
 
 namespace mozilla {
 namespace dom {
 
 class DOMStorage;
 class DOMStorageUsage;
 class DOMStorageManager;
 class DOMStorageDBBridge;
--- a/dom/storage/DOMStorageDBThread.h
+++ b/dom/storage/DOMStorageDBThread.h
@@ -9,16 +9,17 @@
 
 #include "prthread.h"
 #include "prinrval.h"
 #include "nsTArray.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/storage/StatementCache.h"
+#include "nsAutoPtr.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsClassHashtable.h"
 #include "nsIFile.h"
 #include "nsIThreadInternal.h"
 
 class mozIStorageConnection;
 
--- a/dom/storage/DOMStorageIPC.h
+++ b/dom/storage/DOMStorageIPC.h
@@ -8,16 +8,17 @@
 #define nsDOMStorageIPC_h___
 
 #include "mozilla/dom/PStorageChild.h"
 #include "mozilla/dom/PStorageParent.h"
 #include "DOMStorageDBThread.h"
 #include "DOMStorageCache.h"
 #include "DOMStorageObserver.h"
 #include "mozilla/Mutex.h"
+#include "nsAutoPtr.h"
 
 namespace mozilla {
 
 class OriginAttributesPattern;
 
 namespace dom {
 
 class DOMLocalStorageManager;
--- a/dom/svg/DOMSVGAnimatedLengthList.h
+++ b/dom/svg/DOMSVGAnimatedLengthList.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_DOMSVGANIMATEDLENGTHLIST_H__
 #define MOZILLA_DOMSVGANIMATEDLENGTHLIST_H__
 
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsSVGElement.h"
 #include "mozilla/Attributes.h"
 
 namespace mozilla {
 
 class SVGAnimatedLengthList;
--- a/dom/svg/DOMSVGAnimatedNumberList.h
+++ b/dom/svg/DOMSVGAnimatedNumberList.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_DOMSVGANIMATEDNUMBERLIST_H__
 #define MOZILLA_DOMSVGANIMATEDNUMBERLIST_H__
 
-#include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsSVGElement.h"
 #include "nsWrapperCache.h"
 #include "mozilla/Attributes.h"
 
 namespace mozilla {
 
--- a/dom/svg/DOMSVGLength.h
+++ b/dom/svg/DOMSVGLength.h
@@ -3,17 +3,16 @@
 /* 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 MOZILLA_DOMSVGLENGTH_H__
 #define MOZILLA_DOMSVGLENGTH_H__
 
 #include "DOMSVGLengthList.h"
-#include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsDebug.h"
 #include "nsIDOMSVGLength.h"
 #include "nsTArray.h"
 #include "SVGLength.h"
 #include "mozilla/Attributes.h"
 #include "nsWrapperCache.h"
 
--- a/dom/svg/DOMSVGLengthList.h
+++ b/dom/svg/DOMSVGLengthList.h
@@ -3,17 +3,16 @@
 /* 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 MOZILLA_DOMSVGLENGTHLIST_H__
 #define MOZILLA_DOMSVGLENGTHLIST_H__
 
 #include "DOMSVGAnimatedLengthList.h"
-#include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsDebug.h"
 #include "nsTArray.h"
 #include "SVGLengthList.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 
 class nsSVGElement;
--- a/dom/svg/DOMSVGNumber.h
+++ b/dom/svg/DOMSVGNumber.h
@@ -3,17 +3,16 @@
 /* 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 MOZILLA_DOMSVGNUMBER_H__
 #define MOZILLA_DOMSVGNUMBER_H__
 
 #include "DOMSVGNumberList.h"
-#include "nsAutoPtr.h"