Merge m-c to fx-team, a=merge
authorWes Kocher <wkocher@mozilla.com>
Wed, 07 Sep 2016 18:08:34 -0700
changeset 313092 fb7c6b0343295392bac590c19b14e7e5dcccdc33
parent 312985 62bde80d230d3e1f52d1faaf3769dc5682905525 (current diff)
parent 313091 77940cbf0c2a9f52c209fbbde5b2e7d4c74a1501 (diff)
child 313093 ad1252b88e460a400583dc43720f0e540afccfdc
push id20479
push userkwierso@gmail.com
push dateThu, 08 Sep 2016 01:08:46 +0000
treeherderfx-team@fb7c6b034329 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone51.0a1
Merge m-c to fx-team, 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/permission/tests/test_alarms.html
dom/webidl/AlarmsManager.webidl
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/UnifiedComplete.manifest
--- 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/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -2,17 +2,16 @@
 /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 /* 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/. */
 
 window.performance.mark('gecko-shell-loadstart');
 
 Cu.import('resource://gre/modules/ContactService.jsm');
-Cu.import('resource://gre/modules/AlarmService.jsm');
 Cu.import('resource://gre/modules/NotificationDB.jsm');
 Cu.import("resource://gre/modules/AppsUtils.jsm");
 Cu.import('resource://gre/modules/UserAgentOverrides.jsm');
 Cu.import('resource://gre/modules/Keyboard.jsm');
 Cu.import('resource://gre/modules/ErrorPage.jsm');
 Cu.import('resource://gre/modules/AlertsHelper.jsm');
 Cu.import('resource://gre/modules/SystemUpdateService.jsm');
 
--- 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/extensions/schemas/history.json
+++ b/browser/components/extensions/schemas/history.json
@@ -86,29 +86,16 @@
             "type": "string",
             "description": "The visit ID of the referrer."
           },
           "transition": {
             "$ref": "TransitionType",
             "description": "The $(topic:transition-types)[transition type] for this visit from its referrer."
           }
         }
-      },
-      {
-        "id": "HistoryTime",
-        "description": "A time specified as a Date object, a number or string representing milliseconds since the epoch, or an ISO 8601 string",
-        "choices": [
-          {
-            "type": "string",
-            "pattern": "^[1-9]\\d*$"
-          },
-          {
-            "$ref": "extensionTypes.Date"
-          }
-        ]
       }
     ],
     "functions": [
       {
         "name": "search",
         "type": "function",
         "description": "Searches the history for the last visit time of each page matching the query.",
         "async": "callback",
@@ -117,22 +104,22 @@
             "name": "query",
             "type": "object",
             "properties": {
               "text": {
                 "type": "string",
                 "description": "A free-text query to the history service.  Leave empty to retrieve all pages."
               },
               "startTime": {
-                "$ref": "HistoryTime",
+                "$ref": "extensionTypes.Date",
                 "optional": true,
                 "description": "Limit results to those visited after this date. If not specified, this defaults to 24 hours in the past."
               },
               "endTime": {
-                "$ref": "HistoryTime",
+                "$ref": "extensionTypes.Date",
                 "optional": true,
                 "description": "Limit results to those visited before this date."
               },
               "maxResults": {
                 "type": "integer",
                 "optional": true,
                 "minimum": 1,
                 "description": "The maximum number of results to retrieve.  Defaults to 100."
@@ -205,17 +192,17 @@
                 "description": "The title of the page."
               },
               "transition": {
                 "$ref": "TransitionType",
                 "optional": true,
                 "description": "The $(topic:transition-types)[transition type] for this visit from its referrer."
               },
               "visitTime": {
-                "$ref": "HistoryTime",
+                "$ref": "extensionTypes.Date",
                 "optional": true,
                 "description": "The date when this visit occurred."
               }
             }
           },
           {
             "name": "callback",
             "type": "function",
@@ -254,21 +241,21 @@
         "description": "Removes all items within the specified date range from the history.  Pages will not be removed from the history unless all visits fall within the range.",
         "async": "callback",
         "parameters": [
           {
             "name": "range",
             "type": "object",
             "properties": {
               "startTime": {
-                "$ref": "HistoryTime",
+                "$ref": "extensionTypes.Date",
                 "description": "Items added to history after this date."
               },
               "endTime": {
-                "$ref": "HistoryTime",
+                "$ref": "extensionTypes.Date",
                 "description": "Items added to history before this date."
               }
             }
           },
           {
             "name": "callback",
             "type": "function",
             "parameters": []
--- a/browser/components/extensions/test/xpcshell/test_ext_history.js
+++ b/browser/components/extensions/test/xpcshell/test_ext_history.js
@@ -284,17 +284,16 @@ add_task(function* test_add_url() {
 
     browser.test.sendMessage("ready");
   }
 
   let addTestData = [
     [{}, "default"],
     [{visitTime: new Date()}, "with_date"],
     [{visitTime: Date.now()}, "with_ms_number"],
-    [{visitTime: Date.now().toString()}, "with_ms_string"],
     [{visitTime: new Date().toISOString()}, "with_iso_string"],
     [{transition: "typed"}, "valid_transition"],
   ];
 
   let failTestData = [
     [{transition: "generated"}, "an invalid transition", "|generated| is not a supported transition for history"],
     [{visitTime: Date.now() + 1000000}, "a future date", "cannot be a future date"],
     [{url: "about.config"}, "an invalid url", "about.config is not a valid URL"],
--- a/browser/components/migration/moz.build
+++ b/browser/components/migration/moz.build
@@ -1,16 +1,18 @@
 # -*- 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/.
 
 XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
 
+MARIONETTE_UNIT_MANIFESTS += ['tests/marionette/manifest.ini']
+
 JAR_MANIFESTS += ['jar.mn']
 
 XPIDL_SOURCES += [
     'nsIBrowserProfileMigrator.idl',
 ]
 
 XPIDL_MODULE = 'migration'
 
--- 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/build/sanitizers/lsan_suppressions.txt
+++ b/build/sanitizers/lsan_suppressions.txt
@@ -71,16 +71,20 @@ leak:nsPSPrinterList::GetPrinterList
 leak:_PR_Getfd
 
 # Bug 1028483 - The XML parser sometimes leaks an object. bc3
 leak:processInternalEntity
 
 # Bug 1187421 - With e10s, NSS does not always free the error stack. m1.
 leak:nss_ClearErrorStack
 
+# Bug 1189430 - DNS leaks in mochitest-chrome.
+leak:nsDNSService::AsyncResolveExtended
+leak:_GetAddrInfo_Portable
+
 # Bug 1189568 - Indirect leaks of IMContextWrapper and nsIntRect.
 leak:nsWindow::Create
 leak:nsBaseWidget::StoreWindowClipRegion
 
 
 ###
 ### Leaks with system libraries in their stacks. These show up across a number of tests.
 ### Better symbols and disabling fast stackwalking may help diagnose these.
--- 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/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -162,17 +162,17 @@ static const nsAttrValue::EnumTable kMoz
   { "normal",             (int16_t)AudioChannel::Normal },
   { "content",            (int16_t)AudioChannel::Content },
   { "notification",       (int16_t)AudioChannel::Notification },
   { "alarm",              (int16_t)AudioChannel::Alarm },
   { "telephony",          (int16_t)AudioChannel::Telephony },
   { "ringer",             (int16_t)AudioChannel::Ringer },
   { "publicnotification", (int16_t)AudioChannel::Publicnotification },
   { "system",             (int16_t)AudioChannel::System },
-  { nullptr }
+  { nullptr,              0 }
 };
 
 /* static */ void
 AudioChannelService::CreateServiceIfNeeded()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!gAudioChannelService) {
--- a/dom/base/CORSMode.h
+++ b/dom/base/CORSMode.h
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef CORSMode_h_
 #define CORSMode_h_
 
 namespace mozilla {
 
-enum CORSMode {
+enum CORSMode : uint8_t {
   /**
    * The default of not using CORS to validate cross-origin loads.
    */
   CORS_NONE,
 
   /**
    * Validate cross-site loads using CORS, but do not send any credentials
    * (cookies, HTTP auth logins, etc) along with the request.
--- a/dom/base/DirectionalityUtils.h
+++ b/dom/base/DirectionalityUtils.h
@@ -17,17 +17,17 @@ class nsTextNode;
 namespace mozilla {
 namespace dom {
 class Element;
 } // namespace dom
 } // namespace mozilla
 
 namespace mozilla {
 
-enum Directionality {
+enum Directionality : uint8_t {
   eDir_NotSet,
   eDir_RTL,
   eDir_LTR,
   eDir_Auto
 };
 
 /**
  * Set the directionality of an element according to the algorithm defined at
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -3264,17 +3264,17 @@ Element::Matches(const nsAString& aSelec
                                                  selectorList);
 }
 
 static const nsAttrValue::EnumTable kCORSAttributeTable[] = {
   // Order matters here
   // See ParseCORSValue
   { "anonymous",       CORS_ANONYMOUS       },
   { "use-credentials", CORS_USE_CREDENTIALS },
-  { 0 }
+  { nullptr,           0 }
 };
 
 /* static */ void
 Element::ParseCORSValue(const nsAString& aValue,
                         nsAttrValue& aResult)
 {
   DebugOnly<bool> success =
     aResult.ParseEnumValue(aValue, kCORSAttributeTable, false,
--- 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/nsAttrValue.h
+++ b/dom/base/nsAttrValue.h
@@ -7,28 +7,31 @@
 /*
  * A struct that represents the value (type and actual data) of an
  * attribute.
  */
 
 #ifndef nsAttrValue_h___
 #define nsAttrValue_h___
 
+#include <type_traits>
+
 #include "nscore.h"
 #include "nsStringGlue.h"
 #include "nsStringBuffer.h"
 #include "nsColor.h"
 #include "nsCaseTreatment.h"
 #include "nsMargin.h"
 #include "nsCOMPtr.h"
 #include "SVGAttrValueWrapper.h"
 #include "nsTArrayForwardDeclare.h"
 #include "nsIAtom.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/BindingDeclarations.h"
+#include "mozilla/EnumTypeTraits.h"
 
 // Undefine LoadImage to prevent naming conflict with Windows.
 #undef LoadImage
 
 class nsAString;
 class nsIDocument;
 class nsStyledElement;
 struct MiscContainer;
@@ -256,20 +259,39 @@ public:
 
   /**
    * Structure for a mapping from int (enum) values to strings.  When you use
    * it you generally create an array of them.
    * Instantiate like this:
    * EnumTable myTable[] = {
    *   { "string1", 1 },
    *   { "string2", 2 },
-   *   { 0 }
+   *   { nullptr, 0 }
    * }
    */
   struct EnumTable {
+    // EnumTable can be initialized either with an int16_t value
+    // or a value of an enumeration type that can fit within an int16_t.
+
+    constexpr EnumTable(const char* aTag, int16_t aValue)
+      : tag(aTag)
+      , value(aValue)
+    {
+    }
+
+    template<typename T,
+             typename = typename std::enable_if<std::is_enum<T>::value>::type>
+    constexpr EnumTable(const char* aTag, T aValue)
+      : tag(aTag)
+      , value(static_cast<int16_t>(aValue))
+    {
+      static_assert(mozilla::EnumTypeFitsWithin<T, int16_t>::value,
+                    "aValue must be an enum that fits within int16_t");
+    }
+
     /** The string the value maps to */
     const char* tag;
     /** The enum value that maps to this string */
     int16_t value;
   };
 
   /**
    * Parse into an enum value.
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -299,36 +299,36 @@ bool nsContentUtils::sFragmentParsingAct
 bool nsContentUtils::sDOMWindowDumpEnabled;
 #endif
 
 bool nsContentUtils::sDoNotTrackEnabled = false;
 
 mozilla::LazyLogModule nsContentUtils::sDOMDumpLog("Dump");
 
 // Subset of http://www.whatwg.org/specs/web-apps/current-work/#autofill-field-name
-enum AutocompleteFieldName
+enum AutocompleteFieldName : uint8_t
 {
   #define AUTOCOMPLETE_FIELD_NAME(name_, value_) \
     eAutocompleteFieldName_##name_,
   #define AUTOCOMPLETE_CONTACT_FIELD_NAME(name_, value_) \
     AUTOCOMPLETE_FIELD_NAME(name_, value_)
   #include "AutocompleteFieldList.h"
   #undef AUTOCOMPLETE_FIELD_NAME
   #undef AUTOCOMPLETE_CONTACT_FIELD_NAME
 };
 
-enum AutocompleteFieldHint
+enum AutocompleteFieldHint : uint8_t
 {
   #define AUTOCOMPLETE_FIELD_HINT(name_, value_) \
     eAutocompleteFieldHint_##name_,
   #include "AutocompleteFieldList.h"
   #undef AUTOCOMPLETE_FIELD_HINT
 };
 
-enum AutocompleteFieldContactHint
+enum AutocompleteFieldContactHint : uint8_t
 {
   #define AUTOCOMPLETE_FIELD_CONTACT_HINT(name_, value_) \
     eAutocompleteFieldContactHint_##name_,
   #include "AutocompleteFieldList.h"
   #undef AUTOCOMPLETE_FIELD_CONTACT_HINT
 };
 
 enum AutocompleteCategory
@@ -338,41 +338,41 @@ enum AutocompleteCategory
   #undef AUTOCOMPLETE_CATEGORY
 };
 
 static const nsAttrValue::EnumTable kAutocompleteFieldNameTable[] = {
   #define AUTOCOMPLETE_FIELD_NAME(name_, value_) \
     { value_, eAutocompleteFieldName_##name_ },
   #include "AutocompleteFieldList.h"
   #undef AUTOCOMPLETE_FIELD_NAME
-  { 0 }
+  { nullptr, 0 }
 };
 
 static const nsAttrValue::EnumTable kAutocompleteContactFieldNameTable[] = {
   #define AUTOCOMPLETE_CONTACT_FIELD_NAME(name_, value_) \
     { value_, eAutocompleteFieldName_##name_ },
   #include "AutocompleteFieldList.h"
   #undef AUTOCOMPLETE_CONTACT_FIELD_NAME
-  { 0 }
+  { nullptr, 0 }
 };
 
 static const nsAttrValue::EnumTable kAutocompleteFieldHintTable[] = {
   #define AUTOCOMPLETE_FIELD_HINT(name_, value_) \
     { value_, eAutocompleteFieldHint_##name_ },
   #include "AutocompleteFieldList.h"
   #undef AUTOCOMPLETE_FIELD_HINT
-  { 0 }
+  { nullptr, 0 }
 };
 
 static const nsAttrValue::EnumTable kAutocompleteContactFieldHintTable[] = {
   #define AUTOCOMPLETE_FIELD_CONTACT_HINT(name_, value_) \
     { value_, eAutocompleteFieldContactHint_##name_ },
   #include "AutocompleteFieldList.h"
   #undef AUTOCOMPLETE_FIELD_CONTACT_HINT
-  { 0 }
+  { nullptr, 0 }
 };
 
 namespace {
 
 static NS_DEFINE_CID(kParserServiceCID, NS_PARSERSERVICE_CID);
 static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
 
 static PLDHashTable* sEventListenerManagersHash;
--- 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/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -12316,16 +12316,17 @@ class CGDictionary(CGThing):
         if memberInits:
             body += fill(
                 """
                 bool isNull = val.isNullOrUndefined();
                 // We only need these if !isNull, in which case we have |cx|.
                 Maybe<JS::Rooted<JSObject *> > object;
                 Maybe<JS::Rooted<JS::Value> > temp;
                 if (!isNull) {
+                  MOZ_ASSERT(cx);
                   object.emplace(cx, &val.toObject());
                   temp.emplace(cx);
                 }
                 $*{memberInits}
                 """,
                 memberInits="\n".join(memberInits))
 
         body += "return true;\n"
--- 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/HTMLBRElement.cpp
+++ b/dom/html/HTMLBRElement.cpp
@@ -25,21 +25,21 @@ HTMLBRElement::HTMLBRElement(already_Add
 
 HTMLBRElement::~HTMLBRElement()
 {
 }
 
 NS_IMPL_ELEMENT_CLONE(HTMLBRElement)
 
 static const nsAttrValue::EnumTable kClearTable[] = {
-  { "left", NS_STYLE_CLEAR_LEFT },
-  { "right", NS_STYLE_CLEAR_RIGHT },
-  { "all", NS_STYLE_CLEAR_BOTH },
-  { "both", NS_STYLE_CLEAR_BOTH },
-  { 0 }
+  { "left", StyleClear::Left },
+  { "right", StyleClear::Right },
+  { "all", StyleClear::Both },
+  { "both", StyleClear::Both },
+  { nullptr, 0 }
 };
 
 bool
 HTMLBRElement::ParseAttribute(int32_t aNamespaceID,
                               nsIAtom* aAttribute,
                               const nsAString& aValue,
                               nsAttrValue& aResult)
 {
--- a/dom/html/HTMLButtonElement.cpp
+++ b/dom/html/HTMLButtonElement.cpp
@@ -42,17 +42,17 @@ NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER
 
 namespace mozilla {
 namespace dom {
 
 static const nsAttrValue::EnumTable kButtonTypeTable[] = {
   { "button", NS_FORM_BUTTON_BUTTON },
   { "reset", NS_FORM_BUTTON_RESET },
   { "submit", NS_FORM_BUTTON_SUBMIT },
-  { 0 }
+  { nullptr, 0 }
 };
 
 // Default type is 'submit'.
 static const nsAttrValue::EnumTable* kButtonDefaultType = &kButtonTypeTable[2];
 
 
 // Construction, destruction
 HTMLButtonElement::HTMLButtonElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
@@ -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/HTMLFormElement.cpp
+++ b/dom/html/HTMLFormElement.cpp
@@ -82,17 +82,17 @@ namespace mozilla {
 namespace dom {
 
 static const uint8_t NS_FORM_AUTOCOMPLETE_ON  = 1;
 static const uint8_t NS_FORM_AUTOCOMPLETE_OFF = 0;
 
 static const nsAttrValue::EnumTable kFormAutocompleteTable[] = {
   { "on",  NS_FORM_AUTOCOMPLETE_ON },
   { "off", NS_FORM_AUTOCOMPLETE_OFF },
-  { 0 }
+  { nullptr, 0 }
 };
 // Default autocomplete value is 'on'.
 static const nsAttrValue::EnumTable* kFormDefaultAutocomplete = &kFormAutocompleteTable[0];
 
 bool HTMLFormElement::gFirstFormSubmitted = false;
 bool HTMLFormElement::gPasswordManagerInitialized = false;
 
 HTMLFormElement::HTMLFormElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
--- a/dom/html/HTMLFormSubmissionConstants.h
+++ b/dom/html/HTMLFormSubmissionConstants.h
@@ -7,25 +7,25 @@
 #ifndef mozilla_dom_HTMLFormSubmissionConstants_h
 #define mozilla_dom_HTMLFormSubmissionConstants_h
 
 #include "nsIForm.h"
 
 static const nsAttrValue::EnumTable kFormMethodTable[] = {
   { "get", NS_FORM_METHOD_GET },
   { "post", NS_FORM_METHOD_POST },
-  { 0 }
+  { nullptr, 0 }
 };
 
 // Default method is 'get'.
 static const nsAttrValue::EnumTable* kFormDefaultMethod = &kFormMethodTable[0];
 
 static const nsAttrValue::EnumTable kFormEnctypeTable[] = {
   { "multipart/form-data", NS_FORM_ENCTYPE_MULTIPART },
   { "application/x-www-form-urlencoded", NS_FORM_ENCTYPE_URLENCODED },
   { "text/plain", NS_FORM_ENCTYPE_TEXTPLAIN },
-  { 0 }
+  { nullptr, 0 }
 };
 
 // Default method is 'application/x-www-form-urlencoded'.
 static const nsAttrValue::EnumTable* kFormDefaultEnctype = &kFormEnctypeTable[1];
 
 #endif // mozilla_dom_HTMLFormSubmissionConstants_h
--- a/dom/html/HTMLHRElement.cpp
+++ b/dom/html/HTMLHRElement.cpp
@@ -38,17 +38,17 @@ HTMLHRElement::ParseAttribute(int32_t aN
                               nsIAtom* aAttribute,
                               const nsAString& aValue,
                               nsAttrValue& aResult)
 {
   static const nsAttrValue::EnumTable kAlignTable[] = {
     { "left", NS_STYLE_TEXT_ALIGN_LEFT },
     { "right", NS_STYLE_TEXT_ALIGN_RIGHT },
     { "center", NS_STYLE_TEXT_ALIGN_CENTER },
-    { 0 }
+    { nullptr, 0 }
   };
 
   if (aNamespaceID == kNameSpaceID_None) {
     if (aAttribute == nsGkAtoms::width) {
       return aResult.ParseSpecialIntValue(aValue);
     }
     if (aAttribute == nsGkAtoms::size) {
       return aResult.ParseIntWithBounds(aValue, 1, 1000);
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -173,17 +173,17 @@ static const nsAttrValue::EnumTable kInp
   { "range", NS_FORM_INPUT_RANGE },
   { "search", NS_FORM_INPUT_SEARCH },
   { "submit", NS_FORM_INPUT_SUBMIT },
   { "tel", NS_FORM_INPUT_TEL },
   { "text", NS_FORM_INPUT_TEXT },
   { "time", NS_FORM_INPUT_TIME },
   { "url", NS_FORM_INPUT_URL },
   { "week", NS_FORM_INPUT_WEEK },
-  { 0 }
+  { nullptr, 0 }
 };
 
 // Default type is 'text'.
 static const nsAttrValue::EnumTable* kInputDefaultType = &kInputTypeTable[17];
 
 static const uint8_t NS_INPUT_INPUTMODE_AUTO              = 0;
 static const uint8_t NS_INPUT_INPUTMODE_NUMERIC           = 1;
 static const uint8_t NS_INPUT_INPUTMODE_DIGIT             = 2;
@@ -195,17 +195,17 @@ static const uint8_t NS_INPUT_INPUTMODE_
 static const nsAttrValue::EnumTable kInputInputmodeTable[] = {
   { "auto", NS_INPUT_INPUTMODE_AUTO },
   { "numeric", NS_INPUT_INPUTMODE_NUMERIC },
   { "digit", NS_INPUT_INPUTMODE_DIGIT },
   { "uppercase", NS_INPUT_INPUTMODE_UPPERCASE },
   { "lowercase", NS_INPUT_INPUTMODE_LOWERCASE },
   { "titlecase", NS_INPUT_INPUTMODE_TITLECASE },
   { "autocapitalized", NS_INPUT_INPUTMODE_AUTOCAPITALIZED },
-  { 0 }
+  { nullptr, 0 }
 };
 
 // Default inputmode value is "auto".
 static const nsAttrValue::EnumTable* kInputDefaultInputmode = &kInputInputmodeTable[0];
 
 const Decimal HTMLInputElement::kStepScaleFactorDate = Decimal(86400000);
 const Decimal HTMLInputElement::kStepScaleFactorNumberRange = Decimal(1);
 const Decimal HTMLInputElement::kStepScaleFactorTime = Decimal(1000);
@@ -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/HTMLLIElement.cpp
+++ b/dom/html/HTMLLIElement.cpp
@@ -31,27 +31,27 @@ NS_IMPL_STRING_ATTR(HTMLLIElement, Type,
 NS_IMPL_INT_ATTR(HTMLLIElement, Value, value)
 
 // values that are handled case-insensitively
 static const nsAttrValue::EnumTable kUnorderedListItemTypeTable[] = {
   { "disc", NS_STYLE_LIST_STYLE_DISC },
   { "circle", NS_STYLE_LIST_STYLE_CIRCLE },
   { "round", NS_STYLE_LIST_STYLE_CIRCLE },
   { "square", NS_STYLE_LIST_STYLE_SQUARE },
-  { 0 }
+  { nullptr, 0 }
 };
 
 // values that are handled case-sensitively
 static const nsAttrValue::EnumTable kOrderedListItemTypeTable[] = {
   { "A", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
   { "a", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
   { "I", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
   { "i", NS_STYLE_LIST_STYLE_LOWER_ROMAN },
   { "1", NS_STYLE_LIST_STYLE_DECIMAL },
-  { 0 }
+  { nullptr, 0 }
 };
 
 bool
 HTMLLIElement::ParseAttribute(int32_t aNamespaceID,
                               nsIAtom* aAttribute,
                               const nsAString& aValue,
                               nsAttrValue& aResult)
 {
--- a/dom/html/HTMLLegendElement.cpp
+++ b/dom/html/HTMLLegendElement.cpp
@@ -42,17 +42,17 @@ HTMLLegendElement::ParseAttribute(int32_
 {
   // this contains center, because IE4 does
   static const nsAttrValue::EnumTable kAlignTable[] = {
     { "left", NS_STYLE_TEXT_ALIGN_LEFT },
     { "right", NS_STYLE_TEXT_ALIGN_RIGHT },
     { "center", NS_STYLE_TEXT_ALIGN_CENTER },
     { "bottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM },
     { "top", NS_STYLE_VERTICAL_ALIGN_TOP },
-    { 0 }
+    { nullptr, 0 }
   };
 
   if (aAttribute == nsGkAtoms::align && aNamespaceID == kNameSpaceID_None) {
     return aResult.ParseEnumValue(aValue, kAlignTable, false);
   }
 
   return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
                                               aResult);
--- 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;
@@ -2539,33 +2539,28 @@ HTMLMediaElement::AddCaptureMediaTrackTo
        track.get(), destinationTrackID, inputTrack, port.get()));
 }
 
 already_AddRefed<DOMMediaStream>
 HTMLMediaElement::CaptureStreamInternal(bool aFinishWhenEnded,
                                         bool aCaptureAudio,
                                         MediaStreamGraph* aGraph)
 {
+  MOZ_RELEASE_ASSERT(aGraph);
+
   nsPIDOMWindowInner* window = OwnerDoc()->GetInnerWindow();
   if (!window) {
     return nullptr;
   }
 #ifdef MOZ_EME
   if (ContainsRestrictedContent()) {
     return nullptr;
   }
 #endif
 
-  if (!aGraph) {
-    MediaStreamGraph::GraphDriverType graphDriverType =
-      HasAudio() ? MediaStreamGraph::AUDIO_THREAD_DRIVER
-                 : MediaStreamGraph::SYSTEM_THREAD_DRIVER;
-    aGraph = MediaStreamGraph::GetInstance(graphDriverType, mAudioChannel);
-  }
-
   if (!mOutputStreams.IsEmpty() &&
       aGraph != mOutputStreams[0].mStream->GetInputStream()->Graph()) {
     return nullptr;
   }
 
   OutputMediaStream* out = mOutputStreams.AppendElement();
   MediaStreamTrackSourceGetter* getter = new CaptureStreamTrackSourceGetter(this);
   out->mStream = DOMMediaStream::CreateTrackUnionStreamAsInput(window, aGraph, getter);
@@ -2650,43 +2645,58 @@ HTMLMediaElement::CaptureStreamInternal(
   RefPtr<DOMMediaStream> result = out->mStream;
   return result.forget();
 }
 
 already_AddRefed<DOMMediaStream>
 HTMLMediaElement::CaptureAudio(ErrorResult& aRv,
                                MediaStreamGraph* aGraph)
 {
-  RefPtr<DOMMediaStream> stream = CaptureStreamInternal(false, aGraph);
+  MOZ_RELEASE_ASSERT(aGraph);
+
+  RefPtr<DOMMediaStream> stream =
+    CaptureStreamInternal(false, true, aGraph);
   if (!stream) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   return stream.forget();
 }
 
 already_AddRefed<DOMMediaStream>
-HTMLMediaElement::MozCaptureStream(ErrorResult& aRv,
-                                   MediaStreamGraph* aGraph)
-{
-  RefPtr<DOMMediaStream> stream = CaptureStreamInternal(false, aGraph);
+HTMLMediaElement::MozCaptureStream(ErrorResult& aRv)
+{
+  MediaStreamGraph::GraphDriverType graphDriverType =
+    HasAudio() ? MediaStreamGraph::AUDIO_THREAD_DRIVER
+               : MediaStreamGraph::SYSTEM_THREAD_DRIVER;
+  MediaStreamGraph* graph =
+    MediaStreamGraph::GetInstance(graphDriverType, mAudioChannel);
+
+  RefPtr<DOMMediaStream> stream =
+    CaptureStreamInternal(false, false, graph);
   if (!stream) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   return stream.forget();
 }
 
 already_AddRefed<DOMMediaStream>
-HTMLMediaElement::MozCaptureStreamUntilEnded(ErrorResult& aRv,
-                                             MediaStreamGraph* aGraph)
-{
-  RefPtr<DOMMediaStream> stream = CaptureStreamInternal(true, aGraph);
+HTMLMediaElement::MozCaptureStreamUntilEnded(ErrorResult& aRv)
+{
+  MediaStreamGraph::GraphDriverType graphDriverType =
+    HasAudio() ? MediaStreamGraph::AUDIO_THREAD_DRIVER
+               : MediaStreamGraph::SYSTEM_THREAD_DRIVER;
+  MediaStreamGraph* graph =
+    MediaStreamGraph::GetInstance(graphDriverType, mAudioChannel);
+
+  RefPtr<DOMMediaStream> stream =
+    CaptureStreamInternal(true, false, graph);
   if (!stream) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   return stream.forget();
 }
 
@@ -3216,17 +3226,17 @@ bool HTMLMediaElement::ParseAttribute(in
                                       nsAttrValue& aResult)
 {
   // Mappings from 'preload' attribute strings to an enumeration.
   static const nsAttrValue::EnumTable kPreloadTable[] = {
     { "",         HTMLMediaElement::PRELOAD_ATTR_EMPTY },
     { "none",     HTMLMediaElement::PRELOAD_ATTR_NONE },
     { "metadata", HTMLMediaElement::PRELOAD_ATTR_METADATA },
     { "auto",     HTMLMediaElement::PRELOAD_ATTR_AUTO },
-    { 0 }
+    { nullptr,    0 }
   };
 
   if (aNamespaceID == kNameSpaceID_None) {
     if (ParseImageAttribute(aAttribute, aValue, aResult)) {
       return true;
     }
     if (aAttribute == nsGkAtoms::crossorigin) {
       ParseCORSValue(aValue, aResult);
@@ -3937,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
@@ -6569,17 +6579,18 @@ HTMLMediaElement::AudioCaptureStreamChan
     uint64_t id = window->WindowID();
     MediaStreamGraph* msg =
       MediaStreamGraph::GetInstance(MediaStreamGraph::AUDIO_THREAD_DRIVER,
                                     mAudioChannel);
 
     if (GetSrcMediaStream()) {
       mCaptureStreamPort = msg->ConnectToCaptureStream(id, GetSrcMediaStream());
     } else {
-      RefPtr<DOMMediaStream> stream = CaptureStreamInternal(false, msg);
+      RefPtr<DOMMediaStream> stream =
+        CaptureStreamInternal(false, false, msg);
       mCaptureStreamPort = msg->ConnectToCaptureStream(id, stream->GetPlaybackStream());
     }
   } else if (!mAudioCapturedByWindow && mCaptureStreamPort) {
     if (mDecoder) {
       ProcessedMediaStream* ps =
         mCaptureStreamPort->GetSource()->AsProcessedStream();
       MOZ_ASSERT(ps);
 
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -650,23 +650,21 @@ public:
   void CannotDecryptWaitingForKey();
 
   bool MozAutoplayEnabled() const
   {
     return mAutoplayEnabled;
   }
 
   already_AddRefed<DOMMediaStream> CaptureAudio(ErrorResult& aRv,
-                                                MediaStreamGraph* aGraph = nullptr);
+                                                MediaStreamGraph* aGraph);
 
-  already_AddRefed<DOMMediaStream> MozCaptureStream(ErrorResult& aRv,
-                                                    MediaStreamGraph* aGraph = nullptr);
+  already_AddRefed<DOMMediaStream> MozCaptureStream(ErrorResult& aRv);
 
-  already_AddRefed<DOMMediaStream> MozCaptureStreamUntilEnded(ErrorResult& aRv,
-                                                              MediaStreamGraph* aGraph = nullptr);
+  already_AddRefed<DOMMediaStream> MozCaptureStreamUntilEnded(ErrorResult& aRv);
 
   bool MozAudioCaptured() const
   {
     return mAudioCaptured;
   }
 
   void MozGetMetadata(JSContext* aCx, JS::MutableHandle<JSObject*> aResult,
                       ErrorResult& aRv);
@@ -892,17 +890,17 @@ protected:
    * The stream will never finish.
    *
    * When aCaptureAudio is true, we stop playout of audio and instead route it
    * to the DOMMediaStream. Volume and mute state will be applied to the audio
    * reaching the stream. No video tracks will be captured in this case.
    */
   already_AddRefed<DOMMediaStream> CaptureStreamInternal(bool aFinishWhenEnded,
                                                          bool aCaptureAudio,
-                                                         MediaStreamGraph* aGraph = nullptr);
+                                                         MediaStreamGraph* aGraph);
 
   /**
    * Initialize a decoder as a clone of an existing decoder in another
    * element.
    * mLoadingSrc must already be set.
    */
   nsresult InitializeDecoderAsClone(MediaDecoder* aOriginal);
 
@@ -1034,17 +1032,17 @@ protected:
   /**
    * Called when "xpcom-shutdown" event is received.
    */
   void NotifyShutdownEvent();
 
   /**
    * Possible values of the 'preload' attribute.
    */
-  enum PreloadAttrValue {
+  enum PreloadAttrValue : uint8_t {
     PRELOAD_ATTR_EMPTY,    // set to ""
     PRELOAD_ATTR_NONE,     // set to "none"
     PRELOAD_ATTR_METADATA, // set to "metadata"
     PRELOAD_ATTR_AUTO      // set to "auto"
   };
 
   /**
    * The preloading action to perform. These dictate how we react to the
--- a/dom/html/HTMLMenuElement.cpp
+++ b/dom/html/HTMLMenuElement.cpp
@@ -17,28 +17,28 @@
 
 #define HTMLMENUBUILDER_CONTRACTID "@mozilla.org/content/html-menu-builder;1"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Menu)
 
 namespace mozilla {
 namespace dom {
 
-enum MenuType
+enum MenuType : uint8_t
 {
   MENU_TYPE_CONTEXT = 1,
   MENU_TYPE_TOOLBAR,
   MENU_TYPE_LIST
 };
 
 static const nsAttrValue::EnumTable kMenuTypeTable[] = {
   { "context", MENU_TYPE_CONTEXT },
   { "toolbar", MENU_TYPE_TOOLBAR },
   { "list", MENU_TYPE_LIST },
-  { 0 }
+  { nullptr, 0 }
 };
 
 static const nsAttrValue::EnumTable* kMenuDefaultType =
   &kMenuTypeTable[2];
 
 enum SeparatorType
 {
   ST_TRUE_INIT = -1,
--- a/dom/html/HTMLMenuItemElement.cpp
+++ b/dom/html/HTMLMenuItemElement.cpp
@@ -19,28 +19,28 @@ namespace mozilla {
 namespace dom {
 
 // First bits are needed for the menuitem type.
 #define NS_CHECKED_IS_TOGGLED (1 << 2)
 #define NS_ORIGINAL_CHECKED_VALUE (1 << 3)
 #define NS_MENUITEM_TYPE(bits) ((bits) & ~( \
   NS_CHECKED_IS_TOGGLED | NS_ORIGINAL_CHECKED_VALUE))
 
-enum CmdType                                                                 
-{                                                                            
+enum CmdType : uint8_t
+{
   CMD_TYPE_MENUITEM = 1,
   CMD_TYPE_CHECKBOX,
   CMD_TYPE_RADIO
 };
 
 static const nsAttrValue::EnumTable kMenuItemTypeTable[] = {
   { "menuitem", CMD_TYPE_MENUITEM },
   { "checkbox", CMD_TYPE_CHECKBOX },
   { "radio", CMD_TYPE_RADIO },
-  { 0 }
+  { nullptr, 0 }
 };
 
 static const nsAttrValue::EnumTable* kMenuItemDefaultType =
   &kMenuItemTypeTable[0];
 
 // A base class inherited by all radio visitors.
 class Visitor
 {
--- 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/HTMLSharedListElement.cpp
+++ b/dom/html/HTMLSharedListElement.cpp
@@ -50,26 +50,26 @@ nsAttrValue::EnumTable kListTypeTable[] 
   { "circle", NS_STYLE_LIST_STYLE_CIRCLE },
   { "round", NS_STYLE_LIST_STYLE_CIRCLE },
   { "square", NS_STYLE_LIST_STYLE_SQUARE },
   { "decimal", NS_STYLE_LIST_STYLE_DECIMAL },
   { "lower-roman", NS_STYLE_LIST_STYLE_LOWER_ROMAN },
   { "upper-roman", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
   { "lower-alpha", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
   { "upper-alpha", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
-  { 0 }
+  { nullptr, 0 }
 };
 
 static const nsAttrValue::EnumTable kOldListTypeTable[] = {
   { "1", NS_STYLE_LIST_STYLE_DECIMAL },
   { "A", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
   { "a", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
   { "I", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
   { "i", NS_STYLE_LIST_STYLE_LOWER_ROMAN },
-  { 0 }
+  { nullptr, 0 }
 };
 
 bool
 HTMLSharedListElement::ParseAttribute(int32_t aNamespaceID,
                                       nsIAtom* aAttribute,
                                       const nsAString& aValue,
                                       nsAttrValue& aResult)
 {
--- a/dom/html/HTMLTableCaptionElement.cpp
+++ b/dom/html/HTMLTableCaptionElement.cpp
@@ -27,17 +27,17 @@ HTMLTableCaptionElement::WrapNode(JSCont
 
 NS_IMPL_ELEMENT_CLONE(HTMLTableCaptionElement)
 
 static const nsAttrValue::EnumTable kCaptionAlignTable[] = {
   { "left",   NS_STYLE_CAPTION_SIDE_LEFT },
   { "right",  NS_STYLE_CAPTION_SIDE_RIGHT },
   { "top",    NS_STYLE_CAPTION_SIDE_TOP },
   { "bottom", NS_STYLE_CAPTION_SIDE_BOTTOM },
-  { 0 }
+  { nullptr,  0 }
 };
 
 bool
 HTMLTableCaptionElement::ParseAttribute(int32_t aNamespaceID,
                                         nsIAtom* aAttribute,
                                         const nsAString& aValue,
                                         nsAttrValue& aResult)
 {
--- a/dom/html/HTMLTableCellElement.cpp
+++ b/dom/html/HTMLTableCellElement.cpp
@@ -361,17 +361,17 @@ HTMLTableCellElement::GetAlign(DOMString
   }
 }
 
 static const nsAttrValue::EnumTable kCellScopeTable[] = {
   { "row",      NS_STYLE_CELL_SCOPE_ROW },
   { "col",      NS_STYLE_CELL_SCOPE_COL },
   { "rowgroup", NS_STYLE_CELL_SCOPE_ROWGROUP },
   { "colgroup", NS_STYLE_CELL_SCOPE_COLGROUP },
-  { 0 }
+  { nullptr,    0 }
 };
 
 void
 HTMLTableCellElement::GetScope(DOMString& aScope)
 {
   GetEnumAttr(nsGkAtoms::scope, nullptr, aScope);
 }
 
--- a/dom/html/HTMLTrackElement.cpp
+++ b/dom/html/HTMLTrackElement.cpp
@@ -62,17 +62,17 @@ namespace dom {
 
 // Map html attribute string values to TextTrackKind enums.
 static constexpr nsAttrValue::EnumTable kKindTable[] = {
   { "subtitles", static_cast<int16_t>(TextTrackKind::Subtitles) },
   { "captions", static_cast<int16_t>(TextTrackKind::Captions) },
   { "descriptions", static_cast<int16_t>(TextTrackKind::Descriptions) },
   { "chapters", static_cast<int16_t>(TextTrackKind::Chapters) },
   { "metadata", static_cast<int16_t>(TextTrackKind::Metadata) },
-  { 0 }
+  { nullptr, 0 }
 };
 
 // Invalid values are treated as "metadata" in ParseAttribute, but if no value
 // at all is specified, it's treated as "subtitles" in GetKind
 static constexpr const nsAttrValue::EnumTable* kKindTableInvalidValueDefault = &kKindTable[4];
 
 class WindowDestroyObserver final : public nsIObserver
 {
--- 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/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -215,17 +215,17 @@ nsGenericHTMLElement::GetDataset(nsISupp
   *aDataset = Dataset().take();
   return NS_OK;
 }
 
 static const nsAttrValue::EnumTable kDirTable[] = {
   { "ltr", eDir_LTR },
   { "rtl", eDir_RTL },
   { "auto", eDir_Auto },
-  { 0 }
+  { nullptr, 0 }
 };
 
 void
 nsGenericHTMLElement::GetAccessKeyLabel(nsString& aLabel)
 {
   nsAutoString suffix;
   GetAccessKey(suffix);
   if (!suffix.IsEmpty()) {
@@ -1053,44 +1053,44 @@ nsGenericHTMLElement::GetPresContext(Pre
 }
 
 static const nsAttrValue::EnumTable kDivAlignTable[] = {
   { "left", NS_STYLE_TEXT_ALIGN_MOZ_LEFT },
   { "right", NS_STYLE_TEXT_ALIGN_MOZ_RIGHT },
   { "center", NS_STYLE_TEXT_ALIGN_MOZ_CENTER },
   { "middle", NS_STYLE_TEXT_ALIGN_MOZ_CENTER },
   { "justify", NS_STYLE_TEXT_ALIGN_JUSTIFY },
-  { 0 }
+  { nullptr, 0 }
 };
 
 static const nsAttrValue::EnumTable kFrameborderTable[] = {
   { "yes", NS_STYLE_FRAME_YES },
   { "no", NS_STYLE_FRAME_NO },
   { "1", NS_STYLE_FRAME_1 },
   { "0", NS_STYLE_FRAME_0 },
-  { 0 }
+  { nullptr, 0 }
 };
 
 static const nsAttrValue::EnumTable kScrollingTable[] = {
   { "yes", NS_STYLE_FRAME_YES },
   { "no", NS_STYLE_FRAME_NO },
   { "on", NS_STYLE_FRAME_ON },
   { "off", NS_STYLE_FRAME_OFF },
   { "scroll", NS_STYLE_FRAME_SCROLL },
   { "noscroll", NS_STYLE_FRAME_NOSCROLL },
   { "auto", NS_STYLE_FRAME_AUTO },
-  { 0 }
+  { nullptr, 0 }
 };
 
 static const nsAttrValue::EnumTable kTableVAlignTable[] = {
   { "top",     NS_STYLE_VERTICAL_ALIGN_TOP },
   { "middle",  NS_STYLE_VERTICAL_ALIGN_MIDDLE },
   { "bottom",  NS_STYLE_VERTICAL_ALIGN_BOTTOM },
   { "baseline",NS_STYLE_VERTICAL_ALIGN_BASELINE },
-  { 0 }
+  { nullptr,   0 }
 };
 
 bool
 nsGenericHTMLElement::ParseAlignValue(const nsAString& aString,
                                       nsAttrValue& aResult)
 {
   static const nsAttrValue::EnumTable kAlignTable[] = {
     { "left",      NS_STYLE_TEXT_ALIGN_LEFT },
@@ -1102,31 +1102,31 @@ nsGenericHTMLElement::ParseAlignValue(co
 
     { "center",    NS_STYLE_VERTICAL_ALIGN_MIDDLE_WITH_BASELINE },
     { "baseline",  NS_STYLE_VERTICAL_ALIGN_BASELINE },
 
     { "texttop",   NS_STYLE_VERTICAL_ALIGN_TEXT_TOP },
     { "absmiddle", NS_STYLE_VERTICAL_ALIGN_MIDDLE },
     { "abscenter", NS_STYLE_VERTICAL_ALIGN_MIDDLE },
     { "absbottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM },
-    { 0 }
+    { nullptr,     0 }
   };
 
   return aResult.ParseEnumValue(aString, kAlignTable, false);
 }
 
 //----------------------------------------
 
 static const nsAttrValue::EnumTable kTableHAlignTable[] = {
   { "left",   NS_STYLE_TEXT_ALIGN_LEFT },
   { "right",  NS_STYLE_TEXT_ALIGN_RIGHT },
   { "center", NS_STYLE_TEXT_ALIGN_CENTER },
   { "char",   NS_STYLE_TEXT_ALIGN_CHAR },
   { "justify",NS_STYLE_TEXT_ALIGN_JUSTIFY },
-  { 0 }
+  { nullptr,  0 }
 };
 
 bool
 nsGenericHTMLElement::ParseTableHAlignValue(const nsAString& aString,
                                             nsAttrValue& aResult)
 {
   return aResult.ParseEnumValue(aString, kTableHAlignTable, false);
 }
@@ -1137,17 +1137,17 @@ nsGenericHTMLElement::ParseTableHAlignVa
 static const nsAttrValue::EnumTable kTableCellHAlignTable[] = {
   { "left",   NS_STYLE_TEXT_ALIGN_MOZ_LEFT },
   { "right",  NS_STYLE_TEXT_ALIGN_MOZ_RIGHT },
   { "center", NS_STYLE_TEXT_ALIGN_MOZ_CENTER },
   { "char",   NS_STYLE_TEXT_ALIGN_CHAR },
   { "justify",NS_STYLE_TEXT_ALIGN_JUSTIFY },
   { "middle", NS_STYLE_TEXT_ALIGN_MOZ_CENTER },
   { "absmiddle", NS_STYLE_TEXT_ALIGN_CENTER },
-  { 0 }
+  { nullptr,  0 }
 };
 
 bool
 nsGenericHTMLElement::ParseTableCellHAlignValue(const nsAString& aString,
                                                 nsAttrValue& aResult)
 {
   return aResult.ParseEnumValue(aString, kTableCellHAlignTable, false);
 }
@@ -1185,22 +1185,22 @@ nsGenericHTMLElement::ParseImageAttribut
   return false;
 }
 
 bool
 nsGenericHTMLElement::ParseReferrerAttribute(const nsAString& aString,
                                              nsAttrValue& aResult)
 {
   static const nsAttrValue::EnumTable kReferrerTable[] = {
-    { net::kRPS_No_Referrer, net::RP_No_Referrer },
-    { net::kRPS_Origin, net::RP_Origin },
-    { net::kRPS_Origin_When_Cross_Origin, net::RP_Origin_When_Crossorigin },
-    { net::kRPS_No_Referrer_When_Downgrade, net::RP_No_Referrer_When_Downgrade },
-    { net::kRPS_Unsafe_URL, net::RP_Unsafe_URL },
-    { 0 }
+    { net::kRPS_No_Referrer, static_cast<int16_t>(net::RP_No_Referrer) },
+    { net::kRPS_Origin, static_cast<int16_t>(net::RP_Origin) },
+    { net::kRPS_Origin_When_Cross_Origin, static_cast<int16_t>(net::RP_Origin_When_Crossorigin) },
+    { net::kRPS_No_Referrer_When_Downgrade, static_cast<int16_t>(net::RP_No_Referrer_When_Downgrade) },
+    { net::kRPS_Unsafe_URL, static_cast<int16_t>(net::RP_Unsafe_URL) },
+    { nullptr, 0 }
   };
   return aResult.ParseEnumValue(aString, kReferrerTable, false);
 }
 
 bool
 nsGenericHTMLElement::ParseFrameborderValue(const nsAString& aString,
                                             nsAttrValue& aResult)
 {
--- 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/nsIFormControl.h
+++ b/dom/html/nsIFormControl.h
@@ -33,24 +33,24 @@ enum FormControlsTypes {
 
   // Elements with different types, the value is used as a mask.
   // When changing the order, adding or removing elements, be sure to update
   // the static_assert checks accordingly.
   NS_FORM_BUTTON_ELEMENT = 0x40, // 0b01000000
   NS_FORM_INPUT_ELEMENT  = 0x80  // 0b10000000
 };
 
-enum ButtonElementTypes {
+enum ButtonElementTypes : uint8_t {
   NS_FORM_BUTTON_BUTTON = NS_FORM_BUTTON_ELEMENT + 1,
   NS_FORM_BUTTON_RESET,
   NS_FORM_BUTTON_SUBMIT,
   eButtonElementTypesMax
 };
 
-enum InputElementTypes {
+enum InputElementTypes : uint8_t {
   NS_FORM_INPUT_BUTTON = NS_FORM_INPUT_ELEMENT + 1,
   NS_FORM_INPUT_CHECKBOX,
   NS_FORM_INPUT_COLOR,
   NS_FORM_INPUT_DATE,
   NS_FORM_INPUT_EMAIL,
   NS_FORM_INPUT_FILE,
   NS_FORM_INPUT_HIDDEN,
   NS_FORM_INPUT_RESET,
--- 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/ipc/TabContext.cpp
+++ b/dom/ipc/TabContext.cpp
@@ -297,18 +297,18 @@ MaybeInvalidTabContext::MaybeInvalidTabC
 {
   bool isMozBrowserElement = false;
   bool isPrerendered = false;
   uint32_t containingAppId = NO_APP_ID;
   DocShellOriginAttributes originAttributes;
   nsAutoCString originSuffix;
   nsAutoCString signedPkgOriginNoSuffix;
   nsAutoString presentationURL;
-  UIStateChangeType showAccelerators;
-  UIStateChangeType showFocusRings;
+  UIStateChangeType showAccelerators = UIStateChangeType_NoChange;
+  UIStateChangeType showFocusRings = UIStateChangeType_NoChange;
 
   switch(aParams.type()) {
     case IPCTabContext::TPopupIPCTabContext: {
       const PopupIPCTabContext &ipcContext = aParams.get_PopupIPCTabContext();
 
       TabContext *context;
       if (ipcContext.opener().type() == PBrowserOrId::TPBrowserParent) {
         context = TabParent::GetFrom(ipcContext.opener().get_PBrowserParent());
--- 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/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -1001,17 +1001,17 @@ MediaRecorder::MediaRecorder(AudioNode& 
   // union stream in recorder session won't be able to copy data from the
   // stream of non-destination node. Create a pipe stream in this case.
   if (aSrcAudioNode.NumberOfOutputs() > 0) {
     AudioContext* ctx = aSrcAudioNode.Context();
     AudioNodeEngine* engine = new AudioNodeEngine(nullptr);
     AudioNodeStream::Flags flags =
       AudioNodeStream::EXTERNAL_OUTPUT |
       AudioNodeStream::NEED_MAIN_THREAD_FINISHED;
-    mPipeStream = AudioNodeStream::Create(ctx, engine, flags);
+    mPipeStream = AudioNodeStream::Create(ctx, engine, flags, ctx->Graph());
     AudioNodeStream* ns = aSrcAudioNode.GetStream();
     if (ns) {
       mInputPort =
         mPipeStream->AllocateInputPort(aSrcAudioNode.GetStream(),
                                        TRACK_ANY, TRACK_ANY,
                                        0, aSrcOutput);
     }
   }
--- 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/platforms/android/RemoteDataDecoder.cpp
+++ b/dom/media/platforms/android/RemoteDataDecoder.cpp
@@ -144,17 +144,17 @@ public:
       MOZ_ASSERT(ok);
 
       int32_t size;
       ok |= NS_SUCCEEDED(aInfo->Size(&size));
       MOZ_ASSERT(ok);
 
       NS_ENSURE_TRUE_VOID(ok);
 
-      if (size > 0) {
+      if (size > 0 && durationUs.value() > 0) {
         RefPtr<layers::Image> img =
           new SurfaceTextureImage(mDecoder->mSurfaceTexture.get(), mDecoder->mConfig.mDisplay,
                                   gl::OriginPos::BottomLeft);
 
         RefPtr<VideoData> v =
           VideoData::CreateFromImage(mDecoder->mConfig,
                                     offset,
                                     presentationTimeUs,
@@ -166,17 +166,16 @@ public:
                                                   mDecoder->mConfig.mDisplay.width,
                                                   mDecoder->mConfig.mDisplay.height));
 
         mDecoderCallback->Output(v);
       }
 
       if ((flags & MediaCodec::BUFFER_FLAG_END_OF_STREAM) != 0) {
         mDecoderCallback->DrainComplete();
-        return;
       }
     }
 
     friend class RemoteDataDecoder;
 
   private:
     RemoteVideoDecoder* mDecoder;
   };
@@ -218,16 +217,25 @@ public:
   }
 
   nsresult Flush() override
   {
     mInputDurations.Clear();
     return RemoteDataDecoder::Flush();
   }
 
+  nsresult Drain() override
+  {
+    nsresult res = RemoteDataDecoder::Drain();
+    NS_ENSURE_SUCCESS(res, res);
+
+    mInputDurations.Put(0);
+    return NS_OK;
+  }
+
   nsresult Input(MediaRawData* aSample) override
   {
     nsresult res = RemoteDataDecoder::Input(aSample);
     NS_ENSURE_SUCCESS(res, res);
 
     mInputDurations.Put(aSample->mDuration);
     return NS_OK;
   }
@@ -435,17 +443,17 @@ nsresult
 RemoteDataDecoder::Drain()
 {
   BufferInfo::LocalRef bufferInfo;
   nsresult rv = BufferInfo::New(&bufferInfo);
   NS_ENSURE_SUCCESS(rv, rv);
   bufferInfo->Set(0, 0, -1, MediaCodec::BUFFER_FLAG_END_OF_STREAM);
 
   mJavaDecoder->Input(nullptr, bufferInfo);
-  return NS_ERROR_FAILURE;
+  return NS_OK;
 }
 
 nsresult
 RemoteDataDecoder::Shutdown()
 {
   LOG("");
   MOZ_ASSERT(mJavaDecoder && mJavaCallbacks);
 
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -86,16 +86,17 @@ WMFVideoMFTManager::WMFVideoMFTManager(
   , mVideoStride(0)
   , mImageSize(aConfig.mImage)
   , mImageContainer(aImageContainer)
   , mDXVAEnabled(aDXVAEnabled)
   , mLayersBackend(aLayersBackend)
   , mNullOutputCount(0)
   , mGotValidOutputAfterNullOutput(false)
   , mGotExcessiveNullOutput(false)
+  , mIsValid(true)
   // mVideoStride, mVideoWidth, mVideoHeight, mUseHwAccel are initialized in
   // Init().
 {
   MOZ_COUNT_CTOR(WMFVideoMFTManager);
 
   // Need additional checks/params to check vp8/vp9
   if (MP4Decoder::IsH264(aConfig.mMimeType)) {
     mStreamType = H264;
@@ -366,18 +367,42 @@ WMFVideoMFTManager::InitializeDXVA(bool 
     NS_DispatchToMainThread(event, NS_DISPATCH_SYNC);
   }
   mDXVA2Manager = event->mDXVA2Manager;
 
   return mDXVA2Manager != nullptr;
 }
 
 bool
+WMFVideoMFTManager::ValidateVideoInfo()
+{
+  // The WMF H.264 decoder is documented to have a minimum resolution
+  // 48x48 pixels. We've observed the decoder working for output smaller than
+  // that, but on some output it hangs in IMFTransform::ProcessOutput(), so
+  // we just reject streams which are less than the documented minimum.
+  // https://msdn.microsoft.com/en-us/library/windows/desktop/dd797815(v=vs.85).aspx
+  static const int32_t MIN_H264_FRAME_DIMENSION = 48;
+  if (mStreamType == H264 &&
+      (mVideoInfo.mImage.width < MIN_H264_FRAME_DIMENSION ||
+       mVideoInfo.mImage.height < MIN_H264_FRAME_DIMENSION)) {
+    LogToBrowserConsole(NS_LITERAL_STRING(
+      "Can't decode H.264 stream with width or height less than 48 pixels."));
+    mIsValid = false;
+  }
+
+  return mIsValid;
+}
+
+bool
 WMFVideoMFTManager::Init()
 {
+  if (!ValidateVideoInfo()) {
+    return false;
+  }
+
   bool success = InitInternal(/* aForceD3D9 = */ false);
 
   if (success && mDXVA2Manager) {
     // If we had some failures but eventually made it work,
     // make sure we preserve the messages.
     if (mDXVA2Manager->IsD3D11()) {
       mDXVAFailureReason.Append(NS_LITERAL_CSTRING("Using D3D11 API"));
     } else {
@@ -479,16 +504,20 @@ WMFVideoMFTManager::SetDecoderMediaTypes
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   return mDecoder->SetMediaTypes(inputType, outputType);
 }
 
 HRESULT
 WMFVideoMFTManager::Input(MediaRawData* aSample)
 {
+  if (!mIsValid) {
+    return E_FAIL;
+  }
+
   if (!mDecoder) {
     // This can happen during shutdown.
     return E_FAIL;
   }
 
   HRESULT hr = mDecoder->CreateInputSample(aSample->Data(),
                                            uint32_t(aSample->Size()),
                                            aSample->mTime,
@@ -901,11 +930,12 @@ WMFVideoMFTManager::IsHardwareAccelerate
 }
 
 void
 WMFVideoMFTManager::ConfigurationChanged(const TrackInfo& aConfig)
 {
   MOZ_ASSERT(aConfig.GetAsVideoInfo());
   mVideoInfo = *aConfig.GetAsVideoInfo();
   mImageSize = mVideoInfo.mImage;
+  ValidateVideoInfo();
 }
 
 } // namespace mozilla
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.h
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h
@@ -46,16 +46,18 @@ public:
   {
     nsCString failureReason;
     return IsHardwareAccelerated(failureReason)
       ? "wmf hardware video decoder" : "wmf software video decoder";
   }
 
 private:
 
+  bool ValidateVideoInfo();
+
   bool InitializeDXVA(bool aForceD3D9);
 
   bool InitInternal(bool aForceD3D9);
 
   HRESULT ConfigureVideoFrameGeometry();
 
   HRESULT CreateBasicVideoFrame(IMFSample* aSample,
                                 int64_t aStreamOffset,
@@ -96,13 +98,14 @@ private:
   StreamType mStreamType;
 
   const GUID& GetMFTGUID();
   const GUID& GetMediaSubtypeGUID();
 
   uint32_t mNullOutputCount;
   bool mGotValidOutputAfterNullOutput;
   bool mGotExcessiveNullOutput;
+  bool mIsValid;
 };
 
 } // namespace mozilla
 
 #endif // WMFVideoMFTManager_h_
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -528,16 +528,30 @@ var gErrorTests = [
   { name:"bug504843.ogv", type:"video/ogg" },
   { name:"bug501279.ogg", type:"audio/ogg" },
   { name:"bug580982.webm", type:"video/webm" },
   { name:"bug603918.webm", type:"video/webm" },
   { name:"bug604067.webm", type:"video/webm" },
   { name:"bogus.duh", type:"bogus/duh" }
 ];
 
+function IsWindowsVistaOrLater() {
+  var re = /Windows NT (\d+.\d)/;
+  var winver = manifestNavigator().userAgent.match(re);
+  return winver && winver.length == 2 && parseFloat(winver[1]) >= 6.0;
+}
+
+// Windows' H.264 decoder cannot handle H.264 streams with resolution
+// less than 48x48 pixels. We refuse to play and error on such streams.
+if (IsWindowsVistaOrLater() &&
+    manifestVideo().canPlayType('video/mp4; codecs="avc1.42E01E"')) {
+  gErrorTests = gErrorTests.concat({name: "red-46x48.mp4", type:"video/mp4"},
+                                   {name: "red-48x46.mp4", type:"video/mp4"});
+}
+
 // These are files that have nontrivial duration and are useful for seeking within.
 var gSeekTests = [
   { name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
   { name:"audio.wav", type:"audio/x-wav", duration:0.031247 },
   { name:"seek.ogv", type:"video/ogg", duration:3.966 },
   { name:"320x240.ogv", type:"video/ogg", duration:0.266 },
   { name:"seek.webm", type:"video/webm", duration:3.966 },
   { name:"sine.webm", type:"audio/webm", duration:4.001 },
@@ -557,22 +571,16 @@ var gFastSeekTests = [
   // Note: Not all keyframes in the file are actually referenced in the Cues in this file.
   { name:"seek.webm", type:"video/webm", keyframes:[0, 0.8, 1.6, 2.4, 3.2]},
   // Note: the sync points are the points on both the audio and video streams
   // before the keyframes. You can't just assume that the keyframes are the sync
   // points, as the audio required for that sync point may be before the keyframe.
   { name:"bug516323.indexed.ogv", type:"video/ogg", keyframes:[0, 0.46, 3.06] },
 ];
 
-function IsWindows8OrLater() {
-  var re = /Windows NT (\d.\d)/;
-  var winver = manifestNavigator().userAgent.match(re);
-  return winver && winver.length == 2 && parseFloat(winver[1]) >= 6.2;
-}
-
 // These files are WebMs without cues. They're seekable within their buffered
 // ranges. If work renders WebMs fully seekable these files should be moved
 // into gSeekTests
 var gCuelessWebMTests = [
   { name:"no-cues.webm", type:"video/webm", duration:3.967 },
 ];
 
 // These are files that are non seekable, due to problems with the media,
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -486,16 +486,20 @@ support-files =
   r11025_s16_c1_trailing.wav^headers^
   r11025_u8_c1.wav
   r11025_u8_c1.wav^headers^
   r11025_u8_c1_trunc.wav
   r11025_u8_c1_trunc.wav^headers^
   r16000_u8_c1_list.wav
   r16000_u8_c1_list.wav^headers^
   reactivate_helper.html
+  red-46x48.mp4
+  red-46x48.mp4^headers^
+  red-48x46.mp4
+  red-48x46.mp4^headers^
   redirect.sjs
   referer.sjs
   region.vtt
   resolution-change.webm
   resolution-change.webm^headers^
   sample.3gp
   sample.3g2
   sample-fisbone-skeleton4.ogv
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0760cc1c165dc13a50cf0e8b85f75ac7efb5c6f7
GIT binary patch
literal 1548
zc$|GyL5mzk6t0<&U?3pEf<ZP=;(8EwX1jZ4C%Xd;ktH|>BVNowgtoe>db*jau9~Wv
z*_pklASwj$wm-m|;3)`ta1Vk9!9U=NpgAZ;qsc{t9GtxB+0D$ZCPi1juj+m8y?XCe
zH$n(!ZmJ8bBtmuMCCrG7X()9&L<l{R8O}lXk7UGw{Oa7<+3d?7uiifR^|1HF{`&X$
z@VUS4PNGg5H!xL(<FLJjP1I>^;me!b+ff*RqSpk%#<kb3zT9Zzm#*&slW_`)9i^v&
zXAVa}&}u|MxCxuNbGo~+vAet592bl$LCU5w{S6<bnL8<fqqHkjX}g$`l+ZZDhG%gL
zGoA`X2XWX9x&bC75mU?KVAARalQ3*y$>W?)upOm<E@N${U<&WVusCc6U<5BLiwS3m
z_ZWgjVo2HNaoE8$H%gKOOhfDp7oxC$wkBJQIskMi;{c98*q$nR9EIy)h%;hcqV1s2
zo-ubY)QQS6%U#@vu*(ftct=910m)&JEcUD@C|_&@xHMG^T1evjIf~M8BM6XSKNTZG
zrU_M269;PwC31!oCAa{hA)b>NBDsZPrHP&bE?67^CX8sGMVh1q@sU_zc$L>KFZ#Jl
z0V&PPq^~q+=bIW#2Yd>?<7hKDf{83je{{-APDd_o2e=CED{8pS!P?N|VYXgxXiQRr
zWeR2WS)~Q=AwRel*aN48?++gO)Z(Do0jPbLN|H(3*#=-8*Kr#c8d?U|11!Kb8NzMw
zy+!Z9eSVRD_#S#@_V3>}e~P|4|HCgghBv;xxAzwNp!Mq7+qYIfx&8Z{Z+||he{}Bi
zcMssY|0$IkgPD-yoS_rr%x~4KA^$8!?Ii2;`U-mNsKfI#q&@)rrW;f-&-~Y$kNx;K
z{~NanGpLqpoH+|}l?&?@7Ds+7+uFyH6$Aj5>~!u|s`>gi)uNFzVU9KagI#7`_aAVN
zluU5Xsdb@g8Gx0steh?%bB)b)s|+s6QW_UVM&KiS-?~(Q+_%oMCC>Z)pY@1R_{0O$
z1KE2d<Mg;Vo54E(uRAq{F3fJBi+zxv9bUVC?<wCCUoBLBa^;2n8akW*ap&f`x3aD(
z>v4?QQQ=qNwDjcu!?^;wy}7D>cd<v+65ls19Wm$I@rLA;^yAs((nGrp(ON90(J1Eq
ceg0FYyu(ZI7bnLBc!i9!%?^Ac%`gZb08m<M@&Et;
new file mode 100644
--- /dev/null
+++ b/dom/media/test/red-46x48.mp4^headers^
@@ -0,0 +1,1 @@
+Cache-Control: no-store
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d83de4027d11f07f6e76c02f797a540ab9f0eb1b
GIT binary patch
literal 1548
zc$|GyL5mzk6t0<&pb!vY!5}M?xE{ov+3ud%$?iZyWC_l}h!=AZp{=f}o-U@UtEReU
zc4jXshzdcx?GNxKc#t6I!955b1pk05g65zYjV6~Mc*x{c&u(URH7UCKeO2#!@6~&+
zx)DM+b5kQqtq`gsFJVSxOhaYbAwuY}%yJI8e-tAQ<k#oU&Sqczbou7NZ->1v_t$^G
zhtK_edlGfpxPhs*9Ea^KY@<$V3t!ya-j2cm6ul-8Hm<yO`Q=6%zjSp6n2b|U>}WHU
zJaae-f>t96!cExBoip8yjosbd=2$SUB`KQP_BVW#X6}>(jy6u{qU>TyQbOYpTb{)&
z%y=p_9mHWb=mwY+L{3W{2a{Gen1o>qD<0>3g3D0~=pr`d6infrSQdxP0F2;;m6&jr
zc#k1iB$gC?9)}%FbE_3ez%<0paw$a#Xlt^?r~^QUDh}WXgzf2q$5FT*hBzaoOH4Ts
z#xv#)h9=QjR&p0NBJ6St7T%H6dO&hmB#XUL3d$E70WNG6g9=5QKZhtBw~_z}_ER~s
zWSUT|3~{igP$FlED8K~}E%BVp62(g>R+^Y8V8P-DFk!^_EYc(u#7APn@+z-gF8aAk
z0cpdFq^}KV=bHvh2Yd>?<7hKDf{7A^KRV?Frz01)16&376}7y~!P?T~LAG9RX-ra!
zRSISGS)~H_kRMzN?19tL_XiJsYH`r)05m>KCCMc2Yy&7AH*p&a11*E=0T$qz4B<BT
z-lBKlKEKF6d=EW6yLb2c&(Zgf|M=^*;k9q>?7hW4XuZ1j_Knp~ZvJuWyI&6KAD#Q+
z-2=Gpe<`iUU?$Z#XXwN@^LsUG$UlowJIOk|zJwk*>hL@TsSg0Z=>}EIGynDGV?R31
z|HchqHml_tXRZXf%4O*m7Ds+7+uFy92?78sb~^V<)qMTiYSGA<w8t9%!7eke`VY8A
z3MRSd)Vk2L48Y1*RZf?WxyI(YRR$MjDUI_ZEAbKjw{)olxnH`HEpguW|E!0U!YAHD
zJ&?VJGER>RvzfO8uRAq{&d+Y33w@BE9bUQj`IEjUzFMgM#L5f%HFP%r^VaosZ&kXg
ztj95GM}=R7)6$ds59SK!_U5Yk?ZqC|OMKtBbi|x*#~X@Q(vN4COAqa`#2C4pMnlZ|
c`~0U)dxy`!Uz{8l;1x2?HaqZ*G{Ydg4<15mwg3PC
new file mode 100644
--- /dev/null
+++ b/dom/media/test/red-48x46.mp4^headers^
@@ -0,0 +1,1 @@
+Cache-Control: no-store
--- a/dom/media/webaudio/AnalyserNode.cpp
+++ b/dom/media/webaudio/AnalyserNode.cpp
@@ -108,17 +108,18 @@ AnalyserNode::AnalyserNode(AudioContext*
               ChannelInterpretation::Speakers)
   , mAnalysisBlock(2048)
   , mMinDecibels(-100.)
   , mMaxDecibels(-30.)
   , mSmoothingTimeConstant(.8)
 {
   mStream = AudioNodeStream::Create(aContext,
                                     new AnalyserNodeEngine(this),
-                                    AudioNodeStream::NO_STREAM_FLAGS);
+                                    AudioNodeStream::NO_STREAM_FLAGS,
+                                    aContext->Graph());
 
   // Enough chunks must be recorded to handle the case of fftSize being
   // increased to maximum immediately before getFloatTimeDomainData() is
   // called, for example.
   Unused << mChunks.SetLength(CHUNK_COUNT, fallible);
 
   AllocateBuffer();
 }
--- a/dom/media/webaudio/AudioBufferSourceNode.cpp
+++ b/dom/media/webaudio/AudioBufferSourceNode.cpp
@@ -597,17 +597,18 @@ AudioBufferSourceNode::AudioBufferSource
   // mOffset and mDuration are initialized in Start().
   , mPlaybackRate(new AudioParam(this, PLAYBACKRATE, 1.0f, "playbackRate"))
   , mDetune(new AudioParam(this, DETUNE, 0.0f, "detune"))
   , mLoop(false)
   , mStartCalled(false)
 {
   AudioBufferSourceNodeEngine* engine = new AudioBufferSourceNodeEngine(this, aContext->Destination());
   mStream = AudioNodeStream::Create(aContext, engine,
-                                    AudioNodeStream::NEED_MAIN_THREAD_FINISHED);
+                                    AudioNodeStream::NEED_MAIN_THREAD_FINISHED,
+                                    aContext->Graph());
   engine->SetSourceStream(mStream);
   mStream->AddMainThreadListener(this);
 }
 
 AudioBufferSourceNode::~AudioBufferSourceNode()
 {
 }
 
--- a/dom/media/webaudio/AudioNodeStream.cpp
+++ b/dom/media/webaudio/AudioNodeStream.cpp
@@ -66,30 +66,30 @@ AudioNodeStream::DestroyImpl()
   ProcessedMediaStream::DestroyImpl();
 }
 
 /* static */ already_AddRefed<AudioNodeStream>
 AudioNodeStream::Create(AudioContext* aCtx, AudioNodeEngine* aEngine,
                         Flags aFlags, MediaStreamGraph* aGraph)
 {
   MOZ_ASSERT(NS_IsMainThread());
+  MOZ_RELEASE_ASSERT(aGraph);
 
   // MediaRecorders use an AudioNodeStream, but no AudioNode
   AudioNode* node = aEngine->NodeMainThread();
-  MediaStreamGraph* graph = aGraph ? aGraph : aCtx->Graph();
 
   RefPtr<AudioNodeStream> stream =
-    new AudioNodeStream(aEngine, aFlags, graph->GraphRate());
+    new AudioNodeStream(aEngine, aFlags, aGraph->GraphRate());
   stream->mSuspendedCount += aCtx->ShouldSuspendNewStream();
   if (node) {
     stream->SetChannelMixingParametersImpl(node->ChannelCount(),
                                            node->ChannelCountModeValue(),
                                            node->ChannelInterpretationValue());
   }
-  graph->AddStream(stream);
+  aGraph->AddStream(stream);
   return stream.forget();
 }
 
 size_t
 AudioNodeStream::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
 {
   size_t amount = 0;
 
--- a/dom/media/webaudio/AudioNodeStream.h
+++ b/dom/media/webaudio/AudioNodeStream.h
@@ -57,23 +57,22 @@ public:
     // Internal AudioNodeStreams can only pass their output to another
     // AudioNode, whereas external AudioNodeStreams can pass their output
     // to other ProcessedMediaStreams or hardware audio output.
     EXTERNAL_OUTPUT = 1U << 2,
   };
   /**
    * Create a stream that will process audio for an AudioNode.
    * Takes ownership of aEngine.
-   * If aGraph is non-null, use that as the MediaStreamGraph, otherwise use
-   * aCtx's graph. aGraph is only non-null when called for AudioDestinationNode
-   * since the context's graph hasn't been set up in that case.
+   * aGraph is required and equals the graph of aCtx in most cases. An exception
+   * is AudioDestinationNode where the context's graph hasn't been set up yet.
    */
   static already_AddRefed<AudioNodeStream>
   Create(AudioContext* aCtx, AudioNodeEngine* aEngine, Flags aKind,
-         MediaStreamGraph* aGraph = nullptr);
+         MediaStreamGraph* aGraph);
 
 protected:
   /**
    * Transfers ownership of aEngine to the new AudioNodeStream.
    */
   AudioNodeStream(AudioNodeEngine* aEngine,
                   Flags aFlags,
                   TrackRate aSampleRate);
--- a/dom/media/webaudio/AudioParam.cpp
+++ b/dom/media/webaudio/AudioParam.cpp
@@ -86,17 +86,18 @@ AudioParam::Stream()
 {
   if (mStream) {
     return mStream;
   }
 
   AudioNodeEngine* engine = new AudioNodeEngine(nullptr);
   RefPtr<AudioNodeStream> stream =
     AudioNodeStream::Create(mNode->Context(), engine,
-                            AudioNodeStream::NO_STREAM_FLAGS);
+                            AudioNodeStream::NO_STREAM_FLAGS,
+                            mNode->Context()->Graph());
 
   // Force the input to have only one channel, and make it down-mix using
   // the speaker rules if needed.
   stream->SetChannelMixingParametersImpl(1, ChannelCountMode::Explicit, ChannelInterpretation::Speakers);
   // Mark as an AudioParam helper stream
   stream->SetAudioParamHelperStream();
 
   mStream = stream.forget();
--- a/dom/media/webaudio/BiquadFilterNode.cpp
+++ b/dom/media/webaudio/BiquadFilterNode.cpp
@@ -254,17 +254,18 @@ BiquadFilterNode::BiquadFilterNode(Audio
                               350.f, "frequency"))
   , mDetune(new AudioParam(this, BiquadFilterNodeEngine::DETUNE, 0.f, "detune"))
   , mQ(new AudioParam(this, BiquadFilterNodeEngine::Q, 1.f, "Q"))
   , mGain(new AudioParam(this, BiquadFilterNodeEngine::GAIN, 0.f, "gain"))
 {
   uint64_t windowID = aContext->GetParentObject()->WindowID();
   BiquadFilterNodeEngine* engine = new BiquadFilterNodeEngine(this, aContext->Destination(), windowID);
   mStream = AudioNodeStream::Create(aContext, engine,
-                                    AudioNodeStream::NO_STREAM_FLAGS);
+                                    AudioNodeStream::NO_STREAM_FLAGS,
+                                    aContext->Graph());
 }
 
 BiquadFilterNode::~BiquadFilterNode()
 {
 }
 
 size_t
 BiquadFilterNode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
--- a/dom/media/webaudio/ChannelMergerNode.cpp
+++ b/dom/media/webaudio/ChannelMergerNode.cpp
@@ -66,17 +66,18 @@ ChannelMergerNode::ChannelMergerNode(Aud
   : AudioNode(aContext,
               1,
               ChannelCountMode::Explicit,
               ChannelInterpretation::Speakers)
   , mInputCount(aInputCount)
 {
   mStream = AudioNodeStream::Create(aContext,
                                     new ChannelMergerNodeEngine(this),
-                                    AudioNodeStream::NO_STREAM_FLAGS);
+                                    AudioNodeStream::NO_STREAM_FLAGS,
+                                    aContext->Graph());
 }
 
 ChannelMergerNode::~ChannelMergerNode()
 {
 }
 
 JSObject*
 ChannelMergerNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
--- a/dom/media/webaudio/ChannelSplitterNode.cpp
+++ b/dom/media/webaudio/ChannelSplitterNode.cpp
@@ -57,17 +57,18 @@ ChannelSplitterNode::ChannelSplitterNode
   : AudioNode(aContext,
               2,
               ChannelCountMode::Max,
               ChannelInterpretation::Speakers)
   , mOutputCount(aOutputCount)
 {
   mStream = AudioNodeStream::Create(aContext,
                                     new ChannelSplitterNodeEngine(this),
-                                    AudioNodeStream::NO_STREAM_FLAGS);
+                                    AudioNodeStream::NO_STREAM_FLAGS,
+                                    aContext->Graph());
 }
 
 ChannelSplitterNode::~ChannelSplitterNode()
 {
 }
 
 JSObject*
 ChannelSplitterNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
--- a/dom/media/webaudio/ConvolverNode.cpp