Merge inbound to m-c a=merge
authorWes Kocher <wkocher@mozilla.com>
Wed, 07 Sep 2016 17:54:24 -0700
changeset 313101 3f6286f7ce480c890cfe5a97149dfc86bff797b7
parent 313100 7c655e03eef77b961ad44f62aaa0221b7cc51a43 (current diff)
parent 313039 7452e706f98556cec41158761f700b84d726ec98 (diff)
child 313102 95c87737b9d769f9c0e5ff9dc03b5cb2e75fbc38
push id81541
push userkwierso@gmail.com
push dateThu, 08 Sep 2016 01:07:24 +0000
treeherdermozilla-inbound@a8df6215f6c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge inbound to m-c a=merge
dom/alarm/AlarmDB.jsm
dom/alarm/AlarmHalService.cpp
dom/alarm/AlarmHalService.h
dom/alarm/AlarmService.jsm
dom/alarm/AlarmsManager.js
dom/alarm/AlarmsManager.manifest
dom/alarm/moz.build
dom/alarm/nsIAlarmHalService.idl
dom/alarm/test/chrome.ini
dom/alarm/test/file_empty.html
dom/alarm/test/mochitest.ini
dom/alarm/test/system_message_chrome_script.js
dom/alarm/test/test_alarm_add_data.html
dom/alarm/test/test_alarm_add_date.html
dom/alarm/test/test_alarm_add_respectTimezone.html
dom/alarm/test/test_alarm_change_system_clock.js
dom/alarm/test/test_alarm_non_permitted_app.html
dom/alarm/test/test_alarm_permitted_app.html
dom/alarm/test/test_alarm_remove.html
dom/alarm/test/test_bug1015540.html
dom/alarm/test/test_bug1037079.html
dom/alarm/test/test_bug1090896.html
dom/alarm/test/xpcshell.ini
dom/html/HTMLButtonElement.cpp
dom/html/HTMLInputElement.cpp
dom/html/HTMLMediaElement.cpp
dom/permission/tests/test_alarms.html
dom/webidl/AlarmsManager.webidl
dom/webidl/moz.build
hal/tests/browser.ini
hal/tests/browser_alarms.js
hal/tests/moz.build
js/src/jit-test/tests/wasm/basic-bce.js
js/src/jit-test/tests/wasm/basic-const.js
js/src/jit-test/tests/wasm/basic-control-flow.js
js/src/jit-test/tests/wasm/basic-float.js
js/src/jit-test/tests/wasm/basic-grow-memory.js
js/src/jit-test/tests/wasm/basic-integer.js
js/src/jit-test/tests/wasm/basic-memory.js
js/src/jit-test/tests/wasm/random-control-flow.js
testing/web-platform/meta/html/semantics/scripting-1/the-script-element/fetch-src/empty-with-base.html.ini
testing/web-platform/meta/html/semantics/scripting-1/the-script-element/fetch-src/empty.html.ini
testing/web-platform/meta/old-tests/submission/Opera/script_scheduling/137.html.ini
toolkit/components/places/nsNavHistoryResult.cpp
toolkit/components/telemetry/nsITelemetry.idl
--- a/accessible/xul/XULTreeAccessible.cpp
+++ b/accessible/xul/XULTreeAccessible.cpp
@@ -119,17 +119,16 @@ XULTreeAccessible::Value(nsString& aValu
 
   // Return the value is the first selected child.
   nsCOMPtr<nsITreeSelection> selection;
   mTreeView->GetSelection(getter_AddRefs(selection));
   if (!selection)
     return;
 
   int32_t currentIndex;
-  nsCOMPtr<nsIDOMElement> selectItem;
   selection->GetCurrentIndex(&currentIndex);
   if (currentIndex >= 0) {
     nsCOMPtr<nsITreeColumn> keyCol;
 
     nsCOMPtr<nsITreeColumns> cols;
     mTree->GetColumns(getter_AddRefs(cols));
     if (cols)
       cols->GetKeyColumn(getter_AddRefs(keyCol));
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -398,19 +398,16 @@ pref("network.gonk.ms-release-mms-connec
 // Shortnumber matching needed for e.g. Brazil:
 // 03187654321 can be found with 87654321
 pref("dom.phonenumber.substringmatching.BR", 8);
 pref("dom.phonenumber.substringmatching.CO", 10);
 pref("dom.phonenumber.substringmatching.VE", 7);
 pref("dom.phonenumber.substringmatching.CL", 8);
 pref("dom.phonenumber.substringmatching.PE", 7);
 
-// WebAlarms
-pref("dom.mozAlarms.enabled", true);
-
 // NetworkStats
 #ifdef MOZ_WIDGET_GONK
 pref("dom.mozNetworkStats.enabled", true);
 pref("dom.webapps.firstRunWithSIM", true);
 #endif
 
 // ResourceStats
 #ifdef MOZ_WIDGET_GONK
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -165,17 +165,16 @@
 #ifdef MOZ_B2G_BT
 @RESPATH@/components/dom_bluetooth.xpt
 #endif
 #ifdef MOZ_B2G_CAMERA
 @RESPATH@/components/dom_camera.xpt
 #endif
 @RESPATH@/components/dom_canvas.xpt
 @RESPATH@/components/dom_contacts.xpt
-@RESPATH@/components/dom_alarm.xpt
 @RESPATH@/components/dom_core.xpt
 @RESPATH@/components/dom_css.xpt
 @RESPATH@/components/dom_events.xpt
 @RESPATH@/components/dom_geolocation.xpt
 @RESPATH@/components/dom_media.xpt
 @RESPATH@/components/dom_network.xpt
 #ifdef MOZ_SECUREELEMENT
 @RESPATH@/components/dom_secureelement.xpt
@@ -358,18 +357,16 @@
 @RESPATH@/components/PhoneNumberService.js
 @RESPATH@/components/PhoneNumberService.manifest
 @RESPATH@/components/NotificationStorage.js
 @RESPATH@/components/NotificationStorage.manifest
 @RESPATH@/components/PermissionSettings.js
 @RESPATH@/components/PermissionSettings.manifest
 @RESPATH@/components/PermissionPromptService.js
 @RESPATH@/components/PermissionPromptService.manifest
-@RESPATH@/components/AlarmsManager.js
-@RESPATH@/components/AlarmsManager.manifest
 @RESPATH@/components/FeedProcessor.manifest
 @RESPATH@/components/FeedProcessor.js
 @RESPATH@/components/PackagedAppUtils.manifest
 @RESPATH@/components/PackagedAppUtils.js
 @RESPATH@/components/BrowserFeeds.manifest
 @RESPATH@/components/FeedConverter.js
 @RESPATH@/components/FeedWriter.js
 @RESPATH@/components/WebContentConverter.js
--- a/browser/base/content/abouthome/aboutHome.css
+++ b/browser/base/content/abouthome/aboutHome.css
@@ -102,42 +102,41 @@ a {
 #searchText[keepfocus],
 #searchText:focus,
 #searchText[autofocus] {
   border-color: hsla(206,100%,60%,.6) hsla(206,76%,52%,.6) hsla(204,100%,40%,.6);
 }
 
 #searchSubmit {
   margin-inline-start: -1px;
+  color: transparent;
   background: url("chrome://browser/skin/search-arrow-go.svg#search-arrow-go") center center no-repeat, linear-gradient(hsla(0,0%,100%,.8), hsla(0,0%,100%,.1)) padding-box;
   padding: 0;
   border: 1px solid;
   border-color: hsla(210,54%,20%,.15) hsla(210,54%,20%,.17) hsla(210,54%,20%,.2);
   border-radius: 0 2px 2px 0;
   border-inline-start: 1px solid transparent;
   box-shadow: 0 0 2px hsla(0,0%,100%,.5) inset,
               0 1px 0 hsla(0,0%,100%,.2);
-  color: inherit;
   cursor: pointer;
   transition-property: background-color, border-color, box-shadow;
   transition-duration: 150ms;
   width: 50px;
 }
 
 #searchSubmit:dir(rtl) {
   border-radius: 2px 0 0 2px;
   background-image: url("chrome://browser/skin/search-arrow-go.svg#search-arrow-go-rtl"), linear-gradient(hsla(0,0%,100%,.8), hsla(0,0%,100%,.1));
 }
 
 #searchText:focus + #searchSubmit,
 #searchText[keepfocus] + #searchSubmit,
 #searchText + #searchSubmit:hover,
 #searchText[autofocus] + #searchSubmit {
   border-color: #59b5fc #45a3e7 #3294d5;
-  color: white;
 }
 
 #searchText:focus + #searchSubmit,
 #searchText[keepfocus] + #searchSubmit,
 #searchText[autofocus] + #searchSubmit {
   background-image: url("chrome://browser/skin/search-arrow-go.svg#search-arrow-go-inverted"), linear-gradient(#4cb1ff, #1793e5);
   box-shadow: 0 1px 0 hsla(0,0%,100%,.2) inset,
               0 0 0 1px hsla(0,0%,100%,.1) inset,
--- a/browser/base/content/abouthome/aboutHome.xhtml
+++ b/browser/base/content/abouthome/aboutHome.xhtml
@@ -39,18 +39,18 @@
     <div id="topSection">
       <div id="brandLogo"></div>
 
       <div id="searchIconAndTextContainer">
         <div id="searchIcon"/>
         <input type="text" name="q" value="" id="searchText" maxlength="256"
                aria-label="&contentSearchInput.label;" autofocus="autofocus"
                dir="auto"/>
-        <input id="searchSubmit" type="button" value="" onclick="onSearchSubmit(event)"
-               aria-label="&contentSearchSubmit.label;"/>
+        <input id="searchSubmit" type="button" value="&#x25b6;" onclick="onSearchSubmit(event)"
+               title="&contentSearchSubmit.tooltip;"/>
       </div>
 
       <div id="snippetContainer">
         <div id="defaultSnippets" hidden="true">
           <span id="defaultSnippet1">&abouthome.defaultSnippet1.v1;</span>
           <span id="defaultSnippet2">&abouthome.defaultSnippet2.v1;</span>
         </div>
         <span id="rightsSnippet" hidden="true">&abouthome.rightsSnippet;</span>
--- a/browser/base/content/newtab/newTab.css
+++ b/browser/base/content/newtab/newTab.css
@@ -394,41 +394,40 @@ input[type=button] {
 #newtab-search-text[keepfocus],
 #newtab-search-text:focus,
 #newtab-search-text[autofocus] {
   border-color: hsla(206,100%,60%,.6) hsla(206,76%,52%,.6) hsla(204,100%,40%,.6);
 }
 
 #newtab-search-submit {
   margin-inline-start: -1px;
+  color: transparent;
   background: url("chrome://browser/skin/search-arrow-go.svg#search-arrow-go") center center no-repeat, linear-gradient(hsla(0,0%,100%,.8), hsla(0,0%,100%,.1)) padding-box;
   padding: 0;
   border: 1px solid;
   border-color: hsla(210,54%,20%,.15) hsla(210,54%,20%,.17) hsla(210,54%,20%,.2);
   border-radius: 0 2px 2px 0;
   border-inline-start: 1px solid transparent;
   box-shadow: 0 0 2px hsla(0,0%,100%,.5) inset,
               0 1px 0 hsla(0,0%,100%,.2);
-  color: inherit;
   cursor: pointer;
   transition-property: background-color, border-color, box-shadow;
   transition-duration: 150ms;
   width: 50px;
 }
 
 #newtab-search-submit:dir(rtl) {
   border-radius: 2px 0 0 2px;
   background-image: url("chrome://browser/skin/search-arrow-go.svg#search-arrow-go-rtl"), linear-gradient(hsla(0,0%,100%,.8), hsla(0,0%,100%,.1));
 }
 
 #newtab-search-text:focus + #newtab-search-submit,
 #newtab-search-text + #newtab-search-submit:hover,
 #newtab-search-text[autofocus] + #newtab-search-submit {
   border-color: #59b5fc #45a3e7 #3294d5;
-  color: white;
 }
 
 #newtab-search-text:focus + #newtab-search-submit,
 #newtab-search-text[keepfocus] + #newtab-search-submit,
 #newtab-search-text[autofocus] + #newtab-search-submit {
   background-image: url("chrome://browser/skin/search-arrow-go.svg#search-arrow-go-inverted"), linear-gradient(#4cb1ff, #1793e5);
   box-shadow: 0 1px 0 hsla(0,0%,100%,.2) inset,
               0 0 0 1px hsla(0,0%,100%,.1) inset,
--- a/browser/base/content/newtab/newTab.xhtml
+++ b/browser/base/content/newtab/newTab.xhtml
@@ -66,18 +66,18 @@
       </div>
     </div>
 
     <div id="newtab-search-container">
       <div id="newtab-search-form">
         <div id="newtab-search-icon"/>
         <input type="text" name="q" value="" id="newtab-search-text"
              aria-label="&contentSearchInput.label;" maxlength="256" dir="auto"/>
-        <input id="newtab-search-submit" type="button" value=""
-             aria-label="&contentSearchSubmit.label;"/>
+        <input id="newtab-search-submit" type="button" value="&#x25b6;"
+             title="&contentSearchSubmit.tooltip;"/>
       </div>
     </div>
 
     <div id="newtab-horizontal-margin">
       <div class="newtab-side-margin"/>
       <div id="newtab-grid">
       </div>
       <div class="newtab-side-margin"/>
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -2630,55 +2630,16 @@ ContentPermissionPrompt.prototype = {
     }
 
     secHistogram.add(Ci.nsISecurityUITelemetry.WARNING_GEOLOCATION_REQUEST);
 
     this._showPrompt(aRequest, message, "geo", actions, "geolocation",
                      "geo-notification-icon", options);
   },
 
-  _promptFlyWebPublishServer : function(aRequest) {
-    var message = "Would you like to let this site start a server accessible to nearby devices and people?";
-    var actions = [
-      {
-        stringId: "flyWebPublishServer.allowPublishServer",
-        action: Ci.nsIPermissionManager.ALLOW_ACTION,
-        expireType: Ci.nsIPermissionManager.EXPIRE_SESSION
-      },
-      {
-        stringId: "flyWebPublishServer.denyPublishServer",
-        action: Ci.nsIPermissionManager.DENY_ACTION,
-        expireType: Ci.nsIPermissionManager.EXPIRE_SESSION
-      }
-    ];
-
-    let options = {
-      learnMoreURL: "https://flyweb.github.io",
-      popupIconURL: "chrome://flyweb/skin/icon-64.png"
-    };
-
-    let browser = this._getBrowserForRequest(aRequest);
-    let chromeDoc = browser.ownerDocument;
-    let iconElem = chromeDoc.getElementById("flyweb-publish-server-notification-icon");
-    if (!iconElem) {
-      let notificationPopupBox = chromeDoc.getElementById("notification-popup-box");
-      let notificationIcon = chromeDoc.createElement("image");
-      notificationIcon.setAttribute("id", "flyweb-publish-server-notification-icon");
-      notificationIcon.setAttribute("src", "chrome://flyweb/skin/icon-64.png");
-      notificationIcon.setAttribute("class", "notification-anchor-icon flyweb-publish-server-icon");
-      notificationIcon.setAttribute("style", "filter: url(chrome://browser/skin/filters.svg#fill); fill: currentColor; opacity: .4;");
-      notificationIcon.setAttribute("role", "button");
-      notificationIcon.setAttribute("aria-label", "View the publish-server request");
-      notificationPopupBox.appendChild(notificationIcon);
-    }
-
-    this._showPrompt(aRequest, message, "flyweb-publish-server", actions, "flyweb-publish-server",
-                     "flyweb-publish-server-notification-icon", options);
-  },
-
   _promptWebNotifications : function(aRequest) {
     var message = gBrowserBundle.GetStringFromName("webNotifications.receiveFromSite");
 
     var actions;
 
     var browser = this._getBrowserForRequest(aRequest);
     // Only show "allow for session" in PB mode, we don't
     // support "allow for session" in non-PB mode.
@@ -2733,18 +2694,17 @@ ContentPermissionPrompt.prototype = {
     let types = request.types.QueryInterface(Ci.nsIArray);
     if (types.length != 1) {
       request.cancel();
       return;
     }
     let perm = types.queryElementAt(0, Ci.nsIContentPermissionType);
 
     const kFeatureKeys = { "geolocation" : "geo",
-                           "desktop-notification" : "desktop-notification",
-                           "flyweb-publish-server": "flyweb-publish-server"
+                           "desktop-notification" : "desktop-notification"
                          };
 
     // Make sure that we support the request.
     if (!(perm.type in kFeatureKeys)) {
       return;
     }
 
     var requestingPrincipal = request.principal;
@@ -2777,21 +2737,16 @@ ContentPermissionPrompt.prototype = {
     // Show the prompt.
     switch (perm.type) {
     case "geolocation":
       this._promptGeo(request);
       break;
     case "desktop-notification":
       this._promptWebNotifications(request);
       break;
-    case "flyweb-publish-server":
-      if (AppConstants.NIGHTLY_BUILD) {
-        this._promptFlyWebPublishServer(request);
-      }
-      break;
     }
   },
 
 };
 
 var DefaultBrowserCheck = {
   get OPTIONPOPUP() { return "defaultBrowserNotificationPopup" },
   _setAsDefaultTimer: null,
--- a/browser/config/tooltool-manifests/linux32/releng.manifest
+++ b/browser/config/tooltool-manifests/linux32/releng.manifest
@@ -11,19 +11,19 @@
 "size": 11189216,
 "digest": "18bc52b0599b1308b667e282abb45f47597bfc98a5140cfcab8da71dacf89dd76d0dee22a04ce26fe7ad1f04e2d6596991f9e5b01fd2aaaab5542965f596b0e6",
 "algorithm": "sha512",
 "filename": "gtk3.tar.xz",
 "setup": "setup.sh",
 "unpack": true
 },
 {
-"version": "rustc 1.11.0 (9b21dcd6a 2016-08-15) repack",
-"size": 131489924,
-"digest": "59f7463a0da38f324daa4ffc2678d78afb4fe0df13248c1d215bcb996ec05e8521155563cde9a8b719a9b98c5feeaf97cc9e8d52c9b95f6b44728870d908d5b6",
+"version": "gecko rustc 1.11.0 (9b21dcd6a 2016-08-15) x86_64+i586",
+"size": 99378568,
+"digest": "ea5ae0a37ab8c583ef3f9a97c45baf0644feed95f1e6191a4456fd42bbd45b218fe4bc528747a63af55ce67c4b6155bd50f312746628b30e41c421f4d54e5417",
 "algorithm": "sha512",
 "filename": "rustc.tar.xz",
 "unpack": true
 },
 {
 "version": "cargo 0.13.0-nightly (e713e7f 2016-08-31)",
 "size": 3245716,
 "digest": "d5bb0d88ce7bb1b5a316d7a8ca6341672f5ee8008fa7754511bf53fabd54c0770e95397232896d6087547891f1143f6968d8b1e106e39800b43defeb0025c7c0",
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -185,17 +185,16 @@
 @RESPATH@/components/dom_apps.xpt
 @RESPATH@/components/dom_newapps.xpt
 @RESPATH@/components/dom_base.xpt
 @RESPATH@/components/dom_system.xpt
 #ifdef MOZ_B2G_BT
 @RESPATH@/components/dom_bluetooth.xpt
 #endif
 @RESPATH@/components/dom_canvas.xpt
-@RESPATH@/components/dom_alarm.xpt
 @RESPATH@/components/dom_core.xpt
 @RESPATH@/components/dom_css.xpt
 @RESPATH@/components/dom_events.xpt
 @RESPATH@/components/dom_geolocation.xpt
 @RESPATH@/components/dom_media.xpt
 @RESPATH@/components/dom_network.xpt
 @RESPATH@/components/dom_notification.xpt
 @RESPATH@/components/dom_html.xpt
@@ -526,18 +525,16 @@
 @RESPATH@/components/PermissionSettings.js
 @RESPATH@/components/PermissionSettings.manifest
 @RESPATH@/components/ContactManager.js
 @RESPATH@/components/ContactManager.manifest
 @RESPATH@/components/PhoneNumberService.js
 @RESPATH@/components/PhoneNumberService.manifest
 @RESPATH@/components/NotificationStorage.js
 @RESPATH@/components/NotificationStorage.manifest
-@RESPATH@/components/AlarmsManager.js
-@RESPATH@/components/AlarmsManager.manifest
 @RESPATH@/components/Push.js
 @RESPATH@/components/Push.manifest
 @RESPATH@/components/PushComponents.js
 
 @RESPATH@/components/remotebrowserutils.manifest
 @RESPATH@/components/RemoteWebNavigation.js
 
 @RESPATH@/components/SlowScriptDebug.manifest
--- a/browser/locales/en-US/chrome/browser/browser.dtd
+++ b/browser/locales/en-US/chrome/browser/browser.dtd
@@ -422,21 +422,21 @@ These should match what Safari and other
   is a fundamental keybinding and we are maintaining a XP binding so that it is easy
   for people to switch to Linux.
 
  -->
 <!ENTITY searchFocus.commandkey       "k">
 <!ENTITY searchFocus.commandkey2      "e">
 <!ENTITY searchFocusUnix.commandkey   "j">
 
-<!-- LOCALIZATION NOTE (contentSearchInput.label, contentSearchSubmit.label):
-     These are set as the aria-label attribute for the search input box and
-     submit button in the in-content search UI, to be used by screen readers. -->
+<!-- LOCALIZATION NOTE (contentSearchInput.label):
+     This is set as the aria-label attribute for the search input box in the
+     in-content search UI, to be used by screen readers. -->
 <!ENTITY contentSearchInput.label     "Search query">
-<!ENTITY contentSearchSubmit.label    "Submit search">
+<!ENTITY contentSearchSubmit.tooltip  "Submit search">
 
 <!-- LOCALIZATION NOTE (searchFor.label, searchWith.label):
      These two strings are used to build the header above the list of one-click
      search providers:  "Search for <used typed keywords> with:" -->
 <!ENTITY searchFor.label              "Search for ">
 <!ENTITY searchWith.label             " with:">
 
 <!-- LOCALIZATION NOTE (search.label, searchAfter.label):
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -373,26 +373,16 @@ geolocation.shareLocation=Share Location
 geolocation.shareLocation.accesskey=a
 geolocation.alwaysShareLocation=Always Share Location
 geolocation.alwaysShareLocation.accesskey=A
 geolocation.neverShareLocation=Never Share Location
 geolocation.neverShareLocation.accesskey=N
 geolocation.shareWithSite2=Would you like to share your location with this site?
 geolocation.shareWithFile2=Would you like to share your location with this file?
 
-# FlyWeb UI
-# LOCALIZATION NOTE (flyWebPublishServer.allowPublishServer): This is an experimental feature only shipping in Nightly, and doesn't need translation.
-flyWebPublishServer.allowPublishServer=Allow Server
-# LOCALIZATION NOTE (flyWebPublishServer.allowPublishServer.accessKey): This is an experimental feature only shipping in Nightly, and doesn't need translation.
-flyWebPublishServer.allowPublishServer.accesskey=A
-# LOCALIZATION NOTE (flyWebPublishServer.denyPublishServer): This is an experimental feature only shipping in Nightly, and doesn't need translation.
-flyWebPublishServer.denyPublishServer=Block Server
-# LOCALIZATION NOTE (flyWebPublishServer.denyPublishServer.accessKey): This is an experimental feature only shipping in Nightly, and doesn't need translation.
-flyWebPublishServer.denyPublishServer.accesskey=B
-
 webNotifications.receiveForSession=Receive for this session
 webNotifications.receiveForSession.accesskey=s
 webNotifications.alwaysReceive=Always Receive Notifications
 webNotifications.alwaysReceive.accesskey=A
 webNotifications.neverShow=Always Block Notifications
 webNotifications.neverShow.accesskey=N
 webNotifications.receiveFromSite=Would you like to receive notifications from this site?
 # LOCALIZATION NOTE (webNotifications.upgradeTitle): When using native notifications on OS X, the title may be truncated around 32 characters.
--- a/browser/themes/linux/browser.css
+++ b/browser/themes/linux/browser.css
@@ -1706,68 +1706,16 @@ toolbarbutton.chevron > .toolbarbutton-t
 toolbarbutton.chevron > .toolbarbutton-menu-dropmarker {
   display: none;
 }
 
 toolbarbutton.chevron > .toolbarbutton-icon {
   margin: 0;
 }
 
-/* Ctrl-Tab */
-
-#ctrlTab-panel {
-  -moz-appearance: none;
-  background: hsla(0,0%,33%,.85);
-  color: white;
-  border-style: none;
-  padding: 20px 10px 10px;
-  font-weight: bold;
-  text-shadow: 0 0 1px hsl(0,0%,12%), 0 0 2px hsl(0,0%,12%);
-}
-
-.ctrlTab-favicon[src] {
-  background-color: white;
-  width: 20px;
-  height: 20px;
-  padding: 2px;
-}
-
-.ctrlTab-preview-inner > .tabPreview-canvas {
-  box-shadow: 1px 1px 2px hsl(0,0%,12%);
-}
-
-.ctrlTab-preview:not(#ctrlTab-showAll) > * > .ctrlTab-preview-inner > .tabPreview-canvas {
-  margin-bottom: 2px;
-}
-
-.ctrlTab-preview-inner {
-  padding: 8px;
-  border: 2px solid transparent;
-  border-radius: .5em;
-}
-
-.ctrlTab-preview:not(#ctrlTab-showAll) > * > .ctrlTab-preview-inner {
-  margin: -10px -10px 0;
-}
-
-#ctrlTab-showAll:not(:focus) > * > .ctrlTab-preview-inner {
-  background-color: rgba(255,255,255,.2);
-}
-
-.ctrlTab-preview:focus > * > .ctrlTab-preview-inner {
-  color: white;
-  background-color: rgba(0,0,0,.6);
-  text-shadow: none;
-  border-color: white;
-}
-
-#ctrlTab-showAll {
-  margin-top: .5em;
-}
-
 /* Status panel */
 
 .statuspanel-label {
   margin: 0;
   padding: 2px 4px;
   background: -moz-dialog;
   border: 1px none ThreeDShadow;
   border-top-style: solid;
@@ -1785,19 +1733,19 @@ toolbarbutton.chevron > .toolbarbutton-i
 .statuspanel-label:-moz-locale-dir(rtl):not([mirror]),
 .statuspanel-label:-moz-locale-dir(ltr)[mirror] {
   border-left-style: solid;
   border-top-left-radius: .3em;
   margin-left: 1em;
 }
 
 %include ../shared/fullscreen/warning.inc.css
+%include ../shared/ctrlTab.inc.css
 %include ../../../devtools/client/themes/responsivedesign.inc.css
 %include ../../../devtools/client/themes/commandline.inc.css
-
 %include ../shared/plugin-doorhanger.inc.css
 
 notification.pluginVulnerable > .notification-inner > .messageCloseButton:not(:hover) {
   background-image: -moz-image-rect(url("chrome://global/skin/icons/close.svg"), 0, 80, 16, 64);
 }
 
 %include ../shared/login-doorhanger.inc.css
 
--- a/browser/themes/osx/browser.css
+++ b/browser/themes/osx/browser.css
@@ -3118,68 +3118,16 @@ menulist.translate-infobar-element > .me
   width: 28em;
   max-width: 28em;
 }
 
 .addon-install-confirmation-name {
   font-weight: bold;
 }
 
-/* Ctrl-Tab */
-
-#ctrlTab-panel {
-  -moz-appearance: none;
-  -moz-window-shadow: none;
-  background: hsla(0,0%,33%,.85);
-  color: white;
-  border-style: none;
-  padding: 20px 10px 10px;
-  text-shadow: 0 0 1px hsl(0,0%,12%), 0 0 2px hsl(0,0%,12%);
-}
-
-.ctrlTab-favicon[src] {
-  background-color: white;
-  width: 20px;
-  height: 20px;
-  padding: 2px;
-}
-
-.ctrlTab-preview-inner > .tabPreview-canvas {
-  box-shadow: 1px 1px 2px hsl(0,0%,12%);
-}
-
-.ctrlTab-preview:not(#ctrlTab-showAll) > * > .ctrlTab-preview-inner > .tabPreview-canvas {
-  margin-bottom: 2px;
-}
-
-.ctrlTab-preview-inner {
-  padding: 8px;
-  border: 2px solid transparent;
-  border-radius: .5em;
-}
-
-.ctrlTab-preview:not(#ctrlTab-showAll) > * > .ctrlTab-preview-inner {
-  margin: -10px -10px 0;
-}
-
-#ctrlTab-showAll:not(:focus) > * > .ctrlTab-preview-inner {
-  background-color: rgba(255,255,255,.2);
-}
-
-.ctrlTab-preview:focus > * > .ctrlTab-preview-inner {
-  color: white;
-  background-color: rgba(0,0,0,.6);
-  text-shadow: none;
-  border-color: white;
-}
-
-#ctrlTab-showAll {
-  margin-top: .5em;
-}
-
 /* Status panel */
 
 .statuspanel-label {
   margin: 0;
   padding: 2px 4px;
   background: linear-gradient(#fff, #ddd);
   border: 1px none #ccc;
   border-top-style: solid;
@@ -3197,16 +3145,17 @@ menulist.translate-infobar-element > .me
 .statuspanel-label:-moz-locale-dir(rtl):not([mirror]),
 .statuspanel-label:-moz-locale-dir(ltr)[mirror] {
   border-left-style: solid;
   border-top-left-radius: .3em;
   margin-left: 1em;
 }
 
 %include ../shared/fullscreen/warning.inc.css
+%include ../shared/ctrlTab.inc.css
 %include ../../../devtools/client/themes/responsivedesign.inc.css
 %include ../../../devtools/client/themes/commandline.inc.css
 %include ../shared/plugin-doorhanger.inc.css
 %include ../shared/login-doorhanger.inc.css
 
 %include downloads/indicator.css
 
 /* On mac, the popup notification contents are indented by default and so
copy from browser/themes/windows/browser.css
copy to browser/themes/shared/ctrlTab.inc.css
--- a/browser/themes/windows/browser.css
+++ b/browser/themes/shared/ctrlTab.inc.css
@@ -1,2412 +1,28 @@
+%if 0
 /* 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/. */
-
-@import url("chrome://global/skin/");
-
-@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
-@namespace html url("http://www.w3.org/1999/xhtml");
-@namespace svg url("http://www.w3.org/2000/svg");
-
-%include ../shared/browser.inc
-%include windowsShared.inc
-%filter substitution
-%define toolbarShadowColor hsla(209,67%,12%,0.35)
-%define forwardTransitionLength 150ms
-%define conditionalForwardWithUrlbar window:not([chromehidden~="toolbar"]) #urlbar-wrapper
-
-:root {
-  --space-above-tabbar: 15px;
-
-  --backbutton-urlbar-overlap: 6px;
-
-  /* icon width + border + horizontal padding (without the overlap from backbutton-urlbar-overlap) */
-  --forwardbutton-width: 25px;
-
-  --toolbarbutton-vertical-inner-padding: 2px;
-  --toolbarbutton-vertical-outer-padding: 8px;
-
-  --toolbarbutton-hover-background: rgba(0,0,0,.1);
-  --toolbarbutton-hover-bordercolor: rgba(0,0,0,.2);
-  --toolbarbutton-hover-boxshadow: none;
-
-  --toolbarbutton-active-background: rgba(0,0,0,.15);
-  --toolbarbutton-active-bordercolor: rgba(0,0,0,.3);
-  --toolbarbutton-active-boxshadow: 0 0 0 1px rgba(0,0,0,.15) inset;
-
-  --toolbarbutton-checkedhover-backgroundcolor: rgba(0,0,0,.1);
-
-  --urlbar-dropmarker-url: url("chrome://browser/skin/urlbar-history-dropmarker.png");
-  --urlbar-dropmarker-region: rect(0px, 11px, 14px, 0px);
-  --urlbar-dropmarker-hover-region: rect(0px, 22px, 14px, 11px);
-  --urlbar-dropmarker-active-region: rect(0px, 33px, 14px, 22px);
-  --urlbar-dropmarker-2x-url: url("chrome://browser/skin/urlbar-history-dropmarker@2x.png");
-  --urlbar-dropmarker-2x-region: rect(0, 22px, 28px, 0);
-  --urlbar-dropmarker-hover-2x-region: rect(0, 44px, 28px, 22px);
-  --urlbar-dropmarker-active-2x-region: rect(0, 66px, 28px, 44px);
-
-  --panel-separator-color: ThreeDLightShadow;
-
-  --urlbar-separator-color: ThreeDLightShadow;
-}
-
-@media (-moz-windows-default-theme) {
-  :root {
-    --panel-separator-color: hsla(210,4%,10%,.14);
-  }
-}
-
-#nav-bar[brighttext] {
-  --toolbarbutton-hover-background: rgba(255,255,255,.25);
-  --toolbarbutton-hover-bordercolor: rgba(255,255,255,.5);
-
-  --toolbarbutton-active-background: rgba(255,255,255,.4);
-  --toolbarbutton-active-bordercolor: rgba(255,255,255,.7);
-  --toolbarbutton-active-boxshadow: 0 0 0 1px rgba(255,255,255,.4) inset;
-
-  --toolbarbutton-checkedhover-backgroundcolor: rgba(255,255,255,.3);
-}
-
-#nav-bar:-moz-lwtheme {
-  --toolbarbutton-hover-background: rgba(255,255,255,.25);
-  --toolbarbutton-hover-bordercolor: rgba(0,0,0,.2);
-
-  --toolbarbutton-active-background: rgba(70%,70%,70%,.25);
-  --toolbarbutton-active-bordercolor: rgba(0,0,0,.3);
-  --toolbarbutton-active-boxshadow: 0 0 2px rgba(0,0,0,.6) inset;
-
-  --toolbarbutton-checkedhover-backgroundcolor: rgba(85%,85%,85%,.25);
-}
-
-#menubar-items {
-  -moz-box-orient: vertical; /* for flex hack */
-}
-
-#main-menubar {
-  -moz-box-flex: 1; /* make menu items expand to fill toolbar height */
-}
-
-/* Hides the titlebar-placeholder underneath the window caption buttons when we
-   are not autohiding the menubar. */
-#toolbar-menubar:not([autohide="true"]) + #TabsToolbar > .titlebar-placeholder[type="caption-buttons"] {
-  display: none;
-}
-
-/* We want a 4px gap between the TabsToolbar and the toolbar-menubar when the
-   toolbar-menu is displayed, and a 16px gap when it is not. 1px is taken care
-   of by the (light) outer shadow of the tab, the remaining 3/15 are these margins. */
-#toolbar-menubar:not([autohide=true]) ~ #TabsToolbar:not([inFullscreen]),
-#toolbar-menubar[autohide=true]:not([inactive]) ~ #TabsToolbar:not([inFullscreen]) {
-  margin-top: 3px;
-}
-
-#main-window[tabsintitlebar][sizemode="normal"]:not([inFullscreen])[chromehidden~="menubar"] #toolbar-menubar ~ #TabsToolbar,
-#main-window[tabsintitlebar][sizemode="normal"]:not([inFullscreen]) #toolbar-menubar[autohide="true"][inactive] ~ #TabsToolbar {
-  margin-top: var(--space-above-tabbar);
-}
-
-#main-window[customize-entered][tabsintitlebar]:not([inFullscreen]) #toolbar-menubar[customizing-dragovertarget].customization-target::before,
-#main-window[customize-entered][tabsintitlebar]:not([inFullscreen]) #TabsToolbar[customizing-dragovertarget].customization-target::before,
-#main-window[customize-entered][tabsintitlebar]:not([inFullscreen]) #toolbar-menubar.customization-target:hover::before,
-#main-window[customize-entered][tabsintitlebar]:not([inFullscreen]) #TabsToolbar.customization-target:hover::before {
-  outline-color: CaptionText;
-}
-
-#navigator-toolbox {
-  -moz-appearance: none;
-  background-color: transparent;
-  border-top: none;
-}
-
-#navigator-toolbox::after {
-  content: "";
-  display: -moz-box;
-  -moz-box-ordinal-group: 101; /* tabs toolbar is 100 */
-  border-bottom: 1px solid ThreeDShadow;
-}
-
-@media (-moz-windows-default-theme) {
-  @media (-moz-os-version: windows-vista),
-         (-moz-os-version: windows-win7) {
-    #navigator-toolbox::after {
-      border-bottom-color: #aabccf;
-    }
-  }
-
-  @media (-moz-os-version: windows-win8),
-         (-moz-os-version: windows-win10) {
-    #navigator-toolbox::after {
-      border-bottom-color: #c2c2c2;
-    }
-  }
-}
-
-#navigator-toolbox:-moz-lwtheme::after {
-  border-bottom-color: rgba(0,0,0,.3);
-}
-
-#navigator-toolbox > toolbar {
-  -moz-appearance: none;
-  border-style: none;
-}
-
-#navigator-toolbox > toolbar:not(#toolbar-menubar):not(#TabsToolbar) {
-  background-clip: padding-box;
-  background-image: linear-gradient(@toolbarHighlight@, @toolbarHighlight@);
-}
-
-@media (-moz-os-version: windows-xp),
-       (-moz-os-version: windows-vista),
-       (-moz-os-version: windows-win7) {
-  #nav-bar {
-    background-image: linear-gradient(@toolbarHighlight@, transparent) !important;
-  }
-
-  #navigator-toolbox > toolbar:not(#toolbar-menubar):not(#TabsToolbar):not(#nav-bar) {
-    background-image: none;
-  }
-}
-
-#navigator-toolbox > toolbar:not(#toolbar-menubar):not(#TabsToolbar):not(:-moz-lwtheme) {
-  background-color: -moz-Dialog;
-}
-
-#navigator-toolbox > toolbar:not(#toolbar-menubar):not(#TabsToolbar):not(#nav-bar):not(#addon-bar) {
-  overflow: -moz-hidden-unscrollable;
-  max-height: 4em;
-  transition: min-height 170ms ease-out, max-height 170ms ease-out;
-  padding: 0 5px;
-}
-
-#navigator-toolbox > toolbar:not(#toolbar-menubar):not(#TabsToolbar):not(#nav-bar):not(#addon-bar)[collapsed=true] {
-  min-height: 0.1px;
-  max-height: 0;
-  transition: min-height 170ms ease-out, max-height 170ms ease-out, visibility 170ms linear;
-}
-
-@media not all and (-moz-windows-compositor),
-       not all and (-moz-windows-default-theme) {
-  /* Please keep the menu text colors in this media block in sync with
-   * devedition.css, minus the :not(:-moz-lwtheme) condition - see Bug 1165718.
-   */
-  #main-window[tabsintitlebar]:not([inFullscreen]) #toolbar-menubar:not(:-moz-lwtheme),
-  #main-window[tabsintitlebar]:not([inFullscreen]) #TabsToolbar:not(:-moz-lwtheme) {
-    color: CaptionText;
-  }
-
-  #main-window[tabsintitlebar]:not([inFullscreen]) #toolbar-menubar:not(:-moz-lwtheme):-moz-window-inactive,
-  #main-window[tabsintitlebar]:not([inFullscreen]) #TabsToolbar:not(:-moz-lwtheme):-moz-window-inactive {
-    color: InactiveCaptionText;
-  }
-}
-
-@media not all and (-moz-windows-compositor) {
-  #main-window[tabsintitlebar] #titlebar:-moz-lwtheme {
-    visibility: hidden;
-  }
-
-  #main-window[tabsintitlebar] #titlebar-content:-moz-lwtheme {
-    -moz-binding: url("chrome://global/content/bindings/general.xml#windowdragbox");
-    visibility: visible;
-  }
-
-  /* Top-level menu appearance has transparent background, so the text color
-     needs to be inherited from our custom menubar too. */
-  #main-window[tabsintitlebar] #main-menubar > menu:not(:-moz-lwtheme) {
-    color: inherit;
-  }
-}
-
-/**
- * In the classic themes, the titlebar has a horizontal gradient, which is
- * problematic for reading the text of background tabs when they're in the
- * titlebar. We side-step this issue by layering our own background underneath
- * the tabs. Unfortunately, this requires a bunch of positioning in order to get
- * text and icons to not appear fuzzy.
- */
-@media (-moz-windows-classic) {
-  /**
-   * We need to bump up the z-index of the tabbrowser-tabs so that they appear
-   * over top of the fog we're applying for classic themes, as well as the nav-bar.
-   */
-  #main-window[tabsintitlebar]:not([sizemode=fullscreen]) #tabbrowser-tabs {
-    position: relative;
-    z-index: 2;
-  }
-
-  #main-window[tabsintitlebar] #TabsToolbar:not(:-moz-lwtheme) {
-    position: relative;
-  }
-
-  #main-window[tabsintitlebar]:not([sizemode=fullscreen]) #TabsToolbar:not(:-moz-lwtheme)::after {
-    /* Because we use placeholders for window controls etc. in the tabstrip,
-     * and position those with ordinal attributes, and because our layout code
-     * expects :before/:after nodes to come first/last in the frame list,
-     * we have to reorder this element to come last, hence the
-     * ordinal group value (see bug 853415). */
-    -moz-box-ordinal-group: 1001;
-    box-shadow: 0 0 50px 8px ActiveCaption;
-    content: "";
-    display: -moz-box;
-    height: 0;
-    margin: 0 50px;
-    position: absolute;
-    pointer-events: none;
-    top: 100%;
-    width: -moz-available;
-  }
-
-  #main-window[tabsintitlebar]:not([sizemode=fullscreen]) #TabsToolbar:not(:-moz-lwtheme):-moz-window-inactive::after {
-    box-shadow: 0 0 50px 8px InactiveCaption;
-  }
-
-  #main-window[tabsintitlebar]:not([sizemode=fullscreen]) toolbar[customindex]:not(:-moz-lwtheme),
-  #main-window[tabsintitlebar]:not([sizemode=fullscreen]) #PersonalToolbar:not(:-moz-lwtheme) {
-    position: relative;
-  }
-
-  /* Need to constrain the box shadow fade to avoid overlapping layers, see bug 886281. */
-  #main-window[tabsintitlebar]:not([sizemode=fullscreen]) #navigator-toolbox:not(:-moz-lwtheme) {
-    overflow: -moz-hidden-unscrollable;
-  }
-
-  /**
-   * When the tabstrip is overflowed, pinned tab separators get position: absolute,
-   * which makes the pinned tab separators leak over the nav-bar highlight. Forcing
-   * the element to snap to the bottom of the client rect works around the issue.
-   */
-  #main-window[tabsintitlebar] #tabbrowser-tabs[positionpinnedtabs] > .tabbrowser-tab[pinned]::before {
-    bottom: 0px;
-  }
-
-  #main-window[tabsintitlebar]:not([sizemode=fullscreen]) #TabsToolbar .toolbarbutton-1 {
-    position: relative;
-    z-index: 1;
-  }
-
-  /**
-   * With the tabbrowser-tabs element z-index'd above the nav-bar, we now get the
-   * scrollbox button borders leaking over the nav-bar highlight. This transparent bottom
-   * border forces the scrollbox button borders to terminate a pixel early, working
-   * around the issue.
-   */
-  #main-window[tabsintitlebar]:not([sizemode=fullscreen]) .tabbrowser-arrowscrollbox > .scrollbutton-up,
-  #main-window[tabsintitlebar]:not([sizemode=fullscreen]) .tabbrowser-arrowscrollbox > .scrollbutton-down {
-    border-bottom: 1px solid transparent;
-  }
-
-  #main-window[tabsintitlebar][sizemode="normal"] > #tab-view-deck > #browser-panel:-moz-lwtheme {
-    /* Render a window top border: */
-    background-image: linear-gradient(to bottom,
-          ThreeDLightShadow 0, ThreeDLightShadow 1px,
-          ThreeDHighlight 1px, ThreeDHighlight 2px,
-          ActiveBorder 2px, ActiveBorder 4px, transparent 4px);
-  }
-
-  /* End classic titlebar gradient */
-
-  #main-window[tabsintitlebar]:not([inFullscreen]) :-moz-any(#TabsToolbar, #toolbar-menubar) toolbarbutton:not(:-moz-lwtheme) {
-    color: inherit;
-  }
-}
-
-/* Render a window top border for lwthemes on WinXP modern themes: */
-@media (-moz-windows-theme: luna-blue) {
-  #main-window[tabsintitlebar][sizemode="normal"] > #tab-view-deck > #browser-panel:-moz-lwtheme {
-    background-image: linear-gradient(to bottom,
-        rgb(8, 49, 216) 0, rgb(8, 49, 216) 1px,
-        rgb(15, 77, 227) 1px, rgb(15, 77, 227) 2px,
-        rgb(22, 106, 238) 2px, rgb(22, 106, 238) 3px,
-        rgb(8, 85, 221) 3px, rgb(8, 85, 221) 4px,
-        transparent 4px);
-  }
-
-  #main-window[tabsintitlebar][sizemode="normal"] > #tab-view-deck > #browser-panel:-moz-lwtheme:-moz-window-inactive {
-    background-image: linear-gradient(to bottom,
-        rgb(91, 104, 205) 0, rgb(91, 104, 205) 1px,
-        rgb(116, 128, 220) 1px, rgb(116, 128, 220) 2px,
-        rgb(117, 140, 221) 2px, rgb(117, 140, 221) 4px,
-        transparent 4px);
-  }
-}
-
-@media (-moz-windows-theme: luna-silver) {
-  #main-window[tabsintitlebar][sizemode="normal"] > #tab-view-deck > #browser-panel:-moz-lwtheme {
-    background-image: linear-gradient(to bottom,
-        rgb(102,102,126) 0, rgb(102,102,126) 1px,
-        rgb(168,167,191) 1px, rgb(168,167,191) 2px,
-        white 2px, white 3px,
-        rgb(188,188,207) 3px, rgb(188,188,207) 4px,
-        transparent 4px);
-  }
-
-  #main-window[tabsintitlebar][sizemode="normal"] > #tab-view-deck > #browser-panel:-moz-lwtheme:-moz-window-inactive {
-    background-image: linear-gradient(to bottom,
-        rgb(186,186,197) 0, rgb(186,186,197) 1px,
-        rgb(236,238,245) 1px, rgb(236,238,245) 2px,
-        white 2px, white 3px,
-        rgb(215,215,227) 3px, rgb(215,215,227) 4px,
-        transparent 4px);
-  }
-}
-
-@media (-moz-windows-theme: luna-olive) {
-  #main-window[tabsintitlebar][sizemode="normal"] > #tab-view-deck > #browser-panel:-moz-lwtheme {
-    background-image: linear-gradient(to bottom,
-        rgb(139,161,105) 0, rgb(139,161,105) 1px,
-        rgb(171, 189, 133) 1px, rgb(171, 189, 133) 2px,
-        rgb(164,178,127) 2px, rgb(164,178,127) 3px,
-        transparent 3px);
-  }
-
-  #main-window[tabsintitlebar][sizemode="normal"] > #tab-view-deck > #browser-panel:-moz-lwtheme:-moz-window-inactive {
-    background-image: linear-gradient(to bottom,
-        rgb(207, 214, 188) 0, rgb(207, 214, 188) 1px,
-        rgb(224, 226, 200) 1px, rgb(224, 226, 200) 2px,
-        rgb(214, 216, 190) 2px, rgb(214, 216, 190) 3px,
-        transparent 3px);
-  }
-}
-
-#TabsToolbar:not([collapsed="true"]) + #nav-bar {
-  /* Move up into the TabsToolbar for the inner highlight at the top of the nav-bar */
-  margin-top: calc(-1 * var(--navbar-tab-toolbar-highlight-overlap));
-  /* Position the toolbar above the bottom of background tabs */
-  position: relative;
-  z-index: 1;
-}
-
-#nav-bar {
-  border-top: 1px solid @toolbarShadowColor@ !important;
-  box-shadow: 0 1px 0 @toolbarHighlight@ inset;
-}
-@media not all and (-moz-windows-compositor) {
-  #TabsToolbar[collapsed="true"] + #nav-bar {
-    border-top-style: none !important;
-  }
-}
-
-#personal-bookmarks {
-  min-height: 24px;
-}
-
-#print-preview-toolbar:not(:-moz-lwtheme) {
-  -moz-appearance: toolbox;
-}
-
-#browser-bottombox:not(:-moz-lwtheme) {
-  background-color: -moz-dialog;
-}
-
-@media (-moz-os-version: windows-xp) and (-moz-windows-default-theme) {
-  #main-window[tabsintitlebar][sizemode="normal"] #toolbar-menubar {
-    margin-top: 4px;
-  }
-}
-
-/* ::::: titlebar ::::: */
-
-#main-window[sizemode="normal"] > #titlebar {
-  -moz-appearance: -moz-window-titlebar;
-}
-
-#main-window[sizemode="maximized"] > #titlebar {
-  -moz-appearance: -moz-window-titlebar-maximized;
-}
-
-@media (-moz-windows-classic) {
-  #main-window[tabsintitlebar][sizemode="normal"] > #tab-view-deck > #browser-panel > #navigator-toolbox > #toolbar-menubar {
-    margin-top: 4px;
-  }
-}
-
-/* The button box must appear on top of the navigator-toolbox in order for
- * click and hover mouse events to work properly for the button in the restored
- * window state. Otherwise, elements in the navigator-toolbox, like the menubar,
- * can swallow those events. It will also place the buttons above the fog on
- * themes with Aero Glass.
- */
-#titlebar-buttonbox {
-  z-index: 1;
-}
-
-.titlebar-placeholder[type="caption-buttons"] {
-  margin-left: 22px; /* space needed for Aero Snap */
-}
-
-@media (-moz-os-version: windows-xp) {
-  .titlebar-placeholder[type="caption-buttons"] {
-    margin-left: 10px; /* less space needed on XP because there's no Aero Snap */
-  }
-}
-
-/* titlebar command buttons */
-
-#titlebar-min {
-  -moz-appearance: -moz-window-button-minimize;
-}
-
-#titlebar-max {
-  -moz-appearance: -moz-window-button-maximize;
-}
-
-#main-window[sizemode="maximized"] #titlebar-max {
-  -moz-appearance: -moz-window-button-restore;
-}
-
-#titlebar-close {
-  -moz-appearance: -moz-window-button-close;
-}
-
-@media not all and (-moz-windows-classic) {
-  #titlebar-min {
-    margin-inline-end: 2px;
-  }
-}
-
-/* ::::: bookmark buttons ::::: */
-
-toolbarbutton.bookmark-item:not(.subviewbutton),
-#personal-bookmarks[cui-areatype="toolbar"]:not([overflowedItem=true]) > #bookmarks-toolbar-placeholder {
-  margin: 0;
-  padding: 2px 3px;
-  -moz-appearance: none;
-  border: 1px solid transparent;
-  border-radius: 1px;
-  transition-property: background-color, border-color, box-shadow;
-  transition-duration: 150ms;
-}
-
-toolbarbutton.bookmark-item:not(.subviewbutton):hover:not([disabled="true"]):not([open]) {
-  border-color: var(--toolbarbutton-hover-bordercolor);
-  background: var(--toolbarbutton-hover-background);
-}
-
-toolbarbutton.bookmark-item:not(.subviewbutton):hover:active:not([disabled="true"]),
-toolbarbutton.bookmark-item[open="true"] {
-  border-color: var(--toolbarbutton-active-bordercolor);
-  box-shadow: var(--toolbarbutton-active-boxshadow);
-  background: var(--toolbarbutton-active-background);
-}
-
-toolbarbutton.bookmark-item:not(.subviewbutton):hover:not([disabled="true"]):-moz-lwtheme {
-  background-color: rgba(255,255,255,.25);
-  background-origin: padding-box;
-  background-clip: padding-box;
-}
-
-.bookmark-item > .toolbarbutton-icon,
-#personal-bookmarks[cui-areatype="toolbar"] > #bookmarks-toolbar-placeholder > .toolbarbutton-icon {
-  width: 16px;
-  height: 16px;
-}
-
-/* Force the display of the label for bookmarks */
-.bookmark-item > .toolbarbutton-text,
-#personal-bookmarks[cui-areatype="toolbar"] > #bookmarks-toolbar-placeholder > .toolbarbutton-text {
-  display: -moz-box !important;
-}
-
-.bookmark-item > .toolbarbutton-menu-dropmarker {
-  display: none;
-}
-
-#bookmarks-toolbar-placeholder {
-  list-style-image: url("chrome://browser/skin/places/bookmarksToolbar.png") !important;
-}
-
-toolbarpaletteitem[place="palette"] > #personal-bookmarks > #bookmarks-toolbar-placeholder,
-#personal-bookmarks[cui-areatype="menu-panel"] > #bookmarks-toolbar-placeholder {
-  list-style-image: url("chrome://browser/skin/places/bookmarksToolbar-menuPanel.png") !important;
-}
-
-/* ----- BOOKMARK STAR ANIMATION ----- */
-
-@keyframes animation-bookmarkAdded {
-  from { transform: rotate(0deg) translateX(-16px) rotate(0deg) scale(1); opacity: 0; }
-  60%  { transform: rotate(180deg) translateX(-16px) rotate(-180deg) scale(2.2); opacity: 1; }
-  80%  { opacity: 1; }
-  to   { transform: rotate(180deg) translateX(-16px) rotate(-180deg) scale(1); opacity: 0; }
-}
-
-@keyframes animation-bookmarkPulse {
-  from { transform: scale(1); }
-  50%  { transform: scale(1.3); }
-  to   { transform: scale(1); }
-}
-
-#bookmarked-notification-container {
-  min-height: 1px;
-  min-width: 1px;
-  height: 1px;
-  margin-bottom: -1px;
-  z-index: 5;
-  position: relative;
-}
-
-#bookmarked-notification {
-  background-size: 16px;
-  background-position: center;
-  background-repeat: no-repeat;
-  width: 16px;
-  height: 16px;
-  opacity: 0;
-}
-
-#bookmarked-notification-dropmarker-anchor {
-  z-index: -1;
-  position: relative;
-}
-
-#bookmarked-notification-dropmarker-icon {
-  width: 18px;
-  height: 18px;
-  visibility: hidden;
-}
-
-#bookmarked-notification-anchor[notification="finish"] > #bookmarked-notification {
-  background-image: url("chrome://browser/skin/places/bookmarks-notification-finish.png");
-  animation: animation-bookmarkAdded 800ms;
-  animation-timing-function: ease, ease, ease;
-}
-
-#bookmarks-menu-button[notification="finish"] > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon {
-  list-style-image: none !important;
-}
-
-#bookmarked-notification-dropmarker-anchor[notification="finish"] > #bookmarked-notification-dropmarker-icon {
-  visibility: visible;
-  animation: animation-bookmarkPulse 300ms;
-  animation-delay: 600ms;
-  animation-timing-function: ease-out;
-}
-
-/* ::::: bookmark menus ::::: */
-
-menu.bookmark-item,
-menuitem.bookmark-item {
-  min-width: 0;
-  max-width: 32em;
-}
-
-.bookmark-item:not(.subviewbutton) > .menu-iconic-left {
-  margin-top: 0;
-  margin-bottom: 0;
-}
-
-.bookmark-item > .menu-iconic-left > .menu-iconic-icon {
-  padding-inline-start: 0px;
-}
-
-/* ::::: bookmark items ::::: */
-
-.bookmark-item  {
-  list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png");
-}
-
-.bookmark-item[container] {
-  list-style-image: url("chrome://global/skin/icons/folder-item.png");
-  -moz-image-region: rect(0px, 32px, 16px, 16px);
-}
-
-.bookmark-item[container][open] {
-  -moz-image-region: rect(16px, 32px, 32px, 16px);
-}
-
-.bookmark-item[container][livemark] {
-  list-style-image: url("chrome://browser/skin/livemark-folder.png");
-  -moz-image-region: auto;
-}
-
-.bookmark-item[container][livemark] .bookmark-item {
-  list-style-image: url("chrome://browser/skin/places/livemark-item.png");
-  -moz-image-region: rect(0px, 16px, 16px, 0px);
-}
-
-.bookmark-item[container][livemark] .bookmark-item[visited] {
-  -moz-image-region: rect(0px, 32px, 16px, 16px);
-}
-
-.bookmark-item[container][query] {
-  list-style-image: url("chrome://browser/skin/places/query.png");
-  -moz-image-region: auto;
-}
-
-.bookmark-item[query][tagContainer] {
-  list-style-image: url("chrome://browser/skin/places/tag.png");
-  -moz-image-region: auto;
-}
-
-.bookmark-item[query][dayContainer] {
-  list-style-image: url("chrome://browser/skin/places/calendar.png");
-  -moz-image-region: auto;
-}
-
-.bookmark-item[query][hostContainer] {
-  list-style-image: url("chrome://global/skin/icons/folder-item.png");
-  -moz-image-region: rect(0px, 32px, 16px, 16px);
-}
-
-.bookmark-item[query][hostContainer][open] {
-  list-style-image: url("chrome://global/skin/icons/folder-item.png");
-  -moz-image-region: rect(16px, 32px, 32px, 16px);
-}
-
-.bookmark-item[cutting] > .toolbarbutton-icon,
-.bookmark-item[cutting] > .menu-iconic-left > .menu-iconic-icon {
-  opacity: 0.5;
-}
-
-.bookmark-item[cutting] > .toolbarbutton-text,
-.bookmark-item[cutting] > .menu-iconic-left > .menu-iconic-text {
-  opacity: 0.7;
-}
-
-/* ::::: primary toolbar buttons ::::: */
-
-%include ../shared/toolbarbuttons.inc.css
-
-@media (-moz-windows-theme: luna-silver) and (max-resolution: 1dppx) {
-  :-moz-any(@primaryToolbarButtons@),
-  #bookmarks-menu-button.toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon {
-    list-style-image: url("chrome://browser/skin/Toolbar-lunaSilver.png");
-  }
-}
-
-#main-window:not([customizing]) .toolbarbutton-1[disabled=true] > .toolbarbutton-icon,
-#main-window:not([customizing]) .toolbarbutton-1[disabled=true] > .toolbarbutton-menu-dropmarker,
-#main-window:not([customizing]) .toolbarbutton-1[disabled=true] > .toolbarbutton-menubutton-dropmarker,
-#main-window:not([customizing]) .toolbarbutton-1[disabled=true] > .toolbarbutton-menubutton-button > .toolbarbutton-icon,
-#main-window:not([customizing]) .toolbarbutton-1 > .toolbarbutton-menubutton-button[disabled=true] > .toolbarbutton-icon {
-  opacity: .4;
-}
-
-.toolbarbutton-1 > .toolbarbutton-menu-dropmarker,
-.toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker {
-  list-style-image: url("chrome://browser/skin/toolbarbutton-dropdown-arrow.png");
-}
-
-toolbar[brighttext] .toolbarbutton-1 > .toolbarbutton-menu-dropmarker,
-toolbar[brighttext] .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker {
-  list-style-image: url("chrome://browser/skin/toolbarbutton-dropdown-arrow-inverted.png");
-}
-
-.toolbarbutton-1 > .toolbarbutton-icon,
-.toolbarbutton-1 > .toolbarbutton-menubutton-button > .toolbarbutton-icon {
-  margin-inline-end: 0;
-}
-
-:-moz-any(toolbar, .widget-overflow-list) .toolbarbutton-1 > .toolbarbutton-icon,
-:-moz-any(toolbar, .widget-overflow-list) .toolbarbutton-1 > :-moz-any(.toolbarbutton-menubutton-button, .toolbarbutton-badge-stack) > .toolbarbutton-icon {
-  max-width: 16px;
-}
-
-:-moz-any(toolbar, .widget-overflow-list) .toolbarbutton-1:-moz-any(@primaryToolbarButtons@, .toolbarbutton-legacy-addon) > .toolbarbutton-icon,
-:-moz-any(toolbar, .widget-overflow-list) .toolbarbutton-1:-moz-any(@primaryToolbarButtons@, .toolbarbutton-legacy-addon) > :-moz-any(.toolbarbutton-menubutton-button, .toolbarbutton-badge-stack) > .toolbarbutton-icon,
-#bookmarks-menu-button[cui-areatype="toolbar"] > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon {
-  max-width: 18px;
-}
-
-%include ../shared/menupanel.inc.css
-
-@media (-moz-windows-default-theme) {
-  :-moz-any(@primaryToolbarButtons@)[cui-areatype="menu-panel"][panel-multiview-anchor=true] > .toolbarbutton-icon,
-  :-moz-any(@primaryToolbarButtons@)[cui-areatype="menu-panel"][panel-multiview-anchor=true] > .toolbarbutton-badge-stack > .toolbarbutton-icon,
-  :-moz-any(@primaryToolbarButtons@)[cui-areatype="menu-panel"][panel-multiview-anchor=true] > .toolbarbutton-menubutton-button > .toolbarbutton-icon {
-    filter: url(chrome://browser/skin/filters.svg#fill);
-    fill: currentColor;
-  }
-}
-
-@media not all and (-moz-windows-default-theme) {
-  :-moz-any(@primaryToolbarButtons@)[cui-areatype="menu-panel"] > .toolbarbutton-icon,
-  :-moz-any(@primaryToolbarButtons@)[cui-areatype="menu-panel"] > .toolbarbutton-badge-stack > .toolbarbutton-icon,
-  :-moz-any(@primaryToolbarButtons@)[cui-areatype="menu-panel"] > .toolbarbutton-menubutton-button > .toolbarbutton-icon,
-  toolbaritem[cui-areatype="menu-panel"] > :-moz-any(@nestedButtons@) > .toolbarbutton-icon {
-    filter: url(chrome://browser/skin/filters.svg#fill);
-    fill: currentColor;
-    opacity: 0.7 !important; /* !important overrides .toolbarbutton-1[disabled=true] rule */
-  }
-}
-
-.findbar-button,
-#nav-bar .toolbarbutton-1,
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-button {
-  -moz-appearance: none;
-  border: none;
-  padding: 0;
-  background: none;
-}
-
-#nav-bar .toolbarbutton-1:not([type=menu-button]),
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-button,
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker {
-  padding: var(--toolbarbutton-vertical-outer-padding) 2px;
-  -moz-box-pack: center;
-}
-
-#nav-bar #PanelUI-menu-button {
-  padding-inline-start: 5px;
-  padding-inline-end: 5px;
-}
-
-#nav-bar .toolbarbutton-1[type=panel],
-#nav-bar .toolbarbutton-1[type=menu]:not(#back-button):not(#forward-button):not(#feed-button):not(#PanelUI-menu-button) {
-  padding-left: 5px;
-  padding-right: 5px;
-}
-
-#nav-bar .toolbarbutton-1 > menupopup {
-  margin-top: -3px;
-}
-
-#nav-bar .toolbarbutton-1 > menupopup.cui-widget-panel {
-  margin-top: -8px;
-}
-
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-button {
-  padding-inline-end: 0;
-}
-
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker {
-  padding-inline-start: 0;
-  -moz-box-align: center;
-}
-
-.findbar-button > .toolbarbutton-text,
-#nav-bar .toolbarbutton-1 > .toolbarbutton-icon,
-#nav-bar .toolbarbutton-1 > .toolbarbutton-text,
-#nav-bar .toolbarbutton-1 > .toolbarbutton-badge-stack,
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-button > .toolbarbutton-icon,
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon,
-@conditionalForwardWithUrlbar@ > .toolbarbutton-1:-moz-any([disabled],:not([open]):not([disabled]):not(:active)) > .toolbarbutton-icon {
-  padding: var(--toolbarbutton-vertical-inner-padding) 6px;
-  background-origin: padding-box !important;
-  background-clip: padding-box !important;
-  border: 1px solid transparent;
-  border-radius: 1px;
-  transition-property: background-color, border-color, box-shadow;
-  transition-duration: 150ms;
-}
-
-#nav-bar .toolbarbutton-1 > .toolbarbutton-icon,
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-button > .toolbarbutton-icon,
-#nav-bar #bookmarks-menu-button[cui-areatype="toolbar"] > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon {
-  /* horizontal padding + border + actual icon width */
-  max-width: 32px;
-}
-
-@media (-moz-os-version: windows-xp),
-       (-moz-os-version: windows-vista),
-       (-moz-os-version: windows-win7) {
-  /* < Win8 */
-  :root {
-    --toolbarbutton-hover-background: linear-gradient(hsla(0,0%,100%,.6), hsla(0,0%,100%,.1));
-    --toolbarbutton-hover-bordercolor: hsla(210,54%,20%,.15) hsla(210,54%,20%,.2) hsla(210,54%,20%,.25);
-    --toolbarbutton-hover-boxshadow: 0 1px hsla(0,0%,100%,.3) inset,
-                                     0 1px hsla(210,54%,20%,.03),
-                                     0 0 2px hsla(210,54%,20%,.1);
-
-    --toolbarbutton-active-background: hsla(210,54%,20%,.15) linear-gradient(hsla(0,0%,100%,.6), hsla(0,0%,100%,.1));
-    --toolbarbutton-active-bordercolor: hsla(210,54%,20%,.3) hsla(210,54%,20%,.35) hsla(210,54%,20%,.4);
-    --toolbarbutton-active-boxshadow: 0 1px 1px hsla(210,54%,20%,.1) inset,
-                                      0 0 1px hsla(210,54%,20%,.2) inset,
-/* allows keyhole-forward-clip-path to be used for non-hover as well as hover: */
-                                      0 1px 0 hsla(210,54%,20%,0),
-                                      0 0 2px hsla(210,54%,20%,0);
-
-    --toolbarbutton-checkedhover-backgroundcolor: rgba(90%,90%,90%,.4);
-  }
-}
-
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-button > .toolbarbutton-icon:-moz-locale-dir(ltr),
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon:-moz-locale-dir(rtl) {
-  border-top-right-radius: 0;
-  border-bottom-right-radius: 0;
-}
-
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-button > .toolbarbutton-icon:-moz-locale-dir(rtl),
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon:-moz-locale-dir(ltr) {
-  border-top-left-radius: 0;
-  border-bottom-left-radius: 0;
-}
-
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-button > .toolbarbutton-icon {
-  border-inline-end-style: none;
-}
-
-#nav-bar .toolbarbutton-1:not(:-moz-any(@primaryToolbarButtons@, .toolbarbutton-legacy-addon)) > .toolbarbutton-icon,
-#nav-bar .toolbarbutton-1:not(:-moz-any(@primaryToolbarButtons@, .toolbarbutton-legacy-addon)) > .toolbarbutton-badge-stack,
-#nav-bar .toolbarbutton-1:not(:-moz-any(@primaryToolbarButtons@, .toolbarbutton-legacy-addon)) > .toolbarbutton-menubutton-button > .toolbarbutton-icon {
-  padding: calc(var(--toolbarbutton-vertical-inner-padding) + 1px) 7px;
-}
-
-#nav-bar .toolbarbutton-1[type=panel] > .toolbarbutton-icon,
-#nav-bar .toolbarbutton-1[type=panel] > .toolbarbutton-badge-stack,
-#nav-bar .toolbarbutton-1[type=menu]:not(#PanelUI-menu-button):not(#back-button):not(#forward-button) > .toolbarbutton-icon,
-#nav-bar .toolbarbutton-1[type=menu]:not(#PanelUI-menu-button) > .toolbarbutton-badge-stack,
-#nav-bar .toolbarbutton-1[type=menu] > .toolbarbutton-text /* hack for add-ons that forcefully display the label */ {
-  padding-inline-end: 17px;
-}
-
-#nav-bar .toolbarbutton-1[type=panel] > .toolbarbutton-icon,
-#nav-bar .toolbarbutton-1[type=menu]:not(#PanelUI-menu-button):not(#back-button):not(#forward-button) > .toolbarbutton-icon {
-  /* horizontal padding + border + icon width */
-  max-width: 43px;
-}
-
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menu-dropmarker {
-  margin-inline-start: -15px;
-}
-
-#nav-bar #bookmarks-menu-button[cui-areatype="toolbar"] > .toolbarbutton-menubutton-button > .toolbarbutton-icon {
-  /* horizontal padding + border + actual icon width */
-  max-width: 31px;
-}
-
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon {
-  padding-top: calc(var(--toolbarbutton-vertical-inner-padding) + 6px);
-  padding-bottom: calc(var(--toolbarbutton-vertical-inner-padding) + 6px);
-}
-
-#nav-bar .toolbaritem-combined-buttons {
-  margin-left: 2px;
-  margin-right: 2px;
-}
-
-#nav-bar .toolbaritem-combined-buttons > .toolbarbutton-1 {
-  padding-left: 0;
-  padding-right: 0;
-}
-
-#nav-bar .toolbaritem-combined-buttons:not(:hover) > separator,
-#nav-bar .toolbarbutton-1:not(:hover):not(:active):not([open]) > .toolbarbutton-menubutton-dropmarker::before {
-  content: "";
-  display: -moz-box;
-  width: 1px;
-  height: 16px;
-  margin-inline-end: -1px;
-  background-image: linear-gradient(currentColor 0, currentColor 100%);
-  background-position: center;
-  background-repeat: no-repeat;
-  background-size: 1px 16px;
-  opacity: .2;
-}
-
-#nav-bar[brighttext] .toolbaritem-combined-buttons > separator,
-#nav-bar[brighttext] .toolbarbutton-1:not(:hover):not(:active):not([open]) > .toolbarbutton-menubutton-dropmarker::before {
-  opacity: .3;
-}
-
-.findbar-button:not(:-moz-any([checked="true"],[disabled="true"])):hover > .toolbarbutton-text,
-#nav-bar .toolbarbutton-1:not([disabled=true]) > .toolbarbutton-menubutton-button[open] + .toolbarbutton-menubutton-dropmarker > .dropmarker-icon,
-#nav-bar .toolbarbutton-1:not([disabled=true]):-moz-any(:hover,[open]) > .toolbarbutton-menubutton-button > .toolbarbutton-icon,
-#nav-bar .toolbarbutton-1:not([disabled=true]):-moz-any(:hover,[open]) > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon,
-#nav-bar .toolbarbutton-1:not([disabled=true]):not([checked]):not([open]):not(:active):hover > .toolbarbutton-icon,
-#nav-bar .toolbarbutton-1:not([disabled=true]):not([checked]):not([open]):not(:active):hover > .toolbarbutton-text,
-#nav-bar .toolbarbutton-1:not([disabled=true]):not([checked]):not([open]):not(:active):hover > .toolbarbutton-badge-stack,
-@conditionalForwardWithUrlbar@ > #forward-button:not([open]):not(:active):not([disabled]):hover > .toolbarbutton-icon,
-#nav-bar .toolbarbutton-1:not([buttonover]):not([open]):not(:active):hover > .toolbarbutton-menubutton-dropmarker:not([disabled]) > .dropmarker-icon {
-  background: var(--toolbarbutton-hover-background);
-  border-color: var(--toolbarbutton-hover-bordercolor);
-  box-shadow: var(--toolbarbutton-hover-boxshadow);
-}
-
-.findbar-button:not([disabled=true]):-moz-any([checked="true"],:hover:active) > .toolbarbutton-text,
-#nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-button:not([disabled=true]):-moz-any(:hover:active, [open]) > .toolbarbutton-icon,
-#nav-bar .toolbarbutton-1[open] > .toolbarbutton-menubutton-dropmarker:not([disabled=true]) > .dropmarker-icon,
-#nav-bar .toolbarbutton-1:not([disabled=true]):-moz-any([open],[checked],:hover:active) > .toolbarbutton-icon,
-#nav-bar .toolbarbutton-1:not([disabled=true]):-moz-any([open],[checked],:hover:active) > .toolbarbutton-text,
-#nav-bar .toolbarbutton-1:not([disabled=true]):-moz-any([open],[checked],:hover:active) > .toolbarbutton-badge-stack {
-  background: var(--toolbarbutton-active-background);
-  border-color: var(--toolbarbutton-active-bordercolor);
-  box-shadow: var(--toolbarbutton-active-boxshadow);
-  transition-duration: 10ms;
-}
-
-#nav-bar .toolbarbutton-1[checked]:not(:active):hover > .toolbarbutton-icon {
-  background-color: var(--toolbarbutton-checkedhover-backgroundcolor);
-  transition: background-color .4s;
-}
-
-#TabsToolbar .toolbarbutton-1,
-#TabsToolbar .toolbarbutton-1 > .toolbarbutton-menubutton-button,
-.tabbrowser-arrowscrollbox > .scrollbutton-up,
-.tabbrowser-arrowscrollbox > .scrollbutton-down {
-  -moz-appearance: none;
-  border-style: none;
-  padding: 0 3px;
-}
-
-#TabsToolbar .toolbarbutton-1 {
-  margin-bottom: var(--tab-toolbar-navbar-overlap);
-}
-
-#TabsToolbar .toolbarbutton-1:not([disabled=true]):hover,
-#TabsToolbar .toolbarbutton-1[open],
-#TabsToolbar .toolbarbutton-1 > .toolbarbutton-menubutton-button:not([disabled=true]):hover,
-.tabbrowser-arrowscrollbox > .scrollbutton-up:not([disabled=true]):hover,
-.tabbrowser-arrowscrollbox > .scrollbutton-down:not([disabled=true]):hover {
-  background-image: linear-gradient(transparent, rgba(255,255,255,.5)),
-                    linear-gradient(transparent, rgba(0,0,0,.25) 30%),
-                    linear-gradient(transparent, rgba(0,0,0,.25) 30%);
-  background-position: 1px -1px, 0 -1px, 100% -1px;
-  background-size: calc(100% - 2px) 100%, 1px 100%, 1px 100%;
-  background-repeat: no-repeat;
-}
-
-/* unified back/forward button */
-
-:-moz-any(#back-button, #forward-button) > .toolbarbutton-icon {
-  border-color: var(--urlbar-border-color-hover) !important;
-}
-
-:-moz-any(#back-button, #forward-button):not(:hover):not(:active):not([open=true]) > .toolbarbutton-icon,
-:-moz-any(#back-button, #forward-button)[disabled=true] > .toolbarbutton-icon {
-  background-color: rgba(255,255,255,.15) !important;
-}
-
-#forward-button {
-  -moz-box-align: stretch; /* let the button shape grow vertically with the location bar */
-  padding: 0 !important;
-}
-
-#forward-button > menupopup {
-  margin-top: 1px !important;
-}
-
-#forward-button > .toolbarbutton-icon {
-  border-left-style: none !important;
-  border-radius: 0 !important;
-  padding-left: calc(var(--backbutton-urlbar-overlap) + 3px) !important;
-  padding-right: 3px !important;
-  max-width: calc(var(--forwardbutton-width) + var(--backbutton-urlbar-overlap)) !important;
-}
-
-@conditionalForwardWithUrlbar@:not([switchingtabs]) > #forward-button {
-  transition: margin-left @forwardTransitionLength@ ease-out;
-}
-
-@conditionalForwardWithUrlbar@ > #forward-button[disabled] {
-  margin-left: calc(0px - var(--forwardbutton-width) - var(--backbutton-urlbar-overlap));
-}
-
-@conditionalForwardWithUrlbar@:hover:not([switchingtabs]) > #forward-button[disabled] {
-  /* delay the hiding of the forward button when hovered to avoid accidental clicks on the url bar */
-  transition-delay: 100s;
-}
-
-@conditionalForwardWithUrlbar@:not(:hover) > #forward-button[disabled] {
-  /* when not hovered anymore, trigger a new transition to hide the forward button immediately */
-  margin-left: calc(-0.01px - var(--forwardbutton-width) - var(--backbutton-urlbar-overlap));
-}
-
-#back-button {
-  padding-top: 3px !important;
-  padding-bottom: 3px !important;
-  padding-inline-start: 5px !important;
-  padding-inline-end: 0 !important;
-  position: relative !important;
-  z-index: 1 !important;
-  border-radius: 0 10000px 10000px 0 !important;
-}
-
-#back-button:-moz-locale-dir(rtl) {
-  border-radius: 10000px 0 0 10000px !important;
-}
-
-#back-button > menupopup {
-  margin-top: -1px !important;
-}
-
-#back-button > .toolbarbutton-icon {
-  border-radius: 10000px !important;
-  padding: 6px !important;
-  max-width: 32px !important; /* icon width + horizontal padding + border */
-}
-
-#back-button:-moz-locale-dir(rtl) > .toolbarbutton-icon {
-  transform: scaleX(-1);
-}
-
-.unified-nav-back[_moz-menuactive]:-moz-locale-dir(ltr),
-.unified-nav-forward[_moz-menuactive]:-moz-locale-dir(rtl) {
-  list-style-image: url("chrome://browser/skin/menu-back.png") !important;
-}
-
-.unified-nav-forward[_moz-menuactive]:-moz-locale-dir(ltr),
-.unified-nav-back[_moz-menuactive]:-moz-locale-dir(rtl) {
-  list-style-image: url("chrome://browser/skin/menu-forward.png") !important;
-}
-
-/* undo close tab menu item */
-#alltabs_undoCloseTab {
-  list-style-image: url(chrome://browser/skin/undoCloseTab.png);
-}
-
-@media (min-resolution: 1.1dppx) {
-  #alltabs_undoCloseTab {
-    list-style-image: url(chrome://browser/skin/undoCloseTab@2x.png);
-  }
-  #alltabs_undoCloseTab > .toolbarbutton-icon {
-    width: 16px;
-  }
-}
-
-/* zoom control text (reset) button special case: */
-
-#nav-bar #zoom-reset-button > .toolbarbutton-text {
-  /* To make this line up with the icons, it needs the same height (18px) +
-   * padding (2 * 2px) + border (2 * 1px), but as a minimum because otherwise
-   * increase in text sizes would break things...
-   */
-  min-height: 24px;
-}
-
-/* ::::: fullscreen window controls ::::: */
-
-#minimize-button,
-#restore-button,
-#close-button {
-  -moz-appearance: none;
-  border: none;
-  margin: 0 !important;
-  padding: 6px 12px;
-}
-
-#minimize-button {
-  list-style-image: url(chrome://browser/skin/caption-buttons.svg#minimize);
-}
-
-#restore-button {
-  list-style-image: url(chrome://browser/skin/caption-buttons.svg#restore);
-}
-
-#minimize-button:hover,
-#restore-button:hover {
-  background-color: hsla(0, 0%, 0%, .12);
-}
-
-#minimize-button:hover:active,
-#restore-button:hover:active {
-  background-color: hsla(0, 0%, 0%, .22);
-}
-
-#close-button {
-  list-style-image: url(chrome://browser/skin/caption-buttons.svg#close);
-}
-
-#close-button:hover {
-  background-color: hsl(355, 86%, 49%);
-  list-style-image: url(chrome://browser/skin/caption-buttons.svg#close-white);
-}
-
-#close-button:hover:active {
-  background-color: hsl(355, 82%, 69%);
-}
-
-toolbar[brighttext] #minimize-button {
-  list-style-image: url(chrome://browser/skin/caption-buttons.svg#minimize-white);
-}
-
-toolbar[brighttext] #restore-button {
-  list-style-image: url(chrome://browser/skin/caption-buttons.svg#restore-white);
-}
-
-toolbar[brighttext] #close-button {
-  list-style-image: url(chrome://browser/skin/caption-buttons.svg#close-white);
-}
-
-@media (-moz-os-version: windows-xp),
-       (-moz-os-version: windows-vista),
-       (-moz-os-version: windows-win7) {
-  #window-controls {
-    margin-inline-start: 4px;
-  }
-
-  #minimize-button,
-  #restore-button,
-  #close-button {
-    list-style-image: url("chrome://global/skin/icons/windowControls.png");
-    padding: 0;
-  }
-
-  #minimize-button {
-    -moz-image-region: rect(0, 16px, 16px, 0);
-  }
-
-  #minimize-button:hover {
-    -moz-image-region: rect(16px, 16px, 32px, 0);
-  }
-
-  #minimize-button:hover:active {
-    -moz-image-region: rect(32px, 16px, 48px, 0);
-  }
-
-  #restore-button {
-    -moz-image-region: rect(0, 32px, 16px, 16px);
-  }
-
-  #restore-button:hover {
-    -moz-image-region: rect(16px, 32px, 32px, 16px);
-  }
-
-  #restore-button:hover:active {
-    -moz-image-region: rect(32px, 32px, 48px, 16px);
-  }
-
-  #close-button {
-    -moz-image-region: rect(0, 48px, 16px, 32px);
-    -moz-appearance: none;
-    border-style: none;
-    margin: 2px;
-  }
-
-  #close-button:hover {
-    -moz-image-region: rect(16px, 48px, 32px, 32px);
-  }
-
-  #close-button:hover:active {
-    -moz-image-region: rect(32px, 48px, 48px, 32px);
-  }
-}
-
-@media (-moz-os-version: windows-vista),
-       (-moz-os-version: windows-win7) {
-  #window-controls {
-    -moz-box-align: start;
-  }
-
-  #minimize-button,
-  #restore-button,
-  #close-button {
-    -moz-appearance: none;
-    border-style: none;
-    margin: 0;
-  }
-
-  #close-button {
-    -moz-image-region: rect(0, 49px, 16px, 32px);
-  }
-
-  #close-button:hover {
-    -moz-image-region: rect(16px, 49px, 32px, 32px);
-  }
-
-  #close-button:hover:active {
-    -moz-image-region: rect(32px, 49px, 48px, 32px);
-  }
-
-  #minimize-button:-moz-locale-dir(rtl),
-  #restore-button:-moz-locale-dir(rtl),
-  #close-button:-moz-locale-dir(rtl) {
-    transform: scaleX(-1);
-  }
-}
-
-/* ::::: Location Bar ::::: */
-
-#main-window {
-  --urlbar-border-color: ThreeDShadow;
-  --urlbar-border-color-hover: var(--urlbar-border-color);
-}
-
-#navigator-toolbox:-moz-lwtheme {
-  --urlbar-border-color: var(--toolbarbutton-hover-bordercolor);
-}
-
-@media (-moz-windows-default-theme) {
-  @media (-moz-os-version: windows-vista),
-         (-moz-os-version: windows-win7),
-         (-moz-os-version: windows-win8) {
-    #main-window:not(:-moz-lwtheme) {
-      --urlbar-border-color: hsla(210,54%,20%,.25) hsla(210,54%,20%,.27) hsla(210,54%,20%,.3);
-      --urlbar-border-color-hover: hsla(210,54%,20%,.35) hsla(210,54%,20%,.37) hsla(210,54%,20%,.4);
-    }
-  }
-
-  @media (-moz-os-version: windows-win10) {
-    #main-window:not(:-moz-lwtheme) {
-      --urlbar-border-color: hsl(0,0%,90%);
-      --urlbar-border-color-hover: hsl(0,0%,80%);
-    }
-  }
-}
-
-#urlbar,
-.searchbar-textbox {
-  -moz-appearance: none;
-  margin: 0 3px;
-  padding: 0;
-  background-clip: padding-box;
-  border: 1px solid;
-  border-color: var(--urlbar-border-color);
-}
-
-#urlbar:hover,
-.searchbar-textbox:hover {
-  border-color: var(--urlbar-border-color-hover);
-}
-
-@media (-moz-windows-default-theme) {
-  #urlbar,
-  .searchbar-textbox {
-    border-radius: 1px;
-  }
-
-  @media (-moz-os-version: windows-vista),
-         (-moz-os-version: windows-win7),
-         (-moz-os-version: windows-win8) {
-    #urlbar:not(:-moz-lwtheme),
-    .searchbar-textbox:not(:-moz-lwtheme) {
-      box-shadow: 0 1px 0 hsla(0,0%,0%,.01) inset,
-                  0 1px 0 hsla(0,0%,100%,.1);
-    }
-  }
-
-  @media (-moz-os-version: windows-win10) {
-    #urlbar:not(:-moz-lwtheme),
-    .searchbar-textbox:not(:-moz-lwtheme) {
-      padding: 1px;
-      transition-property: border-color, box-shadow;
-      transition-duration: .1s;
-    }
-
-    #urlbar:not(:-moz-lwtheme)[focused],
-    .searchbar-textbox:not(:-moz-lwtheme)[focused] {
-      box-shadow: 0 0 0 1px Highlight inset;
-    }
-  }
-
-  @media not all and (-moz-os-version: windows-xp) {
-    #urlbar:not(:-moz-lwtheme)[focused],
-    .searchbar-textbox:not(:-moz-lwtheme)[focused] {
-      border-color: Highlight;
-    }
-  }
-}
-
-@media (-moz-os-version: windows-win10) {
-  #urlbar,
-  .searchbar-textbox {
-    font-size: 1.15em;
-    min-height: 28px;
-  }
-
-  :root {
-    /* let toolbar buttons match the location and search bar's minimum height */
-    --toolbarbutton-vertical-inner-padding: 4px;
-    --toolbarbutton-vertical-outer-padding: 5px;
-  }
-}
-
-#urlbar:-moz-lwtheme,
-.searchbar-textbox:-moz-lwtheme {
-  background-color: rgba(255,255,255,.8);
-  color: black;
-}
-
-#urlbar:-moz-lwtheme:hover:not([readonly]),
-.searchbar-textbox:-moz-lwtheme:hover {
-  background-color: rgba(255,255,255,.9);
-}
-
-#urlbar:-moz-lwtheme[focused]:not([readonly]),
-.searchbar-textbox:-moz-lwtheme[focused] {
-  background-color: white;
-}
-
-@conditionalForwardWithUrlbar@ > #urlbar {
-  border-inline-start: none;
-  padding-inline-start: 0;
-  margin-left: 0;
-}
-
-@conditionalForwardWithUrlbar@ > #urlbar:-moz-locale-dir(ltr) {
-  border-top-left-radius: 0;
-  border-bottom-left-radius: 0;
-}
-
-@conditionalForwardWithUrlbar@ > #urlbar:-moz-locale-dir(rtl) {
-  border-top-right-radius: 0;
-  border-bottom-right-radius: 0;
-}
-
-@conditionalForwardWithUrlbar@ {
-  clip-path: url("chrome://browser/content/browser.xul#urlbar-back-button-clip-path");
-  margin-inline-start: calc(-1 * var(--backbutton-urlbar-overlap));
-}
-
-@media (-moz-os-version: windows-win10) {
-  @conditionalForwardWithUrlbar@ {
-    clip-path: url("chrome://browser/content/browser.xul#urlbar-back-button-clip-path-win10");
-  }
-
-  :root {
-    --backbutton-urlbar-overlap: 9px;
-  }
-}
-
-@conditionalForwardWithUrlbar@:-moz-locale-dir(rtl),
-@conditionalForwardWithUrlbar@ > #urlbar:-moz-locale-dir(rtl) {
-  /* let urlbar-back-button-clip-path clip the urlbar's right side for RTL */
-  transform: scaleX(-1);
-}
-
-@conditionalForwardWithUrlbar@:-moz-locale-dir(rtl) {
-  -moz-box-direction: reverse;
-}
-
-html|*.urlbar-input:-moz-lwtheme::-moz-placeholder,
-.searchbar-textbox:-moz-lwtheme > .autocomplete-textbox-container > .textbox-input-box > html|*.textbox-input::-moz-placeholder {
-  opacity: 1.0;
-  color: #777;
-}
-
-#urlbar-container {
-  -moz-box-align: center;
-}
-
-.urlbar-textbox-container {
-  -moz-box-align: stretch;
-}
-
-.urlbar-input-box {
-  margin-inline-start: 0;
-}
-
-.urlbar-input-box,
-#urlbar-display-box {
-  padding-inline-start: 4px;
-  border-inline-start: 1px solid var(--urlbar-separator-color);
-  border-image: linear-gradient(transparent 15%, var(--urlbar-separator-color) 15%, var(--urlbar-separator-color) 85%, transparent 85%);
-  border-image-slice: 1;
-}
-
-#urlbar-icons {
-  -moz-box-align: center;
-}
-
-.urlbar-icon {
-  padding: 0 3px;
-  /* 16x16 icon with border-box sizing */
-  width: 22px;
-  height: 16px;
-}
-
-/* ::::: URL Bar Zoom Reset Button ::::: */
-@keyframes urlbar-zoom-reset-pulse {
-  0% {
-    transform: scale(0);
-  }
-  75% {
-    transform: scale(1.5);
-  }
-  100% {
-    transform: scale(1.0);
-  }
-}
-
-#urlbar-zoom-button {
-  -moz-appearance: none;
-  margin: 0 3px;
-  font-size: .8em;
-  padding: 0 8px;
-  border-radius: 1em;
-  background-color: hsla(0,0%,0%,.05);
-  border: 1px solid ThreeDLightShadow;
-}
-
-#urlbar-zoom-button[animate="true"] {
-  animation-name: urlbar-zoom-reset-pulse;
-  animation-duration: 250ms;
-}
-
-#urlbar-zoom-button:hover:active {
-  background-color: hsla(0,0%,0%,.1);
-}
-
-#urlbar-zoom-button > .toolbarbutton-text {
-  display: -moz-box;
-}
-
-#urlbar-zoom-button > .toolbarbutton-icon {
-  display: none;
-}
-
-.search-go-container {
-  padding: 2px 2px;
-}
-
-#urlbar-search-footer {
-  border-top: 1px solid var(--panel-separator-color);
-  background-color: hsla(210,4%,10%,.07);
-}
-
-#urlbar-search-settings {
-  -moz-appearance: none;
-  -moz-user-focus: ignore;
-  color: GrayText;
-  margin: 0;
-  border: 0;
-  padding: 8px 20px;
-  background: transparent;
-}
-
-#urlbar-search-settings:hover {
-  background-color: hsla(210,4%,10%,.07);
-}
-
-#urlbar-search-settings:hover:active {
-  background-color: hsla(210,4%,10%,.12);
-}
-
-#urlbar-search-splitter {
-  min-width: 6px;
-  margin-inline-start: -3px;
-  border: none;
-  background: transparent;
-}
-
-#urlbar-search-splitter + #search-container > #searchbar > .searchbar-textbox {
-  margin-inline-start: 0;
-}
-
-.urlbar-display {
-  margin-top: 0;
-  margin-bottom: 0;
-  margin-inline-start: 0;
-  color: GrayText;
-}
-
-%include ../shared/urlbarSearchSuggestionsNotification.inc.css
-
-#search-container {
-  min-width: calc(54px + 11ch);
-}
-
-/* identity box */
-
-#identity-box:-moz-focusring {
-  outline: 1px dotted;
-  outline-offset: -3px;
-}
-
-/* Location bar dropmarker */
-
-.urlbar-history-dropmarker {
-  -moz-appearance: none;
-  padding: 0 3px;
-  background-color: transparent;
-  border: none;
-  width: auto;
-  list-style-image: var(--urlbar-dropmarker-url);
-  -moz-image-region: var(--urlbar-dropmarker-region);
-  transition: opacity 0.15s ease;
-}
-
-#urlbar-wrapper[switchingtabs] > #urlbar > .urlbar-textbox-container > .urlbar-history-dropmarker {
-  transition: none;
-}
-
-#navigator-toolbox:not(:hover) #nav-bar:not([customizing="true"]) #urlbar:not([focused]) > .urlbar-textbox-container > .urlbar-history-dropmarker {
-  opacity: 0;
-}
-
-.urlbar-history-dropmarker:hover {
-  -moz-image-region: var(--urlbar-dropmarker-hover-region);
-}
-
-.urlbar-history-dropmarker:hover:active,
-.urlbar-history-dropmarker[open="true"] {
-  -moz-image-region: var(--urlbar-dropmarker-active-region);
-}
-
-@media (min-resolution: 1.1dppx) {
-  .urlbar-history-dropmarker {
-    list-style-image: var(--urlbar-dropmarker-2x-url);
-    -moz-image-region: var(--urlbar-dropmarker-2x-region);
-  }
-
-  .urlbar-history-dropmarker:hover {
-    -moz-image-region: var(--urlbar-dropmarker-hover-2x-region);
-  }
-
-  .urlbar-history-dropmarker[open="true"],
-  .urlbar-history-dropmarker:hover:active {
-    -moz-image-region: var(--urlbar-dropmarker-active-2x-region);
-  }
-
-  .urlbar-history-dropmarker > .dropmarker-icon {
-    width: 11px;
-  }
-}
-
-/* page proxy icon */
-
-%include ../shared/identity-block/identity-block.inc.css
-
-/* autocomplete */
-
-#treecolAutoCompleteImage {
-  max-width: 36px;
-}
-
-.autocomplete-richlistbox {
-  padding: 4px;
-}
-
-.autocomplete-richlistitem {
-  height: 30px;
-  min-height: 30px;
-  font: message-box;
-  border-radius: 2px;
-  border: 1px solid transparent;
-}
-
-.autocomplete-richlistitem[selected=true] {
-  background-color: hsl(210, 80%, 52%);
-}
-
-.ac-title {
-  font-size: 14px;
-  color: hsl(0, 0%, 0%);
-}
-
-.ac-tags {
-  font-size: 12px;
-}
-
-html|span.ac-tag {
-  background-color: hsl(216, 0%, 88%);
-  color: hsl(0, 0%, 0%);
-  border-radius: 2px;
-  border: 1px solid transparent;
-  padding: 0 1px;
-}
-
-.ac-separator,
-.ac-url,
-.ac-action {
-  font-size: 12px;
-}
-
-.ac-separator {
-  color: hsl(0, 0%, 50%);
-}
-
-.ac-url {
-  color: hsl(210, 77%, 47%);
-}
-
-.ac-action {
-  color: hsl(178, 100%, 28%);
-}
-
-.ac-title[selected=true],
-.ac-separator[selected],
-.ac-url[selected=true],
-.ac-action[selected=true] {
-  color: hsl(0, 0%, 100%);
-}
-
-.ac-tags-text[selected] > html|span.ac-tag {
-  background-color: hsl(0, 0%, 100%);
-  color: hsl(210, 80%, 40%);
-}
-
-html|span.ac-emphasize-text-title,
-html|span.ac-emphasize-text-tag,
-html|span.ac-emphasize-text-url {
-  font-weight: 600;
-}
-
-@media not all and (-moz-windows-default-theme) {
-  .autocomplete-richlistitem[selected=true] {
-    background-color: Highlight;
-  }
-
-  .ac-title {
-    color: inherit;
-  }
-
-  html|span.ac-tag {
-    background-color: -moz-FieldText;
-    color: -moz-Field;
-  }
-
-  .ac-separator,
-  .ac-url,
-  .ac-action {
-    color: -moz-nativehyperlinktext;
-  }
-
-  .ac-tags-text[selected] > html|span.ac-tag {
-    background-color: HighlightText;
-    color: Highlight;
-  }
-}
-
-.ac-type-icon[type=bookmark] {
-  list-style-image: url("chrome://browser/skin/urlbar-star.svg#star");
-}
-
-.ac-type-icon[type=bookmark][selected][current] {
-  list-style-image: url("chrome://browser/skin/urlbar-star.svg#star-inverted");
-}
-
-.autocomplete-treebody::-moz-tree-image(bookmark, treecolAutoCompleteImage) {
-  list-style-image: url("chrome://browser/skin/places/autocomplete-star.png");
-  -moz-image-region: rect(0 16px 16px 0);
-  width: 16px;
-  height: 16px;
-}
-
-@media (min-resolution: 1.1dppx) {
-  .autocomplete-treebody::-moz-tree-image(bookmark, treecolAutoCompleteImage) {
-    list-style-image: url("chrome://browser/skin/places/autocomplete-star@2x.png");
-    -moz-image-region: rect(0 32px 32px 0);
-  }
-}
-
-@media not all and (-moz-os-version: windows-vista) and (-moz-windows-default-theme) {
-  @media not all and (-moz-os-version: windows-win7) and (-moz-windows-default-theme) {
-    .autocomplete-treebody::-moz-tree-image(selected, current, bookmark, treecolAutoCompleteImage) {
-      -moz-image-region: rect(0 32px 16px 16px);
-    }
-
-    @media (min-resolution: 1.1dppx) {
-      .autocomplete-treebody::-moz-tree-image(selected, current, bookmark, treecolAutoCompleteImage) {
-        -moz-image-region: rect(0 64px 32px 32px);
-      }
-    }
-
-    .autocomplete-treebody::-moz-tree-image(keyword, treecolAutoCompleteImage, selected) {
-      list-style-image: url(chrome://global/skin/icons/autocomplete-search.svg#search-icon-inverted);
-    }
-  }
-}
-
-.ac-type-icon[type=keyword],
-.ac-site-icon[type=searchengine],
-.autocomplete-treebody::-moz-tree-image(keyword, treecolAutoCompleteImage) {
-  list-style-image: url(chrome://global/skin/icons/autocomplete-search.svg#search-icon);
-}
-
-.ac-type-icon[type=keyword][selected],
-.ac-site-icon[type=searchengine][selected],
-.autocomplete-treebody::-moz-tree-image(keyword, treecolAutoCompleteImage, selected) {
-  list-style-image: url(chrome://global/skin/icons/autocomplete-search.svg#search-icon-inverted);
-}
-
-.autocomplete-treebody::-moz-tree-image(tag, treecolAutoCompleteImage) {
-  list-style-image: url("chrome://browser/skin/places/tag.png");
-  width: 16px;
-  height: 16px;
-}
-
-.ac-type-icon[type=switchtab],
-.ac-type-icon[type=remotetab] {
-  list-style-image: url("chrome://browser/skin/urlbar-tab.svg#tab");
-}
-
-.ac-type-icon[type=switchtab][selected],
-.ac-type-icon[type=remotetab][selected] {
-  list-style-image: url("chrome://browser/skin/urlbar-tab.svg#tab-inverted");
-}
-
-.autocomplete-treebody::-moz-tree-cell-text(treecolAutoCompleteComment) {
-  color: GrayText;
-}
-
-.autocomplete-treebody::-moz-tree-cell-text(suggesthint, treecolAutoCompleteComment),
-.autocomplete-treebody::-moz-tree-cell-text(suggestfirst, treecolAutoCompleteComment)
-{
-  color: GrayText;
-  font-size: smaller;
-}
-
-.autocomplete-treebody::-moz-tree-cell(suggesthint) {
-  border-top: 1px solid GrayText;
-}
-
-/* combined go/reload/stop button in location bar */
-
-#urlbar-go-button,
-#urlbar-reload-button,
-#urlbar-stop-button {
-  -moz-appearance: none;
-  border-style: none;
-  list-style-image: url("chrome://browser/skin/reload-stop-go.png");
-  padding: 0 9px;
-  margin-inline-start: 5px;
-  border-inline-start: 1px solid var(--urlbar-separator-color);
-  border-image: linear-gradient(transparent 15%,
-                                var(--urlbar-separator-color) 15%,
-                                var(--urlbar-separator-color) 85%,
-                                transparent 85%);
-  border-image-slice: 1;
-}
-
-#urlbar-reload-button {
-  -moz-image-region: rect(0, 14px, 14px, 0);
-}
-
-#urlbar-reload-button:not([disabled]):hover {
-  -moz-image-region: rect(14px, 14px, 28px, 0);
-}
-
-#urlbar-reload-button:not([disabled]):hover:active {
-  -moz-image-region: rect(28px, 14px, 42px, 0);
-}
-
-#urlbar-reload-button:-moz-locale-dir(rtl) > .toolbarbutton-icon {
-  transform: scaleX(-1);
-}
-
-#urlbar-go-button {
-  -moz-image-region: rect(0, 42px, 14px, 28px);
-}
-
-#urlbar-go-button:hover {
-  -moz-image-region: rect(14px, 42px, 28px, 28px);
-}
-
-#urlbar-go-button:hover:active {
-  -moz-image-region: rect(28px, 42px, 42px, 28px);
-}
-
-#urlbar-go-button:-moz-locale-dir(rtl) > .toolbarbutton-icon {
-  transform: scaleX(-1);
-}
-
-#urlbar-stop-button {
-  -moz-image-region: rect(0, 28px, 14px, 14px);
-}
-
-#urlbar-stop-button:not([disabled]):hover {
-  -moz-image-region: rect(14px, 28px, 28px, 14px);
-}
-
-#urlbar-stop-button:hover:active {
-  -moz-image-region: rect(28px, 28px, 42px, 14px);
-}
-
-@media (min-resolution: 1.1dppx) {
-  #urlbar-go-button,
-  #urlbar-reload-button,
-  #urlbar-stop-button {
-    list-style-image: url("chrome://browser/skin/reload-stop-go@2x.png");
-  }
-
-  #urlbar-go-button > .toolbarbutton-icon,
-  #urlbar-reload-button > .toolbarbutton-icon,
-  #urlbar-stop-button > .toolbarbutton-icon {
-    width: 14px;
-  }
-
-  #urlbar-go-button {
-    -moz-image-region: rect(0, 84px, 28px, 56px);
-  }
-
-  #urlbar-go-button:hover {
-    -moz-image-region: rect(28px, 84px, 56px, 56px);
-  }
-
-  #urlbar-go-button:hover:active {
-    -moz-image-region: rect(56px, 84px, 84px, 56px);
-  }
-
-  #urlbar-reload-button {
-    -moz-image-region: rect(0, 28px, 28px, 0);
-  }
-
-  #urlbar-reload-button:not([disabled]):hover {
-    -moz-image-region: rect(28px, 28px, 56px, 0);
-  }
-
-  #urlbar-reload-button:not([disabled]):hover:active {
-    -moz-image-region: rect(56px, 28px, 84px, 0);
-  }
-
-  #urlbar-stop-button {
-    -moz-image-region: rect(0, 56px, 28px, 28px);
-  }
-
-  #urlbar-stop-button:not([disabled]):hover {
-    -moz-image-region: rect(28px, 56px, 56px, 28px);
-  }
-
-  #urlbar-stop-button:hover:active {
-    -moz-image-region: rect(56px, 56px, 84px, 28px);
-  }
-}
-
-/* popup blocker button */
-
-#page-report-button {
-  list-style-image: url("chrome://browser/skin/urlbar-popup-blocked.png");
-  -moz-image-region: rect(0, 16px, 16px, 0);
-}
-
-#page-report-button:hover {
-  -moz-image-region: rect(0, 32px, 16px, 16px);
-}
-
-#page-report-button:hover:active,
-#page-report-button[open="true"] {
-  -moz-image-region: rect(0, 48px, 16px, 32px);
-}
-
-/* Reader mode button */
-
-#reader-mode-button {
-  list-style-image: url("chrome://browser/skin/readerMode.svg");
-  -moz-image-region: rect(0, 16px, 16px, 0);
-}
-
-#reader-mode-button:hover,
-#reader-mode-button[readeractive]:hover {
-  -moz-image-region: rect(0, 32px, 16px, 16px);
-}
-
-#reader-mode-button:hover:active,
-#reader-mode-button[readeractive] {
-  -moz-image-region: rect(0, 48px, 16px, 32px);
-}
-
-/* social share panel */
-%include ../shared/social/social.inc.css
-
-.social-panel-frame {
-  border-radius: inherit;
-}
-
-.social-share-frame {
-  min-width: 756px;
-  height: 150px;
-}
-#share-container {
-  min-width: 756px;
-  background-color: white;
-  background-repeat: no-repeat;
-  background-position: center center;
-}
-#share-container[loading] {
-  background-image: url(chrome://browser/skin/tabbrowser/pendingpaint.png);
-}
-#share-container > browser {
-  transition: opacity 150ms ease-in-out;
-  opacity: 1;
-}
-#share-container[loading] > browser {
-  opacity: 0;
-}
-
-.social-share-toolbar {
-  border-bottom: 1px solid #e2e5e8;
-  padding: 2px;
-}
-
-#social-share-provider-buttons {
-  padding: 0;
-  margin: 0;
-}
-
-.share-provider-button {
-  padding: 5px;
-  margin: 2px;
-}
-
-.share-provider-button > .toolbarbutton-text {
-  display: none;
-}
-.share-provider-button > .toolbarbutton-icon {
-  width: 16px;
-  min-height: 16px;
-  max-height: 16px;
-}
-
-#social-share-panel {
-  min-height: 100px;
-  min-width: 766px;
-}
-
-#share-container,
-.social-share-frame {
-  border-top-left-radius: 0;
-  border-bottom-left-radius: inherit;
-  border-top-right-radius: 0;
-  border-bottom-right-radius: inherit;
-}
-
-#social-share-panel > .social-share-toolbar {
-  border-top-left-radius: inherit;
-  border-top-right-radius: inherit;
-}
-
-#social-share-provider-buttons {
-  border-top-left-radius: inherit;
-  border-top-right-radius: inherit;
-}
-
-/* bookmarks menu-button */
-
-#nav-bar #bookmarks-menu-button[cui-areatype="toolbar"]:not([overflowedItem=true]) > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon {
-  padding-top: var(--toolbarbutton-vertical-inner-padding);
-  padding-bottom: var(--toolbarbutton-vertical-inner-padding);
-}
-
-#BMB_bookmarksPopup[side="top"],
-#BMB_bookmarksPopup[side="bottom"] {
-  margin-left: -20px;
-  margin-right: -20px;
-}
-
-#BMB_bookmarksPopup[side="left"],
-#BMB_bookmarksPopup[side="right"] {
-  margin-top: -20px;
-  margin-bottom: -20px;
-}
-
-/* bookmarking panel */
-
-#editBookmarkPanelStarIcon {
-  list-style-image: url("chrome://browser/skin/places/starred48.png");
-  width: 48px;
-  height: 48px;
-}
-
-#editBookmarkPanelStarIcon[unstarred] {
-  list-style-image: url("chrome://browser/skin/places/unstarred48.png");
-}
-
-#editBookmarkPanelTitle {
-  font-size: 130%;
-}
-
-#editBookmarkPanelHeader,
-#editBookmarkPanelContent {
-  margin-bottom: .5em;
-}
-
-/* Implements editBookmarkPanel resizing on folderTree un-collapse. */
-#editBMPanel_folderTree {
-  min-width: 27em;
-}
-
-/* ::::: content area ::::: */
-
-#sidebar {
-  background-color: Window;
-}
-
-#sidebar-title {
-  padding-inline-start: 0px;
-}
-
-#sidebar-header > .close-icon {
-  -moz-appearance: none;
-  padding: 2px;
-  margin: 0;
-  border: none;
-}
-
-@media not all and (min-resolution: 1.1dppx) {
-  #sidebar-header > .close-icon:-moz-lwtheme-brighttext {
-    list-style-image: url("chrome://global/skin/icons/close-inverted.png");
-  }
-}
-
-@media (min-resolution: 1.1dppx) {
-  #sidebar-header > .close-icon:-moz-lwtheme-brighttext {
-    list-style-image: url("chrome://global/skin/icons/close-inverted@2x.png");
-  }
-}
-
-@media (-moz-os-version: windows-xp),
-       (-moz-os-version: windows-vista),
-       (-moz-os-version: windows-win7) {
-  #sidebar-header > .close-icon {
-    padding-top: 4px;
-    padding-bottom: 4px;
-  }
-}
-
-.browserContainer > findbar {
-  background-color: -moz-dialog;
-  color: -moz-DialogText;
-  text-shadow: none;
-}
-
-/* Tabstrip */
-
-#TabsToolbar {
-  min-height: 0;
-  padding: 0;
-  margin-bottom: calc(-1 * var(--tab-toolbar-navbar-overlap)); /* overlap the nav-bar's top border */
-}
-
-@media (-moz-os-version: windows-xp) and (-moz-windows-default-theme) {
-  #main-window[sizemode=normal] #TabsToolbar {
-    padding-left: 2px;
-    padding-right: 2px;
-  }
-}
-
-%include ../shared/tabs.inc.css
-
-/* Remove border between tab strip and navigation toolbar on Windows 10+ */
-@media not all and (-moz-os-version: windows-xp) {
-  @media not all and (-moz-os-version: windows-vista) {
-    @media not all and (-moz-os-version: windows-win7) {
-      @media not all and (-moz-os-version: windows-win8) {
-        @media (-moz-windows-default-theme) {
-          .tab-background-end[selected=true]::after,
-          .tab-background-start[selected=true]::after {
-            content: none;
-          }
-
-          #TabsToolbar {
-            --tab-stroke-background-size: 0 0;
-          }
-
-          :root {
-            --tab-toolbar-navbar-overlap: 0px;
-          }
-
-          #nav-bar {
-            border-top-style: none !important;
-            box-shadow: none;
-          }
-        }
-      }
-    }
-  }
-}
-
-/* Invert the unhovered close tab icons on bright-text tabs */
-@media not all and (min-resolution: 1.1dppx) {
-  .tab-close-button:-moz-lwtheme-brighttext,
-  #TabsToolbar[brighttext] .tab-close-button:not([selected="true"]) {
-    list-style-image: url("chrome://global/skin/icons/close-inverted.png");
-  }
-}
-
-@media (min-resolution: 1.1dppx) {
-  .tab-close-button:-moz-lwtheme-brighttext,
-  #TabsToolbar[brighttext] .tab-close-button:not([selected="true"]) {
-    list-style-image: url("chrome://global/skin/icons/close-inverted@2x.png");
-  }
-}
-
-/* tabbrowser-tab focus ring */
-.tabbrowser-tab:focus > .tab-stack > .tab-content {
-  outline: 1px dotted;
-  outline-offset: -6px;
-}
-
-/* Tab DnD indicator */
-.tab-drop-indicator {
-  list-style-image: url(chrome://browser/skin/tabbrowser/tabDragIndicator.png);
-  margin-bottom: -9px;
-  z-index: 3;
-}
-
-/* Tab close button */
-.tab-close-button {
-  -moz-appearance: none;
-  border: none;
-}
-
-/* Tab scrollbox arrow, tabstrip new tab and all-tabs buttons */
-
-.tabbrowser-arrowscrollbox > .scrollbutton-up,
-.tabbrowser-arrowscrollbox > .scrollbutton-down {
-  list-style-image: url("chrome://browser/skin/tabbrowser/tab-arrow-left.svg");
-  margin: 0 0 var(--tab-toolbar-navbar-overlap);
-}
-
-#TabsToolbar[brighttext] > #tabbrowser-tabs > .tabbrowser-arrowscrollbox > .scrollbutton-up,
-#TabsToolbar[brighttext] > #tabbrowser-tabs > .tabbrowser-arrowscrollbox > .scrollbutton-down {
-  list-style-image: url(chrome://browser/skin/tabbrowser/tab-arrow-left-inverted.svg);
-}
-
-.tabbrowser-arrowscrollbox > .scrollbutton-up[disabled],
-.tabbrowser-arrowscrollbox > .scrollbutton-down[disabled] {
-  opacity: .4;
-}
-
-.tabbrowser-arrowscrollbox > .scrollbutton-up:-moz-locale-dir(rtl),
-.tabbrowser-arrowscrollbox > .scrollbutton-down:-moz-locale-dir(ltr) {
-  transform: scaleX(-1);
-}
-
-.tabbrowser-arrowscrollbox > .scrollbutton-down {
-  transition: 1s background-color ease-out;
-}
-
-.tabbrowser-arrowscrollbox > .scrollbutton-down[notifybgtab] {
-  background-color: Highlight;
-  transition: none;
-}
-
-.tabs-newtab-button > .toolbarbutton-icon {
-  margin-top: -1px;
-  margin-bottom: -1px;
-}
-
-.tabs-newtab-button,
-#TabsToolbar > #new-tab-button,
-#TabsToolbar > toolbarpaletteitem > #new-tab-button {
-  list-style-image: url(chrome://browser/skin/tabbrowser/newtab.svg);
-  -moz-image-region: auto;
-}
-
-#TabsToolbar[brighttext] .tabs-newtab-button,
-#TabsToolbar[brighttext] > #new-tab-button,
-#TabsToolbar[brighttext] > toolbarpaletteitem > #new-tab-button {
-  list-style-image: url(chrome://browser/skin/tabbrowser/newtab-inverted.svg);
-}
-
-.tabs-newtab-button > .toolbarbutton-icon,
-#TabsToolbar > #new-tab-button > .toolbarbutton-icon,
-#TabsToolbar > toolbarpaletteitem > #new-tab-button > .toolbarbutton-icon {
-  width: 16px;
-}
-
-#TabsToolbar > #new-tab-button {
-  width: 26px;
-}
-
-#alltabs-button {
-  list-style-image: url("chrome://browser/skin/toolbarbutton-dropdown-arrow.png");
-}
-
-#TabsToolbar[brighttext] > #alltabs-button,
-#TabsToolbar[brighttext] > toolbarpaletteitem > #alltabs-button {
-  list-style-image: url("chrome://browser/skin/toolbarbutton-dropdown-arrow-inverted.png");
-}
-
-#alltabs-button > .toolbarbutton-icon {
-  margin: 0 2px;
-}
-
-#alltabs-button > .toolbarbutton-menu-dropmarker {
-  display: none;
-}
-
-/* All tabs menupopup */
-.alltabs-item > .menu-iconic-left > .menu-iconic-icon {
-  list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png");
-}
-
-.alltabs-item[selected="true"] {
-  font-weight: bold;
-}
-
-.alltabs-item[busy] > .menu-iconic-left > .menu-iconic-icon {
-  list-style-image: url("chrome://global/skin/icons/loading.png");
-}
-
-@media (min-resolution: 1.1dppx) {
-  .alltabs-item[busy] > .menu-iconic-left > .menu-iconic-icon {
-    list-style-image: url("chrome://global/skin/icons/loading@2x.png");
-  }
-}
-
-toolbarbutton.chevron {
-  list-style-image: url("chrome://global/skin/toolbar/chevron.gif") !important;
-}
-
-toolbar[brighttext] toolbarbutton.chevron {
-  list-style-image: url("chrome://global/skin/toolbar/chevron-inverted.png") !important;
-}
-
-toolbarbutton.chevron:-moz-locale-dir(rtl) > .toolbarbutton-icon {
-  transform: scaleX(-1);
-}
-
-toolbarbutton.chevron > .toolbarbutton-text,
-toolbarbutton.chevron > .toolbarbutton-menu-dropmarker {
-  display: none;
-}
-
-toolbarbutton.chevron > .toolbarbutton-icon {
-  margin: 0;
-}
-
-#sidebar-throbber[loading="true"] {
-  list-style-image: url("chrome://global/skin/icons/loading.png");
-  margin-inline-end: 4px;
-}
-
-@media (min-resolution: 1.1dppx) {
-  #sidebar-throbber[loading="true"] {
-    list-style-image: url("chrome://global/skin/icons/loading@2x.png");
-    width: 16px;
-  }
-}
-
-/* Bookmarks toolbar */
-#PlacesToolbarDropIndicator {
-  list-style-image: url(chrome://browser/skin/places/toolbarDropMarker.png);
-}
-
-toolbarbutton.bookmark-item[dragover="true"][open="true"] {
-  -moz-appearance: none;
-  background: Highlight !important;
-  color: HighlightText !important;
-}
-
-/* rules for menupopup drop indicators */
-.menupopup-drop-indicator-bar {
-  position: relative;
-  /* these two margins must together compensate the indicator's height */
-  margin-top: -1px;
-  margin-bottom: -1px;
-}
-
-.menupopup-drop-indicator {
-  list-style-image: none;
-  height: 2px;
-  margin-inline-end: -4em;
-  background-color: Highlight;
-}
-
-%include ../shared/notification-icons.inc.css
-
-.popup-notification-body[popupid="addon-progress"],
-.popup-notification-body[popupid="addon-install-confirmation"] {
-  width: 28em;
-  max-width: 28em;
-}
-
-.addon-install-confirmation-name {
-  font-weight: bold;
-}
-
-/* Notification icon box */
-
-.notification-anchor-icon:-moz-focusring {
-  outline: 1px dotted -moz-DialogText;
-}
-
-/* Translation infobar */
-
-%include ../shared/translation/infobar.inc.css
-
-notification[value="translation"] {
-  min-height: 40px;
-}
-
-@media (-moz-windows-default-theme) {
-  notification[value="translation"],
-  notification[value="translation"] button,
-  notification[value="translation"] menulist {
-    min-height: 30px;
-    color: #545454;
-  }
-
-  notification[value="translation"] {
-    background-color: #EEE;
-  }
-
-  notification[value="translation"] button,
-  notification[value="translation"] menulist {
-    padding-inline-end: 1ch;
-  }
-
-  notification[value="translation"] menulist {
-    border: 1px solid #C1C1C1;
-    background-color: #FFF;
-  }
-
-  notification[value="translation"] button {
-    border: 1px solid #C1C1C1;
-    background-color: #FBFBFB;
-  }
-
-  notification[value="translation"] button,
-  notification[value="translation"] menulist,
-  notification[value="translation"] menulist > .menulist-label-box {
-    margin-inline-start: 1ch;
-    margin-inline-end: 1ch;
-  }
-
-  notification[value="translation"] button:hover,
-  notification[value="translation"] button:active,
-  notification[value="translation"] menulist:hover,
-  notification[value="translation"] menulist:active {
-    background-color: #EBEBEB;
-  }
-
-  notification[value="translation"] button[anonid="translate"] {
-    color: #FFF;
-    background-color: #0095DD;
-    box-shadow: none;
-    border: 1px solid #006B9D;
-  }
-
-  notification[value="translation"] button[anonid="translate"]:hover,
-  notification[value="translation"] button[anonid="translate"]:active {
-    background-color: #008ACB;
-  }
-
-  notification[value="translation"] button[type="menu"] > .button-box > .button-menu-dropmarker,
-  notification[value="translation"] menulist > .menulist-dropmarker {
-    list-style-image: url("chrome://browser/skin/toolbarbutton-dropdown-arrow.png");
-  }
-
-  notification[value="translation"] button > .button-box,
-  notification[value="translation"] button[type="menu"] > .button-box > .button-menu-dropmarker {
-    padding: 0;
-    margin-inline-start: 3ch;
-  }
-
-  notification[value="translation"] button:not([type="menu"]) > .button-box {
-    margin-inline-end: 3ch;
-  }
-}
-
-.translation-menupopup {
-  -moz-appearance: none;
-}
-
-/* Bookmarks roots menu-items */
-#subscribeToPageMenuitem:not([disabled]),
-#subscribeToPageMenupopup {
-  list-style-image: url("chrome://browser/skin/feeds/feedIcon16.png");
-}
-
-#bookmarksToolbarFolderMenu,
-#BMB_bookmarksToolbar,
-#panelMenu_bookmarksToolbar {
-  list-style-image: url("chrome://browser/skin/places/bookmarksToolbar.png");
-  -moz-image-region: auto;
-}
-
-#menu_unsortedBookmarks,
-#BMB_unsortedBookmarks,
-#panelMenu_unsortedBookmarks {
-  list-style-image: url("chrome://browser/skin/places/unsortedBookmarks.png");
-  -moz-image-region: auto;
-}
+%endif
 
 /* Ctrl-Tab */
 
 #ctrlTab-panel {
   -moz-appearance: none;
+%ifdef XP_MACOSX
+  -moz-window-shadow: none;
+%endif
   background: hsla(0,0%,33%,.85);
   color: white;
   border-style: none;
   padding: 20px 10px 10px;
+%ifndef XP_MACOSX
   font-weight: bold;
+%endif
   text-shadow: 0 0 1px hsl(0,0%,12%), 0 0 2px hsl(0,0%,12%);
 }
 
 .ctrlTab-favicon[src] {
   background-color: white;
   width: 20px;
   height: 20px;
   padding: 2px;
@@ -2440,279 +56,8 @@ notification[value="translation"] {
   text-shadow: none;
   border-color: white;
 }
 
 #ctrlTab-showAll {
   margin-top: .5em;
 }
 
-/* Status panel */
-
-.statuspanel-label {
-  margin: 0;
-  padding: 2px 4px;
-  background: -moz-dialog;
-  border: 1px none ThreeDShadow;
-  border-top-style: solid;
-  color: -moz-dialogText;
-  text-shadow: none;
-}
-
-@media (-moz-windows-default-theme) {
-  .statuspanel-label {
-    background: linear-gradient(#fff, #ddd);
-    border-color: #ccc;
-    color: #333;
-  }
-}
-
-.statuspanel-label:-moz-locale-dir(ltr):not([mirror]),
-.statuspanel-label:-moz-locale-dir(rtl)[mirror] {
-  border-right-style: solid;
-  /* disabled for triggering grayscale AA (bug 659213)
-  border-top-right-radius: .3em;
-  */
-  margin-right: 1em;
-}
-
-.statuspanel-label:-moz-locale-dir(rtl):not([mirror]),
-.statuspanel-label:-moz-locale-dir(ltr)[mirror] {
-  border-left-style: solid;
-  /* disabled for triggering grayscale AA (bug 659213)
-  border-top-left-radius: .3em;
-  */
-  margin-left: 1em;
-}
-
-%include ../shared/fullscreen/warning.inc.css
-%include ../../../devtools/client/themes/responsivedesign.inc.css
-%include ../../../devtools/client/themes/commandline.inc.css
-
-%include ../shared/plugin-doorhanger.inc.css
-
-notification.pluginVulnerable > .notification-inner > .messageCloseButton {
-  list-style-image: url("chrome://global/skin/icons/close-inverted.png");
-}
-
-@media (min-resolution: 1.1dppx) {
-  notification.pluginVulnerable > .notification-inner > .messageCloseButton {
-    list-style-image: url("chrome://global/skin/icons/close-inverted@2x.png");
-  }
-}
-
-%include ../shared/login-doorhanger.inc.css
-
-%include downloads/indicator.css
-
-/* Error counter */
-
-#developer-toolbar-toolbox-button[error-count]:before {
-  color: #FDF3DE;
-  min-width: 16px;
-  text-shadow: none;
-  background-image: linear-gradient(#B4211B, #8A1915);
-  border-radius: 1px;
-  margin-inline-end: 5px;
-}
-
-/* Customization mode */
-
-%include ../shared/customizableui/customizeMode.inc.css
-
-/**
- * This next rule is a hack to disable subpixel anti-aliasing on all
- * labels during the customize mode transition. Subpixel anti-aliasing
- * on Windows with Direct2D layers acceleration is particularly slow to
- * paint, so this hack is how we sidestep that performance bottleneck.
- */
-#main-window:-moz-any([customize-entering],[customize-exiting]) label {
-  transform: perspective(0.01px);
-}
-
-#main-window[customize-entered] > #tab-view-deck {
-  background-image: url("chrome://browser/skin/customizableui/customizeMode-gridTexture.png");
-  background-attachment: fixed;
-}
-
-#main-window[customization-lwtheme] > #tab-view-deck:-moz-lwtheme {
-  background-repeat: no-repeat;
-  background-position: right top;
-  background-attachment: fixed;
-  /* The image will get set from CustomizeMode.jsm */
-  background-image: none;
-  background-color: transparent;
-}
-
-#main-window[customization-lwtheme]:-moz-lwtheme {
-  background-image: url("chrome://browser/skin/customizableui/customizeMode-gridTexture.png");
-  background-repeat: repeat;
-  background-attachment: fixed;
-  background-position: left top;
-}
-
-#main-window[customize-entered] #browser-bottombox,
-#main-window[customize-entered] #customization-container {
-  border-left: 1px solid @toolbarShadowColor@;
-  border-right: 1px solid @toolbarShadowColor@;
-  background-clip: padding-box;
-}
-
-#main-window[customize-entered] #browser-bottombox {
-  border-bottom: 1px solid @toolbarShadowColor@;
-}
-
-#customization-tipPanel > .panel-arrowcontainer > .panel-arrowbox > .panel-arrow[side="left"] {
-  margin-right: -2px;
-}
-
-#customization-tipPanel > .panel-arrowcontainer > .panel-arrowbox > .panel-arrow[side="right"] {
-  margin-left: -2px;
-}
-
-/* End customization mode */
-
-/* Private browsing indicators */
-
-/**
- * Currently, we have two places where we put private browsing indicators on
- * Windows. When tabsintitlebar is enabled, we draw the indicator in the titlebar.
- * When tabsintitlebar is disabled, we draw the indicator at the end of the
- * tabstrip. The titlebar indicator is the fiddliest of the bunch, since we
- * want the bottom border of the image to line up with the bottom of the window
- * caption buttons. That's why there's so much special-casing going on in here.
- */
-.private-browsing-indicator {
-  display: none;
-  pointer-events: none;
-}
-
-#private-browsing-indicator-titlebar {
-  display: block;
-  position: absolute;
-}
-
-#main-window[privatebrowsingmode=temporary][tabsintitlebar] #private-browsing-indicator-titlebar > .private-browsing-indicator {
-  display: block;
-}
-
-#main-window[privatebrowsingmode=temporary]:-moz-any([inFullscreen],:not([tabsintitlebar])) #TabsToolbar > .private-browsing-indicator {
-  display: -moz-box;
-}
-
-#TabsToolbar > .private-browsing-indicator {
-  background: url("chrome://browser/skin/privatebrowsing-mask-tabstrip.png") no-repeat center -3px;
-  margin-inline-start: 4px;
-  width: 48px;
-}
-
-/* Bug 1008183: We're intentionally using the titlebar asset here for fullscreen
- * mode, since the tabstrip "mimics" the titlebar in that case with its own
- * min/max/close window buttons.
- */
-#private-browsing-indicator-titlebar > .private-browsing-indicator,
-#main-window[inFullscreen] #TabsToolbar > .private-browsing-indicator {
-  background: url("chrome://browser/skin/privatebrowsing-mask-titlebar.png") no-repeat center 0px;
-  margin-inline-end: 4px;
-  width: 40px;
-  height: 20px;
-  position: relative;
-}
-
-@media (-moz-os-version: windows-xp) {
-  @media not all and (-moz-windows-classic) {
-    #private-browsing-indicator-titlebar > .private-browsing-indicator {
-      background-image: url("chrome://browser/skin/privatebrowsing-mask-titlebar-XPVista7-tall.png");
-      height: 28px;
-    }
-
-    #main-window[sizemode="maximized"] > #titlebar > #titlebar-content > #titlebar-buttonbox-container > #private-browsing-indicator-titlebar > .private-browsing-indicator {
-      top: -5px;
-    }
-    #main-window[sizemode="normal"] > #titlebar > #titlebar-content > #titlebar-buttonbox-container > #private-browsing-indicator-titlebar > .private-browsing-indicator {
-      top: -1px;
-    }
-  }
-}
-
-@media (-moz-windows-classic) {
-  /**
-   * We have to use top instead of background-position in this case, otherwise
-   * the bottom of the indicator would get cut off by the bounds of the
-   * private-browsing-indicator element.
-   */
-  #main-window[sizemode="normal"] > #titlebar > #titlebar-content > #titlebar-buttonbox-container > #private-browsing-indicator-titlebar > .private-browsing-indicator {
-    top: 4px;
-  }
-}
-
-@media (-moz-os-version: windows-vista),
-       (-moz-os-version: windows-win7) {
-  @media (-moz-windows-glass) {
-    #main-window[sizemode="normal"] > #titlebar > #titlebar-content > #titlebar-buttonbox-container > #private-browsing-indicator-titlebar > .private-browsing-indicator {
-      top: 1px;
-    }
-    #main-window[sizemode="maximized"] > #titlebar > #titlebar-content > #titlebar-buttonbox-container > #private-browsing-indicator-titlebar > .private-browsing-indicator {
-      top: -1px;
-    }
-  }
-
-  /**
-   * This next block targets Aero Basic, which has different positioning for the
-   * window caption buttons, and therefore needs to be special-cased.
-   */
-  @media (-moz-windows-default-theme) {
-    @media not all and (-moz-windows-compositor) {
-      #main-window[sizemode="normal"] > #titlebar > #titlebar-content > #titlebar-buttonbox-container > #private-browsing-indicator-titlebar > .private-browsing-indicator {
-        background-image: url("chrome://browser/skin/privatebrowsing-mask-titlebar-XPVista7-tall.png");
-        height: 28px;
-      }
-    }
-  }
-}
-
-/* End private browsing indicators */
-
-%include ../shared/UITour.inc.css
-
-#UITourTooltipButtons {
-  /**
-   * Override the --panel-arrowcontent-padding so the background extends
-   * to the sides and bottom of the panel.
-   */
-  margin-left: -10px;
-  margin-right: -10px;
-  margin-bottom: -10px;
-}
-
-%include ../shared/contextmenu.inc.css
-
-#context-navigation {
-  background-color: menu;
-  padding-bottom: 4px;
-}
-
-#context-sep-navigation {
-  margin-inline-start: -28px;
-  margin-top: -4px;
-}
-
-
-@media not all and (-moz-os-version: windows-xp) {
-%include browser-aero.css
-}
-
-.browser-extension-panel > .panel-arrowcontainer > .panel-arrowcontent {
-  padding: 0;
-  overflow: hidden;
-}
-
-@media (-moz-os-version: windows-xp),
-       (-moz-os-version: windows-vista),
-       (-moz-os-version: windows-win7) {
-  .cui-widget-panelview[id^=PanelUI-webext-] {
-    border-radius: 4px;
-  }
-}
-
-.webextension-popup-browser {
-  border-radius: inherit;
-}
--- a/browser/themes/windows/browser.css
+++ b/browser/themes/windows/browser.css
@@ -2388,68 +2388,16 @@ notification[value="translation"] {
 
 #menu_unsortedBookmarks,
 #BMB_unsortedBookmarks,
 #panelMenu_unsortedBookmarks {
   list-style-image: url("chrome://browser/skin/places/unsortedBookmarks.png");
   -moz-image-region: auto;
 }
 
-/* Ctrl-Tab */
-
-#ctrlTab-panel {
-  -moz-appearance: none;
-  background: hsla(0,0%,33%,.85);
-  color: white;
-  border-style: none;
-  padding: 20px 10px 10px;
-  font-weight: bold;
-  text-shadow: 0 0 1px hsl(0,0%,12%), 0 0 2px hsl(0,0%,12%);
-}
-
-.ctrlTab-favicon[src] {
-  background-color: white;
-  width: 20px;
-  height: 20px;
-  padding: 2px;
-}
-
-.ctrlTab-preview-inner > .tabPreview-canvas {
-  box-shadow: 1px 1px 2px hsl(0,0%,12%);
-}
-
-.ctrlTab-preview:not(#ctrlTab-showAll) > * > .ctrlTab-preview-inner > .tabPreview-canvas {
-  margin-bottom: 2px;
-}
-
-.ctrlTab-preview-inner {
-  padding: 8px;
-  border: 2px solid transparent;
-  border-radius: .5em;
-}
-
-.ctrlTab-preview:not(#ctrlTab-showAll) > * > .ctrlTab-preview-inner {
-  margin: -10px -10px 0;
-}
-
-#ctrlTab-showAll:not(:focus) > * > .ctrlTab-preview-inner {
-  background-color: rgba(255,255,255,.2);
-}
-
-.ctrlTab-preview:focus > * > .ctrlTab-preview-inner {
-  color: white;
-  background-color: rgba(0,0,0,.6);
-  text-shadow: none;
-  border-color: white;
-}
-
-#ctrlTab-showAll {
-  margin-top: .5em;
-}
-
 /* Status panel */
 
 .statuspanel-label {
   margin: 0;
   padding: 2px 4px;
   background: -moz-dialog;
   border: 1px none ThreeDShadow;
   border-top-style: solid;
@@ -2479,19 +2427,19 @@ notification[value="translation"] {
   border-left-style: solid;
   /* disabled for triggering grayscale AA (bug 659213)
   border-top-left-radius: .3em;
   */
   margin-left: 1em;
 }
 
 %include ../shared/fullscreen/warning.inc.css
+%include ../shared/ctrlTab.inc.css
 %include ../../../devtools/client/themes/responsivedesign.inc.css
 %include ../../../devtools/client/themes/commandline.inc.css
-
 %include ../shared/plugin-doorhanger.inc.css
 
 notification.pluginVulnerable > .notification-inner > .messageCloseButton {
   list-style-image: url("chrome://global/skin/icons/close-inverted.png");
 }
 
 @media (min-resolution: 1.1dppx) {
   notification.pluginVulnerable > .notification-inner > .messageCloseButton {
--- a/build/clang-plugin/clang-plugin.cpp
+++ b/build/clang-plugin/clang-plugin.cpp
@@ -153,32 +153,38 @@ private:
     virtual void run(const MatchFinder::MatchResult &Result);
   };
 
   class AssertAssignmentChecker : public MatchFinder::MatchCallback {
   public:
     virtual void run(const MatchFinder::MatchResult &Result);
   };
 
+  class KungFuDeathGripChecker : public MatchFinder::MatchCallback {
+  public:
+    virtual void run(const MatchFinder::MatchResult &Result);
+  };
+
   ScopeChecker Scope;
   ArithmeticArgChecker ArithmeticArg;
   TrivialCtorDtorChecker TrivialCtorDtor;
   NaNExprChecker NaNExpr;
   NoAddRefReleaseOnReturnChecker NoAddRefReleaseOnReturn;
   RefCountedInsideLambdaChecker RefCountedInsideLambda;
   ExplicitOperatorBoolChecker ExplicitOperatorBool;
   NoDuplicateRefCntMemberChecker NoDuplicateRefCntMember;
   NeedsNoVTableTypeChecker NeedsNoVTableType;
   NonMemMovableTemplateArgChecker NonMemMovableTemplateArg;
   NonMemMovableMemberChecker NonMemMovableMember;
   ExplicitImplicitChecker ExplicitImplicit;
   NoAutoTypeChecker NoAutoType;
   NoExplicitMoveConstructorChecker NoExplicitMoveConstructor;
   RefCountedCopyConstructorChecker RefCountedCopyConstructor;
   AssertAssignmentChecker AssertAttribution;
+  KungFuDeathGripChecker KungFuDeathGrip;
   MatchFinder AstMatcher;
 };
 
 namespace {
 
 std::string getDeclarationNamespace(const Decl *Declaration) {
   const DeclContext *DC =
       Declaration->getDeclContext()->getEnclosingNamespaceContext();
@@ -309,16 +315,54 @@ bool isIgnoredExprForMustUse(const Expr 
 
   return false;
 }
 
 template<typename T>
 StringRef getNameChecked(const T& D) {
   return D->getIdentifier() ? D->getName() : "";
 }
+
+bool typeIsRefPtr(QualType Q) {
+  CXXRecordDecl *D = Q->getAsCXXRecordDecl();
+  if (!D || !D->getIdentifier()) {
+    return false;
+  }
+
+  StringRef name = D->getName();
+  if (name == "RefPtr" || name == "nsCOMPtr") {
+    return true;
+  }
+  return false;
+}
+
+// The method defined in clang for ignoring implicit nodes doesn't work with
+// some AST trees. To get around this, we define our own implementation of
+// IgnoreImplicit.
+const Stmt *IgnoreImplicit(const Stmt *s) {
+  while (true) {
+    if (auto *ewc = dyn_cast<ExprWithCleanups>(s)) {
+      s = ewc->getSubExpr();
+    } else if (auto *mte = dyn_cast<MaterializeTemporaryExpr>(s)) {
+      s = mte->GetTemporaryExpr();
+    } else if (auto *bte = dyn_cast<CXXBindTemporaryExpr>(s)) {
+      s = bte->getSubExpr();
+    } else if (auto *ice = dyn_cast<ImplicitCastExpr>(s)) {
+      s = ice->getSubExpr();
+    } else {
+      break;
+    }
+  }
+
+  return s;
+}
+
+const Expr *IgnoreImplicit(const Expr *e) {
+  return cast<Expr>(IgnoreImplicit(static_cast<const Stmt *>(e)));
+}
 }
 
 class CustomTypeAnnotation {
   enum ReasonKind {
     RK_None,
     RK_Direct,
     RK_ArrayElement,
     RK_BaseClass,
@@ -816,16 +860,19 @@ AST_MATCHER(CallExpr, isAssertAssignment
       && Method->getDeclName().isIdentifier()
       && Method->getName() == AssertName;
 }
 
 AST_MATCHER(CXXRecordDecl, isLambdaDecl) {
   return Node.isLambda();
 }
 
+AST_MATCHER(QualType, isRefPtr) {
+  return typeIsRefPtr(Node);
+}
 }
 }
 
 namespace {
 
 void CustomTypeAnnotation::dumpAnnotationReason(DiagnosticsEngine &Diag,
                                                 QualType T,
                                                 SourceLocation Loc) {
@@ -1140,16 +1187,19 @@ DiagnosticsMatcher::DiagnosticsMatcher()
           hasDeclaration(cxxConstructorDecl(isCompilerProvidedCopyConstructor(),
                                             ofClass(hasRefCntMember()))))
           .bind("node"),
       &RefCountedCopyConstructor);
 
   AstMatcher.addMatcher(
       callExpr(isAssertAssignmentTestFunc()).bind("funcCall"),
       &AssertAttribution);
+
+  AstMatcher.addMatcher(varDecl(hasType(isRefPtr())).bind("decl"),
+                        &KungFuDeathGrip);
 }
 
 // These enum variants determine whether an allocation has occured in the code.
 enum AllocationVariety {
   AV_None,
   AV_Global,
   AV_Automatic,
   AV_Temporary,
@@ -1688,16 +1738,107 @@ void DiagnosticsMatcher::AssertAssignmen
       DiagnosticIDs::Error, "Forbidden assignment in assert expression");
   const CallExpr *FuncCall = Result.Nodes.getNodeAs<CallExpr>("funcCall");
 
   if (FuncCall && hasSideEffectAssignment(FuncCall)) {
     Diag.Report(FuncCall->getLocStart(), AssignInsteadOfComp);
   }
 }
 
+void DiagnosticsMatcher::KungFuDeathGripChecker::run(
+    const MatchFinder::MatchResult &Result) {
+  DiagnosticsEngine &Diag = Result.Context->getDiagnostics();
+  unsigned ErrorID = Diag.getDiagnosticIDs()->getCustomDiagID(
+      DiagnosticIDs::Error,
+      "Unused \"kungFuDeathGrip\" %0 objects constructed from %1 are prohibited");
+
+  unsigned NoteID = Diag.getDiagnosticIDs()->getCustomDiagID(
+      DiagnosticIDs::Note,
+      "Please switch all accesses to this %0 to go through '%1', or explicitly pass '%1' to `mozilla::Unused`");
+
+  const VarDecl *D = Result.Nodes.getNodeAs<VarDecl>("decl");
+  if (D->isReferenced() || !D->hasLocalStorage() || !D->hasInit()) {
+    return;
+  }
+
+  // Not interested in parameters.
+  if (isa<ImplicitParamDecl>(D) || isa<ParmVarDecl>(D)) {
+    return;
+  }
+
+  const Expr *E = IgnoreImplicit(D->getInit());
+  const CXXConstructExpr *CE = dyn_cast<CXXConstructExpr>(E);
+  if (CE && CE->getNumArgs() == 0) {
+    // We don't report an error when we construct and don't use a nsCOMPtr /
+    // nsRefPtr with no arguments. We don't report it because the error is not
+    // related to the current check. In the future it may be reported through a
+    // more generic mechanism.
+    return;
+  }
+
+  // We don't want to look at the single argument conversion constructors
+  // which are inbetween the declaration and the actual object which we are
+  // assigning into the nsCOMPtr/RefPtr. To do this, we repeatedly
+  // IgnoreImplicit, then look at the expression. If it is one of these
+  // conversion constructors, we ignore it and continue to dig.
+  while ((CE = dyn_cast<CXXConstructExpr>(E)) && CE->getNumArgs() == 1) {
+    E = IgnoreImplicit(CE->getArg(0));
+  }
+
+  // We allow taking a kungFuDeathGrip of `this` because it cannot change
+  // beneath us, so calling directly through `this` is OK. This is the same
+  // for local variable declarations.
+  //
+  // We also don't complain about unused RefPtrs which are constructed from
+  // the return value of a new expression, as these are required in order to
+  // immediately destroy the value created (which was presumably created for
+  // its side effects), and are not used as a death grip.
+  if (isa<CXXThisExpr>(E) || isa<DeclRefExpr>(E) || isa<CXXNewExpr>(E)) {
+    return;
+  }
+
+  // These types are assigned into nsCOMPtr and RefPtr for their side effects,
+  // and not as a kungFuDeathGrip. We don't want to consider RefPtr and nsCOMPtr
+  // types which are initialized with these types as errors.
+  const TagDecl *TD = E->getType()->getAsTagDecl();
+  if (TD && TD->getIdentifier()) {
+    static const char *IgnoreTypes[] = {
+      "already_AddRefed",
+      "nsGetServiceByCID",
+      "nsGetServiceByCIDWithError",
+      "nsGetServiceByContractID",
+      "nsGetServiceByContractIDWithError",
+      "nsCreateInstanceByCID",
+      "nsCreateInstanceByContractID",
+      "nsCreateInstanceFromFactory",
+    };
+
+    for (uint32_t i = 0; i < sizeof(IgnoreTypes) / sizeof(IgnoreTypes[0]); ++i) {
+      if (TD->getName() == IgnoreTypes[i]) {
+        return;
+      }
+    }
+  }
+
+  // Report the error
+  const char *ErrThing;
+  const char *NoteThing;
+  if (isa<MemberExpr>(E)) {
+    ErrThing  = "members";
+    NoteThing = "member";
+  } else {
+    ErrThing = "temporary values";
+    NoteThing = "value";
+  }
+
+  // We cannot provide the note if we don't have an initializer
+  Diag.Report(D->getLocStart(), ErrorID) << D->getType() << ErrThing;
+  Diag.Report(E->getLocStart(), NoteID) << NoteThing << getNameChecked(D);
+}
+
 class MozCheckAction : public PluginASTAction {
 public:
   ASTConsumerPtr CreateASTConsumer(CompilerInstance &CI,
                                    StringRef FileName) override {
 #if CLANG_VERSION_FULL >= 306
     std::unique_ptr<MozChecker> Checker(llvm::make_unique<MozChecker>(CI));
     ASTConsumerPtr Other(Checker->getOtherConsumer());
 
new file mode 100644
--- /dev/null
+++ b/build/clang-plugin/tests/TestKungFuDeathGrip.cpp
@@ -0,0 +1,107 @@
+#define MOZ_IMPLICIT __attribute__((annotate("moz_implicit")))
+
+template <typename T>
+class already_AddRefed {
+public:
+  already_AddRefed();
+  T* mPtr;
+};
+
+template <typename T>
+class RefPtr {
+public:
+  RefPtr();
+  MOZ_IMPLICIT RefPtr(T* aIn);
+  MOZ_IMPLICIT RefPtr(already_AddRefed<T> aIn);
+  ~RefPtr();
+  T* mPtr;
+};
+
+template <typename T>
+class nsCOMPtr {
+public:
+  nsCOMPtr();
+  MOZ_IMPLICIT nsCOMPtr(T* aIn);
+  MOZ_IMPLICIT nsCOMPtr(already_AddRefed<T> aIn);
+  ~nsCOMPtr();
+  T* mPtr;
+};
+
+class Type {
+public:
+  static nsCOMPtr<Type> someStaticCOMPtr;
+
+  void f(nsCOMPtr<Type> ignoredArgument, Type *param) {
+    nsCOMPtr<Type> never_referenced;
+    nsCOMPtr<Type> kfdg_t1(this);
+    nsCOMPtr<Type> kfdg_t2 = this;
+
+    nsCOMPtr<Type> kfdg_m1(p); // expected-error {{Unused "kungFuDeathGrip" 'nsCOMPtr<Type>' objects constructed from members are prohibited}} expected-note {{Please switch all accesses to this member to go through 'kfdg_m1', or explicitly pass 'kfdg_m1' to `mozilla::Unused`}}
+    nsCOMPtr<Type> kfdg_m2 = p; // expected-error {{Unused "kungFuDeathGrip" 'nsCOMPtr<Type>' objects constructed from members are prohibited}} expected-note {{Please switch all accesses to this member to go through 'kfdg_m2', or explicitly pass 'kfdg_m2' to `mozilla::Unused`}}
+    nsCOMPtr<Type> kfdg_m3(p);
+    kfdg_m3.mPtr->f(nullptr, nullptr);
+    nsCOMPtr<Type> kfdg_m4 = p;
+    kfdg_m4.mPtr->f(nullptr, nullptr);
+
+    nsCOMPtr<Type> kfdg_a1((already_AddRefed<Type>()));
+    nsCOMPtr<Type> kfdg_a2 = already_AddRefed<Type>();
+
+    nsCOMPtr<Type> kfdg_p1(param);
+    nsCOMPtr<Type> kfdg_p2 = param;
+
+
+    RefPtr<Type> never_referenced2;
+    RefPtr<Type> kfdg_t3(this);
+    RefPtr<Type> kfdg_t4 = this;
+
+    RefPtr<Type> kfdg_m5(p); // expected-error {{Unused "kungFuDeathGrip" 'RefPtr<Type>' objects constructed from members are prohibited}} expected-note {{Please switch all accesses to this member to go through 'kfdg_m5', or explicitly pass 'kfdg_m5' to `mozilla::Unused`}}
+    RefPtr<Type> kfdg_m6 = p; // expected-error {{Unused "kungFuDeathGrip" 'RefPtr<Type>' objects constructed from members are prohibited}} expected-note {{Please switch all accesses to this member to go through 'kfdg_m6', or explicitly pass 'kfdg_m6' to `mozilla::Unused`}}
+    RefPtr<Type> kfdg_m7(p);
+    kfdg_m7.mPtr->f(nullptr, nullptr);
+    RefPtr<Type> kfdg_m8 = p;
+    kfdg_m8.mPtr->f(nullptr, nullptr);
+
+    RefPtr<Type> kfdg_a3((already_AddRefed<Type>()));
+    RefPtr<Type> kfdg_a4 = already_AddRefed<Type>();
+
+    RefPtr<Type> kfdg_p3(param);
+    RefPtr<Type> kfdg_p4 = param;
+  }
+
+  Type *p;
+};
+
+void f(nsCOMPtr<Type> ignoredArgument, Type *param) {
+  nsCOMPtr<Type> never_referenced;
+  Type t;
+  // Type *p = nullptr;
+  nsCOMPtr<Type> kfdg_m1(t.p); // expected-error {{Unused "kungFuDeathGrip" 'nsCOMPtr<Type>' objects constructed from members are prohibited}} expected-note {{Please switch all accesses to this member to go through 'kfdg_m1', or explicitly pass 'kfdg_m1' to `mozilla::Unused`}}
+  nsCOMPtr<Type> kfdg_m2 = t.p; // expected-error {{Unused "kungFuDeathGrip" 'nsCOMPtr<Type>' objects constructed from members are prohibited}} expected-note {{Please switch all accesses to this member to go through 'kfdg_m2', or explicitly pass 'kfdg_m2' to `mozilla::Unused`}}
+  nsCOMPtr<Type> kfdg_m3(t.p);
+  kfdg_m3.mPtr->f(nullptr, nullptr);
+  nsCOMPtr<Type> kfdg_m4 = t.p;
+  kfdg_m4.mPtr->f(nullptr, nullptr);
+
+  nsCOMPtr<Type> kfdg_a1((already_AddRefed<Type>()));
+  nsCOMPtr<Type> kfdg_a2 = already_AddRefed<Type>();
+
+  nsCOMPtr<Type> kfdg_p1(param);
+  nsCOMPtr<Type> kfdg_p2 = param;
+
+
+  RefPtr<Type> never_referenced2;
+  RefPtr<Type> kfdg_m5(t.p); // expected-error {{Unused "kungFuDeathGrip" 'RefPtr<Type>' objects constructed from members are prohibited}} expected-note {{Please switch all accesses to this member to go through 'kfdg_m5', or explicitly pass 'kfdg_m5' to `mozilla::Unused`}}
+  RefPtr<Type> kfdg_m6 = t.p; // expected-error {{Unused "kungFuDeathGrip" 'RefPtr<Type>' objects constructed from members are prohibited}} expected-note {{Please switch all accesses to this member to go through 'kfdg_m6', or explicitly pass 'kfdg_m6' to `mozilla::Unused`}}
+  RefPtr<Type> kfdg_m7(t.p);
+  kfdg_m7.mPtr->f(nullptr, nullptr);
+  RefPtr<Type> kfdg_m8 = t.p;
+  kfdg_m8.mPtr->f(nullptr, nullptr);
+
+  RefPtr<Type> kfdg_a3((already_AddRefed<Type>()));
+  RefPtr<Type> kfdg_a4 = already_AddRefed<Type>();
+
+  RefPtr<Type> kfdg_p3(param);
+  RefPtr<Type> kfdg_p4 = param;
+}
+
+nsCOMPtr<Type> Type::someStaticCOMPtr(nullptr);
--- a/build/clang-plugin/tests/moz.build
+++ b/build/clang-plugin/tests/moz.build
@@ -10,16 +10,17 @@ Library('clang-plugin-tests')
 SOURCES += [
     'TestAssertWithAssignment.cpp',
     'TestBadImplicitConversionCtor.cpp',
     'TestCustomHeap.cpp',
     'TestExplicitOperatorBool.cpp',
     'TestGlobalClass.cpp',
     'TestHeapClass.cpp',
     'TestInheritTypeAnnotationsFromTemplateArgs.cpp',
+    'TestKungFuDeathGrip.cpp',
     'TestMultipleAnnotations.cpp',
     'TestMustOverride.cpp',
     'TestMustUse.cpp',
     'TestNANTestingExpr.cpp',
     'TestNANTestingExprC.c',
     'TestNeedsNoVTableType.cpp',
     'TestNoAddRefReleaseOnReturn.cpp',
     'TestNoArithmeticExprInArgument.cpp',
--- a/build/moz.configure/rust.configure
+++ b/build/moz.configure/rust.configure
@@ -100,17 +100,17 @@ def rust_target(rust_compiler, rustc, ta
             # FreeBSD
             ('x86', 'FreeBSD'): 'i686-unknown-freebsd',
             ('x86_64', 'FreeBSD'): 'x86_64-unknown-freebsd',
             # NetBSD
             ('x86_64', 'NetBSD'): 'x86_64-unknown-netbsd',
             # OpenBSD
             ('x86_64', 'OpenBSD'): 'x86_64-unknown-openbsd',
             # Linux
-            ('x86', 'Linux'): 'i686-unknown-linux-gnu',
+            ('x86', 'Linux'): 'i586-unknown-linux-gnu',
             # Linux
             ('x86_64', 'Linux'): 'x86_64-unknown-linux-gnu',
             # OS X and iOS
             ('x86', 'OSX'): 'i686-apple-darwin',
             ('x86', 'iOS'): 'i386-apple-ios',
             ('x86_64', 'OSX'): 'x86_64-apple-darwin',
             # Android
             ('x86', 'Android'): 'i686-linux-android',
--- a/caps/DomainPolicy.cpp
+++ b/caps/DomainPolicy.cpp
@@ -136,18 +136,16 @@ CopyURIs(const InfallibleTArray<URIParam
         nsCOMPtr<nsIURI> uri = DeserializeURI(aDomains[i]);
         aSet->Add(uri);
     }
 }
 
 void
 DomainPolicy::ApplyClone(DomainPolicyClone* aClone)
 {
-    nsCOMPtr<nsIDomainSet> list;
-
     CopyURIs(aClone->blacklist(), mBlacklist);
     CopyURIs(aClone->whitelist(), mWhitelist);
     CopyURIs(aClone->superBlacklist(), mSuperBlacklist);
     CopyURIs(aClone->superWhitelist(), mSuperWhitelist);
 }
 
 static already_AddRefed<nsIURI>
 GetCanonicalClone(nsIURI* aURI)
--- a/chrome/nsChromeRegistryContent.cpp
+++ b/chrome/nsChromeRegistryContent.cpp
@@ -70,17 +70,16 @@ nsChromeRegistryContent::RegisterPackage
     nsresult rv = NS_NewURI(getter_AddRefs(locale),
                             aPackage.localeBaseURI.spec,
                             aPackage.localeBaseURI.charset.get(),
                             nullptr, io);
     if (NS_FAILED(rv))
       return;
   }
   if (aPackage.skinBaseURI.spec.Length()) {
-    nsCOMPtr<nsIURI> skinBaseURI;
     nsresult rv = NS_NewURI(getter_AddRefs(skin),
                             aPackage.skinBaseURI.spec,
                             aPackage.skinBaseURI.charset.get(),
                             nullptr, io);
     if (NS_FAILED(rv))
       return;
   }
 
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -1649,24 +1649,24 @@ nsDocShell::PrepareForNewContentModel()
 }
 
 NS_IMETHODIMP
 nsDocShell::FirePageHideNotification(bool aIsUnload)
 {
   if (mContentViewer && !mFiredUnloadEvent) {
     // Keep an explicit reference since calling PageHide could release
     // mContentViewer
-    nsCOMPtr<nsIContentViewer> kungFuDeathGrip(mContentViewer);
+    nsCOMPtr<nsIContentViewer> contentViewer(mContentViewer);
     mFiredUnloadEvent = true;
 
     if (mTiming) {
       mTiming->NotifyUnloadEventStart();
     }
 
-    mContentViewer->PageHide(aIsUnload);
+    contentViewer->PageHide(aIsUnload);
 
     if (mTiming) {
       mTiming->NotifyUnloadEventEnd();
     }
 
     AutoTArray<nsCOMPtr<nsIDocShell>, 8> kids;
     uint32_t n = mChildList.Length();
     kids.SetCapacity(n);
@@ -7585,16 +7585,17 @@ nsDocShell::EndPageLoad(nsIWebProgress* 
   } else {
     mCharsetReloadState = eCharsetReloadInit;
   }
 
   // Save a pointer to the currently-loading history entry.
   // nsDocShell::EndPageLoad will clear mLSHE, but we may need this history
   // entry further down in this method.
   nsCOMPtr<nsISHEntry> loadingSHE = mLSHE;
+  mozilla::Unused << loadingSHE; // XXX: Not sure if we need this anymore
 
   //
   // one of many safeguards that prevent death and destruction if
   // someone is so very very rude as to bring this window down
   // during this load handler.
   //
   nsCOMPtr<nsIDocShell> kungFuDeathGrip(this);
 
@@ -9326,33 +9327,33 @@ nsDocShell::SetupNewViewer(nsIContentVie
         NS_ENSURE_SUCCESS(oldCv->GetAuthorStyleDisabled(&styleDisabled),
                           NS_ERROR_FAILURE);
       }
     }
   }
 
   nscolor bgcolor = NS_RGBA(0, 0, 0, 0);
   // Ensure that the content viewer is destroyed *after* the GC - bug 71515
-  nsCOMPtr<nsIContentViewer> kungfuDeathGrip = mContentViewer;
-  if (mContentViewer) {
+  nsCOMPtr<nsIContentViewer> contentViewer = mContentViewer;
+  if (contentViewer) {
     // Stop any activity that may be happening in the old document before
     // releasing it...
-    mContentViewer->Stop();
+    contentViewer->Stop();
 
     // Try to extract the canvas background color from the old
     // presentation shell, so we can use it for the next document.
     nsCOMPtr<nsIPresShell> shell;
-    mContentViewer->GetPresShell(getter_AddRefs(shell));
+    contentViewer->GetPresShell(getter_AddRefs(shell));
 
     if (shell) {
       bgcolor = shell->GetCanvasBackground();
     }
 
-    mContentViewer->Close(mSavingOldViewer ? mOSHE.get() : nullptr);
-    aNewViewer->SetPreviousViewer(mContentViewer);
+    contentViewer->Close(mSavingOldViewer ? mOSHE.get() : nullptr);
+    aNewViewer->SetPreviousViewer(contentViewer);
   }
   if (mOSHE && (!mContentViewer || !mSavingOldViewer)) {
     // We don't plan to save a viewer in mOSHE; tell it to drop
     // any other state it's holding.
     mOSHE->SyncPresentationState();
   }
 
   mContentViewer = nullptr;
@@ -9763,23 +9764,24 @@ nsDocShell::InternalLoad(nsIURI* aURI,
     }
   }
 
   bool isJavaScript = false;
   if (NS_FAILED(aURI->SchemeIs("javascript", &isJavaScript))) {
     isJavaScript = false;
   }
 
+  RefPtr<nsGlobalWindow> scriptGlobal = mScriptGlobal;
+
   // First, notify any nsIContentPolicy listeners about the document load.
   // Only abort the load if a content policy listener explicitly vetos it!
   // Use nsPIDOMWindow since we _want_ to cross the chrome boundary if needed
   nsCOMPtr<Element> requestingElement =
-    mScriptGlobal->AsOuter()->GetFrameElementInternal();
-
-  RefPtr<nsGlobalWindow> MMADeathGrip = mScriptGlobal;
+    scriptGlobal->AsOuter()->GetFrameElementInternal();
+
 
   int16_t shouldLoad = nsIContentPolicy::ACCEPT;
   uint32_t contentType;
   bool isNewDocShell = false;
   bool isTargetTopLevelDocShell = false;
   nsCOMPtr<nsIDocShell> targetDocShell;
   if (aWindowTarget && *aWindowTarget) {
     // Locate the target DocShell.
@@ -9815,17 +9817,17 @@ nsDocShell::InternalLoad(nsIURI* aURI,
     contentType = requestingElement->IsHTMLElement(nsGkAtoms::iframe) ?
       nsIContentPolicy::TYPE_INTERNAL_IFRAME : nsIContentPolicy::TYPE_INTERNAL_FRAME;
   } else {
     contentType = nsIContentPolicy::TYPE_DOCUMENT;
   }
 
   nsISupports* context = requestingElement;
   if (!context) {
-    context = ToSupports(mScriptGlobal);
+    context = ToSupports(scriptGlobal);
   }
 
   // XXXbz would be nice to know the loading principal here... but we don't
   nsCOMPtr<nsIPrincipal> loadingPrincipal = aTriggeringPrincipal;
   if (!loadingPrincipal && aReferrer) {
     rv =
       CreatePrincipalFromReferrer(aReferrer, getter_AddRefs(loadingPrincipal));
     NS_ENSURE_SUCCESS(rv, rv);
@@ -10321,18 +10323,18 @@ nsDocShell::InternalLoad(nsIURI* aURI,
       }
 
       SetDocCurrentStateObj(mOSHE);
 
       // Inform the favicon service that the favicon for oldURI also
       // applies to aURI.
       CopyFavicon(currentURI, aURI, doc->NodePrincipal(), UsePrivateBrowsing());
 
-      RefPtr<nsGlobalWindow> win = mScriptGlobal ?
-        mScriptGlobal->GetCurrentInnerWindowInternal() : nullptr;
+      RefPtr<nsGlobalWindow> win = scriptGlobal ?
+        scriptGlobal->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
       // the presShell that we have a new hash.  See bug 680257.
       rv = ScrollToAnchor(curURIHasRef, newURIHasRef, newHash, aLoadType);
       NS_ENSURE_SUCCESS(rv, rv);
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -1579,27 +1579,25 @@ nsSHistory::LoadEntry(int32_t aIndex, lo
 
   if (!canNavigate) {
     // If the listener asked us not to proceed with
     // the operation, simply return.
     mRequestedIndex = -1;
     return NS_OK;  // XXX Maybe I can return some other error code?
   }
 
-  nsCOMPtr<nsIURI> nexturi;
   int32_t pCount = 0;
   int32_t nCount = 0;
   nsCOMPtr<nsISHContainer> prevAsContainer(do_QueryInterface(prevEntry));
   nsCOMPtr<nsISHContainer> nextAsContainer(do_QueryInterface(nextEntry));
   if (prevAsContainer && nextAsContainer) {
     prevAsContainer->GetChildCount(&pCount);
     nextAsContainer->GetChildCount(&nCount);
   }
 
-  nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
   if (mRequestedIndex == mIndex) {
     // Possibly a reload case
     docShell = mRootDocShell;
   } else {
     // Going back or forward.
     if (pCount > 0 && nCount > 0) {
       /* THis is a subframe navigation. Go find
        * the docshell in which load should happen
deleted file mode 100644
--- a/dom/alarm/AlarmDB.jsm
+++ /dev/null
@@ -1,140 +0,0 @@
-/* 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/. */
-
-"use strict";
-
-this.EXPORTED_SYMBOLS = ["AlarmDB"];
-
-/* static functions */
-const DEBUG = false;
-
-function debug(aStr) {
-  if (DEBUG)
-    dump("AlarmDB: " + aStr + "\n");
-}
-
-const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/IndexedDBHelper.jsm");
-
-const ALARMDB_NAME    = "alarms";
-const ALARMDB_VERSION = 1;
-const ALARMSTORE_NAME = "alarms";
-
-this.AlarmDB = function AlarmDB() {
-  debug("AlarmDB()");
-}
-
-AlarmDB.prototype = {
-  __proto__: IndexedDBHelper.prototype,
-
-  init: function init() {
-    debug("init()");
-
-    this.initDBHelper(ALARMDB_NAME, ALARMDB_VERSION, [ALARMSTORE_NAME]);
-  },
-
-  upgradeSchema: function upgradeSchema(aTransaction, aDb,
-                                        aOldVersion, aNewVersion) {
-    debug("upgradeSchema()");
-
-    let objStore =
-      aDb.createObjectStore(ALARMSTORE_NAME,
-                            { keyPath: "id", autoIncrement: true });
-
-    objStore.createIndex("date",           "date",           { unique: false });
-    objStore.createIndex("ignoreTimezone", "ignoreTimezone", { unique: false });
-    objStore.createIndex("timezoneOffset", "timezoneOffset", { unique: false });
-    objStore.createIndex("data",           "data",           { unique: false });
-    objStore.createIndex("pageURL",        "pageURL",        { unique: false });
-    objStore.createIndex("manifestURL",    "manifestURL",    { unique: false });
-
-    debug("Created object stores and indexes");
-  },
-
-  /**
-   * @param aAlarm
-   *        The record to be added.
-   * @param aSuccessCb
-   *        Callback function to invoke with result ID.
-   * @param aErrorCb [optional]
-   *        Callback function to invoke when there was an error.
-   */
-  add: function add(aAlarm, aSuccessCb, aErrorCb) {
-    debug("add()");
-
-    this.newTxn("readwrite", ALARMSTORE_NAME, function txnCb(aTxn, aStore) {
-      debug("Going to add " + JSON.stringify(aAlarm));
-      aStore.put(aAlarm).onsuccess = function setTxnResult(aEvent) {
-        aTxn.result = aEvent.target.result;
-        debug("Request successful. New record ID: " + aTxn.result);
-      };
-    }, aSuccessCb, aErrorCb);
-  },
-
-  /**
-   * @param aId
-   *        The ID of record to be removed.
-   * @param aManifestURL
-   *        The manifest URL of the app that alarm belongs to.
-   *        If null, directly remove the ID record; otherwise,
-   *        need to check if the alarm belongs to this app.
-   * @param aSuccessCb
-   *        Callback function to invoke with result.
-   * @param aErrorCb [optional]
-   *        Callback function to invoke when there was an error.
-   */
-  remove: function remove(aId, aManifestURL, aSuccessCb, aErrorCb) {
-    debug("remove()");
-
-    this.newTxn("readwrite", ALARMSTORE_NAME, function txnCb(aTxn, aStore) {
-      debug("Going to remove " + aId);
-
-      // Look up the existing record and compare the manifestURL
-      // to see if the alarm to be removed belongs to this app.
-      aStore.get(aId).onsuccess = function doRemove(aEvent) {
-        let alarm = aEvent.target.result;
-
-        if (!alarm) {
-          debug("Alarm doesn't exist. No need to remove it.");
-          return;
-        }
-
-        if (aManifestURL && aManifestURL != alarm.manifestURL) {
-          debug("Cannot remove the alarm added by other apps.");
-          return;
-        }
-
-        aStore.delete(aId);
-      };
-    }, aSuccessCb, aErrorCb);
-  },
-
-  /**
-   * @param aManifestURL
-   *        The manifest URL of the app that alarms belong to.
-   *        If null, directly return all alarms; otherwise,
-   *        only return the alarms that belong to this app.
-   * @param aSuccessCb
-   *        Callback function to invoke with result array.
-   * @param aErrorCb [optional]
-   *        Callback function to invoke when there was an error.
-   */
-  getAll: function getAll(aManifestURL, aSuccessCb, aErrorCb) {
-    debug("getAll()");
-
-    this.newTxn("readonly", ALARMSTORE_NAME, function txnCb(aTxn, aStore) {
-      if (!aTxn.result) {
-        aTxn.result = [];
-      }
-
-      let index = aStore.index("manifestURL");
-      index.mozGetAll(aManifestURL).onsuccess = function setTxnResult(aEvent) {
-        aTxn.result = aEvent.target.result;
-        debug("Request successful. Record count: " + aTxn.result.length);
-      };
-    }, aSuccessCb, aErrorCb);
-  }
-};
deleted file mode 100644
--- a/dom/alarm/AlarmHalService.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/* -*- 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 "AlarmHalService.h"
-
-namespace mozilla {
-namespace dom {
-namespace alarm {
-
-using namespace hal;
-
-NS_IMPL_ISUPPORTS(AlarmHalService, nsIAlarmHalService)
-
-void
-AlarmHalService::Init()
-{
-  mAlarmEnabled = RegisterTheOneAlarmObserver(this);
-  if (!mAlarmEnabled) {
-    return;
-  }
-  RegisterSystemTimezoneChangeObserver(this);
-  RegisterSystemClockChangeObserver(this);
-}
-
-/* virtual */ AlarmHalService::~AlarmHalService()
-{
-  if (mAlarmEnabled) {
-    UnregisterTheOneAlarmObserver();
-    UnregisterSystemTimezoneChangeObserver(this);
-    UnregisterSystemClockChangeObserver(this);
-  }
-}
-
-/* static */ StaticRefPtr<AlarmHalService> AlarmHalService::sSingleton;
-
-/* static */ already_AddRefed<AlarmHalService>
-AlarmHalService::GetInstance()
-{
-  if (!sSingleton) {
-    sSingleton = new AlarmHalService();
-    sSingleton->Init();
-    ClearOnShutdown(&sSingleton);
-  }
-
-  RefPtr<AlarmHalService> service = sSingleton.get();
-  return service.forget();
-}
-
-NS_IMETHODIMP
-AlarmHalService::SetAlarm(int32_t aSeconds, int32_t aNanoseconds, bool* aStatus)
-{
-  if (!mAlarmEnabled) {
-    return NS_ERROR_FAILURE;
-  }
-
-  bool status = hal::SetAlarm(aSeconds, aNanoseconds);
-  if (status) {
-    *aStatus = status;
-    return NS_OK;
-  } else {
-    return NS_ERROR_FAILURE;
-  }
-}
-
-NS_IMETHODIMP
-AlarmHalService::SetAlarmFiredCb(nsIAlarmFiredCb* aAlarmFiredCb)
-{
-  mAlarmFiredCb = aAlarmFiredCb;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-AlarmHalService::SetTimezoneChangedCb(nsITimezoneChangedCb* aTimeZoneChangedCb)
-{
-  mTimezoneChangedCb = aTimeZoneChangedCb;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-AlarmHalService::SetSystemClockChangedCb(
-    nsISystemClockChangedCb* aSystemClockChangedCb)
-{
-  mSystemClockChangedCb = aSystemClockChangedCb;
-  return NS_OK;
-}
-
-void
-AlarmHalService::Notify(const void_t& aVoid)
-{
-  if (!mAlarmFiredCb) {
-    return;
-  }
-  mAlarmFiredCb->OnAlarmFired();
-}
-
-void
-AlarmHalService::Notify(
-  const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo)
-{
-  if (!mTimezoneChangedCb) {
-    return;
-  }
-  mTimezoneChangedCb->OnTimezoneChanged(
-    aSystemTimezoneChangeInfo.newTimezoneOffsetMinutes());
-}
-
-void
-AlarmHalService::Notify(const int64_t& aClockDeltaMS)
-{
-  if (!mSystemClockChangedCb) {
-    return;
-  }
-  mSystemClockChangedCb->OnSystemClockChanged(aClockDeltaMS);
-}
-
-} // namespace alarm
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/alarm/AlarmHalService.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- 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_alarm_AlarmHalService_h
-#define mozilla_dom_alarm_AlarmHalService_h
-
-#include "base/basictypes.h"
-#include "mozilla/ClearOnShutdown.h"
-#include "mozilla/StaticPtr.h"
-#include "mozilla/Hal.h"
-#include "mozilla/Services.h"
-#include "nsIAlarmHalService.h"
-#include "nsIObserver.h"
-#include "nsIObserverService.h"
-
-namespace mozilla {
-namespace dom {
-namespace alarm {
-
-typedef Observer<void_t> AlarmObserver;
-typedef Observer<hal::SystemTimezoneChangeInformation> SystemTimezoneChangeObserver;
-typedef Observer<int64_t> SystemClockChangeObserver;
-
-class AlarmHalService : public nsIAlarmHalService,
-                        public AlarmObserver,
-                        public SystemTimezoneChangeObserver,
-                        public SystemClockChangeObserver
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIALARMHALSERVICE
-
-  AlarmHalService()
-    : mAlarmEnabled(false)
-  {}
-
-  void Init();
-
-  static already_AddRefed<AlarmHalService> GetInstance();
-
-  // Implementing hal::AlarmObserver
-  void Notify(const void_t& aVoid) override;
-
-  // Implementing hal::SystemTimezoneChangeObserver
-  void Notify(const hal::SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) override;
-
-  // Implementing hal::SystemClockChangeObserver
-  void Notify(const int64_t& aClockDeltaMS) override;
-
-private:
-  virtual ~AlarmHalService();
-
-  bool mAlarmEnabled;
-  static StaticRefPtr<AlarmHalService> sSingleton;
-
-  nsCOMPtr<nsIAlarmFiredCb> mAlarmFiredCb;
-  nsCOMPtr<nsITimezoneChangedCb> mTimezoneChangedCb;
-  nsCOMPtr<nsISystemClockChangedCb> mSystemClockChangedCb;
-};
-
-} // namespace alarm
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_alarm_AlarmHalService_h
deleted file mode 100644
--- a/dom/alarm/AlarmService.jsm
+++ /dev/null
@@ -1,633 +0,0 @@
-/* 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/. */
-
-"use strict";
-
-const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/AlarmDB.jsm");
-Cu.import("resource://gre/modules/Log.jsm");
-Cu.import("resource://gre/modules/AppConstants.jsm");
-
-function getLogger() {
-  var logger = Log.repository.getLogger("AlarmsService");
-  logger.addAppender(new Log.DumpAppender(new Log.BasicFormatter()));
-  logger.level = Log.Level.Debug;
-  return logger;
-}
-
-const logger = getLogger();
-
-/* Only log in B2G */
-function debug(aStr) {
-  AppConstants.MOZ_B2G && logger.debug(aStr);
-}
-
-this.EXPORTED_SYMBOLS = ["AlarmService"];
-
-XPCOMUtils.defineLazyGetter(this, "appsService", function() {
-  return Cc["@mozilla.org/AppsService;1"].getService(Ci.nsIAppsService);
-});
-
-XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
-                                   "@mozilla.org/parentprocessmessagemanager;1",
-                                   "nsIMessageListenerManager");
-
-XPCOMUtils.defineLazyGetter(this, "messenger", function() {
-  return Cc["@mozilla.org/system-message-internal;1"]
-           .getService(Ci.nsISystemMessagesInternal);
-});
-
-XPCOMUtils.defineLazyGetter(this, "powerManagerService", function() {
-  return Cc["@mozilla.org/power/powermanagerservice;1"]
-           .getService(Ci.nsIPowerManagerService);
-});
-
-/**
- * AlarmService provides an API to schedule alarms using the device's RTC.
- *
- * AlarmService is primarily used by the mozAlarms API (navigator.mozAlarms)
- * which uses IPC to communicate with the service.
- *
- * AlarmService can also be used by Gecko code by importing the module and then
- * using AlarmService.add() and AlarmService.remove(). Only Gecko code running
- * in the parent process should do this.
- */
-
-this.AlarmService = {
-  lastChromeId: 0,
-
-  init: function init() {
-    debug("init()");
-
-    Services.obs.addObserver(this, "profile-change-teardown", false);
-    Services.obs.addObserver(this, "webapps-clear-data",false);
-
-    this._currentTimezoneOffset = (new Date()).getTimezoneOffset();
-
-    let alarmHalService = this._alarmHalService =
-      Cc["@mozilla.org/alarmHalService;1"].getService(Ci.nsIAlarmHalService);
-
-    alarmHalService.setAlarmFiredCb(this._onAlarmFired.bind(this));
-    alarmHalService.setTimezoneChangedCb(this._onTimezoneChanged.bind(this));
-    alarmHalService.setSystemClockChangedCb(
-      this._onSystemClockChanged.bind(this));
-
-    // Add the messages to be listened to.
-    this._messages = ["AlarmsManager:GetAll",
-                      "AlarmsManager:Add",
-                      "AlarmsManager:Remove"];
-    this._messages.forEach(function addMessage(msgName) {
-      ppmm.addMessageListener(msgName, this);
-    }.bind(this));
-
-    // Set the indexeddb database.
-    this._db = new AlarmDB();
-    this._db.init();
-
-    // Variable to save alarms waiting to be set.
-    this._alarmQueue = [];
-
-    this._restoreAlarmsFromDb();
-  },
-
-  // Getter/setter to access the current alarm set in system.
-  _alarm: null,
-  get _currentAlarm() {
-    return this._alarm;
-  },
-  set _currentAlarm(aAlarm) {
-    this._alarm = aAlarm;
-    if (!aAlarm) {
-      return;
-    }
-
-    let alarmTimeInMs = this._getAlarmTime(aAlarm);
-    let ns = (alarmTimeInMs % 1000) * 1000000;
-    if (!this._alarmHalService.setAlarm(alarmTimeInMs / 1000, ns)) {
-      throw Components.results.NS_ERROR_FAILURE;
-    }
-  },
-
-  receiveMessage: function receiveMessage(aMessage) {
-    debug("receiveMessage(): " + aMessage.name);
-    let json = aMessage.json;
-
-    // To prevent the hacked child process from sending commands to parent
-    // to schedule alarms, we need to check its permission and manifest URL.
-    if (this._messages.indexOf(aMessage.name) != -1) {
-      if (!aMessage.target.assertPermission("alarms")) {
-        debug("Got message from a child process with no 'alarms' permission.");
-        return null;
-      }
-
-      if (!aMessage.target.assertContainApp(json.manifestURL)) {
-        debug("Got message from a child process containing illegal manifest URL.");
-        return null;
-      }
-    }
-
-    let mm = aMessage.target.QueryInterface(Ci.nsIMessageSender);
-
-    switch (aMessage.name) {
-      case "AlarmsManager:GetAll":
-        this._db.getAll(json.manifestURL,
-          function getAllSuccessCb(aAlarms) {
-            debug("Callback after getting alarms from database: " +
-                  JSON.stringify(aAlarms));
-
-            this._sendAsyncMessage(mm, "GetAll", true, json.requestId, aAlarms);
-          }.bind(this),
-          function getAllErrorCb(aErrorMsg) {
-            this._sendAsyncMessage(mm, "GetAll", false, json.requestId, aErrorMsg);
-          }.bind(this));
-        break;
-
-      case "AlarmsManager:Add":
-        // Prepare a record for the new alarm to be added.
-        let newAlarm = { date: json.date,
-                         ignoreTimezone: json.ignoreTimezone,
-                         data: json.data,
-                         pageURL: json.pageURL,
-                         manifestURL: json.manifestURL };
-
-        this.add(newAlarm, null,
-          // Receives the alarm ID as the last argument.
-          this._sendAsyncMessage.bind(this, mm, "Add", true, json.requestId),
-          // Receives the error message as the last argument.
-          this._sendAsyncMessage.bind(this, mm, "Add", false, json.requestId));
-        break;
-
-      case "AlarmsManager:Remove":
-        this.remove(json.id, json.manifestURL);
-        break;
-
-      default:
-        throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-        break;
-    }
-  },
-
-  _sendAsyncMessage: function _sendAsyncMessage(aMessageManager, aMessageName,
-                                                aSuccess, aRequestId, aData) {
-    debug("_sendAsyncMessage()");
-
-    if (!aMessageManager) {
-      debug("Invalid message manager: null");
-      throw Components.results.NS_ERROR_FAILURE;
-    }
-
-    let json = null;
-    switch (aMessageName) {
-      case "Add":
-        json = aSuccess ?
-          { requestId: aRequestId, id: aData } :
-          { requestId: aRequestId, errorMsg: aData };
-        break;
-
-      case "GetAll":
-        json = aSuccess ?
-          { requestId: aRequestId, alarms: aData } :
-          { requestId: aRequestId, errorMsg: aData };
-        break;
-
-      default:
-        throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-        break;
-    }
-
-    aMessageManager.sendAsyncMessage("AlarmsManager:" + aMessageName +
-                                       ":Return:" + (aSuccess ? "OK" : "KO"),
-                                     json);
-  },
-
-  _removeAlarmFromDb: function _removeAlarmFromDb(aId, aManifestURL,
-                                                  aRemoveSuccessCb) {
-    debug("_removeAlarmFromDb()");
-
-    // If the aRemoveSuccessCb is undefined or null, set a dummy callback for
-    // it which is needed for _db.remove().
-    if (!aRemoveSuccessCb) {
-      aRemoveSuccessCb = function removeSuccessCb() {
-        debug("Remove alarm from DB successfully.");
-      };
-    }
-
-    // Is this a chrome alarm?
-    if (aId < 0) {
-      aRemoveSuccessCb();
-      return;
-    }
-
-    this._db.remove(aId, aManifestURL, aRemoveSuccessCb,
-                    function removeErrorCb(aErrorMsg) {
-                      throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-                    });
-  },
-
-  /**
-   * Create a copy of the alarm that does not expose internal fields to
-   * receivers and sticks to the public |respectTimezone| API rather than the
-   * boolean |ignoreTimezone| field.
-   */
-  _publicAlarm: function _publicAlarm(aAlarm) {
-    let alarm = { "id": aAlarm.id,
-                  "date": aAlarm.date,
-                  "respectTimezone": aAlarm.ignoreTimezone ?
-                                       "ignoreTimezone" : "honorTimezone",
-                  "data": aAlarm.data };
-
-    return alarm;
-  },
-
-  _fireSystemMessage: function _fireSystemMessage(aAlarm) {
-    debug("Fire system message: " + JSON.stringify(aAlarm));
-
-    let manifestURI = Services.io.newURI(aAlarm.manifestURL, null, null);
-    let pageURI = Services.io.newURI(aAlarm.pageURL, null, null);
-
-    messenger.sendMessage("alarm",
-                          this._publicAlarm(aAlarm),
-                          pageURI,
-                          manifestURI);
-  },
-
-  _notifyAlarmObserver: function _notifyAlarmObserver(aAlarm) {
-    debug("_notifyAlarmObserver()");
-
-    let wakeLock = powerManagerService.newWakeLock("cpu");
-
-    let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
-    timer.initWithCallback(() => {
-      debug("_notifyAlarmObserver - timeout()");
-      if (aAlarm.manifestURL) {
-        this._fireSystemMessage(aAlarm);
-      } else if (typeof aAlarm.alarmFiredCb === "function") {
-        aAlarm.alarmFiredCb(this._publicAlarm(aAlarm));
-      }
-
-      wakeLock.unlock();
-    }, 0, Ci.nsITimer.TYPE_ONE_SHOT);
-  },
-
-  _onAlarmFired: function _onAlarmFired() {
-    debug("_onAlarmFired()");
-
-    if (this._currentAlarm) {
-      let currentAlarmTime = this._getAlarmTime(this._currentAlarm);
-
-      // If a alarm fired before the actual time that the current
-      // alarm should occur, we reset this current alarm.
-      if (currentAlarmTime > Date.now()) {
-        let currentAlarm = this._currentAlarm;
-        this._currentAlarm = currentAlarm;
-
-        this._debugCurrentAlarm();
-        return;
-      }
-
-      this._removeAlarmFromDb(this._currentAlarm.id, null);
-      // We need to clear the current alarm before notifying because chrome
-      // alarms may add a new alarm during their callback, and we do not want
-      // to clobber it.
-      let firingAlarm = this._currentAlarm;
-      this._currentAlarm = null;
-      this._notifyAlarmObserver(firingAlarm);
-    }
-
-    // Reset the next alarm from the queue.
-    let alarmQueue = this._alarmQueue;
-    while (alarmQueue.length > 0) {
-      let nextAlarm = alarmQueue.shift();
-      let nextAlarmTime = this._getAlarmTime(nextAlarm);
-
-      // If the next alarm has been expired, directly notify the observer.
-      // it instead of setting it.
-      if (nextAlarmTime <= Date.now()) {
-        this._removeAlarmFromDb(nextAlarm.id, null);
-        this._notifyAlarmObserver(nextAlarm);
-      } else {
-        this._currentAlarm = nextAlarm;
-        break;
-      }
-    }
-
-    this._debugCurrentAlarm();
-  },
-
-  _onTimezoneChanged: function _onTimezoneChanged(aTimezoneOffset) {
-    debug("_onTimezoneChanged()");
-
-    this._currentTimezoneOffset = aTimezoneOffset;
-    this._restoreAlarmsFromDb();
-  },
-
-  _onSystemClockChanged: function _onSystemClockChanged(aClockDeltaMS) {
-    debug("_onSystemClockChanged");
-    this._restoreAlarmsFromDb();
-  },
-
-  _restoreAlarmsFromDb: function _restoreAlarmsFromDb() {
-    debug("_restoreAlarmsFromDb()");
-
-    this._db.getAll(null,
-      function getAllSuccessCb(aAlarms) {
-        debug("Callback after getting alarms from database: " +
-              JSON.stringify(aAlarms));
-
-        // Clear any alarms set or queued in the cache if coming from db.
-        let alarmQueue = this._alarmQueue;
-        if (this._currentAlarm) {
-          alarmQueue.unshift(this._currentAlarm);
-          this._currentAlarm = null;
-        }
-        for (let i = 0; i < alarmQueue.length;) {
-          if (alarmQueue[i]['id'] < 0) {
-            ++i;
-            continue;
-          }
-          alarmQueue.splice(i, 1);
-        }
-
-        // Only restore the alarm that's not yet expired; otherwise, remove it
-        // from the database and notify the observer.
-        aAlarms.forEach(function addAlarm(aAlarm) {
-          if ("manifestURL" in aAlarm && aAlarm.manifestURL &&
-              this._getAlarmTime(aAlarm) > Date.now()) {
-            alarmQueue.push(aAlarm);
-          } else {
-            this._removeAlarmFromDb(aAlarm.id, null);
-            this._notifyAlarmObserver(aAlarm);
-          }
-        }.bind(this));
-
-        // Set the next alarm from the queue.
-        if (alarmQueue.length) {
-          alarmQueue.sort(this._sortAlarmByTimeStamps.bind(this));
-          this._currentAlarm = alarmQueue.shift();
-        }
-
-        this._debugCurrentAlarm();
-      }.bind(this),
-      function getAllErrorCb(aErrorMsg) {
-        throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-      });
-  },
-
-  _getAlarmTime: function _getAlarmTime(aAlarm) {
-    // Avoid casting a Date object to a Date again to
-    // preserve milliseconds. See bug 810973.
-    let alarmTime;
-    if (aAlarm.date instanceof Date) {
-      alarmTime = aAlarm.date.getTime();
-    } else {
-      alarmTime = (new Date(aAlarm.date)).getTime();
-    }
-
-    // For an alarm specified with "ignoreTimezone", it must be fired respect
-    // to the user's timezone.  Supposing an alarm was set at 7:00pm at Tokyo,
-    // it must be gone off at 7:00pm respect to Paris' local time when the user
-    // is located at Paris.  We can adjust the alarm UTC time by calculating
-    // the difference of the orginal timezone and the current timezone.
-    if (aAlarm.ignoreTimezone) {
-      alarmTime +=
-        (this._currentTimezoneOffset - aAlarm.timezoneOffset) * 60000;
-    }
-    return alarmTime;
-  },
-
-  _sortAlarmByTimeStamps: function _sortAlarmByTimeStamps(aAlarm1, aAlarm2) {
-    return this._getAlarmTime(aAlarm1) - this._getAlarmTime(aAlarm2);
-  },
-
-  _debugCurrentAlarm: function _debugCurrentAlarm() {
-    debug("Current alarm: " + JSON.stringify(this._currentAlarm));
-    debug("Alarm queue: " + JSON.stringify(this._alarmQueue));
-  },
-
-  /**
-   *
-   * Add a new alarm. This will set the RTC to fire at the selected date and
-   * notify the caller. Notifications are delivered via System Messages if the
-   * alarm is added on behalf of a app. Otherwise aAlarmFiredCb is called.
-   *
-   * @param object aNewAlarm
-   *        Should contain the following literal properties:
-   *          - |date| date: when the alarm should timeout.
-   *          - |ignoreTimezone| boolean: See [1] for the details.
-   *          - |manifestURL| string: Manifest of app on whose behalf the alarm
-   *                                  is added.
-   *          - |pageURL| string: The page in the app that receives the system
-   *                              message.
-   *          - |data| object [optional]: Data that can be stored in DB.
-   * @param function aAlarmFiredCb
-   *        Callback function invoked when the alarm is fired.
-   *        It receives a single argument, the alarm object.
-   *        May be null.
-   * @param function aSuccessCb
-   *        Callback function to receive an alarm ID (number).
-   * @param function aErrorCb
-   *        Callback function to receive an error message (string).
-   * @returns void
-   *
-   * Notes:
-   * [1] https://wiki.mozilla.org/WebAPI/AlarmAPI#Proposed_API
-   */
-
-  add: function(aNewAlarm, aAlarmFiredCb, aSuccessCb, aErrorCb) {
-    debug("add(" + aNewAlarm.date + ")");
-
-    aSuccessCb = aSuccessCb || function() {};
-    aErrorCb = aErrorCb || function() {};
-
-    if (!aNewAlarm) {
-      aErrorCb("alarm is null");
-      return;
-    }
-
-    if (!aNewAlarm.date) {
-      aErrorCb("alarm.date is null");
-      return;
-    }
-
-    aNewAlarm['timezoneOffset'] = this._currentTimezoneOffset;
-
-    if ("manifestURL" in aNewAlarm) {
-      this._db.add(aNewAlarm,
-        function addSuccessCb(aNewId) {
-          debug("Callback after adding alarm in database.");
-          this.processNewAlarm(aNewAlarm, aNewId, aAlarmFiredCb, aSuccessCb);
-        }.bind(this),
-        function addErrorCb(aErrorMsg) {
-          aErrorCb(aErrorMsg);
-        }.bind(this));
-    } else {
-      // alarms without manifests are managed by chrome code. For them we use
-      // negative IDs.
-      this.processNewAlarm(aNewAlarm, --this.lastChromeId, aAlarmFiredCb,
-                           aSuccessCb);
-    }
-  },
-
-  processNewAlarm: function(aNewAlarm, aNewId, aAlarmFiredCb, aSuccessCb) {
-    aNewAlarm['id'] = aNewId;
-
-    // Now that the alarm has been added to the database, we can tack on
-    // the non-serializable callback to the in-memory object.
-    aNewAlarm['alarmFiredCb'] = aAlarmFiredCb;
-
-    // If the new alarm already expired at this moment, we directly
-    // notify this alarm
-    let newAlarmTime = this._getAlarmTime(aNewAlarm);
-    if (newAlarmTime < Date.now()) {
-      aSuccessCb(aNewId);
-      this._removeAlarmFromDb(aNewAlarm.id, null);
-      this._notifyAlarmObserver(aNewAlarm);
-      return;
-    }
-
-    // If there is no alarm being set in system, set the new alarm.
-    if (this._currentAlarm == null) {
-      this._currentAlarm = aNewAlarm;
-      this._debugCurrentAlarm();
-      aSuccessCb(aNewId);
-      return;
-    }
-
-    // If the new alarm is earlier than the current alarm, swap them and
-    // push the previous alarm back to the queue.
-    let alarmQueue = this._alarmQueue;
-    let currentAlarmTime = this._getAlarmTime(this._currentAlarm);
-    if (newAlarmTime < currentAlarmTime) {
-      alarmQueue.unshift(this._currentAlarm);
-      this._currentAlarm = aNewAlarm;
-      this._debugCurrentAlarm();
-      aSuccessCb(aNewId);
-      return;
-    }
-
-    // Push the new alarm in the queue.
-    alarmQueue.push(aNewAlarm);
-    alarmQueue.sort(this._sortAlarmByTimeStamps.bind(this));
-    this._debugCurrentAlarm();
-    aSuccessCb(aNewId);
-  },
-
-  /*
-   * Remove the alarm associated with an ID.
-   *
-   * @param number aAlarmId
-   *        The ID of the alarm to be removed.
-   * @param string aManifestURL
-   *        Manifest URL for application which added the alarm. (Optional)
-   * @returns void
-   */
-  remove: function(aAlarmId, aManifestURL) {
-    debug("remove(" + aAlarmId + ", " + aManifestURL + ")");
-
-    this._removeAlarmFromDb(aAlarmId, aManifestURL,
-      function removeSuccessCb() {
-        debug("Callback after removing alarm from database.");
-
-        // If there are no alarms set, nothing to do.
-        if (!this._currentAlarm) {
-          debug("No alarms set.");
-          return;
-        }
-
-        // Check if the alarm to be removed is in the queue and whether it
-        // belongs to the requesting app.
-        let alarmQueue = this._alarmQueue;
-        if (this._currentAlarm.id != aAlarmId ||
-            this._currentAlarm.manifestURL != aManifestURL) {
-
-          for (let i = 0; i < alarmQueue.length; i++) {
-            if (alarmQueue[i].id == aAlarmId &&
-                alarmQueue[i].manifestURL == aManifestURL) {
-
-              alarmQueue.splice(i, 1);
-              break;
-            }
-          }
-          this._debugCurrentAlarm();
-          return;
-        }
-
-        // The alarm to be removed is the current alarm reset the next alarm
-        // from the queue if any.
-        if (alarmQueue.length) {
-          this._currentAlarm = alarmQueue.shift();
-          this._debugCurrentAlarm();
-          return;
-        }
-
-        // No alarm waiting to be set in the queue.
-        this._currentAlarm = null;
-        this._debugCurrentAlarm();
-      }.bind(this));
-  },
-
-  observe: function(aSubject, aTopic, aData) {
-    debug("observe(): " + aTopic);
-
-    switch (aTopic) {
-      case "profile-change-teardown":
-        this.uninit();
-        break;
-
-      case "webapps-clear-data":
-        let params =
-          aSubject.QueryInterface(Ci.mozIApplicationClearPrivateDataParams);
-        if (!params) {
-          debug("Error! Fail to remove alarms for an uninstalled app.");
-          return;
-        }
-
-        // Only remove alarms for apps.
-        if (params.browserOnly) {
-          return;
-        }
-
-        let manifestURL = appsService.getManifestURLByLocalId(params.appId);
-        if (!manifestURL) {
-          debug("Error! Fail to remove alarms for an uninstalled app.");
-          return;
-        }
-
-        this._db.getAll(manifestURL,
-          function getAllSuccessCb(aAlarms) {
-            aAlarms.forEach(function removeAlarm(aAlarm) {
-              this.remove(aAlarm.id, manifestURL);
-            }, this);
-          }.bind(this),
-          function getAllErrorCb(aErrorMsg) {
-            throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-          });
-        break;
-    }
-  },
-
-  uninit: function uninit() {
-    debug("uninit()");
-
-    Services.obs.removeObserver(this, "profile-change-teardown");
-    Services.obs.removeObserver(this, "webapps-clear-data");
-
-    this._messages.forEach(function(aMsgName) {
-      ppmm.removeMessageListener(aMsgName, this);
-    }.bind(this));
-    ppmm = null;
-
-    if (this._db) {
-      this._db.close();
-    }
-    this._db = null;
-
-    this._alarmHalService = null;
-  }
-}
-
-AlarmService.init();
deleted file mode 100644
--- a/dom/alarm/AlarmsManager.js
+++ /dev/null
@@ -1,227 +0,0 @@
-/* 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/. */
-
-"use strict";
-
-/* static functions */
-const DEBUG = false;
-const REQUEST_CPU_LOCK_TIMEOUT = 10 * 1000; // 10 seconds.
-
-function debug(aStr) {
-  if (DEBUG)
-    dump("AlarmsManager: " + aStr + "\n");
-}
-
-const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gPowerManagerService",
-                                   "@mozilla.org/power/powermanagerservice;1",
-                                   "nsIPowerManagerService");
-
-function AlarmsManager() {
-  debug("Constructor");
-
-  // A <requestId, {cpuLock, timer}> map.
-  this._cpuLockDict = new Map();
-}
-
-AlarmsManager.prototype = {
-  __proto__: DOMRequestIpcHelper.prototype,
-
-  contractID : "@mozilla.org/alarmsManager;1",
-
-  classID : Components.ID("{fea1e884-9b05-11e1-9b64-87a7016c3860}"),
-
-  QueryInterface : XPCOMUtils.generateQI([Ci.nsIDOMGlobalPropertyInitializer,
-                                          Ci.nsISupportsWeakReference,
-                                          Ci.nsIObserver]),
-
-  add: function add(aDate, aRespectTimezone, aData) {
-    debug("add()");
-
-    if (!this._manifestURL) {
-      debug("Cannot add alarms for non-installed apps.");
-      throw Components.results.NS_ERROR_FAILURE;
-    }
-
-    if (!aDate) {
-      throw Components.results.NS_ERROR_INVALID_ARG;
-    }
-
-    let isIgnoreTimezone = true;
-
-    switch (aRespectTimezone) {
-      case "honorTimezone":
-        isIgnoreTimezone = false;
-        break;
-
-      case "ignoreTimezone":
-        isIgnoreTimezone = true;
-        break;
-
-      default:
-        throw Components.results.NS_ERROR_INVALID_ARG;
-        break;
-    }
-
-    let data = aData;
-    if (aData) {
-      // Run JSON.stringify() in the sand box with the principal of the calling
-      // web page to ensure no cross-origin object is involved. A "Permission
-      // Denied" error will be thrown in case of privilege violation.
-      let sandbox = new Cu.Sandbox(Cu.getWebIDLCallerPrincipal());
-      sandbox.data = aData;
-      data = JSON.parse(Cu.evalInSandbox("JSON.stringify(data)", sandbox));
-    }
-    let request = this.createRequest();
-    let requestId = this.getRequestId(request);
-    this._lockCpuForRequest(requestId);
-    this._cpmm.sendAsyncMessage("AlarmsManager:Add",
-                                { requestId: requestId,
-                                  date: aDate,
-                                  ignoreTimezone: isIgnoreTimezone,
-                                  data: data,
-                                  pageURL: this._pageURL,
-                                  manifestURL: this._manifestURL });
-    return request;
-  },
-
-  remove: function remove(aId) {
-    debug("remove()");
-
-    this._cpmm.sendAsyncMessage("AlarmsManager:Remove",
-                                { id: aId, manifestURL: this._manifestURL });
-  },
-
-  getAll: function getAll() {
-    debug("getAll()");
-
-    let request = this.createRequest();
-    this._cpmm.sendAsyncMessage("AlarmsManager:GetAll",
-                                { requestId: this.getRequestId(request),
-                                  manifestURL: this._manifestURL });
-    return request;
-  },
-
-  receiveMessage: function receiveMessage(aMessage) {
-    debug("receiveMessage(): " + aMessage.name);
-
-    let json = aMessage.json;
-    let request = this.getRequest(json.requestId);
-
-    if (!request) {
-      debug("No request stored! " + json.requestId);
-      return;
-    }
-
-    switch (aMessage.name) {
-      case "AlarmsManager:Add:Return:OK":
-        this._unlockCpuForRequest(json.requestId);
-        Services.DOMRequest.fireSuccess(request, json.id);
-        break;
-
-      case "AlarmsManager:GetAll:Return:OK":
-        // We don't need to expose everything to the web content.
-        let alarms = [];
-        json.alarms.forEach(function trimAlarmInfo(aAlarm) {
-          let alarm = { "id": aAlarm.id,
-                        "date": aAlarm.date,
-                        "respectTimezone": aAlarm.ignoreTimezone ?
-                                             "ignoreTimezone" : "honorTimezone",
-                        "data": aAlarm.data };
-          alarms.push(alarm);
-        });
-
-        Services.DOMRequest.fireSuccess(request,
-                                        Cu.cloneInto(alarms, this._window));
-        break;
-
-      case "AlarmsManager:Add:Return:KO":
-        this._unlockCpuForRequest(json.requestId);
-        Services.DOMRequest.fireError(request, json.errorMsg);
-        break;
-
-      case "AlarmsManager:GetAll:Return:KO":
-        Services.DOMRequest.fireError(request, json.errorMsg);
-        break;
-
-      default:
-        debug("Wrong message: " + aMessage.name);
-        break;
-    }
-
-    this.removeRequest(json.requestId);
-   },
-
-  // nsIDOMGlobalPropertyInitializer implementation
-  init: function init(aWindow) {
-    debug("init()");
-
-    this._cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
-                   .getService(Ci.nsISyncMessageSender);
-
-    // Add the valid messages to be listened.
-    this.initDOMRequestHelper(aWindow, ["AlarmsManager:Add:Return:OK",
-                                        "AlarmsManager:Add:Return:KO",
-                                        "AlarmsManager:GetAll:Return:OK",
-                                        "AlarmsManager:GetAll:Return:KO"]);
-
-    // Get the manifest URL if this is an installed app
-    let appsService = Cc["@mozilla.org/AppsService;1"]
-                        .getService(Ci.nsIAppsService);
-    let principal = aWindow.document.nodePrincipal;
-    this._pageURL = principal.URI.spec;
-    this._manifestURL = appsService.getManifestURLByLocalId(principal.appId);
-    this._window = aWindow;
-  },
-
-  // Called from DOMRequestIpcHelper.
-  uninit: function uninit() {
-    debug("uninit()");
-  },
-
-  _lockCpuForRequest: function (aRequestId) {
-    if (this._cpuLockDict.has(aRequestId)) {
-      debug('Cpu wakelock for request ' + aRequestId + ' has been acquired. ' +
-            'You may call this function repeatedly or requestId is collision.');
-      return;
-    }
-
-    // Acquire a lock for given request and save for lookup lately.
-    debug('Acquire cpu lock for request ' + aRequestId);
-    let cpuLockInfo = {
-      cpuLock: gPowerManagerService.newWakeLock("cpu"),
-      timer: Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer)
-    };
-    this._cpuLockDict.set(aRequestId, cpuLockInfo);
-
-    // Start a timer to prevent from non-responding request.
-    cpuLockInfo.timer.initWithCallback(() => {
-      debug('Request timeout! Release the cpu lock');
-      this._unlockCpuForRequest(aRequestId);
-    }, REQUEST_CPU_LOCK_TIMEOUT, Ci.nsITimer.TYPE_ONE_SHOT);
-  },
-
-  _unlockCpuForRequest: function(aRequestId) {
-    let cpuLockInfo = this._cpuLockDict.get(aRequestId);
-    if (!cpuLockInfo) {
-      debug('The cpu lock for requestId ' + aRequestId + ' is either invalid ' +
-            'or has been released.');
-      return;
-    }
-
-    // Release the cpu lock and cancel the timer.
-    debug('Release the cpu lock for ' + aRequestId);
-    cpuLockInfo.cpuLock.unlock();
-    cpuLockInfo.timer.cancel();
-    this._cpuLockDict.delete(aRequestId);
-  },
-
-}
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([AlarmsManager])
deleted file mode 100644
--- a/dom/alarm/AlarmsManager.manifest
+++ /dev/null
@@ -1,2 +0,0 @@
-component {fea1e884-9b05-11e1-9b64-87a7016c3860} AlarmsManager.js
-contract @mozilla.org/alarmsManager;1 {fea1e884-9b05-11e1-9b64-87a7016c3860}
deleted file mode 100644
--- a/dom/alarm/moz.build
+++ /dev/null
@@ -1,39 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-XPIDL_SOURCES += [
-    'nsIAlarmHalService.idl',
-]
-
-XPIDL_MODULE = 'dom_alarm'
-
-EXPORTS.mozilla.dom.alarm += [
-    'AlarmHalService.h',
-]
-
-SOURCES += [
-    'AlarmHalService.cpp',
-]
-
-EXTRA_COMPONENTS += [
-    'AlarmsManager.js',
-    'AlarmsManager.manifest',
-]
-
-EXTRA_JS_MODULES += [
-    'AlarmDB.jsm',
-    'AlarmService.jsm',
-]
-
-include('/ipc/chromium/chromium-config.mozbuild')
-
-FINAL_LIBRARY = 'xul'
-
-MOCHITEST_MANIFESTS += ['test/mochitest.ini']
-
-MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
-
-XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell.ini']
deleted file mode 100644
--- a/dom/alarm/nsIAlarmHalService.idl
+++ /dev/null
@@ -1,40 +0,0 @@
-/* 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 "nsISupports.idl"
-
-[scriptable, function, uuid(53dec7f9-bb51-4c3a-98ab-80d5d750c9dd)]
-interface nsIAlarmFiredCb : nsISupports
-{
-  void onAlarmFired();
-};
-
-[scriptable, function, uuid(e6662911-c066-4358-9388-8661065c65a2)]
-interface nsITimezoneChangedCb : nsISupports
-{
-  void onTimezoneChanged(in int32_t aTimezoneOffset);
-};
-
-[scriptable, function, uuid(46ece987-a3ec-4124-906f-d99c83296ac6)]
-interface nsISystemClockChangedCb : nsISupports
-{
-  void onSystemClockChanged(in int32_t aClockDeltaMS);
-};
-
-%{C++
-#define NS_ALARMHALSERVICE_CID { 0x7dafea4c, 0x7163, 0x4b70, { 0x95, 0x4e, 0x5a, 0xd4, 0x09, 0x94, 0x83, 0xd7 } }
-#define ALARMHALSERVICE_CONTRACTID "@mozilla.org/alarmHalService;1"
-%}
-
-[scriptable, uuid(35074214-f50d-4f9a-b173-8d564dfa657d)]
-interface nsIAlarmHalService : nsISupports
-{
-  bool setAlarm(in int32_t aSeconds, in int32_t aNanoseconds);
-  void setAlarmFiredCb(in nsIAlarmFiredCb aAlarmFiredCb);
-  void setTimezoneChangedCb(in nsITimezoneChangedCb aTimezoneChangedCb);
-  void setSystemClockChangedCb(in nsISystemClockChangedCb aSystemClockChangedCb);
-};
-
-
-
deleted file mode 100644
--- a/dom/alarm/test/chrome.ini
+++ /dev/null
@@ -1,7 +0,0 @@
-[DEFAULT]
-run-if = buildapp == 'b2g' || buildapp == 'mulet'
-support-files =
-  file_empty.html
-  system_message_chrome_script.js
-
-[test_alarm_permitted_app.html]
deleted file mode 100644
--- a/dom/alarm/test/file_empty.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<!DOCTYPE html>
-<html><head></head><body><span id="text">Nothing to see here</span><iframe name="subframe"></iframe></body></html>
deleted file mode 100644
--- a/dom/alarm/test/mochitest.ini
+++ /dev/null
@@ -1,14 +0,0 @@
-[DEFAULT]
-run-if = buildapp == 'b2g' || buildapp == 'mulet'
-support-files =
-  file_empty.html
-  system_message_chrome_script.js
-
-[test_alarm_add_data.html]
-[test_alarm_add_date.html]
-[test_alarm_add_respectTimezone.html]
-[test_alarm_non_permitted_app.html]
-[test_alarm_remove.html]
-[test_bug1015540.html]
-[test_bug1037079.html]
-[test_bug1090896.html]
deleted file mode 100644
--- a/dom/alarm/test/system_message_chrome_script.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-'use strict';
-
-var { classes: Cc, interfaces: Ci } = Components;
-
-const systemMessenger = Cc["@mozilla.org/system-message-internal;1"]
-                          .getService(Ci.nsISystemMessagesInternal);
-const ioService = Cc["@mozilla.org/network/io-service;1"]
-                    .getService(Ci.nsIIOService);
-
-addMessageListener("trigger-register-page", function(aData) {
-  systemMessenger.registerPage(aData.type,
-                               ioService.newURI(aData.pageURL, null, null),
-                               ioService.newURI(aData.manifestURL, null, null));
-  sendAsyncMessage("page-registered");
-});
deleted file mode 100644
--- a/dom/alarm/test/test_alarm_add_data.html
+++ /dev/null
@@ -1,246 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test data Paramter for Alarm API</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-  <script type="application/javascript">
-
-  "use strict";
-
-  // Verify passing {} for the data paramter
-  function testEmptyObject() {
-    var tomorrow = new Date();
-    tomorrow.setDate(tomorrow.getDate() + 1);
-
-    var data = {};
-
-    var domRequest;
-    try {
-      domRequest = navigator.mozAlarms.add(tomorrow, "honorTimezone", data);
-    } catch (e) {
-      ok(false,
-         "Unexpected exception trying to add alarm for tomorrow for empty object test.");
-
-      return testEmptyList();
-    }
-    domRequest.onsuccess = function(e) {
-      var alarmId = e.target.result;
-
-      // Confirm the alarm added has the data we requested
-      var allReq;
-      try {
-        allReq = navigator.mozAlarms.getAll();
-      } catch (e) {
-        ok(false,
-          "Unexpected exception trying to get all alarms for empty object test.");
-
-        return testEmptyList();
-      }
-      allReq.onsuccess = function(ev) {
-        navigator.mozAlarms.remove(alarmId);
-
-        var found = false;
-        ev.target.result.forEach(function(alarm, i, arr) {
-          if (alarm.id == alarmId) {
-            // Found the one we added
-            ok(Object.keys(alarm.data).length === 0,
-               "Empty object passed for data parameter for new alarm.");
-
-            found = true;
-          }
-        });
-
-        if (!found) {
-          ok(false, "Couldn't find alarm that was added for empty object test.");
-        }
-
-        testEmptyList();
-      }
-      allReq.onerror = function(e) {
-        ok(false, "Unable to get all alarms for empty object test.");
-
-        testEmptyList();
-      }
-    };
-    domRequest.onerror = function(e) {
-      ok(false, "Unable to add alarm for tomorrow for empty object test.");
-
-      testEmptyList();
-    };
-
-  }
-
-  // Verify passing [] for the data paramter
-  function testEmptyList() {
-    var tomorrow = new Date();
-    tomorrow.setDate(tomorrow.getDate() + 1);
-
-    var data = [];
-
-    var domRequest;
-    try {
-      domRequest = navigator.mozAlarms.add(tomorrow, "honorTimezone", data);
-    } catch (e) {
-      ok(false,
-         "Unexpected exception trying to add alarm for tomorrow for empty list test.");
-
-      return testNull();
-    }
-    domRequest.onsuccess = function(e) {
-      var alarmId = e.target.result;
-
-      // Confirm the alarm added has the data we requested
-      var allReq;
-      try {
-        allReq = navigator.mozAlarms.getAll();
-      } catch (e) {
-        ok(false,
-          "Unexpected exception trying to get all alarms for empty list test.");
-
-        return testNull();
-      }
-      allReq.onsuccess = function(ev) {
-        navigator.mozAlarms.remove(alarmId);
-
-        var found = false;
-        ev.target.result.forEach(function(alarm, i, arr) {
-          if (alarm.id == alarmId) {
-            // Found the one we added
-            ok(alarm.data.length === 0,
-               "Empty list passed for data parameter for new alarm.");
-
-            found = true;
-          }
-        });
-
-        if (!found) {
-          ok(false, "Couldn't find alarm that was added for empty list test.");
-        }
-
-        testNull();
-      }
-      allReq.onerror = function(e) {
-        ok(false, "Unable to get all alarms for empty list test.");
-
-        testNull();
-      }
-    };
-    domRequest.onerror = function(e) {
-      ok(false, "Unable to add alarm for tomorrow for empty list test.");
-
-      testNull();
-    };
-
-  }
-
-  // Verify passing null for the data paramter
-  function testNull() {
-    var tomorrow = new Date();
-    tomorrow.setDate(tomorrow.getDate() + 1);
-
-    var data = null;
-
-    var domRequest;
-    try {
-      domRequest = navigator.mozAlarms.add(tomorrow, "honorTimezone", data);
-    } catch (e) {
-      ok(false,
-         "Unexpected exception trying to add alarm for tomorrow for null test.");
-      return SimpleTest.finish();
-    }
-    domRequest.onsuccess = function(e) {
-      var alarmId = e.target.result;
-
-      // Confirm the alarm added has the data we requested
-      var allReq;
-      try {
-        allReq = navigator.mozAlarms.getAll();
-      } catch (e) {
-        ok(false,
-          "Unexpected exception trying to get all alarms for null test.");
-        return SimpleTest.finish();
-      }
-      allReq.onsuccess = function(ev) {
-        navigator.mozAlarms.remove(alarmId);
-
-        var found = false;
-        ev.target.result.forEach(function(alarm, i, arr) {
-          if (alarm.id == alarmId) {
-            // Found the one we added
-            ok(alarm.data === null,
-               "Null passed for data parameter for new alarm.");
-
-            found = true;
-          }
-        });
-
-        if (!found) {
-          ok(false, "Couldn't find alarm that was added for null test.");
-        }
-        SimpleTest.finish();
-      }
-      allReq.onerror = function(e) {
-        ok(false, "Unable to get all alarms for null test.");
-        SimpleTest.finish();
-      }
-    };
-    domRequest.onerror = function(e) {
-      ok(false, "Unable to add alarm for tomorrow for null test.");
-      SimpleTest.finish();
-    };
-
-  }
-
-  function startTests() {
-    SpecialPowers.pushPrefEnv({
-      "set": [["dom.mozAlarms.enabled", true]]
-    }, function() {
-      var isAllowedToTest = true;
-
-      if (navigator.appVersion.indexOf("Android") !== -1) {
-        ok(true, "mozAlarms is not allowed on Android for now. " +
-                 "TODO Bug 863557.");
-        isAllowedToTest = false;
-      } else if (SpecialPowers.wrap(document).nodePrincipal.appStatus ==
-                 SpecialPowers.Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED) {
-        ok(true, "mozAlarms is not allowed for non-installed apps. " +
-                 "TODO Bug 876981.");
-        isAllowedToTest = false;
-      }
-
-      if (isAllowedToTest) {
-        ok(true, "Start to test...");
-        testEmptyObject();
-      } else {
-        // A sanity check to make sure we must run tests on Firefox OS (B2G).
-        if (navigator.userAgent.indexOf("Mobile") != -1 &&
-            navigator.appVersion.indexOf("Android") == -1) {
-          ok(false, "Should run the test on Firefox OS (B2G)!");
-        }
-
-        SimpleTest.finish();
-      }
-    });
-  }
-
-  SimpleTest.expectAssertions(0, 9);
-  SimpleTest.waitForExplicitFinish();
-  if (SpecialPowers.hasPermission("alarms", document)) {
-    startTests();
-  } else {
-    // Add the permission and reload the page so it propogates
-    SpecialPowers.addPermission("alarms", true, document);
-    window.location.reload();
-  }
-
-  </script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/dom/alarm/test/test_alarm_add_date.html
+++ /dev/null
@@ -1,146 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test date Paramter for Alarm API</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-  <script type="application/javascript">
-
-  "use strict";
-
-  // Verify passing a Date in the future doesn't fail
-  function testFutureDate() {
-    var tomorrow = new Date();
-    tomorrow.setDate(tomorrow.getDate() + 1);
-
-    var domRequest;
-    try {
-      domRequest = navigator.mozAlarms.add(tomorrow, "honorTimezone", {});
-    } catch (e) {
-      ok(false,
-         "Unexpected exception trying to add alarm for tomorrow.");
-
-      // Proceed to next test.
-      return testPastDate();
-    }
-    domRequest.onsuccess = function(e) {
-      navigator.mozAlarms.remove(e.target.result);
-      ok(true, "Add alarm for future date.");
-
-      // Awesome, no error so proceed to next test.
-      testPastDate();
-    };
-    domRequest.onerror = function(e) {
-      ok(false, "Unable to add alarm for tomorrow`.");
-
-      // Proceed to next test.
-      testPastDate();
-    };
-  }
-
-  // Verify passing a Date that's already past doesn't fail (it should fire immediately).
-  function testPastDate() {
-    var yesterday = new Date();
-    yesterday.setDate(yesterday.getDate() - 1);
-
-    var domRequest;
-    try {
-      domRequest = navigator.mozAlarms.add(yesterday, "honorTimezone", {});
-    } catch (e) {
-      ok(false,
-         "Unexpected exception trying to add alarm for yesterday.");
-
-      // Move on to the next test.
-      return testNullDate();
-    }
-    domRequest.onsuccess = function(e) {
-      navigator.mozAlarms.remove(e.target.result);
-
-      ok(true, "Should be able to add alarm for already past date, which should fire immediately.");
-
-      // Move on to the next test.
-      testNullDate();
-    };
-    domRequest.onerror = function(e) {
-      ok(false, "Unable to add alarm for yesterday.");
-
-      // Move on to the next test.
-      testNullDate();
-    }
-  }
-
-  // Verify passing null does indeed fail
-  function testNullDate() {
-    try {
-      navigator.mozAlarms.add(null, "honorTimezone", {});
-      ok(false, "Expected an exception to be thrown for alarm with null date.");
-    } catch(e) {
-      ok(true, "Exception thrown for alarm with null date.");
-    }
-
-    // Move on to the next test.
-    testInvalidTimeZone()
-  }
-
-  function testInvalidTimeZone() {
-    try {
-      navigator.mozAlarms.add(new Date(), "badTimeZoneArg", {});
-      ok(false, "Expected an exception to be thrown while testing bad time zone arg.");
-    } catch(e) {
-      ok(true, "Exception thrown while testing bad time zone arg.");
-    }
-    SimpleTest.finish();
-  }
-
-  function startTests() {
-    SpecialPowers.pushPrefEnv({
-      "set": [["dom.mozAlarms.enabled", true]]
-    }, function() {
-      var isAllowedToTest = true;
-
-      if (navigator.appVersion.indexOf("Android") !== -1) {
-        ok(true, "mozAlarms is not allowed on Android for now. " +
-                 "TODO Bug 863557.");
-        isAllowedToTest = false;
-      } else if (SpecialPowers.wrap(document).nodePrincipal.appStatus ==
-                 SpecialPowers.Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED) {
-        ok(true, "mozAlarms is not allowed for non-installed apps. " +
-                 "TODO Bug 876981.");
-        isAllowedToTest = false;
-      }
-
-      if (isAllowedToTest) {
-        ok(true, "Start to test...");
-        testFutureDate();
-      } else {
-        // A sanity check to make sure we must run tests on Firefox OS (B2G).
-        if (navigator.userAgent.indexOf("Mobile") != -1 &&
-            navigator.appVersion.indexOf("Android") == -1) {
-          ok(false, "Should run the test on Firefox OS (B2G)!");
-        }
-
-        SimpleTest.finish();
-      }
-    });
-  }
-
-  SimpleTest.expectAssertions(0, 9);
-  SimpleTest.waitForExplicitFinish();
-  if (SpecialPowers.hasPermission("alarms", document)) {
-    startTests();
-  } else {
-    // Add the permissions and reload so they propogate
-    SpecialPowers.addPermission("alarms", true, document);
-    window.location.reload();
-  }
-
-  </script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/dom/alarm/test/test_alarm_add_respectTimezone.html
+++ /dev/null
@@ -1,170 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test respectTimezone Parameter for Alarm API</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-  <script type="application/javascript">
-
-  "use strict";
-
-  // Verify passing `honorTimezone` doesn't fail
-  function testHonorTimezone(tomorrow) {
-    var domRequest;
-    try {
-      domRequest = navigator.mozAlarms.add(tomorrow, "honorTimezone", {});
-    } catch (e) {
-      ok(false,
-         "Unexpected exception trying to add alarm for tomorrow with `honorTimezone`.");
-      return testIgnoreTimezone(tomorrow);
-    }
-    domRequest.onsuccess = function(e) {
-      navigator.mozAlarms.remove(e.target.result);
-
-      ok(true, "Passing `honorTimezone` for repectTimezone argument.");
-      testIgnoreTimezone(tomorrow);
-    };
-    domRequest.onerror = function(e) {
-      ok(false, "Unable to add alarm for tomorrow with `honorTimezone`.");
-      testIgnoreTimezone(tomorrow);
-    };
-
-  }
-
-  // Verify passing `ignoreTimezone` doesn't fail
-  function testIgnoreTimezone(tomorrow) {
-    var domRequest;
-    try {
-      domRequest = navigator.mozAlarms.add(tomorrow, "ignoreTimezone", {});
-    } catch (e) {
-      ok(false,
-         "Unexpected exception trying to add alarm for tomorrow with `ignoreTimezone`.");
-      return testBadInput(tomorrow);
-    }
-    domRequest.onsuccess = function(e) {
-      navigator.mozAlarms.remove(e.target.result);
-
-      ok(true, "Passing `ignoreTimezone` for respectTimezone argument.");
-      testBadInput(tomorrow);
-    };
-    domRequest.onerror = function(e) {
-      ok(false, "Unable to add alarm for tomorrow with `ignoreTimezone`.");
-      testBadInput(tomorrow);
-    }
-  }
-
-  // Verify passing a string that's not `honorTimezone` or `ignoreTimezone`
-  // does fail
-  function testBadInput(tomorrow) {
-    var domRequest;
-    try {
-      domRequest = navigator.mozAlarms.add(tomorrow, "badinput", {});
-    } catch (e) {
-      ok(true, "Bad input for repectTimezone does indeed fail.");
-
-      // Errors, as it should. On to the next test.
-      return testNull(tomorrow);
-    }
-    domRequest.onsuccess = function(e) {
-      // Welp, this shouldn't happen
-      ok(false, "Malformed input accepted for `respectTimezone` param.");
-      testNull(tomorrow);
-    };
-  }
-
-  // Verify passing null does indeed fail
-  function testNull(tomorrow) {
-    var domRequest;
-    try {
-      domRequest = navigator.mozAlarms.add(tomorrow, null, {});
-    } catch(e) {
-      ok(true, "Passing null for respectTimezone does indeed fail.");
-
-      // Exception thrown, on to the next test
-      return testMisspelt(tomorrow);
-    }
-    domRequest.onsuccess = function(e) {
-      // Null should not be valid
-      ok(false, "Null should not be accepted as input for `respectTimezone` param.");
-      testMisspelt(tomorrow);
-    };
-  }
-
-  // Verify that misspelling does indeed fail
-  function testMisspelt(tomorrow) {
-    var domRequest;
-    try {
-      // Missing the e in `ignoreTimezone`
-      domRequest = navigator.mozAlarms.add(tomorrow, "ignoreTimzone", {});
-    } catch (e) {
-      ok(true, "Misspelling `ignoreTimezone` does indeed fail.");
-
-      // Exception thrown, all is right in the world.
-      // All done with tests now.
-      return SimpleTest.finish();
-    }
-    domRequest.onsuccess = function(e) {
-      // The misspelled word should not be valid
-      ok(false, "Misspelt parameter should fail.");
-      SimpleTest.finish();
-    };
-  }
-
-  function startTests() {
-    SpecialPowers.pushPrefEnv({
-      "set": [["dom.mozAlarms.enabled", true]]
-    }, function() {
-      var isAllowedToTest = true;
-
-      if (navigator.appVersion.indexOf("Android") !== -1) {
-        ok(true, "mozAlarms is not allowed on Android for now. " +
-                 "TODO Bug 863557.");
-        isAllowedToTest = false;
-      } else if (SpecialPowers.wrap(document).nodePrincipal.appStatus ==
-                 SpecialPowers.Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED) {
-        ok(true, "mozAlarms is not allowed for non-installed apps. " +
-                 "TODO Bug 876981.");
-        isAllowedToTest = false;
-      }
-
-      if (isAllowedToTest) {
-        ok(true, "Start to test...");
-
-        // Arbitrary date to use for tests
-        var tomorrow = new Date();
-        tomorrow.setDate(tomorrow.getDate() + 1);
-
-        // Kick off the tests
-        testHonorTimezone(tomorrow);
-      } else {
-        // A sanity check to make sure we must run tests on Firefox OS (B2G).
-        if (navigator.userAgent.indexOf("Mobile") != -1 &&
-            navigator.appVersion.indexOf("Android") == -1) {
-          ok(false, "Should run the test on Firefox OS (B2G)!");
-        }
-
-        SimpleTest.finish();
-      }
-    });
-  }
-
-  SimpleTest.expectAssertions(0, 9);
-  SimpleTest.waitForExplicitFinish();
-  if (SpecialPowers.hasPermission("alarms", document)) {
-    startTests();
-  } else {
-    // Add the permission and reload the page so it propogates
-    SpecialPowers.addPermission("alarms", true, document);
-    window.location.reload();
-  }
-
-  </script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/dom/alarm/test/test_alarm_change_system_clock.js
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-Components.utils.import("resource://gre/modules/AlarmService.jsm");
-Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gTimeService",
-                                   "@mozilla.org/time/timeservice;1",
-                                   "nsITimeService");
-
-const ALARM_OFFSET = 10000; // 10 seconds.
-const CLOCK_OFFSET = 20000; // 20 seconds.
-const MANIFEST_URL = "http://dummyurl.com/manifest.webapp";
-
-var alarmDate;
-var alarmFired;
-function alarmCb() {
-  alarmFired = true;
-};
-
-function run_test() {
-  do_get_profile();
-  Services.prefs.setBoolPref("dom.mozAlarms.enabled", true);
-  run_next_test();
-}
-
-/* Tests */
-
-add_test(function test_getAll() {
-  do_print("= There should not be any alarm =");
-  AlarmService._db.getAll(MANIFEST_URL, (aAlarms) => {
-    do_check_eq(aAlarms.length, 0);
-    run_next_test();
-  });
-});
-
-add_test(function test_addAlarm() {
-  do_print("= Set alarm =");
-  alarmDate = Date.now() + ALARM_OFFSET;
-  AlarmService.add({
-    date: alarmDate,
-    manifestURL: MANIFEST_URL
-  }, alarmCb, run_next_test, do_throw);
-});
-
-add_test(function test_alarmNotFired() {
-  do_print("= The alarm should be in the DB and pending =");
-  AlarmService._db.getAll(MANIFEST_URL, aAlarms => {
-    do_check_eq(aAlarms.length, 1, "The alarm is in the DB");
-    run_next_test();
-  });
-});
-
-add_test(function test_changeSystemClock() {
-  do_print("= Change system clock =");
-  gTimeService.set(Date.now() + CLOCK_OFFSET);
-  run_next_test();
-});
-
-add_test(function test_alarmFired() {
-  do_print("= The alarm should have been fired and removed from the DB =");
-  do_check_true(alarmFired, "The alarm was fired");
-  AlarmService._db.getAll(MANIFEST_URL, aAlarms => {
-    do_check_eq(aAlarms.length, 0, "No alarms in the DB");
-    run_next_test();
-  });
-});
deleted file mode 100644
--- a/dom/alarm/test/test_alarm_non_permitted_app.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test Non-Permitted Application for Alarm API</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-<script type="application/javascript">
-
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-if (SpecialPowers.hasPermission("alarms", document)) {
-  SpecialPowers.removePermission("alarms", document);
-  window.location.reload();
-} else {
-  SpecialPowers.pushPrefEnv({"set": [["dom.mozAlarms.enabled", true]]}, function() {
-    SpecialPowers.removePermission("alarms", document);
-    ok(!('mozAlarms' in navigator),
-       "navigator.mozAlarms should not exist without permission");
-    ok(!('AlarmsManager' in window),
-       "Interface AlarmsManager should not exist without permission");
-    SpecialPowers.addPermission("alarms", true, document);
-    SimpleTest.finish();
-  });
-}
-</script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/dom/alarm/test/test_alarm_permitted_app.html
+++ /dev/null
@@ -1,42 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test Permitted Application for Alarm API</title>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-<script type="application/javascript">
-
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-
-SpecialPowers.pushPrefEnv({"set": [["dom.mozAlarms.enabled", true]]}, function() {
-  // mozAlarms is installed on all platforms except Android for the moment.
-  if (navigator.appVersion.indexOf("Android") != -1) {
-    try {
-      todo('mozAlarms' in navigator,
-           "mozAlarms is not allowed on Android for now. TODO Bug 863557.");
-    } catch (e) {
-      todo(!e, "('mozAlarms' in navigator) should not throw exceptions once " +
-               "mozAlarms is installed on Android. TODO Bug 863557. " +
-               "Caught exception: " + e);
-    }
-  } else {
-    ok('AlarmsManager' in window, "Interface AlarmsManager should exist");
-    ok('mozAlarms' in navigator, "navigator.mozAlarms should exist");
-    ok(navigator.mozAlarms instanceof AlarmsManager,
-       "navigator.mozAlarms should be an instance of AlarmsManager");
-  }
-
-  SimpleTest.finish();
-});
-
-</script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/dom/alarm/test/test_alarm_remove.html
+++ /dev/null
@@ -1,118 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test Adding and Removing Alarms with Alarm API</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-  <script type="application/javascript">
-
-  "use strict";
-
-  function checkNumberOfAlarms(n, cbk) {
-    var domRequest;
-    try {
-      domRequest = navigator.mozAlarms.getAll();
-    } catch (e) {
-      ok(false,
-         "Unexpected exception trying to get all alarms.");
-      return cbk();
-    }
-    domRequest.onsuccess = function(e) {
-      ok(e.target.result.length === n, "Correct number of alarms set.");
-      cbk();
-    }
-  }
-
-  // Add alarm and then remove it
-  function testAddRemove() {
-    var tomorrow = new Date();
-    tomorrow.setDate(tomorrow.getDate() + 1);
-
-    var domRequest;
-    try {
-      domRequest = navigator.mozAlarms.getAll();
-    } catch (e) {
-      ok(false,
-         "Unexpected exception trying to get all alarms.");
-
-      return SimpleTest.finish();
-    }
-    domRequest.onsuccess = function(e) {
-      var initialAlarmsN = e.target.result.length;
-
-      var dr;
-      try {
-        dr = navigator.mozAlarms.add(tomorrow, "honorTimezone", null);
-      } catch (e) {
-        ok(false,
-           "Unexpected exception trying add alarm.");
-
-        return SimpleTest.finish();
-      }
-      dr.onsuccess = function(ev) {
-        var alarmId = ev.target.result;
-
-        checkNumberOfAlarms(initialAlarmsN + 1, function() {
-          navigator.mozAlarms.remove(alarmId);
-
-          checkNumberOfAlarms(initialAlarmsN, function() {
-            SimpleTest.finish();
-          });
-        });
-      }
-
-    }
-
-  }
-
-  function startTests() {
-    SpecialPowers.pushPrefEnv({
-      "set": [["dom.mozAlarms.enabled", true]]
-    }, function() {
-      var isAllowedToTest = true;
-
-      if (navigator.appVersion.indexOf("Android") !== -1) {
-        ok(true, "mozAlarms is not allowed on Android for now. " +
-                 "TODO Bug 863557.");
-        isAllowedToTest = false;
-      } else if (SpecialPowers.wrap(document).nodePrincipal.appStatus ==
-                 SpecialPowers.Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED) {
-        ok(true, "mozAlarms is not allowed for non-installed apps. " +
-                 "TODO Bug 876981.");
-        isAllowedToTest = false;
-      }
-
-      if (isAllowedToTest) {
-        ok(true, "Start to test...");
-        testAddRemove();
-      } else {
-        // A sanity check to make sure we must run tests on Firefox OS (B2G).
-        if (navigator.userAgent.indexOf("Mobile") != -1 &&
-            navigator.appVersion.indexOf("Android") == -1) {
-          ok(false, "Should run the test on Firefox OS (B2G)!");
-        }
-
-        SimpleTest.finish();
-      }
-    });
-  }
-
-  SimpleTest.expectAssertions(0, 9);
-  SimpleTest.waitForExplicitFinish();
-  if (SpecialPowers.hasPermission("alarms", document)) {
-    startTests();
-  } else {
-    // Add the permission and reload so it's propogated
-    SpecialPowers.addPermission("alarms", true, document);
-    window.location.reload();
-  }
-  </script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/dom/alarm/test/test_bug1015540.html
+++ /dev/null
@@ -1,73 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test data Paramter of Alarm API for Bug 1015540</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1015540">Bug 1015540</a>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-  <script type="application/javascript">
-
-  "use strict";
-
-  // Verify passing a cross-origin object for the data paramter
-  function testCrossOriginObject() {
-    var tomorrow = new Date();
-    tomorrow.setDate(tomorrow.getDate() + 1);
-
-    var data = document.getElementById('ifr').contentWindow;
-
-    try {
-      navigator.mozAlarms.add(tomorrow, "honorTimezone", data);
-      ok(false, "Adding alarms for cross-origin objects should be prohibited.");
-    } catch (e) {
-      ok(true, "Adding alarms for cross-origin objects is prohibited.");
-    }
-
-    SimpleTest.finish();
-  }
-
-  function startTests() {
-    SpecialPowers.pushPrefEnv({
-      "set": [["dom.mozAlarms.enabled", true]]
-    }, function() {
-   	  SpecialPowers.addPermission("alarms", true, document);
-      var isAllowedToTest = true;
-
-      if (navigator.appVersion.indexOf("Android") !== -1) {
-        ok(true, "mozAlarms is not allowed on Android for now. " +
-                 "TODO Bug 863557.");
-        isAllowedToTest = false;
-      } else if (SpecialPowers.wrap(document).nodePrincipal.appStatus ==
-                 SpecialPowers.Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED) {
-        ok(true, "mozAlarms is not allowed for non-installed apps. " +
-                 "TODO Bug 876981.");
-        isAllowedToTest = false;
-      }
-
-      if (isAllowedToTest) {
-        ok(true, "Start to test...");
-        testCrossOriginObject();
-      } else {
-        // A sanity check to make sure we must run tests on Firefox OS (B2G).
-        if (navigator.userAgent.indexOf("Mobile") != -1 &&
-            navigator.appVersion.indexOf("Android") == -1) {
-          ok(false, "Should run the test on Firefox OS (B2G)!");
-        }
-
-        SimpleTest.finish();
-      }
-    });
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  </script>
-</pre>
-<iframe id="ifr" onload="startTests()" src="http://example.org/tests/dom/alarm/test/file_empty.html"></iframe>
-</body>
-</html>
deleted file mode 100644
--- a/dom/alarm/test/test_bug1037079.html
+++ /dev/null
@@ -1,105 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test time alert is fired for Bug 1037079</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-  <script type="application/javascript">
-
-  "use strict";
-
-  function registerPage() {
-    var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('system_message_chrome_script.js'));
-    gScript.addMessageListener("page-registered", function pageRegisteredHandler() {
-      gScript.removeMessageListener("page-registered", pageRegisteredHandler);
-      gScript.destroy();
-      testFireTimeAlert();
-    });
-
-    gScript.sendAsyncMessage("trigger-register-page",
-                             { type: "alarm",
-                               manifestURL: window.location.origin + "/manifest.webapp",
-                               pageURL: window.location.href });
-  }
-
-  function testFireTimeAlert() {
-    var secondsLater = new Date();
-    secondsLater.setSeconds(secondsLater.getSeconds() + 10);
-
-    var domRequest;
-    try {
-      // Set system message handler.
-      navigator.mozSetMessageHandler('alarm', function(message){
-        ok(true, "Time alert has been fired.");
-        SimpleTest.finish();
-      });
-
-      domRequest = navigator.mozAlarms.add(secondsLater, "honorTimezone",
-                                           {type: "timer"});
-    } catch (e) {
-      ok(false, "Unexpected exception trying to set time alert.");
-
-      return SimpleTest.finish();
-    }
-    domRequest.onsuccess = function(e) {
-      ok(true, "Set time alert. Waiting to be fired.");
-    };
-    domRequest.onerror = function(e) {
-      ok(false, "Unable to set time alert.");
-
-      SimpleTest.finish();
-    };
-  }
-
-  function startTests() {
-    SpecialPowers.pushPrefEnv({
-      "set": [["dom.mozAlarms.enabled", true]]
-    }, function() {
-      var isAllowedToTest = true;
-
-      if (navigator.appVersion.indexOf("Android") !== -1) {
-        ok(true, "mozAlarms is not allowed on Android for now. " +
-                 "TODO Bug 863557.");
-        isAllowedToTest = false;
-      } else if (SpecialPowers.wrap(document).nodePrincipal.appStatus ==
-                 SpecialPowers.Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED) {
-        ok(true, "mozAlarms is not allowed for non-installed apps. " +
-                 "TODO Bug 876981.");
-        isAllowedToTest = false;
-      }
-
-      if (isAllowedToTest) {
-        ok(true, "Start to test...");
-        registerPage();
-      } else {
-        // A sanity check to make sure we must run tests on Firefox OS (B2G).
-        if (navigator.userAgent.indexOf("Mobile") != -1 &&
-            navigator.appVersion.indexOf("Android") == -1) {
-          ok(false, "Should run the test on Firefox OS (B2G)!");
-        }
-
-        SimpleTest.finish();
-      }
-    });
-  }
-
-  SimpleTest.expectAssertions(0, 9);
-  SimpleTest.waitForExplicitFinish();
-  if (SpecialPowers.hasPermission("alarms", document)) {
-    startTests();
-  } else {
-    // Add the permissions and reload so they propogate
-    SpecialPowers.addPermission("alarms", true, document);
-    window.location.reload();
-  }
-
-  </script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/dom/alarm/test/test_bug1090896.html
+++ /dev/null
@@ -1,97 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test time alert is fired for Bug 1090896</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-  <script type="application/javascript">
-
-  "use strict";
-
-  function registerPage() {
-    var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('system_message_chrome_script.js'));
-    gScript.addMessageListener("page-registered", function pageRegisteredHandler() {
-      gScript.removeMessageListener("page-registered", pageRegisteredHandler);
-      gScript.destroy();
-      testFireTimeAlertWithNoData();
-    });
-
-    gScript.sendAsyncMessage("trigger-register-page",
-                             { type: "alarm",
-                               manifestURL: window.location.origin + "/manifest.webapp",
-                               pageURL: window.location.href });
-  }
-
-  function testFireTimeAlertWithNoData() {
-    var secondsLater = new Date();
-    secondsLater.setSeconds(secondsLater.getSeconds() + 1);
-
-    var domRequest;
-    try {
-      // Set system message handler.
-      navigator.mozSetMessageHandler('alarm', function(message){
-        ok(true, "Time alert has been fired.");
-        SimpleTest.finish();
-      });
-
-      domRequest = navigator.mozAlarms.add(secondsLater, "honorTimezone");
-    } catch (e) {
-      ok(false, "Unexpected exception trying to set time alert. " + e);
-
-      return SimpleTest.finish();
-    }
-    domRequest.onsuccess = function(e) {
-      ok(true, "Set time alert. Waiting to be fired.");
-    };
-    domRequest.onerror = function(e) {
-      ok(false, "Unable to set time alert.");
-
-      SimpleTest.finish();
-    };
-  }
-
-  function startTests() {
-    SpecialPowers.pushPrefEnv({
-      "set": [["dom.mozAlarms.enabled", true]]
-    }, function() {
-      var isAllowedToTest = true;
-
-      if (navigator.appVersion.indexOf("Android") !== -1) {
-        ok(true, "mozAlarms is not allowed on Android for now. " +
-                 "TODO Bug 863557.");
-        isAllowedToTest = false;
-      } else if (SpecialPowers.wrap(document).nodePrincipal.appStatus ==
-                 SpecialPowers.Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED) {
-        ok(true, "mozAlarms is not allowed for non-installed apps. " +
-                 "TODO Bug 876981.");
-        isAllowedToTest = false;
-      }
-
-      if (isAllowedToTest) {
-        ok(true, "Start to test...");
-        registerPage();
-      } else {
-        // A sanity check to make sure we must run tests on Firefox OS (B2G).
-        if (navigator.userAgent.indexOf("Mobile") != -1 &&
-            navigator.appVersion.indexOf("Android") == -1) {
-          ok(false, "Should run the test on Firefox OS (B2G)!");
-        }
-
-        SimpleTest.finish();
-      }
-    });
-  }
-
-  SimpleTest.waitForExplicitFinish();
-  SpecialPowers.pushPermissions([{'type': 'alarms', 'allow': true, 'context': document}], startTests);
-
-  </script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/dom/alarm/test/xpcshell.ini
+++ /dev/null
@@ -1,7 +0,0 @@
-[DEFAULT]
-head =
-tail =
-
-[test_alarm_change_system_clock.js]
-# This test fails on the ICS emulator. We can enable it once bug 1090359 is fixed.
-skip-if = 1
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -221,23 +221,23 @@ Animation::SetTimeline(AnimationTimeline
   SetTimelineNoUpdate(aTimeline);
   PostUpdate();
 }
 
 // https://w3c.github.io/web-animations/#setting-the-timeline
 void
 Animation::SetTimelineNoUpdate(AnimationTimeline* aTimeline)
 {
-  RefPtr<AnimationTimeline> oldTimeline = mTimeline;
   if (mTimeline == aTimeline) {
     return;
   }
 
-  if (mTimeline) {
-    mTimeline->RemoveAnimation(this);
+  RefPtr<AnimationTimeline> oldTimeline = mTimeline;
+  if (oldTimeline) {
+    oldTimeline->RemoveAnimation(this);
   }
 
   mTimeline = aTimeline;
   if (!mStartTime.IsNull()) {
     mHoldTime.SetNull();
   }
 
   UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
--- a/dom/base/NodeInfo.cpp
+++ b/dom/base/NodeInfo.cpp
@@ -202,16 +202,17 @@ NodeInfo::NamespaceEquals(const nsAStrin
 
   return mozilla::dom::NodeInfo::NamespaceEquals(nsid);
 }
 
 void
 NodeInfo::DeleteCycleCollectable()
 {
   RefPtr<nsNodeInfoManager> kungFuDeathGrip = mOwnerManager;
+  mozilla::Unused << kungFuDeathGrip; // Just keeping value alive for longer than this
   delete this;
 }
 
 bool
 NodeInfo::CanSkip()
 {
   return mDocument &&
     nsCCUncollectableMarker::InGeneration(mDocument->GetMarkedCCGeneration());
--- a/dom/base/TextInputProcessor.cpp
+++ b/dom/base/TextInputProcessor.cpp
@@ -72,17 +72,17 @@ TextInputProcessor::~TextInputProcessor(
 {
   if (mDispatcher && mDispatcher->IsComposing()) {
     // If this is composing and not canceling the composition, nobody can steal
     // the rights of TextEventDispatcher from this instance.  Therefore, this
     // needs to cancel the composition here.
     if (NS_SUCCEEDED(IsValidStateForComposition())) {
       RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
       nsEventStatus status = nsEventStatus_eIgnore;
-      mDispatcher->CommitComposition(status, &EmptyString());
+      kungFuDeathGrip->CommitComposition(status, &EmptyString());
     }
   }
 }
 
 bool
 TextInputProcessor::IsComposing() const
 {
   return mDispatcher && mDispatcher->IsComposing();
@@ -369,17 +369,17 @@ TextInputProcessor::StartComposition(nsI
                                      uint32_t aKeyFlags,
                                      uint8_t aOptionalArgc,
                                      bool* aSucceeded)
 {
   MOZ_RELEASE_ASSERT(aSucceeded, "aSucceeded must not be nullptr");
   MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
   *aSucceeded = false;
 
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
 
   WidgetKeyboardEvent* keyboardEvent;
   nsresult rv =
     PrepareKeyboardEventForComposition(aDOMKeyEvent, aKeyFlags, aOptionalArgc,
                                        keyboardEvent);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -388,92 +388,92 @@ TextInputProcessor::StartComposition(nsI
     MaybeDispatchKeydownForComposition(keyboardEvent, aKeyFlags);
   if (NS_WARN_IF(NS_FAILED(dispatcherResult.mResult)) ||
       !dispatcherResult.mCanContinue) {
     return dispatcherResult.mResult;
   }
 
   if (dispatcherResult.mDoDefault) {
     nsEventStatus status = nsEventStatus_eIgnore;
-    rv = mDispatcher->StartComposition(status);
+    rv = kungFuDeathGrip->StartComposition(status);
     *aSucceeded = status != nsEventStatus_eConsumeNoDefault &&
-                    mDispatcher && mDispatcher->IsComposing();
+                    kungFuDeathGrip && kungFuDeathGrip->IsComposing();
   }
 
   MaybeDispatchKeyupForComposition(keyboardEvent, aKeyFlags);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TextInputProcessor::SetPendingCompositionString(const nsAString& aString)
 {
   MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
   nsresult rv = IsValidStateForComposition();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
-  return mDispatcher->SetPendingCompositionString(aString);
+  return kungFuDeathGrip->SetPendingCompositionString(aString);
 }
 
 NS_IMETHODIMP
 TextInputProcessor::AppendClauseToPendingComposition(uint32_t aLength,
                                                      uint32_t aAttribute)
 {
   MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
   TextRangeType textRangeType;
   switch (aAttribute) {
     case ATTR_RAW_CLAUSE:
     case ATTR_SELECTED_RAW_CLAUSE:
     case ATTR_CONVERTED_CLAUSE:
     case ATTR_SELECTED_CLAUSE:
       textRangeType = ToTextRangeType(aAttribute);
       break;
     default:
       return NS_ERROR_INVALID_ARG;
   }
   nsresult rv = IsValidStateForComposition();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
-  return mDispatcher->AppendClauseToPendingComposition(aLength, textRangeType);
+  return kungFuDeathGrip->AppendClauseToPendingComposition(aLength, textRangeType);
 }
 
 NS_IMETHODIMP
 TextInputProcessor::SetCaretInPendingComposition(uint32_t aOffset)
 {
   MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
   nsresult rv = IsValidStateForComposition();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
-  return mDispatcher->SetCaretInPendingComposition(aOffset, 0);
+  return kungFuDeathGrip->SetCaretInPendingComposition(aOffset, 0);
 }
 
 NS_IMETHODIMP
 TextInputProcessor::FlushPendingComposition(nsIDOMKeyEvent* aDOMKeyEvent,
                                             uint32_t aKeyFlags,
                                             uint8_t aOptionalArgc,
                                             bool* aSucceeded)
 {
   MOZ_RELEASE_ASSERT(aSucceeded, "aSucceeded must not be nullptr");
   MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
 
   // Even if this doesn't flush pending composition actually, we need to reset
   // pending composition for starting next composition with new user input.
   AutoPendingCompositionResetter resetter(this);
 
   *aSucceeded = false;
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
   bool wasComposing = IsComposing();
 
   WidgetKeyboardEvent* keyboardEvent;
   nsresult rv =
     PrepareKeyboardEventForComposition(aDOMKeyEvent, aKeyFlags, aOptionalArgc,
                                        keyboardEvent);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -489,17 +489,17 @@ TextInputProcessor::FlushPendingComposit
   // Even if the preceding keydown event was consumed, if the composition
   // was already started, we shouldn't prevent the change of composition.
   if (dispatcherResult.mDoDefault || wasComposing) {
     // Preceding keydown event may cause destroying the widget.
     if (NS_FAILED(IsValidStateForComposition())) {
       return NS_OK;
     }
     nsEventStatus status = nsEventStatus_eIgnore;
-    rv = mDispatcher->FlushPendingComposition(status);
+    rv = kungFuDeathGrip->FlushPendingComposition(status);
     *aSucceeded = status != nsEventStatus_eConsumeNoDefault;
   }
 
   MaybeDispatchKeyupForComposition(keyboardEvent, aKeyFlags);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -551,17 +551,17 @@ TextInputProcessor::CommitCompositionInt
                       const WidgetKeyboardEvent* aKeyboardEvent,
                       uint32_t aKeyFlags,
                       const nsAString* aCommitString,
                       bool* aSucceeded)
 {
   if (aSucceeded) {
     *aSucceeded = false;
   }
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
   bool wasComposing = IsComposing();
 
   EventDispatcherResult dispatcherResult =
     MaybeDispatchKeydownForComposition(aKeyboardEvent, aKeyFlags);
   if (NS_WARN_IF(NS_FAILED(dispatcherResult.mResult)) ||
       !dispatcherResult.mCanContinue) {
     return dispatcherResult.mResult;
   }
@@ -570,17 +570,17 @@ TextInputProcessor::CommitCompositionInt
   // was already started, we shouldn't prevent the commit of composition.
   nsresult rv = NS_OK;
   if (dispatcherResult.mDoDefault || wasComposing) {
     // Preceding keydown event may cause destroying the widget.
     if (NS_FAILED(IsValidStateForComposition())) {
       return NS_OK;
     }
     nsEventStatus status = nsEventStatus_eIgnore;
-    rv = mDispatcher->CommitComposition(status, aCommitString);
+    rv = kungFuDeathGrip->CommitComposition(status, aCommitString);
     if (aSucceeded) {
       *aSucceeded = status != nsEventStatus_eConsumeNoDefault;
     }
   }
 
   MaybeDispatchKeyupForComposition(aKeyboardEvent, aKeyFlags);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -607,27 +607,27 @@ TextInputProcessor::CancelComposition(ns
   return CancelCompositionInternal(keyboardEvent, aKeyFlags);
 }
 
 nsresult
 TextInputProcessor::CancelCompositionInternal(
                       const WidgetKeyboardEvent* aKeyboardEvent,
                       uint32_t aKeyFlags)
 {
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
 
   EventDispatcherResult dispatcherResult =
     MaybeDispatchKeydownForComposition(aKeyboardEvent, aKeyFlags);
   if (NS_WARN_IF(NS_FAILED(dispatcherResult.mResult)) ||
       !dispatcherResult.mCanContinue) {
     return dispatcherResult.mResult;
   }
 
   nsEventStatus status = nsEventStatus_eIgnore;
-  nsresult rv = mDispatcher->CommitComposition(status, &EmptyString());
+  nsresult rv = kungFuDeathGrip->CommitComposition(status, &EmptyString());
 
   MaybeDispatchKeyupForComposition(aKeyboardEvent, aKeyFlags);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
@@ -830,36 +830,36 @@ TextInputProcessor::KeydownInternal(cons
     if (aKeyFlags & KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT) {
       return NS_OK;
     }
   } else if (NS_WARN_IF(aKeyFlags & KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT)) {
     return NS_ERROR_INVALID_ARG;
   }
   keyEvent.mModifiers = GetActiveModifiers();
 
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
   rv = IsValidStateForComposition();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   nsEventStatus status = aConsumedFlags ? nsEventStatus_eConsumeNoDefault :
                                           nsEventStatus_eIgnore;
-  if (!mDispatcher->DispatchKeyboardEvent(eKeyDown, keyEvent, status)) {
+  if (!kungFuDeathGrip->DispatchKeyboardEvent(eKeyDown, keyEvent, status)) {
     // If keydown event isn't dispatched, we don't need to dispatch keypress
     // events.
     return NS_OK;
   }
 
   aConsumedFlags |=
     (status == nsEventStatus_eConsumeNoDefault) ? KEYDOWN_IS_CONSUMED :
                                                   KEYEVENT_NOT_CONSUMED;
 
   if (aAllowToDispatchKeypress &&
-      mDispatcher->MaybeDispatchKeypressEvents(keyEvent, status)) {
+      kungFuDeathGrip->MaybeDispatchKeypressEvents(keyEvent, status)) {
     aConsumedFlags |=
       (status == nsEventStatus_eConsumeNoDefault) ? KEYPRESS_IS_CONSUMED :
                                                     KEYEVENT_NOT_CONSUMED;
   }
 
   return NS_OK;
 }
 
@@ -910,25 +910,25 @@ TextInputProcessor::KeyupInternal(const 
     if (aKeyFlags & KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT) {
       return NS_OK;
     }
   } else if (NS_WARN_IF(aKeyFlags & KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT)) {
     return NS_ERROR_INVALID_ARG;
   }
   keyEvent.mModifiers = GetActiveModifiers();
 
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
   rv = IsValidStateForComposition();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   nsEventStatus status = aDoDefault ? nsEventStatus_eIgnore :
                                       nsEventStatus_eConsumeNoDefault;
-  mDispatcher->DispatchKeyboardEvent(eKeyUp, keyEvent, status);
+  kungFuDeathGrip->DispatchKeyboardEvent(eKeyUp, keyEvent, status);
   aDoDefault = (status != nsEventStatus_eConsumeNoDefault);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TextInputProcessor::GetModifierState(const nsAString& aModifierKeyName,
                                      bool* aActive)
 {
--- a/dom/base/WebSocket.cpp
+++ b/dom/base/WebSocket.cpp
@@ -1260,41 +1260,41 @@ WebSocket::ConstructorCommon(const Globa
       aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
       return nullptr;
     }
 
     protocolArray.AppendElement(protocolElement);
   }
 
   RefPtr<WebSocket> webSocket = new WebSocket(ownerWindow);
-  RefPtr<WebSocketImpl> kungfuDeathGrip = webSocket->mImpl;
+  RefPtr<WebSocketImpl> webSocketImpl = webSocket->mImpl;
 
   bool connectionFailed = true;
 
   if (NS_IsMainThread()) {
-    webSocket->mImpl->Init(aGlobal.Context(), principal, !!aTransportProvider,
-                           aUrl, protocolArray, EmptyCString(),
-                           0, 0, aRv, &connectionFailed);
+    webSocketImpl->Init(aGlobal.Context(), principal, !!aTransportProvider,
+                        aUrl, protocolArray, EmptyCString(),
+                        0, 0, aRv, &connectionFailed);
   } else {
     // In workers we have to keep the worker alive using a workerHolder in order
     // to dispatch messages correctly.
-    if (!webSocket->mImpl->RegisterWorkerHolder()) {
+    if (!webSocketImpl->RegisterWorkerHolder()) {
       aRv.Throw(NS_ERROR_FAILURE);
       return nullptr;
     }
 
     unsigned lineno, column;
     JS::AutoFilename file;
     if (!JS::DescribeScriptedCaller(aGlobal.Context(), &file, &lineno,
                                     &column)) {
       NS_WARNING("Failed to get line number and filename in workers.");
     }
 
     RefPtr<InitRunnable> runnable =
-      new InitRunnable(webSocket->mImpl, !!aTransportProvider, aUrl,
+      new InitRunnable(webSocketImpl, !!aTransportProvider, aUrl,
                        protocolArray, nsDependentCString(file.get()), lineno,
                        column, aRv, &connectionFailed);
     runnable->Dispatch(aRv);
   }
 
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
--- a/dom/base/nsCopySupport.cpp
+++ b/dom/base/nsCopySupport.cpp
@@ -540,17 +540,18 @@ static nsresult AppendDOMNode(nsITransfe
   NS_ENSURE_SUCCESS(rv, rv);
 
   // get document for the encoder
   nsCOMPtr<nsIDocument> document = aDOMNode->OwnerDoc();
 
   // Note that XHTML is not counted as HTML here, because we can't copy it
   // properly (all the copy code for non-plaintext assumes using HTML
   // serializers and parsers is OK, and those mess up XHTML).
-  nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document, &rv);
+  DebugOnly<nsCOMPtr<nsIHTMLDocument>> htmlDoc =
+    nsCOMPtr<nsIHTMLDocument>(do_QueryInterface(document, &rv));
   NS_ENSURE_SUCCESS(rv, NS_OK);
 
   NS_ENSURE_TRUE(document->IsHTMLDocument(), NS_OK);
 
   // init encoder with document and node
   rv = docEncoder->NativeInit(document, NS_LITERAL_STRING(kHTMLMime),
                               nsIDocumentEncoder::OutputAbsoluteLinks |
                               nsIDocumentEncoder::OutputEncodeW3CEntities);
--- a/dom/base/nsDOMAttributeMap.cpp
+++ b/dom/base/nsDOMAttributeMap.cpp
@@ -255,17 +255,17 @@ nsDOMAttributeMap::SetNamedItemNS(Attr& 
     // setting a preexisting attribute is a no-op, just return the same
     // node.
     RefPtr<Attr> attribute = &aAttr;
     return attribute.forget();
   }
 
   nsresult rv;
   if (mContent->OwnerDoc() != aAttr.OwnerDoc()) {
-    nsCOMPtr<nsINode> adoptedNode =
+    DebugOnly<void*> adoptedNode =
       mContent->OwnerDoc()->AdoptNode(aAttr, aError);
     if (aError.Failed()) {
       return nullptr;
     }
 
     NS_ASSERTION(adoptedNode == &aAttr, "Uh, adopt node changed nodes?");
   }
 
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -4708,19 +4708,19 @@ nsPIDOMWindowOuter*
 nsDocument::GetWindowInternal() const
 {
   MOZ_ASSERT(!mWindow, "This should not be called when mWindow is not null!");
   // Let's use mScriptGlobalObject. Even if the document is already removed from
   // the docshell, the outer window might be still obtainable from the it.
   nsCOMPtr<nsPIDOMWindowOuter> win;
   if (mRemovedFromDocShell) {
     // The docshell returns the outer window we are done.
-    nsCOMPtr<nsIDocShell> kungfuDeathGrip(mDocumentContainer);
-    if (mDocumentContainer) {
-      win = mDocumentContainer->GetWindow();
+    nsCOMPtr<nsIDocShell> kungFuDeathGrip(mDocumentContainer);
+    if (kungFuDeathGrip) {
+      win = kungFuDeathGrip->GetWindow();
     }
   } else {
     if (nsCOMPtr<nsPIDOMWindowInner> inner = do_QueryInterface(mScriptGlobalObject)) {
       // mScriptGlobalObject is always the inner window, let's get the outer.
       win = inner->GetOuterWindow();
     }
   }
 
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -1055,21 +1055,21 @@ nsFrameLoader::SwapWithOtherRemoteLoader
   aOther->mRemoteBrowser->SetOwnerElement(ourContent);
 
   MaybeUpdatePrimaryTabParent(eTabParentChanged);
   aOther->MaybeUpdatePrimaryTabParent(eTabParentChanged);
 
   RefPtr<nsFrameMessageManager> ourMessageManager = mMessageManager;
   RefPtr<nsFrameMessageManager> otherMessageManager = aOther->mMessageManager;
   // Swap and setup things in parent message managers.
-  if (mMessageManager) {
-    mMessageManager->SetCallback(aOther);
+  if (ourMessageManager) {
+    ourMessageManager->SetCallback(aOther);
   }
-  if (aOther->mMessageManager) {
-    aOther->mMessageManager->SetCallback(this);
+  if (otherMessageManager) {
+    otherMessageManager->SetCallback(this);
   }
   mMessageManager.swap(aOther->mMessageManager);
 
   aFirstToSwap.swap(aSecondToSwap);
 
   ourFrameFrame->EndSwapDocShells(otherFrame);
 
   ourShell->BackingScaleFactorChanged();
@@ -2754,17 +2754,19 @@ nsFrameLoader::SendCrossProcessKeyEvent(
 
 nsresult
 nsFrameLoader::CreateStaticClone(nsIFrameLoader* aDest)
 {
   nsFrameLoader* dest = static_cast<nsFrameLoader*>(aDest);
   dest->MaybeCreateDocShell();
   NS_ENSURE_STATE(dest->mDocShell);
 
-  nsCOMPtr<nsIDocument> dummy = dest->mDocShell->GetDocument();
+  nsCOMPtr<nsIDocument> kungFuDeathGrip = dest->mDocShell->GetDocument();
+  Unused << kungFuDeathGrip;
+
   nsCOMPtr<nsIContentViewer> viewer;
   dest->mDocShell->GetContentViewer(getter_AddRefs(viewer));
   NS_ENSURE_STATE(viewer);
 
   nsCOMPtr<nsIDocShell> origDocShell;
   GetDocShell(getter_AddRefs(origDocShell));
   NS_ENSURE_STATE(origDocShell);
 
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -1308,22 +1308,26 @@ nsFrameMessageManager::ReceiveMessage(ns
 
             JS_ClearPendingException(cx);
             continue;
           }
         }
       }
     }
   }
-  RefPtr<nsFrameMessageManager> kungfuDeathGrip = mParentManager;
-  return mParentManager ? mParentManager->ReceiveMessage(aTarget, aTargetFrameLoader,
-                                                         aTargetClosed, aMessage,
-                                                         aIsSync, aCloneData,
-                                                         aCpows, aPrincipal,
-                                                         aRetVal) : NS_OK;
+
+  RefPtr<nsFrameMessageManager> kungFuDeathGrip = mParentManager;
+  if (kungFuDeathGrip) {
+    return kungFuDeathGrip->ReceiveMessage(aTarget, aTargetFrameLoader,
+                                           aTargetClosed, aMessage,
+                                           aIsSync, aCloneData,
+                                           aCpows, aPrincipal,
+                                           aRetVal);
+  }
+  return NS_OK;
 }
 
 void
 nsFrameMessageManager::AddChildManager(nsFrameMessageManager* aManager)
 {
   mChildManagers.AppendObject(aManager);
 
   RefPtr<nsFrameMessageManager> kungfuDeathGrip = this;
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -444,17 +444,18 @@ nsGlobalWindow::DOMMinTimeoutValue() con
 // inner doesn't already exists.
 #define FORWARD_TO_INNER_CREATE(method, args, err_rval)                       \
   PR_BEGIN_MACRO                                                              \
   if (IsOuterWindow()) {                                                      \
     if (!mInnerWindow) {                                                      \
       if (mIsClosed) {                                                        \
         return err_rval;                                                      \
       }                                                                       \
-      nsCOMPtr<nsIDocument> doc = GetDoc();                                   \
+      nsCOMPtr<nsIDocument> kungFuDeathGrip = GetDoc();                       \
+      ::mozilla::Unused << kungFuDeathGrip;                                   \
       if (!mInnerWindow) {                                                    \
         return err_rval;                                                      \
       }                                                                       \
     }                                                                         \
     return GetCurrentInnerWindowInternal()->method args;                      \
   }                                                                           \
   PR_END_MACRO
 
@@ -2153,20 +2154,22 @@ nsGlobalWindow::WouldReuseInnerWindow(ns
 void
 nsGlobalWindow::SetInitialPrincipalToSubject()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   // First, grab the subject principal.
   nsCOMPtr<nsIPrincipal> newWindowPrincipal = nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller();
 
-  // Now, if we're about to use the system principal or an nsExpandedPrincipal,
-  // make sure we're not using it for a content docshell.
-  if (nsContentUtils::IsSystemOrExpandedPrincipal(newWindowPrincipal) &&
-      GetDocShell()->ItemType() != nsIDocShellTreeItem::typeChrome) {
+  // We should never create windows with an expanded principal.
+  // If we have a system principal, make sure we're not using it for a content
+  // docshell.
+  if (nsContentUtils::IsExpandedPrincipal(newWindowPrincipal) ||
+      (nsContentUtils::IsSystemPrincipal(newWindowPrincipal) &&
+       GetDocShell()->ItemType() != nsIDocShellTreeItem::typeChrome)) {
     newWindowPrincipal = nullptr;
   }
 
   // If there's an existing document, bail if it either:
   if (mDoc) {
     // (a) is not an initial about:blank document, or
     if (!mDoc->IsInitialDocument())
       return;
@@ -2863,17 +2866,17 @@ nsGlobalWindow::SetNewDocument(nsIDocume
 
         newInnerWindow->ClearDocumentDependentSlots(cx);
       }
     } else {
       newInnerWindow->InnerSetNewDocument(cx, aDocument);
 
       // Initialize DOM classes etc on the inner window.
       JS::Rooted<JSObject*> obj(cx, newInnerGlobal);
-      rv = mContext->InitClasses(obj);
+      rv = kungFuDeathGrip->InitClasses(obj);
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     // If the document comes from a JAR, check if the channel was determined
     // to be unsafe. If so, permanently disable script on the compartment by
     // calling Block() and throwing away the key.
     nsCOMPtr<nsIJARChannel> jarChannel = do_QueryInterface(aDocument->GetChannel());
     if (jarChannel && jarChannel->GetIsUnsafe()) {
@@ -2886,17 +2889,17 @@ nsGlobalWindow::SetNewDocument(nsIDocume
     }
 
     // Give the new inner window our chrome event handler (since it
     // doesn't have one).
     newInnerWindow->mChromeEventHandler = mChromeEventHandler;
   }
 
   nsJSContext::PokeGC(JS::gcreason::SET_NEW_DOCUMENT);
-  mContext->DidInitializeContext();
+  kungFuDeathGrip->DidInitializeContext();
 
   // We wait to fire the debugger hook until the window is all set up and hooked
   // up with the outer. See bug 969156.
   if (createdInnerWindow) {
     nsContentUtils::AddScriptRunner(
       NewRunnableMethod(newInnerWindow,
                         &nsGlobalWindow::FireOnNewGlobalObject));
   }
@@ -3429,17 +3432,20 @@ nsGlobalWindow::PostHandleEvent(EventCha
     default:
       return NS_OK;
   }
 
   /* mChromeEventHandler and mContext go dangling in the middle of this
    function under some circumstances (events that destroy the window)
    without this addref. */
   nsCOMPtr<nsIDOMEventTarget> kungFuDeathGrip1(mChromeEventHandler);
+  mozilla::Unused << kungFuDeathGrip1; // These aren't referred to through the function
   nsCOMPtr<nsIScriptContext> kungFuDeathGrip2(GetContextInternal());
+  mozilla::Unused << kungFuDeathGrip2; // These aren't referred to through the function
+
 
   if (aVisitor.mEvent->mMessage == eResize) {
     mIsHandlingResizeEvent = false;
   } else if (aVisitor.mEvent->mMessage == eUnload &&
              aVisitor.mEvent->IsTrusted()) {
     // Execute bindingdetached handlers before we tear ourselves
     // down.
     if (mDoc) {
@@ -3599,16 +3605,17 @@ void
 nsPIDOMWindow<T>::MaybeCreateDoc()
 {
   MOZ_ASSERT(!mDoc);
   if (nsIDocShell* docShell = GetDocShell()) {
     // Note that |document| here is the same thing as our mDoc, but we
     // don't have to explicitly set the member variable because the docshell
     // has already called SetNewDocument().
     nsCOMPtr<nsIDocument> document = docShell->GetDocument();
+    Unused << document;
   }
 }
 
 void
 nsPIDOMWindowOuter::SetInitialKeyboardIndicators(
   UIStateChangeType aShowAccelerators, UIStateChangeType aShowFocusRings)
 {
   MOZ_ASSERT(IsOuterWindow());
@@ -11861,16 +11868,17 @@ nsGlobalWindow::OpenInternal(const nsASt
       // window.open() from JavaScript, make sure there's a document in
       // the new window. We do this by simply asking the new window for
       // its document, this will synchronously create an empty document
       // if there is no document in the window.
       // XXXbz should this just use EnsureInnerWindow()?
 
       // Force document creation.
       nsCOMPtr<nsIDocument> doc = (*aReturn)->GetDoc();
+      Unused << doc;
     }
   }
 
   if (checkForPopup) {
     MOZ_ASSERT(abuseLevel < openAbused, "Why didn't we take the early return?");
 
     if (abuseLevel >= openControlled) {
       nsGlobalWindow *opened = nsGlobalWindow::Cast(*aReturn);
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -2181,21 +2181,25 @@ DOMGCSliceCallback(JSContext* aCx, JS::G
                                                       "InterSliceGCTimerFired");
       }
 
       if (ShouldTriggerCC(nsCycleCollector_suspectedCount())) {
         nsCycleCollector_dispatchDeferredDeletion();
       }
 
       if (sPostGCEventsToConsole) {
-        nsString gcstats;
+        NS_NAMED_LITERAL_STRING(kFmt, "[%s] ");
+        nsString prefix, gcstats;
         gcstats.Adopt(aDesc.formatSliceMessage(aCx));
+        prefix.Adopt(nsTextFormatter::smprintf(kFmt.get(),
+                                               ProcessNameForCollectorLog()));
+        nsString msg = prefix + gcstats;
         nsCOMPtr<nsIConsoleService> cs = do_GetService(NS_CONSOLESERVICE_CONTRACTID);
         if (cs) {
-          cs->LogStringMessage(gcstats.get());
+          cs->LogStringMessage(msg.get());
         }
       }
 
       break;
 
     default:
       MOZ_CRASH("Unexpected GCProgress value");
   }
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -3033,16 +3033,17 @@ nsObjectLoadingContent::SyncStartPluginI
   // the document and active
   nsCOMPtr<nsIContent> thisContent =
     do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
   if (!InActiveDocument(thisContent)) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIURI> kungFuURIGrip(mURI);
+  mozilla::Unused << kungFuURIGrip; // This URI is not referred to within this function
   nsCString contentType(mContentType);
   return InstantiatePluginInstance();
 }
 
 NS_IMETHODIMP
 nsObjectLoadingContent::AsyncStartPluginInstance()
 {
   // OK to have an instance already or a pending spawn.
--- a/dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp
@@ -20,16 +20,18 @@
 
 #include "mozilla/RefPtr.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "nsIInputStream.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 
+#include "mozilla/Unused.h"
+
 #define FILTER_NO_SMS_GSM   0x01
 #define FILTER_NO_SMS_CDMA  0x02
 #define FILTER_NO_EMAIL     0x04
 #define FILTER_NO_MMS       0x08
 
 USING_BLUETOOTH_NAMESPACE
 using namespace mozilla;
 using namespace mozilla::dom;
--- a/dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
@@ -19,16 +19,18 @@
 #include "mozilla/RefPtr.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "nsIInputStream.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsNetCID.h"
 
+#include "mozilla/Unused.h"
+
 USING_BLUETOOTH_NAMESPACE
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::ipc;
 
 namespace {
   // UUID of PBAP PSE
   static const BluetoothUuid kPbapPSE(PBAP_PSE);
--- a/dom/bluetooth/common/BluetoothUtils.cpp
+++ b/dom/bluetooth/common/BluetoothUtils.cpp
@@ -12,16 +12,17 @@
 #include "mozilla/dom/BluetoothGattServerBinding.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
 #include "nsContentUtils.h"
 #include "nsISystemMessagesInternal.h"
 #include "nsIUUIDGenerator.h"
 #include "nsServiceManagerUtils.h"
 #include "nsXULAppAPI.h"
+#include "mozilla/Unused.h"
 
 BEGIN_BLUETOOTH_NAMESPACE
 
 void
 AddressToString(const BluetoothAddress& aAddress, nsAString& aString)
 {
   char str[BLUETOOTH_ADDRESS_LENGTH + 1];
 
--- a/dom/camera/TestGonkCameraHardware.cpp
+++ b/dom/camera/TestGonkCameraHardware.cpp
@@ -383,17 +383,17 @@ TestGonkCameraHardware::Init()
       }
 
       return NS_OK;
     }
   };
 
   DebugOnly<nsresult> rv = WaitWhileRunningOnMainThread(new Delegate(this));
   NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "WaitWhileRunningOnMainThread failed");
-  return rv;
+  return NS_OK;
 }
 
 int
 TestGonkCameraHardware::AutoFocus()
 {
   class Delegate : public ControlMessage
   {
   public:
--- a/dom/console/Console.cpp
+++ b/dom/console/Console.cpp
@@ -1995,17 +1995,17 @@ Console::StartTimer(JSContext* aCx, cons
     return false;
   }
 
   nsAutoJSString label;
   if (NS_WARN_IF(!label.init(aCx, jsString))) {
     return false;
   }
 
-  DOMHighResTimeStamp entry;
+  DOMHighResTimeStamp entry = 0;
   if (!mTimerRegistry.Get(label, &entry)) {
     mTimerRegistry.Put(label, aTimestamp);
   } else {
     aTimestamp = entry;
   }
 
   aTimerLabel = label;
   *aTimerValue = aTimestamp;
@@ -2058,17 +2058,17 @@ Console::StopTimer(JSContext* aCx, const
     return false;
   }
 
   nsAutoJSString key;
   if (NS_WARN_IF(!key.init(aCx, jsString))) {
     return false;
   }
 
-  DOMHighResTimeStamp entry;
+  DOMHighResTimeStamp entry = 0;
   if (NS_WARN_IF(!mTimerRegistry.Get(key, &entry))) {
     return false;
   }
 
   mTimerRegistry.Remove(key);
 
   aTimerLabel = key;
   *aTimerDuration = aTimestamp - entry;
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -318,17 +318,17 @@ IMEStateManager::OnRemoveContent(nsPresC
       MOZ_LOG(sISMLog, LogLevel::Debug,
         ("  OnRemoveContent(), "
          "composition is in the content"));
 
       // Try resetting the native IME state.  Be aware, typically, this method
       // is called during the content being removed.  Then, the native
       // composition events which are caused by following APIs are ignored due
       // to unsafe to run script (in PresShell::HandleEvent()).
-      nsCOMPtr<nsIWidget> widget = aPresContext->GetRootWidget();
+      DebugOnly<void*> widget = aPresContext->GetRootWidget();
       MOZ_ASSERT(widget, "Why is there no widget?");
       nsresult rv =
         compositionInContent->NotifyIME(REQUEST_TO_CANCEL_COMPOSITION);
       if (NS_FAILED(rv)) {
         compositionInContent->NotifyIME(REQUEST_TO_COMMIT_COMPOSITION);
       }
     }
   }
@@ -1596,18 +1596,18 @@ IMEStateManager::CreateIMEContentObserve
   MOZ_LOG(sISMLog, LogLevel::Debug,
     ("  CreateIMEContentObserver() is creating an "
      "IMEContentObserver instance..."));
   sActiveIMEContentObserver = new IMEContentObserver();
 
   // IMEContentObserver::Init() might create another IMEContentObserver
   // instance.  So, sActiveIMEContentObserver would be replaced with new one.
   // We should hold the current instance here.
-  RefPtr<IMEContentObserver> kungFuDeathGrip(sActiveIMEContentObserver);
-  sActiveIMEContentObserver->Init(widget, sPresContext, sContent, aEditor);
+  RefPtr<IMEContentObserver> activeIMEContentObserver(sActiveIMEContentObserver);
+  activeIMEContentObserver->Init(widget, sPresContext, sContent, aEditor);
 }
 
 // static
 nsresult
 IMEStateManager::GetFocusSelectionAndRoot(nsISelection** aSelection,
                                           nsIContent** aRootContent)
 {
   if (!sActiveIMEContentObserver) {
--- a/dom/fetch/Fetch.cpp
+++ b/dom/fetch/Fetch.cpp
@@ -1044,17 +1044,17 @@ FetchBody<Derived>::ContinueConsumeBody(
   mReadDone = true;
 #endif
 
   AutoFreeBuffer autoFree(aResult);
 
   MOZ_ASSERT(mConsumePromise);
   RefPtr<Promise> localPromise = mConsumePromise.forget();
 
-  RefPtr<Derived> kungfuDeathGrip = DerivedClass();
+  RefPtr<Derived> derivedClass = DerivedClass();
   ReleaseObject();
 
   if (NS_WARN_IF(NS_FAILED(aStatus))) {
     localPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
 
     // If binding aborted, cancel the pump. We can't assert mConsumeBodyPump.
     // In the (admittedly rare) situation that BeginConsumeBodyMainThread()
     // context switches out, and the worker thread gets canceled before the
@@ -1093,17 +1093,17 @@ FetchBody<Derived>::ContinueConsumeBody(
   if (NS_FAILED(aStatus)) {
     return;
   }
 
   // Finish successfully consuming body according to type.
   MOZ_ASSERT(aResult);
 
   AutoJSAPI jsapi;
-  if (!jsapi.Init(DerivedClass()->GetParentObject())) {
+  if (!jsapi.Init(derivedClass->GetParentObject())) {
     localPromise->MaybeReject(NS_ERROR_UNEXPECTED);
     return;
   }
 
   JSContext* cx = jsapi.cx();
   ErrorResult error;
 
   switch (mConsumeType) {
@@ -1119,32 +1119,32 @@ FetchBody<Derived>::ContinueConsumeBody(
         localPromise->MaybeResolve(cx, val);
         // ArrayBuffer takes over ownership.
         autoFree.Reset();
       }
       break;
     }
     case CONSUME_BLOB: {
       RefPtr<dom::Blob> blob = BodyUtil::ConsumeBlob(
-        DerivedClass()->GetParentObject(), NS_ConvertUTF8toUTF16(mMimeType),
+        derivedClass->GetParentObject(), NS_ConvertUTF8toUTF16(mMimeType),
         aResultLength, aResult, error);
       if (!error.Failed()) {
         localPromise->MaybeResolve(blob);
         // File takes over ownership.
         autoFree.Reset();
       }
       break;
     }
     case CONSUME_FORMDATA: {
       nsCString data;
       data.Adopt(reinterpret_cast<char*>(aResult), aResultLength);
       autoFree.Reset();
 
       RefPtr<dom::FormData> fd = BodyUtil::ConsumeFormData(
-        DerivedClass()->GetParentObject(),
+        derivedClass->GetParentObject(),
         mMimeType, data, error);
       if (!error.Failed()) {
         localPromise->MaybeResolve(fd);
       }
       break;
     }
     case CONSUME_TEXT:
       // fall through handles early exit.
--- a/dom/flyweb/FlyWebPublishedServer.cpp
+++ b/dom/flyweb/FlyWebPublishedServer.cpp
@@ -166,26 +166,16 @@ NS_IMPL_ISUPPORTS_INHERITED0(FlyWebPubli
 
 FlyWebPublishedServerImpl::FlyWebPublishedServerImpl(nsPIDOMWindowInner* aOwner,
                                                      const nsAString& aName,
                                                      const FlyWebPublishOptions& aOptions)
   : FlyWebPublishedServer(aOwner, aName, aOptions)
   , mHttpServer(new HttpServer())
 {
   LOG_I("FlyWebPublishedServerImpl::FlyWebPublishedServerImpl(%p)", this);
-}
-
-void
-FlyWebPublishedServerImpl::PermissionGranted(bool aGranted)
-{
-  LOG_I("FlyWebPublishedServerImpl::PermissionGranted(%b)", aGranted);
-  if (!aGranted) {
-    PublishedServerStarted(NS_ERROR_FAILURE);
-    return;
-  }
 
   mHttpServer->Init(-1, Preferences::GetBool("flyweb.use-tls", false), this);
 }
 
 void
 FlyWebPublishedServerImpl::Close()
 {
   FlyWebPublishedServer::Close();
@@ -257,84 +247,72 @@ FlyWebPublishedServerImpl::OnWebSocketAc
 }
 
 /******** FlyWebPublishedServerChild ********/
 
 FlyWebPublishedServerChild::FlyWebPublishedServerChild(nsPIDOMWindowInner* aOwner,
                                                        const nsAString& aName,
                                                        const FlyWebPublishOptions& aOptions)
   : FlyWebPublishedServer(aOwner, aName, aOptions)
-  , mActorExists(false)
+  , mActorDestroyed(false)
 {
   LOG_I("FlyWebPublishedServerChild::FlyWebPublishedServerChild(%p)", this);
 
+  ContentChild::GetSingleton()->
+    SendPFlyWebPublishedServerConstructor(this,
+                                          PromiseFlatString(aName),
+                                          aOptions);
+
   // The matching release happens when the actor is destroyed, in
   // ContentChild::DeallocPFlyWebPublishedServerChild
   NS_ADDREF_THIS();
 }
 
-void
-FlyWebPublishedServerChild::PermissionGranted(bool aGranted)
-{
-  if (!aGranted) {
-    PublishedServerStarted(NS_ERROR_FAILURE);
-    return;
-  }
-
-  mActorExists = true;
-  FlyWebPublishOptions options;
-  options.mUiUrl = mUiUrl;
-
-  // Proceed with initialization.
-  ContentChild::GetSingleton()->
-    SendPFlyWebPublishedServerConstructor(this, mName, options);
-}
-
 bool
 FlyWebPublishedServerChild::RecvServerReady(const nsresult& aStatus)
 {
   LOG_I("FlyWebPublishedServerChild::RecvServerReady(%p)", this);
-  MOZ_ASSERT(mActorExists);
+  MOZ_ASSERT(!mActorDestroyed);
 
   PublishedServerStarted(aStatus);
   return true;
 }
 
 bool
 FlyWebPublishedServerChild::RecvServerClose()
 {
   LOG_I("FlyWebPublishedServerChild::RecvServerClose(%p)", this);
-  MOZ_ASSERT(mActorExists);
+  MOZ_ASSERT(!mActorDestroyed);
 
   Close();
 
   return true;
 }
 
 bool
 FlyWebPublishedServerChild::RecvFetchRequest(const IPCInternalRequest& aRequest,
                                              const uint64_t& aRequestId)
 {
   LOG_I("FlyWebPublishedServerChild::RecvFetchRequest(%p)", this);
-  MOZ_ASSERT(mActorExists);
+  MOZ_ASSERT(!mActorDestroyed);
 
   RefPtr<InternalRequest> request = new InternalRequest(aRequest);
   mPendingRequests.Put(request, aRequestId);
   FireFetchEvent(request);
 
   return true;
 }
 
 bool
 FlyWebPublishedServerChild::RecvWebSocketRequest(const IPCInternalRequest& aRequest,
                                                  const uint64_t& aRequestId,
                                                  PTransportProviderChild* aProvider)
 {
   LOG_I("FlyWebPublishedServerChild::RecvWebSocketRequest(%p)", this);
-  MOZ_ASSERT(mActorExists);
+  MOZ_ASSERT(!mActorDestroyed);
 
   RefPtr<InternalRequest> request = new InternalRequest(aRequest);
   mPendingRequests.Put(request, aRequestId);
 
   // Not addreffing here. The addref was already done when the
   // PTransportProvider child constructor original ran.
   mPendingTransportProviders.Put(aRequestId,
     dont_AddRef(static_cast<TransportProviderChild*>(aProvider)));
@@ -344,26 +322,26 @@ FlyWebPublishedServerChild::RecvWebSocke
   return true;
 }
 
 void
 FlyWebPublishedServerChild::ActorDestroy(ActorDestroyReason aWhy)
 {
   LOG_I("FlyWebPublishedServerChild::ActorDestroy(%p)", this);
 
-  mActorExists = false;
+  mActorDestroyed = true;
 }
 
 void
 FlyWebPublishedServerChild::OnFetchResponse(InternalRequest* aRequest,
                                             InternalResponse* aResponse)
 {
   LOG_I("FlyWebPublishedServerChild::OnFetchResponse(%p)", this);
 
-  if (!mActorExists) {
+  if (mActorDestroyed) {
     LOG_I("FlyWebPublishedServerChild::OnFetchResponse(%p) - No actor!", this);
     return;
   }
 
   uint64_t id = mPendingRequests.Get(aRequest);
   MOZ_ASSERT(id);
   mPendingRequests.Remove(aRequest);
 
@@ -378,17 +356,17 @@ FlyWebPublishedServerChild::OnFetchRespo
 
 already_AddRefed<nsITransportProvider>
 FlyWebPublishedServerChild::OnWebSocketAcceptInternal(InternalRequest* aRequest,
                                                       const Optional<nsAString>& aProtocol,
                                                       ErrorResult& aRv)
 {
   LOG_I("FlyWebPublishedServerChild::OnWebSocketAcceptInternal(%p)", this);
 
-  if (!mActorExists) {
+  if (mActorDestroyed) {
     LOG_I("FlyWebPublishedServerChild::OnWebSocketAcceptInternal(%p) - No actor!", this);
     return nullptr;
   }
 
   uint64_t id = mPendingRequests.Get(aRequest);
   MOZ_ASSERT(id);
   mPendingRequests.Remove(aRequest);
 
@@ -417,17 +395,17 @@ FlyWebPublishedServerChild::OnWebSocketA
 }
 
 void
 FlyWebPublishedServerChild::OnWebSocketResponse(InternalRequest* aRequest,
                                                 InternalResponse* aResponse)
 {
   LOG_I("FlyWebPublishedServerChild::OnFetchResponse(%p)", this);
 
-  if (!mActorExists) {
+  if (mActorDestroyed) {
     LOG_I("FlyWebPublishedServerChild::OnFetchResponse(%p) - No actor!", this);
     return;
   }
 
   uint64_t id = mPendingRequests.Get(aRequest);
   MOZ_ASSERT(id);
   mPendingRequests.Remove(aRequest);
 
@@ -445,17 +423,17 @@ FlyWebPublishedServerChild::OnWebSocketR
 
 void
 FlyWebPublishedServerChild::Close()
 {
   LOG_I("FlyWebPublishedServerChild::Close(%p)", this);
 
   FlyWebPublishedServer::Close();
 
-  if (mActorExists) {
+  if (!mActorDestroyed) {
     LOG_I("FlyWebPublishedServerChild::Close - sending __delete__ (%p)", this);
 
     Send__delete__(this);
   }
 }
 
 /******** FlyWebPublishedServerParent ********/
 
--- a/dom/flyweb/FlyWebPublishedServer.h
+++ b/dom/flyweb/FlyWebPublishedServer.h
@@ -52,18 +52,16 @@ public:
     return mName;
   }
 
   void GetUiUrl(nsAString& aUiUrl)
   {
     aUiUrl = mUiUrl;
   }
 
-  virtual void PermissionGranted(bool aGranted) = 0;
-
   virtual void OnFetchResponse(InternalRequest* aRequest,
                                InternalResponse* aResponse) = 0;
   already_AddRefed<WebSocket>
     OnWebSocketAccept(InternalRequest* aConnectRequest,
                       const Optional<nsAString>& aProtocol,
                       ErrorResult& aRv);
   virtual void OnWebSocketResponse(InternalRequest* aConnectRequest,
                                    InternalResponse* aResponse) = 0;
--- a/dom/flyweb/FlyWebPublishedServerIPC.h
+++ b/dom/flyweb/FlyWebPublishedServerIPC.h
@@ -45,17 +45,16 @@ public:
   void GetCertKey(nsACString& aKey) {
     if (mHttpServer) {
       mHttpServer->GetCertKey(aKey);
     } else {
       aKey.Truncate();
     }
   }
 
-  virtual void PermissionGranted(bool aGranted) override;
   virtual void OnFetchResponse(InternalRequest* aRequest,
                                InternalResponse* aResponse) override;
   virtual void OnWebSocketResponse(InternalRequest* aConnectRequest,
                                    InternalResponse* aResponse) override;
   virtual already_AddRefed<nsITransportProvider>
     OnWebSocketAcceptInternal(InternalRequest* aConnectRequest,
                               const Optional<nsAString>& aProtocol,
                               ErrorResult& aRv) override;
@@ -94,17 +93,16 @@ private:
 class FlyWebPublishedServerChild final : public FlyWebPublishedServer
                                        , public PFlyWebPublishedServerChild
 {
 public:
   FlyWebPublishedServerChild(nsPIDOMWindowInner* aOwner,
                              const nsAString& aName,
                              const FlyWebPublishOptions& aOptions);
 
-  virtual void PermissionGranted(bool aGranted) override;
   virtual bool RecvServerReady(const nsresult& aStatus) override;
   virtual bool RecvServerClose() override;
   virtual bool RecvFetchRequest(const IPCInternalRequest& aRequest,
                                 const uint64_t& aRequestId) override;
   virtual bool RecvWebSocketRequest(const IPCInternalRequest& aRequest,
                                     const uint64_t& aRequestId,
                                     PTransportProviderChild* aProvider) override;
 
@@ -122,17 +120,17 @@ public:
   virtual void ActorDestroy(ActorDestroyReason aWhy) override;
 
 private:
   ~FlyWebPublishedServerChild() {}
 
   nsDataHashtable<nsRefPtrHashKey<InternalRequest>, uint64_t> mPendingRequests;
   nsRefPtrHashtable<nsUint64HashKey, TransportProviderChild>
     mPendingTransportProviders;
-  bool mActorExists;
+  bool mActorDestroyed;
 };
 
 class FlyWebPublishedServerParent final : public PFlyWebPublishedServerParent
                                         , public nsIDOMEventListener
 {
 public:
   FlyWebPublishedServerParent(const nsAString& aName,
                               const FlyWebPublishOptions& aOptions);
--- a/dom/flyweb/FlyWebService.cpp
+++ b/dom/flyweb/FlyWebService.cpp
@@ -4,160 +4,46 @@
  * 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/FlyWebService.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/ScopeExit.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/FlyWebPublishedServerIPC.h"
-#include "mozilla/AddonPathService.h"
 #include "nsISocketTransportService.h"
 #include "mdns/libmdns/nsDNSServiceInfo.h"
 #include "nsIUUIDGenerator.h"
 #include "nsStandardURL.h"
 #include "mozilla/Services.h"
 #include "nsISupportsPrimitives.h"
 #include "mozilla/dom/FlyWebDiscoveryManagerBinding.h"
 #include "prnetdb.h"
 #include "DNS.h"
-#include "nsContentPermissionHelper.h"
 #include "nsSocketTransportService2.h"
 #include "nsSocketTransport2.h"
 #include "nsHashPropertyBag.h"
 #include "nsNetUtil.h"
 #include "nsISimpleEnumerator.h"
 #include "nsIProperty.h"
 #include "nsICertOverrideService.h"
 
 namespace mozilla {
 namespace dom {
 
 struct FlyWebPublishOptions;
 
 static LazyLogModule gFlyWebServiceLog("FlyWebService");
 #undef LOG_I
 #define LOG_I(...) MOZ_LOG(mozilla::dom::gFlyWebServiceLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
-
 #undef LOG_E
 #define LOG_E(...) MOZ_LOG(mozilla::dom::gFlyWebServiceLog, mozilla::LogLevel::Error, (__VA_ARGS__))
-
 #undef LOG_TEST_I
 #define LOG_TEST_I(...) MOZ_LOG_TEST(mozilla::dom::gFlyWebServiceLog, mozilla::LogLevel::Debug)
 
-class FlyWebPublishServerPermissionCheck final
-  : public nsIContentPermissionRequest
-  , public nsIRunnable
-{
-public:
-  NS_DECL_ISUPPORTS
-
-  FlyWebPublishServerPermissionCheck(const nsCString& aServiceName, uint64_t aWindowID,
-                                     FlyWebPublishedServer* aServer)
-    : mServiceName(aServiceName)
-    , mWindowID(aWindowID)
-    , mServer(aServer)
-  {}
-
-  uint64_t WindowID() const
-  {
-    return mWindowID;
-  }
-
-  NS_IMETHOD Run() override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    nsGlobalWindow* globalWindow = nsGlobalWindow::GetInnerWindowWithId(mWindowID);
-    if (!globalWindow) {
-      return Cancel();
-    }
-    mWindow = globalWindow->AsInner();
-    if (NS_WARN_IF(!mWindow)) {
-      return Cancel();
-    }
-
-    nsCOMPtr<nsIDocument> doc = mWindow->GetDoc();
-    if (NS_WARN_IF(!doc)) {
-      return Cancel();
-    }
-
-    mPrincipal = doc->NodePrincipal();
-    MOZ_ASSERT(mPrincipal);
-
-    mRequester = new nsContentPermissionRequester(mWindow);
-    return nsContentPermissionUtils::AskPermission(this, mWindow);
-  }
-
-  NS_IMETHOD Cancel() override
-  {
-    Resolve(false);
-    return NS_OK;
-  }
-
-  NS_IMETHOD Allow(JS::HandleValue aChoices) override
-  {
-    MOZ_ASSERT(aChoices.isUndefined());
-    Resolve(true);
-    return NS_OK;
-  }
-
-  NS_IMETHOD GetTypes(nsIArray** aTypes) override
-  {
-    nsTArray<nsString> emptyOptions;
-    return nsContentPermissionUtils::CreatePermissionArray(NS_LITERAL_CSTRING("flyweb-publish-server"),
-                                                           NS_LITERAL_CSTRING("unused"), emptyOptions, aTypes);
-  }
-
-  NS_IMETHOD GetRequester(nsIContentPermissionRequester** aRequester) override
-  {
-    NS_ENSURE_ARG_POINTER(aRequester);
-    nsCOMPtr<nsIContentPermissionRequester> requester = mRequester;
-    requester.forget(aRequester);
-    return NS_OK;
-  }
-
-  NS_IMETHOD GetPrincipal(nsIPrincipal** aRequestingPrincipal) override
-  {
-    NS_IF_ADDREF(*aRequestingPrincipal = mPrincipal);
-    return NS_OK;
-  }
-
-  NS_IMETHOD GetWindow(mozIDOMWindow** aRequestingWindow) override
-  {
-    NS_IF_ADDREF(*aRequestingWindow = mWindow);
-    return NS_OK;
-  }
-
-  NS_IMETHOD GetElement(nsIDOMElement** aRequestingElement) override
-  {
-    *aRequestingElement = nullptr;
-    return NS_OK;
-  }
-
-private:
-  void Resolve(bool aResolve)
-  {
-    mServer->PermissionGranted(aResolve);
-  }
-
-  virtual ~FlyWebPublishServerPermissionCheck() = default;
-
-  nsCString mServiceName;
-  uint64_t mWindowID;
-  RefPtr<FlyWebPublishedServer> mServer;
-  nsCOMPtr<nsPIDOMWindowInner> mWindow;
-  nsCOMPtr<nsIPrincipal> mPrincipal;
-  nsCOMPtr<nsIContentPermissionRequester> mRequester;
-};
-
-NS_IMPL_ISUPPORTS(FlyWebPublishServerPermissionCheck,
-                  nsIContentPermissionRequest,
-                  nsIRunnable)
-
 class FlyWebMDNSService final
   : public nsIDNSServiceDiscoveryListener
   , public nsIDNSServiceResolveListener
   , public nsIDNSRegistrationListener
   , public nsITimerCallback
 {
   friend class FlyWebService;
 
@@ -950,88 +836,39 @@ FlyWebService::Init()
       mMDNSFlywebService = nullptr;
       rv.SuppressException();
     }
   }
 
   return ErrorResult(NS_OK);
 }
 
-static already_AddRefed<FlyWebPublishPromise>
-MakeRejectionPromise(const char* name)
-{
-    MozPromiseHolder<FlyWebPublishPromise> holder;
-    RefPtr<FlyWebPublishPromise> promise = holder.Ensure(name);
-    holder.Reject(NS_ERROR_FAILURE, name);
-    return promise.forget();
-}
-
 already_AddRefed<FlyWebPublishPromise>
 FlyWebService::PublishServer(const nsAString& aName,
                              const FlyWebPublishOptions& aOptions,
                              nsPIDOMWindowInner* aWindow)
 {
   // Scan uiUrl for illegal characters
 
   RefPtr<FlyWebPublishedServer> existingServer =
     FlyWebService::GetOrCreate()->FindPublishedServerByName(aName);
   if (existingServer) {
     LOG_I("PublishServer: Trying to publish server with already-existing name %s.",
           NS_ConvertUTF16toUTF8(aName).get());
-    return MakeRejectionPromise(__func__);
+    MozPromiseHolder<FlyWebPublishPromise> holder;
+    RefPtr<FlyWebPublishPromise> promise = holder.Ensure(__func__);
+    holder.Reject(NS_ERROR_FAILURE, __func__);
+    return promise.forget();
   }
 
   RefPtr<FlyWebPublishedServer> server;
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     server = new FlyWebPublishedServerChild(aWindow, aName, aOptions);
   } else {
     server = new FlyWebPublishedServerImpl(aWindow, aName, aOptions);
-
-    // Before proceeding, ensure that the FlyWeb system addon exists.
-    nsresult rv;
-    nsCOMPtr<nsIURI> uri;
-    rv = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("chrome://flyweb/skin/icon-64.png"));
-    if (NS_FAILED(rv)) {
-      return MakeRejectionPromise(__func__);
-    }
-
-    JSAddonId *addonId = MapURIToAddonID(uri);
-    if (!addonId) {
-      LOG_E("PublishServer: Failed to find FlyWeb system addon.");
-      return MakeRejectionPromise(__func__);
-    }
-
-    JSFlatString* flat = JS_ASSERT_STRING_IS_FLAT(JS::StringOfAddonId(addonId));
-    nsAutoString addonIdString;
-    AssignJSFlatString(addonIdString, flat);
-    if (!addonIdString.EqualsLiteral("flyweb@mozilla.org")) {
-      nsCString addonIdCString = NS_ConvertUTF16toUTF8(addonIdString);
-      LOG_E("PublishServer: FlyWeb resource found on wrong system addon: %s.", addonIdCString.get());
-      return MakeRejectionPromise(__func__);
-    }
-  }
-
-  if (aWindow) {
-    nsresult rv;
-
-    MOZ_ASSERT(NS_IsMainThread());
-    rv = NS_DispatchToCurrentThread(
-      MakeAndAddRef<FlyWebPublishServerPermissionCheck>(
-        NS_ConvertUTF16toUTF8(aName), aWindow->WindowID(), server));
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      LOG_E("PublishServer: Failed to dispatch permission check runnable for %s",
-            NS_ConvertUTF16toUTF8(aName).get());
-      return MakeRejectionPromise(__func__);
-    }
-  } else {
-    // If aWindow is null, we're definitely in the e10s parent process.
-    // In this case, we know that permission has already been granted
-    // by the user because of content-process prompt.
-    MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
-    server->PermissionGranted(true);
   }
 
   mServers.AppendElement(server);
 
   return server->GetPublishPromise();
 }
 
 already_AddRefed<FlyWebPublishedServer>
--- a/dom/html/HTMLButtonElement.cpp
+++ b/dom/html/HTMLButtonElement.cpp
@@ -381,17 +381,17 @@ HTMLButtonElement::PostHandleEvent(Event
         // Using presShell to dispatch the event. It makes sure that
         // event is not handled if the window is being destroyed.
         if (presShell && (event.mMessage != eFormSubmit ||
                           mForm->SubmissionCanProceed(this))) {
           // TODO: removing this code and have the submit event sent by the form
           // see bug 592124.
           // Hold a strong ref while dispatching
           RefPtr<HTMLFormElement> form(mForm);
-          presShell->HandleDOMEventWithTarget(mForm, &event, &status);
+          presShell->HandleDOMEventWithTarget(form, &event, &status);
           aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
         }
       }
     }
   } else if ((aVisitor.mItemFlags & NS_IN_SUBMIT_CLICK) && mForm) {
     // Tell the form to flush a possible pending submission.
     // the reason is that the script returned false (the event was
     // not ignored) so if there is a stored submission, it needs to
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -3339,17 +3339,17 @@ HTMLInputElement::MaybeSubmitForm(nsPres
              mForm->SubmissionCanProceed(nullptr)) {
     // TODO: removing this code and have the submit event sent by the form,
     // bug 592124.
     // If there's only one text control, just submit the form
     // Hold strong ref across the event
     RefPtr<mozilla::dom::HTMLFormElement> form = mForm;
     InternalFormEvent event(true, eFormSubmit);
     nsEventStatus status = nsEventStatus_eIgnore;
-    shell->HandleDOMEventWithTarget(mForm, &event, &status);
+    shell->HandleDOMEventWithTarget(form, &event, &status);
   }
 
   return NS_OK;
 }
 
 void
 HTMLInputElement::SetCheckedInternal(bool aChecked, bool aNotify)
 {
@@ -4598,17 +4598,17 @@ HTMLInputElement::PostHandleEvent(EventC
             // handling the event the pres context will return a null
             // pres shell.  See bug 125624.
             // TODO: removing this code and have the submit event sent by the
             // form, see bug 592124.
             if (presShell && (event.mMessage != eFormSubmit ||
                               mForm->SubmissionCanProceed(this))) {
               // Hold a strong ref while dispatching
               RefPtr<mozilla::dom::HTMLFormElement> form(mForm);
-              presShell->HandleDOMEventWithTarget(mForm, &event, &status);
+              presShell->HandleDOMEventWithTarget(form, &event, &status);
               aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
             }
           }
           break;
 
         default:
           break;
         } //switch
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -294,17 +294,17 @@ public:
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     if (!mElement) {
       return;
     }
 
     RefPtr<HTMLMediaElement> deathGrip = mElement;
-    mElement->UpdateInitialMediaSize(aSize);
+    deathGrip->UpdateInitialMediaSize(aSize);
   }
 
   void NotifyRealtimeTrackData(MediaStreamGraph* aGraph,
                                StreamTime aTrackOffset,
                                const MediaSegment& aMedia) override
   {
     if (mInitialSizeFound) {
       return;
@@ -3947,26 +3947,26 @@ public:
   }
   void DoNotifyOutput()
   {
     {
       MutexAutoLock lock(mMutex);
       mPendingNotifyOutput = false;
     }
     if (mElement && mHaveCurrentData) {
-      RefPtr<HTMLMediaElement> deathGrip = mElement;
-      mElement->FireTimeUpdate(true);
+      RefPtr<HTMLMediaElement> kungFuDeathGrip = mElement;
+      kungFuDeathGrip->FireTimeUpdate(true);
     }
   }
   void DoNotifyHaveCurrentData()
   {
     mHaveCurrentData = true;
     if (mElement) {
-      RefPtr<HTMLMediaElement> deathGrip = mElement;
-      mElement->FirstFrameLoaded();
+      RefPtr<HTMLMediaElement> kungFuDeathGrip = mElement;
+      kungFuDeathGrip->FirstFrameLoaded();
     }
     NotifyWatchers();
     DoNotifyOutput();
   }
 
   // These notifications run on the media graph thread so we need to
   // dispatch events to the main thread.
   virtual void NotifyBlockingChanged(MediaStreamGraph* aGraph, Blocking aBlocked) override
--- a/dom/html/HTMLScriptElement.cpp
+++ b/dom/html/HTMLScriptElement.cpp
@@ -134,16 +134,20 @@ void
 HTMLScriptElement::SetText(const nsAString& aValue, ErrorResult& rv)
 {
   rv = nsContentUtils::SetNodeTextContent(this, aValue, true);
 }
 
 
 NS_IMPL_STRING_ATTR(HTMLScriptElement, Charset, charset)
 NS_IMPL_BOOL_ATTR(HTMLScriptElement, Defer, defer)
+// If this ever gets changed to return "" if the attr value is "" (see
+// https://github.com/whatwg/html/issues/1739 for why it might not get changed),
+// it may be worth it to use GetSrc instead of GetAttr and manual
+// NewURIWithDocumentCharset in FreezeUriAsyncDefer.
 NS_IMPL_URI_ATTR(HTMLScriptElement, Src, src)
 NS_IMPL_STRING_ATTR(HTMLScriptElement, Type, type)
 NS_IMPL_STRING_ATTR(HTMLScriptElement, HtmlFor, _for)
 NS_IMPL_STRING_ATTR(HTMLScriptElement, Event, event)
 
 void
 HTMLScriptElement::SetCharset(const nsAString& aCharset, ErrorResult& rv)
 {
@@ -265,21 +269,27 @@ HTMLScriptElement::GetScriptCharset(nsAS
 void
 HTMLScriptElement::FreezeUriAsyncDefer()
 {
   if (mFrozen) {
     return;
   }
 
   // variation of this code in nsSVGScriptElement - check if changes
-  // need to be transfered when modifying
-  if (HasAttr(kNameSpaceID_None, nsGkAtoms::src)) {
-    nsAutoString src;
-    GetSrc(src);
-    NS_NewURI(getter_AddRefs(mUri), src);
+  // need to be transfered when modifying.  Note that we don't use GetSrc here
+  // because it will return the base URL when the attr value is "".
+  nsAutoString src;
+  if (GetAttr(kNameSpaceID_None, nsGkAtoms::src, src)) {
+    // Empty src should be treated as invalid URL.
+    if (!src.IsEmpty()) {
+      nsCOMPtr<nsIURI> baseURI = GetBaseURI();
+      nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(mUri),
+                                                src, OwnerDoc(), baseURI);
+    }
+
     // At this point mUri will be null for invalid URLs.
     mExternal = true;
 
     bool defer, async;
     GetAsync(&async);
     GetDefer(&defer);
 
     mDefer = !async && defer;
--- a/dom/html/ImageDocument.cpp
+++ b/dom/html/ImageDocument.cpp
@@ -356,17 +356,17 @@ ImageDocument::ShrinkToFit()
       classList->Remove(NS_LITERAL_STRING("overflowingVertical"), ignored);
     }
     ignored.SuppressException();
     return;
   }
 
   // Keep image content alive while changing the attributes.
   nsCOMPtr<Element> imageContent = mImageContent;
-  nsCOMPtr<nsIDOMHTMLImageElement> image = do_QueryInterface(mImageContent);
+  nsCOMPtr<nsIDOMHTMLImageElement> image = do_QueryInterface(imageContent);
   image->SetWidth(std::max(1, NSToCoordFloor(GetRatio() * mImageWidth)));
   image->SetHeight(std::max(1, NSToCoordFloor(GetRatio() * mImageHeight)));
   
   // The view might have been scrolled when zooming in, scroll back to the
   // origin now that we're showing a shrunk-to-window version.
   ScrollImageTo(0, 0, false);
 
   if (!mImageContent) {
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -2653,18 +2653,20 @@ nsHTMLDocument::EditingStateChanged()
   nsresult rv = docshell->GetEditingSession(getter_AddRefs(editSession));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIEditor> existingEditor;
   editSession->GetEditorForWindow(window, getter_AddRefs(existingEditor));
   if (existingEditor) {
     // We might already have an editor if it was set up for mail, let's see
     // if this is actually the case.
+#ifdef DEBUG
     nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(existingEditor);
     MOZ_ASSERT(htmlEditor, "If we have an editor, it must be an HTML editor");
+#endif
     uint32_t flags = 0;
     existingEditor->GetFlags(&flags);
     if (flags & nsIPlaintextEditor::eEditorMailMask) {
       // We already have a mail editor, then we should not attempt to create
       // another one.
       return NS_OK;
     }
   }
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -2101,17 +2101,17 @@ nsTextEditorState::SetValue(const nsAStr
 
         nsCOMPtr<nsISelectionController> kungFuDeathGrip = mSelCon.get();
         uint32_t currentLength = currentValue.Length();
         uint32_t newlength = newValue.Length();
         if (!currentLength ||
             !StringBeginsWith(newValue, currentValue)) {
           // Replace the whole text.
           currentLength = 0;
-          mSelCon->SelectAll();
+          kungFuDeathGrip->SelectAll();
         } else {
           // Collapse selection to the end so that we can append data.
           mBoundFrame->SelectAllOrCollapseToEndOfText(false);
         }
         const nsAString& insertValue =
           StringTail(newValue, newlength - currentLength);
         nsCOMPtr<nsIPlaintextEditor> plaintextEditor = do_QueryInterface(mEditor);
         if (!plaintextEditor || !weakFrame.IsAlive()) {
--- a/dom/indexedDB/ActorsChild.cpp
+++ b/dom/indexedDB/ActorsChild.cpp
@@ -1495,20 +1495,20 @@ BackgroundFactoryRequestChild::RecvBlock
     MOZ_ASSERT(blockedEvent);
   }
 
   RefPtr<IDBRequest> kungFuDeathGrip = mRequest;
 
   IDB_LOG_MARK("IndexedDB %s: Child  Request[%llu]: Firing \"blocked\" event",
                "IndexedDB %s: C R[%llu]: \"blocked\"",
                IDB_LOG_ID_STRING(),
-               mRequest->LoggingSerialNumber());
+               kungFuDeathGrip->LoggingSerialNumber());
 
   bool dummy;
-  if (NS_FAILED(mRequest->DispatchEvent(blockedEvent, &dummy))) {
+  if (NS_FAILED(kungFuDeathGrip->DispatchEvent(blockedEvent, &dummy))) {
     NS_WARNING("Failed to dispatch event!");
   }
 
   return true;
 }
 
 /*******************************************************************************
  * BackgroundDatabaseChild
@@ -1788,73 +1788,73 @@ BackgroundDatabaseChild::RecvVersionChan
 
   if (!mDatabase || mDatabase->IsClosed()) {
     return true;
   }
 
   RefPtr<IDBDatabase> kungFuDeathGrip = mDatabase;
 
   // Handle bfcache'd windows.
-  if (nsPIDOMWindowInner* owner = mDatabase->GetOwner()) {
+  if (nsPIDOMWindowInner* owner = kungFuDeathGrip->GetOwner()) {
     // The database must be closed if the window is already frozen.
     bool shouldAbortAndClose = owner->IsFrozen();
 
     // Anything in the bfcache has to be evicted and then we have to close the
     // database also.
     if (nsCOMPtr<nsIDocument> doc = owner->GetExtantDoc()) {
       if (nsCOMPtr<nsIBFCacheEntry> bfCacheEntry = doc->GetBFCacheEntry()) {
         bfCacheEntry->RemoveFromBFCacheSync();
         shouldAbortAndClose = true;
       }
     }
 
     if (shouldAbortAndClose) {
       // Invalidate() doesn't close the database in the parent, so we have
       // to call Close() and AbortTransactions() manually.
-      mDatabase->AbortTransactions(/* aShouldWarn */ false);
-      mDatabase->Close();
+      kungFuDeathGrip->AbortTransactions(/* aShouldWarn */ false);
+      kungFuDeathGrip->Close();
       return true;
     }
   }
 
   // Otherwise fire a versionchange event.
   const nsDependentString type(kVersionChangeEventType);
 
   nsCOMPtr<nsIDOMEvent> versionChangeEvent;
 
   switch (aNewVersion.type()) {
     case NullableVersion::Tnull_t:
       versionChangeEvent =
-        IDBVersionChangeEvent::Create(mDatabase, type, aOldVersion);
+        IDBVersionChangeEvent::Create(kungFuDeathGrip, type, aOldVersion);
       MOZ_ASSERT(versionChangeEvent);
       break;
 
     case NullableVersion::Tuint64_t:
       versionChangeEvent =
-        IDBVersionChangeEvent::Create(mDatabase,
+        IDBVersionChangeEvent::Create(kungFuDeathGrip,
                                       type,
                                       aOldVersion,
                                       aNewVersion.get_uint64_t());
       MOZ_ASSERT(versionChangeEvent);
       break;
 
     default:
       MOZ_CRASH("Should never get here!");
   }
 
   IDB_LOG_MARK("IndexedDB %s: Child : Firing \"versionchange\" event",
                "IndexedDB %s: C: IDBDatabase \"versionchange\" event",
                IDB_LOG_ID_STRING());
 
   bool dummy;
-  if (NS_FAILED(mDatabase->DispatchEvent(versionChangeEvent, &dummy))) {
+  if (NS_FAILED(kungFuDeathGrip->DispatchEvent(versionChangeEvent, &dummy))) {
     NS_WARNING("Failed to dispatch event!");
   }
 
-  if (!mDatabase->IsClosed()) {
+  if (!kungFuDeathGrip->IsClosed()) {
     SendBlocked();
   }
 
   return true;
 }
 
 bool
 BackgroundDatabaseChild::RecvInvalidate()
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -23944,18 +23944,17 @@ nsresult
 CreateIndexOp::InsertDataFromObjectStoreInternal(
                                                 DatabaseConnection* aConnection)
 {
   MOZ_ASSERT(aConnection);
   aConnection->AssertIsOnConnectionThread();
   MOZ_ASSERT(!IndexedDatabaseManager::InLowDiskSpaceMode());
   MOZ_ASSERT(mMaybeUniqueIndexTable);
 
-  nsCOMPtr<mozIStorageConnection> storageConnection =
-    aConnection->GetStorageConnection();
+  DebugOnly<void*> storageConnection = aConnection->GetStorageConnection();
   MOZ_ASSERT(storageConnection);
 
   DatabaseConnection::CachedStatement stmt;
   nsresult rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
     "UPDATE object_data "
       "SET index_data_values = update_index_data_values "
         "(key, index_data_values, file_ids, data) "
       "WHERE object_store_id = :object_store_id;"),
--- a/dom/ipc/Blob.cpp
+++ b/dom/ipc/Blob.cpp
@@ -1660,17 +1660,17 @@ private:
 
     // If our luck is *really* bad then it is possible for the CloseStream() and
     // nsIThread::Shutdown() functions to run before the Dispatch() call here
     // finishes... Keep the thread alive until this method returns.
     nsCOMPtr<nsIThread> kungFuDeathGrip = mIOTarget;
 
     mClosing = true;
 
-    nsresult rv = mIOTarget->Dispatch(this, NS_DISPATCH_NORMAL);
+    nsresult rv = kungFuDeathGrip->Dispatch(this, NS_DISPATCH_NORMAL);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return NS_OK;
   }
 
   NS_IMETHOD
   Run() override
   {
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -4998,17 +4998,16 @@ ContentParent::RecvCreateWindow(PBrowser
     if (!newTab->SetRenderFrame(rfp) ||
         !newTab->GetRenderFrameInfo(aTextureFactoryIdentifier, aLayersId)) {
       *aResult = NS_ERROR_FAILURE;
     }
 
     return true;
   }
 
-  nsCOMPtr<mozIDOMWindowProxy> window;
   TabParent::AutoUseNewTab aunt(newTab, aWindowIsNew, aURLToLoad);
 
   nsCOMPtr<nsPIWindowWatcher> pwwatch =
     do_GetService(NS_WINDOWWATCHER_CONTRACTID, aResult);
 
   if (NS_WARN_IF(NS_FAILED(*aResult))) {
     return true;
   }
--- a/dom/jsurl/nsJSProtocolHandler.cpp
+++ b/dom/jsurl/nsJSProtocolHandler.cpp
@@ -211,17 +211,17 @@ nsresult nsJSThunk::EvaluateScript(nsICh
     nsPIDOMWindowInner *innerWin = win->GetCurrentInnerWindow();
 
     if (innerWin != aOriginalInnerWindow) {
         return NS_ERROR_UNEXPECTED;
     }
 
     nsCOMPtr<nsIScriptGlobalObject> innerGlobal = do_QueryInterface(innerWin);
 
-    nsCOMPtr<nsIDOMWindow> domWindow(do_QueryInterface(global, &rv));
+    mozilla::DebugOnly<nsCOMPtr<nsIDOMWindow>> domWindow(do_QueryInterface(global, &rv));
     if (NS_FAILED(rv)) {
         return NS_ERROR_FAILURE;
     }
 
     // So far so good: get the script context from its owner.
     nsCOMPtr<nsIScriptContext> scriptContext = global->GetContext();
     if (!scriptContext)
         return NS_ERROR_FAILURE;
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -876,16 +876,17 @@ GeckoMediaPluginServiceParent::AsyncAddP
     ->CompletionPromise();
 }
 
 NS_IMETHODIMP
 GeckoMediaPluginServiceParent::AddPluginDirectory(const nsAString& aDirectory)
 {
   MOZ_ASSERT(NS_IsMainThread());
   RefPtr<GenericPromise> p = AsyncAddPluginDirectory(aDirectory);
+  Unused << p;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 GeckoMediaPluginServiceParent::RemovePluginDirectory(const nsAString& aDirectory)
 {
   MOZ_ASSERT(NS_IsMainThread());
   return GMPDispatch(new PathRunnable(this, aDirectory,
--- a/dom/media/webaudio/test/mochitest.ini
+++ b/dom/media/webaudio/test/mochitest.ini
@@ -45,16 +45,17 @@ support-files =
 skip-if = (toolkit == 'android' && debug) || os == 'win' # bug 1127845, bug 1138468
 [test_audioBufferSourceNodeNoStart.html]
 [test_audioBufferSourceNodeNullBuffer.html]
 [test_audioBufferSourceNodeOffset.html]
 skip-if = (toolkit == 'gonk') || (toolkit == 'android') || debug #bug 906752
 [test_audioBufferSourceNodePassThrough.html]
 [test_audioBufferSourceNodeRate.html]
 [test_AudioContext.html]
+[test_AudioContext_disabled.html]
 [test_audioContextSuspendResumeClose.html]
 skip-if = buildapp == 'mulet'
 tags=capturestream
 [test_audioDestinationNode.html]
 [test_AudioListener.html]
 [test_AudioNodeDevtoolsAPI.html]
 [test_audioParamChaining.html]
 [test_AudioParamDevtoolsAPI.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/test_AudioContext_disabled.html
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test whether we can disable the AudioContext interface</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="webaudio.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+const webaudio_interfaces = [
+  "AudioContext",
+  "OfflineAudioContext",
+  "AudioContext",
+  "OfflineAudioCompletionEvent",
+  "AudioNode",
+  "AudioDestinationNode",
+  "AudioParam",
+  "GainNode",
+  "DelayNode",
+  "AudioBuffer",
+  "AudioBufferSourceNode",
+  "MediaElementAudioSourceNode",
+  "ScriptProcessorNode",
+  "AudioProcessingEvent",
+  "PannerNode",
+  "AudioListener",
+  "StereoPannerNode",
+  "ConvolverNode",
+  "AnalyserNode",
+  "ChannelSplitterNode",
+  "ChannelMergerNode",
+  "DynamicsCompressorNode",
+  "BiquadFilterNode",
+  "IIRFilterNode",
+  "WaveShaperNode",
+  "OscillatorNode",
+  "PeriodicWave",
+  "MediaStreamAudioSourceNode",
+  "MediaStreamAudioDestinationNode"
+];
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+  SpecialPowers.pushPrefEnv({"set": [["dom.webaudio.enabled", false]]}, function() {
+      webaudio_interfaces.forEach((e) => ok(!window[e], e + " must be disabled when the Web Audio API is disabled"));
+    SimpleTest.finish();
+  });
+});
+
+</script>
+</pre>
+</body>
+</html>
--- a/dom/messagechannel/MessagePortParent.cpp
+++ b/dom/messagechannel/MessagePortParent.cpp
@@ -128,17 +128,17 @@ MessagePortParent::RecvClose()
 
 void
 MessagePortParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   if (mService && mEntangled) {
     // When the last parent is deleted, this service is freed but this cannot
     // be done when the hashtables are written by CloseAll.
     RefPtr<MessagePortService> kungFuDeathGrip = mService;
-    mService->ParentDestroy(this);
+    kungFuDeathGrip->ParentDestroy(this);
   }
 }
 
 bool
 MessagePortParent::Entangled(const nsTArray<MessagePortMessage>& aMessages)
 {
   MOZ_ASSERT(!mEntangled);
   mEntangled = true;
--- a/dom/moz.build
+++ b/dom/moz.build
@@ -46,17 +46,16 @@ DIRS += [
     'battery',
     'browser-element',
     'cache',
     'canvas',
     'cellbroadcast',
     'contacts',
     'crypto',
     'phonenumberutils',
-    'alarm',
     'devicestorage',
     'encoding',
     'events',
     'fetch',
     'filehandle',
     'filesystem',
     'flyweb',
     'fmradio',
--- a/dom/network/UDPSocketParent.cpp
+++ b/dom/network/UDPSocketParent.cpp
@@ -276,19 +276,19 @@ static nsCOMPtr<nsIEventTarget> GetSTSTh
   sts_thread = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
   MOZ_ASSERT(NS_SUCCEEDED(rv));
 
   return sts_thread;
 }
 
 static void CheckSTSThread()
 {
-  nsCOMPtr<nsIEventTarget> sts_thread = GetSTSThread();
+  DebugOnly<nsCOMPtr<nsIEventTarget>> sts_thread = GetSTSThread();
 
-  ASSERT_ON_THREAD(sts_thread);
+  ASSERT_ON_THREAD(sts_thread.value);
 }
 
 
 // Proxy the Connect() request to the STS thread, since it may block and
 // should be done there.
 bool
 UDPSocketParent::RecvConnect(const UDPAddressInfo& aAddressInfo)
 {
--- a/dom/notification/Notification.cpp
+++ b/dom/notification/Notification.cpp
@@ -2523,29 +2523,29 @@ NotificationWorkerHolder::Notify(Status 
     // closed, but there is no permission to show it so that the main thread
     // immediately drops the NotificationRef. In this case, this function blocks
     // on the main thread, but the main thread dispatches the control runnable,
     // invalidating mNotification.
     RefPtr<Notification> kungFuDeathGrip = mNotification;
 
     // Dispatched to main thread, blocks on closing the Notification.
     RefPtr<CloseNotificationRunnable> r =
-      new CloseNotificationRunnable(mNotification);
+      new CloseNotificationRunnable(kungFuDeathGrip);
     ErrorResult rv;
     r->Dispatch(rv);
     // XXXbz I'm told throwing and returning false from here is pointless (and
     // also that doing sync stuff from here is really weird), so I guess we just
     // suppress the exception on rv, if any.
     rv.SuppressException();
 
     // Only call ReleaseObject() to match the observer's NotificationRef
     // ownership (since CloseNotificationRunnable asked the observer to drop the
     // reference to the notification).
     if (r->HadObserver()) {
-      mNotification->ReleaseObject();
+      kungFuDeathGrip->ReleaseObject();
     }
 
     // From this point we cannot touch properties of this feature because
     // ReleaseObject() may have led to the notification going away and the
     // notification owns this feature!
   }
   return true;
 }
--- a/dom/permission/tests/mochitest.ini
+++ b/dom/permission/tests/mochitest.ini
@@ -1,16 +1,14 @@
 [DEFAULT]
 support-files =
   file_framework.js
   file_shim.html
   file_empty.html
 
-[test_alarms.html]
-skip-if = true
 [test_browser.html]
 skip-if = true
 [test_embed-apps.html]
 skip-if = true || e10s #Bug 931116, b2g desktop specific, initial triage ### Bug 1255339: blacklist because no more mozApps
 [test_idle.html]
 # skip-if = (toolkit == 'gonk' && debug) #debug-only failure
 skip-if = true
 [test_permission_basics.html]
deleted file mode 100644
--- a/dom/permission/tests/test_alarms.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=815105
--->
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 815105 </title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=815105">Mozilla Bug 815105 </a>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-<script type="application/javascript;version=1.8" src="file_framework.js"></script>
-<script type="application/javascript;version=1.8">
-var gData = [
-  {
-    perm: ["alarms"],
-    // AlarmsManager is not enabled on Android yet
-    // exception on accessing AlarmsManager
-    // See bug 863557
-    skip: ["Android"],
-    obj: "mozAlarms",
-    webidl: "AlarmsManager",
-    settings: [["dom.mozAlarms.enabled", true]],
-  },
-]
-</script>
-</pre>
-</body>
-</html>
-
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -313,20 +313,20 @@ nsresult nsNPAPIPluginInstance::Stop()
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
 nsNPAPIPluginInstance::GetDOMWindow()
 {
   if (!mOwner)
     return nullptr;
 
-  RefPtr<nsPluginInstanceOwner> deathGrip(mOwner);
+  RefPtr<nsPluginInstanceOwner> kungFuDeathGrip(mOwner);
 
   nsCOMPtr<nsIDocument> doc;
-  mOwner->GetDocument(getter_AddRefs(doc));
+  kungFuDeathGrip->GetDocument(getter_AddRefs(doc));
   if (!doc)
     return nullptr;
 
   RefPtr<nsPIDOMWindowOuter> window = doc->GetWindow();
 
   return window.forget();
 }
 
--- a/dom/smil/nsSMILAnimationController.cpp
+++ b/dom/smil/nsSMILAnimationController.cpp
@@ -419,19 +419,19 @@ nsSMILAnimationController::DoSample(bool
   }
 
   // return early if there are no active animations to avoid a style flush
   if (currentCompositorTable->Count() == 0) {
     mLastCompositorTable = nullptr;
     return;
   }
 
-  nsCOMPtr<nsIDocument> kungFuDeathGrip(mDocument);  // keeps 'this' alive too
+  nsCOMPtr<nsIDocument> document(mDocument);  // keeps 'this' alive too
   if (isStyleFlushNeeded) {
-    mDocument->FlushPendingNotifications(Flush_Style);
+    document->FlushPendingNotifications(Flush_Style);
   }
 
   // WARNING:
   // WARNING: the above flush may have destroyed the pres shell and/or
   // WARNING: frames and other layout related objects.
   // WARNING:
 
   // STEP 5: Compose currently-animated attributes.
--- a/dom/speakermanager/tests/test_speakermanager.html
+++ b/dom/speakermanager/tests/test_speakermanager.html
@@ -32,17 +32,17 @@
   }
 
   function startTests() {
     // Currently applicable only on FxOS
     if (navigator.userAgent.indexOf("Mobile") != -1 &&
         navigator.appVersion.indexOf("Android") == -1) {
       testObject();
     } else {
-      ok(true, "mozAlarms on Firefox OS only.");
+      ok(true, "MozSpeakerManager on Firefox OS only.");
       SimpleTest.finish();
     }
   }
 
   SimpleTest.waitForExplicitFinish();
   SpecialPowers.pushPermissions(
     [{ "type": "speaker-control", "allow": 1, "context": document }],
     startTests);
--- a/dom/svg/SVGScriptElement.cpp
+++ b/dom/svg/SVGScriptElement.cpp
@@ -149,18 +149,22 @@ SVGScriptElement::FreezeUriAsyncDefer()
     // need to be transfered when modifying
     nsAutoString src;
     if (mStringAttributes[HREF].IsExplicitlySet()) {
       mStringAttributes[HREF].GetAnimValue(src, this);
     } else {
       mStringAttributes[XLINK_HREF].GetAnimValue(src, this);
     }
 
-    nsCOMPtr<nsIURI> baseURI = GetBaseURI();
-    NS_NewURI(getter_AddRefs(mUri), src, nullptr, baseURI);
+    // Empty src should be treated as invalid URL.
+    if (!src.IsEmpty()) {
+      nsCOMPtr<nsIURI> baseURI = GetBaseURI();
+      NS_NewURI(getter_AddRefs(mUri), src, nullptr, baseURI);
+    }
+
     // At this point mUri will be null for invalid URLs.
     mExternal = true;
   }
 
   mFrozen = true;
 }
 
 //----------------------------------------------------------------------
deleted file mode 100644
--- a/dom/webidl/AlarmsManager.webidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * https://wiki.mozilla.org/WebAPI/AlarmAPI
- */
-
-[NavigatorProperty="mozAlarms",
- JSImplementation="@mozilla.org/alarmsManager;1",
- Pref="dom.mozAlarms.enabled",
- ChromeOnly]
-interface AlarmsManager {
-  DOMRequest getAll();
-  [UnsafeInPrerendering]
-  DOMRequest add(any date, DOMString respectTimezone, optional any data);
-  [UnsafeInPrerendering]
-  void remove(unsigned long id);
-};
--- a/dom/webidl/AnalyserNode.webidl
+++ b/dom/webidl/AnalyserNode.webidl
@@ -5,16 +5,17 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface AnalyserNode : AudioNode {
 
     // Real-time frequency-domain data
     void getFloatFrequencyData(Float32Array array);
     void getByteFrequencyData(Uint8Array array);
 
     // Real-time waveform data
     void getFloatTimeDomainData(Float32Array array);
--- a/dom/webidl/AudioBuffer.webidl
+++ b/dom/webidl/AudioBuffer.webidl
@@ -5,16 +5,17 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface AudioBuffer {
 
     readonly attribute float sampleRate;
     readonly attribute unsigned long length;
 
     // in seconds 
     readonly attribute double duration;
 
--- a/dom/webidl/AudioBufferSourceNode.webidl
+++ b/dom/webidl/AudioBufferSourceNode.webidl
@@ -5,16 +5,17 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface AudioBufferSourceNode : AudioNode {
 
     attribute AudioBuffer? buffer;
 
     readonly attribute AudioParam playbackRate;
     readonly attribute AudioParam detune;
 
     attribute boolean loop;
--- a/dom/webidl/AudioContext.webidl
+++ b/dom/webidl/AudioContext.webidl
@@ -19,17 +19,18 @@ enum AudioContextState {
     "closed"
 };
 
 dictionary PeriodicWaveConstraints {
   boolean disableNormalization = false;
 };
 
 [Constructor,
- Constructor(AudioChannel audioChannelType)]
+ Constructor(AudioChannel audioChannelType),
+ Pref="dom.webaudio.enabled"]
 interface AudioContext : EventTarget {
 
     readonly attribute AudioDestinationNode destination;
     readonly attribute float sampleRate;
     readonly attribute double currentTime;
     readonly attribute AudioListener listener;
     readonly attribute AudioContextState state;
     [Throws]
--- a/dom/webidl/AudioDestinationNode.webidl
+++ b/dom/webidl/AudioDestinationNode.webidl
@@ -5,14 +5,15 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface AudioDestinationNode : AudioNode {
 
     readonly attribute unsigned long maxChannelCount;
 
 };
 
--- a/dom/webidl/AudioListener.webidl
+++ b/dom/webidl/AudioListener.webidl
@@ -5,16 +5,17 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface AudioListener {
 
     // same as OpenAL (default 1)
     [Deprecated="PannerNodeDoppler"]
     attribute double dopplerFactor;
 
     // in meters / second (default 343.3)
     [Deprecated="PannerNodeDoppler"]
--- a/dom/webidl/AudioNode.webidl
+++ b/dom/webidl/AudioNode.webidl
@@ -16,16 +16,17 @@ enum ChannelCountMode {
     "explicit"
 };
 
 enum ChannelInterpretation {
     "speakers",
     "discrete"
 };
 
+[Pref="dom.webaudio.enabled"]
 interface AudioNode : EventTarget {
 
     [Throws]
     AudioNode connect(AudioNode destination, optional unsigned long output = 0, optional unsigned long input = 0);
     [Throws]
     void connect(AudioParam destination, optional unsigned long output = 0);
     [Throws]
     void disconnect(optional unsigned long output = 0);
--- a/dom/webidl/AudioParam.webidl
+++ b/dom/webidl/AudioParam.webidl
@@ -5,16 +5,17 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface AudioParam {
 
     attribute float value;
     readonly attribute float defaultValue;
 
     // Parameter automation. 
     [Throws]
     AudioParam setValueAtTime(float value, double startTime);
--- a/dom/webidl/AudioProcessingEvent.webidl
+++ b/dom/webidl/AudioProcessingEvent.webidl
@@ -5,16 +5,17 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface AudioProcessingEvent : Event {
 
   readonly attribute double playbackTime;
 
   [Throws]
   readonly attribute AudioBuffer inputBuffer;
   [Throws]
   readonly attribute AudioBuffer outputBuffer;
--- a/dom/webidl/BiquadFilterNode.webidl
+++ b/dom/webidl/BiquadFilterNode.webidl
@@ -16,16 +16,17 @@ enum BiquadFilterType {
   "bandpass",
   "lowshelf",
   "highshelf",
   "peaking",
   "notch",
   "allpass"
 };
 
+[Pref="dom.webaudio.enabled"]
 interface BiquadFilterNode : AudioNode {
 
     attribute BiquadFilterType type;
     readonly attribute AudioParam frequency; // in Hertz
     readonly attribute AudioParam detune; // in Cents
     readonly attribute AudioParam Q; // Quality factor
     readonly attribute AudioParam gain; // in Decibels
 
--- a/dom/webidl/ChannelMergerNode.webidl
+++ b/dom/webidl/ChannelMergerNode.webidl
@@ -5,12 +5,13 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface ChannelMergerNode : AudioNode {
 
 };
 
--- a/dom/webidl/ChannelSplitterNode.webidl
+++ b/dom/webidl/ChannelSplitterNode.webidl
@@ -5,12 +5,13 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface ChannelSplitterNode : AudioNode {
 
 };
 
--- a/dom/webidl/ConvolverNode.webidl
+++ b/dom/webidl/ConvolverNode.webidl
@@ -5,16 +5,17 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface ConvolverNode : AudioNode {
 
       [SetterThrows]
       attribute AudioBuffer? buffer;
       attribute boolean normalize;
 
 };
 
--- a/dom/webidl/DelayNode.webidl
+++ b/dom/webidl/DelayNode.webidl
@@ -5,16 +5,17 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface DelayNode : AudioNode {
 
     readonly attribute AudioParam delayTime;
 
 };
 
 // Mozilla extension
 DelayNode implements AudioNodePassThrough;
--- a/dom/webidl/DynamicsCompressorNode.webidl
+++ b/dom/webidl/DynamicsCompressorNode.webidl
@@ -5,16 +5,17 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface DynamicsCompressorNode : AudioNode {
 
     readonly attribute AudioParam threshold; // in Decibels
     readonly attribute AudioParam knee; // in Decibels
     readonly attribute AudioParam ratio; // unit-less
     readonly attribute float reduction; // in Decibels
     readonly attribute AudioParam attack; // in Seconds
     readonly attribute AudioParam release; // in Seconds
--- a/dom/webidl/GainNode.webidl
+++ b/dom/webidl/GainNode.webidl
@@ -5,16 +5,17 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface GainNode : AudioNode {
 
     readonly attribute AudioParam gain;
 
 };
 
 // Mozilla extension
 GainNode implements AudioNodePassThrough;
--- a/dom/webidl/IIRFilterNode.webidl
+++ b/dom/webidl/IIRFilterNode.webidl
@@ -4,14 +4,15 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * The origin of this IDL file is https://www.w3.org/TR/webaudio
  *
  * Copyright © 2016 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface IIRFilterNode : AudioNode {
     void getFrequencyResponse(Float32Array frequencyHz, Float32Array magResponse, Float32Array phaseResponse);
 };
 
 // Mozilla extension
 IIRFilterNode implements AudioNodePassThrough;
--- a/dom/webidl/MediaElementAudioSourceNode.webidl
+++ b/dom/webidl/MediaElementAudioSourceNode.webidl
@@ -5,15 +5,16 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface MediaElementAudioSourceNode : AudioNode {
 
 };
 
 // Mozilla extensions
 MediaElementAudioSourceNode implements AudioNodePassThrough;
 
--- a/dom/webidl/MediaStreamAudioDestinationNode.webidl
+++ b/dom/webidl/MediaStreamAudioDestinationNode.webidl
@@ -5,13 +5,14 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface MediaStreamAudioDestinationNode : AudioNode {
 
     readonly attribute MediaStream stream;
 
 };
--- a/dom/webidl/MediaStreamAudioSourceNode.webidl
+++ b/dom/webidl/MediaStreamAudioSourceNode.webidl
@@ -5,15 +5,16 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface MediaStreamAudioSourceNode : AudioNode {
 
 };
 
 // Mozilla extensions
 MediaStreamAudioSourceNode implements AudioNodePassThrough;
 
--- a/dom/webidl/OfflineAudioCompletionEvent.webidl
+++ b/dom/webidl/OfflineAudioCompletionEvent.webidl
@@ -5,14 +5,15 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface OfflineAudioCompletionEvent : Event {
 
     readonly attribute AudioBuffer renderedBuffer;
 
 };
 
--- a/dom/webidl/OfflineAudioContext.webidl
+++ b/dom/webidl/OfflineAudioContext.webidl
@@ -5,17 +5,18 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
-[Constructor(unsigned long numberOfChannels, unsigned long length, float sampleRate)]
+[Constructor(unsigned long numberOfChannels, unsigned long length, float sampleRate),
+Pref="dom.webaudio.enabled"]
 interface OfflineAudioContext : AudioContext {
 
     [Throws]
     Promise<AudioBuffer> startRendering();
 
     attribute EventHandler oncomplete;
     readonly attribute unsigned long length;
 
--- a/dom/webidl/OscillatorNode.webidl
+++ b/dom/webidl/OscillatorNode.webidl
@@ -13,16 +13,17 @@
 enum OscillatorType {
   "sine",
   "square",
   "sawtooth",
   "triangle",
   "custom"
 };
 
+[Pref="dom.webaudio.enabled"]
 interface OscillatorNode : AudioNode {
 
     [SetterThrows]
     attribute OscillatorType type;
 
     readonly attribute AudioParam frequency; // in Hertz
     readonly attribute AudioParam detune; // in Cents
 
--- a/dom/webidl/PannerNode.webidl
+++ b/dom/webidl/PannerNode.webidl
@@ -16,16 +16,17 @@ enum PanningModelType {
 };
 
 enum DistanceModelType {
   "linear",
   "inverse",
   "exponential"
 };
 
+[Pref="dom.webaudio.enabled"]
 interface PannerNode : AudioNode {
 
     // Default for stereo is equalpower
     attribute PanningModelType panningModel;
 
     // Uses a 3D cartesian coordinate system
     void setPosition(double x, double y, double z);
     void setOrientation(double x, double y, double z);
--- a/dom/webidl/PeriodicWave.webidl
+++ b/dom/webidl/PeriodicWave.webidl
@@ -5,12 +5,13 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface PeriodicWave {
 
 };
 
--- a/dom/webidl/ScriptProcessorNode.webidl
+++ b/dom/webidl/ScriptProcessorNode.webidl
@@ -5,16 +5,17 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface ScriptProcessorNode : AudioNode {
 
     attribute EventHandler onaudioprocess;
 
     readonly attribute long bufferSize;
 
 };
 
--- a/dom/webidl/StereoPannerNode.webidl
+++ b/dom/webidl/StereoPannerNode.webidl
@@ -5,15 +5,16 @@
  *
  * The origin of this IDL file is
  * https://webaudio.github.io/web-audio-api/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
+[Pref="dom.webaudio.enabled"]
 interface StereoPannerNode : AudioNode {
   readonly attribute AudioParam pan;
 };
 
 // Mozilla extension
 StereoPannerNode implements AudioNodePassThrough;
 
--- a/dom/webidl/WaveShaperNode.webidl
+++ b/dom/webidl/WaveShaperNode.webidl
@@ -11,16 +11,17 @@
  */
 
 enum OverSampleType {
   "none",
   "2x",
   "4x"
 };
 
+[Pref="dom.webaudio.enabled"]
 interface WaveShaperNode : AudioNode {
 
       [SetterThrows]
       attribute Float32Array? curve;
       attribute OverSampleType oversample;
 
 };
 
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -916,17 +916,12 @@ if CONFIG['MOZ_B2G']:
         'Apps.webidl',
         'Identity.webidl',
         'MozApplicationEvent.webidl'
     ]
     GENERATED_EVENTS_WEBIDL_FILES += [
         'MozApplicationEvent.webidl'
     ]
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
-    WEBIDL_FILES += [
-        'AlarmsManager.webidl',
-    ]
-
 if CONFIG['ACCESSIBILITY']:
     WEBIDL_FILES += [
         'AccessibleNode.webidl',
     ]
--- a/dom/workers/WorkerNavigator.h
+++ b/dom/workers/WorkerNavigator.h
@@ -6,16 +6,17 @@
 
 #ifndef mozilla_dom_workernavigator_h__
 #define mozilla_dom_workernavigator_h__
 
 #include "Workers.h"
 #include "RuntimeService.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
+#include "mozilla/dom/StorageManager.h"
 
 namespace mozilla {
 namespace dom {
 class Promise;
 class StorageManager;
 
 class WorkerNavigator final : public nsWrapperCache
 {
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -2535,17 +2535,17 @@ WorkerPrivateParent<Derived>::Freeze(nsP
     bool allFrozen = false;
 
     for (uint32_t i = 0; i < mSharedWorkers.Length(); ++i) {
       if (aWindow && mSharedWorkers[i]->GetOwner() == aWindow) {
         // Calling Freeze() may change the refcount, ensure that the worker
         // outlives this call.
         RefPtr<SharedWorker> kungFuDeathGrip = mSharedWorkers[i];
 
-        mSharedWorkers[i]->Freeze();
+        kungFuDeathGrip->Freeze();
       } else {
         MOZ_ASSERT_IF(mSharedWorkers[i]->GetOwner() && aWindow,
                       !SameCOMIdentity(mSharedWorkers[i]->GetOwner(),
                                        aWindow));
         if (!mSharedWorkers[i]->IsFrozen()) {
           allFrozen = false;
         }
       }
@@ -2599,17 +2599,17 @@ WorkerPrivateParent<Derived>::Thaw(nsPID
     bool anyRunning = false;
 
     for (uint32_t i = 0; i < mSharedWorkers.Length(); ++i) {
       if (aWindow && mSharedWorkers[i]->GetOwner() == aWindow) {
         // Calling Thaw() may change the refcount, ensure that the worker
         // outlives this call.
         RefPtr<SharedWorker> kungFuDeathGrip = mSharedWorkers[i];
 
-        mSharedWorkers[i]->Thaw();
+        kungFuDeathGrip->Thaw();
         anyRunning = true;
       } else {
         MOZ_ASSERT_IF(mSharedWorkers[i]->GetOwner() && aWindow,
                       !SameCOMIdentity(mSharedWorkers[i]->GetOwner(),
                                        aWindow));
         if (!mSharedWorkers[i]->IsFrozen()) {
           anyRunning = true;
         }
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -3948,9 +3948,9 @@ RequestHeaders::CharsetIterator::Next()
   }
 
   mCutoff = start;
 
   return true;
 }
 
 } // dom namespace
-} // mozilla namespaceo
+} // mozilla namespace
--- a/editor/libeditor/EditorEventListener.cpp
+++ b/editor/libeditor/EditorEventListener.cpp
@@ -349,16 +349,17 @@ EditorEventListener::EditorHasFocus()
 NS_IMPL_ISUPPORTS(EditorEventListener, nsIDOMEventListener)
 
 NS_IMETHODIMP
 EditorEventListener::HandleEvent(nsIDOMEvent* aEvent)
 {
   NS_ENSURE_TRUE(mEditorBase, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIEditor> kungFuDeathGrip = mEditorBase;
+  Unused << kungFuDeathGrip; // mEditorBase is not referred to in this function
 
   WidgetEvent* internalEvent = aEvent->WidgetEventPtr();
 
   // Let's handle each event with the message of the internal event of the
   // coming event.  If the DOM event was created with improper interface,
   // e.g., keydown event is created with |new MouseEvent("keydown", {});|,
   // its message is always 0.  Therefore, we can ban such strange event easy.
   // However, we need to handle strange "focus" and "blur" event.  See the
--- a/editor/libeditor/HTMLAbsPositionEditor.cpp
+++ b/editor/libeditor/HTMLAbsPositionEditor.cpp
@@ -65,22 +65,22 @@ HTMLEditor::AbsolutePositionSelection(bo
   // Find out if the selection is collapsed:
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   TextRulesInfo ruleInfo(aEnabled ? EditAction::setAbsolutePosition :
                                     EditAction::removeAbsolutePosition);
   bool cancel, handled;
   // Protect the edit rules object from dying
-  nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
-  nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  nsCOMPtr<nsIEditRules> rules(mRules);
+  nsresult res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   if (NS_FAILED(res) || cancel)
     return res;
 
-  return mRules->DidDoAction(selection, &ruleInfo, res);
+  return rules->DidDoAction(selection, &ruleInfo, res);
 }
 
 NS_IMETHODIMP
 HTMLEditor::GetAbsolutelyPositionedSelectionContainer(nsIDOMElement** _retval)
 {
   nsAutoString positionStr;
   nsCOMPtr<nsINode> node = GetSelectionContainer();
   nsCOMPtr<nsIDOMNode> resultNode;
@@ -171,22 +171,22 @@ HTMLEditor::RelativeChangeZIndex(int32_t
   // brade: can we get rid of this comment?
   // Find out if the selection is collapsed:
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
   TextRulesInfo ruleInfo(aChange < 0 ? EditAction::decreaseZIndex :
                                        EditAction::increaseZIndex);
   bool cancel, handled;
   // Protect the edit rules object from dying
-  nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
-  nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  nsCOMPtr<nsIEditRules> rules(mRules);
+  nsresult res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   if (cancel || NS_FAILED(res))
     return res;
 
-  return mRules->DidDoAction(selection, &ruleInfo, res);
+  return rules->DidDoAction(selection, &ruleInfo, res);
 }
 
 NS_IMETHODIMP
 HTMLEditor::GetElementZIndex(nsIDOMElement* aElement,
                              int32_t* aZindex)
 {
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   NS_ENSURE_STATE(element || !aElement);
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -292,45 +292,45 @@ NS_IMETHODIMP
 HTMLEditRules::BeforeEdit(EditAction action,
                           nsIEditor::EDirection aDirection)
 {
   if (mLockRulesSniffing) {
     return NS_OK;
   }
 
   NS_ENSURE_STATE(mHTMLEditor);
-  nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
+  RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
 
   AutoLockRulesSniffing lockIt(this);
   mDidExplicitlySetInterline = false;
 
   if (!mActionNesting) {
     mActionNesting++;
 
     // Clear our flag about if just deleted a range
     mDidRangedDelete = false;
 
     // Remember where our selection was before edit action took place:
 
     // Get selection
-    RefPtr<Selection> selection = mHTMLEditor->GetSelection();
+    RefPtr<Selection> selection = htmlEditor->GetSelection();
 
     // Get the selection location
     if (!selection->RangeCount()) {
       return NS_ERROR_UNEXPECTED;
     }
     mRangeItem->startNode = selection->GetRangeAt(0)->GetStartParent();
     mRangeItem->startOffset = selection->GetRangeAt(0)->StartOffset();
     mRangeItem->endNode = selection->GetRangeAt(0)->GetEndParent();
     mRangeItem->endOffset = selection->GetRangeAt(0)->EndOffset();
     nsCOMPtr<nsINode> selStartNode = mRangeItem->startNode;
     nsCOMPtr<nsINode> selEndNode = mRangeItem->endNode;
 
     // Register with range updater to track this as we perturb the doc
-    (mHTMLEditor->mRangeUpdater).RegisterRangeItem(mRangeItem);
+    htmlEditor->mRangeUpdater.RegisterRangeItem(mRangeItem);
 
     // Clear deletion state bool
     mDidDeleteSelection = false;
 
     // Clear out mDocChangeRange and mUtilRange
     if (mDocChangeRange) {
       // Clear out our accounting of what changed
       mDocChangeRange->Reset();
@@ -347,17 +347,17 @@ HTMLEditRules::BeforeEdit(EditAction act
         IsStyleCachePreservingAction(action)) {
       nsCOMPtr<nsINode> selNode =
         aDirection == nsIEditor::eNext ? selEndNode : selStartNode;
       nsresult rv = CacheInlineStyles(GetAsDOMNode(selNode));
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     // Stabilize the document against contenteditable count changes
-    nsCOMPtr<nsIDOMDocument> doc = mHTMLEditor->GetDOMDocument();
+    nsCOMPtr<nsIDOMDocument> doc = htmlEditor->GetDOMDocument();
     NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
     nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(doc);
     NS_ENSURE_TRUE(htmlDoc, NS_ERROR_FAILURE);
     if (htmlDoc->GetEditingState() == nsIHTMLDocument::eContentEditable) {
       htmlDoc->ChangeContentEditableCount(nullptr, +1);
       mRestoreContentEditableCount = true;
     }
 
@@ -374,33 +374,33 @@ NS_IMETHODIMP
 HTMLEditRules::AfterEdit(EditAction action,
                          nsIEditor::EDirection aDirection)
 {
   if (mLockRulesSniffing) {
     return NS_OK;
   }
 
   NS_ENSURE_STATE(mHTMLEditor);
-  nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
+  RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
 
   AutoLockRulesSniffing lockIt(this);
 
   MOZ_ASSERT(mActionNesting > 0);
   nsresult rv = NS_OK;
   mActionNesting--;
   if (!mActionNesting) {
     // Do all the tricky stuff
     rv = AfterEditInner(action, aDirection);
 
     // Free up selectionState range item
-    (mHTMLEditor->mRangeUpdater).DropRangeItem(mRangeItem);
+    htmlEditor->mRangeUpdater.DropRangeItem(mRangeItem);
 
     // Reset the contenteditable count to its previous value
     if (mRestoreContentEditableCount) {
-      nsCOMPtr<nsIDOMDocument> doc = mHTMLEditor->GetDOMDocument();
+      nsCOMPtr<nsIDOMDocument> doc = htmlEditor->GetDOMDocument();
       NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
       nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(doc);
       NS_ENSURE_TRUE(htmlDoc, NS_ERROR_FAILURE);
       if (htmlDoc->GetEditingState() == nsIHTMLDocument::eContentEditable) {
         htmlDoc->ChangeContentEditableCount(nullptr, -1);
       }
       mRestoreContentEditableCount = false;
     }
@@ -784,37 +784,37 @@ HTMLEditRules::GetListItemState(bool* aM
 
 nsresult
 HTMLEditRules::GetAlignment(bool* aMixed,
                             nsIHTMLEditor::EAlignment* aAlign)
 {
   MOZ_ASSERT(aMixed && aAlign);
 
   NS_ENSURE_STATE(mHTMLEditor);
-  nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
+  RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
 
   // For now, just return first alignment.  We'll lie about if it's mixed.
   // This is for efficiency given that our current ui doesn't care if it's
   // mixed.
   // cmanske: NOT TRUE! We would like to pay attention to mixed state in Format
   // | Align submenu!
 
   // This routine assumes that alignment is done ONLY via divs
 
   // Default alignment is left
   *aMixed = false;
   *aAlign = nsIHTMLEditor::eLeft;
 
   // Get selection
-  NS_ENSURE_STATE(mHTMLEditor->GetSelection());
-  OwningNonNull<Selection> selection = *mHTMLEditor->GetSelection();
+  NS_ENSURE_STATE(htmlEditor->GetSelection());
+  OwningNonNull<Selection> selection = *htmlEditor->GetSelection();
 
   // Get selection location
-  NS_ENSURE_TRUE(mHTMLEditor->GetRoot(), NS_ERROR_FAILURE);
-  OwningNonNull<Element> root = *mHTMLEditor->GetRoot();
+  NS_ENSURE_TRUE(htmlEditor->GetRoot(), NS_ERROR_FAILURE);
+  OwningNonNull<Element> root = *htmlEditor->GetRoot();
 
   int32_t rootOffset = root->GetParentNode() ?
                        root->GetParentNode()->IndexOf(root) : -1;
 
   NS_ENSURE_STATE(selection->GetRangeAt(0) &&
                   selection->GetRangeAt(0)->GetStartParent());
   OwningNonNull<nsINode> parent = *selection->GetRangeAt(0)->GetStartParent();
   int32_t offset = selection->GetRangeAt(0)->StartOffset();
@@ -823,43 +823,43 @@ HTMLEditRules::GetAlignment(bool* aMixed
   nsCOMPtr<nsINode> nodeToExamine;
   if (selection->Collapsed() || parent->GetAsText()) {
     // If selection is collapsed, we want to look at 'parent' and its ancestors
     // for divs with alignment on them.  If we are in a text node, then that is
     // the node of interest.
     nodeToExamine = parent;
   } else if (parent->IsHTMLElement(nsGkAtoms::html) && offset == rootOffset) {
     // If we have selected the body, let's look at the first editable node
-    nodeToExamine = mHTMLEditor->GetNextNode(parent, offset, true);
+    nodeToExamine = htmlEditor->GetNextNode(parent, offset, true);
   } else {
     nsTArray<RefPtr<nsRange>> arrayOfRanges;
     GetPromotedRanges(selection, arrayOfRanges, EditAction::align);
 
     // Use these ranges to construct a list of nodes to act on.
     nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
     nsresult rv = GetNodesForOperation(arrayOfRanges, arrayOfNodes,
                                        EditAction::align, TouchContent::no);
     NS_ENSURE_SUCCESS(rv, rv);
     nodeToExamine = arrayOfNodes.SafeElementAt(0);
   }
 
   NS_ENSURE_TRUE(nodeToExamine, NS_ERROR_NULL_POINTER);
 
   NS_NAMED_LITERAL_STRING(typeAttrName, "align");
-  nsCOMPtr<Element> blockParent = mHTMLEditor->GetBlock(*nodeToExamine);
+  nsCOMPtr<Element> blockParent = htmlEditor->GetBlock(*nodeToExamine);
 
   NS_ENSURE_TRUE(blockParent, NS_ERROR_FAILURE);
 
-  if (mHTMLEditor->IsCSSEnabled() &&
-      mHTMLEditor->mCSSEditUtils->IsCSSEditableProperty(blockParent, nullptr,
+  if (htmlEditor->IsCSSEnabled() &&
+      htmlEditor->mCSSEditUtils->IsCSSEditableProperty(blockParent, nullptr,
                                                         &typeAttrName)) {
     // We are in CSS mode and we know how to align this element with CSS
     nsAutoString value;
     // Let's get the value(s) of text-align or margin-left/margin-right
-    mHTMLEditor->mCSSEditUtils->GetCSSEquivalentToHTMLInlineStyleSet(
+    htmlEditor->mCSSEditUtils->GetCSSEquivalentToHTMLInlineStyleSet(
         blockParent, nullptr, &typeAttrName, value, CSSEditUtils::eComputed);
     if (value.EqualsLiteral("center") ||
         value.EqualsLiteral("-moz-center") ||
         value.EqualsLiteral("auto auto")) {
       *aAlign = nsIHTMLEditor::eCenter;
       return NS_OK;
     }
     if (value.EqualsLiteral("right") ||
@@ -1167,17 +1167,17 @@ void
 HTMLEditRules::WillInsert(Selection& aSelection,
                           bool* aCancel)
 {
   MOZ_ASSERT(aCancel);
 
   TextEditRules::WillInsert(aSelection, aCancel);
 
   NS_ENSURE_TRUE_VOID(mHTMLEditor);
-  nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
+  RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
 
   // Adjust selection to prevent insertion after a moz-BR.  This next only
   // works for collapsed selections right now, because selection is a pain to
   // work with when not collapsed.  (no good way to extend start or end of
   // selection), so we ignore those types of selections.
   if (!aSelection.Collapsed()) {
     return;
   }
@@ -1185,21 +1185,21 @@ HTMLEditRules::WillInsert(Selection& aSe
   // If we are after a mozBR in the same block, then move selection to be
   // before it
   NS_ENSURE_TRUE_VOID(aSelection.GetRangeAt(0) &&
                       aSelection.GetRangeAt(0)->GetStartParent());
   OwningNonNull<nsINode> selNode = *aSelection.GetRangeAt(0)->GetStartParent();
   int32_t selOffset = aSelection.GetRangeAt(0)->StartOffset();
 
   // Get prior node
-  nsCOMPtr<nsIContent> priorNode = mHTMLEditor->GetPriorHTMLNode(selNode,
-                                                                 selOffset);
+  nsCOMPtr<nsIContent> priorNode = htmlEditor->GetPriorHTMLNode(selNode,
+                                                                selOffset);
   if (priorNode && TextEditUtils::IsMozBR(priorNode)) {
-    nsCOMPtr<Element> block1 = mHTMLEditor->GetBlock(selNode);
-    nsCOMPtr<Element> block2 = mHTMLEditor->GetBlockNodeParent(priorNode);
+    nsCOMPtr<Element> block1 = htmlEditor->GetBlock(selNode);
+    nsCOMPtr<Element> block2 = htmlEditor->GetBlockNodeParent(priorNode);
 
     if (block1 && block1 == block2) {
       // If we are here then the selection is right after a mozBR that is in
       // the same block as the selection.  We need to move the selection start
       // to be before the mozBR.
       selNode = priorNode->GetParentNode();
       selOffset = selNode->IndexOf(priorNode);
       nsresult res = aSelection.Collapse(selNode, selOffset);
@@ -1476,22 +1476,22 @@ HTMLEditRules::WillInsertBreak(Selection
                                bool* aCancel,
                                bool* aHandled)
 {
   MOZ_ASSERT(aCancel && aHandled);
   *aCancel = false;
   *aHandled = false;
 
   NS_ENSURE_STATE(mHTMLEditor);
-  nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
+  RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
 
   // If the selection isn't collapsed, delete it.
   nsresult res;
   if (!aSelection.Collapsed()) {
-    res = mHTMLEditor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip);
+    res = htmlEditor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip);
     NS_ENSURE_SUCCESS(res, res);
   }
 
   WillInsert(aSelection, aCancel);
 
   // Initialize out param.  We want to ignore result of WillInsert().
   *aCancel = false;
 
@@ -1508,44 +1508,44 @@ HTMLEditRules::WillInsertBreak(Selection
   // Smart splitting rules
   NS_ENSURE_TRUE(aSelection.GetRangeAt(0) &&
                  aSelection.GetRangeAt(0)->GetStartParent(),
                  NS_ERROR_FAILURE);
   OwningNonNull<nsINode> node = *aSelection.GetRangeAt(0)->GetStartParent();
   int32_t offset = aSelection.GetRangeAt(0)->StartOffset();
 
   // Do nothing if the node is read-only
-  if (!mHTMLEditor->IsModifiableNode(node)) {
+  if (!htmlEditor->IsModifiableNode(node)) {
     *aCancel = true;
     return NS_OK;
   }
 
   // Identify the block
-  nsCOMPtr<Element> blockParent = mHTMLEditor->GetBlock(node);
+  nsCOMPtr<Element> blockParent = htmlEditor->GetBlock(node);
   NS_ENSURE_TRUE(blockParent, NS_ERROR_FAILURE);
 
   // If the active editing host is an inline element, or if the active editing
   // host is the block parent itself, just append a br.
-  nsCOMPtr<Element> host = mHTMLEditor->GetActiveEditingHost();
+  nsCOMPtr<Element> host = htmlEditor->GetActiveEditingHost();
   if (!EditorUtils::IsDescendantOf(blockParent, host)) {
     res = StandardBreakImpl(node, offset, aSelection);
     NS_ENSURE_SUCCESS(res, res);
     *aHandled = true;
     return NS_OK;
   }
 
   // If block is empty, populate with br.  (For example, imagine a div that
   // contains the word "text".  The user selects "text" and types return.
   // "Text" is deleted leaving an empty block.  We want to put in one br to
   // make block have a line.  Then code further below will put in a second br.)
   bool isEmpty;
   IsEmptyBlock(*blockParent, &isEmpty);
   if (isEmpty) {
-    nsCOMPtr<Element> br = mHTMLEditor->CreateBR(blockParent,
-                                                 blockParent->Length());
+    nsCOMPtr<Element> br = htmlEditor->CreateBR(blockParent,
+                                                blockParent->Length());
     NS_ENSURE_STATE(br);
   }
 
   nsCOMPtr<Element> listItem = IsInListItem(blockParent);
   if (listItem && listItem != host) {
     ReturnInListItem(aSelection, *listItem, node, offset);
     *aHandled = true;
     return NS_OK;
@@ -1571,51 +1571,51 @@ HTMLEditRules::WillInsertBreak(Selection
 }
 
 nsresult
 HTMLEditRules::StandardBreakImpl(nsINode& aNode,
                                  int32_t aOffset,
                                  Selection& aSelection)
 {
   NS_ENSURE_STATE(mHTMLEditor);
-  nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
+  RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
 
   nsCOMPtr<Element> brNode;
   bool bAfterBlock = false;
   bool bBeforeBlock = false;
   nsCOMPtr<nsINode> node = &aNode;
   nsresult res;
 
   if (IsPlaintextEditor()) {
-    brNode = mHTMLEditor->CreateBR(node, aOffset);
+    brNode = htmlEditor->CreateBR(node, aOffset);
     NS_ENSURE_STATE(brNode);
   } else {
-    WSRunObject wsObj(mHTMLEditor, node, aOffset);
+    WSRunObject wsObj(htmlEditor, node, aOffset);
     int32_t visOffset = 0;
     WSType wsType;
     nsCOMPtr<nsINode> visNode;
     wsObj.PriorVisibleNode(node, aOffset, address_of(visNode),
                            &visOffset, &wsType);
     if (wsType & WSType::block) {
       bAfterBlock = true;
     }
     wsObj.NextVisibleNode(node, aOffset, address_of(visNode),
                           &visOffset, &wsType);
     if (wsType & WSType::block) {
       bBeforeBlock = true;
     }
     nsCOMPtr<nsIDOMNode> linkDOMNode;
-    if (mHTMLEditor->IsInLink(GetAsDOMNode(node), address_of(linkDOMNode))) {
+    if (htmlEditor->IsInLink(GetAsDOMNode(node), address_of(linkDOMNode))) {
       // Split the link
       nsCOMPtr<Element> linkNode = do_QueryInterface(linkDOMNode);
       NS_ENSURE_STATE(linkNode || !linkDOMNode);
       nsCOMPtr<nsINode> linkParent = linkNode->GetParentNode();
-      aOffset = mHTMLEditor->SplitNodeDeep(*linkNode, *node->AsContent(),
-                                           aOffset,
-                                           HTMLEditor::EmptyContainers::no);
+      aOffset = htmlEditor->SplitNodeDeep(*linkNode, *node->AsContent(),
+                                          aOffset,
+                                          HTMLEditor::EmptyContainers::no);
       NS_ENSURE_STATE(aOffset != -1);
       node = linkParent;
     }
     brNode = wsObj.InsertBreak(address_of(node), &aOffset, nsIEditor::eNone);
     NS_ENSURE_TRUE(brNode, NS_ERROR_FAILURE);
   }
   node = brNode->GetParentNode();
   NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
@@ -1623,33 +1623,33 @@ HTMLEditRules::StandardBreakImpl(nsINode
   if (bAfterBlock && bBeforeBlock) {
     // We just placed a br between block boundaries.  This is the one case
     // where we want the selection to be before the br we just placed, as the
     // br will be on a new line, rather than at end of prior line.
     aSelection.SetInterlinePosition(true);
     res = aSelection.Collapse(node, offset);
     NS_ENSURE_SUCCESS(res, res);
   } else {
-    WSRunObject wsObj(mHTMLEditor, node, offset + 1);
+    WSRunObject wsObj(htmlEditor, node, offset + 1);
     nsCOMPtr<nsINode> secondBR;
     int32_t visOffset = 0;
     WSType wsType;
     wsObj.NextVisibleNode(node, offset + 1, address_of(secondBR),
                           &visOffset, &wsType);
     if (wsType == WSType::br) {
       // The next thing after the break we inserted is another break.  Move the
       // second break to be the first break's sibling.  This will prevent them
       // from being in different inline nodes, which would break
       // SetInterlinePosition().  It will also assure that if the user clicks
       // away and then clicks back on their new blank line, they will still get
       // the style from the line above.
       nsCOMPtr<nsINode> brParent = secondBR->GetParentNode();
       int32_t brOffset = brParent ? brParent->IndexOf(secondBR) : -1;
       if (brParent != node || brOffset != offset + 1) {
-        res = mHTMLEditor->MoveNode(secondBR->AsContent(), node, offset + 1);
+        res = htmlEditor->MoveNode(secondBR->AsContent(), node, offset + 1);
         NS_ENSURE_SUCCESS(res, res);
       }
     }
     // SetInterlinePosition(true) means we want the caret to stick to the
     // content on the "right".  We want the caret to stick to whatever is past
     // the break.  This is because the break is on the same line we were on,
     // but the next content will be on the following line.
 
@@ -2528,39 +2528,39 @@ HTMLEditRules::GetGoodSelPointForNode(ns
 nsresult
 HTMLEditRules::JoinBlocks(nsIContent& aLeftNode,
                           nsIContent& aRightNode,
                           bool* aCanceled)
 {
   MOZ_ASSERT(aCanceled);
 
   NS_ENSURE_STATE(mHTMLEditor);
-  nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
-
-  nsCOMPtr<Element> leftBlock = mHTMLEditor->GetBlock(aLeftNode);
-  nsCOMPtr<Element> rightBlock = mHTMLEditor->GetBlock(aRightNode);
+  RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
+
+  nsCOMPtr<Element> leftBlock = htmlEditor->GetBlock(aLeftNode);
+  nsCOMPtr<Element> rightBlock = htmlEditor->GetBlock(aRightNode);
 
   // Sanity checks
   NS_ENSURE_TRUE(leftBlock && rightBlock, NS_ERROR_NULL_POINTER);
   NS_ENSURE_STATE(leftBlock != rightBlock);
 
   if (HTMLEditUtils::IsTableElement(leftBlock) ||
       HTMLEditUtils::IsTableElement(rightBlock)) {
     // Do not try to merge table elements
     *aCanceled = true;
     return NS_OK;
   }
 
   // Make sure we don't try to move things into HR's, which look like blocks
   // but aren't containers
   if (leftBlock->IsHTMLElement(nsGkAtoms::hr)) {
-    leftBlock = mHTMLEditor->GetBlockNodeParent(leftBlock);
+    leftBlock = htmlEditor->GetBlockNodeParent(leftBlock);
   }
   if (rightBlock->IsHTMLElement(nsGkAtoms::hr)) {
-    rightBlock = mHTMLEditor->GetBlockNodeParent(rightBlock);
+    rightBlock = htmlEditor->GetBlockNodeParent(rightBlock);
   }
   NS_ENSURE_STATE(leftBlock && rightBlock);
 
   // Bail if both blocks the same
   if (leftBlock == rightBlock) {
     *aCanceled = true;
     return NS_OK;
   }
@@ -2591,39 +2591,39 @@ HTMLEditRules::JoinBlocks(nsIContent& aL
       // sublists in our implementation.
       leftBlock = leftList;
       rightBlock = rightList;
       mergeLists = true;
       existingList = leftList->NodeInfo()->NameAtom();
     }
   }
 
-  AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor);
+  AutoTransactionsConserveSelection dontSpazMySelection(htmlEditor);
 
   nsresult res = NS_OK;
   int32_t rightOffset = 0;
   int32_t leftOffset = -1;
 
   // offset below is where you find yourself in rightBlock when you traverse
   // upwards from leftBlock
   if (EditorUtils::IsDescendantOf(leftBlock, rightBlock, &rightOffset)) {
     // Tricky case.  Left block is inside right block.  Do ws adjustment.  This
     // just destroys non-visible ws at boundaries we will be joining.
     rightOffset++;
-    res = WSRunObject::ScrubBlockBoundary(mHTMLEditor,
+    res = WSRunObject::ScrubBlockBoundary(htmlEditor,
                                           WSRunObject::kBlockEnd,
                                           leftBlock);
     NS_ENSURE_SUCCESS(res, res);
 
     {
       // We can't just track rightBlock because it's an Element.
       nsCOMPtr<nsINode> trackingRightBlock(rightBlock);
-      AutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater,
+      AutoTrackDOMPoint tracker(htmlEditor->mRangeUpdater,
                                 address_of(trackingRightBlock), &rightOffset);
-      res = WSRunObject::ScrubBlockBoundary(mHTMLEditor,
+      res = WSRunObject::ScrubBlockBoundary(htmlEditor,
                                             WSRunObject::kAfterBlock,
                                             rightBlock, rightOffset);
       NS_ENSURE_SUCCESS(res, res);
       if (trackingRightBlock->IsElement()) {
         rightBlock = trackingRightBlock->AsElement();
       } else {
         NS_ENSURE_STATE(trackingRightBlock->GetParentElement());
         rightBlock = trackingRightBlock->GetParentElement();
@@ -2632,41 +2632,41 @@ HTMLEditRules::JoinBlocks(nsIContent& aL
     // Do br adjustment.
     nsCOMPtr<Element> brNode =
       CheckForInvisibleBR(*leftBlock, BRLocation::blockEnd);
     if (mergeLists) {
       // The idea here is to take all children in rightList that are past
       // offset, and pull them into leftlist.
       for (nsCOMPtr<nsIContent> child = rightList->GetChildAt(offset);
            child; child = rightList->GetChildAt(rightOffset)) {
-        res = mHTMLEditor->MoveNode(child, leftList, -1);
+        res = htmlEditor->MoveNode(child, leftList, -1);
         NS_ENSURE_SUCCESS(res, res);
       }
     } else {
       res = MoveBlock(*leftBlock, *rightBlock, leftOffset, rightOffset);
     }
     if (brNode) {
-      mHTMLEditor->DeleteNode(brNode);
+      htmlEditor->DeleteNode(brNode);
     }
   // Offset below is where you find yourself in leftBlock when you traverse
   // upwards from rightBlock
   } else if (EditorUtils::IsDescendantOf(rightBlock, leftBlock, &leftOffset)) {
     // Tricky case.  Right block is inside left block.  Do ws adjustment.  This
     // just destroys non-visible ws at boundaries we will be joining.
-    res = WSRunObject::ScrubBlockBoundary(mHTMLEditor,
+    res = WSRunObject::ScrubBlockBoundary(htmlEditor,
                                           WSRunObject::kBlockStart,
                                           rightBlock);
     NS_ENSURE_SUCCESS(res, res);
     {
       // We can't just track leftBlock because it's an Element, so track
       // something else.
       nsCOMPtr<nsINode> trackingLeftBlock(leftBlock);
-      AutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater,
+      AutoTrackDOMPoint tracker(htmlEditor->mRangeUpdater,
                                 address_of(trackingLeftBlock), &leftOffset);
-      res = WSRunObject::ScrubBlockBoundary(mHTMLEditor,
+      res = WSRunObject::ScrubBlockBoundary(htmlEditor,
                                             WSRunObject::kBeforeBlock,
                                             leftBlock, leftOffset);
       NS_ENSURE_SUCCESS(res, res);
       if (trackingLeftBlock->IsElement()) {
         leftBlock = trackingLeftBlock->AsElement();
       } else {
         NS_ENSURE_STATE(trackingLeftBlock->GetParentElement());
         leftBlock = trackingLeftBlock->GetParentElement();
@@ -2708,49 +2708,49 @@ HTMLEditRules::JoinBlocks(nsIContent& aL
 
         // We want to move our content just after the previous visible node.
         previousContentOffset++;
       }
 
       // Because we don't want the moving content to receive the style of the
       // previous content, we split the previous content's style.
 
-      nsCOMPtr<Element> editorRoot = mHTMLEditor->GetEditorRoot();
+      nsCOMPtr<Element> editorRoot = htmlEditor->GetEditorRoot();
       if (!editorRoot || &aLeftNode != editorRoot) {
         nsCOMPtr<nsIContent> splittedPreviousContent;
-        res = mHTMLEditor->SplitStyleAbovePoint(address_of(previousContentParent),
-                                                &previousContentOffset,
-                                                nullptr, nullptr, nullptr,
-                                                getter_AddRefs(splittedPreviousContent));
+        res = htmlEditor->SplitStyleAbovePoint(address_of(previousContentParent),
+                                               &previousContentOffset,
+                                               nullptr, nullptr, nullptr,
+                                               getter_AddRefs(splittedPreviousContent));
         NS_ENSURE_SUCCESS(res, res);
 
         if (splittedPreviousContent) {
           previousContentParent = splittedPreviousContent->GetParentNode();
           previousContentOffset = previousContentParent ?
             previousContentParent->IndexOf(splittedPreviousContent) : -1;
         }
       }
 
       NS_ENSURE_TRUE(previousContentParent, NS_ERROR_NULL_POINTER);
 
       res = MoveBlock(*previousContentParent->AsElement(), *rightBlock,
           previousContentOffset, rightOffset);
       NS_ENSURE_SUCCESS(res, res);
     }
     if (brNode) {
-      mHTMLEditor->DeleteNode(brNode);
+      htmlEditor->DeleteNode(brNode);
     }
   } else {
     // Normal case.  Blocks are siblings, or at least close enough.  An example
     // of the latter is <p>paragraph</p><ul><li>one<li>two<li>three</ul>.  The
     // first li and the p are not true siblings, but we still want to join them
     // if you backspace from li into p.
 
     // Adjust whitespace at block boundaries
-    res = WSRunObject::PrepareToJoinBlocks(mHTMLEditor, leftBlock, rightBlock);