diff --git a/accessible/xul/XULTreeAccessible.cpp b/accessible/xul/XULTreeAccessible.cpp index 512c9a37bcbd..b8f7e8408031 100644 --- a/accessible/xul/XULTreeAccessible.cpp +++ b/accessible/xul/XULTreeAccessible.cpp @@ -124,7 +124,6 @@ XULTreeAccessible::Value(nsString& aValue) return; int32_t currentIndex; - nsCOMPtr selectItem; selection->GetCurrentIndex(¤tIndex); if (currentIndex >= 0) { nsCOMPtr keyCol; diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index 6fd657e34ca8..093556fa0579 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -403,9 +403,6 @@ 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); diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index 423222be85f8..d00724fab7b9 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -170,7 +170,6 @@ #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 @@ -363,8 +362,6 @@ @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 diff --git a/browser/base/content/abouthome/aboutHome.css b/browser/base/content/abouthome/aboutHome.css index 1e259330cf7f..7f46a7e5911e 100644 --- a/browser/base/content/abouthome/aboutHome.css +++ b/browser/base/content/abouthome/aboutHome.css @@ -107,6 +107,7 @@ a { #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; @@ -115,7 +116,6 @@ a { 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; @@ -132,7 +132,6 @@ a { #searchText + #searchSubmit:hover, #searchText[autofocus] + #searchSubmit { border-color: #59b5fc #45a3e7 #3294d5; - color: white; } #searchText:focus + #searchSubmit, diff --git a/browser/base/content/abouthome/aboutHome.xhtml b/browser/base/content/abouthome/aboutHome.xhtml index 655f64b567c3..c6f9177dbc19 100644 --- a/browser/base/content/abouthome/aboutHome.xhtml +++ b/browser/base/content/abouthome/aboutHome.xhtml @@ -44,8 +44,8 @@ - +
diff --git a/browser/base/content/newtab/newTab.css b/browser/base/content/newtab/newTab.css index 49102bf36412..2b601995858f 100644 --- a/browser/base/content/newtab/newTab.css +++ b/browser/base/content/newtab/newTab.css @@ -399,6 +399,7 @@ input[type=button] { #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; @@ -407,7 +408,6 @@ input[type=button] { 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; @@ -423,7 +423,6 @@ input[type=button] { #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, diff --git a/browser/base/content/newtab/newTab.xhtml b/browser/base/content/newtab/newTab.xhtml index f9eb8b2a79a7..03d14c02d0fe 100644 --- a/browser/base/content/newtab/newTab.xhtml +++ b/browser/base/content/newtab/newTab.xhtml @@ -71,8 +71,8 @@
- +
diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index a27decbce95c..bcb0b9444c2f 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -2635,45 +2635,6 @@ ContentPermissionPrompt.prototype = { "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"); @@ -2738,8 +2699,7 @@ ContentPermissionPrompt.prototype = { 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. @@ -2782,11 +2742,6 @@ ContentPermissionPrompt.prototype = { case "desktop-notification": this._promptWebNotifications(request); break; - case "flyweb-publish-server": - if (AppConstants.NIGHTLY_BUILD) { - this._promptFlyWebPublishServer(request); - } - break; } }, diff --git a/browser/config/tooltool-manifests/linux32/releng.manifest b/browser/config/tooltool-manifests/linux32/releng.manifest index 7363ba9be367..7580df8f8e23 100644 --- a/browser/config/tooltool-manifests/linux32/releng.manifest +++ b/browser/config/tooltool-manifests/linux32/releng.manifest @@ -16,9 +16,9 @@ "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 diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 51652fa01c8a..936e432bae96 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -190,7 +190,6 @@ @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 @@ -531,8 +530,6 @@ @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 diff --git a/browser/locales/en-US/chrome/browser/browser.dtd b/browser/locales/en-US/chrome/browser/browser.dtd index 519f9fda2acf..8042f717b0a5 100644 --- a/browser/locales/en-US/chrome/browser/browser.dtd +++ b/browser/locales/en-US/chrome/browser/browser.dtd @@ -427,11 +427,11 @@ These should match what Safari and other Apple applications use on OS X Lion. -- - + - + - - - Test for Bug 815105 - - - - -Mozilla Bug 815105 -

- -
-
-
-
- - - diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp index 4d67d0e6da0b..1015bcff3c5a 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.cpp +++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp @@ -318,10 +318,10 @@ nsNPAPIPluginInstance::GetDOMWindow() if (!mOwner) return nullptr; - RefPtr deathGrip(mOwner); + RefPtr kungFuDeathGrip(mOwner); nsCOMPtr doc; - mOwner->GetDocument(getter_AddRefs(doc)); + kungFuDeathGrip->GetDocument(getter_AddRefs(doc)); if (!doc) return nullptr; diff --git a/dom/smil/nsSMILAnimationController.cpp b/dom/smil/nsSMILAnimationController.cpp index 965143c15dd0..f447509311bb 100644 --- a/dom/smil/nsSMILAnimationController.cpp +++ b/dom/smil/nsSMILAnimationController.cpp @@ -424,9 +424,9 @@ nsSMILAnimationController::DoSample(bool aSkipUnchangedContainers) return; } - nsCOMPtr kungFuDeathGrip(mDocument); // keeps 'this' alive too + nsCOMPtr document(mDocument); // keeps 'this' alive too if (isStyleFlushNeeded) { - mDocument->FlushPendingNotifications(Flush_Style); + document->FlushPendingNotifications(Flush_Style); } // WARNING: diff --git a/dom/speakermanager/tests/test_speakermanager.html b/dom/speakermanager/tests/test_speakermanager.html index 18cbc098fbfd..509df5e84a0c 100644 --- a/dom/speakermanager/tests/test_speakermanager.html +++ b/dom/speakermanager/tests/test_speakermanager.html @@ -37,7 +37,7 @@ navigator.appVersion.indexOf("Android") == -1) { testObject(); } else { - ok(true, "mozAlarms on Firefox OS only."); + ok(true, "MozSpeakerManager on Firefox OS only."); SimpleTest.finish(); } } diff --git a/dom/svg/SVGScriptElement.cpp b/dom/svg/SVGScriptElement.cpp index acf31e911c3a..ffc049c212ca 100644 --- a/dom/svg/SVGScriptElement.cpp +++ b/dom/svg/SVGScriptElement.cpp @@ -154,8 +154,12 @@ SVGScriptElement::FreezeUriAsyncDefer() mStringAttributes[XLINK_HREF].GetAnimValue(src, this); } - nsCOMPtr baseURI = GetBaseURI(); - NS_NewURI(getter_AddRefs(mUri), src, nullptr, baseURI); + // Empty src should be treated as invalid URL. + if (!src.IsEmpty()) { + nsCOMPtr baseURI = GetBaseURI(); + NS_NewURI(getter_AddRefs(mUri), src, nullptr, baseURI); + } + // At this point mUri will be null for invalid URLs. mExternal = true; } diff --git a/dom/webidl/AlarmsManager.webidl b/dom/webidl/AlarmsManager.webidl deleted file mode 100644 index 184fdb741a8b..000000000000 --- a/dom/webidl/AlarmsManager.webidl +++ /dev/null @@ -1,19 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * https://wiki.mozilla.org/WebAPI/AlarmAPI - */ - -[NavigatorProperty="mozAlarms", - JSImplementation="@mozilla.org/alarmsManager;1", - Pref="dom.mozAlarms.enabled", - ChromeOnly] -interface AlarmsManager { - DOMRequest getAll(); - [UnsafeInPrerendering] - DOMRequest add(any date, DOMString respectTimezone, optional any data); - [UnsafeInPrerendering] - void remove(unsigned long id); -}; diff --git a/dom/webidl/AnalyserNode.webidl b/dom/webidl/AnalyserNode.webidl index 035047919483..5b4be8822810 100644 --- a/dom/webidl/AnalyserNode.webidl +++ b/dom/webidl/AnalyserNode.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface AnalyserNode : AudioNode { // Real-time frequency-domain data diff --git a/dom/webidl/AudioBuffer.webidl b/dom/webidl/AudioBuffer.webidl index 3c3422cdbe61..ab45268f3921 100644 --- a/dom/webidl/AudioBuffer.webidl +++ b/dom/webidl/AudioBuffer.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface AudioBuffer { readonly attribute float sampleRate; diff --git a/dom/webidl/AudioBufferSourceNode.webidl b/dom/webidl/AudioBufferSourceNode.webidl index 01d8d2975009..f74a968ec212 100644 --- a/dom/webidl/AudioBufferSourceNode.webidl +++ b/dom/webidl/AudioBufferSourceNode.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface AudioBufferSourceNode : AudioNode { attribute AudioBuffer? buffer; diff --git a/dom/webidl/AudioContext.webidl b/dom/webidl/AudioContext.webidl index f08902319c9f..0079817f2bae 100644 --- a/dom/webidl/AudioContext.webidl +++ b/dom/webidl/AudioContext.webidl @@ -24,7 +24,8 @@ dictionary PeriodicWaveConstraints { }; [Constructor, - Constructor(AudioChannel audioChannelType)] + Constructor(AudioChannel audioChannelType), + Pref="dom.webaudio.enabled"] interface AudioContext : EventTarget { readonly attribute AudioDestinationNode destination; diff --git a/dom/webidl/AudioDestinationNode.webidl b/dom/webidl/AudioDestinationNode.webidl index 166f5a2a86c2..e5c6db868f9e 100644 --- a/dom/webidl/AudioDestinationNode.webidl +++ b/dom/webidl/AudioDestinationNode.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface AudioDestinationNode : AudioNode { readonly attribute unsigned long maxChannelCount; diff --git a/dom/webidl/AudioListener.webidl b/dom/webidl/AudioListener.webidl index 669f5875706d..8970e6b989e6 100644 --- a/dom/webidl/AudioListener.webidl +++ b/dom/webidl/AudioListener.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface AudioListener { // same as OpenAL (default 1) diff --git a/dom/webidl/AudioNode.webidl b/dom/webidl/AudioNode.webidl index 600ed05e7a10..3d4778d61669 100644 --- a/dom/webidl/AudioNode.webidl +++ b/dom/webidl/AudioNode.webidl @@ -21,6 +21,7 @@ enum ChannelInterpretation { "discrete" }; +[Pref="dom.webaudio.enabled"] interface AudioNode : EventTarget { [Throws] diff --git a/dom/webidl/AudioParam.webidl b/dom/webidl/AudioParam.webidl index b27997cfa878..ee5514f34f24 100644 --- a/dom/webidl/AudioParam.webidl +++ b/dom/webidl/AudioParam.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface AudioParam { attribute float value; diff --git a/dom/webidl/AudioProcessingEvent.webidl b/dom/webidl/AudioProcessingEvent.webidl index c450ff496853..8cf3d9cc2272 100644 --- a/dom/webidl/AudioProcessingEvent.webidl +++ b/dom/webidl/AudioProcessingEvent.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface AudioProcessingEvent : Event { readonly attribute double playbackTime; diff --git a/dom/webidl/BiquadFilterNode.webidl b/dom/webidl/BiquadFilterNode.webidl index d1f964a918ae..7a9efb77de80 100644 --- a/dom/webidl/BiquadFilterNode.webidl +++ b/dom/webidl/BiquadFilterNode.webidl @@ -21,6 +21,7 @@ enum BiquadFilterType { "allpass" }; +[Pref="dom.webaudio.enabled"] interface BiquadFilterNode : AudioNode { attribute BiquadFilterType type; diff --git a/dom/webidl/ChannelMergerNode.webidl b/dom/webidl/ChannelMergerNode.webidl index 28424a3c4a28..a1a7148f2c0f 100644 --- a/dom/webidl/ChannelMergerNode.webidl +++ b/dom/webidl/ChannelMergerNode.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface ChannelMergerNode : AudioNode { }; diff --git a/dom/webidl/ChannelSplitterNode.webidl b/dom/webidl/ChannelSplitterNode.webidl index d30678e3d0d3..c7c0be4983a2 100644 --- a/dom/webidl/ChannelSplitterNode.webidl +++ b/dom/webidl/ChannelSplitterNode.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface ChannelSplitterNode : AudioNode { }; diff --git a/dom/webidl/ConvolverNode.webidl b/dom/webidl/ConvolverNode.webidl index df972d9d92ee..b49af04002c1 100644 --- a/dom/webidl/ConvolverNode.webidl +++ b/dom/webidl/ConvolverNode.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface ConvolverNode : AudioNode { [SetterThrows] diff --git a/dom/webidl/DelayNode.webidl b/dom/webidl/DelayNode.webidl index f2c15a1a52bc..6a8fb5c3ae71 100644 --- a/dom/webidl/DelayNode.webidl +++ b/dom/webidl/DelayNode.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface DelayNode : AudioNode { readonly attribute AudioParam delayTime; diff --git a/dom/webidl/DynamicsCompressorNode.webidl b/dom/webidl/DynamicsCompressorNode.webidl index 4d186fb8c547..dc0e46f63a94 100644 --- a/dom/webidl/DynamicsCompressorNode.webidl +++ b/dom/webidl/DynamicsCompressorNode.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface DynamicsCompressorNode : AudioNode { readonly attribute AudioParam threshold; // in Decibels diff --git a/dom/webidl/GainNode.webidl b/dom/webidl/GainNode.webidl index a4198ea2764e..143325c70fdb 100644 --- a/dom/webidl/GainNode.webidl +++ b/dom/webidl/GainNode.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface GainNode : AudioNode { readonly attribute AudioParam gain; diff --git a/dom/webidl/IIRFilterNode.webidl b/dom/webidl/IIRFilterNode.webidl index 4442e28ef144..a1164b6ae121 100644 --- a/dom/webidl/IIRFilterNode.webidl +++ b/dom/webidl/IIRFilterNode.webidl @@ -9,6 +9,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface IIRFilterNode : AudioNode { void getFrequencyResponse(Float32Array frequencyHz, Float32Array magResponse, Float32Array phaseResponse); }; diff --git a/dom/webidl/MediaElementAudioSourceNode.webidl b/dom/webidl/MediaElementAudioSourceNode.webidl index d27d395a6877..f1ac17473548 100644 --- a/dom/webidl/MediaElementAudioSourceNode.webidl +++ b/dom/webidl/MediaElementAudioSourceNode.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface MediaElementAudioSourceNode : AudioNode { }; diff --git a/dom/webidl/MediaStreamAudioDestinationNode.webidl b/dom/webidl/MediaStreamAudioDestinationNode.webidl index 9b1d49705f97..aafff964eea4 100644 --- a/dom/webidl/MediaStreamAudioDestinationNode.webidl +++ b/dom/webidl/MediaStreamAudioDestinationNode.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface MediaStreamAudioDestinationNode : AudioNode { readonly attribute MediaStream stream; diff --git a/dom/webidl/MediaStreamAudioSourceNode.webidl b/dom/webidl/MediaStreamAudioSourceNode.webidl index c09c1eb9baed..e717ef2543f1 100644 --- a/dom/webidl/MediaStreamAudioSourceNode.webidl +++ b/dom/webidl/MediaStreamAudioSourceNode.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface MediaStreamAudioSourceNode : AudioNode { }; diff --git a/dom/webidl/OfflineAudioCompletionEvent.webidl b/dom/webidl/OfflineAudioCompletionEvent.webidl index 6e731508c7a7..0203bfa10193 100644 --- a/dom/webidl/OfflineAudioCompletionEvent.webidl +++ b/dom/webidl/OfflineAudioCompletionEvent.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface OfflineAudioCompletionEvent : Event { readonly attribute AudioBuffer renderedBuffer; diff --git a/dom/webidl/OfflineAudioContext.webidl b/dom/webidl/OfflineAudioContext.webidl index 97c9e25db9ce..51dc683f7491 100644 --- a/dom/webidl/OfflineAudioContext.webidl +++ b/dom/webidl/OfflineAudioContext.webidl @@ -10,7 +10,8 @@ * liability, trademark and document use rules apply. */ -[Constructor(unsigned long numberOfChannels, unsigned long length, float sampleRate)] +[Constructor(unsigned long numberOfChannels, unsigned long length, float sampleRate), +Pref="dom.webaudio.enabled"] interface OfflineAudioContext : AudioContext { [Throws] diff --git a/dom/webidl/OscillatorNode.webidl b/dom/webidl/OscillatorNode.webidl index 531a0e465ea1..268897080960 100644 --- a/dom/webidl/OscillatorNode.webidl +++ b/dom/webidl/OscillatorNode.webidl @@ -18,6 +18,7 @@ enum OscillatorType { "custom" }; +[Pref="dom.webaudio.enabled"] interface OscillatorNode : AudioNode { [SetterThrows] diff --git a/dom/webidl/PannerNode.webidl b/dom/webidl/PannerNode.webidl index b771fc4175b0..86b8928524b9 100644 --- a/dom/webidl/PannerNode.webidl +++ b/dom/webidl/PannerNode.webidl @@ -21,6 +21,7 @@ enum DistanceModelType { "exponential" }; +[Pref="dom.webaudio.enabled"] interface PannerNode : AudioNode { // Default for stereo is equalpower diff --git a/dom/webidl/PeriodicWave.webidl b/dom/webidl/PeriodicWave.webidl index faa940c94830..c118274a240b 100644 --- a/dom/webidl/PeriodicWave.webidl +++ b/dom/webidl/PeriodicWave.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface PeriodicWave { }; diff --git a/dom/webidl/ScriptProcessorNode.webidl b/dom/webidl/ScriptProcessorNode.webidl index 4cd34bbc5d10..81c02443f170 100644 --- a/dom/webidl/ScriptProcessorNode.webidl +++ b/dom/webidl/ScriptProcessorNode.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface ScriptProcessorNode : AudioNode { attribute EventHandler onaudioprocess; diff --git a/dom/webidl/StereoPannerNode.webidl b/dom/webidl/StereoPannerNode.webidl index 1ee3fa95377c..f84c8310b7b2 100644 --- a/dom/webidl/StereoPannerNode.webidl +++ b/dom/webidl/StereoPannerNode.webidl @@ -10,6 +10,7 @@ * liability, trademark and document use rules apply. */ +[Pref="dom.webaudio.enabled"] interface StereoPannerNode : AudioNode { readonly attribute AudioParam pan; }; diff --git a/dom/webidl/WaveShaperNode.webidl b/dom/webidl/WaveShaperNode.webidl index a2b4a9569a16..ac30c94dcc94 100644 --- a/dom/webidl/WaveShaperNode.webidl +++ b/dom/webidl/WaveShaperNode.webidl @@ -16,6 +16,7 @@ enum OverSampleType { "4x" }; +[Pref="dom.webaudio.enabled"] interface WaveShaperNode : AudioNode { [SetterThrows] diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 38e0d6dc37f0..8458aa2e862a 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -921,11 +921,6 @@ if CONFIG['MOZ_B2G']: 'MozApplicationEvent.webidl' ] -if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android': - WEBIDL_FILES += [ - 'AlarmsManager.webidl', - ] - if CONFIG['ACCESSIBILITY']: WEBIDL_FILES += [ 'AccessibleNode.webidl', diff --git a/dom/workers/WorkerNavigator.h b/dom/workers/WorkerNavigator.h index 3a1a3e970e54..64338e46b1d8 100644 --- a/dom/workers/WorkerNavigator.h +++ b/dom/workers/WorkerNavigator.h @@ -11,6 +11,7 @@ #include "RuntimeService.h" #include "nsString.h" #include "nsWrapperCache.h" +#include "mozilla/dom/StorageManager.h" namespace mozilla { namespace dom { diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 51fee89c01a7..ece99b6dace8 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -2540,7 +2540,7 @@ WorkerPrivateParent::Freeze(nsPIDOMWindowInner* aWindow) // outlives this call. RefPtr kungFuDeathGrip = mSharedWorkers[i]; - mSharedWorkers[i]->Freeze(); + kungFuDeathGrip->Freeze(); } else { MOZ_ASSERT_IF(mSharedWorkers[i]->GetOwner() && aWindow, !SameCOMIdentity(mSharedWorkers[i]->GetOwner(), @@ -2604,7 +2604,7 @@ WorkerPrivateParent::Thaw(nsPIDOMWindowInner* aWindow) // outlives this call. RefPtr kungFuDeathGrip = mSharedWorkers[i]; - mSharedWorkers[i]->Thaw(); + kungFuDeathGrip->Thaw(); anyRunning = true; } else { MOZ_ASSERT_IF(mSharedWorkers[i]->GetOwner() && aWindow, diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp index 6568dcf4e020..32b251bd9d59 100644 --- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -3953,4 +3953,4 @@ RequestHeaders::CharsetIterator::Next() } } // dom namespace -} // mozilla namespaceo +} // mozilla namespace diff --git a/editor/libeditor/EditorEventListener.cpp b/editor/libeditor/EditorEventListener.cpp index 55b049636d87..97de9adb3c80 100644 --- a/editor/libeditor/EditorEventListener.cpp +++ b/editor/libeditor/EditorEventListener.cpp @@ -354,6 +354,7 @@ EditorEventListener::HandleEvent(nsIDOMEvent* aEvent) NS_ENSURE_TRUE(mEditorBase, NS_ERROR_FAILURE); nsCOMPtr kungFuDeathGrip = mEditorBase; + Unused << kungFuDeathGrip; // mEditorBase is not referred to in this function WidgetEvent* internalEvent = aEvent->WidgetEventPtr(); diff --git a/editor/libeditor/HTMLAbsPositionEditor.cpp b/editor/libeditor/HTMLAbsPositionEditor.cpp index bab501c1207e..1f6bd9a5aa36 100644 --- a/editor/libeditor/HTMLAbsPositionEditor.cpp +++ b/editor/libeditor/HTMLAbsPositionEditor.cpp @@ -70,12 +70,12 @@ HTMLEditor::AbsolutePositionSelection(bool aEnabled) EditAction::removeAbsolutePosition); bool cancel, handled; // Protect the edit rules object from dying - nsCOMPtr kungFuDeathGrip(mRules); - nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); + nsCOMPtr rules(mRules); + nsresult res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled); if (NS_FAILED(res) || cancel) return res; - return mRules->DidDoAction(selection, &ruleInfo, res); + return rules->DidDoAction(selection, &ruleInfo, res); } NS_IMETHODIMP @@ -176,12 +176,12 @@ HTMLEditor::RelativeChangeZIndex(int32_t aChange) EditAction::increaseZIndex); bool cancel, handled; // Protect the edit rules object from dying - nsCOMPtr kungFuDeathGrip(mRules); - nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); + nsCOMPtr rules(mRules); + nsresult res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled); if (cancel || NS_FAILED(res)) return res; - return mRules->DidDoAction(selection, &ruleInfo, res); + return rules->DidDoAction(selection, &ruleInfo, res); } NS_IMETHODIMP diff --git a/editor/libeditor/HTMLEditRules.cpp b/editor/libeditor/HTMLEditRules.cpp index 39b365ef01db..8c6bda1859e9 100644 --- a/editor/libeditor/HTMLEditRules.cpp +++ b/editor/libeditor/HTMLEditRules.cpp @@ -297,7 +297,7 @@ HTMLEditRules::BeforeEdit(EditAction action, } NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); AutoLockRulesSniffing lockIt(this); mDidExplicitlySetInterline = false; @@ -311,7 +311,7 @@ HTMLEditRules::BeforeEdit(EditAction action, // Remember where our selection was before edit action took place: // Get selection - RefPtr selection = mHTMLEditor->GetSelection(); + RefPtr selection = htmlEditor->GetSelection(); // Get the selection location if (!selection->RangeCount()) { @@ -325,7 +325,7 @@ HTMLEditRules::BeforeEdit(EditAction action, nsCOMPtr selEndNode = mRangeItem->endNode; // Register with range updater to track this as we perturb the doc - (mHTMLEditor->mRangeUpdater).RegisterRangeItem(mRangeItem); + htmlEditor->mRangeUpdater.RegisterRangeItem(mRangeItem); // Clear deletion state bool mDidDeleteSelection = false; @@ -352,7 +352,7 @@ HTMLEditRules::BeforeEdit(EditAction action, } // Stabilize the document against contenteditable count changes - nsCOMPtr doc = mHTMLEditor->GetDOMDocument(); + nsCOMPtr doc = htmlEditor->GetDOMDocument(); NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED); nsCOMPtr htmlDoc = do_QueryInterface(doc); NS_ENSURE_TRUE(htmlDoc, NS_ERROR_FAILURE); @@ -379,7 +379,7 @@ HTMLEditRules::AfterEdit(EditAction action, } NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); AutoLockRulesSniffing lockIt(this); @@ -391,11 +391,11 @@ HTMLEditRules::AfterEdit(EditAction action, rv = AfterEditInner(action, aDirection); // Free up selectionState range item - (mHTMLEditor->mRangeUpdater).DropRangeItem(mRangeItem); + htmlEditor->mRangeUpdater.DropRangeItem(mRangeItem); // Reset the contenteditable count to its previous value if (mRestoreContentEditableCount) { - nsCOMPtr doc = mHTMLEditor->GetDOMDocument(); + nsCOMPtr doc = htmlEditor->GetDOMDocument(); NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED); nsCOMPtr htmlDoc = do_QueryInterface(doc); NS_ENSURE_TRUE(htmlDoc, NS_ERROR_FAILURE); @@ -789,7 +789,7 @@ HTMLEditRules::GetAlignment(bool* aMixed, MOZ_ASSERT(aMixed && aAlign); NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); // For now, just return first alignment. We'll lie about if it's mixed. // This is for efficiency given that our current ui doesn't care if it's @@ -804,12 +804,12 @@ HTMLEditRules::GetAlignment(bool* aMixed, *aAlign = nsIHTMLEditor::eLeft; // Get selection - NS_ENSURE_STATE(mHTMLEditor->GetSelection()); - OwningNonNull selection = *mHTMLEditor->GetSelection(); + NS_ENSURE_STATE(htmlEditor->GetSelection()); + OwningNonNull selection = *htmlEditor->GetSelection(); // Get selection location - NS_ENSURE_TRUE(mHTMLEditor->GetRoot(), NS_ERROR_FAILURE); - OwningNonNull root = *mHTMLEditor->GetRoot(); + NS_ENSURE_TRUE(htmlEditor->GetRoot(), NS_ERROR_FAILURE); + OwningNonNull root = *htmlEditor->GetRoot(); int32_t rootOffset = root->GetParentNode() ? root->GetParentNode()->IndexOf(root) : -1; @@ -828,7 +828,7 @@ HTMLEditRules::GetAlignment(bool* aMixed, nodeToExamine = parent; } else if (parent->IsHTMLElement(nsGkAtoms::html) && offset == rootOffset) { // If we have selected the body, let's look at the first editable node - nodeToExamine = mHTMLEditor->GetNextNode(parent, offset, true); + nodeToExamine = htmlEditor->GetNextNode(parent, offset, true); } else { nsTArray> arrayOfRanges; GetPromotedRanges(selection, arrayOfRanges, EditAction::align); @@ -844,17 +844,17 @@ HTMLEditRules::GetAlignment(bool* aMixed, NS_ENSURE_TRUE(nodeToExamine, NS_ERROR_NULL_POINTER); NS_NAMED_LITERAL_STRING(typeAttrName, "align"); - nsCOMPtr blockParent = mHTMLEditor->GetBlock(*nodeToExamine); + nsCOMPtr blockParent = htmlEditor->GetBlock(*nodeToExamine); NS_ENSURE_TRUE(blockParent, NS_ERROR_FAILURE); - if (mHTMLEditor->IsCSSEnabled() && - mHTMLEditor->mCSSEditUtils->IsCSSEditableProperty(blockParent, nullptr, + if (htmlEditor->IsCSSEnabled() && + htmlEditor->mCSSEditUtils->IsCSSEditableProperty(blockParent, nullptr, &typeAttrName)) { // We are in CSS mode and we know how to align this element with CSS nsAutoString value; // Let's get the value(s) of text-align or margin-left/margin-right - mHTMLEditor->mCSSEditUtils->GetCSSEquivalentToHTMLInlineStyleSet( + htmlEditor->mCSSEditUtils->GetCSSEquivalentToHTMLInlineStyleSet( blockParent, nullptr, &typeAttrName, value, CSSEditUtils::eComputed); if (value.EqualsLiteral("center") || value.EqualsLiteral("-moz-center") || @@ -1172,7 +1172,7 @@ HTMLEditRules::WillInsert(Selection& aSelection, TextEditRules::WillInsert(aSelection, aCancel); NS_ENSURE_TRUE_VOID(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); // Adjust selection to prevent insertion after a moz-BR. This next only // works for collapsed selections right now, because selection is a pain to @@ -1190,11 +1190,11 @@ HTMLEditRules::WillInsert(Selection& aSelection, int32_t selOffset = aSelection.GetRangeAt(0)->StartOffset(); // Get prior node - nsCOMPtr priorNode = mHTMLEditor->GetPriorHTMLNode(selNode, - selOffset); + nsCOMPtr priorNode = htmlEditor->GetPriorHTMLNode(selNode, + selOffset); if (priorNode && TextEditUtils::IsMozBR(priorNode)) { - nsCOMPtr block1 = mHTMLEditor->GetBlock(selNode); - nsCOMPtr block2 = mHTMLEditor->GetBlockNodeParent(priorNode); + nsCOMPtr block1 = htmlEditor->GetBlock(selNode); + nsCOMPtr block2 = htmlEditor->GetBlockNodeParent(priorNode); if (block1 && block1 == block2) { // If we are here then the selection is right after a mozBR that is in @@ -1481,12 +1481,12 @@ HTMLEditRules::WillInsertBreak(Selection& aSelection, *aHandled = false; NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); // If the selection isn't collapsed, delete it. nsresult res; if (!aSelection.Collapsed()) { - res = mHTMLEditor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip); + res = htmlEditor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip); NS_ENSURE_SUCCESS(res, res); } @@ -1513,18 +1513,18 @@ HTMLEditRules::WillInsertBreak(Selection& aSelection, int32_t offset = aSelection.GetRangeAt(0)->StartOffset(); // Do nothing if the node is read-only - if (!mHTMLEditor->IsModifiableNode(node)) { + if (!htmlEditor->IsModifiableNode(node)) { *aCancel = true; return NS_OK; } // Identify the block - nsCOMPtr blockParent = mHTMLEditor->GetBlock(node); + nsCOMPtr blockParent = htmlEditor->GetBlock(node); NS_ENSURE_TRUE(blockParent, NS_ERROR_FAILURE); // If the active editing host is an inline element, or if the active editing // host is the block parent itself, just append a br. - nsCOMPtr host = mHTMLEditor->GetActiveEditingHost(); + nsCOMPtr host = htmlEditor->GetActiveEditingHost(); if (!EditorUtils::IsDescendantOf(blockParent, host)) { res = StandardBreakImpl(node, offset, aSelection); NS_ENSURE_SUCCESS(res, res); @@ -1539,8 +1539,8 @@ HTMLEditRules::WillInsertBreak(Selection& aSelection, bool isEmpty; IsEmptyBlock(*blockParent, &isEmpty); if (isEmpty) { - nsCOMPtr br = mHTMLEditor->CreateBR(blockParent, - blockParent->Length()); + nsCOMPtr br = htmlEditor->CreateBR(blockParent, + blockParent->Length()); NS_ENSURE_STATE(br); } @@ -1576,7 +1576,7 @@ HTMLEditRules::StandardBreakImpl(nsINode& aNode, Selection& aSelection) { NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); nsCOMPtr brNode; bool bAfterBlock = false; @@ -1585,10 +1585,10 @@ HTMLEditRules::StandardBreakImpl(nsINode& aNode, nsresult res; if (IsPlaintextEditor()) { - brNode = mHTMLEditor->CreateBR(node, aOffset); + brNode = htmlEditor->CreateBR(node, aOffset); NS_ENSURE_STATE(brNode); } else { - WSRunObject wsObj(mHTMLEditor, node, aOffset); + WSRunObject wsObj(htmlEditor, node, aOffset); int32_t visOffset = 0; WSType wsType; nsCOMPtr visNode; @@ -1603,14 +1603,14 @@ HTMLEditRules::StandardBreakImpl(nsINode& aNode, bBeforeBlock = true; } nsCOMPtr linkDOMNode; - if (mHTMLEditor->IsInLink(GetAsDOMNode(node), address_of(linkDOMNode))) { + if (htmlEditor->IsInLink(GetAsDOMNode(node), address_of(linkDOMNode))) { // Split the link nsCOMPtr linkNode = do_QueryInterface(linkDOMNode); NS_ENSURE_STATE(linkNode || !linkDOMNode); nsCOMPtr linkParent = linkNode->GetParentNode(); - aOffset = mHTMLEditor->SplitNodeDeep(*linkNode, *node->AsContent(), - aOffset, - HTMLEditor::EmptyContainers::no); + aOffset = htmlEditor->SplitNodeDeep(*linkNode, *node->AsContent(), + aOffset, + HTMLEditor::EmptyContainers::no); NS_ENSURE_STATE(aOffset != -1); node = linkParent; } @@ -1628,7 +1628,7 @@ HTMLEditRules::StandardBreakImpl(nsINode& aNode, res = aSelection.Collapse(node, offset); NS_ENSURE_SUCCESS(res, res); } else { - WSRunObject wsObj(mHTMLEditor, node, offset + 1); + WSRunObject wsObj(htmlEditor, node, offset + 1); nsCOMPtr secondBR; int32_t visOffset = 0; WSType wsType; @@ -1644,7 +1644,7 @@ HTMLEditRules::StandardBreakImpl(nsINode& aNode, nsCOMPtr brParent = secondBR->GetParentNode(); int32_t brOffset = brParent ? brParent->IndexOf(secondBR) : -1; if (brParent != node || brOffset != offset + 1) { - res = mHTMLEditor->MoveNode(secondBR->AsContent(), node, offset + 1); + res = htmlEditor->MoveNode(secondBR->AsContent(), node, offset + 1); NS_ENSURE_SUCCESS(res, res); } } @@ -2533,10 +2533,10 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode, MOZ_ASSERT(aCanceled); NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); - nsCOMPtr leftBlock = mHTMLEditor->GetBlock(aLeftNode); - nsCOMPtr rightBlock = mHTMLEditor->GetBlock(aRightNode); + nsCOMPtr leftBlock = htmlEditor->GetBlock(aLeftNode); + nsCOMPtr rightBlock = htmlEditor->GetBlock(aRightNode); // Sanity checks NS_ENSURE_TRUE(leftBlock && rightBlock, NS_ERROR_NULL_POINTER); @@ -2552,10 +2552,10 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode, // Make sure we don't try to move things into HR's, which look like blocks // but aren't containers if (leftBlock->IsHTMLElement(nsGkAtoms::hr)) { - leftBlock = mHTMLEditor->GetBlockNodeParent(leftBlock); + leftBlock = htmlEditor->GetBlockNodeParent(leftBlock); } if (rightBlock->IsHTMLElement(nsGkAtoms::hr)) { - rightBlock = mHTMLEditor->GetBlockNodeParent(rightBlock); + rightBlock = htmlEditor->GetBlockNodeParent(rightBlock); } NS_ENSURE_STATE(leftBlock && rightBlock); @@ -2596,7 +2596,7 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode, } } - AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor); + AutoTransactionsConserveSelection dontSpazMySelection(htmlEditor); nsresult res = NS_OK; int32_t rightOffset = 0; @@ -2608,7 +2608,7 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode, // Tricky case. Left block is inside right block. Do ws adjustment. This // just destroys non-visible ws at boundaries we will be joining. rightOffset++; - res = WSRunObject::ScrubBlockBoundary(mHTMLEditor, + res = WSRunObject::ScrubBlockBoundary(htmlEditor, WSRunObject::kBlockEnd, leftBlock); NS_ENSURE_SUCCESS(res, res); @@ -2616,9 +2616,9 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode, { // We can't just track rightBlock because it's an Element. nsCOMPtr trackingRightBlock(rightBlock); - AutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, + AutoTrackDOMPoint tracker(htmlEditor->mRangeUpdater, address_of(trackingRightBlock), &rightOffset); - res = WSRunObject::ScrubBlockBoundary(mHTMLEditor, + res = WSRunObject::ScrubBlockBoundary(htmlEditor, WSRunObject::kAfterBlock, rightBlock, rightOffset); NS_ENSURE_SUCCESS(res, res); @@ -2637,21 +2637,21 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode, // offset, and pull them into leftlist. for (nsCOMPtr child = rightList->GetChildAt(offset); child; child = rightList->GetChildAt(rightOffset)) { - res = mHTMLEditor->MoveNode(child, leftList, -1); + res = htmlEditor->MoveNode(child, leftList, -1); NS_ENSURE_SUCCESS(res, res); } } else { res = MoveBlock(*leftBlock, *rightBlock, leftOffset, rightOffset); } if (brNode) { - mHTMLEditor->DeleteNode(brNode); + htmlEditor->DeleteNode(brNode); } // Offset below is where you find yourself in leftBlock when you traverse // upwards from rightBlock } else if (EditorUtils::IsDescendantOf(rightBlock, leftBlock, &leftOffset)) { // Tricky case. Right block is inside left block. Do ws adjustment. This // just destroys non-visible ws at boundaries we will be joining. - res = WSRunObject::ScrubBlockBoundary(mHTMLEditor, + res = WSRunObject::ScrubBlockBoundary(htmlEditor, WSRunObject::kBlockStart, rightBlock); NS_ENSURE_SUCCESS(res, res); @@ -2659,9 +2659,9 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode, // We can't just track leftBlock because it's an Element, so track // something else. nsCOMPtr trackingLeftBlock(leftBlock); - AutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, + AutoTrackDOMPoint tracker(htmlEditor->mRangeUpdater, address_of(trackingLeftBlock), &leftOffset); - res = WSRunObject::ScrubBlockBoundary(mHTMLEditor, + res = WSRunObject::ScrubBlockBoundary(htmlEditor, WSRunObject::kBeforeBlock, leftBlock, leftOffset); NS_ENSURE_SUCCESS(res, res); @@ -2713,13 +2713,13 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode, // Because we don't want the moving content to receive the style of the // previous content, we split the previous content's style. - nsCOMPtr editorRoot = mHTMLEditor->GetEditorRoot(); + nsCOMPtr editorRoot = htmlEditor->GetEditorRoot(); if (!editorRoot || &aLeftNode != editorRoot) { nsCOMPtr splittedPreviousContent; - res = mHTMLEditor->SplitStyleAbovePoint(address_of(previousContentParent), - &previousContentOffset, - nullptr, nullptr, nullptr, - getter_AddRefs(splittedPreviousContent)); + res = htmlEditor->SplitStyleAbovePoint(address_of(previousContentParent), + &previousContentOffset, + nullptr, nullptr, nullptr, + getter_AddRefs(splittedPreviousContent)); NS_ENSURE_SUCCESS(res, res); if (splittedPreviousContent) { @@ -2736,7 +2736,7 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode, NS_ENSURE_SUCCESS(res, res); } if (brNode) { - mHTMLEditor->DeleteNode(brNode); + htmlEditor->DeleteNode(brNode); } } else { // Normal case. Blocks are siblings, or at least close enough. An example @@ -2745,7 +2745,7 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode, // if you backspace from li into p. // Adjust whitespace at block boundaries - res = WSRunObject::PrepareToJoinBlocks(mHTMLEditor, leftBlock, rightBlock); + res = WSRunObject::PrepareToJoinBlocks(htmlEditor, leftBlock, rightBlock); NS_ENSURE_SUCCESS(res, res); // Do br adjustment. nsCOMPtr brNode = @@ -2765,7 +2765,7 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode, NS_ENSURE_SUCCESS(res, res); } if (brNode) { - res = mHTMLEditor->DeleteNode(brNode); + res = htmlEditor->DeleteNode(brNode); NS_ENSURE_SUCCESS(res, res); } } @@ -2825,13 +2825,13 @@ HTMLEditRules::MoveNodeSmart(nsIContent& aNode, MOZ_ASSERT(aInOutDestOffset); NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); nsresult res; // Check if this node can go into the destination node - if (mHTMLEditor->CanContain(aDestElement, aNode)) { + if (htmlEditor->CanContain(aDestElement, aNode)) { // If it can, move it there - res = mHTMLEditor->MoveNode(&aNode, &aDestElement, *aInOutDestOffset); + res = htmlEditor->MoveNode(&aNode, &aDestElement, *aInOutDestOffset); NS_ENSURE_SUCCESS(res, res); if (*aInOutDestOffset != -1) { (*aInOutDestOffset)++; @@ -2843,7 +2843,7 @@ HTMLEditRules::MoveNodeSmart(nsIContent& aNode, NS_ENSURE_SUCCESS(res, res); } - res = mHTMLEditor->DeleteNode(&aNode); + res = htmlEditor->DeleteNode(&aNode); NS_ENSURE_SUCCESS(res, res); } return NS_OK; @@ -3322,7 +3322,7 @@ HTMLEditRules::WillMakeBasicBlock(Selection& aSelection, MOZ_ASSERT(aCancel && aHandled); NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); OwningNonNull blockType = NS_Atomize(aBlockType); @@ -3333,8 +3333,8 @@ HTMLEditRules::WillMakeBasicBlock(Selection& aSelection, nsresult res = NormalizeSelection(&aSelection); NS_ENSURE_SUCCESS(res, res); - AutoSelectionRestorer selectionRestorer(&aSelection, mHTMLEditor); - AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor); + AutoSelectionRestorer selectionRestorer(&aSelection, htmlEditor); + AutoTransactionsConserveSelection dontSpazMySelection(htmlEditor); *aHandled = true; // Contruct a list of nodes to act on. @@ -3345,7 +3345,7 @@ HTMLEditRules::WillMakeBasicBlock(Selection& aSelection, // Remove all non-editable nodes. Leave them be. for (int32_t i = arrayOfNodes.Length() - 1; i >= 0; i--) { - if (!mHTMLEditor->IsEditable(arrayOfNodes[i])) { + if (!htmlEditor->IsEditable(arrayOfNodes[i])) { arrayOfNodes.RemoveElementAt(i); } } @@ -3362,25 +3362,25 @@ HTMLEditRules::WillMakeBasicBlock(Selection& aSelection, if (blockType == nsGkAtoms::normal || blockType == nsGkAtoms::_empty) { // We are removing blocks (going to "body text") - NS_ENSURE_TRUE(mHTMLEditor->GetBlock(parent), NS_ERROR_NULL_POINTER); - OwningNonNull curBlock = *mHTMLEditor->GetBlock(parent); + NS_ENSURE_TRUE(htmlEditor->GetBlock(parent), NS_ERROR_NULL_POINTER); + OwningNonNull curBlock = *htmlEditor->GetBlock(parent); if (HTMLEditUtils::IsFormatNode(curBlock)) { // If the first editable node after selection is a br, consume it. // Otherwise it gets pushed into a following block after the split, // which is visually bad. nsCOMPtr brNode = - mHTMLEditor->GetNextHTMLNode(parent, offset); + htmlEditor->GetNextHTMLNode(parent, offset); if (brNode && brNode->IsHTMLElement(nsGkAtoms::br)) { - res = mHTMLEditor->DeleteNode(brNode); + res = htmlEditor->DeleteNode(brNode); NS_ENSURE_SUCCESS(res, res); } // Do the splits! - offset = mHTMLEditor->SplitNodeDeep(curBlock, *parent->AsContent(), + offset = htmlEditor->SplitNodeDeep(curBlock, *parent->AsContent(), offset, HTMLEditor::EmptyContainers::no); NS_ENSURE_STATE(offset != -1); // Put a br at the split point - brNode = mHTMLEditor->CreateBR(curBlock->GetParentNode(), offset); + brNode = htmlEditor->CreateBR(curBlock->GetParentNode(), offset); NS_ENSURE_STATE(brNode); // Put selection at the split point res = aSelection.Collapse(curBlock->GetParentNode(), offset); @@ -3393,9 +3393,9 @@ HTMLEditRules::WillMakeBasicBlock(Selection& aSelection, } else { // We are making a block. Consume a br, if needed. nsCOMPtr brNode = - mHTMLEditor->GetNextHTMLNode(parent, offset, true); + htmlEditor->GetNextHTMLNode(parent, offset, true); if (brNode && brNode->IsHTMLElement(nsGkAtoms::br)) { - res = mHTMLEditor->DeleteNode(brNode); + res = htmlEditor->DeleteNode(brNode); NS_ENSURE_SUCCESS(res, res); // We don't need to act on this node any more arrayOfNodes.RemoveElement(brNode); @@ -3404,14 +3404,14 @@ HTMLEditRules::WillMakeBasicBlock(Selection& aSelection, res = SplitAsNeeded(blockType, parent, offset); NS_ENSURE_SUCCESS(res, res); nsCOMPtr block = - mHTMLEditor->CreateNode(blockType, parent, offset); + htmlEditor->CreateNode(blockType, parent, offset); NS_ENSURE_STATE(block); // Remember our new block for postprocessing mNewBlock = block; // Delete anything that was in the list of nodes while (!arrayOfNodes.IsEmpty()) { OwningNonNull curNode = arrayOfNodes[0]; - res = mHTMLEditor->DeleteNode(curNode); + res = htmlEditor->DeleteNode(curNode); NS_ENSURE_SUCCESS(res, res); arrayOfNodes.RemoveElementAt(0); } @@ -3922,15 +3922,15 @@ HTMLEditRules::WillOutdent(Selection& aSelection, *aHandled = true; nsCOMPtr rememberedLeftBQ, rememberedRightBQ; NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); - bool useCSS = mHTMLEditor->IsCSSEnabled(); + RefPtr htmlEditor(mHTMLEditor); + bool useCSS = htmlEditor->IsCSSEnabled(); nsresult res = NormalizeSelection(&aSelection); NS_ENSURE_SUCCESS(res, res); // Some scoping for selection resetting - we may need to tweak it { - AutoSelectionRestorer selectionRestorer(&aSelection, mHTMLEditor); + AutoSelectionRestorer selectionRestorer(&aSelection, htmlEditor); // Convert the selection ranges into "promoted" selection ranges: this // basically just expands the range to include the immediate block parent, @@ -3972,23 +3972,23 @@ HTMLEditRules::WillOutdent(Selection& aSelection, lastBQChild = nullptr; curBlockQuoteIsIndentedWithCSS = false; } - res = mHTMLEditor->RemoveBlockContainer(curNode); + res = htmlEditor->RemoveBlockContainer(curNode); NS_ENSURE_SUCCESS(res, res); continue; } // Is it a block with a 'margin' property? if (useCSS && IsBlockNode(curNode)) { nsIAtom& marginProperty = - MarginPropertyAtomForIndent(*mHTMLEditor->mCSSEditUtils, curNode); + MarginPropertyAtomForIndent(*htmlEditor->mCSSEditUtils, curNode); nsAutoString value; - mHTMLEditor->mCSSEditUtils->GetSpecifiedProperty(curNode, + htmlEditor->mCSSEditUtils->GetSpecifiedProperty(curNode, marginProperty, value); float f; nsCOMPtr unit; - NS_ENSURE_STATE(mHTMLEditor); - mHTMLEditor->mCSSEditUtils->ParseLength(value, &f, - getter_AddRefs(unit)); + NS_ENSURE_STATE(htmlEditor); + htmlEditor->mCSSEditUtils->ParseLength(value, &f, + getter_AddRefs(unit)); if (f > 0) { ChangeIndentation(*curNode->AsElement(), Change::minus); continue; @@ -4046,7 +4046,7 @@ HTMLEditRules::WillOutdent(Selection& aSelection, // Keep looking up the hierarchy as long as we don't hit the body or the // active editing host or a table element (other than an entire table) while (!n->IsHTMLElement(nsGkAtoms::body) && - mHTMLEditor->IsDescendantOfEditorRoot(n) && + htmlEditor->IsDescendantOfEditorRoot(n) && (n->IsHTMLElement(nsGkAtoms::table) || !HTMLEditUtils::IsTableElement(n))) { if (!n->GetParentNode()) { @@ -4061,13 +4061,13 @@ HTMLEditRules::WillOutdent(Selection& aSelection, break; } else if (useCSS) { nsIAtom& marginProperty = - MarginPropertyAtomForIndent(*mHTMLEditor->mCSSEditUtils, curNode); + MarginPropertyAtomForIndent(*htmlEditor->mCSSEditUtils, curNode); nsAutoString value; - mHTMLEditor->mCSSEditUtils->GetSpecifiedProperty(*n, marginProperty, + htmlEditor->mCSSEditUtils->GetSpecifiedProperty(*n, marginProperty, value); float f; nsCOMPtr unit; - mHTMLEditor->mCSSEditUtils->ParseLength(value, &f, getter_AddRefs(unit)); + htmlEditor->mCSSEditUtils->ParseLength(value, &f, getter_AddRefs(unit)); if (f > 0 && !(HTMLEditUtils::IsList(curParent) && HTMLEditUtils::IsList(curNode))) { curBlockQuote = n->AsElement(); @@ -4085,7 +4085,7 @@ HTMLEditRules::WillOutdent(Selection& aSelection, // Move node out of list if (HTMLEditUtils::IsList(curNode)) { // Just unwrap this sublist - res = mHTMLEditor->RemoveBlockContainer(curNode); + res = htmlEditor->RemoveBlockContainer(curNode); NS_ENSURE_SUCCESS(res, res); } // handled list item case above @@ -4102,21 +4102,20 @@ HTMLEditRules::WillOutdent(Selection& aSelection, // list. Be sure to put it after the parent list because this // loop iterates backwards through the parent's list of children. - res = mHTMLEditor->MoveNode(child, curParent, offset + 1); + res = htmlEditor->MoveNode(child, curParent, offset + 1); NS_ENSURE_SUCCESS(res, res); } else { // Delete any non-list items for now - res = mHTMLEditor->DeleteNode(child); + res = htmlEditor->DeleteNode(child); NS_ENSURE_SUCCESS(res, res); } child = curNode->GetLastChild(); } // Delete the now-empty list - res = mHTMLEditor->RemoveBlockContainer(curNode); + res = htmlEditor->RemoveBlockContainer(curNode); NS_ENSURE_SUCCESS(res, res); } else if (useCSS) { nsCOMPtr element; - nsCOMPtr textNode = do_QueryInterface(curNode); if (curNode->GetAsText()) { // We want to outdent the parent of text nodes element = curNode->GetParentElement(); @@ -4203,7 +4202,7 @@ HTMLEditRules::SplitBlock(Element& aBlock, MOZ_ASSERT(EditorUtils::IsDescendantOf(&aStartChild, &aBlock) && EditorUtils::IsDescendantOf(&aEndChild, &aBlock)); NS_ENSURE_TRUE_VOID(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); // Get split point location OwningNonNull startParent = *aStartChild.GetParent(); @@ -4211,9 +4210,9 @@ HTMLEditRules::SplitBlock(Element& aBlock, // Do the splits! nsCOMPtr newMiddleNode1; - mHTMLEditor->SplitNodeDeep(aBlock, startParent, startOffset, - HTMLEditor::EmptyContainers::no, - aOutLeftNode, getter_AddRefs(newMiddleNode1)); + htmlEditor->SplitNodeDeep(aBlock, startParent, startOffset, + HTMLEditor::EmptyContainers::no, + aOutLeftNode, getter_AddRefs(newMiddleNode1)); // Get split point location OwningNonNull endParent = *aEndChild.GetParent(); @@ -4222,9 +4221,9 @@ HTMLEditRules::SplitBlock(Element& aBlock, // Do the splits! nsCOMPtr newMiddleNode2; - mHTMLEditor->SplitNodeDeep(aBlock, endParent, endOffset, - HTMLEditor::EmptyContainers::no, - getter_AddRefs(newMiddleNode2), aOutRightNode); + htmlEditor->SplitNodeDeep(aBlock, endParent, endOffset, + HTMLEditor::EmptyContainers::no, + getter_AddRefs(newMiddleNode2), aOutRightNode); if (aOutMiddleNode) { if (newMiddleNode2) { @@ -4457,7 +4456,7 @@ HTMLEditRules::WillAlign(Selection& aSelection, MOZ_ASSERT(aCancel && aHandled); NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); WillInsert(aSelection, aCancel); @@ -4467,7 +4466,7 @@ HTMLEditRules::WillAlign(Selection& aSelection, nsresult rv = NormalizeSelection(&aSelection); NS_ENSURE_SUCCESS(rv, rv); - AutoSelectionRestorer selectionRestorer(&aSelection, mHTMLEditor); + AutoSelectionRestorer selectionRestorer(&aSelection, htmlEditor); // Convert the selection ranges into "promoted" selection ranges: This // basically just expands the range to include the immediate block parent, @@ -4529,20 +4528,20 @@ HTMLEditRules::WillAlign(Selection& aSelection, // Consume a trailing br, if any. This is to keep an alignment from // creating extra lines, if possible. nsCOMPtr brContent = - mHTMLEditor->GetNextHTMLNode(parent, offset); + htmlEditor->GetNextHTMLNode(parent, offset); if (brContent && TextEditUtils::IsBreak(brContent)) { // Making use of html structure... if next node after where we are // putting our div is not a block, then the br we found is in same block // we are, so it's safe to consume it. - nsCOMPtr sibling = mHTMLEditor->GetNextHTMLSibling(parent, - offset); + nsCOMPtr sibling = htmlEditor->GetNextHTMLSibling(parent, + offset); if (sibling && !IsBlockNode(*sibling)) { - rv = mHTMLEditor->DeleteNode(brContent); + rv = htmlEditor->DeleteNode(brContent); NS_ENSURE_SUCCESS(rv, rv); } } - nsCOMPtr div = mHTMLEditor->CreateNode(nsGkAtoms::div, parent, - offset); + nsCOMPtr div = htmlEditor->CreateNode(nsGkAtoms::div, parent, + offset); NS_ENSURE_STATE(div); // Remember our new block for postprocessing mNewBlock = div; @@ -4570,13 +4569,13 @@ HTMLEditRules::WillAlign(Selection& aSelection, // them in a div, or whatever is appropriate. Woohoo! nsCOMPtr curDiv; - bool useCSS = mHTMLEditor->IsCSSEnabled(); + bool useCSS = htmlEditor->IsCSSEnabled(); for (size_t i = 0; i < nodeArray.Length(); i++) { auto& curNode = nodeArray[i]; // Here's where we actually figure out what to do // Ignore all non-editable nodes. Leave them be. - if (!mHTMLEditor->IsEditable(curNode)) { + if (!htmlEditor->IsEditable(curNode)) { continue; } @@ -4602,7 +4601,7 @@ HTMLEditRules::WillAlign(Selection& aSelection, ((HTMLEditUtils::IsTableElement(curParent) && !HTMLEditUtils::IsTableCellOrCaption(*curParent)) || HTMLEditUtils::IsList(curParent) || - (NS_SUCCEEDED(mHTMLEditor->IsEmptyNode(curNode, &isEmptyTextNode)) && + (NS_SUCCEEDED(htmlEditor->IsEmptyNode(curNode, &isEmptyTextNode)) && isEmptyTextNode))) { continue; } @@ -4614,7 +4613,7 @@ HTMLEditRules::WillAlign(Selection& aSelection, rv = RemoveAlignment(GetAsDOMNode(curNode), aAlignType, true); NS_ENSURE_SUCCESS(rv, rv); if (useCSS) { - mHTMLEditor->mCSSEditUtils->SetCSSEquivalentToHTMLStyle( + htmlEditor->mCSSEditUtils->SetCSSEquivalentToHTMLStyle( curNode->AsElement(), nullptr, &NS_LITERAL_STRING("align"), &aAlignType, false); curDiv = nullptr; @@ -4641,7 +4640,7 @@ HTMLEditRules::WillAlign(Selection& aSelection, rv = SplitAsNeeded(*nsGkAtoms::div, curParent, offset); NS_ENSURE_SUCCESS(rv, rv); - curDiv = mHTMLEditor->CreateNode(nsGkAtoms::div, curParent, offset); + curDiv = htmlEditor->CreateNode(nsGkAtoms::div, curParent, offset); NS_ENSURE_STATE(curDiv); // Remember our new block for postprocessing mNewBlock = curDiv; @@ -4652,7 +4651,7 @@ HTMLEditRules::WillAlign(Selection& aSelection, NS_ENSURE_STATE(curNode->IsContent()); // Tuck the node into the end of the active div - rv = mHTMLEditor->MoveNode(curNode->AsContent(), curDiv, -1); + rv = htmlEditor->MoveNode(curNode->AsContent(), curDiv, -1); NS_ENSURE_SUCCESS(rv, rv); } @@ -4769,24 +4768,24 @@ HTMLEditRules::CheckForEmptyBlock(nsINode* aStartNode, return NS_OK; } NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); // If we are inside an empty block, delete it. Note: do NOT delete table // elements this way. - nsCOMPtr block = mHTMLEditor->GetBlock(*aStartNode); + nsCOMPtr block = htmlEditor->GetBlock(*aStartNode); bool bIsEmptyNode; nsCOMPtr emptyBlock; nsresult res; if (block && block != aBodyNode) { // Efficiency hack, avoiding IsEmptyNode() call when in body - res = mHTMLEditor->IsEmptyNode(block, &bIsEmptyNode, true, false); + res = htmlEditor->IsEmptyNode(block, &bIsEmptyNode, true, false); NS_ENSURE_SUCCESS(res, res); while (block && bIsEmptyNode && !HTMLEditUtils::IsTableElement(block) && block != aBodyNode) { emptyBlock = block; - block = mHTMLEditor->GetBlockNodeParent(emptyBlock); + block = htmlEditor->GetBlockNodeParent(emptyBlock); if (block) { - res = mHTMLEditor->IsEmptyNode(block, &bIsEmptyNode, true, false); + res = htmlEditor->IsEmptyNode(block, &bIsEmptyNode, true, false); NS_ENSURE_SUCCESS(res, res); } } @@ -4800,9 +4799,9 @@ HTMLEditRules::CheckForEmptyBlock(nsINode* aStartNode, if (HTMLEditUtils::IsListItem(emptyBlock)) { // Are we the first list item in the list? bool bIsFirst; - NS_ENSURE_STATE(mHTMLEditor); - res = mHTMLEditor->IsFirstEditableChild(GetAsDOMNode(emptyBlock), - &bIsFirst); + NS_ENSURE_STATE(htmlEditor); + res = htmlEditor->IsFirstEditableChild(GetAsDOMNode(emptyBlock), + &bIsFirst); NS_ENSURE_SUCCESS(res, res); if (bIsFirst) { nsCOMPtr listParent = blockParent->GetParentNode(); @@ -4811,9 +4810,9 @@ HTMLEditRules::CheckForEmptyBlock(nsINode* aStartNode, // If we are a sublist, skip the br creation if (!HTMLEditUtils::IsList(listParent)) { // Create a br before list - NS_ENSURE_STATE(mHTMLEditor); + NS_ENSURE_STATE(htmlEditor); nsCOMPtr br = - mHTMLEditor->CreateBR(listParent, listOffset); + htmlEditor->CreateBR(listParent, listOffset); NS_ENSURE_STATE(br); // Adjust selection to be right before it res = aSelection->Collapse(listParent, listOffset); @@ -4825,8 +4824,8 @@ HTMLEditRules::CheckForEmptyBlock(nsINode* aStartNode, } else { if (aAction == nsIEditor::eNext) { // Move to the start of the next node, if any - nsCOMPtr nextNode = mHTMLEditor->GetNextNode(blockParent, - offset + 1, true); + nsCOMPtr nextNode = htmlEditor->GetNextNode(blockParent, + offset + 1, true); if (nextNode) { EditorDOMPoint pt = GetGoodSelPointForNode(*nextNode, aAction); res = aSelection->Collapse(pt.node, pt.offset); @@ -4838,9 +4837,9 @@ HTMLEditRules::CheckForEmptyBlock(nsINode* aStartNode, } } else { // Move to the end of the previous node - nsCOMPtr priorNode = mHTMLEditor->GetPriorNode(blockParent, - offset, - true); + nsCOMPtr priorNode = htmlEditor->GetPriorNode(blockParent, + offset, + true); if (priorNode) { EditorDOMPoint pt = GetGoodSelPointForNode(*priorNode, aAction); res = aSelection->Collapse(pt.node, pt.offset); @@ -4851,8 +4850,8 @@ HTMLEditRules::CheckForEmptyBlock(nsINode* aStartNode, } } } - NS_ENSURE_STATE(mHTMLEditor); - res = mHTMLEditor->DeleteNode(emptyBlock); + NS_ENSURE_STATE(htmlEditor); + res = htmlEditor->DeleteNode(emptyBlock); *aHandled = true; NS_ENSURE_SUCCESS(res, res); } @@ -5461,7 +5460,7 @@ HTMLEditRules::PromoteRange(nsRange& aRange, EditAction aOperationType) { NS_ENSURE_TRUE(mHTMLEditor, ); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); nsCOMPtr startNode = aRange.GetStartParent(); nsCOMPtr endNode = aRange.GetEndParent(); @@ -5473,14 +5472,14 @@ HTMLEditRules::PromoteRange(nsRange& aRange, // inside block elements that contain nothing but a solo
. It's easier // to put a workaround here than to revamp GetPromotedPoint. :-( if (startNode == endNode && startOffset == endOffset) { - nsCOMPtr block = mHTMLEditor->GetBlock(*startNode); + nsCOMPtr block = htmlEditor->GetBlock(*startNode); if (block) { bool bIsEmptyNode = false; - nsCOMPtr root = mHTMLEditor->GetActiveEditingHost(); + nsCOMPtr root = htmlEditor->GetActiveEditingHost(); // Make sure we don't go higher than our root element in the content tree NS_ENSURE_TRUE(root, ); if (!nsContentUtils::ContentIsDescendantOf(root, block)) { - mHTMLEditor->IsEmptyNode(block, &bIsEmptyNode, true, false); + htmlEditor->IsEmptyNode(block, &bIsEmptyNode, true, false); } if (bIsEmptyNode) { startNode = block; @@ -5498,7 +5497,6 @@ HTMLEditRules::PromoteRange(nsRange& aRange, nsCOMPtr opStartNode; nsCOMPtr opEndNode; int32_t opStartOffset, opEndOffset; - RefPtr opRange; GetPromotedPoint(kStart, GetAsDOMNode(startNode), startOffset, aOperationType, address_of(opStartNode), &opStartOffset); @@ -5506,9 +5504,9 @@ HTMLEditRules::PromoteRange(nsRange& aRange, address_of(opEndNode), &opEndOffset); // Make sure that the new range ends up to be in the editable section. - if (!mHTMLEditor->IsDescendantOfEditorRoot( + if (!htmlEditor->IsDescendantOfEditorRoot( EditorBase::GetNodeAtRangeOffsetPoint(opStartNode, opStartOffset)) || - !mHTMLEditor->IsDescendantOfEditorRoot( + !htmlEditor->IsDescendantOfEditorRoot( EditorBase::GetNodeAtRangeOffsetPoint(opEndNode, opEndOffset - 1))) { return; } @@ -5549,7 +5547,7 @@ HTMLEditRules::GetNodesForOperation( TouchContent aTouchContent) { NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); int32_t rangeCount = aArrayOfRanges.Length(); nsresult res = NS_OK; @@ -5561,7 +5559,7 @@ HTMLEditRules::GetNodesForOperation( for (int32_t i = 0; i < rangeCount; i++) { RefPtr r = aArrayOfRanges[i]; nsCOMPtr endParent = do_QueryInterface(r->GetEndParent()); - if (!mHTMLEditor->IsTextNode(endParent)) { + if (!htmlEditor->IsTextNode(endParent)) { continue; } nsCOMPtr textNode = do_QueryInterface(endParent); @@ -5573,8 +5571,8 @@ HTMLEditRules::GetNodesForOperation( if (0 < offset && offset < (int32_t)(tempString.Length())) { // Split the text node. nsCOMPtr tempNode; - res = mHTMLEditor->SplitNode(endParent->AsDOMNode(), offset, - getter_AddRefs(tempNode)); + res = htmlEditor->SplitNode(endParent->AsDOMNode(), offset, + getter_AddRefs(tempNode)); NS_ENSURE_SUCCESS(res, res); // Correct the range. @@ -5597,7 +5595,7 @@ HTMLEditRules::GetNodesForOperation( for (int32_t i = 0; i < rangeCount; i++) { rangeItemArray[i] = new RangeItem(); rangeItemArray[i]->StoreRange(aArrayOfRanges[0]); - mHTMLEditor->mRangeUpdater.RegisterRangeItem(rangeItemArray[i]); + htmlEditor->mRangeUpdater.RegisterRangeItem(rangeItemArray[i]); aArrayOfRanges.RemoveElementAt(0); } // Now bust up inlines. @@ -5609,7 +5607,7 @@ HTMLEditRules::GetNodesForOperation( } // Then unregister the ranges for (auto& item : rangeItemArray) { - mHTMLEditor->mRangeUpdater.DropRangeItem(item); + htmlEditor->mRangeUpdater.DropRangeItem(item); aArrayOfRanges.AppendElement(item->GetRange()); } NS_ENSURE_SUCCESS(res, res); @@ -5658,7 +5656,7 @@ HTMLEditRules::GetNodesForOperation( } // Outdent should look inside of divs. if (aOperationType == EditAction::outdent && - !mHTMLEditor->IsCSSEnabled()) { + !htmlEditor->IsCSSEnabled()) { for (int32_t i = aOutArrayOfNodes.Length() - 1; i >= 0; i--) { OwningNonNull node = aOutArrayOfNodes[i]; if (node->IsHTMLElement(nsGkAtoms::div)) { @@ -5681,7 +5679,7 @@ HTMLEditRules::GetNodesForOperation( for (int32_t i = aOutArrayOfNodes.Length() - 1; i >= 0; i--) { OwningNonNull node = aOutArrayOfNodes[i]; if (aTouchContent == TouchContent::yes && IsInlineNode(node) && - mHTMLEditor->IsContainer(node) && !mHTMLEditor->IsTextNode(node)) { + htmlEditor->IsContainer(node) && !htmlEditor->IsTextNode(node)) { nsTArray> arrayOfInlines; res = BustUpInlinesAtBRs(*node->AsContent(), arrayOfInlines); NS_ENSURE_SUCCESS(res, res); @@ -5713,9 +5711,9 @@ HTMLEditRules::GetListActionNodes( TouchContent aTouchContent) { NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); - RefPtr selection = mHTMLEditor->GetSelection(); + RefPtr selection = htmlEditor->GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE); // Added this in so that ui code can ask to change an entire list, even if @@ -5741,7 +5739,7 @@ HTMLEditRules::GetListActionNodes( { // We don't like other people messing with our selection! - AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor); + AutoTransactionsConserveSelection dontSpazMySelection(htmlEditor); // contruct a list of nodes to act on. nsresult res = GetNodesFromSelection(*selection, EditAction::makeList, @@ -5754,7 +5752,7 @@ HTMLEditRules::GetListActionNodes( OwningNonNull testNode = aOutArrayOfNodes[i]; // Remove all non-editable nodes. Leave them be. - if (!mHTMLEditor->IsEditable(testNode)) { + if (!htmlEditor->IsEditable(testNode)) { aOutArrayOfNodes.RemoveElementAt(i); continue; } @@ -5780,7 +5778,7 @@ HTMLEditRules::LookInsideDivBQandList( nsTArray>& aNodeArray) { NS_ENSURE_TRUE(mHTMLEditor, ); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); // If there is only one node in the array, and it is a list, div, or // blockquote, then look inside of it until we find inner list or content. @@ -5795,7 +5793,7 @@ HTMLEditRules::LookInsideDivBQandList( HTMLEditUtils::IsList(curNode) || curNode->IsHTMLElement(nsGkAtoms::blockquote)) { // Dive as long as there's only one child, and it's a list, div, blockquote - uint32_t numChildren = mHTMLEditor->CountEditableChildren(curNode); + uint32_t numChildren = htmlEditor->CountEditableChildren(curNode); if (numChildren != 1) { break; } @@ -5853,9 +5851,9 @@ HTMLEditRules::GetParagraphFormatNodes( TouchContent aTouchContent) { NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); - RefPtr selection = mHTMLEditor->GetSelection(); + RefPtr selection = htmlEditor->GetSelection(); NS_ENSURE_STATE(selection); // Contruct a list of nodes to act on. @@ -5868,7 +5866,7 @@ HTMLEditRules::GetParagraphFormatNodes( OwningNonNull testNode = outArrayOfNodes[i]; // Remove all non-editable nodes. Leave them be. - if (!mHTMLEditor->IsEditable(testNode)) { + if (!htmlEditor->IsEditable(testNode)) { outArrayOfNodes.RemoveElementAt(i); continue; } @@ -5935,7 +5933,7 @@ HTMLEditRules::BustUpInlinesAtBRs( nsTArray>& aOutArrayOfNodes) { NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); // First build up a list of all the break nodes inside the inline container. nsTArray> arrayOfBreaks; @@ -5962,10 +5960,10 @@ HTMLEditRules::BustUpInlinesAtBRs( int32_t splitOffset = splitParentNode->IndexOf(breakNode); int32_t resultOffset = - mHTMLEditor->SplitNodeDeep(*splitDeepNode, splitParentNode, splitOffset, - HTMLEditor::EmptyContainers::yes, - getter_AddRefs(leftNode), - getter_AddRefs(rightNode)); + htmlEditor->SplitNodeDeep(*splitDeepNode, splitParentNode, splitOffset, + HTMLEditor::EmptyContainers::yes, + getter_AddRefs(leftNode), + getter_AddRefs(rightNode)); NS_ENSURE_STATE(resultOffset != -1); // Put left node in node list @@ -5976,8 +5974,8 @@ HTMLEditRules::BustUpInlinesAtBRs( aOutArrayOfNodes.AppendElement(*leftNode); } // Move break outside of container and also put in node list - nsresult res = mHTMLEditor->MoveNode(breakNode, inlineParentNode, - resultOffset); + nsresult res = htmlEditor->MoveNode(breakNode, inlineParentNode, + resultOffset); NS_ENSURE_SUCCESS(res, res); aOutArrayOfNodes.AppendElement(*breakNode); @@ -6118,7 +6116,7 @@ HTMLEditRules::ReturnInHeader(Selection& aSelection, int32_t aOffset) { NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); // Remember where the header is nsCOMPtr headerParent = aHeader.GetParentNode(); @@ -6126,20 +6124,20 @@ HTMLEditRules::ReturnInHeader(Selection& aSelection, // Get ws code to adjust any ws nsCOMPtr node = &aNode; - nsresult res = WSRunObject::PrepareToSplitAcrossBlocks(mHTMLEditor, + nsresult res = WSRunObject::PrepareToSplitAcrossBlocks(htmlEditor, address_of(node), &aOffset); NS_ENSURE_SUCCESS(res, res); // Split the header NS_ENSURE_STATE(node->IsContent()); - mHTMLEditor->SplitNodeDeep(aHeader, *node->AsContent(), aOffset); + htmlEditor->SplitNodeDeep(aHeader, *node->AsContent(), aOffset); // If the left-hand heading is empty, put a mozbr in it - nsCOMPtr prevItem = mHTMLEditor->GetPriorHTMLSibling(&aHeader); + nsCOMPtr prevItem = htmlEditor->GetPriorHTMLSibling(&aHeader); if (prevItem && HTMLEditUtils::IsHeader(*prevItem)) { bool isEmptyNode; - res = mHTMLEditor->IsEmptyNode(prevItem, &isEmptyNode); + res = htmlEditor->IsEmptyNode(prevItem, &isEmptyNode); NS_ENSURE_SUCCESS(res, res); if (isEmptyNode) { res = CreateMozBR(prevItem->AsDOMNode(), 0); @@ -6152,23 +6150,23 @@ HTMLEditRules::ReturnInHeader(Selection& aSelection, res = IsEmptyBlock(aHeader, &isEmpty, MozBRCounts::no); NS_ENSURE_SUCCESS(res, res); if (isEmpty) { - res = mHTMLEditor->DeleteNode(&aHeader); + res = htmlEditor->DeleteNode(&aHeader); NS_ENSURE_SUCCESS(res, res); // Layout tells the caret to blink in a weird place if we don't place a // break after the header. nsCOMPtr sibling = - mHTMLEditor->GetNextHTMLSibling(headerParent, offset + 1); + htmlEditor->GetNextHTMLSibling(headerParent, offset + 1); if (!sibling || !sibling->IsHTMLElement(nsGkAtoms::br)) { ClearCachedStyles(); - mHTMLEditor->mTypeInState->ClearAllProps(); + htmlEditor->mTypeInState->ClearAllProps(); // Create a paragraph nsCOMPtr pNode = - mHTMLEditor->CreateNode(nsGkAtoms::p, headerParent, offset + 1); + htmlEditor->CreateNode(nsGkAtoms::p, headerParent, offset + 1); NS_ENSURE_STATE(pNode); // Append a
to it - nsCOMPtr brNode = mHTMLEditor->CreateBR(pNode, 0); + nsCOMPtr brNode = htmlEditor->CreateBR(pNode, 0); NS_ENSURE_STATE(brNode); // Set selection to before the break @@ -6388,10 +6386,10 @@ HTMLEditRules::ReturnInListItem(Selection& aSelection, MOZ_ASSERT(HTMLEditUtils::IsListItem(&aListItem)); NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); // Get the item parent and the active editing host. - nsCOMPtr root = mHTMLEditor->GetActiveEditingHost(); + nsCOMPtr root = htmlEditor->GetActiveEditingHost(); nsCOMPtr list = aListItem.GetParentElement(); int32_t itemOffset = list ? list->IndexOf(&aListItem) : -1; @@ -6409,34 +6407,34 @@ HTMLEditRules::ReturnInListItem(Selection& aSelection, // Are we the last list item in the list? bool isLast; - res = mHTMLEditor->IsLastEditableChild(aListItem.AsDOMNode(), &isLast); + res = htmlEditor->IsLastEditableChild(aListItem.AsDOMNode(), &isLast); NS_ENSURE_SUCCESS(res, res); if (!isLast) { // We need to split the list! ErrorResult rv; - mHTMLEditor->SplitNode(*list, itemOffset, rv); + htmlEditor->SplitNode(*list, itemOffset, rv); NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult()); } // Are we in a sublist? if (HTMLEditUtils::IsList(listParent)) { // If so, move item out of this list and into the grandparent list - res = mHTMLEditor->MoveNode(&aListItem, listParent, offset + 1); + res = htmlEditor->MoveNode(&aListItem, listParent, offset + 1); NS_ENSURE_SUCCESS(res, res); res = aSelection.Collapse(&aListItem, 0); NS_ENSURE_SUCCESS(res, res); } else { // Otherwise kill this item - res = mHTMLEditor->DeleteNode(&aListItem); + res = htmlEditor->DeleteNode(&aListItem); NS_ENSURE_SUCCESS(res, res); // Time to insert a paragraph nsCOMPtr pNode = - mHTMLEditor->CreateNode(nsGkAtoms::p, listParent, offset + 1); + htmlEditor->CreateNode(nsGkAtoms::p, listParent, offset + 1); NS_ENSURE_STATE(pNode); // Append a
to it - nsCOMPtr brNode = mHTMLEditor->CreateBR(pNode, 0); + nsCOMPtr brNode = htmlEditor->CreateBR(pNode, 0); NS_ENSURE_STATE(brNode); // Set selection to before the break @@ -6449,27 +6447,27 @@ HTMLEditRules::ReturnInListItem(Selection& aSelection, // Else we want a new list item at the same list level. Get ws code to // adjust any ws. nsCOMPtr selNode = &aNode; - res = WSRunObject::PrepareToSplitAcrossBlocks(mHTMLEditor, + res = WSRunObject::PrepareToSplitAcrossBlocks(htmlEditor, address_of(selNode), &aOffset); NS_ENSURE_SUCCESS(res, res); // Now split list item NS_ENSURE_STATE(selNode->IsContent()); - mHTMLEditor->SplitNodeDeep(aListItem, *selNode->AsContent(), aOffset); + htmlEditor->SplitNodeDeep(aListItem, *selNode->AsContent(), aOffset); // Hack: until I can change the damaged doc range code back to being // extra-inclusive, I have to manually detect certain list items that may be // left empty. - nsCOMPtr prevItem = mHTMLEditor->GetPriorHTMLSibling(&aListItem); + nsCOMPtr prevItem = htmlEditor->GetPriorHTMLSibling(&aListItem); if (prevItem && HTMLEditUtils::IsListItem(prevItem)) { bool isEmptyNode; - res = mHTMLEditor->IsEmptyNode(prevItem, &isEmptyNode); + res = htmlEditor->IsEmptyNode(prevItem, &isEmptyNode); NS_ENSURE_SUCCESS(res, res); if (isEmptyNode) { res = CreateMozBR(prevItem->AsDOMNode(), 0); NS_ENSURE_SUCCESS(res, res); } else { - res = mHTMLEditor->IsEmptyNode(&aListItem, &isEmptyNode, true); + res = htmlEditor->IsEmptyNode(&aListItem, &isEmptyNode, true); NS_ENSURE_SUCCESS(res, res); if (isEmptyNode) { nsCOMPtr nodeAtom = aListItem.NodeInfo()->NameAtom(); @@ -6480,7 +6478,7 @@ HTMLEditRules::ReturnInListItem(Selection& aSelection, nsIAtom* listAtom = nodeAtom == nsGkAtoms::dt ? nsGkAtoms::dd : nsGkAtoms::dt; nsCOMPtr newListItem = - mHTMLEditor->CreateNode(listAtom, list, itemOffset + 1); + htmlEditor->CreateNode(listAtom, list, itemOffset + 1); NS_ENSURE_STATE(newListItem); res = mTextEditor->DeleteNode(&aListItem); NS_ENSURE_SUCCESS(res, res); @@ -6491,7 +6489,7 @@ HTMLEditRules::ReturnInListItem(Selection& aSelection, } nsCOMPtr brNode; - res = mHTMLEditor->CopyLastEditableChildStyles(GetAsDOMNode(prevItem), + res = htmlEditor->CopyLastEditableChildStyles(GetAsDOMNode(prevItem), GetAsDOMNode(&aListItem), getter_AddRefs(brNode)); NS_ENSURE_SUCCESS(res, res); if (brNode) { @@ -6503,7 +6501,7 @@ HTMLEditRules::ReturnInListItem(Selection& aSelection, return NS_OK; } } else { - WSRunObject wsObj(mHTMLEditor, &aListItem, 0); + WSRunObject wsObj(htmlEditor, &aListItem, 0); nsCOMPtr visNode; int32_t visOffset = 0; WSType wsType; @@ -6603,7 +6601,7 @@ nsresult HTMLEditRules::RemoveBlockStyle(nsTArray>& aNodeArray) { NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); // Intent of this routine is to be used for converting to/from headers, // paragraphs, pre, and address. Those blocks that pretty much just contain @@ -6622,7 +6620,7 @@ HTMLEditRules::RemoveBlockStyle(nsTArray>& aNodeArray) firstNode = lastNode = curBlock = nullptr; } // Remove current block - res = mHTMLEditor->RemoveBlockContainer(*curNode->AsContent()); + res = htmlEditor->RemoveBlockContainer(*curNode->AsContent()); NS_ENSURE_SUCCESS(res, res); } else if (curNode->IsAnyOfHTMLElements(nsGkAtoms::table, nsGkAtoms::tr, @@ -6660,7 +6658,7 @@ HTMLEditRules::RemoveBlockStyle(nsTArray>& aNodeArray) // Fall out and handle curNode } } - curBlock = mHTMLEditor->GetBlockNodeParent(curNode); + curBlock = htmlEditor->GetBlockNodeParent(curNode); if (curBlock && HTMLEditUtils::IsFormatNode(curBlock)) { firstNode = lastNode = curNode->AsContent(); } else { @@ -6696,13 +6694,13 @@ HTMLEditRules::ApplyBlockStyle(nsTArray>& aNodeArray, // paragraphs, pre, and address. Those blocks that pretty much just contain // inline things... NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr kungFuDeathGrip(mHTMLEditor); + RefPtr htmlEditor(mHTMLEditor); nsresult res; // Remove all non-editable nodes. Leave them be. for (int32_t i = aNodeArray.Length() - 1; i >= 0; i--) { - if (!mHTMLEditor->IsEditable(aNodeArray[i])) { + if (!htmlEditor->IsEditable(aNodeArray[i])) { aNodeArray.RemoveElementAt(i); } } @@ -6729,9 +6727,9 @@ HTMLEditRules::ApplyBlockStyle(nsTArray>& aNodeArray, HTMLEditUtils::IsFormatNode(curNode)) { // Forget any previous block used for previous inline nodes curBlock = nullptr; - newBlock = mHTMLEditor->ReplaceContainer(curNode->AsElement(), - &aBlockTag, nullptr, nullptr, - EditorBase::eCloneAttributes); + newBlock = htmlEditor->ReplaceContainer(curNode->AsElement(), + &aBlockTag, nullptr, nullptr, + EditorBase::eCloneAttributes); NS_ENSURE_STATE(newBlock); } else if (HTMLEditUtils::IsTable(curNode) || HTMLEditUtils::IsList(curNode) || @@ -6754,7 +6752,7 @@ HTMLEditRules::ApplyBlockStyle(nsTArray>& aNodeArray, res = SplitAsNeeded(aBlockTag, curParent, offset); NS_ENSURE_SUCCESS(res, res); nsCOMPtr theBlock = - mHTMLEditor->CreateNode(&aBlockTag, curParent, offset); + htmlEditor->CreateNode(&aBlockTag, curParent, offset); NS_ENSURE_STATE(theBlock); // Remember our new block for postprocessing mNewBlock = theBlock; @@ -6765,19 +6763,19 @@ HTMLEditRules::ApplyBlockStyle(nsTArray>& aNodeArray, if (curBlock) { // Forget any previous block used for previous inline nodes curBlock = nullptr; - res = mHTMLEditor->DeleteNode(curNode); + res = htmlEditor->DeleteNode(curNode); NS_ENSURE_SUCCESS(res, res); } else { // The break is the first (or even only) node we encountered. Create a // block for it. res = SplitAsNeeded(aBlockTag, curParent, offset); NS_ENSURE_SUCCESS(res, res); - curBlock = mHTMLEditor->CreateNode(&aBlockTag, curParent, offset); + curBlock = htmlEditor->CreateNode(&aBlockTag, curParent, offset); NS_ENSURE_STATE(curBlock); // Remember our new block for postprocessing mNewBlock = curBlock; // Note: doesn't matter if we set mNewBlock multiple times. - res = mHTMLEditor->MoveNode(curNode->AsContent(), curBlock, -1); + res = htmlEditor->MoveNode(curNode->AsContent(), curBlock, -1); NS_ENSURE_SUCCESS(res, res); } } else if (IsInlineNode(curNode)) { @@ -6788,7 +6786,7 @@ HTMLEditRules::ApplyBlockStyle(nsTArray>& aNodeArray, // added here if that should change // // If curNode is a non editable, drop it if we are going to
.
-      if (&aBlockTag == nsGkAtoms::pre && !mHTMLEditor->IsEditable(curNode)) {
+      if (&aBlockTag == nsGkAtoms::pre && !htmlEditor->IsEditable(curNode)) {
         // Do nothing to this block
         continue;
       }
@@ -6797,7 +6795,7 @@ HTMLEditRules::ApplyBlockStyle(nsTArray>& aNodeArray,
       if (!curBlock) {
         res = SplitAsNeeded(aBlockTag, curParent, offset);
         NS_ENSURE_SUCCESS(res, res);
-        curBlock = mHTMLEditor->CreateNode(&aBlockTag, curParent, offset);
+        curBlock = htmlEditor->CreateNode(&aBlockTag, curParent, offset);
         NS_ENSURE_STATE(curBlock);
         // Remember our new block for postprocessing
         mNewBlock = curBlock;
@@ -6808,7 +6806,7 @@ HTMLEditRules::ApplyBlockStyle(nsTArray>& aNodeArray,
 
       // This is a continuation of some inline nodes that belong together in
       // the same block item.  Use curBlock.
-      res = mHTMLEditor->MoveNode(curNode->AsContent(), curBlock, -1);
+      res = htmlEditor->MoveNode(curNode->AsContent(), curBlock, -1);
       NS_ENSURE_SUCCESS(res, res);
     }
   }
@@ -7200,7 +7198,7 @@ HTMLEditRules::CheckInterlinePosition(Selection& aSelection)
   }
 
   NS_ENSURE_TRUE_VOID(mHTMLEditor);
-  nsCOMPtr kungFuDeathGrip(mHTMLEditor);
+  RefPtr htmlEditor(mHTMLEditor);
 
   // Get the (collapsed) selection location
   NS_ENSURE_TRUE_VOID(aSelection.GetRangeAt(0) &&
@@ -7212,21 +7210,21 @@ HTMLEditRules::CheckInterlinePosition(Selection& aSelection)
   // special-case first so that we don't accidentally fall through into one of
   // the other conditionals.
   nsCOMPtr node =
-    mHTMLEditor->GetPriorHTMLNode(selNode, selOffset, true);
+    htmlEditor->GetPriorHTMLNode(selNode, selOffset, true);
   if (node && node->IsHTMLElement(nsGkAtoms::br)) {
     aSelection.SetInterlinePosition(true);
     return;
   }
 
   // Are we after a block?  If so try set caret to following content
-  node = mHTMLEditor->GetPriorHTMLSibling(selNode, selOffset);
+  node = htmlEditor->GetPriorHTMLSibling(selNode, selOffset);
   if (node && IsBlockNode(*node)) {
     aSelection.SetInterlinePosition(true);
     return;
   }
 
   // Are we before a block?  If so try set caret to prior content
-  node = mHTMLEditor->GetNextHTMLSibling(selNode, selOffset);
+  node = htmlEditor->GetNextHTMLSibling(selNode, selOffset);
   if (node && IsBlockNode(*node)) {
     aSelection.SetInterlinePosition(false);
   }
@@ -7486,7 +7484,7 @@ nsresult
 HTMLEditRules::RemoveEmptyNodes()
 {
   NS_ENSURE_STATE(mHTMLEditor);
-  nsCOMPtr kungFuDeathGrip(mHTMLEditor);
+  RefPtr htmlEditor(mHTMLEditor);
 
   // Some general notes on the algorithm used here: the goal is to examine all
   // the nodes in mDocChangeRange, and remove the empty ones.  We do this by
@@ -7566,8 +7564,8 @@ HTMLEditRules::RemoveEmptyNodes()
       if (bIsCandidate) {
         // We delete mailcites even if they have a solo br in them.  Other
         // nodes we require to be empty.
-        res = mHTMLEditor->IsEmptyNode(node->AsDOMNode(), &bIsEmptyNode,
-                                       bIsMailCite, true);
+        res = htmlEditor->IsEmptyNode(node->AsDOMNode(), &bIsEmptyNode,
+                                      bIsMailCite, true);
         NS_ENSURE_SUCCESS(res, res);
         if (bIsEmptyNode) {
           if (bIsMailCite) {
@@ -7590,8 +7588,8 @@ HTMLEditRules::RemoveEmptyNodes()
 
   // now delete the empty nodes
   for (auto& delNode : arrayOfEmptyNodes) {
-    if (mHTMLEditor->IsModifiableNode(delNode)) {
-      res = mHTMLEditor->DeleteNode(delNode);
+    if (htmlEditor->IsModifiableNode(delNode)) {
+      res = htmlEditor->DeleteNode(delNode);
       NS_ENSURE_SUCCESS(res, res);
     }
   }
@@ -7600,17 +7598,17 @@ HTMLEditRules::RemoveEmptyNodes()
   // to pull out any br's and preserve them.
   for (auto& delNode : arrayOfEmptyCites) {
     bool bIsEmptyNode;
-    res = mHTMLEditor->IsEmptyNode(delNode, &bIsEmptyNode, false, true);
+    res = htmlEditor->IsEmptyNode(delNode, &bIsEmptyNode, false, true);
     NS_ENSURE_SUCCESS(res, res);
     if (!bIsEmptyNode) {
       // We are deleting a cite that has just a br.  We want to delete cite,
       // but preserve br.
       nsCOMPtr parent = delNode->GetParentNode();
       int32_t offset = parent ? parent->IndexOf(delNode) : -1;
-      nsCOMPtr br = mHTMLEditor->CreateBR(parent, offset);
+      nsCOMPtr br = htmlEditor->CreateBR(parent, offset);
       NS_ENSURE_STATE(br);
     }
-    res = mHTMLEditor->DeleteNode(delNode);
+    res = htmlEditor->DeleteNode(delNode);
     NS_ENSURE_SUCCESS(res, res);
   }
 
@@ -7671,11 +7669,11 @@ bool
 HTMLEditRules::IsEmptyInline(nsINode& aNode)
 {
   NS_ENSURE_TRUE(mHTMLEditor, false);
-  nsCOMPtr kungFuDeathGrip(mHTMLEditor);
+  RefPtr htmlEditor(mHTMLEditor);
 
-  if (IsInlineNode(aNode) && mHTMLEditor->IsContainer(&aNode)) {
+  if (IsInlineNode(aNode) && htmlEditor->IsContainer(&aNode)) {
     bool isEmpty = true;
-    mHTMLEditor->IsEmptyNode(&aNode, &isEmpty);
+    htmlEditor->IsEmptyNode(&aNode, &isEmpty);
     return isEmpty;
   }
   return false;
@@ -7691,12 +7689,12 @@ HTMLEditRules::ListIsEmptyLine(nsTArray>& aArrayOfNodes)
   NS_ENSURE_TRUE(aArrayOfNodes.Length(), true);
 
   NS_ENSURE_TRUE(mHTMLEditor, false);
-  nsCOMPtr kungFuDeathGrip(mHTMLEditor);
+  RefPtr htmlEditor(mHTMLEditor);
 
   int32_t brCount = 0;
 
   for (auto& node : aArrayOfNodes) {
-    if (!mHTMLEditor->IsEditable(node)) {
+    if (!htmlEditor->IsEditable(node)) {
       continue;
     }
     if (TextEditUtils::IsBreak(node)) {
@@ -7780,7 +7778,7 @@ nsresult
 HTMLEditRules::RemoveListStructure(Element& aList)
 {
   NS_ENSURE_STATE(mHTMLEditor);
-  nsCOMPtr kungFuDeathGrip(mHTMLEditor);
+  RefPtr htmlEditor(mHTMLEditor);
   nsresult res;
 
   while (aList.GetFirstChild()) {
@@ -7798,13 +7796,13 @@ HTMLEditRules::RemoveListStructure(Element& aList)
       NS_ENSURE_SUCCESS(res, res);
     } else {
       // Delete any non-list items for now
-      res = mHTMLEditor->DeleteNode(child);
+      res = htmlEditor->DeleteNode(child);
       NS_ENSURE_SUCCESS(res, res);
     }
   }
 
   // Delete the now-empty list
-  res = mHTMLEditor->RemoveBlockContainer(aList);
+  res = htmlEditor->RemoveBlockContainer(aList);
   NS_ENSURE_SUCCESS(res, res);
 
   return NS_OK;
@@ -8352,16 +8350,16 @@ HTMLEditRules::AlignBlock(Element& aElement,
   }
 
   NS_ENSURE_STATE(mHTMLEditor);
-  nsCOMPtr kungFuDeathGrip(mHTMLEditor);
+  RefPtr htmlEditor(mHTMLEditor);
 
   nsresult res = RemoveAlignment(aElement.AsDOMNode(), aAlignType,
                                  aContentsOnly == ContentsOnly::yes);
   NS_ENSURE_SUCCESS(res, res);
   NS_NAMED_LITERAL_STRING(attr, "align");
-  if (mHTMLEditor->IsCSSEnabled()) {
+  if (htmlEditor->IsCSSEnabled()) {
     // Let's use CSS alignment; we use margin-left and margin-right for tables
     // and text-align for other block-level elements
-    res = mHTMLEditor->SetAttributeOrEquivalent(
+    res = htmlEditor->SetAttributeOrEquivalent(
       static_cast(aElement.AsDOMNode()), attr, aAlignType,
       false);
     NS_ENSURE_SUCCESS(res, res);
@@ -8370,8 +8368,8 @@ HTMLEditRules::AlignBlock(Element& aElement,
     // supports the align attribute but we'll never know...
     if (HTMLEditUtils::SupportsAlignAttr(aElement.AsDOMNode())) {
       res =
-        mHTMLEditor->SetAttribute(static_cast(aElement.AsDOMNode()),
-                                  attr, aAlignType);
+        htmlEditor->SetAttribute(static_cast(aElement.AsDOMNode()),
+                                 attr, aAlignType);
       NS_ENSURE_SUCCESS(res, res);
     }
   }
@@ -8383,19 +8381,19 @@ HTMLEditRules::ChangeIndentation(Element& aElement,
                                  Change aChange)
 {
   NS_ENSURE_STATE(mHTMLEditor);
-  nsCOMPtr kungFuDeathGrip(mHTMLEditor);
+  RefPtr htmlEditor(mHTMLEditor);
 
   nsIAtom& marginProperty =
-    MarginPropertyAtomForIndent(*mHTMLEditor->mCSSEditUtils, aElement);
+    MarginPropertyAtomForIndent(*htmlEditor->mCSSEditUtils, aElement);
   nsAutoString value;
-  mHTMLEditor->mCSSEditUtils->GetSpecifiedProperty(aElement, marginProperty,
-                                                   value);
+  htmlEditor->mCSSEditUtils->GetSpecifiedProperty(aElement, marginProperty,
+                                                  value);
   float f;
   nsCOMPtr unit;
-  mHTMLEditor->mCSSEditUtils->ParseLength(value, &f, getter_AddRefs(unit));
+  htmlEditor->mCSSEditUtils->ParseLength(value, &f, getter_AddRefs(unit));
   if (0 == f) {
     nsAutoString defaultLengthUnit;
-    mHTMLEditor->mCSSEditUtils->GetDefaultLengthUnit(defaultLengthUnit);
+    htmlEditor->mCSSEditUtils->GetDefaultLengthUnit(defaultLengthUnit);
     unit = NS_Atomize(defaultLengthUnit);
   }
   int8_t multiplier = aChange == Change::plus ? +1 : -1;
@@ -8423,23 +8421,23 @@ HTMLEditRules::ChangeIndentation(Element& aElement,
     nsAutoString newValue;
     newValue.AppendFloat(f);
     newValue.Append(nsDependentAtomString(unit));
-    mHTMLEditor->mCSSEditUtils->SetCSSProperty(aElement, marginProperty,
-                                               newValue);
+    htmlEditor->mCSSEditUtils->SetCSSProperty(aElement, marginProperty,
+                                              newValue);
     return NS_OK;
   }
 
-  mHTMLEditor->mCSSEditUtils->RemoveCSSProperty(aElement, marginProperty,
-                                                value);
+  htmlEditor->mCSSEditUtils->RemoveCSSProperty(aElement, marginProperty,
+                                               value);
 
   // Remove unnecessary divs
   if (!aElement.IsHTMLElement(nsGkAtoms::div) ||
-      &aElement == mHTMLEditor->GetActiveEditingHost() ||
-      !mHTMLEditor->IsDescendantOfEditorRoot(&aElement) ||
+      &aElement == htmlEditor->GetActiveEditingHost() ||
+      !htmlEditor->IsDescendantOfEditorRoot(&aElement) ||
       HTMLEditor::HasAttributes(&aElement)) {
     return NS_OK;
   }
 
-  nsresult res = mHTMLEditor->RemoveContainer(&aElement);
+  nsresult res = htmlEditor->RemoveContainer(&aElement);
   NS_ENSURE_SUCCESS(res, res);
 
   return NS_OK;
@@ -8452,7 +8450,7 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
 {
   MOZ_ASSERT(aCancel && aHandled);
   NS_ENSURE_STATE(mHTMLEditor);
-  nsCOMPtr kungFuDeathGrip(mHTMLEditor);
+  RefPtr htmlEditor(mHTMLEditor);
 
   WillInsert(aSelection, aCancel);
 
@@ -8460,7 +8458,7 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
   *aCancel = false;
   *aHandled = true;
 
-  nsCOMPtr focusElement = mHTMLEditor->GetSelectionContainer();
+  nsCOMPtr focusElement = htmlEditor->GetSelectionContainer();
   if (focusElement && HTMLEditUtils::IsImage(focusElement)) {
     mNewBlock = focusElement;
     return NS_OK;
@@ -8468,7 +8466,7 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
 
   nsresult res = NormalizeSelection(&aSelection);
   NS_ENSURE_SUCCESS(res, res);
-  AutoSelectionRestorer selectionRestorer(&aSelection, mHTMLEditor);
+  AutoSelectionRestorer selectionRestorer(&aSelection, htmlEditor);
 
   // Convert the selection ranges into "promoted" selection ranges: this
   // basically just expands the range to include the immediate block parent,
@@ -8498,14 +8496,14 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
     res = SplitAsNeeded(*nsGkAtoms::div, parent, offset);
     NS_ENSURE_SUCCESS(res, res);
     nsCOMPtr positionedDiv =
-      mHTMLEditor->CreateNode(nsGkAtoms::div, parent, offset);
+      htmlEditor->CreateNode(nsGkAtoms::div, parent, offset);
     NS_ENSURE_STATE(positionedDiv);
     // Remember our new block for postprocessing
     mNewBlock = positionedDiv;
     // Delete anything that was in the list of nodes
     while (!arrayOfNodes.IsEmpty()) {
       OwningNonNull curNode = arrayOfNodes[0];
-      res = mHTMLEditor->DeleteNode(curNode);
+      res = htmlEditor->DeleteNode(curNode);
       NS_ENSURE_SUCCESS(res, res);
       arrayOfNodes.RemoveElementAt(0);
     }
@@ -8527,7 +8525,7 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
     OwningNonNull curNode = *arrayOfNodes[i]->AsContent();
 
     // Ignore all non-editable nodes.  Leave them be.
-    if (!mHTMLEditor->IsEditable(curNode)) {
+    if (!htmlEditor->IsEditable(curNode)) {
       continue;
     }
 
@@ -8541,7 +8539,7 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
       // Check to see if curList is still appropriate.  Which it is if curNode
       // is still right after it in the same list.
       if (curList) {
-        sibling = mHTMLEditor->GetPriorHTMLSibling(curNode);
+        sibling = htmlEditor->GetPriorHTMLSibling(curNode);
       }
 
       if (!curList || (sibling && sibling != curList)) {
@@ -8553,18 +8551,18 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
           nsCOMPtr curParentParent = curParent->GetParentNode();
           int32_t parentOffset = curParentParent
             ? curParentParent->IndexOf(curParent) : -1;
-          curPositionedDiv = mHTMLEditor->CreateNode(nsGkAtoms::div, curParentParent,
-                                                     parentOffset);
+          curPositionedDiv = htmlEditor->CreateNode(nsGkAtoms::div, curParentParent,
+                                                    parentOffset);
           mNewBlock = curPositionedDiv;
         }
-        curList = mHTMLEditor->CreateNode(curParent->NodeInfo()->NameAtom(),
-                                          curPositionedDiv, -1);
+        curList = htmlEditor->CreateNode(curParent->NodeInfo()->NameAtom(),
+                                         curPositionedDiv, -1);
         NS_ENSURE_STATE(curList);
         // curList is now the correct thing to put curNode in.  Remember our
         // new block for postprocessing.
       }
       // Tuck the node into the end of the active list
-      res = mHTMLEditor->MoveNode(curNode, curList, -1);
+      res = htmlEditor->MoveNode(curNode, curList, -1);
       NS_ENSURE_SUCCESS(res, res);
     } else {
       // Not a list item, use blockquote?  If we are inside a list item, we
@@ -8584,7 +8582,7 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
         // Check to see if curList is still appropriate.  Which it is if
         // curNode is still right after it in the same list.
         if (curList) {
-          sibling = mHTMLEditor->GetPriorHTMLSibling(curNode);
+          sibling = htmlEditor->GetPriorHTMLSibling(curNode);
         }
 
         if (!curList || (sibling && sibling != curList)) {
@@ -8596,16 +8594,16 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
             nsCOMPtr curParentParent = curParent->GetParentNode();
             int32_t parentOffset = curParentParent ?
               curParentParent->IndexOf(curParent) : -1;
-            curPositionedDiv = mHTMLEditor->CreateNode(nsGkAtoms::div,
-                                                       curParentParent,
-                                                       parentOffset);
+            curPositionedDiv = htmlEditor->CreateNode(nsGkAtoms::div,
+                                                      curParentParent,
+                                                      parentOffset);
             mNewBlock = curPositionedDiv;
           }
-          curList = mHTMLEditor->CreateNode(curParent->NodeInfo()->NameAtom(),
-                                            curPositionedDiv, -1);
+          curList = htmlEditor->CreateNode(curParent->NodeInfo()->NameAtom(),
+                                           curPositionedDiv, -1);
           NS_ENSURE_STATE(curList);
         }
-        res = mHTMLEditor->MoveNode(listItem, curList, -1);
+        res = htmlEditor->MoveNode(listItem, curList, -1);
         NS_ENSURE_SUCCESS(res, res);
         // Remember we indented this li
         indentedLI = listItem;
@@ -8621,8 +8619,8 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
           }
           res = SplitAsNeeded(*nsGkAtoms::div, curParent, offset);
           NS_ENSURE_SUCCESS(res, res);
-          curPositionedDiv = mHTMLEditor->CreateNode(nsGkAtoms::div, curParent,
-                                                     offset);
+          curPositionedDiv = htmlEditor->CreateNode(nsGkAtoms::div, curParent,
+                                                    offset);
           NS_ENSURE_STATE(curPositionedDiv);
           // Remember our new block for postprocessing
           mNewBlock = curPositionedDiv;
@@ -8630,7 +8628,7 @@ HTMLEditRules::WillAbsolutePosition(Selection& aSelection,
         }
 
         // Tuck the node into the end of the active blockquote
-        res = mHTMLEditor->MoveNode(curNode, curPositionedDiv, -1);
+        res = htmlEditor->MoveNode(curNode, curPositionedDiv, -1);
         NS_ENSURE_SUCCESS(res, res);
         // Forget curList, if any
         curList = nullptr;
@@ -8723,8 +8721,8 @@ HTMLEditRules::DocumentModifiedWorker()
   // DeleteNode below may cause a flush, which could destroy the editor
   nsAutoScriptBlockerSuppressNodeRemoved scriptBlocker;
 
-  nsCOMPtr kungFuDeathGrip(mHTMLEditor);
-  RefPtr selection = mHTMLEditor->GetSelection();
+  RefPtr htmlEditor(mHTMLEditor);
+  RefPtr selection = htmlEditor->GetSelection();
   if (!selection) {
     return;
   }
diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp
index 8c0562134bff..63868e97abcf 100644
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -1492,7 +1492,7 @@ HTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement,
                                      bool aDeleteSelection)
 {
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   nsresult res = NS_ERROR_NOT_INITIALIZED;
 
@@ -1515,7 +1515,7 @@ HTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement,
   bool cancel, handled;
   TextRulesInfo ruleInfo(EditAction::insertElement);
   ruleInfo.insertElement = aElement;
-  res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   if (cancel || (NS_FAILED(res))) return res;
 
   if (!handled)
@@ -1583,7 +1583,7 @@ HTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement,
       }
     }
   }
-  res = mRules->DidDoAction(selection, &ruleInfo, res);
+  res = rules->DidDoAction(selection, &ruleInfo, res);
   return res;
 }
 
@@ -1957,7 +1957,7 @@ HTMLEditor::MakeOrChangeList(const nsAString& aListType,
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   bool cancel, handled;
 
@@ -1972,7 +1972,7 @@ HTMLEditor::MakeOrChangeList(const nsAString& aListType,
   ruleInfo.blockType = &aListType;
   ruleInfo.entireList = entireList;
   ruleInfo.bulletType = &aBulletType;
-  res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   if (cancel || (NS_FAILED(res))) return res;
 
   if (!handled)
@@ -2018,7 +2018,7 @@ HTMLEditor::MakeOrChangeList(const nsAString& aListType,
     }
   }
 
-  res = mRules->DidDoAction(selection, &ruleInfo, res);
+  res = rules->DidDoAction(selection, &ruleInfo, res);
   return res;
 }
 
@@ -2029,7 +2029,7 @@ HTMLEditor::RemoveList(const nsAString& aListType)
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   bool cancel, handled;
 
@@ -2044,12 +2044,12 @@ HTMLEditor::RemoveList(const nsAString& aListType)
   if (aListType.LowerCaseEqualsLiteral("ol"))
     ruleInfo.bOrdered = true;
   else  ruleInfo.bOrdered = false;
-  res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   if (cancel || (NS_FAILED(res))) return res;
 
   // no default behavior for this yet.  what would it mean?
 
-  res = mRules->DidDoAction(selection, &ruleInfo, res);
+  res = rules->DidDoAction(selection, &ruleInfo, res);
   return res;
 }
 
@@ -2060,7 +2060,7 @@ HTMLEditor::MakeDefinitionItem(const nsAString& aItemType)
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   bool cancel, handled;
 
@@ -2073,7 +2073,7 @@ HTMLEditor::MakeDefinitionItem(const nsAString& aItemType)
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
   TextRulesInfo ruleInfo(EditAction::makeDefListItem);
   ruleInfo.blockType = &aItemType;
-  res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   if (cancel || (NS_FAILED(res))) return res;
 
   if (!handled)
@@ -2081,7 +2081,7 @@ HTMLEditor::MakeDefinitionItem(const nsAString& aItemType)
     // todo: no default for now.  we count on rules to handle it.
   }
 
-  res = mRules->DidDoAction(selection, &ruleInfo, res);
+  res = rules->DidDoAction(selection, &ruleInfo, res);
   return res;
 }
 
@@ -2092,7 +2092,7 @@ HTMLEditor::InsertBasicBlock(const nsAString& aBlockType)
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   bool cancel, handled;
 
@@ -2105,7 +2105,7 @@ HTMLEditor::InsertBasicBlock(const nsAString& aBlockType)
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
   TextRulesInfo ruleInfo(EditAction::makeBasicBlock);
   ruleInfo.blockType = &aBlockType;
-  res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   if (cancel || (NS_FAILED(res))) return res;
 
   if (!handled)
@@ -2151,7 +2151,7 @@ HTMLEditor::InsertBasicBlock(const nsAString& aBlockType)
     }
   }
 
-  res = mRules->DidDoAction(selection, &ruleInfo, res);
+  res = rules->DidDoAction(selection, &ruleInfo, res);
   return res;
 }
 
@@ -2162,7 +2162,7 @@ HTMLEditor::Indent(const nsAString& aIndent)
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   bool cancel, handled;
   EditAction opID = EditAction::indent;
@@ -2178,7 +2178,7 @@ HTMLEditor::Indent(const nsAString& aIndent)
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   TextRulesInfo ruleInfo(opID);
-  res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   if (cancel || (NS_FAILED(res))) return res;
 
   if (!handled)
@@ -2230,7 +2230,7 @@ HTMLEditor::Indent(const nsAString& aIndent)
       }
     }
   }
-  res = mRules->DidDoAction(selection, &ruleInfo, res);
+  res = rules->DidDoAction(selection, &ruleInfo, res);
   return res;
 }
 
@@ -2240,12 +2240,11 @@ NS_IMETHODIMP
 HTMLEditor::Align(const nsAString& aAlignType)
 {
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   AutoEditBatch beginBatching(this);
   AutoRules beginRulesSniffing(this, EditAction::align, nsIEditor::eNext);
 
-  nsCOMPtr node;
   bool cancel, handled;
 
   // Find out if the selection is collapsed:
@@ -2253,11 +2252,11 @@ HTMLEditor::Align(const nsAString& aAlignType)
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
   TextRulesInfo ruleInfo(EditAction::align);
   ruleInfo.alignType = &aAlignType;
-  nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  nsresult res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   if (cancel || NS_FAILED(res))
     return res;
 
-  res = mRules->DidDoAction(selection, &ruleInfo, res);
+  res = rules->DidDoAction(selection, &ruleInfo, res);
   return res;
 }
 
@@ -3252,8 +3251,8 @@ HTMLEditor::DoContentInserted(nsIDocument* aDocument,
       return;
     }
     // Protect the edit rules object from dying
-    nsCOMPtr kungFuDeathGrip(mRules);
-    mRules->DocumentModified();
+    nsCOMPtr rules(mRules);
+    rules->DocumentModified();
 
     // Update spellcheck for only the newly-inserted node (bug 743819)
     if (mInlineSpellChecker) {
@@ -3296,8 +3295,8 @@ HTMLEditor::ContentRemoved(nsIDocument* aDocument,
       return;
     }
     // Protect the edit rules object from dying
-    nsCOMPtr kungFuDeathGrip(mRules);
-    mRules->DocumentModified();
+    nsCOMPtr rules(mRules);
+    rules->DocumentModified();
   }
 }
 
@@ -3473,10 +3472,12 @@ HTMLEditor::StartOperation(EditAction opID,
                            nsIEditor::EDirection aDirection)
 {
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   EditorBase::StartOperation(opID, aDirection);  // will set mAction, mDirection
-  if (mRules) return mRules->BeforeEdit(mAction, mDirection);
+  if (rules) {
+    return rules->BeforeEdit(mAction, mDirection);
+  }
   return NS_OK;
 }
 
@@ -3488,11 +3489,13 @@ NS_IMETHODIMP
 HTMLEditor::EndOperation()
 {
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   // post processing
   nsresult res = NS_OK;
-  if (mRules) res = mRules->AfterEdit(mAction, mDirection);
+  if (rules) {
+    res = rules->AfterEdit(mAction, mDirection);
+  }
   EditorBase::EndOperation();  // will clear mAction, mDirection
   return res;
 }
@@ -3549,14 +3552,14 @@ HTMLEditor::SelectEntireDocument(Selection* aSelection)
   if (!aSelection || !mRules) { return NS_ERROR_NULL_POINTER; }
 
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   // get editor root node
   nsCOMPtr rootElement = do_QueryInterface(GetRoot());
 
   // is doc empty?
   bool bDocIsEmpty;
-  nsresult res = mRules->DocumentIsEmpty(&bDocIsEmpty);
+  nsresult res = rules->DocumentIsEmpty(&bDocIsEmpty);
   NS_ENSURE_SUCCESS(res, res);
 
   if (bDocIsEmpty)
@@ -4559,7 +4562,7 @@ HTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
   ForceCompositionEnd();
 
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   RefPtr selection = GetSelection();
   NS_ENSURE_STATE(selection);
@@ -4574,7 +4577,7 @@ HTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
 
   bool cancel, handled;
   TextRulesInfo ruleInfo(EditAction::setTextProperty);
-  nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  nsresult res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   NS_ENSURE_SUCCESS(res, res);
   if (!cancel && !handled) {
     // Loop through the ranges in the selection
@@ -4691,7 +4694,7 @@ HTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
   }
   if (!cancel) {
     // Post-process
-    res = mRules->DidDoAction(selection, &ruleInfo, res);
+    res = rules->DidDoAction(selection, &ruleInfo, res);
     NS_ENSURE_SUCCESS(res, res);
   }
   return NS_OK;
diff --git a/editor/libeditor/HTMLEditorDataTransfer.cpp b/editor/libeditor/HTMLEditorDataTransfer.cpp
index d5f67b628fa5..f6f1f29da6b6 100644
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -119,8 +119,8 @@ HTMLEditor::LoadHTML(const nsAString& aInputString)
   TextRulesInfo ruleInfo(EditAction::loadHTML);
   bool cancel, handled;
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
-  nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  nsCOMPtr rules(mRules);
+  nsresult rv = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   NS_ENSURE_SUCCESS(rv, rv);
   if (cancel) {
     return NS_OK; // rules canceled the operation
@@ -145,7 +145,7 @@ HTMLEditor::LoadHTML(const nsAString& aInputString)
       NS_ENSURE_SUCCESS(rv, rv);
     }
     // put the fragment into the document
-    nsCOMPtr parent, junk;
+    nsCOMPtr parent;
     rv = range->GetStartContainer(getter_AddRefs(parent));
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
@@ -163,7 +163,7 @@ HTMLEditor::LoadHTML(const nsAString& aInputString)
     }
   }
 
-  return mRules->DidDoAction(selection, &ruleInfo, rv);
+  return rules->DidDoAction(selection, &ruleInfo, rv);
 }
 
 NS_IMETHODIMP
@@ -205,7 +205,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
   NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
 
   // Prevent the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   // force IME commit; set up rules sniffing and batching
   ForceCompositionEnd();
@@ -229,7 +229,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
                                            aTrustedInput);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr targetNode, tempNode;
+  nsCOMPtr targetNode;
   int32_t targetOffset=0;
 
   if (!aDestNode)
@@ -367,7 +367,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
   // give rules a chance to handle or cancel
   TextRulesInfo ruleInfo(EditAction::insertElement);
   bool cancel, handled;
-  rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  rv = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   NS_ENSURE_SUCCESS(rv, rv);
   if (cancel) {
     return NS_OK; // rules canceled the operation
@@ -552,7 +552,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
       } else if (parentBlock && HTMLEditUtils::IsPre(parentBlock) &&
                  HTMLEditUtils::IsPre(curNode)) {
         // Check for pre's going into pre's.
-        nsCOMPtr child, tmp;
+        nsCOMPtr child;
         curNode->GetFirstChild(getter_AddRefs(child));
         while (child)
         {
@@ -704,7 +704,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
     }
   }
 
-  return mRules->DidDoAction(selection, &ruleInfo, rv);
+  return rules->DidDoAction(selection, &ruleInfo, rv);
 }
 
 NS_IMETHODIMP
@@ -1689,8 +1689,8 @@ HTMLEditor::PasteAsCitedQuotation(const nsAString& aCitation,
   TextRulesInfo ruleInfo(EditAction::insertElement);
   bool cancel, handled;
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
-  nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  nsCOMPtr rules(mRules);
+  nsresult rv = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   NS_ENSURE_SUCCESS(rv, rv);
   if (cancel || handled) {
     return NS_OK; // rules canceled the operation
@@ -1880,8 +1880,8 @@ HTMLEditor::InsertAsPlaintextQuotation(const nsAString& aQuotedText,
   TextRulesInfo ruleInfo(EditAction::insertElement);
   bool cancel, handled;
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
-  nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  nsCOMPtr rules(mRules);
+  nsresult rv = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   NS_ENSURE_SUCCESS(rv, rv);
   if (cancel || handled) {
     return NS_OK; // rules canceled the operation
@@ -1970,8 +1970,8 @@ HTMLEditor::InsertAsCitedQuotation(const nsAString& aQuotedText,
   TextRulesInfo ruleInfo(EditAction::insertElement);
   bool cancel, handled;
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
-  nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  nsCOMPtr rules(mRules);
+  nsresult rv = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   NS_ENSURE_SUCCESS(rv, rv);
   if (cancel || handled) {
     return NS_OK; // rules canceled the operation
diff --git a/editor/libeditor/HTMLStyleEditor.cpp b/editor/libeditor/HTMLStyleEditor.cpp
index ed8b47d93f21..01d9d28cdba4 100644
--- a/editor/libeditor/HTMLStyleEditor.cpp
+++ b/editor/libeditor/HTMLStyleEditor.cpp
@@ -114,7 +114,7 @@ HTMLEditor::SetInlineProperty(nsIAtom* aProperty,
 {
   NS_ENSURE_TRUE(aProperty, NS_ERROR_NULL_POINTER);
   NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
   ForceCompositionEnd();
 
   RefPtr selection = GetSelection();
@@ -136,7 +136,7 @@ HTMLEditor::SetInlineProperty(nsIAtom* aProperty,
   bool cancel, handled;
   TextRulesInfo ruleInfo(EditAction::setTextProperty);
   // Protect the edit rules object from dying
-  nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  nsresult res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   NS_ENSURE_SUCCESS(res, res);
   if (!cancel && !handled) {
     // Loop through the ranges in the selection
@@ -220,7 +220,7 @@ HTMLEditor::SetInlineProperty(nsIAtom* aProperty,
   }
   if (!cancel) {
     // Post-process
-    return mRules->DidDoAction(selection, &ruleInfo, res);
+    return rules->DidDoAction(selection, &ruleInfo, res);
   }
   return NS_OK;
 }
@@ -1226,8 +1226,8 @@ HTMLEditor::RemoveInlinePropertyImpl(nsIAtom* aProperty,
   bool cancel, handled;
   TextRulesInfo ruleInfo(EditAction::removeTextProperty);
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
-  nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  nsCOMPtr rules(mRules);
+  nsresult res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   NS_ENSURE_SUCCESS(res, res);
   if (!cancel && !handled) {
     // Loop through the ranges in the selection
@@ -1317,7 +1317,7 @@ HTMLEditor::RemoveInlinePropertyImpl(nsIAtom* aProperty,
   }
   if (!cancel) {
     // Post-process
-    res = mRules->DidDoAction(selection, &ruleInfo, res);
+    res = rules->DidDoAction(selection, &ruleInfo, res);
     NS_ENSURE_SUCCESS(res, res);
   }
   return NS_OK;
diff --git a/editor/libeditor/HTMLTableEditor.cpp b/editor/libeditor/HTMLTableEditor.cpp
index ce880da2f540..f713b46be694 100644
--- a/editor/libeditor/HTMLTableEditor.cpp
+++ b/editor/libeditor/HTMLTableEditor.cpp
@@ -520,7 +520,6 @@ NS_IMETHODIMP
 HTMLEditor::InsertTableRow(int32_t aNumber,
                            bool aAfter)
 {
-  RefPtr selection;
   nsCOMPtr table;
   nsCOMPtr curCell;
 
@@ -1106,7 +1105,6 @@ HTMLEditor::DeleteColumn(nsIDOMElement* aTable,
   NS_ENSURE_TRUE(aTable, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr cell;
-  nsCOMPtr cellInDeleteCol;
   int32_t startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
   bool    isSelected;
   int32_t rowIndex = 0;
diff --git a/editor/libeditor/TextEditor.cpp b/editor/libeditor/TextEditor.cpp
index 4cd3fb368abf..d24890ab1a66 100644
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -660,7 +660,7 @@ TextEditor::DeleteSelection(EDirection aAction,
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   nsresult result;
 
@@ -696,7 +696,7 @@ TextEditor::DeleteSelection(EDirection aAction,
   ruleInfo.collapsedAction = aAction;
   ruleInfo.stripWrappers = aStripWrappers;
   bool cancel, handled;
-  result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  result = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   NS_ENSURE_SUCCESS(result, result);
   if (!cancel && !handled)
   {
@@ -705,7 +705,7 @@ TextEditor::DeleteSelection(EDirection aAction,
   if (!cancel)
   {
     // post-process
-    result = mRules->DidDoAction(selection, &ruleInfo, result);
+    result = rules->DidDoAction(selection, &ruleInfo, result);
   }
 
   return result;
@@ -717,7 +717,7 @@ TextEditor::InsertText(const nsAString& aStringToInsert)
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   EditAction opID = EditAction::insertText;
   if (ShouldHandleIMEComposition()) {
@@ -739,7 +739,7 @@ TextEditor::InsertText(const nsAString& aStringToInsert)
   ruleInfo.maxLength = mMaxTextLength;
 
   bool cancel, handled;
-  nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  nsresult res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   NS_ENSURE_SUCCESS(res, res);
   if (!cancel && !handled)
   {
@@ -748,7 +748,7 @@ TextEditor::InsertText(const nsAString& aStringToInsert)
   if (!cancel)
   {
     // post-process
-    res = mRules->DidDoAction(selection, &ruleInfo, res);
+    res = rules->DidDoAction(selection, &ruleInfo, res);
   }
   return res;
 }
@@ -759,7 +759,7 @@ TextEditor::InsertLineBreak()
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   AutoEditBatch beginBatching(this);
   AutoRules beginRulesSniffing(this, EditAction::insertBreak, nsIEditor::eNext);
@@ -771,7 +771,7 @@ TextEditor::InsertLineBreak()
   TextRulesInfo ruleInfo(EditAction::insertBreak);
   ruleInfo.maxLength = mMaxTextLength;
   bool cancel, handled;
-  nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  nsresult res = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   NS_ENSURE_SUCCESS(res, res);
   if (!cancel && !handled)
   {
@@ -824,7 +824,7 @@ TextEditor::InsertLineBreak()
   if (!cancel)
   {
     // post-process, always called if WillInsertBreak didn't return cancel==true
-    res = mRules->DidDoAction(selection, &ruleInfo, res);
+    res = rules->DidDoAction(selection, &ruleInfo, res);
   }
 
   return res;
@@ -838,9 +838,9 @@ TextEditor::BeginIMEComposition(WidgetCompositionEvent* aEvent)
   if (IsPasswordEditor()) {
     NS_ENSURE_TRUE(mRules, NS_ERROR_NULL_POINTER);
     // Protect the edit rules object from dying
-    nsCOMPtr kungFuDeathGrip(mRules);
+    nsCOMPtr rules(mRules);
 
-    TextEditRules* textEditRules = static_cast(mRules.get());
+    TextEditRules* textEditRules = static_cast(rules.get());
     textEditRules->ResetIMETextPWBuf();
   }
 
@@ -921,9 +921,9 @@ TextEditor::GetDocumentIsEmpty(bool* aDocumentIsEmpty)
   NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
 
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
-  return mRules->DocumentIsEmpty(aDocumentIsEmpty);
+  return rules->DocumentIsEmpty(aDocumentIsEmpty);
 }
 
 NS_IMETHODIMP
@@ -1087,7 +1087,7 @@ NS_IMETHODIMP
 TextEditor::Undo(uint32_t aCount)
 {
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   AutoUpdateViewBatch beginViewBatching(this);
 
@@ -1100,12 +1100,12 @@ TextEditor::Undo(uint32_t aCount)
   TextRulesInfo ruleInfo(EditAction::undo);
   RefPtr selection = GetSelection();
   bool cancel, handled;
-  nsresult result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  nsresult result = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
 
   if (!cancel && NS_SUCCEEDED(result))
   {
     result = EditorBase::Undo(aCount);
-    result = mRules->DidDoAction(selection, &ruleInfo, result);
+    result = rules->DidDoAction(selection, &ruleInfo, result);
   }
 
   NotifyEditorObservers(eNotifyEditorObserversOfEnd);
@@ -1116,7 +1116,7 @@ NS_IMETHODIMP
 TextEditor::Redo(uint32_t aCount)
 {
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   AutoUpdateViewBatch beginViewBatching(this);
 
@@ -1129,12 +1129,12 @@ TextEditor::Redo(uint32_t aCount)
   TextRulesInfo ruleInfo(EditAction::redo);
   RefPtr selection = GetSelection();
   bool cancel, handled;
-  nsresult result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  nsresult result = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
 
   if (!cancel && NS_SUCCEEDED(result))
   {
     result = EditorBase::Redo(aCount);
-    result = mRules->DidDoAction(selection, &ruleInfo, result);
+    result = rules->DidDoAction(selection, &ruleInfo, result);
   }
 
   NotifyEditorObservers(eNotifyEditorObserversOfEnd);
@@ -1294,7 +1294,7 @@ TextEditor::OutputToString(const nsAString& aFormatType,
                            nsAString& aOutputString)
 {
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   nsString resultString;
   TextRulesInfo ruleInfo(EditAction::outputText);
@@ -1303,7 +1303,7 @@ TextEditor::OutputToString(const nsAString& aFormatType,
   nsAutoString str(aFormatType);
   ruleInfo.outputFormat = &str;
   bool cancel, handled;
-  nsresult rv = mRules->WillDoAction(nullptr, &ruleInfo, &cancel, &handled);
+  nsresult rv = rules->WillDoAction(nullptr, &ruleInfo, &cancel, &handled);
   if (cancel || NS_FAILED(rv)) { return rv; }
   if (handled)
   { // this case will get triggered by password fields
@@ -1410,7 +1410,7 @@ TextEditor::InsertAsQuotation(const nsAString& aQuotedText,
                               nsIDOMNode** aNodeInserted)
 {
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   // Let the citer quote it for us:
   nsString quotedStuff;
@@ -1432,7 +1432,7 @@ TextEditor::InsertAsQuotation(const nsAString& aQuotedText,
   // give rules a chance to handle or cancel
   TextRulesInfo ruleInfo(EditAction::insertElement);
   bool cancel, handled;
-  rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
+  rv = rules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   NS_ENSURE_SUCCESS(rv, rv);
   if (cancel) return NS_OK; // rules canceled the operation
   if (!handled)
@@ -1550,10 +1550,12 @@ TextEditor::StartOperation(EditAction opID,
                            nsIEditor::EDirection aDirection)
 {
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   EditorBase::StartOperation(opID, aDirection);  // will set mAction, mDirection
-  if (mRules) return mRules->BeforeEdit(mAction, mDirection);
+  if (rules) {
+    return rules->BeforeEdit(mAction, mDirection);
+  }
   return NS_OK;
 }
 
@@ -1565,11 +1567,13 @@ NS_IMETHODIMP
 TextEditor::EndOperation()
 {
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   // post processing
   nsresult res = NS_OK;
-  if (mRules) res = mRules->AfterEdit(mAction, mDirection);
+  if (rules) {
+    res = rules->AfterEdit(mAction, mDirection);
+  }
   EditorBase::EndOperation();  // will clear mAction, mDirection
   return res;
 }
@@ -1580,12 +1584,11 @@ TextEditor::SelectEntireDocument(Selection* aSelection)
   if (!aSelection || !mRules) { return NS_ERROR_NULL_POINTER; }
 
   // Protect the edit rules object from dying
-  nsCOMPtr kungFuDeathGrip(mRules);
+  nsCOMPtr rules(mRules);
 
   // is doc empty?
   bool bDocIsEmpty;
-  if (NS_SUCCEEDED(mRules->DocumentIsEmpty(&bDocIsEmpty)) && bDocIsEmpty)
-  {
+  if (NS_SUCCEEDED(rules->DocumentIsEmpty(&bDocIsEmpty)) && bDocIsEmpty) {
     // get root node
     nsCOMPtr rootElement = do_QueryInterface(GetRoot());
     NS_ENSURE_TRUE(rootElement, NS_ERROR_FAILURE);
diff --git a/editor/txmgr/nsTransactionItem.cpp b/editor/txmgr/nsTransactionItem.cpp
index 222f644226ce..a2d5ea19c172 100644
--- a/editor/txmgr/nsTransactionItem.cpp
+++ b/editor/txmgr/nsTransactionItem.cpp
@@ -255,9 +255,9 @@ nsTransactionItem::RedoTransaction(nsTransactionManager *aTxMgr)
 {
   nsresult result;
 
-  nsCOMPtr kungfuDeathGrip(mTransaction);
-  if (mTransaction) {
-    result = mTransaction->RedoTransaction();
+  nsCOMPtr transaction(mTransaction);
+  if (transaction) {
+    result = transaction->RedoTransaction();
 
     NS_ENSURE_SUCCESS(result, result);
   }
diff --git a/editor/txtsvc/nsTextServicesDocument.cpp b/editor/txtsvc/nsTextServicesDocument.cpp
index 3debeea6c8b1..540e88bf7aae 100644
--- a/editor/txtsvc/nsTextServicesDocument.cpp
+++ b/editor/txtsvc/nsTextServicesDocument.cpp
@@ -3167,7 +3167,6 @@ nsTextServicesDocument::FirstTextNodeInCurrentBlock(nsIContentIterator *iter)
 nsresult
 nsTextServicesDocument::FirstTextNodeInPrevBlock(nsIContentIterator *aIterator)
 {
-  nsCOMPtr content;
   nsresult result;
 
   NS_ENSURE_TRUE(aIterator, NS_ERROR_NULL_POINTER);
diff --git a/embedding/browser/nsWebBrowser.cpp b/embedding/browser/nsWebBrowser.cpp
index 42aac0aa30e4..11f96deff59c 100644
--- a/embedding/browser/nsWebBrowser.cpp
+++ b/embedding/browser/nsWebBrowser.cpp
@@ -1661,7 +1661,11 @@ nsWebBrowser::ScrollByPages(int32_t aNumPages)
 NS_IMETHODIMP
 nsWebBrowser::SetDocShell(nsIDocShell* aDocShell)
 {
+  // We need to keep the docshell alive while we perform the changes, but we
+  // don't need to call any methods on it.
   nsCOMPtr kungFuDeathGrip(mDocShell);
+  mozilla::Unused << kungFuDeathGrip;
+
   if (aDocShell) {
     NS_ENSURE_TRUE(!mDocShell, NS_ERROR_FAILURE);
 
diff --git a/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp b/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp
index 5e1b91f3ac88..605b67753e8f 100644
--- a/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp
+++ b/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp
@@ -1529,7 +1529,6 @@ nsWebBrowserPersist::GetExtensionForContentType(const char16_t *aContentType, ch
         NS_ENSURE_TRUE(mMIMEService, NS_ERROR_FAILURE);
     }
 
-    nsCOMPtr mimeInfo;
     nsAutoCString contentType;
     contentType.AssignWithConversion(aContentType);
     nsAutoCString ext;
diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.cpp b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
index 964d85ef24fd..96011a37e356 100644
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -1805,7 +1805,6 @@ nsresult mozInlineSpellChecker::GetSpellCheckSelection(nsISelection ** aSpellChe
   nsresult rv = editor->GetSelectionController(getter_AddRefs(selcon));
   NS_ENSURE_SUCCESS(rv, rv); 
 
-  nsCOMPtr spellCheckSelection;
   return selcon->GetSelection(nsISelectionController::SELECTION_SPELLCHECK, aSpellCheckSelection);
 }
 
diff --git a/gfx/2d/DrawTargetSkia.cpp b/gfx/2d/DrawTargetSkia.cpp
index 6dfe95374277..124fced56e53 100644
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -11,6 +11,8 @@
 #include "FilterNodeSoftware.h"
 #include "HelpersSkia.h"
 
+#include "mozilla/ArrayUtils.h"
+
 #include "skia/include/core/SkSurface.h"
 #include "skia/include/core/SkTypeface.h"
 #include "skia/include/effects/SkGradientShader.h"
@@ -103,6 +105,12 @@ ReleaseTemporarySurface(void* aPixels, void* aContext)
   }
 }
 
+#ifdef IS_BIG_ENDIAN
+static const int kARGBAlphaOffset = 0;
+#else
+static const int kARGBAlphaOffset = 3;
+#endif
+
 static void
 WriteRGBXFormat(uint8_t* aData, const IntSize &aSize,
                 const int32_t aStride, SurfaceFormat aFormat)
@@ -116,11 +124,7 @@ WriteRGBXFormat(uint8_t* aData, const IntSize &aSize,
 
   for (int row = 0; row < height; ++row) {
     for (int column = 0; column < width; column += 4) {
-#ifdef IS_BIG_ENDIAN
-      aData[column] = 0xFF;
-#else
-      aData[column + 3] = 0xFF;
-#endif
+      aData[column + kARGBAlphaOffset] = 0xFF;
     }
     aData += aStride;
   }
@@ -142,11 +146,14 @@ VerifyRGBXFormat(uint8_t* aData, const IntSize &aSize, const int32_t aStride, Su
 
   for (int row = 0; row < height; ++row) {
     for (int column = 0; column < width; column += 4) {
-#ifdef IS_BIG_ENDIAN
-      MOZ_ASSERT(aData[column] == 0xFF);
-#else
-      MOZ_ASSERT(aData[column + 3] == 0xFF);
-#endif
+      if (aData[column + kARGBAlphaOffset] != 0xFF) {
+        gfxCriticalError() << "RGBX pixel at (" << column << "," << row << ") in "
+                           << width << "x" << height << " surface is not opaque: "
+                           << int(aData[column]) << ","
+                           << int(aData[column+1]) << ","
+                           << int(aData[column+2]) << ","
+                           << int(aData[column+3]);
+      }
     }
     aData += aStride;
   }
@@ -169,27 +176,30 @@ VerifyRGBXCorners(uint8_t* aData, const IntSize &aSize, const int32_t aStride, S
   const int strideDiff = aStride - (width * pixelSize);
   MOZ_ASSERT(width * pixelSize <= aStride);
 
-#ifdef IS_BIG_ENDIAN
-  const int alphaOffset = 0;
-#else
-  const int alphaOffset = 3;
-#endif
-
-  const int topLeft = alphaOffset;
-  const int topRight = width * pixelSize + alphaOffset - pixelSize;
-  const int bottomRight = aStride * height - strideDiff + alphaOffset - pixelSize;
-  const int bottomLeft = aStride * height - aStride + alphaOffset;
+  const int topLeft = kARGBAlphaOffset;
+  const int topRight = width * pixelSize + kARGBAlphaOffset - pixelSize;
+  const int bottomRight = aStride * height - strideDiff + kARGBAlphaOffset - pixelSize;
+  const int bottomLeft = aStride * height - aStride + kARGBAlphaOffset;
 
   // Lastly the center pixel
   int middleRowHeight = height / 2;
   int middleRowWidth = (width / 2) * pixelSize;
-  const int middle = aStride * middleRowHeight + middleRowWidth + alphaOffset;
+  const int middle = aStride * middleRowHeight + middleRowWidth + kARGBAlphaOffset;
 
-  MOZ_ASSERT(aData[topLeft] == 0xFF);
-  MOZ_ASSERT(aData[topRight] == 0xFF);
-  MOZ_ASSERT(aData[bottomRight] == 0xFF);
-  MOZ_ASSERT(aData[bottomLeft] == 0xFF);
-  MOZ_ASSERT(aData[middle] == 0xFF);
+  const int offsets[] = { topLeft, topRight, bottomRight, bottomLeft, middle };
+  for (size_t i = 0; i < MOZ_ARRAY_LENGTH(offsets); i++) {
+    int offset = offsets[i];
+    if (aData[offset] != 0xFF) {
+        int row = offset / aStride;
+        int column = (offset % aStride) / pixelSize;
+        gfxCriticalError() << "RGBX corner pixel at (" << column << "," << row << ") in "
+                           << width << "x" << height << " surface is not opaque: "
+                           << int(aData[column]) << ","
+                           << int(aData[column+1]) << ","
+                           << int(aData[column+2]) << ","
+                           << int(aData[column+3]);
+    }
+  }
 
   return true;
 }
diff --git a/gfx/tests/gtest/TestTreeTraversal.cpp b/gfx/tests/gtest/TestTreeTraversal.cpp
index f16f4b9f85f2..043e28fd5671 100644
--- a/gfx/tests/gtest/TestTreeTraversal.cpp
+++ b/gfx/tests/gtest/TestTreeTraversal.cpp
@@ -1501,7 +1501,6 @@ MOZ_GTEST_BENCH(TreeTraversal, TreeTraversal_ForwardDepthFirstSearchPostOrderPer
 template 
 static RefPtr BreadthFirstSearchForwardQueue(RefPtr aNode)
 {
-  RefPtr returnNode = nullptr;
   queue> nodes;
   nodes.push(aNode);
   while(!nodes.empty()) {
@@ -1951,7 +1950,6 @@ MOZ_GTEST_BENCH(TreeTraversal, TreeTraversal_ReverseDepthFirstSearchPostOrderPer
 template 
 static RefPtr BreadthFirstSearchReverseQueue(RefPtr aNode)
 {
-  RefPtr returnNode = nullptr;
   queue> nodes;
   nodes.push(aNode);
   while(!nodes.empty()) {
diff --git a/hal/moz.build b/hal/moz.build
index 9a511cad8576..eb92f53c64f6 100644
--- a/hal/moz.build
+++ b/hal/moz.build
@@ -20,7 +20,6 @@ EXPORTS.mozilla += [
     'HalWakeLock.h',
 ]
 
-TEST_DIRS += ['tests']
 UNIFIED_SOURCES += [
     'HalWakeLock.cpp',
     'sandbox/SandboxHal.cpp',
diff --git a/hal/tests/browser.ini b/hal/tests/browser.ini
deleted file mode 100644
index 239765dd1063..000000000000
--- a/hal/tests/browser.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[DEFAULT]
-
-[browser_alarms.js]
diff --git a/hal/tests/browser_alarms.js b/hal/tests/browser_alarms.js
deleted file mode 100644
index bf01e0aeaafc..000000000000
--- a/hal/tests/browser_alarms.js
+++ /dev/null
@@ -1,187 +0,0 @@
-XPCOMUtils.defineLazyModuleGetter(this, "AlarmService",
-                                  "resource://gre/modules/AlarmService.jsm");
-
-/*
- * Tests for Bug 867868 and related Alarm API bugs.
- *
- * NOTE: These tests pass the alarm time to AlarmService as a number and not as
- * a date. See bug 810973 about Date truncating milliseconds. AlarmService does
- * not officially allow a integer, but nor does it disallow it. Of course this
- * test will break if AlarmService adds a type check, hence this note.
- * FIXME: when bug 810973 is fixed.
- */
-
-function add_alarm_future(cb) {
-  let alarmId = undefined;
-  AlarmService.add({
-    date: new Date(Date.now() + 143),
-    ignoreTimezone: true
-  },
-  function onAlarmFired(aAlarm) {
-    ok(alarmId === aAlarm.id, "Future alarm fired successfully.");
-    cb();
-  },
-  function onSuccess(aAlarmId) {
-    alarmId = aAlarmId;
-  },
-  function onError(error) {
-    ok(false, "Unexpected error adding future alarm " + error);
-    cb();
-  });
-}
-
-function add_alarm_present(cb) {
-  let self = this;
-  let alarmId = undefined;
-  AlarmService.add({
-    date: new Date(),
-    ignoreTimezone: true
-  },
-  function onAlarmFired(aAlarm) {
-    ok(alarmId === aAlarm.id, "Present alarm fired successfully.");
-    cb();
-  },
-  function onSuccess(aAlarmId) {
-    alarmId = aAlarmId;
-  }, function onError(error) {
-    ok(false, "Unexpected error adding alarm for current time " + error);
-    cb();
-  });
-}
-
-function add_alarm_past(cb) {
-  let self = this;
-  let alarmId = undefined;
-  AlarmService.add({
-    date: new Date(Date.now() - 5),
-    ignoreTimezone: true
-  },
-  function onAlarmFired(aAlarm) {
-    ok(alarmId === aAlarm.id, "Past alarm fired successfully.");
-    cb();
-  },
-  function onSuccess(aAlarmId) {
-    alarmId = aAlarmId;
-  },
-  function onError(error) {
-    ok(false, "Unexpected error adding alarm for time in the past " + error);
-    cb();
-  });
-}
-
-function trigger_all_alarms(cb) {
-  let n = 10;
-  let counter = 0;
-  let date = new Date(Date.now() + 57);
-  function onAlarmFired() {
-    counter++;
-    info("trigger_all_alarms count " + counter);
-    if (counter == n) {
-      ok(true, "All " + n + " alarms set to a particular time fired.");
-      cb();
-    }
-  }
-
-  for (let i = 0; i < n; i++) {
-    AlarmService.add(
-      {
-        date: date,
-        ignoreTimezone: true
-      },
-      onAlarmFired
-    );
-  }
-}
-
-function multiple_handlers(cb) {
-  let d = new Date(Date.now() + 100);
-  let called = 0;
-
-  function done() {
-    if (called == 2) {
-      ok(true, "Two alarms for the same time fired.");
-      cb();
-    }
-  }
-
-  function handler1() {
-    called++;
-    done();
-  }
-
-  function handler2() {
-    called++;
-    done();
-  }
-
-  AlarmService.add(
-    {
-      date: d,
-      ignoreTimezone: true
-    },
-    handler1
-  );
-  AlarmService.add(
-    {
-      date: d,
-      ignoreTimezone: true
-    },
-    handler2
-  );
-}
-
-function same_time_alarms(cb) {
-  var fired = 0;
-  var delay = new Date(Date.now() + 100);
-
-  function check() {
-    fired++;
-    if (fired == 4) {
-      ok(true, "All alarms set for the same time fired.");
-      cb();
-    }
-  }
-
-  function addImmediateAlarm() {
-    fired++;
-    AlarmService.add({
-      date: delay,
-      ignoreTimezone: true
-    }, check);
-  }
-
-  AlarmService.add({
-    date: delay,
-    ignoreTimezone: true
-  }, addImmediateAlarm);
-
-  AlarmService.add({
-    date: delay,
-    ignoreTimezone: true
-  }, addImmediateAlarm);
-}
-
-function test() {
-  var tests = [
-    add_alarm_future,
-    add_alarm_present,
-    add_alarm_past,
-    trigger_all_alarms,
-    multiple_handlers,
-    same_time_alarms
-  ]
-
-  var testIndex = -1;
-  function nextTest() {
-    testIndex++;
-    if (testIndex >= tests.length)
-      return;
-
-    waitForExplicitFinish();
-    tests[testIndex](function() {
-      finish();
-      nextTest();
-    });
-  }
-  nextTest();
-}
diff --git a/hal/tests/moz.build b/hal/tests/moz.build
deleted file mode 100644
index 438916bed679..000000000000
--- a/hal/tests/moz.build
+++ /dev/null
@@ -1,6 +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/.
-
-BROWSER_CHROME_MANIFESTS += ['browser.ini']
-
diff --git a/image/SVGDocumentWrapper.cpp b/image/SVGDocumentWrapper.cpp
index ed6fb6a87643..6a04e570e919 100644
--- a/image/SVGDocumentWrapper.cpp
+++ b/image/SVGDocumentWrapper.cpp
@@ -368,8 +368,7 @@ SVGDocumentWrapper::SetupViewer(nsIRequest* aRequest,
   NS_ENSURE_TRUE(parser, NS_ERROR_UNEXPECTED);
 
   // XML-only, because this is for SVG content
-  nsIContentSink* sink = parser->GetContentSink();
-  nsCOMPtr xmlSink = do_QueryInterface(sink);
+  nsCOMPtr sink = parser->GetContentSink();
   NS_ENSURE_TRUE(sink, NS_ERROR_UNEXPECTED);
 
   listener.swap(mListener);
diff --git a/image/imgRequestProxy.cpp b/image/imgRequestProxy.cpp
index 97a17794f5f1..4ccf1ff1d2ac 100644
--- a/image/imgRequestProxy.cpp
+++ b/image/imgRequestProxy.cpp
@@ -787,7 +787,7 @@ imgRequestProxy::Notify(int32_t aType, const mozilla::gfx::IntRect* aRect)
   // Make sure the listener stays alive while we notify.
   nsCOMPtr listener(mListener);
 
-  mListener->Notify(this, aType, aRect);
+  listener->Notify(this, aType, aRect);
 }
 
 void
@@ -807,8 +807,8 @@ imgRequestProxy::OnLoadComplete(bool aLastPart)
 
   if (mListener && !mCanceled) {
     // Hold a ref to the listener while we call it, just in case.
-    nsCOMPtr kungFuDeathGrip(mListener);
-    mListener->Notify(this, imgINotificationObserver::LOAD_COMPLETE, nullptr);
+    nsCOMPtr listener(mListener);
+    listener->Notify(this, imgINotificationObserver::LOAD_COMPLETE, nullptr);
   }
 
   // If we're expecting more data from a multipart channel, re-add ourself
diff --git a/ipc/ril/RilSocket.cpp b/ipc/ril/RilSocket.cpp
index 4ff71d253ae7..490a74ac0abf 100644
--- a/ipc/ril/RilSocket.cpp
+++ b/ipc/ril/RilSocket.cpp
@@ -12,6 +12,7 @@
 #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
 #include "nsXULAppAPI.h"
 #include "RilSocketConsumer.h"
+#include "mozilla/Unused.h"
 
 static const size_t MAX_READ_SIZE = 1 << 16;
 
diff --git a/js/src/asmjs/WasmCompile.cpp b/js/src/asmjs/WasmCompile.cpp
index 6b1f0344f09f..4fd969a7ec02 100644
--- a/js/src/asmjs/WasmCompile.cpp
+++ b/js/src/asmjs/WasmCompile.cpp
@@ -613,7 +613,7 @@ DecodeFunctionSection(Decoder& d, ModuleGeneratorData* init)
 }
 
 static UniqueChars
-MaybeDecodeName(Decoder& d)
+DecodeName(Decoder& d)
 {
     uint32_t numBytes;
     if (!d.readVarU32(&numBytes))
@@ -774,28 +774,22 @@ DecodeImport(Decoder& d, bool newFormat, ModuleGeneratorData* init, ImportVector
         if (!init->funcImports.emplaceBack(sig))
             return false;
 
-        UniqueChars moduleName = MaybeDecodeName(d);
+        UniqueChars moduleName = DecodeName(d);
         if (!moduleName)
             return Fail(d, "expected valid import module name");
 
-        if (!strlen(moduleName.get()))
-            return Fail(d, "module name cannot be empty");
-
-        UniqueChars funcName = MaybeDecodeName(d);
+        UniqueChars funcName = DecodeName(d);
         if (!funcName)
             return Fail(d, "expected valid import func name");
 
         return imports->emplaceBack(Move(moduleName), Move(funcName), DefinitionKind::Function);
     }
 
-    UniqueChars moduleName = MaybeDecodeName(d);
+    UniqueChars moduleName = DecodeName(d);
     if (!moduleName)
         return Fail(d, "expected valid import module name");
 
-    if (!strlen(moduleName.get()))
-        return Fail(d, "module name cannot be empty");
-
-    UniqueChars funcName = MaybeDecodeName(d);
+    UniqueChars funcName = DecodeName(d);
     if (!funcName)
         return Fail(d, "expected valid import func name");
 
@@ -1074,7 +1068,7 @@ typedef HashSet CStringSet;
 static UniqueChars
 DecodeExportName(Decoder& d, CStringSet* dupSet)
 {
-    UniqueChars exportName = MaybeDecodeName(d);
+    UniqueChars exportName = DecodeName(d);
     if (!exportName) {
         Fail(d, "expected valid export name");
         return nullptr;
diff --git a/js/src/asmjs/WasmJS.cpp b/js/src/asmjs/WasmJS.cpp
index b3cfd88633e8..4a41483e5db2 100644
--- a/js/src/asmjs/WasmJS.cpp
+++ b/js/src/asmjs/WasmJS.cpp
@@ -106,14 +106,12 @@ GetImports(JSContext* cx,
         if (!GetProperty(cx, importObj, import.module.get(), &v))
             return false;
 
-        if (strlen(import.func.get()) > 0) {
-            if (!v.isObject())
-                return Throw(cx, JSMSG_WASM_BAD_IMPORT_FIELD, "an Object");
+        if (!v.isObject())
+            return Throw(cx, JSMSG_WASM_BAD_IMPORT_FIELD, "an Object");
 
-            RootedObject obj(cx, &v.toObject());
-            if (!GetProperty(cx, obj, import.func.get(), &v))
-                return false;
-        }
+        RootedObject obj(cx, &v.toObject());
+        if (!GetProperty(cx, obj, import.func.get(), &v))
+            return false;
 
         switch (import.kind) {
           case DefinitionKind::Function:
@@ -1288,6 +1286,36 @@ WebAssembly_compile(JSContext* cx, unsigned argc, Value* vp)
 }
 #endif
 
+static bool
+WebAssembly_validate(JSContext* cx, unsigned argc, Value* vp)
+{
+    CallArgs callArgs = CallArgsFromVp(argc, vp);
+
+    MutableBytes bytecode;
+    CompileArgs compileArgs;
+    if (!GetCompileArgs(cx, callArgs, "WebAssembly.validate", &bytecode, &compileArgs))
+        return false;
+
+    UniqueChars error;
+    bool validated = !!Compile(*bytecode, compileArgs, &error);
+
+    // If the reason for validation failure was OOM (signalled by null error
+    // message), report out-of-memory so that validate's return is always
+    // correct.
+    if (!validated && !error) {
+        ReportOutOfMemory(cx);
+        return false;
+    }
+
+    if (error) {
+        JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING, GetErrorMessage, nullptr,
+                                     JSMSG_WASM_DECODE_FAIL, "?", error.get());
+    }
+
+    callArgs.rval().setBoolean(validated);
+    return true;
+}
+
 static const JSFunctionSpec WebAssembly_static_methods[] =
 {
 #if JS_HAS_TOSOURCE
@@ -1296,6 +1324,7 @@ static const JSFunctionSpec WebAssembly_static_methods[] =
 #ifdef SPIDERMONKEY_PROMISE
     JS_FN("compile", WebAssembly_compile, 1, 0),
 #endif
+    JS_FN("validate", WebAssembly_validate, 1, 0),
     JS_FS_END
 };
 
diff --git a/js/src/builtin/ModuleObject.cpp b/js/src/builtin/ModuleObject.cpp
index cb93a3b08748..b6fb69b2f7ce 100644
--- a/js/src/builtin/ModuleObject.cpp
+++ b/js/src/builtin/ModuleObject.cpp
@@ -411,7 +411,15 @@ ModuleNamespaceObject::ProxyHandler::getOwnPropertyDescriptor(JSContext* cx, Han
             return true;
         }
 
-        // TODO: Implement @@toStringTag here and in has() and get() methods.
+        if (symbol == cx->wellKnownSymbols().toStringTag) {
+            RootedValue value(cx, StringValue(cx->names().Module));
+            desc.object().set(proxy);
+            desc.setWritable(false);
+            desc.setEnumerable(false);
+            desc.setConfigurable(true);
+            desc.setValue(value);
+            return true;
+        }
 
         return true;
     }
@@ -450,10 +458,8 @@ ModuleNamespaceObject::ProxyHandler::has(JSContext* cx, HandleObject proxy, Hand
     Rooted ns(cx, &proxy->as());
     if (JSID_IS_SYMBOL(id)) {
         Rooted symbol(cx, JSID_TO_SYMBOL(id));
-        if (symbol == cx->wellKnownSymbols().iterator)
-            return true;
-
-        return false;
+        return symbol == cx->wellKnownSymbols().iterator ||
+               symbol == cx->wellKnownSymbols().toStringTag;
     }
 
     *bp = ns->bindings().has(id);
@@ -472,6 +478,11 @@ ModuleNamespaceObject::ProxyHandler::get(JSContext* cx, HandleObject proxy, Hand
             return true;
         }
 
+        if (symbol == cx->wellKnownSymbols().toStringTag) {
+            vp.setString(cx->names().Module);
+            return true;
+        }
+
         return false;
     }
 
diff --git a/js/src/gc/Nursery.cpp b/js/src/gc/Nursery.cpp
index 50bac46d230b..35631b942c03 100644
--- a/js/src/gc/Nursery.cpp
+++ b/js/src/gc/Nursery.cpp
@@ -953,18 +953,13 @@ js::Nursery::queueSweepAction(SweepThunk thunk, void* data)
 {
     static_assert(sizeof(SweepAction) % CellSize == 0,
                   "SweepAction size must be a multiple of cell size");
-    MOZ_ASSERT(!runtime()->mainThread.suppressGC);
 
-    SweepAction* action = nullptr;
-    if (isEnabled() && !js::oom::ShouldFailWithOOM())
-        action = reinterpret_cast(allocate(sizeof(SweepAction)));
+    MOZ_ASSERT(isEnabled());
 
-    if (!action) {
-        runtime()->gc.evictNursery();
-        AutoSetThreadIsSweeping threadIsSweeping;
-        thunk(data);
-        return;
-    }
+    AutoEnterOOMUnsafeRegion oomUnsafe;
+    auto action = reinterpret_cast(allocate(sizeof(SweepAction)));
+    if (!action)
+        oomUnsafe.crash("Nursery::queueSweepAction");
 
     new (action) SweepAction(thunk, data, sweepActions_);
     sweepActions_ = action;
diff --git a/js/src/gc/RootMarking.cpp b/js/src/gc/RootMarking.cpp
index bf0322570f7f..cc7be72a4008 100644
--- a/js/src/gc/RootMarking.cpp
+++ b/js/src/gc/RootMarking.cpp
@@ -379,6 +379,9 @@ js::gc::GCRuntime::traceRuntimeCommon(JSTracer* trc, TraceOrMarkRuntime traceOrM
     // Trace SPS.
     rt->spsProfiler.trace(trc);
 
+    // Trace helper thread roots.
+    HelperThreadState().trace(trc);
+
     // Trace the embedding's black and gray roots.
     if (!rt->isHeapMinorCollecting()) {
         gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_EMBEDDING);
diff --git a/js/src/jit-test/lib/asm.js b/js/src/jit-test/lib/asm.js
index 4724912556ea..4f5afa903c0a 100644
--- a/js/src/jit-test/lib/asm.js
+++ b/js/src/jit-test/lib/asm.js
@@ -2,7 +2,6 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-const ASM_OK_STRING = "successfully compiled asm.js code";
 const ASM_TYPE_FAIL_STRING = "asm.js type error:";
 const ASM_DIRECTIVE_FAIL_STRING = "\"use asm\" is only meaningful in the Directive Prologue of a function body";
 
diff --git a/js/src/jit-test/lib/wasm.js b/js/src/jit-test/lib/wasm.js
index 5948078a000a..1b4820d3ff8a 100644
--- a/js/src/jit-test/lib/wasm.js
+++ b/js/src/jit-test/lib/wasm.js
@@ -3,6 +3,41 @@ if (!wasmIsSupported())
 
 load(libdir + "asserts.js");
 
+function textToBinary(str) {
+    // TODO when mass-switching to the new-format, just rename
+    // textToBinary to wasmTextToBinary and remove this function.
+    return wasmTextToBinary(str, 'new-format');
+}
+
+function evalText(str, imports) {
+    // TODO when mass-switching to the new-format, just rename
+    // evalText to wasmEvalText and remove the function wasmEvalText
+    // below.
+    let binary = wasmTextToBinary(str, 'new-format');
+    let valid = WebAssembly.validate(binary);
+
+    let m;
+    try {
+        m = new WebAssembly.Module(binary);
+        assertEq(valid, true);
+    } catch(e) {
+        assertEq(valid, false);
+        throw e;
+    }
+
+    return new WebAssembly.Instance(m, imports);
+}
+
+function wasmValidateText(str) {
+    assertEq(WebAssembly.validate(wasmTextToBinary(str, 'new-format')), true);
+}
+
+function wasmFailValidateText(str, errorType, pattern) {
+    let binary = wasmTextToBinary(str, 'new-format');
+    assertEq(WebAssembly.validate(binary), false);
+    assertErrorMessage(() => new WebAssembly.Module(binary), errorType, pattern);
+}
+
 function wasmEvalText(str, imports) {
     var exports = Wasm.instantiateModule(wasmTextToBinary(str), imports).exports;
     if (Object.keys(exports).length == 1 && exports[""])
diff --git a/js/src/jit-test/tests/basic/bug1296015.js b/js/src/jit-test/tests/basic/bug1296015.js
new file mode 100644
index 000000000000..ce1b270d212a
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug1296015.js
@@ -0,0 +1,9 @@
+function f() {
+    for (var i=0; i<30000; i++) {
+        var a = inIon() ? 0 : 300;
+        var buf = new Uint8ClampedArray(a);
+        (function() {}) * this;
+    }
+    try {} catch(e) {}
+}
+f();
diff --git a/js/src/jit-test/tests/basic/bug1300548.js b/js/src/jit-test/tests/basic/bug1300548.js
new file mode 100644
index 000000000000..f70f560bfc0a
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug1300548.js
@@ -0,0 +1,13 @@
+var g1 = newGlobal();
+var g2 = newGlobal({sameZoneAs: g1});
+function f() {
+    var o = Object.create(null);
+    for (var p in o) {};
+}
+g1.eval(f.toSource());
+g2.eval(f.toSource());
+
+for (var i=0; i<10; i++) {
+    g1.eval("f()");
+    g2.eval("f()");
+}
diff --git a/js/src/jit-test/tests/debug/Memory-takeCensus-11.js b/js/src/jit-test/tests/debug/Memory-takeCensus-11.js
index 3763b9d0c361..c9c65b00320f 100644
--- a/js/src/jit-test/tests/debug/Memory-takeCensus-11.js
+++ b/js/src/jit-test/tests/debug/Memory-takeCensus-11.js
@@ -2,6 +2,7 @@
 
 const g = newGlobal();
 g.eval("setLazyParsingDisabled(true)");
+g.eval("setJitCompilerOption('ion.warmup.trigger', 1000)");
 
 const dbg = new Debugger(g);
 
diff --git a/js/src/jit-test/tests/gc/bug-1298356.js b/js/src/jit-test/tests/gc/bug-1298356.js
new file mode 100644
index 000000000000..ced15ec61895
--- /dev/null
+++ b/js/src/jit-test/tests/gc/bug-1298356.js
@@ -0,0 +1,7 @@
+if (!('oomTest' in this))
+    quit();
+
+/x/;
+oomTest(function(){
+    offThreadCompileScript('');
+})
diff --git a/js/src/jit-test/tests/modules/import-namespace.js b/js/src/jit-test/tests/modules/import-namespace.js
index 500c3e70db6f..f44d4568aae2 100644
--- a/js/src/jit-test/tests/modules/import-namespace.js
+++ b/js/src/jit-test/tests/modules/import-namespace.js
@@ -54,6 +54,16 @@ assertThrowsInstanceOf(function() { ns.a = 1; }, TypeError);
 delete ns.foo;
 assertThrowsInstanceOf(function() { delete ns.a; }, TypeError);
 
+// Test @@toStringTag property
+desc = Object.getOwnPropertyDescriptor(ns, Symbol.toStringTag);
+assertEq(desc.value, "Module");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+assertEq(typeof desc.get, "undefined");
+assertEq(typeof desc.set, "undefined");
+assertEq(Object.prototype.toString.call(ns), "[object Module]");
+
 // Test @@iterator method.
 let iteratorFun = ns[Symbol.iterator];
 assertEq(iteratorFun.name, "[Symbol.iterator]");
diff --git a/js/src/jit-test/tests/wasm/basic.js b/js/src/jit-test/tests/wasm/basic.js
index 42e3314fd608..7452d83422f2 100644
--- a/js/src/jit-test/tests/wasm/basic.js
+++ b/js/src/jit-test/tests/wasm/basic.js
@@ -24,13 +24,13 @@ assertEq(desc.enumerable, true);
 assertEq(desc.configurable, true);
 assertEq(desc.value(), undefined);
 
-wasmEvalText('(module (func) (func) (export "a" 0))');
-wasmEvalText('(module (func) (func) (export "a" 1))');
-wasmEvalText('(module (func $a) (func $b) (export "a" $a) (export "b" $b))');
-wasmEvalText('(module (func $a) (func $b) (export "a" $a) (export "b" $b))');
+wasmValidateText('(module (func) (func) (export "a" 0))');
+wasmValidateText('(module (func) (func) (export "a" 1))');
+wasmValidateText('(module (func $a) (func $b) (export "a" $a) (export "b" $b))');
+wasmValidateText('(module (func $a) (func $b) (export "a" $a) (export "b" $b))');
 
-assertErrorMessage(() => wasmEvalText('(module (func) (export "a" 1))'), TypeError, /exported function index out of bounds/);
-assertErrorMessage(() => wasmEvalText('(module (func) (func) (export "a" 2))'), TypeError, /exported function index out of bounds/);
+wasmFailValidateText('(module (func) (export "a" 1))', TypeError, /exported function index out of bounds/);
+wasmFailValidateText('(module (func) (func) (export "a" 2))', TypeError, /exported function index out of bounds/);
 
 var o = wasmEvalText('(module (func) (export "a" 0) (export "b" 0))');
 assertEq(Object.getOwnPropertyNames(o).sort().toString(), "a,b");
@@ -57,25 +57,26 @@ assertErrorMessage(() => wasmEvalText('(module (func) (func) (export "a" 0) (exp
 // ----------------------------------------------------------------------------
 // signatures
 
-assertErrorMessage(() => wasmEvalText('(module (func (result i32)))'), TypeError, mismatchError("void", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (nop)))'), TypeError, mismatchError("void", "i32"));
-wasmEvalText('(module (func (nop)))');
-wasmEvalText('(module (func (result i32) (i32.const 42)))');
-wasmEvalText('(module (func (param i32)))');
-wasmEvalText('(module (func (param i32) (result i32) (i32.const 42)))');
-wasmEvalText('(module (func (result i32) (param i32) (i32.const 42)))');
-wasmEvalText('(module (func (param f32)))');
-wasmEvalText('(module (func (param f64)))');
+wasmFailValidateText('(module (func (result i32)))', TypeError, mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (result i32) (nop)))', TypeError, mismatchError("void", "i32"));
+
+wasmValidateText('(module (func (nop)))');
+wasmValidateText('(module (func (result i32) (i32.const 42)))');
+wasmValidateText('(module (func (param i32)))');
+wasmValidateText('(module (func (param i32) (result i32) (i32.const 42)))');
+wasmValidateText('(module (func (result i32) (param i32) (i32.const 42)))');
+wasmValidateText('(module (func (param f32)))');
+wasmValidateText('(module (func (param f64)))');
 
 var f = wasmEvalText('(module (func (param i64) (result i32) (i32.const 123)) (export "" 0))');
-assertErrorMessage(() => f(), TypeError, /i64/);
+assertErrorMessage(f, TypeError, /i64/);
 var f = wasmEvalText('(module (func (param i32) (result i64) (i64.const 123)) (export "" 0))');
-assertErrorMessage(() => f(), TypeError, /i64/);
+assertErrorMessage(f, TypeError, /i64/);
 
 var f = wasmEvalText('(module (import $imp "a" "b" (param i64) (result i32)) (func $f (call_import $imp (i64.const 0))) (export "" $f))', {a:{b:()=>{}}});
-assertErrorMessage(() => f(), TypeError, /i64/);
+assertErrorMessage(f, TypeError, /i64/);
 var f = wasmEvalText('(module (import $imp "a" "b" (result i64)) (func $f (call_import $imp)) (export "" $f))', {a:{b:()=>{}}});
-assertErrorMessage(() => f(), TypeError, /i64/);
+assertErrorMessage(f, TypeError, /i64/);
 
 setJitCompilerOption('wasm.test-mode', 1);
 assertEqI64(wasmEvalText('(module (func (result i64) (i64.const 123)) (export "" 0))')(), {low: 123, high: 0});
@@ -103,29 +104,29 @@ assertErrorMessage(() => wasmEvalText(code, {a:{b:1}}), TypeError, notFunction);
 wasmEvalText(code, {a:{b:()=>{}}});
 
 var code = '(module (import "" "b"))';
-assertErrorMessage(() => wasmEvalText(code), TypeError, /module name cannot be empty/);
+wasmEvalText(code, {"":{b:()=>{}}});
 
 var code = '(module (import "a" ""))';
 assertErrorMessage(() => wasmEvalText(code), TypeError, noImportObj);
-assertErrorMessage(() => wasmEvalText(code, {}), TypeError, notFunction);
-assertErrorMessage(() => wasmEvalText(code, {a:1}), TypeError, notFunction);
-wasmEvalText(code, {a:()=>{}});
+assertErrorMessage(() => wasmEvalText(code, {}), TypeError, notObject);
+assertErrorMessage(() => wasmEvalText(code, {a:1}), TypeError, notObject);
+wasmEvalText(code, {a:{"":()=>{}}});
 
 var code = '(module (import "a" "") (import "b" "c") (import "c" ""))';
 assertErrorMessage(() => wasmEvalText(code, {a:()=>{}, b:{c:()=>{}}, c:{}}), TypeError, notFunction);
-wasmEvalText(code, {a:()=>{}, b:{c:()=>{}}, c:()=>{}});
+wasmEvalText(code, {a:{"":()=>{}}, b:{c:()=>{}}, c:{"":()=>{}}});
 
-wasmEvalText('(module (import "a" "" (result i32)))', {a: ()=> {}});
-wasmEvalText('(module (import "a" "" (result f32)))', {a: ()=> {}});
-wasmEvalText('(module (import "a" "" (result f64)))', {a: ()=> {}});
-wasmEvalText('(module (import $foo "a" "" (result f64)))', {a: ()=> {}});
+wasmEvalText('(module (import "a" "" (result i32)))', {a:{"":()=>{}}});
+wasmEvalText('(module (import "a" "" (result f32)))', {a:{"":()=>{}}});
+wasmEvalText('(module (import "a" "" (result f64)))', {a:{"":()=>{}}});
+wasmEvalText('(module (import $foo "a" "" (result f64)))', {a:{"":()=>{}}});
 
 // ----------------------------------------------------------------------------
 // memory
 
-wasmEvalText('(module (memory 0))');
-wasmEvalText('(module (memory 1))');
-assertErrorMessage(() => wasmEvalText('(module (memory 65536))'), TypeError, /initial memory size too big/);
+wasmValidateText('(module (memory 0))');
+wasmValidateText('(module (memory 1))');
+wasmFailValidateText('(module (memory 65536))', TypeError, /initial memory size too big/);
 
 // May OOM, but must not crash:
 try {
@@ -134,57 +135,6 @@ try {
     assertEq(String(e).indexOf("out of memory") != -1, true);
 }
 
-// Tests to reinstate pending a switch back to "real" memory exports:
-//
-//assertErrorMessage(() => wasmEvalText('(module (export "" memory))'), TypeError, /no memory section/);
-//
-//var buf = wasmEvalText('(module (memory 1) (export "" memory))');
-//assertEq(buf instanceof ArrayBuffer, true);
-//assertEq(buf.byteLength, 65536);
-//
-//assertErrorMessage(() => wasmEvalText('(module (memory 1) (export "a" memory) (export "a" memory))'), TypeError, /duplicate export/);
-//assertErrorMessage(() => wasmEvalText('(module (memory 1) (func) (export "a" memory) (export "a" 0))'), TypeError, /duplicate export/);
-//var {a, b} = wasmEvalText('(module (memory 1) (export "a" memory) (export "b" memory))');
-//assertEq(a instanceof ArrayBuffer, true);
-//assertEq(a, b);
-//
-//var obj = wasmEvalText('(module (memory 1) (func (result i32) (i32.const 42)) (func (nop)) (export "a" memory) (export "b" 0) (export "c" 1))');
-//assertEq(obj.a instanceof ArrayBuffer, true);
-//assertEq(obj.b instanceof Function, true);
-//assertEq(obj.c instanceof Function, true);
-//assertEq(obj.a.byteLength, 65536);
-//assertEq(obj.b(), 42);
-//assertEq(obj.c(), undefined);
-//
-//var obj = wasmEvalText('(module (memory 1) (func (result i32) (i32.const 42)) (export "" memory) (export "a" 0) (export "b" 0))');
-//assertEq(obj instanceof ArrayBuffer, true);
-//assertEq(obj.a instanceof Function, true);
-//assertEq(obj.b instanceof Function, true);
-//assertEq(obj.a, obj.b);
-//assertEq(obj.byteLength, 65536);
-//assertEq(obj.a(), 42);
-//
-//var buf = wasmEvalText('(module (memory 1 (segment 0 "")) (export "" memory))');
-//assertEq(new Uint8Array(buf)[0], 0);
-//
-//var buf = wasmEvalText('(module (memory 1 (segment 65536 "")) (export "" memory))');
-//assertEq(new Uint8Array(buf)[0], 0);
-//
-//var buf = wasmEvalText('(module (memory 1 (segment 0 "a")) (export "" memory))');
-//assertEq(new Uint8Array(buf)[0], 'a'.charCodeAt(0));
-//
-//var buf = wasmEvalText('(module (memory 1 (segment 0 "a") (segment 2 "b")) (export "" memory))');
-//assertEq(new Uint8Array(buf)[0], 'a'.charCodeAt(0));
-//assertEq(new Uint8Array(buf)[1], 0);
-//assertEq(new Uint8Array(buf)[2], 'b'.charCodeAt(0));
-//
-//var buf = wasmEvalText('(module (memory 1 (segment 65535 "c")) (export "" memory))');
-//assertEq(new Uint8Array(buf)[0], 0);
-//assertEq(new Uint8Array(buf)[65535], 'c'.charCodeAt(0));
-//
-//assertErrorMessage(() => wasmEvalText('(module (memory 1 (segment 65536 "a")) (export "" memory))'), TypeError, /data segment does not fit/);
-//assertErrorMessage(() => wasmEvalText('(module (memory 1 (segment 65535 "ab")) (export "" memory))'), TypeError, /data segment does not fit/);
-
 var buf = wasmEvalText('(module (memory 1) (export "memory" memory))').memory;
 assertEq(buf instanceof ArrayBuffer, true);
 assertEq(buf.byteLength, 65536);
@@ -215,8 +165,8 @@ var buf = wasmEvalText('(module (memory 1 (segment 65535 "c")) (export "memory"
 assertEq(new Uint8Array(buf)[0], 0);
 assertEq(new Uint8Array(buf)[65535], 'c'.charCodeAt(0));
 
-assertErrorMessage(() => wasmEvalText('(module (memory 1 (segment 65536 "a")) (export "memory" memory))'), TypeError, /data segment does not fit/);
-assertErrorMessage(() => wasmEvalText('(module (memory 1 (segment 65535 "ab")) (export "memory" memory))'), TypeError, /data segment does not fit/);
+wasmFailValidateText('(module (memory 1 (segment 65536 "a")) (export "memory" memory))', TypeError, /data segment does not fit/);
+wasmFailValidateText('(module (memory 1 (segment 65535 "ab")) (export "memory" memory))', TypeError, /data segment does not fit/);
 
 // ----------------------------------------------------------------------------
 // locals
@@ -226,79 +176,82 @@ assertEq(wasmEvalText('(module (func (param i32) (result i32) (get_local 0)) (ex
 assertEq(wasmEvalText('(module (func (param i32) (param i32) (result i32) (get_local 0)) (export "" 0))')(42, 43), 42);
 assertEq(wasmEvalText('(module (func (param i32) (param i32) (result i32) (get_local 1)) (export "" 0))')(42, 43), 43);
 
-assertErrorMessage(() => wasmEvalText('(module (func (get_local 0)))'), TypeError, /get_local index out of range/);
-wasmEvalText('(module (func (local i32)))');
-wasmEvalText('(module (func (local i32) (local f32)))');
+wasmFailValidateText('(module (func (get_local 0)))', TypeError, /get_local index out of range/);
+wasmValidateText('(module (func (local i32)))');
+wasmValidateText('(module (func (local i32) (local f32)))');
 assertEq(wasmEvalText('(module (func (result i32) (local i32) (get_local 0)) (export "" 0))')(), 0);
-assertErrorMessage(() => wasmEvalText('(module (func (result f32) (local i32) (get_local 0)))'), TypeError, mismatchError("i32", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (local f32) (get_local 0)))'), TypeError, mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (result f32) (local i32) (get_local 0)))', TypeError, mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (result i32) (local f32) (get_local 0)))', TypeError, mismatchError("f32", "i32"));
 assertEq(wasmEvalText('(module (func (result i32) (param i32) (local f32) (get_local 0)) (export "" 0))')(), 0);
 assertEq(wasmEvalText('(module (func (result f32) (param i32) (local f32) (get_local 1)) (export "" 0))')(), 0);
-assertErrorMessage(() => wasmEvalText('(module (func (result f32) (param i32) (local f32) (get_local 0)))'), TypeError, mismatchError("i32", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (param i32) (local f32) (get_local 1)))'), TypeError, mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (result f32) (param i32) (local f32) (get_local 0)))', TypeError, mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (result i32) (param i32) (local f32) (get_local 1)))', TypeError, mismatchError("f32", "i32"));
 
-assertErrorMessage(() => wasmEvalText('(module (func (set_local 0 (i32.const 0))))'), TypeError, /set_local index out of range/);
-wasmEvalText('(module (func (local i32) (set_local 0 (i32.const 0))))');
-assertErrorMessage(() => wasmEvalText('(module (func (local f32) (set_local 0 (i32.const 0))))'), TypeError, mismatchError("i32", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (local f32) (set_local 0 (nop))))'), TypeError, mismatchError("void", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (local i32) (local f32) (set_local 0 (get_local 1))))'), TypeError, mismatchError("f32", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (local i32) (local f32) (set_local 1 (get_local 0))))'), TypeError, mismatchError("i32", "f32"));
-wasmEvalText('(module (func (local i32) (local f32) (set_local 0 (get_local 0))))');
-wasmEvalText('(module (func (local i32) (local f32) (set_local 1 (get_local 1))))');
+wasmFailValidateText('(module (func (set_local 0 (i32.const 0))))', TypeError, /set_local index out of range/);
+wasmValidateText('(module (func (local i32) (set_local 0 (i32.const 0))))');
+wasmFailValidateText('(module (func (local f32) (set_local 0 (i32.const 0))))', TypeError, mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (local f32) (set_local 0 (nop))))', TypeError, mismatchError("void", "f32"));
+wasmFailValidateText('(module (func (local i32) (local f32) (set_local 0 (get_local 1))))', TypeError, mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (local i32) (local f32) (set_local 1 (get_local 0))))', TypeError, mismatchError("i32", "f32"));
+wasmValidateText('(module (func (local i32) (local f32) (set_local 0 (get_local 0))))');
+wasmValidateText('(module (func (local i32) (local f32) (set_local 1 (get_local 1))))');
 assertEq(wasmEvalText('(module (func (result i32) (local i32) (set_local 0 (i32.const 42))) (export "" 0))')(), 42);
 assertEq(wasmEvalText('(module (func (result i32) (local i32) (set_local 0 (get_local 0))) (export "" 0))')(), 0);
 
 assertEq(wasmEvalText('(module (func (param $a i32) (result i32) (get_local $a)) (export "" 0))')(), 0);
 assertEq(wasmEvalText('(module (func (param $a i32) (local $b i32) (result i32) (block (set_local $b (get_local $a)) (get_local $b))) (export "" 0))')(42), 42);
 
-wasmEvalText('(module (func (local i32) (local $a f32) (set_local 0 (i32.const 1)) (set_local $a (f32.const nan))))');
+wasmValidateText('(module (func (local i32) (local $a f32) (set_local 0 (i32.const 1)) (set_local $a (f32.const nan))))');
 
 // ----------------------------------------------------------------------------
 // blocks
 
 assertEq(wasmEvalText('(module (func (block)) (export "" 0))')(), undefined);
 
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (block)))'), TypeError, mismatchError("void", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (block (block))))'), TypeError, mismatchError("void", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (local i32) (set_local 0 (block))))'), TypeError, mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (result i32) (block)))', TypeError, mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (result i32) (block (block))))', TypeError, mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (local i32) (set_local 0 (block))))', TypeError, mismatchError("void", "i32"));
 
 assertEq(wasmEvalText('(module (func (block (block))) (export "" 0))')(), undefined);
 assertEq(wasmEvalText('(module (func (result i32) (block (i32.const 42))) (export "" 0))')(), 42);
 assertEq(wasmEvalText('(module (func (result i32) (block (block (i32.const 42)))) (export "" 0))')(), 42);
-assertErrorMessage(() => wasmEvalText('(module (func (result f32) (block (i32.const 0))))'), TypeError, mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (result f32) (block (i32.const 0))))', TypeError, mismatchError("i32", "f32"));
 
 assertEq(wasmEvalText('(module (func (result i32) (block (i32.const 13) (block (i32.const 42)))) (export "" 0))')(), 42);
-assertErrorMessage(() => wasmEvalText('(module (func (result f32) (param f32) (block (get_local 0) (i32.const 0))))'), TypeError, mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (result f32) (param f32) (block (get_local 0) (i32.const 0))))', TypeError, mismatchError("i32", "f32"));
 
 assertEq(wasmEvalText('(module (func (result i32) (local i32) (set_local 0 (i32.const 42)) (get_local 0)) (export "" 0))')(), 42);
 
 // ----------------------------------------------------------------------------
 // calls
 
-assertThrowsInstanceOf(() => wasmEvalText('(module (func (nop)) (func (call 0 (i32.const 0))))'), TypeError);
+wasmFailValidateText('(module (func (nop)) (func (call 0 (i32.const 0))))', TypeError, /call arity out of range/);
+
+wasmFailValidateText('(module (func (param i32) (nop)) (func (call 0)))', TypeError, /call arity out of range/);
+wasmFailValidateText('(module (func (param f32) (nop)) (func (call 0 (i32.const 0))))', TypeError, mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (nop)) (func (call 3)))', TypeError, /callee index out of range/);
+
+wasmValidateText('(module (func (nop)) (func (call 0)))');
+wasmValidateText('(module (func (param i32) (nop)) (func (call 0 (i32.const 0))))');
 
-assertThrowsInstanceOf(() => wasmEvalText('(module (func (param i32) (nop)) (func (call 0)))'), TypeError);
-assertThrowsInstanceOf(() => wasmEvalText('(module (func (param f32) (nop)) (func (call 0 (i32.const 0))))'), TypeError);
-assertErrorMessage(() => wasmEvalText('(module (func (nop)) (func (call 3)))'), TypeError, /callee index out of range/);
-wasmEvalText('(module (func (nop)) (func (call 0)))');
-wasmEvalText('(module (func (param i32) (nop)) (func (call 0 (i32.const 0))))');
 assertEq(wasmEvalText('(module (func (result i32) (i32.const 42)) (func (result i32) (call 0)) (export "" 1))')(), 42);
 assertThrowsInstanceOf(() => wasmEvalText('(module (func (call 0)) (export "" 0))')(), InternalError);
 assertThrowsInstanceOf(() => wasmEvalText('(module (func (call 1)) (func (call 0)) (export "" 0))')(), InternalError);
-wasmEvalText('(module (func (param i32 f32)) (func (call 0 (i32.const 0) (f32.const nan))))');
-assertErrorMessage(() => wasmEvalText('(module (func (param i32 f32)) (func (call 0 (i32.const 0) (i32.const 0))))'), TypeError, mismatchError("i32", "f32"));
 
-assertThrowsInstanceOf(() => wasmEvalText('(module (import "a" "") (func (call_import 0 (i32.const 0))))', {a:()=>{}}), TypeError);
+wasmValidateText('(module (func (param i32 f32)) (func (call 0 (i32.const 0) (f32.const nan))))');
+wasmFailValidateText('(module (func (param i32 f32)) (func (call 0 (i32.const 0) (i32.const 0))))', TypeError, mismatchError("i32", "f32"));
+
+wasmFailValidateText('(module (import "a" "") (func (call_import 0 (i32.const 0))))', TypeError, /call arity out of range/);
+wasmFailValidateText('(module (import "a" "" (param i32)) (func (call_import 0)))', TypeError, /call arity out of range/);
+wasmFailValidateText('(module (import "a" "" (param f32)) (func (call_import 0 (i32.const 0))))', TypeError, mismatchError("i32", "f32"));
 
-assertThrowsInstanceOf(() => wasmEvalText('(module (import "a" "" (param i32)) (func (call_import 0)))', {a:()=>{}}), TypeError);
-assertThrowsInstanceOf(() => wasmEvalText('(module (import "a" "" (param f32)) (func (call_import 0 (i32.const 0))))', {a:()=>{}}), TypeError);
 assertErrorMessage(() => wasmEvalText('(module (import "a" "") (func (call_import 1)))'), TypeError, /import index out of range/);
-wasmEvalText('(module (import "a" "") (func (call_import 0)))', {a:()=>{}});
-wasmEvalText('(module (import "a" "" (param i32)) (func (call_import 0 (i32.const 0))))', {a:()=>{}});
+wasmEvalText('(module (import "" "a") (func (call_import 0)))', {"":{a:()=>{}}});
+wasmEvalText('(module (import "" "a" (param i32)) (func (call_import 0 (i32.const 0))))', {"":{a:()=>{}}});
 
 function checkF32CallImport(v) {
-    assertEq(wasmEvalText('(module (import "a" "" (result f32)) (func (result f32) (call_import 0)) (export "" 0))', {a:()=>{ return v; }})(), Math.fround(v));
-    wasmEvalText('(module (import "a" "" (param f32)) (func (param f32) (call_import 0 (get_local 0))) (export "" 0))', {a:x=>{ assertEq(Math.fround(v), x); }})(v);
+    assertEq(wasmEvalText('(module (import "" "a" (result f32)) (func (result f32) (call_import 0)) (export "" 0))', {"":{a:()=>{ return v; }}})(), Math.fround(v));
+    wasmEvalText('(module (import "" "a" (param f32)) (func (param f32) (call_import 0 (get_local 0))) (export "" 0))', {"":{a:x=>{ assertEq(Math.fround(v), x); }}})(v);
 }
 checkF32CallImport(13.37);
 checkF32CallImport(NaN);
@@ -306,29 +259,29 @@ checkF32CallImport(-Infinity);
 checkF32CallImport(-0);
 checkF32CallImport(Math.pow(2, 32) - 1);
 
-var f = wasmEvalText('(module (import "inc" "") (func (call_import 0)) (export "" 0))', {inc:()=>counter++});
-var g = wasmEvalText('(module (import "f" "") (func (block (call_import 0) (call_import 0))) (export "" 0))', {f});
 var counter = 0;
+var f = wasmEvalText('(module (import "" "inc") (func (call_import 0)) (export "" 0))', {"":{inc:()=>counter++}});
+var g = wasmEvalText('(module (import "" "f") (func (block (call_import 0) (call_import 0))) (export "" 0))', {"":{f}});
 f();
 assertEq(counter, 1);
 g();
 assertEq(counter, 3);
 
-var f = wasmEvalText('(module (import "callf" "") (func (call_import 0)) (export "" 0))', {callf:()=>f()});
+var f = wasmEvalText('(module (import "" "callf") (func (call_import 0)) (export "" 0))', {"":{callf:()=>f()}});
 assertThrowsInstanceOf(() => f(), InternalError);
 
-var f = wasmEvalText('(module (import "callg" "") (func (call_import 0)) (export "" 0))', {callg:()=>g()});
-var g = wasmEvalText('(module (import "callf" "") (func (call_import 0)) (export "" 0))', {callf:()=>f()});
+var f = wasmEvalText('(module (import "" "callg") (func (call_import 0)) (export "" 0))', {"":{callg:()=>g()}});
+var g = wasmEvalText('(module (import "" "callf") (func (call_import 0)) (export "" 0))', {"":{callf:()=>f()}});
 assertThrowsInstanceOf(() => f(), InternalError);
 
-var code = '(module (import "one" "" (result i32)) (import "two" "" (result i32)) (func (result i32) (i32.const 3)) (func (result i32) (i32.const 4)) (func (result i32) BODY) (export "" 2))';
-var imports = {one:()=>1, two:()=>2};
+var code = '(module (import "" "one" (result i32)) (import "" "two" (result i32)) (func (result i32) (i32.const 3)) (func (result i32) (i32.const 4)) (func (result i32) BODY) (export "" 2))';
+var imports = {"":{one:()=>1, two:()=>2}};
 assertEq(wasmEvalText(code.replace('BODY', '(call_import 0)'), imports)(), 1);
 assertEq(wasmEvalText(code.replace('BODY', '(call_import 1)'), imports)(), 2);
 assertEq(wasmEvalText(code.replace('BODY', '(call 0)'), imports)(), 3);
 assertEq(wasmEvalText(code.replace('BODY', '(call 1)'), imports)(), 4);
 
-assertEq(wasmEvalText(`(module (import "evalcx" "" (param i32) (result i32)) (func (result i32) (call_import 0 (i32.const 0))) (export "" 0))`, {evalcx})(), 0);
+assertEq(wasmEvalText(`(module (import "" "evalcx" (param i32) (result i32)) (func (result i32) (call_import 0 (i32.const 0))) (export "" 0))`, {"":{evalcx}})(), 0);
 
 if (typeof evaluate === 'function')
     evaluate(`Wasm.instantiateModule(wasmTextToBinary('(module)')) `, { fileName: null });
@@ -336,7 +289,7 @@ if (typeof evaluate === 'function')
 {
     setJitCompilerOption('wasm.test-mode', 1);
 
-    let imp = {
+    let imp = {"":{
         param(i64) {
             assertEqI64(i64, {
                 low: 0x9abcdef0,
@@ -358,27 +311,27 @@ if (typeof evaluate === 'function')
             i64.low = 1337;
             return i64;
         }
-    }
+    }}
 
     assertEq(wasmEvalText(`(module
-        (import "param" "" (param i64) (result i32))
+        (import "" "param" (param i64) (result i32))
         (func (result i32) (call_import 0 (i64.const 0x123456789abcdef0)))
         (export "" 0))`, imp)(), 42);
 
     assertEq(wasmEvalText(`(module
-        (import "param" "" (param i64)(param i64)(param i64)(param i64)(param i64)(param i64)(param i64) (param i64) (result i32))
+        (import "" "param" (param i64)(param i64)(param i64)(param i64)(param i64)(param i64)(param i64) (param i64) (result i32))
         (func (result i32) (call_import 0 (i64.const 0x123456789abcdef0)(i64.const 0x123456789abcdef0)(i64.const 0x123456789abcdef0)(i64.const 0x123456789abcdef0)(i64.const 0x123456789abcdef0)(i64.const 0x123456789abcdef0)(i64.const 0x123456789abcdef0)(i64.const 0x123456789abcdef0)))
         (export "" 0))`, imp)(), 42);
 
     assertEqI64(wasmEvalText(`(module
-        (import "result" "" (param i32) (result i64))
+        (import "" "result" (param i32) (result i64))
         (func (result i64) (call_import 0 (i32.const 3)))
         (export "" 0))`, imp)(), { low: 0xabcdef01, high: 0x1234567b });
 
     // Ensure the ion exit is never taken.
     let ionThreshold = 2 * getJitCompilerOptions()['ion.warmup.trigger'];
     assertEqI64(wasmEvalText(`(module
-        (import "paramAndResult" "" (param i64) (result i64))
+        (import "" "paramAndResult" (param i64) (result i64))
         (func (result i64) (local i32) (local i64)
          (set_local 0 (i32.const 0))
          (loop $out $in
@@ -393,7 +346,7 @@ if (typeof evaluate === 'function')
     setJitCompilerOption('wasm.test-mode', 0);
 }
 
-assertErrorMessage(() => wasmEvalText(`(module (type $t (func)) (func (call_indirect $t (i32.const 0))))`), TypeError, /can't call_indirect without a table/);
+wasmFailValidateText(`(module (type $t (func)) (func (call_indirect $t (i32.const 0))))`, TypeError, /can't call_indirect without a table/);
 
 var {v2i, i2i, i2v} = wasmEvalText(`(module
     (type (func (result i32)))
@@ -444,14 +397,14 @@ assertErrorMessage(() => i2v(5), Error, badIndirectCall);
     assertEq(wasmEvalText(
         `(module
             (type $v2v (func))
-            (import $foo "f" "")
+            (import $foo "" "f")
             (func $a (call_import $foo))
             (func $b (result i32) (i32.const 0))
             (table $a $b)
             (func $bar (call_indirect $v2v (i32.const 0)))
             (export "" $bar)
         )`,
-        {f:() => { stack = new Error().stack }}
+        {"":{f:() => { stack = new Error().stack }}}
     )(), undefined);
 
     disableSPSProfiling();
@@ -469,15 +422,14 @@ for (bad of [6, 7, 100, Math.pow(2,31)-1, Math.pow(2,31), Math.pow(2,31)+1, Math
     assertThrowsInstanceOf(() => i2v(bad, 0), RangeError);
 }
 
-wasmEvalText('(module (func $foo (nop)) (func (call $foo)))');
-wasmEvalText('(module (func (call $foo)) (func $foo (nop)))');
-wasmEvalText('(module (import $bar "a" "") (func (call_import $bar)) (func $foo (nop)))', {a:()=>{}});
-
+wasmValidateText('(module (func $foo (nop)) (func (call $foo)))');
+wasmValidateText('(module (func (call $foo)) (func $foo (nop)))');
+wasmValidateText('(module (import $bar "" "a") (func (call_import $bar)) (func $foo (nop)))');
 
 // ----------------------------------------------------------------------------
 // select
 
-assertErrorMessage(() => wasmEvalText('(module (func (select (i32.const 0) (i32.const 0) (f32.const 0))))'), TypeError, mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (select (i32.const 0) (i32.const 0) (f32.const 0))))', TypeError, mismatchError("f32", "i32"));
 
 assertEq(wasmEvalText('(module (func (select (i32.const 0) (f32.const 0) (i32.const 0))) (export "" 0))')(), undefined);
 assertEq(wasmEvalText('(module (func (select (block) (i32.const 0) (i32.const 0))) (export "" 0))')(), undefined);
@@ -491,16 +443,16 @@ assertEq(wasmEvalText('(module (func) (func (select (call 0) (call 0) (i32.const
 var numT = 0;
 var numF = 0;
 
-var imports = {
+var imports = {"": {
     ifTrue: () => 1 + numT++,
     ifFalse: () => -1 + numF++,
-}
+}}
 
 // Test that side-effects are applied on both branches.
 var f = wasmEvalText(`
 (module
- (import "ifTrue" "" (result i32))
- (import "ifFalse" "" (result i32))
+ (import "" "ifTrue" (result i32))
+ (import "" "ifFalse" (result i32))
  (func (result i32) (param i32)
   (select
    (call_import 0)
@@ -630,4 +582,3 @@ testSelect('f64', 'nan', Math.pow(2, -31));
 
     setJitCompilerOption('wasm.test-mode', 0);
 }
-
diff --git a/js/src/jit-test/tests/wasm/basic-bce.js b/js/src/jit-test/tests/wasm/bce.js
similarity index 100%
rename from js/src/jit-test/tests/wasm/basic-bce.js
rename to js/src/jit-test/tests/wasm/bce.js
diff --git a/js/src/jit-test/tests/wasm/binary.js b/js/src/jit-test/tests/wasm/binary.js
index 67c242a8a4e7..59bde38ffd78 100644
--- a/js/src/jit-test/tests/wasm/binary.js
+++ b/js/src/jit-test/tests/wasm/binary.js
@@ -229,14 +229,14 @@ assertThrowsInstanceOf(() => wasmEval(moduleWithSections([sigSection([v2vSig]),
 assertErrorMessage(() => wasmEval(moduleWithSections([importSection([{sigIndex:0, module:"a", func:"b"}])])), TypeError, /signature index out of range/);
 assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), importSection([{sigIndex:1, module:"a", func:"b"}])])), TypeError, /signature index out of range/);
 wasmEval(moduleWithSections([sigSection([v2vSig]), importSection([])]));
-wasmEval(moduleWithSections([sigSection([v2vSig]), importSection([{sigIndex:0, module:"a", func:""}])]), {a:()=>{}});
+wasmEval(moduleWithSections([sigSection([v2vSig]), importSection([{sigIndex:0, module:"a", func:""}])]), {a:{"":()=>{}}});
 
 wasmEval(moduleWithSections([
     sigSection([v2vSig]),
     importSection([{sigIndex:0, module:"a", func:""}]),
     declSection([0]),
     bodySection([v2vBody])
-]), {a:()=>{}});
+]), {a:{"":()=>{}}});
 
 assertErrorMessage(() => wasmEval(moduleWithSections([ {name: dataSegmentsId, body: [], } ])), TypeError, /data section requires a memory section/);
 
diff --git a/js/src/jit-test/tests/wasm/basic-const.js b/js/src/jit-test/tests/wasm/const.js
similarity index 100%
rename from js/src/jit-test/tests/wasm/basic-const.js
rename to js/src/jit-test/tests/wasm/const.js
diff --git a/js/src/jit-test/tests/wasm/basic-control-flow.js b/js/src/jit-test/tests/wasm/control-flow.js
similarity index 98%
rename from js/src/jit-test/tests/wasm/basic-control-flow.js
rename to js/src/jit-test/tests/wasm/control-flow.js
index 867526391a2c..ac0a68bbc108 100644
--- a/js/src/jit-test/tests/wasm/basic-control-flow.js
+++ b/js/src/jit-test/tests/wasm/control-flow.js
@@ -47,9 +47,9 @@ assertEq(wasmEvalText(`(module
 
 // The if (resp. else) branch is taken iff the condition is true (resp. false)
 counter = 0;
-var imports = { inc() { counter++ } };
+var imports = { "":{inc() { counter++ }} };
 assertEq(wasmEvalText(`(module
-    (import "inc" "" (result i32))
+    (import "" "inc" (result i32))
     (func
         (result i32)
         (if
@@ -63,7 +63,7 @@ assertEq(wasmEvalText(`(module
 assertEq(counter, 0);
 
 assertEq(wasmEvalText(`(module
-    (import "inc" "" (result i32))
+    (import "" "inc" (result i32))
     (func
         (result i32)
         (if
@@ -77,7 +77,7 @@ assertEq(wasmEvalText(`(module
 assertEq(counter, 0);
 
 assertEq(wasmEvalText(`(module
-    (import "inc" "" (result i32))
+    (import "" "inc" (result i32))
     (func
         (if
             (i32.const 0)
@@ -89,7 +89,7 @@ assertEq(wasmEvalText(`(module
 assertEq(counter, 0);
 
 assertEq(wasmEvalText(`(module
-    (import "inc" "" (result i32))
+    (import "" "inc" (result i32))
     (func
         (if
             (i32.const 1)
@@ -103,7 +103,7 @@ assertEq(counter, 1);
 // One can chain if with if/if
 counter = 0;
 assertEq(wasmEvalText(`(module
-    (import "inc" "" (result i32))
+    (import "" "inc" (result i32))
     (func
         (result i32)
         (if
@@ -212,13 +212,13 @@ assertEq(wasmEvalText(`(module (func (result i32)
 
 var notcalled = false;
 var called = false;
-var imports = {
+var imports = {"": {
     notcalled() {notcalled = true},
     called() {called = true}
-};
+}};
 assertEq(wasmEvalText(`(module
-(import "notcalled" "")
-(import "called" "")
+(import "" "notcalled")
+(import "" "called")
 (func
   (block
     (return (br 0))
diff --git a/js/src/jit-test/tests/wasm/basic-float.js b/js/src/jit-test/tests/wasm/float.js
similarity index 100%
rename from js/src/jit-test/tests/wasm/basic-float.js
rename to js/src/jit-test/tests/wasm/float.js
diff --git a/js/src/jit-test/tests/wasm/globals.js b/js/src/jit-test/tests/wasm/globals.js
index 455210011791..991bdcab856c 100644
--- a/js/src/jit-test/tests/wasm/globals.js
+++ b/js/src/jit-test/tests/wasm/globals.js
@@ -2,7 +2,6 @@
 load(libdir + "wasm.js");
 
 const { Instance, Module } = WebAssembly;
-const evalText = (txt, imports = {}) => new Instance(new Module(wasmTextToBinary(txt, 'new-format')), imports).exports;
 
 // Locally-defined globals
 assertErrorMessage(() => evalText(`(module (global))`), SyntaxError, /parsing/);
@@ -33,7 +32,7 @@ function testInner(type, initialValue, nextValue, coercion, assertFunc = assertE
         (export "get_cst" $get_cst)
 
         (export "set" $set)
-    )`);
+    )`).exports;
 
     assertFunc(module.get(), coercion(initialValue));
     assertEq(module.set(coercion(nextValue)), undefined);
@@ -76,7 +75,7 @@ var module = evalText(`(module
     (export "get2" $get_2) (export "set2" $set_2)
     (export "get3" $get_3) (export "set3" $set_3)
     (export "get4" $get_4) (export "set4" $set_4)
-)`);
+)`).exports;
 
 let values = [42, 10, Math.fround(13.37), 13.37, -18];
 let nextValues = [13, 37, Math.fround(-17.89), 9.3, -13];
@@ -107,7 +106,7 @@ module = evalText(`(module
     globals: {
         a: 1
     }
-});
+}).exports;
 assertEq(module.f, module.tbl.get(1));
 
 // Import/export rules.
@@ -120,7 +119,7 @@ module = evalText(`(module
  (func $get (result i32) (get_global $g))
  (export "getter" $get)
  (export "value" global 0)
-)`, { globals: {x: 42} });
+)`, { globals: {x: 42} }).exports;
 
 assertEq(module.getter(), 42);
 assertEq(module.value, 42);
@@ -131,7 +130,7 @@ module = evalText(`(module
  (global i32 immutable (i32.const 1337))
  (export "imported" global 0)
  (export "defined" global 1)
-)`, { globals: {x: 42} });
+)`, { globals: {x: 42} }).exports;
 
 assertEq(module.imported, 42);
 assertEq(module.defined, 1337);
@@ -166,7 +165,7 @@ function testInitExpr(type, initialValue, nextValue, coercion, assertFunc = asse
         globals: {
             a: coercion(initialValue)
         }
-    });
+    }).exports;
 
     assertFunc(module.get0(), coercion(initialValue));
     assertFunc(module.get1(), coercion(initialValue));
@@ -196,7 +195,7 @@ testInitExpr('f64', 13.37, 0.1989, x => +x);
      (global i64 immutable (i64.const 0xFAFADADABABA))
      (export "imported" global 0)
      (export "defined" global 1)
-    )`, { globals: {x: createI64('0x1234567887654321')} });
+    )`, { globals: {x: createI64('0x1234567887654321')} }).exports;
 
     assertEqI64(module.imported, createI64('0x1234567887654321'));
     assertEqI64(module.defined, createI64('0xFAFADADABABA'));
diff --git a/js/src/jit-test/tests/wasm/basic-grow-memory.js b/js/src/jit-test/tests/wasm/grow-memory.js
similarity index 100%
rename from js/src/jit-test/tests/wasm/basic-grow-memory.js
rename to js/src/jit-test/tests/wasm/grow-memory.js
diff --git a/js/src/jit-test/tests/wasm/import-export.js b/js/src/jit-test/tests/wasm/import-export.js
index 96e1c8b9693e..df4c89702551 100644
--- a/js/src/jit-test/tests/wasm/import-export.js
+++ b/js/src/jit-test/tests/wasm/import-export.js
@@ -22,10 +22,6 @@ const tab2Elem = new Table({initial:2, element:"anyfunc"});
 const tab3Elem = new Table({initial:3, element:"anyfunc"});
 const tab4Elem = new Table({initial:4, element:"anyfunc"});
 
-// Explicitly opt into the new binary format for imports and exports until it
-// is used by default everywhere.
-const textToBinary = str => wasmTextToBinary(str, 'new-format');
-
 assertErrorMessage(() => new Memory({initial:2, maximum:1}), TypeError, /bad Memory maximum size/);
 
 const m1 = new Module(textToBinary('(module (import "foo" "bar") (import "baz" "quux"))'));
@@ -94,7 +90,7 @@ assertErrorMessage(() => new Module(textToBinary('(module (import "a" "b" (table
 
 // Import wasm-wasm type mismatch
 
-var e = new Instance(new Module(textToBinary('(module (func $i2v (param i32)) (export "i2v" $i2v) (func $f2v (param f32)) (export "f2v" $f2v))'))).exports;
+var e = evalText('(module (func $i2v (param i32)) (export "i2v" $i2v) (func $f2v (param f32)) (export "f2v" $f2v))').exports;
 var i2vm = new Module(textToBinary('(module (import "a" "b" (param i32)))'));
 var f2vm = new Module(textToBinary('(module (import "a" "b" (param f32)))'));
 assertEq(new Instance(i2vm, {a:{b:e.i2v}}) instanceof Instance, true);
diff --git a/js/src/jit-test/tests/wasm/import-gc.js b/js/src/jit-test/tests/wasm/import-gc.js
index 61bd07d24b78..d32a1a2ad66b 100644
--- a/js/src/jit-test/tests/wasm/import-gc.js
+++ b/js/src/jit-test/tests/wasm/import-gc.js
@@ -8,10 +8,6 @@ load(libdir + 'asserts.js');
 const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 
-// Explicitly opt into the new binary format for imports and exports until it
-// is used by default everywhere.
-const textToBinary = str => wasmTextToBinary(str, 'new-format');
-
 const m1 = new Module(textToBinary(`(module (func $f) (export "f" $f))`));
 const m2 = new Module(textToBinary(`(module (import "a" "f") (func $f) (export "g" $f))`));
 
diff --git a/js/src/jit-test/tests/wasm/basic-integer.js b/js/src/jit-test/tests/wasm/integer.js
similarity index 100%
rename from js/src/jit-test/tests/wasm/basic-integer.js
rename to js/src/jit-test/tests/wasm/integer.js
diff --git a/js/src/jit-test/tests/wasm/jsapi.js b/js/src/jit-test/tests/wasm/jsapi.js
index ee0c0ffb6760..1491c0f83ea2 100644
--- a/js/src/jit-test/tests/wasm/jsapi.js
+++ b/js/src/jit-test/tests/wasm/jsapi.js
@@ -1,10 +1,6 @@
 load(libdir + 'wasm.js');
 load(libdir + 'asserts.js');
 
-// Explicitly opt into the new binary format for imports and exports until it
-// is used by default everywhere.
-const textToBinary = str => wasmTextToBinary(str, 'new-format');
-
 const emptyModule = textToBinary('(module)');
 
 // 'WebAssembly' property on global object
diff --git a/js/src/jit-test/tests/wasm/basic-memory.js b/js/src/jit-test/tests/wasm/memory.js
similarity index 100%
rename from js/src/jit-test/tests/wasm/basic-memory.js
rename to js/src/jit-test/tests/wasm/memory.js
diff --git a/js/src/jit-test/tests/wasm/profiling.js b/js/src/jit-test/tests/wasm/profiling.js
index b4625758361d..edd46178d286 100644
--- a/js/src/jit-test/tests/wasm/profiling.js
+++ b/js/src/jit-test/tests/wasm/profiling.js
@@ -9,10 +9,6 @@ const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 const Table = WebAssembly.Table;
 
-// Explicitly opt into the new binary format for imports and exports until it
-// is used by default everywhere.
-const textToBinary = str => wasmTextToBinary(str, 'new-format');
-
 function normalize(stack)
 {
     var wasmFrameTypes = [
@@ -58,7 +54,7 @@ function test(code, expect)
 {
     enableSPSProfiling();
 
-    var f = new Instance(new Module(textToBinary(code))).exports[""];
+    var f = evalText(code).exports[""];
     enableSingleStepProfiling();
     f();
     assertEqStacks(disableSingleStepProfiling(), expect);
@@ -112,7 +108,7 @@ testError(
 Error);
 
 (function() {
-    var e = new Instance(new Module(textToBinary(`
+    var e = evalText(`
     (module
         (func $foo (result i32) (i32.const 42))
         (export "foo" $foo)
@@ -120,7 +116,7 @@ Error);
         (table (resizable 10))
         (elem (i32.const 0) $foo $bar)
         (export "tbl" table)
-    )`))).exports;
+    )`).exports;
     assertEq(e.foo(), 42);
     assertEq(e.tbl.get(0)(), 42);
     assertEq(e.tbl.get(1)(), 13);
@@ -152,7 +148,7 @@ Error);
     assertEqStacks(disableSingleStepProfiling(), ["", ">", "0,>", ">", "", ">", "1,>", ">", ""]);
     disableSPSProfiling();
 
-    var e2 = new Instance(new Module(textToBinary(`
+    var e2 = evalText(`
     (module
         (type $v2i (func (result i32)))
         (import "a" "b" (table 10))
@@ -160,8 +156,7 @@ Error);
         (func $bar (result i32) (i32.const 99))
         (func $baz (param $i i32) (result i32) (call_indirect $v2i (get_local $i)))
         (export "baz" $baz)
-    )`)),
-    {a:{b:e.tbl}}).exports;
+    )`, {a:{b:e.tbl}}).exports;
 
     enableSPSProfiling();
     enableSingleStepProfiling();
diff --git a/js/src/jit-test/tests/wasm/random-control-flow.js b/js/src/jit-test/tests/wasm/regress/misc-control-flow.js
similarity index 100%
rename from js/src/jit-test/tests/wasm/random-control-flow.js
rename to js/src/jit-test/tests/wasm/regress/misc-control-flow.js
diff --git a/js/src/jit-test/tests/wasm/spec.js b/js/src/jit-test/tests/wasm/spec.js
index facbe7358142..0ecab0e087e4 100644
--- a/js/src/jit-test/tests/wasm/spec.js
+++ b/js/src/jit-test/tests/wasm/spec.js
@@ -215,8 +215,7 @@ function exec(e) {
 
     if (exprName === "module") {
         let moduleText = e.toString();
-        var m = new WebAssembly.Module(wasmTextToBinary(moduleText, 'new-format'));
-        module = new WebAssembly.Instance(m, imports).exports;
+        module = evalText(moduleText, imports).exports;
         return;
     }
 
@@ -275,18 +274,14 @@ function exec(e) {
             assert(errMsg.quoted, "assert_invalid second argument must be a string");
             errMsg.quoted = false;
         }
-        let caught = false;
+        // assert_invalid tests both the decoder *and* the parser itself.
         try {
-            new WebAssembly.Instance(
-                new WebAssembly.Module(
-                    wasmTextToBinary(moduleText, 'new-format')),
-                imports);
+            assertEq(WebAssembly.validate(textToBinary(moduleText)), false);
         } catch(e) {
-            if (errMsg && e.toString().indexOf(errMsg) === -1)
-                warn(`expected error message "${errMsg}", got "${e}"`);
-            caught = true;
+            if (/wasm text error/.test(e.toString()))
+                return;
+            throw e;
         }
-        assert(caught, "assert_invalid error");
         return;
     }
 
diff --git a/js/src/jit-test/tests/wasm/start.js b/js/src/jit-test/tests/wasm/start.js
index e0741877be18..49f983a63c07 100644
--- a/js/src/jit-test/tests/wasm/start.js
+++ b/js/src/jit-test/tests/wasm/start.js
@@ -14,12 +14,12 @@ assertErrorMessage(() => wasmEvalText('(module (func (result f32)) (start 0))'),
 // Basic use case.
 var count = 0;
 function inc() { count++; }
-var exports = wasmEvalText(`(module (import $imp "inc" "") (func $f (param i32)) (func (call_import $imp)) (start $f))`, { inc });
+var exports = wasmEvalText(`(module (import $imp "" "inc") (func $f (param i32)) (func (call_import $imp)) (start $f))`, { "":{inc} });
 assertEq(count, 1);
 assertEq(Object.keys(exports).length, 0);
 
 count = 0;
-exports = wasmEvalText(`(module (import "inc" "") (func $start (call_import 0)) (start $start) (export "" 0))`, { inc });
+exports = wasmEvalText(`(module (import "" "inc") (func $start (call_import 0)) (start $start) (export "" 0))`, { "":{inc} });
 assertEq(count, 1);
 assertEq(typeof exports, 'function');
 assertEq(exports(), undefined);
@@ -28,27 +28,26 @@ assertEq(count, 2);
 // New API.
 const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
-const textToBinary = str => wasmTextToBinary(str, 'new-format');
 
 count = 0;
-const m = new Module(textToBinary('(module (import $imp "inc" "") (func) (func $start (call $imp)) (start $start) (export "" $start))'));
+const m = new Module(textToBinary('(module (import $imp "" "inc") (func) (func $start (call $imp)) (start $start) (export "" $start))'));
 assertEq(count, 0);
 
 assertErrorMessage(() => new Instance(m), TypeError, /no import object given/);
 assertEq(count, 0);
 
-const i1 = new Instance(m, { inc });
+const i1 = new Instance(m, { "":{inc} });
 assertEq(count, 1);
 i1.exports[""]();
 assertEq(count, 2);
 
-const i2 = new Instance(m, { inc });
+const i2 = new Instance(m, { "":{inc} });
 assertEq(count, 3);
 
 function fail() { assertEq(true, false); }
 
 count = 0;
-const m2 = new Module(textToBinary('(module (import "fail" "") (import $imp "inc" "") (func) (start $imp))'));
+const m2 = new Module(textToBinary('(module (import "" "fail") (import $imp "" "inc") (func) (start $imp))'));
 assertEq(count, 0);
-new Instance(m2, { inc, fail });
+new Instance(m2, {"":{ inc, fail }});
 assertEq(count, 1);
diff --git a/js/src/jit-test/tests/wasm/table-gc.js b/js/src/jit-test/tests/wasm/table-gc.js
index 22048cb523f3..12c34cd1ccea 100644
--- a/js/src/jit-test/tests/wasm/table-gc.js
+++ b/js/src/jit-test/tests/wasm/table-gc.js
@@ -9,11 +9,6 @@ const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 const Table = WebAssembly.Table;
 
-// Explicitly opt into the new binary format for imports and exports until it
-// is used by default everywhere.
-const textToBinary = str => wasmTextToBinary(str, 'new-format');
-const evalText = (str, imports) => new Instance(new Module(textToBinary(str)), imports);
-
 var caller = `(type $v2i (func (result i32))) (func $call (param $i i32) (result i32) (call_indirect $v2i (get_local $i))) (export "call" $call)`
 var callee = i => `(func $f${i} (type $v2i) (result i32) (i32.const ${i}))`;
 
diff --git a/js/src/jit-test/tests/wasm/tables.js b/js/src/jit-test/tests/wasm/tables.js
index fc9d5d6f235c..3526e5ae96f8 100644
--- a/js/src/jit-test/tests/wasm/tables.js
+++ b/js/src/jit-test/tests/wasm/tables.js
@@ -7,12 +7,6 @@ const Instance = WebAssembly.Instance;
 const Table = WebAssembly.Table;
 const Memory = WebAssembly.Memory;
 
-// Explicitly opt into the new binary format for imports and exports until it
-// is used by default everywhere.
-const textToBinary = str => wasmTextToBinary(str, 'new-format');
-
-const evalText = (str, imports) => new Instance(new Module(textToBinary(str)), imports);
-
 var callee = i => `(func $f${i} (result i32) (i32.const ${i}))`;
 
 assertErrorMessage(() => new Module(textToBinary(`(module (elem (i32.const 0) $f0) ${callee(0)})`)), TypeError, /table index out of range/);
diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp
index 884a35270091..4499f574f43f 100644
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -8785,7 +8785,7 @@ CodeGenerator::visitIteratorStart(LIteratorStart* lir)
     MOZ_ASSERT(flags == JSITER_ENUMERATE);
 
     // Fetch the most recent iterator and ensure it's not nullptr.
-    masm.loadPtr(AbsoluteAddress(GetJitContext()->runtime->addressOfLastCachedNativeIterator()), output);
+    masm.loadPtr(AbsoluteAddress(gen->compartment->addressOfLastCachedNativeIterator()), output);
     masm.branchTestPtr(Assembler::Zero, output, output, ool->entry());
 
     // Load NativeIterator.
@@ -11608,19 +11608,6 @@ CodeGenerator::visitInterruptCheck(LInterruptCheck* lir)
     masm.bind(ool->rejoin());
 }
 
-void
-CodeGenerator::visitAsmJSInterruptCheck(LAsmJSInterruptCheck* lir)
-{
-    Label rejoin;
-    masm.branch32(Assembler::Equal, wasm::SymbolicAddress::InterruptUint32, Imm32(0), &rejoin);
-
-    MOZ_ASSERT((sizeof(AsmJSFrame) + masm.framePushed()) % ABIStackAlignment == 0);
-    masm.call(wasm::SymbolicAddress::HandleExecutionInterrupt);
-    masm.branchIfFalseBool(ReturnReg, wasm::JumpTarget::Throw);
-
-    masm.bind(&rejoin);
-}
-
 void
 CodeGenerator::visitWasmTrap(LWasmTrap* lir)
 {
diff --git a/js/src/jit/CodeGenerator.h b/js/src/jit/CodeGenerator.h
index d173614e51b4..cde7d133ee19 100644
--- a/js/src/jit/CodeGenerator.h
+++ b/js/src/jit/CodeGenerator.h
@@ -418,7 +418,6 @@ class CodeGenerator final : public CodeGeneratorSpecific
 
     void visitInterruptCheck(LInterruptCheck* lir);
     void visitOutOfLineInterruptCheckImplicit(OutOfLineInterruptCheckImplicit* ins);
-    void visitAsmJSInterruptCheck(LAsmJSInterruptCheck* lir);
     void visitWasmTrap(LWasmTrap* lir);
     void visitRecompileCheck(LRecompileCheck* ins);
     void visitRotate(LRotate* ins);
diff --git a/js/src/jit/CompileWrappers.cpp b/js/src/jit/CompileWrappers.cpp
index 6b67beecfcc8..286bd17c51ba 100644
--- a/js/src/jit/CompileWrappers.cpp
+++ b/js/src/jit/CompileWrappers.cpp
@@ -74,12 +74,6 @@ CompileRuntime::addressOfActivation()
     return runtime()->addressOfActivation();
 }
 
-const void*
-CompileRuntime::addressOfLastCachedNativeIterator()
-{
-    return &static_cast(runtime())->caches.nativeIterCache.last;
-}
-
 #ifdef JS_GC_ZEAL
 const void*
 CompileRuntime::addressOfGCZealModeBits()
@@ -248,6 +242,12 @@ CompileCompartment::addressOfEnumerators()
     return &compartment()->enumerators;
 }
 
+const void*
+CompileCompartment::addressOfLastCachedNativeIterator()
+{
+    return &compartment()->lastCachedNativeIterator;
+}
+
 const void*
 CompileCompartment::addressOfRandomNumberGenerator()
 {
diff --git a/js/src/jit/CompileWrappers.h b/js/src/jit/CompileWrappers.h
index 611a603b299c..ae42d8602c94 100644
--- a/js/src/jit/CompileWrappers.h
+++ b/js/src/jit/CompileWrappers.h
@@ -51,9 +51,6 @@ class CompileRuntime
     // &runtime()->activation_
     const void* addressOfActivation();
 
-    // &GetJitContext()->runtime->nativeIterCache.last
-    const void* addressOfLastCachedNativeIterator();
-
 #ifdef JS_GC_ZEAL
     const void* addressOfGCZealModeBits();
 #endif
@@ -117,6 +114,7 @@ class CompileCompartment
 
     const void* addressOfEnumerators();
     const void* addressOfRandomNumberGenerator();
+    const void* addressOfLastCachedNativeIterator();
 
     const JitCompartment* jitCompartment();
 
diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp
index 73eacadfc04d..66ffa3a09243 100644
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -14616,3 +14616,14 @@ IonBuilder::convertToBoolean(MDefinition* input)
 
     return result;
 }
+
+void
+IonBuilder::trace(JSTracer* trc)
+{
+    if (script_->zoneFromAnyThread()->runtimeFromAnyThread() != trc->runtime())
+        return;
+
+    TraceManuallyBarrieredEdge(trc, &script_, "IonBuiler::script_");
+    if (actionableAbortScript_)
+        TraceManuallyBarrieredEdge(trc, &actionableAbortScript_, "IonBuiler::actionableAbortScript_");
+}
diff --git a/js/src/jit/IonBuilder.h b/js/src/jit/IonBuilder.h
index 22b6f6f6b020..170488a148f2 100644
--- a/js/src/jit/IonBuilder.h
+++ b/js/src/jit/IonBuilder.h
@@ -1154,6 +1154,8 @@ class IonBuilder
         *abortMessage = actionableAbortMessage_;
     }
 
+    void trace(JSTracer* trc);
+
   private:
     MOZ_MUST_USE bool init();
 
diff --git a/js/src/jit/Lowering.cpp b/js/src/jit/Lowering.cpp
index f0f594bd5f21..3801578d88c0 100644
--- a/js/src/jit/Lowering.cpp
+++ b/js/src/jit/Lowering.cpp
@@ -2522,13 +2522,6 @@ LIRGenerator::visitInterruptCheck(MInterruptCheck* ins)
     assignSafepoint(lir, ins);
 }
 
-void
-LIRGenerator::visitAsmJSInterruptCheck(MAsmJSInterruptCheck* ins)
-{
-    gen->setPerformsCall();
-    add(new(alloc()) LAsmJSInterruptCheck, ins);
-}
-
 void
 LIRGenerator::visitWasmTrap(MWasmTrap* ins)
 {
diff --git a/js/src/jit/Lowering.h b/js/src/jit/Lowering.h
index 7b5aad462497..bf8f676891e2 100644
--- a/js/src/jit/Lowering.h
+++ b/js/src/jit/Lowering.h
@@ -190,7 +190,6 @@ class LIRGenerator : public LIRGeneratorSpecific
     void visitLoadFixedSlotAndUnbox(MLoadFixedSlotAndUnbox* ins);
     void visitFunctionEnvironment(MFunctionEnvironment* ins);
     void visitInterruptCheck(MInterruptCheck* ins);
-    void visitAsmJSInterruptCheck(MAsmJSInterruptCheck* ins);
     void visitWasmTrap(MWasmTrap* ins);
     void visitAsmReinterpret(MAsmReinterpret* ins);
     void visitStoreSlot(MStoreSlot* ins);
diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h
index 16b35a7d6453..7c3dca63f8e4 100644
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -7737,17 +7737,6 @@ class MInterruptCheck : public MNullaryInstruction
     }
 };
 
-// Check whether we need to fire the interrupt handler at loop headers and
-// function prologues in asm.js. Generated only if we can't use implicit
-// interrupt checks with signal handlers.
-class MAsmJSInterruptCheck
-  : public MNullaryInstruction
-{
-  public:
-    INSTRUCTION_HEADER(AsmJSInterruptCheck)
-    TRIVIAL_NEW_WRAPPERS
-};
-
 // Directly jumps to the indicated trap, leaving Wasm code and reporting a
 // runtime error.
 
diff --git a/js/src/jit/MOpcodes.h b/js/src/jit/MOpcodes.h
index f6d079b77357..d71d336e5aa3 100644
--- a/js/src/jit/MOpcodes.h
+++ b/js/src/jit/MOpcodes.h
@@ -262,7 +262,6 @@ namespace jit {
     _(InstanceOf)                                                           \
     _(CallInstanceOf)                                                       \
     _(InterruptCheck)                                                       \
-    _(AsmJSInterruptCheck)                                                  \
     _(GetDOMProperty)                                                       \
     _(GetDOMMember)                                                         \
     _(SetDOMProperty)                                                       \
diff --git a/js/src/jit/shared/LIR-shared.h b/js/src/jit/shared/LIR-shared.h
index e712d297a635..df4fc13f554c 100644
--- a/js/src/jit/shared/LIR-shared.h
+++ b/js/src/jit/shared/LIR-shared.h
@@ -1391,19 +1391,6 @@ class LCheckOverRecursed : public LInstructionHelper<0, 0, 0>
     }
 };
 
-class LAsmJSInterruptCheck : public LInstructionHelper<0, 0, 0>
-{
-  public:
-    LIR_HEADER(AsmJSInterruptCheck);
-
-    LAsmJSInterruptCheck()
-    { }
-
-    bool isCall() const {
-        return true;
-    }
-};
-
 class LWasmTrap : public LInstructionHelper<0, 0, 0>
 {
   public:
diff --git a/js/src/jit/shared/LOpcodes-shared.h b/js/src/jit/shared/LOpcodes-shared.h
index f83d7e04e28c..a864a70684b5 100644
--- a/js/src/jit/shared/LOpcodes-shared.h
+++ b/js/src/jit/shared/LOpcodes-shared.h
@@ -370,7 +370,6 @@
     _(InstanceOfV)                  \
     _(CallInstanceOf)               \
     _(InterruptCheck)               \
-    _(AsmJSInterruptCheck)          \
     _(WasmTrap)                     \
     _(AsmReinterpret)               \
     _(AsmReinterpretToI64)          \
diff --git a/js/src/jscompartment.cpp b/js/src/jscompartment.cpp
index 78dea4e24c85..c38455eb022d 100644
--- a/js/src/jscompartment.cpp
+++ b/js/src/jscompartment.cpp
@@ -80,6 +80,7 @@ JSCompartment::JSCompartment(Zone* zone, const JS::CompartmentOptions& options =
     debugScriptMap(nullptr),
     debugEnvs(nullptr),
     enumerators(nullptr),
+    lastCachedNativeIterator(nullptr),
     compartmentStats_(nullptr),
     scheduledForDestruction(false),
     maybeAlive(true),
@@ -860,9 +861,9 @@ JSCompartment::fixupCrossCompartmentWrappersAfterMovingGC(JSTracer* trc)
 void
 JSCompartment::fixupAfterMovingGC()
 {
+    purge();
     fixupGlobal();
     objectGroups.fixupTablesAfterMovingGC();
-    dtoaCache.purge();
     fixupScriptMapsAfterMovingGC();
 }
 
@@ -931,6 +932,7 @@ void
 JSCompartment::purge()
 {
     dtoaCache.purge();
+    lastCachedNativeIterator = nullptr;
 }
 
 void
diff --git a/js/src/jscompartment.h b/js/src/jscompartment.h
index f3880db70f47..9706b94b0c1a 100644
--- a/js/src/jscompartment.h
+++ b/js/src/jscompartment.h
@@ -802,6 +802,9 @@ struct JSCompartment
      */
     js::NativeIterator* enumerators;
 
+    /* Native iterator most recently started. */
+    js::PropertyIteratorObject* lastCachedNativeIterator;
+
   private:
     /* Used by memory reporters and invalid otherwise. */
     JS::CompartmentStats* compartmentStats_;
diff --git a/js/src/jsiter.cpp b/js/src/jsiter.cpp
index e3f789d22814..41297b9b6494 100644
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -823,6 +823,12 @@ CanCacheIterableObject(JSContext* cx, JSObject* obj)
 bool
 js::GetIterator(JSContext* cx, HandleObject obj, unsigned flags, MutableHandleObject objp)
 {
+#ifdef DEBUG
+    auto assertCompartment = mozilla::MakeScopeExit([&] {
+        assertSameCompartment(cx, objp);
+    });
+#endif
+
     if (obj->is() || obj->is()) {
         objp.set(obj);
         return true;
@@ -842,8 +848,7 @@ js::GetIterator(JSContext* cx, HandleObject obj, unsigned flags, MutableHandleOb
     if (flags == JSITER_ENUMERATE) {
         // Check to see if this is the same as the most recent object which was
         // iterated over.
-        PropertyIteratorObject* last = cx->caches.nativeIterCache.last;
-        if (last) {
+        if (PropertyIteratorObject* last = cx->compartment()->lastCachedNativeIterator) {
             NativeIterator* lastni = last->getNativeIterator();
             if (!(lastni->flags & (JSITER_ACTIVE|JSITER_UNREUSABLE)) &&
                 CanCompareIterableObjectToCache(obj) &&
@@ -882,21 +887,21 @@ js::GetIterator(JSContext* cx, HandleObject obj, unsigned flags, MutableHandleOb
             } while (pobj);
         }
 
-        PropertyIteratorObject* iterobj = cx->caches.nativeIterCache.get(key);
-        if (iterobj) {
+        if (PropertyIteratorObject* iterobj = cx->caches.nativeIterCache.get(key)) {
             NativeIterator* ni = iterobj->getNativeIterator();
             if (!(ni->flags & (JSITER_ACTIVE|JSITER_UNREUSABLE)) &&
                 ni->guard_key == key &&
                 ni->guard_length == guards.length() &&
                 Compare(reinterpret_cast(ni->guard_array),
-                        guards.begin(), ni->guard_length))
+                        guards.begin(), ni->guard_length) &&
+                iterobj->compartment() == cx->compartment())
             {
                 objp.set(iterobj);
 
                 UpdateNativeIterator(ni, obj);
                 RegisterEnumerator(cx, iterobj, ni);
                 if (guards.length() == 2)
-                    cx->caches.nativeIterCache.last = iterobj;
+                    cx->compartment()->lastCachedNativeIterator = iterobj;
                 return true;
             }
         }
@@ -930,7 +935,7 @@ js::GetIterator(JSContext* cx, HandleObject obj, unsigned flags, MutableHandleOb
         cx->caches.nativeIterCache.set(key, iterobj);
 
     if (guards.length() == 2)
-        cx->caches.nativeIterCache.last = iterobj;
+        cx->compartment()->lastCachedNativeIterator = iterobj;
     return true;
 }
 
diff --git a/js/src/vm/Caches.h b/js/src/vm/Caches.h
index a85b34c20b90..91a78bdc8224 100644
--- a/js/src/vm/Caches.h
+++ b/js/src/vm/Caches.h
@@ -126,17 +126,11 @@ class NativeIterCache
     }
 
   public:
-    /* Native iterator most recently started. */
-    PropertyIteratorObject* last;
-
-    NativeIterCache()
-      : last(nullptr)
-    {
+    NativeIterCache() {
         mozilla::PodArrayZero(data);
     }
 
     void purge() {
-        last = nullptr;
         mozilla::PodArrayZero(data);
     }
 
diff --git a/js/src/vm/CommonPropertyNames.h b/js/src/vm/CommonPropertyNames.h
index 68a91f5797f0..6a29e7869d3a 100644
--- a/js/src/vm/CommonPropertyNames.h
+++ b/js/src/vm/CommonPropertyNames.h
@@ -191,6 +191,7 @@
     macro(minute, minute, "minute") \
     macro(missingArguments, missingArguments, "missingArguments") \
     macro(module, module, "module") \
+    macro(Module, Module, "Module") \
     macro(ModuleDeclarationInstantiation, ModuleDeclarationInstantiation, "ModuleDeclarationInstantiation") \
     macro(ModuleEvaluation, ModuleEvaluation, "ModuleEvaluation") \
     macro(month, month, "month") \
diff --git a/js/src/vm/HelperThreads.cpp b/js/src/vm/HelperThreads.cpp
index b4e8d93bf905..8073653ba035 100644
--- a/js/src/vm/HelperThreads.cpp
+++ b/js/src/vm/HelperThreads.cpp
@@ -210,9 +210,9 @@ ParseTask::ParseTask(ParseTaskKind kind, ExclusiveContext* cx, JSObject* exclusi
                      JS::OffThreadCompileCallback callback, void* callbackData)
   : kind(kind), cx(cx), options(initCx), chars(chars), length(length),
     alloc(JSRuntime::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE),
-    exclusiveContextGlobal(initCx, exclusiveContextGlobal),
+    exclusiveContextGlobal(exclusiveContextGlobal),
     callback(callback), callbackData(callbackData),
-    script(initCx), sourceObject(initCx),
+    script(nullptr), sourceObject(nullptr),
     errors(cx), overRecursed(false), outOfMemory(false)
 {
 }
@@ -254,6 +254,19 @@ ParseTask::~ParseTask()
         js_delete(errors[i]);
 }
 
+void
+ParseTask::trace(JSTracer* trc)
+{
+    if (exclusiveContextGlobal->zoneFromAnyThread()->runtimeFromAnyThread() != trc->runtime())
+        return;
+
+    TraceManuallyBarrieredEdge(trc, &exclusiveContextGlobal, "ParseTask::exclusiveContextGlobal");
+    if (script)
+        TraceManuallyBarrieredEdge(trc, &script, "ParseTask::script");
+    if (sourceObject)
+        TraceManuallyBarrieredEdge(trc, &sourceObject, "ParseTask::sourceObject");
+}
+
 ScriptParseTask::ScriptParseTask(ExclusiveContext* cx, JSObject* exclusiveContextGlobal,
                                  JSContext* initCx, const char16_t* chars, size_t length,
                                  JS::OffThreadCompileCallback callback, void* callbackData)
@@ -269,7 +282,7 @@ ScriptParseTask::parse()
     script = frontend::CompileGlobalScript(cx, alloc, ScopeKind::Global,
                                            options, srcBuf,
                                            /* extraSct = */ nullptr,
-                                           /* sourceObjectOut = */ sourceObject.address());
+                                           /* sourceObjectOut = */ &sourceObject);
 }
 
 ModuleParseTask::ModuleParseTask(ExclusiveContext* cx, JSObject* exclusiveContextGlobal,
@@ -284,8 +297,7 @@ void
 ModuleParseTask::parse()
 {
     SourceBufferHolder srcBuf(chars, length, SourceBufferHolder::NoOwnership);
-    ModuleObject* module = frontend::CompileModule(cx, options, srcBuf, alloc,
-                                                   sourceObject.address());
+    ModuleObject* module = frontend::CompileModule(cx, options, srcBuf, alloc, &sourceObject);
     if (module)
         script = module->script();
 }
@@ -1673,6 +1685,22 @@ GlobalHelperThreadState::compressionTaskForSource(ScriptSource* ss,
     return nullptr;
 }
 
+void
+GlobalHelperThreadState::trace(JSTracer* trc)
+{
+    AutoLockHelperThreadState lock;
+    for (auto builder : ionWorklist(lock))
+        builder->trace(trc);
+    for (auto builder : ionFinishedList(lock))
+        builder->trace(trc);
+    for (auto parseTask : parseWorklist_)
+        parseTask->trace(trc);
+    for (auto parseTask : parseFinishedList_)
+        parseTask->trace(trc);
+    for (auto parseTask : parseWaitingOnGC_)
+        parseTask->trace(trc);
+}
+
 void
 HelperThread::handleGCHelperWorkload(AutoLockHelperThreadState& locked)
 {
diff --git a/js/src/vm/HelperThreads.h b/js/src/vm/HelperThreads.h
index 0413ec20dbd0..43b58edc4398 100644
--- a/js/src/vm/HelperThreads.h
+++ b/js/src/vm/HelperThreads.h
@@ -230,6 +230,8 @@ class GlobalHelperThreadState
                                    Handle global,
                                    JSCompartment* dest);
 
+    void trace(JSTracer* trc);
+
   private:
     /*
      * Number of wasm jobs that encountered failure for the active module.
@@ -490,7 +492,7 @@ struct ParseTask
     LifoAlloc alloc;
 
     // Rooted pointer to the global object used by 'cx'.
-    PersistentRootedObject exclusiveContextGlobal;
+    JSObject* exclusiveContextGlobal;
 
     // Callback invoked off the main thread when the parse finishes.
     JS::OffThreadCompileCallback callback;
@@ -499,10 +501,10 @@ struct ParseTask
     // Holds the final script between the invocation of the callback and the
     // point where FinishOffThreadScript is called, which will destroy the
     // ParseTask.
-    PersistentRootedScript script;
+    JSScript* script;
 
     // Holds the ScriptSourceObject generated for the script compilation.
-    PersistentRooted sourceObject;
+    ScriptSourceObject* sourceObject;
 
     // Any errors or warnings produced during compilation. These are reported
     // when finishing the script.
@@ -524,6 +526,8 @@ struct ParseTask
     }
 
     virtual ~ParseTask();
+
+    void trace(JSTracer* trc);
 };
 
 struct ScriptParseTask : public ParseTask
diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h
index 2e5cabcb4771..0acfa5c217a6 100644
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -1654,7 +1654,7 @@ struct GCManagedDeletePolicy
     void operator()(const T* ptr) {
         if (ptr) {
             JSRuntime* rt = TlsPerThreadData.get()->runtimeIfOnOwnerThread();
-            if (rt) {
+            if (rt && rt->gc.nursery.isEnabled()) {
                 // The object may contain nursery pointers and must only be
                 // destroyed after a minor GC.
                 rt->gc.callAfterMinorGC(deletePtr, const_cast(ptr));
diff --git a/js/src/vm/TypedArrayObject.h b/js/src/vm/TypedArrayObject.h
index 965ca282510b..1b134ba79bcf 100644
--- a/js/src/vm/TypedArrayObject.h
+++ b/js/src/vm/TypedArrayObject.h
@@ -120,8 +120,7 @@ class TypedArrayObject : public NativeObject
     AllocKindForLazyBuffer(size_t nbytes)
     {
         MOZ_ASSERT(nbytes <= INLINE_BUFFER_LIMIT);
-        /* For GGC we need at least one slot in which to store a forwarding pointer. */
-        size_t dataSlots = Max(size_t(1), AlignBytes(nbytes, sizeof(Value)) / sizeof(Value));
+        size_t dataSlots = AlignBytes(nbytes, sizeof(Value)) / sizeof(Value);
         MOZ_ASSERT(nbytes <= dataSlots * sizeof(Value));
         return gc::GetGCObjectKind(FIXED_DATA_START + dataSlots);
     }
diff --git a/js/src/vm/UnboxedObject-inl.h b/js/src/vm/UnboxedObject-inl.h
index ad6af5c10c7a..e7fa81201869 100644
--- a/js/src/vm/UnboxedObject-inl.h
+++ b/js/src/vm/UnboxedObject-inl.h
@@ -568,10 +568,12 @@ MoveBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* obj, uint32_t dstStart,
         uint8_t* data = obj->as().elements();
         size_t elementSize = UnboxedTypeSize(Type);
 
-        if (UnboxedTypeNeedsPreBarrier(Type)) {
+        if (UnboxedTypeNeedsPreBarrier(Type) &&
+            JS::shadow::Zone::asShadowZone(obj->zone())->needsIncrementalBarrier())
+        {
             // Trigger pre barriers on any elements we are overwriting. See
-            // moveDenseElements::moveDenseElements. No post barrier is needed
-            // as only whole cell post barriers are used with unboxed objects.
+            // NativeObject::moveDenseElements. No post barrier is needed as
+            // only whole cell post barriers are used with unboxed objects.
             for (size_t i = 0; i < length; i++)
                 obj->as().triggerPreBarrier(dstStart + i);
         }
diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp
index c9f9d7df4da6..ad6bdadb15fa 100644
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -59,7 +59,6 @@ JSValIsInterfaceOfType(JSContext* cx, HandleValue v, REFNSIID iid)
 {
 
     nsCOMPtr wn;
-    nsCOMPtr sup;
     nsCOMPtr iface;
 
     if (v.isPrimitive())
diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp
index fca25f3d5835..a389510c68ef 100644
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -343,10 +343,12 @@ xpc_MarkInCCGeneration(nsISupports* aVariant, uint32_t aGeneration)
 void
 xpc_TryUnmarkWrappedGrayObject(nsISupports* aWrappedJS)
 {
+#ifdef DEBUG
     nsCOMPtr wjsug =
       do_QueryInterface(aWrappedJS);
     MOZ_ASSERT(!wjsug, "One should never be able to QI to "
                        "nsIXPConnectWrappedJSUnmarkGray successfully!");
+#endif
 }
 
 /***************************************************************************/
diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp
index 4a61c6c855ce..1e8f89128ed0 100644
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -5275,7 +5275,6 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder,
   uint32_t oldGeneration = mContainerLayerGeneration;
   mContainerLayerGeneration = ++mMaxContainerLayerGeneration;
 
-  RefPtr paintedLayerInvalidRegion = nullptr;
   if (mRetainingManager) {
     if (aContainerItem) {
       StoreDataForFrame(aContainerItem, containerLayer, LAYER_ACTIVE);
diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp
index 7bed67439041..2572a5033e1f 100644
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -299,6 +299,7 @@ RestyleManager::AttributeChanged(Element* aElement,
   // XXXbz how, exactly, would this attribute change cause us to be
   // destroyed from inside this function?
   nsCOMPtr shell = PresContext()->GetPresShell();
+  mozilla::Unused << shell; // Unused within this function
 
   // Get the frame associated with the content which is the highest in the frame tree
   nsIFrame* primaryFrame = aElement->GetPrimaryFrame();
@@ -694,6 +695,7 @@ RestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint,
 
   // Make sure that the viewmanager will outlive the presshell
   RefPtr vm = presShell->GetViewManager();
+  mozilla::Unused << vm; // Not used within this function
 
   // We may reconstruct frames below and hence process anything that is in the
   // tree. We don't want to get notified to process those items again after.
diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp
index 9e1a47f745bf..87e4b3e62e0d 100644
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -672,9 +672,9 @@ nsDocumentViewer::InitPresentationStuff(bool aDoInitialReflow)
   width = p2a * mBounds.width;
   height = p2a * mBounds.height;
   if (aDoInitialReflow) {
-    nsCOMPtr shellGrip = mPresShell;
+    nsCOMPtr shell = mPresShell;
     // Initial reflow
-    mPresShell->Initialize(width, height);
+    shell->Initialize(width, height);
   } else {
     // Store the visible area so it's available for other callers of
     // Initialize, like nsContentSink::StartLayout.
@@ -1028,8 +1028,8 @@ nsDocumentViewer::LoadComplete(nsresult aStatus)
     // Now that the document has loaded, we can tell the presshell
     // to unsuppress painting.
     if (mPresShell) {
-      nsCOMPtr shellDeathGrip(mPresShell);
-      mPresShell->UnsuppressPainting();
+      nsCOMPtr shell(mPresShell);
+      shell->UnsuppressPainting();
       // mPresShell could have been removed now, see bug 378682/421432
       if (mPresShell) {
         mPresShell->LoadComplete();
@@ -1708,8 +1708,8 @@ nsDocumentViewer::Stop(void)
 
   if (!mLoaded && mPresShell) {
     // Well, we might as well paint what we have so far.
-    nsCOMPtr shellDeathGrip(mPresShell); // bug 378682
-    mPresShell->UnsuppressPainting();
+    nsCOMPtr shell(mPresShell); // bug 378682
+    shell->UnsuppressPainting();
   }
 
   return NS_OK;
@@ -2070,8 +2070,8 @@ nsDocumentViewer::Show(void)
     // shown...
 
     if (mPresShell) {
-      nsCOMPtr shellDeathGrip(mPresShell); // bug 378682
-      mPresShell->UnsuppressPainting();
+      nsCOMPtr shell(mPresShell); // bug 378682
+      shell->UnsuppressPainting();
     }
   }
 
diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp
index cb7954dc3325..1ad6205f7e80 100644
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -1897,7 +1897,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight, nscoord a
                                ? aOldWidth != aWidth
                                : aOldHeight != aHeight;
 
-  RefPtr viewManagerDeathGrip = mViewManager;
+  RefPtr viewManager = mViewManager;
   // Take this ref after viewManager so it'll make sure to go away first.
   nsCOMPtr kungFuDeathGrip(this);
 
@@ -1931,7 +1931,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight, nscoord a
 
         // Kick off a top-down reflow
         AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow);
-        nsViewManager::AutoDisableRefresh refreshBlocker(mViewManager);
+        nsViewManager::AutoDisableRefresh refreshBlocker(viewManager);
 
         mDirtyRoots.RemoveElement(rootFrame);
         DoReflow(rootFrame, true);
@@ -4063,10 +4063,10 @@ PresShell::FlushPendingNotifications(mozilla::ChangesToFlush aFlush)
 
   NS_ASSERTION(!isSafeToFlush || mViewManager, "Must have view manager");
   // Make sure the view manager stays alive.
-  RefPtr viewManagerDeathGrip = mViewManager;
+  RefPtr viewManager = mViewManager;
   bool didStyleFlush = false;
   bool didLayoutFlush = false;
-  if (isSafeToFlush && mViewManager) {
+  if (isSafeToFlush && viewManager) {
     // Processing pending notifications can kill us, and some callers only
     // hold weak refs when calling FlushPendingNotifications().  :(
     nsCOMPtr kungFuDeathGrip(this);
@@ -4095,7 +4095,7 @@ PresShell::FlushPendingNotifications(mozilla::ChangesToFlush aFlush)
     // Process pending restyles, since any flush of the presshell wants
     // up-to-date style data.
     if (!mIsDestroying) {
-      mViewManager->FlushDelayedResize(false);
+      viewManager->FlushDelayedResize(false);
       mPresContext->FlushPendingMediaFeatureValuesChanged();
 
       // Flush any pending update of the user font set, since that could
@@ -4151,7 +4151,7 @@ PresShell::FlushPendingNotifications(mozilla::ChangesToFlush aFlush)
         !mIsDestroying) {
       didLayoutFlush = true;
       mFrameConstructor->RecalcQuotesAndCounters();
-      mViewManager->FlushDelayedResize(true);
+      viewManager->FlushDelayedResize(true);
       if (ProcessReflowCommands(flushType < Flush_Layout) && mContentToScrollTo) {
         // We didn't get interrupted.  Go ahead and scroll to our content
         DoScrollContentIntoView();
@@ -4164,7 +4164,7 @@ PresShell::FlushPendingNotifications(mozilla::ChangesToFlush aFlush)
 
     if (flushType >= Flush_Layout) {
       if (!mIsDestroying) {
-        mViewManager->UpdateWidgetGeometry();
+        viewManager->UpdateWidgetGeometry();
       }
     }
   }
diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp
index 5572e3b0270c..f570abb380b8 100644
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -205,7 +205,6 @@ static void Shutdown();
 #include "nsIMobileMessageService.h"
 #include "nsIMobileMessageDatabaseService.h"
 #include "nsIPowerManagerService.h"
-#include "nsIAlarmHalService.h"
 #include "nsIMediaManager.h"
 #include "mozilla/dom/nsMixedContentBlocker.h"
 
@@ -215,7 +214,6 @@ static void Shutdown();
 #include "mozilla/dom/FlyWebService.h"
 
 #include "mozilla/dom/power/PowerManagerService.h"
-#include "mozilla/dom/alarm/AlarmHalService.h"
 #include "mozilla/dom/time/TimeService.h"
 #include "StreamingProtocolService.h"
 
@@ -251,7 +249,6 @@ static void Shutdown();
 
 using namespace mozilla;
 using namespace mozilla::dom;
-using mozilla::dom::alarm::AlarmHalService;
 using mozilla::dom::power::PowerManagerService;
 using mozilla::dom::quota::QuotaManagerService;
 using mozilla::dom::workers::ServiceWorkerManager;
@@ -361,8 +358,6 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMobileMessageDatabaseService,
                                          NS_CreateMobileMessageDatabaseService)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIPowerManagerService,
                                          PowerManagerService::GetInstance)
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIAlarmHalService,
-                                         AlarmHalService::GetInstance)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsITimeService,
                                          TimeService::GetInstance)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIStreamingProtocolControllerService,
@@ -833,7 +828,6 @@ NS_DEFINE_NAMED_CID(MOBILE_MESSAGE_SERVICE_CID);
 NS_DEFINE_NAMED_CID(MOBILE_MESSAGE_DATABASE_SERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_POWERMANAGERSERVICE_CID);
 NS_DEFINE_NAMED_CID(OSFILECONSTANTSSERVICE_CID);
-NS_DEFINE_NAMED_CID(NS_ALARMHALSERVICE_CID);
 NS_DEFINE_NAMED_CID(UDPSOCKETCHILD_CID);
 NS_DEFINE_NAMED_CID(NS_TIMESERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_MEDIASTREAMCONTROLLERSERVICE_CID);
@@ -1135,7 +1129,6 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
   { &kMOBILE_MESSAGE_DATABASE_SERVICE_CID, false, nullptr, nsIMobileMessageDatabaseServiceConstructor },
   { &kNS_POWERMANAGERSERVICE_CID, false, nullptr, nsIPowerManagerServiceConstructor, Module::ALLOW_IN_GPU_PROCESS },
   { &kOSFILECONSTANTSSERVICE_CID, true, nullptr, OSFileConstantsServiceConstructor },
-  { &kNS_ALARMHALSERVICE_CID, false, nullptr, nsIAlarmHalServiceConstructor },
   { &kUDPSOCKETCHILD_CID, false, nullptr, UDPSocketChildConstructor },
   { &kGECKO_MEDIA_PLUGIN_SERVICE_CID, true, nullptr, GeckoMediaPluginServiceConstructor },
   { &kNS_TIMESERVICE_CID, false, nullptr, nsITimeServiceConstructor },
@@ -1299,7 +1292,6 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
   { MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID, &kMOBILE_MESSAGE_DATABASE_SERVICE_CID },
   { POWERMANAGERSERVICE_CONTRACTID, &kNS_POWERMANAGERSERVICE_CID, Module::ALLOW_IN_GPU_PROCESS },
   { OSFILECONSTANTSSERVICE_CONTRACTID, &kOSFILECONSTANTSSERVICE_CID },
-  { ALARMHALSERVICE_CONTRACTID, &kNS_ALARMHALSERVICE_CID },
   { "@mozilla.org/udp-socket-child;1", &kUDPSOCKETCHILD_CID },
   { TIMESERVICE_CONTRACTID, &kNS_TIMESERVICE_CID },
   { MEDIASTREAMCONTROLLERSERVICE_CONTRACTID, &kNS_MEDIASTREAMCONTROLLERSERVICE_CID },
diff --git a/layout/generic/nsPluginFrame.cpp b/layout/generic/nsPluginFrame.cpp
index c0468115996e..64e3ea5767aa 100644
--- a/layout/generic/nsPluginFrame.cpp
+++ b/layout/generic/nsPluginFrame.cpp
@@ -321,7 +321,6 @@ nsPluginFrame::PrepForDrawing(nsIWidget *aWidget)
     configuration->mBounds.height = NSAppUnitsToIntPixels(mRect.height, appUnitsPerDevPixel);
     parentWidget->ConfigureChildren(configurations);
 
-    RefPtr dx = viewMan->GetDeviceContext();
     mInnerView->AttachWidgetEventHandler(mWidget);
 
 #ifdef XP_MACOSX
diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp
index 8f1d2783ee8b..78767121ceb1 100644
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -2783,7 +2783,6 @@ nsFrameSelection::SelectBlockOfCells(nsIContent *aStartCell, nsIContent *aEndCel
   NS_ENSURE_TRUE(aEndCell, NS_ERROR_NULL_POINTER);
   mEndSelectedCell = aEndCell;
 
-  nsCOMPtr startCell;
   nsresult result = NS_OK;
 
   // If new end cell is in a different table, do nothing
@@ -5092,17 +5091,17 @@ Selection::Collapse(nsINode& aParentNode, uint32_t aOffset, ErrorResult& aRv)
     return;
   }
 
-  nsCOMPtr kungfuDeathGrip = &aParentNode;
+  nsCOMPtr parentNode = &aParentNode;
 
   mFrameSelection->InvalidateDesiredPos();
-  if (!IsValidSelectionPoint(mFrameSelection, &aParentNode)) {
+  if (!IsValidSelectionPoint(mFrameSelection, parentNode)) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
   nsresult result;
 
   RefPtr presContext = GetPresContext();
-  if (!presContext || presContext->Document() != aParentNode.OwnerDoc()) {
+  if (!presContext || presContext->Document() != parentNode->OwnerDoc()) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
@@ -5115,37 +5114,37 @@ Selection::Collapse(nsINode& aParentNode, uint32_t aOffset, ErrorResult& aRv)
 
   // Hack to display the caret on the right line (bug 1237236).
   if (mFrameSelection->GetHint() != CARET_ASSOCIATE_AFTER &&
-      aParentNode.IsContent()) {
+      parentNode->IsContent()) {
     int32_t frameOffset;
     nsTextFrame* f =
-      do_QueryFrame(nsCaret::GetFrameAndOffset(this, &aParentNode,
+      do_QueryFrame(nsCaret::GetFrameAndOffset(this, parentNode,
                                                aOffset, &frameOffset));
     if (f && f->IsAtEndOfLine() && f->HasSignificantTerminalNewline()) {
-      if ((aParentNode.AsContent() == f->GetContent() &&
+      if ((parentNode->AsContent() == f->GetContent() &&
            f->GetContentEnd() == int32_t(aOffset)) ||
-          (&aParentNode == f->GetContent()->GetParentNode() &&
-           aParentNode.IndexOf(f->GetContent()) + 1 == int32_t(aOffset))) {
+          (parentNode == f->GetContent()->GetParentNode() &&
+           parentNode->IndexOf(f->GetContent()) + 1 == int32_t(aOffset))) {
         mFrameSelection->SetHint(CARET_ASSOCIATE_AFTER);
       }
     }
   }
 
-  RefPtr range = new nsRange(&aParentNode);
-  result = range->SetEnd(&aParentNode, aOffset);
+  RefPtr range = new nsRange(parentNode);
+  result = range->SetEnd(parentNode, aOffset);
   if (NS_FAILED(result)) {
     aRv.Throw(result);
     return;
   }
-  result = range->SetStart(&aParentNode, aOffset);
+  result = range->SetStart(parentNode, aOffset);
   if (NS_FAILED(result)) {
     aRv.Throw(result);
     return;
   }
 
 #ifdef DEBUG_SELECTION
-  nsCOMPtr content = do_QueryInterface(&aParentNode);
-  nsCOMPtr doc = do_QueryInterface(&aParentNode);
-  printf ("Sel. Collapse to %p %s %d\n", &aParentNode,
+  nsCOMPtr content = do_QueryInterface(parentNode);
+  nsCOMPtr doc = do_QueryInterface(parentNode);
+  printf ("Sel. Collapse to %p %s %d\n", parentNode.get(),
           content ? nsAtomCString(content->NodeInfo()->NameAtom()).get()
                   : (doc ? "DOCUMENT" : "???"),
           aOffset);
diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp
index 1640b2becae1..7fbfa49949ac 100644
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -1872,8 +1872,6 @@ nsPrintEngine::OnStateChange(nsIWebProgress* aWebProgress,
     return NS_OK;
   }
   if (aStateFlags & STATE_START) {
-    nsCOMPtr channel = do_QueryInterface(aRequest);
-
     ++mLoadCounter;
   } else if (aStateFlags & STATE_STOP) {
     mDidLoadDataForPrinting = true;
diff --git a/layout/printing/nsPrintObject.cpp b/layout/printing/nsPrintObject.cpp
index 922c65e4d804..fd4377886b44 100644
--- a/layout/printing/nsPrintObject.cpp
+++ b/layout/printing/nsPrintObject.cpp
@@ -67,7 +67,10 @@ nsPrintObject::Init(nsIDocShell* aDocShell, nsIDOMDocument* aDoc,
   }
   NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
 
+  // Keep the document related to this docshell alive
   nsCOMPtr dummy = do_GetInterface(mDocShell);
+  mozilla::Unused << dummy;
+
   nsCOMPtr viewer;
   mDocShell->GetContentViewer(getter_AddRefs(viewer));
   NS_ENSURE_STATE(viewer);
diff --git a/layout/style/FontFace.cpp b/layout/style/FontFace.cpp
index 8adfe19c6105..3fbf3feeba55 100644
--- a/layout/style/FontFace.cpp
+++ b/layout/style/FontFace.cpp
@@ -160,8 +160,6 @@ FontFace::CreateForRule(nsISupports* aGlobal,
                         FontFaceSet* aFontFaceSet,
                         nsCSSFontFaceRule* aRule)
 {
-  nsCOMPtr globalObject = do_QueryInterface(aGlobal);
-
   RefPtr obj = new FontFace(aGlobal, aFontFaceSet);
   obj->mRule = aRule;
   obj->mSourceType = eSourceType_FontFaceRule;
diff --git a/layout/xul/nsScrollbarFrame.cpp b/layout/xul/nsScrollbarFrame.cpp
index 549d97ede7bc..d9c28a2bf90e 100644
--- a/layout/xul/nsScrollbarFrame.cpp
+++ b/layout/xul/nsScrollbarFrame.cpp
@@ -95,8 +95,8 @@ nsScrollbarFrame::AttributeChanged(int32_t aNameSpaceID,
   if (!scrollable)
     return rv;
 
-  nsCOMPtr kungFuDeathGrip(mContent);
-  scrollable->CurPosAttributeChanged(mContent);
+  nsCOMPtr content(mContent);
+  scrollable->CurPosAttributeChanged(content);
   return rv;
 }
 
diff --git a/layout/xul/nsSliderFrame.cpp b/layout/xul/nsSliderFrame.cpp
index 39a4999de958..fa76d9e72630 100644
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -878,7 +878,6 @@ nsSliderFrame::SetCurrentPositionInternal(nsIContent* aScrollbar, int32_t aNewPo
     // See if we have a mediator.
     nsIScrollbarMediator* mediator = scrollbarFrame->GetScrollbarMediator();
     if (mediator) {
-      nsCOMPtr content = GetContent();
       nscoord oldPos = nsPresContext::CSSPixelsToAppUnits(GetCurrentPosition(scrollbar));
       nscoord newPos = nsPresContext::CSSPixelsToAppUnits(aNewPos);
       mediator->ThumbMoved(scrollbarFrame, oldPos, newPos);
diff --git a/layout/xul/nsSplitterFrame.cpp b/layout/xul/nsSplitterFrame.cpp
index d6f98600ae45..7879a176d369 100644
--- a/layout/xul/nsSplitterFrame.cpp
+++ b/layout/xul/nsSplitterFrame.cpp
@@ -384,15 +384,15 @@ nsSplitterFrame::HandleEvent(nsPresContext* aPresContext,
   }
 
   nsWeakFrame weakFrame(this);
-  RefPtr kungFuDeathGrip(mInner);
+  RefPtr inner(mInner);
   switch (aEvent->mMessage) {
     case eMouseMove: 
-      mInner->MouseDrag(aPresContext, aEvent);
+      inner->MouseDrag(aPresContext, aEvent);
       break;
   
     case eMouseUp:
       if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
-        mInner->MouseUp(aPresContext, aEvent);
+        inner->MouseUp(aPresContext, aEvent);
       }
       break;
 
diff --git a/layout/xul/nsXULPopupManager.cpp b/layout/xul/nsXULPopupManager.cpp
index 4a74afdf550f..cf60814cc3c7 100644
--- a/layout/xul/nsXULPopupManager.cpp
+++ b/layout/xul/nsXULPopupManager.cpp
@@ -1509,6 +1509,7 @@ nsXULPopupManager::FirePopupHidingEvent(nsIContent* aPopup,
                                         bool aIsCancel)
 {
   nsCOMPtr presShell = aPresContext->PresShell();
+  mozilla::Unused << presShell; // This presShell may be keeping things alive on non GTK platforms
 
   nsEventStatus status = nsEventStatus_eIgnore;
   WidgetMouseEvent event(true, eXULPopupHiding, nullptr,
@@ -2745,6 +2746,7 @@ nsXULMenuCommandEvent::Run()
     nsPresContext* presContext = menuFrame->PresContext();
     nsCOMPtr shell = presContext->PresShell();
     RefPtr kungFuDeathGrip = shell->GetViewManager();
+    mozilla::Unused << kungFuDeathGrip; // Not referred to directly within this function
 
     // Deselect ourselves.
     if (mCloseMenuMode != CloseMenuMode_None)
diff --git a/media/mtransport/nr_timer.cpp b/media/mtransport/nr_timer.cpp
index 6b4cc8b82782..a1f9d709c811 100644
--- a/media/mtransport/nr_timer.cpp
+++ b/media/mtransport/nr_timer.cpp
@@ -58,6 +58,7 @@
 #include "nsITimer.h"
 #include "nsNetCID.h"
 #include "runnable_utils.h"
+#include "mozilla/DebugOnly.h"
 
 extern "C" {
 #include "nr_api.h"
@@ -166,9 +167,9 @@ static nsCOMPtr GetSTSThread() {
 // These timers must only be used from the STS thread.
 // This function is a helper that enforces that.
 static void CheckSTSThread() {
-  nsCOMPtr sts_thread = GetSTSThread();
+  DebugOnly> sts_thread = GetSTSThread();
 
-  ASSERT_ON_THREAD(sts_thread);
+  ASSERT_ON_THREAD(sts_thread.value);
 }
 
 static int nr_async_timer_set_zero(NR_async_cb cb, void *arg,
diff --git a/mfbt/tests/TestNotNull.cpp b/mfbt/tests/TestNotNull.cpp
index 7887d6575785..4642dd93edd1 100644
--- a/mfbt/tests/TestNotNull.cpp
+++ b/mfbt/tests/TestNotNull.cpp
@@ -7,6 +7,7 @@
 #include "mozilla/NotNull.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
+#include "mozilla/Unused.h"
 
 using mozilla::WrapNotNull;
 using mozilla::MakeUnique;
@@ -283,10 +284,12 @@ TestNotNullWithRefPtr()
   // At this point the refcount is still 2.
 
   RefPtr r4 = r2;
+  mozilla::Unused << r4;
 
   // At this point the refcount is 3.
 
   RefPtr r5 = r3.get();
+  mozilla::Unused << r5;
 
   // At this point the refcount is 4.
 
diff --git a/mobile/android/chrome/content/PermissionsHelper.js b/mobile/android/chrome/content/PermissionsHelper.js
index ad1eb760aaba..cc5fe4f43f28 100644
--- a/mobile/android/chrome/content/PermissionsHelper.js
+++ b/mobile/android/chrome/content/PermissionsHelper.js
@@ -5,8 +5,7 @@
 
 var PermissionsHelper = {
   _permissonTypes: ["password", "geolocation", "popup", "indexedDB",
-                    "offline-app", "desktop-notification", "plugins", "native-intent",
-                    "flyweb-publish-server"],
+                    "offline-app", "desktop-notification", "plugins", "native-intent"],
   _permissionStrings: {
     "password": {
       label: "password.logins",
@@ -18,11 +17,6 @@ var PermissionsHelper = {
       allowed: "geolocation.allow",
       denied: "geolocation.dontAllow"
     },
-    "flyweb-publish-server": {
-      label: "flyWebPublishServer.publishServer",
-      allowed: "flyWebPublishServer.allow",
-      denied: "flyWebPublishServer.dontAllow"
-    },
     "popup": {
       label: "blockPopups.label2",
       allowed: "popup.show",
diff --git a/mobile/android/components/ContentPermissionPrompt.js b/mobile/android/components/ContentPermissionPrompt.js
index 0d8627a2844c..5e68bfd664d3 100644
--- a/mobile/android/components/ContentPermissionPrompt.js
+++ b/mobile/android/components/ContentPermissionPrompt.js
@@ -18,14 +18,12 @@ const kEntities = {
   "device-storage:sdcard": "deviceStorageSdcard",
   "device-storage:videos": "deviceStorageVideos",
   "geolocation": "geolocation",
-  "flyweb-publish-server": "flyWebPublishServer",
 };
 
 // For these types, prompt for permission if action is unknown.
 const PROMPT_FOR_UNKNOWN = [
   "desktop-notification",
   "geolocation",
-  "flyweb-publish-server",
 ];
 
 function ContentPermissionPrompt() {}
diff --git a/mobile/android/locales/en-US/chrome/browser.properties b/mobile/android/locales/en-US/chrome/browser.properties
index 0b30acb70520..cc4dad3b788f 100644
--- a/mobile/android/locales/en-US/chrome/browser.properties
+++ b/mobile/android/locales/en-US/chrome/browser.properties
@@ -131,18 +131,6 @@ desktopNotification2.ask=Would you like to receive notifications from this site?
 # used in site settings dialog.
 desktopNotification.notifications=Notifications
 
-# FlyWeb UI
-# LOCALIZATION NOTE (flyWebPublishServer.allow): This is an experimental feature only shipping in Nightly, and doesn't need translation.
-flyWebPublishServer.allow=Allow
-# LOCALIZATION NOTE (flyWebPublishServer.dontAllow): This is an experimental feature only shipping in Nightly, and doesn't need translation.
-flyWebPublishServer.dontAllow=Deny
-# LOCALIZATION NOTE (flyWebPublishServer.ask): This is an experimental feature only shipping in Nightly, and doesn't need translation.
-flyWebPublishServer.ask=Would you like to let this site start a server accessible to nearby devices and people?
-# LOCALIZATION NOTE (flyWebPublishServer.dontAskAgain): This is an experimental feature only shipping in Nightly, and doesn't need translation.
-flyWebPublishServer.dontAskAgain=Don't ask again for this site
-# LOCALIZATION NOTE (flyWebPublishServer.publishServer): This is an experimental feature only shipping in Nightly, and doesn't need translation.
-flyWebPublishServer.publishServer=Publish Server
-
 # Imageblocking
 imageblocking.downloadedImage=Image unblocked
 imageblocking.showAllImages=Show All
diff --git a/modules/libjar/nsJAR.cpp b/modules/libjar/nsJAR.cpp
index 70bea8edade0..fb9651658598 100644
--- a/modules/libjar/nsJAR.cpp
+++ b/modules/libjar/nsJAR.cpp
@@ -1112,7 +1112,6 @@ nsZipReaderCache::IsCached(nsIFile* zipFile, bool* aResult)
 {
   NS_ENSURE_ARG_POINTER(zipFile);
   nsresult rv;
-  nsCOMPtr antiLockZipGrip;
   MutexAutoLock lock(mLock);
 
   nsAutoCString uri;
@@ -1131,7 +1130,6 @@ nsZipReaderCache::GetZip(nsIFile* zipFile, nsIZipReader* *result)
 {
   NS_ENSURE_ARG_POINTER(zipFile);
   nsresult rv;
-  nsCOMPtr antiLockZipGrip;
   MutexAutoLock lock(mLock);
 
 #ifdef ZIP_CACHE_HIT_RATE
diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp
index 445b09dd9e6a..82b14c9e5db7 100644
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -335,7 +335,6 @@ nsJARChannel::LookupFile(bool aAllowAsync)
         return NS_OK;
 
     nsresult rv;
-    nsCOMPtr uri;
 
     rv = mJarURI->GetJARFile(getter_AddRefs(mJarBaseURI));
     if (NS_FAILED(rv))
diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
index 3f172638a51a..8762b0ade1d4 100644
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -519,6 +519,8 @@ pref("media.navigator.audio.full_duplex", false);
 #endif
 #endif
 
+pref("dom.webaudio.enabled", true);
+
 #if !defined(ANDROID)
 pref("media.getusermedia.screensharing.enabled", true);
 #endif
@@ -756,7 +758,13 @@ pref("gfx.font_rendering.opentype_svg.enabled", true);
 // comma separated list of backends to use in order of preference
 // e.g., pref("gfx.canvas.azure.backends", "direct2d,skia,cairo");
 pref("gfx.canvas.azure.backends", "direct2d1.1,skia,cairo");
+
+#ifdef NIGHTLY_BUILD
 pref("gfx.content.azure.backends", "direct2d1.1,skia,cairo");
+#else
+pref("gfx.content.azure.backends", "direct2d1.1,cairo");
+#endif
+
 #else
 #ifdef XP_MACOSX
 pref("gfx.content.azure.backends", "skia");
@@ -4734,9 +4742,6 @@ pref("dom.sms.defaultServiceId", 0);
 // negative: read ahead all IDs if possible.
 pref("dom.sms.maxReadAheadEntries", 0);
 
-// WebAlarms
-pref("dom.mozAlarms.enabled", false);
-
 // Push
 
 pref("dom.push.enabled", false);
diff --git a/netwerk/cache2/CacheEntry.cpp b/netwerk/cache2/CacheEntry.cpp
index 083d22588b55..dba9e72b1dd8 100644
--- a/netwerk/cache2/CacheEntry.cpp
+++ b/netwerk/cache2/CacheEntry.cpp
@@ -1823,7 +1823,6 @@ NS_IMETHODIMP CacheOutputCloseListener::Run()
 size_t CacheEntry::SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const
 {
   size_t n = 0;
-  nsCOMPtr sizeOf;
 
   n += mCallbacks.ShallowSizeOfExcludingThis(mallocSizeOf);
   if (mFile) {
diff --git a/netwerk/ipc/ChannelEventQueue.cpp b/netwerk/ipc/ChannelEventQueue.cpp
index b9bd2b34417a..a4dbae7d5b5d 100644
--- a/netwerk/ipc/ChannelEventQueue.cpp
+++ b/netwerk/ipc/ChannelEventQueue.cpp
@@ -9,6 +9,7 @@
 #include "mozilla/net/ChannelEventQueue.h"
 #include "mozilla/Unused.h"
 #include "nsThreadUtils.h"
+#include "mozilla/Unused.h"
 
 namespace mozilla {
 namespace net {
@@ -36,6 +37,7 @@ ChannelEventQueue::FlushQueue()
   // destructor) unless we make sure its refcount doesn't drop to 0 while this
   // method is running.
   nsCOMPtr kungFuDeathGrip(mOwner);
+  mozilla::Unused << kungFuDeathGrip; // Not used in this function
 
   // Prevent flushed events from flushing the queue recursively
   {
diff --git a/netwerk/protocol/http/InterceptedChannel.cpp b/netwerk/protocol/http/InterceptedChannel.cpp
index 9206b5d4b549..231efe96c279 100644
--- a/netwerk/protocol/http/InterceptedChannel.cpp
+++ b/netwerk/protocol/http/InterceptedChannel.cpp
@@ -162,8 +162,6 @@ InterceptedChannelChrome::InterceptedChannelChrome(nsHttpChannel* aChannel,
 void
 InterceptedChannelChrome::NotifyController()
 {
-  nsCOMPtr out;
-
   // Intercepted responses should already be decoded.
   mChannel->SetApplyConversion(false);
 
diff --git a/netwerk/sctp/datachannel/DataChannel.cpp b/netwerk/sctp/datachannel/DataChannel.cpp
index 624cb9c1234c..f699197beff8 100644
--- a/netwerk/sctp/datachannel/DataChannel.cpp
+++ b/netwerk/sctp/datachannel/DataChannel.cpp
@@ -2546,7 +2546,7 @@ DataChannel::Close()
 {
   ENSURE_DATACONNECTION;
   RefPtr connection(mConnection);
-  mConnection->Close(this);
+  connection->Close(this);
 }
 
 // Used when disconnecting from the DataChannelConnection
diff --git a/parser/html/nsHtml5Parser.cpp b/parser/html/nsHtml5Parser.cpp
index 8d3a6e6648bb..e8ca12f89b99 100644
--- a/parser/html/nsHtml5Parser.cpp
+++ b/parser/html/nsHtml5Parser.cpp
@@ -210,14 +210,15 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
   // Gripping the other objects just in case, since the other old grip
   // required grips to these, too.
   RefPtr streamKungFuDeathGrip(GetStreamParser());
-  RefPtr treeOpKungFuDeathGrip(mExecutor);
+  mozilla::Unused << streamKungFuDeathGrip; // Not used within function
+  RefPtr executor(mExecutor);
 
-  if (!mExecutor->HasStarted()) {
+  if (!executor->HasStarted()) {
     NS_ASSERTION(!GetStreamParser(),
                  "Had stream parser but document.write started life cycle.");
     // This is the first document.write() on a document.open()ed document
-    mExecutor->SetParser(this);
-    mTreeBuilder->setScriptingEnabled(mExecutor->IsScriptEnabled());
+    executor->SetParser(this);
+    mTreeBuilder->setScriptingEnabled(executor->IsScriptEnabled());
 
     bool isSrcdoc = false;
     nsCOMPtr channel;
@@ -228,7 +229,7 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
     mTreeBuilder->setIsSrcdocDocument(isSrcdoc);
 
     mTokenizer->start();
-    mExecutor->Start();
+    executor->Start();
     if (!aContentType.EqualsLiteral("text/html")) {
       mTreeBuilder->StartPlainText();
       mTokenizer->StartPlainText();
@@ -238,12 +239,12 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
      * WillBuildModel to be called before the document has had its 
      * script global object set.
      */
-    rv = mExecutor->WillBuildModel(eDTDMode_unknown);
+    rv = executor->WillBuildModel(eDTDMode_unknown);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // Return early if the parser has processed EOF
-  if (mExecutor->IsComplete()) {
+  if (executor->IsComplete()) {
     return NS_OK;
   }
 
@@ -371,11 +372,11 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
       }
 
       if (!mTokenizer->EnsureBufferSpace(stackBuffer.getLength())) {
-        return mExecutor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
+        return executor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
       }
       mLastWasCR = mTokenizer->tokenizeBuffer(&stackBuffer);
       if (NS_FAILED((rv = mTreeBuilder->IsBroken()))) {
-        return mExecutor->MarkAsBroken(rv);
+        return executor->MarkAsBroken(rv);
       }
 
       if (inRootContext) {
@@ -386,11 +387,11 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
 
       if (mTreeBuilder->HasScript()) {
         mTreeBuilder->Flush(); // Move ops to the executor
-        rv = mExecutor->FlushDocumentWrite(); // run the ops
+        rv = executor->FlushDocumentWrite(); // run the ops
         NS_ENSURE_SUCCESS(rv, rv);
         // Flushing tree ops can cause all sorts of things.
         // Return early if the parser got terminated.
-        if (mExecutor->IsComplete()) {
+        if (executor->IsComplete()) {
           return NS_OK;
         }
       }
@@ -405,7 +406,7 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
     heapBuffer = stackBuffer.FalliblyCopyAsOwningBuffer();
     if (!heapBuffer) {
       // Allocation failed. The parser is now broken.
-      return mExecutor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
+      return executor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
     }
   }
 
@@ -446,7 +447,7 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
       "Buffer wasn't tokenized to completion?");
     // Scripting semantics require a forced tree builder flush here
     mTreeBuilder->Flush(); // Move ops to the executor
-    rv = mExecutor->FlushDocumentWrite(); // run the ops
+    rv = executor->FlushDocumentWrite(); // run the ops
     NS_ENSURE_SUCCESS(rv, rv);
   } else if (stackBuffer.hasMore()) {
     // The buffer wasn't tokenized to completion. Tokenize the untokenized
@@ -457,7 +458,7 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
       if (!mDocWriteSpeculativeTreeBuilder) {
         // Lazily initialize if uninitialized
         mDocWriteSpeculativeTreeBuilder =
-            new nsHtml5TreeBuilder(nullptr, mExecutor->GetStage());
+            new nsHtml5TreeBuilder(nullptr, executor->GetStage());
         mDocWriteSpeculativeTreeBuilder->setScriptingEnabled(
             mTreeBuilder->isScriptingEnabled());
         mDocWriteSpeculativeTokenizer =
@@ -484,20 +485,20 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
       if (stackBuffer.hasMore()) {
         if (!mDocWriteSpeculativeTokenizer->EnsureBufferSpace(
             stackBuffer.getLength())) {
-          return mExecutor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
+          return executor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
         }
         mDocWriteSpeculativeLastWasCR =
             mDocWriteSpeculativeTokenizer->tokenizeBuffer(&stackBuffer);
         nsresult rv;
         if (NS_FAILED((rv = mDocWriteSpeculativeTreeBuilder->IsBroken()))) {
-          return mExecutor->MarkAsBroken(rv);
+          return executor->MarkAsBroken(rv);
         }
       }
     }
 
     mDocWriteSpeculativeTreeBuilder->Flush();
     mDocWriteSpeculativeTreeBuilder->DropHandles();
-    mExecutor->FlushSpeculativeLoads();
+    executor->FlushSpeculativeLoads();
   }
 
   return NS_OK;
@@ -514,12 +515,12 @@ nsHtml5Parser::Terminate()
   // XXX - [ until we figure out a way to break parser-sink circularity ]
   // Hack - Hold a reference until we are completely done...
   nsCOMPtr kungFuDeathGrip(this);
-  RefPtr streamKungFuDeathGrip(GetStreamParser());
-  RefPtr treeOpKungFuDeathGrip(mExecutor);
-  if (GetStreamParser()) {
-    GetStreamParser()->Terminate();
+  RefPtr streamParser(GetStreamParser());
+  RefPtr executor(mExecutor);
+  if (streamParser) {
+    streamParser->Terminate();
   }
-  return mExecutor->DidBuildModel(true);
+  return executor->DidBuildModel(true);
 }
 
 NS_IMETHODIMP
diff --git a/parser/html/nsHtml5TreeOpExecutor.cpp b/parser/html/nsHtml5TreeOpExecutor.cpp
index 815823b168a6..a79802007ae9 100644
--- a/parser/html/nsHtml5TreeOpExecutor.cpp
+++ b/parser/html/nsHtml5TreeOpExecutor.cpp
@@ -350,7 +350,7 @@ nsHtml5TreeOpExecutor::RunFlushLoop()
   
   nsHtml5FlushLoopGuard guard(this); // this is also the self-kungfu!
   
-  nsCOMPtr parserKungFuDeathGrip(mParser);
+  RefPtr parserKungFuDeathGrip(mParser);
 
   // Remember the entry time
   (void) nsContentSink::WillParseImpl();
@@ -366,7 +366,7 @@ nsHtml5TreeOpExecutor::RunFlushLoop()
       return;
     }
 
-    if (!mParser->IsParserEnabled()) {
+    if (!parserKungFuDeathGrip->IsParserEnabled()) {
       // The parser is blocked.
       return;
     }
@@ -413,6 +413,7 @@ nsHtml5TreeOpExecutor::RunFlushLoop()
       // gripped before calling ParseUntilBlocked();
       RefPtr streamKungFuDeathGrip = 
         GetParser()->GetStreamParser();
+      mozilla::Unused << streamKungFuDeathGrip; // Not used within function
       // Now parse content left in the document.write() buffer queue if any.
       // This may generate tree ops on its own or dequeue a speculation.
       nsresult rv = GetParser()->ParseUntilBlocked();
@@ -527,6 +528,7 @@ nsHtml5TreeOpExecutor::FlushDocumentWrite()
   // avoid crashing near EOF
   RefPtr kungFuDeathGrip(this);
   RefPtr parserKungFuDeathGrip(mParser);
+  mozilla::Unused << parserKungFuDeathGrip; // Intentionally not used within function
 
   NS_ASSERTION(!mReadingFromStage,
     "Got doc write flush when reading from stage");
diff --git a/parser/htmlparser/nsParser.cpp b/parser/htmlparser/nsParser.cpp
index 4b86b236e637..1d10a336c305 100644
--- a/parser/htmlparser/nsParser.cpp
+++ b/parser/htmlparser/nsParser.cpp
@@ -1050,8 +1050,8 @@ nsParser::ContinueInterruptedParsing()
                         mParserContext->mStreamListenerState == eOnStop;
 
   mProcessingNetworkData = true;
-  if (mSink) {
-    mSink->WillParse();
+  if (sinkDeathGrip) {
+    sinkDeathGrip->WillParse();
   }
   result = ResumeParse(true, isFinalChunk); // Ref. bug 57999
   mProcessingNetworkData = false;
@@ -1836,8 +1836,8 @@ nsParser::OnDataAvailable(nsIRequest *request, nsISupports* aContext,
       nsCOMPtr kungFuDeathGrip(this);
       nsCOMPtr sinkDeathGrip(mSink);
       mProcessingNetworkData = true;
-      if (mSink) {
-        mSink->WillParse();
+      if (sinkDeathGrip) {
+        sinkDeathGrip->WillParse();
       }
       rv = ResumeParse();
       mProcessingNetworkData = false;
diff --git a/python/mozbuild/mozbuild/mozinfo.py b/python/mozbuild/mozbuild/mozinfo.py
index 35a3a7c00728..65808416bf95 100755
--- a/python/mozbuild/mozbuild/mozinfo.py
+++ b/python/mozbuild/mozbuild/mozinfo.py
@@ -78,23 +78,30 @@ def build_dict(config, env=os.environ):
         d["bits"] = 32
     # other CPUs will wind up with unknown bits
 
-    d['debug'] = substs.get('MOZ_DEBUG') == '1'
-    d['nightly_build'] = substs.get('NIGHTLY_BUILD') == '1'
-    d['release_build'] = substs.get('RELEASE_BUILD') == '1'
-    d['pgo'] = substs.get('MOZ_PGO') == '1'
-    d['crashreporter'] = bool(substs.get('MOZ_CRASHREPORTER'))
-    d['datareporting'] = bool(substs.get('MOZ_DATA_REPORTING'))
-    d['healthreport'] = substs.get('MOZ_SERVICES_HEALTHREPORT') == '1'
-    d['sync'] = substs.get('MOZ_SERVICES_SYNC') == '1'
-    d['asan'] = substs.get('MOZ_ASAN') == '1'
-    d['tsan'] = substs.get('MOZ_TSAN') == '1'
-    d['telemetry'] = substs.get('MOZ_TELEMETRY_REPORTING') == '1'
-    d['tests_enabled'] = substs.get('ENABLE_TESTS') == "1"
     d['bin_suffix'] = substs.get('BIN_SUFFIX', '')
-    d['addon_signing'] = substs.get('MOZ_ADDON_SIGNING') == '1'
-    d['require_signing'] = substs.get('MOZ_REQUIRE_SIGNING') == '1'
-    d['official'] = bool(substs.get('MOZILLA_OFFICIAL'))
-    d['sm_promise'] = bool(substs.get('SPIDERMONKEY_PROMISE'))
+
+    # This is where all bool-like values go.
+    for info_name, subst_name in [
+            ('debug', 'MOZ_DEBUG'),
+            ('nightly_build', 'NIGHTLY_BUILD'),
+            ('release_build', 'RELEASE_BUILD'),
+            ('pgo', 'MOZ_PGO'),
+            ('crashreporter', 'MOZ_CRASHREPORTER'),
+            ('datareporting', 'MOZ_DATA_REPORTING'),
+            ('healthreport', 'MOZ_SERVICES_HEALTHREPORT'),
+            ('sync', 'MOZ_SERVICES_SYNC'),
+            ('asan', 'MOZ_ASAN'),
+            ('tsan', 'MOZ_TSAN'),
+            ('telemetry', 'MOZ_TELEMETRY_REPORTING'),
+            ('tests_enabled', 'ENABLE_TESTS'),
+            ('addon_signing', 'MOZ_ADDON_SIGNING'),
+            ('require_signing', 'MOZ_REQUIRE_SIGNING'),
+            ('official', 'MOZILLA_OFFICIAL'),
+            ('sm_promise', 'SPIDERMONKEY_PROMISE'),
+            ('rust', 'MOZ_RUST'),
+    ]:
+        d[info_name] = bool(substs.get(subst_name))
+
 
     def guess_platform():
         if d['buildapp'] in ('browser', 'mulet'):
diff --git a/rdf/base/nsRDFXMLDataSource.cpp b/rdf/base/nsRDFXMLDataSource.cpp
index c3a3711b2521..e108a7b0ba11 100644
--- a/rdf/base/nsRDFXMLDataSource.cpp
+++ b/rdf/base/nsRDFXMLDataSource.cpp
@@ -475,7 +475,6 @@ RDFXMLDataSourceImpl::BlockingParse(nsIURI* aURL, nsIStreamListener* aConsumer)
     // should be able to do by itself.
     
     nsCOMPtr channel;
-    nsCOMPtr request;
 
     // Null LoadGroup ?
     rv = NS_NewChannel(getter_AddRefs(channel),
diff --git a/security/manager/pki/nsASN1Tree.cpp b/security/manager/pki/nsASN1Tree.cpp
index 24a370b9b2fb..ce9672d8d2c4 100644
--- a/security/manager/pki/nsASN1Tree.cpp
+++ b/security/manager/pki/nsASN1Tree.cpp
@@ -87,7 +87,6 @@ nsNSSASN1Tree::InitChildsRecursively(myNode* n)
 
   myNode *walk = nullptr;
   myNode *prev = nullptr;
-  nsCOMPtr isupports;
   for (uint32_t i = 0; i < numObjects; i++) {
     if (0 == i) {
       n->child = walk = new myNode;
diff --git a/security/manager/pki/nsNSSDialogs.cpp b/security/manager/pki/nsNSSDialogs.cpp
index 5f641758e4eb..9e4e73d76275 100644
--- a/security/manager/pki/nsNSSDialogs.cpp
+++ b/security/manager/pki/nsNSSDialogs.cpp
@@ -272,9 +272,6 @@ nsNSSDialogs::PickCertificate(nsIInterfaceRequestor *ctx,
 
   *canceled = false;
 
-  // Get the parent window for the dialog
-  nsCOMPtr parent = do_GetInterface(ctx);
-
   nsCOMPtr block =
            do_CreateInstance(NS_DIALOGPARAMBLOCK_CONTRACTID);
   if (!block) return NS_ERROR_FAILURE;
@@ -437,9 +434,6 @@ nsNSSDialogs::ChooseToken(nsIInterfaceRequestor *aCtx, const char16_t **aTokenLi
 
   *aCanceled = false;
 
-  // Get the parent window for the dialog
-  nsCOMPtr parent = do_GetInterface(aCtx);
-
   nsCOMPtr block =
            do_CreateInstance(NS_DIALOGPARAMBLOCK_CONTRACTID);
   if (!block) return NS_ERROR_FAILURE;
diff --git a/security/manager/ssl/nsNSSComponent.cpp b/security/manager/ssl/nsNSSComponent.cpp
index a0093b6c7510..28256ac72312 100644
--- a/security/manager/ssl/nsNSSComponent.cpp
+++ b/security/manager/ssl/nsNSSComponent.cpp
@@ -2194,7 +2194,6 @@ GetDefaultCertVerifier()
   static NS_DEFINE_CID(kNSSComponentCID, NS_NSSCOMPONENT_CID);
 
   nsCOMPtr nssComponent(do_GetService(kNSSComponentCID));
-  RefPtr certVerifier;
   if (nssComponent) {
     return nssComponent->GetDefaultCertVerifier();
   }
diff --git a/storage/mozStorageAsyncStatementExecution.cpp b/storage/mozStorageAsyncStatementExecution.cpp
index 62309d3d8312..add32131a308 100644
--- a/storage/mozStorageAsyncStatementExecution.cpp
+++ b/storage/mozStorageAsyncStatementExecution.cpp
@@ -70,10 +70,9 @@ public:
       // Hold a strong reference to the callback while notifying it, so that if
       // it spins the event loop, the callback won't be released and freed out
       // from under us.
-      nsCOMPtr callback =
-        do_QueryInterface(mCallback);
+      nsCOMPtr callback = mCallback;
 
-      (void)mCallback->HandleResult(mResults);
+      (void)callback->HandleResult(mResults);
     }
 
     return NS_OK;
@@ -106,10 +105,9 @@ public:
       // Hold a strong reference to the callback while notifying it, so that if
       // it spins the event loop, the callback won't be released and freed out
       // from under us.
-      nsCOMPtr callback =
-        do_QueryInterface(mCallback);
+      nsCOMPtr callback = mCallback;
 
-      (void)mCallback->HandleError(mErrorObj);
+      (void)callback->HandleError(mErrorObj);
     }
 
     return NS_OK;
diff --git a/testing/mochitest/mochitest_options.py b/testing/mochitest/mochitest_options.py
index fa24952b0879..922ca85d5490 100644
--- a/testing/mochitest/mochitest_options.py
+++ b/testing/mochitest/mochitest_options.py
@@ -777,11 +777,6 @@ class MochitestArguments(ArgumentContainer):
             "geckomediaplugin": 20000,
         }
 
-        # Bug 1293324 - OSX 10.10 sometimes leaks a little more
-        # graphics layers stuff in the content process.
-        if mozinfo.isMac:
-            options.leakThresholds["tab"] = 12000
-
         # XXX We can't normalize test_paths in the non build_obj case here,
         # because testRoot depends on the flavor, which is determined by the
         # mach command and therefore not finalized yet. Conversely, test paths
diff --git a/testing/web-platform/meta/html/semantics/scripting-1/the-script-element/fetch-src/empty-with-base.html.ini b/testing/web-platform/meta/html/semantics/scripting-1/the-script-element/fetch-src/empty-with-base.html.ini
deleted file mode 100644
index 2b03e6988acd..000000000000
--- a/testing/web-platform/meta/html/semantics/scripting-1/the-script-element/fetch-src/empty-with-base.html.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[empty-with-base.html]
-  type: testharness
-  [Script src with an empty URL]
-    expected: FAIL
-
diff --git a/testing/web-platform/meta/html/semantics/scripting-1/the-script-element/fetch-src/empty.html.ini b/testing/web-platform/meta/html/semantics/scripting-1/the-script-element/fetch-src/empty.html.ini
deleted file mode 100644
index 097c7682d532..000000000000
--- a/testing/web-platform/meta/html/semantics/scripting-1/the-script-element/fetch-src/empty.html.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[empty.html]
-  type: testharness
-  [Script src with an empty URL]
-    expected: FAIL
-
diff --git a/testing/web-platform/meta/old-tests/submission/Opera/script_scheduling/137.html.ini b/testing/web-platform/meta/old-tests/submission/Opera/script_scheduling/137.html.ini
deleted file mode 100644
index 2e61359eb169..000000000000
--- a/testing/web-platform/meta/old-tests/submission/Opera/script_scheduling/137.html.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[137.html]
-  type: testharness
-  expected: ERROR
diff --git a/toolkit/components/downloads/ApplicationReputation.cpp b/toolkit/components/downloads/ApplicationReputation.cpp
index 6828bc24b287..351205d31b36 100644
--- a/toolkit/components/downloads/ApplicationReputation.cpp
+++ b/toolkit/components/downloads/ApplicationReputation.cpp
@@ -1271,6 +1271,7 @@ PendingLookup::SendRemoteQueryInternal()
 
   nsCOMPtr httpChannel(do_QueryInterface(mChannel, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
+  mozilla::Unused << httpChannel;
 
   // Upload the protobuf to the application reputation service.
   nsCOMPtr uploadChannel = do_QueryInterface(mChannel, &rv);
diff --git a/toolkit/components/places/nsNavHistoryResult.cpp b/toolkit/components/places/nsNavHistoryResult.cpp
index 2f3d47e5f414..249cd3d525ed 100644
--- a/toolkit/components/places/nsNavHistoryResult.cpp
+++ b/toolkit/components/places/nsNavHistoryResult.cpp
@@ -3014,7 +3014,8 @@ nsNavHistoryQueryResultNode::OnItemMoved(int64_t aFolder,
  */
 NS_IMPL_ISUPPORTS_INHERITED(nsNavHistoryFolderResultNode,
                             nsNavHistoryContainerResultNode,
-                            nsINavHistoryQueryResultNode)
+                            nsINavHistoryQueryResultNode,
+                            mozIStorageStatementCallback)
 
 nsNavHistoryFolderResultNode::nsNavHistoryFolderResultNode(
     const nsACString& aTitle, nsNavHistoryQueryOptions* aOptions,
diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp
index 2322856aa489..40208f68e9d0 100644
--- a/toolkit/components/satchel/nsFormFillController.cpp
+++ b/toolkit/components/satchel/nsFormFillController.cpp
@@ -613,7 +613,6 @@ nsFormFillController::GetInPrivateContext(bool *aInPrivateContext)
   nsCOMPtr element = do_QueryInterface(mFocusedInput);
   element->GetOwnerDocument(getter_AddRefs(inputDoc));
   nsCOMPtr doc = do_QueryInterface(inputDoc);
-  nsCOMPtr docShell = doc->GetDocShell();
   nsCOMPtr loadContext = doc->GetLoadContext();
   *aInPrivateContext = loadContext && loadContext->UsePrivateBrowsing();
   return NS_OK;
diff --git a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
index d6e1f84f718d..674681581992 100644
--- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
+++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
@@ -394,7 +394,6 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, bool aIsLinksOnly,
 
   // ------------ Get ranges ready ----------------
   nsCOMPtr returnRange;
-  nsCOMPtr focusedPS;
   if (NS_FAILED(GetSearchContainers(currentContainer,
                                     (!aIsFirstVisiblePreferred ||
                                      mStartFindRange) ?
@@ -897,7 +896,7 @@ nsTypeAheadFind::RangeStartsInsideLink(nsIDOMRange *aRange,
   // We now have the correct start node for the range
   // Search for links, starting with startNode, and going up parent chain
 
-  nsCOMPtr tag, hrefAtom(NS_Atomize("href"));
+  nsCOMPtr hrefAtom(NS_Atomize("href"));
   nsCOMPtr typeAtom(NS_Atomize("type"));
 
   while (true) {
diff --git a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
index aa4a44d77d83..7dc4224cf9a9 100644
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
@@ -1692,6 +1692,8 @@ nsUrlClassifierDBService::Observe(nsISupports *aSubject, const char *aTopic,
     nsresult rv;
     nsCOMPtr prefs(do_QueryInterface(aSubject, &rv));
     NS_ENSURE_SUCCESS(rv, rv);
+    Unused << prefs;
+
     if (NS_LITERAL_STRING(CHECK_MALWARE_PREF).Equals(aData)) {
       mCheckMalware = Preferences::GetBool(CHECK_MALWARE_PREF,
         CHECK_MALWARE_DEFAULT);
diff --git a/toolkit/crashreporter/test/unit/test_crash_rust_panic.js b/toolkit/crashreporter/test/unit/test_crash_rust_panic.js
new file mode 100644
index 000000000000..84ed638ae0f8
--- /dev/null
+++ b/toolkit/crashreporter/test/unit/test_crash_rust_panic.js
@@ -0,0 +1,12 @@
+function run_test()
+{
+  // Try crashing with a Rust panic
+  do_crash(function() {
+             Components.classes["@mozilla.org/xpcom/debug;1"].getService(Components.interfaces.nsIDebug2).rustPanic("OH NO");
+           },
+           function(mdump, extra) {
+             //TODO: check some extra things?
+           },
+          // process will exit with a zero exit status
+          true);
+}
diff --git a/toolkit/crashreporter/test/unit/xpcshell.ini b/toolkit/crashreporter/test/unit/xpcshell.ini
index 00fe74692cd5..ae8622e9b5c3 100644
--- a/toolkit/crashreporter/test/unit/xpcshell.ini
+++ b/toolkit/crashreporter/test/unit/xpcshell.ini
@@ -9,6 +9,8 @@ support-files =
 [test_crash_moz_crash.js]
 [test_crash_purevirtual.js]
 [test_crash_runtimeabort.js]
+[test_crash_rust_panic.js]
+skip-if = !rust
 [test_crash_after_js_oom_reported.js]
 [test_crash_after_js_oom_recovered.js]
 [test_crash_after_js_oom_reported_2.js]
diff --git a/toolkit/library/rust/lib.rs b/toolkit/library/rust/lib.rs
index 5f5141050e95..e7697d8f3808 100644
--- a/toolkit/library/rust/lib.rs
+++ b/toolkit/library/rust/lib.rs
@@ -3,3 +3,12 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 extern crate mp4parse_capi;
+
+use std::ffi::CStr;
+use std::os::raw::c_char;
+
+/// Used to implement `nsIDebug2::RustPanic` for testing purposes.
+#[no_mangle]
+pub extern fn intentional_panic(message: *const c_char) {
+    panic!("{}", unsafe { CStr::from_ptr(message) }.to_string_lossy());
+}
diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
index f2185a10f9b4..bb5c4cd51831 100644
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -1428,9 +1428,11 @@ ScopedXPCOMStartup::Initialize()
     mServiceManager = nullptr;
   }
   else {
+#ifdef DEBUG
     nsCOMPtr reg =
       do_QueryInterface(mServiceManager);
     NS_ASSERTION(reg, "Service Manager doesn't QI to Registrar.");
+#endif
   }
 
   return rv;
diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp
index edd9305d6620..44cf297cc89a 100644
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -942,7 +942,6 @@ int64_t nsDocLoader::GetMaxTotalProgress()
   int64_t newMaxTotal = 0;
 
   uint32_t count = mChildList.Length();
-  nsCOMPtr webProgress;
   for (uint32_t i=0; i < count; i++)
   {
     int64_t individualProgress = 0;
diff --git a/uriloader/base/nsURILoader.cpp b/uriloader/base/nsURILoader.cpp
index 7c1da6e99e7a..30cb16e97eb6 100644
--- a/uriloader/base/nsURILoader.cpp
+++ b/uriloader/base/nsURILoader.cpp
@@ -384,8 +384,6 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
 
   LOG(("  forceExternalHandling: %s", forceExternalHandling ? "yes" : "no"));
 
-  // We're going to try to find a contentListener that can handle our data
-  nsCOMPtr contentListener;
   // The type or data the contentListener wants.
   nsXPIDLCString desiredContentType;
 
diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp
index 8c3bf85c8fc9..bbe5524b1f3f 100644
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -2306,11 +2306,11 @@ void nsExternalAppHandler::RequestSaveDestination(const nsAFlatString &aDefaultF
   RefPtr kungFuDeathGrip(this);
   nsCOMPtr dlg(mDialog);
 
-  rv = mDialog->PromptForSaveToFileAsync(this,
-                                         GetDialogParent(),
-                                         aDefaultFile.get(),
-                                         aFileExtension.get(),
-                                         mForceSave);
+  rv = dlg->PromptForSaveToFileAsync(this,
+                                     GetDialogParent(),
+                                     aDefaultFile.get(),
+                                     aFileExtension.get(),
+                                     mForceSave);
   if (NS_FAILED(rv)) {
     Cancel(NS_BINDING_ABORTED);
   }
@@ -2863,7 +2863,6 @@ NS_IMETHODIMP nsExternalHelperAppService::GetTypeFromFile(nsIFile* aFile, nsACSt
 {
   NS_ENSURE_ARG_POINTER(aFile);
   nsresult rv;
-  nsCOMPtr info;
 
   // Get the Extension
   nsAutoString fileName;
diff --git a/uriloader/prefetch/nsOfflineCacheUpdate.cpp b/uriloader/prefetch/nsOfflineCacheUpdate.cpp
index affbd9782ea6..4b6cd4d0cf0c 100644
--- a/uriloader/prefetch/nsOfflineCacheUpdate.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdate.cpp
@@ -1759,8 +1759,6 @@ nsOfflineCacheUpdate::Begin()
     }
 
     // Start checking the manifest.
-    nsCOMPtr uri;
-
     mManifestItem = new nsOfflineManifestItem(mManifestURI,
                                               mDocumentURI,
                                               mLoadingPrincipal,
diff --git a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
index 5587894deaf1..adb3fd5160a4 100644
--- a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
@@ -380,6 +380,7 @@ nsOfflineCacheUpdateService::UpdateFinished(nsOfflineCacheUpdate *aUpdate)
 
     // keep this item alive until we're done notifying observers
     RefPtr update = mUpdates[0];
+    Unused << update;
     mUpdates.RemoveElementAt(0);
     mUpdateRunning = false;
 
diff --git a/uriloader/prefetch/nsPrefetchService.cpp b/uriloader/prefetch/nsPrefetchService.cpp
index 078fb4cafd1c..7a94313ebb8a 100644
--- a/uriloader/prefetch/nsPrefetchService.cpp
+++ b/uriloader/prefetch/nsPrefetchService.cpp
@@ -411,7 +411,6 @@ void
 nsPrefetchService::ProcessNextURI(nsPrefetchNode *aFinished)
 {
     nsresult rv;
-    nsCOMPtr uri, referrer;
 
     if (aFinished) {
         mCurrentNodes.RemoveElement(aFinished);
diff --git a/widget/cocoa/TextInputHandler.mm b/widget/cocoa/TextInputHandler.mm
index 9ee777a6c22a..d4afcf29f512 100644
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -1534,7 +1534,7 @@ TextInputHandler::HandleKeyDownEvent(NSEvent* aNativeEvent)
     [NSCursor setHiddenUntilMouseMoves:YES];
   }
 
-  RefPtr kungFuDeathGrip(mWidget);
+  RefPtr widget(mWidget);
 
   KeyEventState* currentKeyEvent = PushKeyEvent(aNativeEvent);
   AutoKeyEventStateCleaner remover(this);
@@ -1553,7 +1553,7 @@ TextInputHandler::HandleKeyDownEvent(NSEvent* aNativeEvent)
         return false;
       }
 
-      WidgetKeyboardEvent imeEvent(true, eKeyDown, mWidget);
+      WidgetKeyboardEvent imeEvent(true, eKeyDown, widget);
       currentKeyEvent->InitKeyEvent(this, imeEvent);
       imeEvent.mPluginTextEventString.Assign(committed);
       nsEventStatus status = nsEventStatus_eIgnore;
@@ -1574,7 +1574,7 @@ TextInputHandler::HandleKeyDownEvent(NSEvent* aNativeEvent)
     return false;
   }
 
-  WidgetKeyboardEvent keydownEvent(true, eKeyDown, mWidget);
+  WidgetKeyboardEvent keydownEvent(true, eKeyDown, widget);
   currentKeyEvent->InitKeyEvent(this, keydownEvent);
 
   nsEventStatus status = nsEventStatus_eIgnore;
@@ -1613,7 +1613,7 @@ TextInputHandler::HandleKeyDownEvent(NSEvent* aNativeEvent)
   // Don't call interpretKeyEvents when a plugin has focus.  If we call it,
   // for example, a character is inputted twice during a composition in e10s
   // mode.
-  if (!mWidget->IsPluginFocused() && (IsIMEEnabled() || IsASCIICapableOnly())) {
+  if (!widget->IsPluginFocused() && (IsIMEEnabled() || IsASCIICapableOnly())) {
     MOZ_LOG(gLog, LogLevel::Info,
       ("%p TextInputHandler::HandleKeyDownEvent, calling interpretKeyEvents",
        this));
@@ -1647,7 +1647,7 @@ TextInputHandler::HandleKeyDownEvent(NSEvent* aNativeEvent)
       return false;
     }
 
-    WidgetKeyboardEvent keypressEvent(true, eKeyPress, mWidget);
+    WidgetKeyboardEvent keypressEvent(true, eKeyPress, widget);
     currentKeyEvent->InitKeyEvent(this, keypressEvent);
 
     // If we called interpretKeyEvents and this isn't normal character input
@@ -1743,6 +1743,7 @@ TextInputHandler::HandleFlagsChanged(NSEvent* aNativeEvent)
   }
 
   RefPtr kungFuDeathGrip(mWidget);
+  mozilla::Unused << kungFuDeathGrip; // Not referenced within this function
 
   MOZ_LOG(gLog, LogLevel::Info,
     ("%p TextInputHandler::HandleFlagsChanged, aNativeEvent=%p, "
@@ -2195,7 +2196,7 @@ TextInputHandler::InsertText(NSAttributedString* aAttrString,
     return;
   }
 
-  RefPtr kungFuDeathGrip(mWidget);
+  RefPtr widget(mWidget);
 
   // If the replacement range is specified, select the range.  Then, the
   // selection will be replaced by the later keypress event.
@@ -2214,7 +2215,7 @@ TextInputHandler::InsertText(NSAttributedString* aAttrString,
   }
 
   // Dispatch keypress event with char instead of compositionchange event
-  WidgetKeyboardEvent keypressEvent(true, eKeyPress, mWidget);
+  WidgetKeyboardEvent keypressEvent(true, eKeyPress, widget);
   // XXX Why do we need to dispatch keypress event for not inputting any
   //     string?  If it wants to delete the specified range, should we
   //     dispatch an eContentCommandDelete event instead?  Because this
@@ -2263,7 +2264,7 @@ TextInputHandler::InsertText(NSAttributedString* aAttrString,
 bool
 TextInputHandler::DoCommandBySelector(const char* aSelector)
 {
-  RefPtr kungFuDeathGrip(mWidget);
+  RefPtr widget(mWidget);
 
   KeyEventState* currentKeyEvent = GetCurrentKeyEvent();
 
@@ -2289,7 +2290,7 @@ TextInputHandler::DoCommandBySelector(const char* aSelector)
       return false;
     }
 
-    WidgetKeyboardEvent keypressEvent(true, eKeyPress, mWidget);
+    WidgetKeyboardEvent keypressEvent(true, eKeyPress, widget);
     currentKeyEvent->InitKeyEvent(this, keypressEvent);
 
     nsEventStatus status = nsEventStatus_eIgnore;
diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm
index edc4b7dffc3e..d46f564f25c5 100644
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1406,6 +1406,8 @@ nsresult nsChildView::ConfigureChildren(const nsTArray& aConfigur
 NS_IMETHODIMP nsChildView::DispatchEvent(WidgetGUIEvent* event,
                                          nsEventStatus& aStatus)
 {
+  RefPtr kungFuDeathGrip(this);
+
 #ifdef DEBUG
   debug_DumpEvent(stdout, event->mWidget, event, "something", 0);
 #endif
@@ -1429,16 +1431,16 @@ NS_IMETHODIMP nsChildView::DispatchEvent(WidgetGUIEvent* event,
   // If the listener is NULL, check if the parent is a popup. If it is, then
   // this child is the popup content view attached to a popup. Get the
   // listener from the parent popup instead.
-  nsCOMPtr kungFuDeathGrip = do_QueryInterface(mParentWidget ? mParentWidget : this);
-  if (!listener && mParentWidget) {
-    if (mParentWidget->WindowType() == eWindowType_popup) {
+  nsCOMPtr parentWidget = mParentWidget;
+  if (!listener && parentWidget) {
+    if (parentWidget->WindowType() == eWindowType_popup) {
       // Check just in case event->mWidget isn't this widget
       if (event->mWidget) {
         listener = event->mWidget->GetWidgetListener();
       }
       if (!listener) {
-        event->mWidget = mParentWidget;
-        listener = mParentWidget->GetWidgetListener();
+        event->mWidget = parentWidget;
+        listener = parentWidget->GetWidgetListener();
       }
     }
   }
@@ -6066,8 +6068,8 @@ nsChildView::GetSelectionAsPlaintext(nsAString& aResult)
   id nativeAccessible = nil;
 
   nsAutoRetainCocoaObject kungFuDeathGrip(self);
-  nsCOMPtr kungFuDeathGrip2(mGeckoChild);
-  RefPtr accessible = mGeckoChild->GetDocumentAccessible();
+  RefPtr geckoChild(mGeckoChild);
+  RefPtr accessible = geckoChild->GetDocumentAccessible();
   if (!accessible)
     return nil;
 
diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm
index 6da31fdc8cbe..63538cf0dc38 100644
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -1886,6 +1886,7 @@ nsCocoaWindow::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus)
   aStatus = nsEventStatus_eIgnore;
 
   nsCOMPtr kungFuDeathGrip(event->mWidget);
+  mozilla::Unused << kungFuDeathGrip; // Not used within this function
 
   if (mWidgetListener)
     aStatus = mWidgetListener->HandleEvent(event, mUseAttachedEvents);
diff --git a/widget/cocoa/nsMenuX.mm b/widget/cocoa/nsMenuX.mm
index dfa1a4a6b6d5..757221eac638 100644
--- a/widget/cocoa/nsMenuX.mm
+++ b/widget/cocoa/nsMenuX.mm
@@ -421,7 +421,6 @@ void nsMenuX::MenuConstruct()
       if (ownerDoc && jsapi.Init(ownerDoc->GetInnerWindow())) {
         JSContext* cx = jsapi.cx();
         JS::RootedObject ignoredObj(cx);
-        nsCOMPtr wrapper;
         xpconnect->WrapNative(cx, JS::CurrentGlobalOrNull(cx), menuPopup,
                               NS_GET_IID(nsISupports), ignoredObj.address());
         mXBLAttached = true;
diff --git a/widget/gtk/IMContextWrapper.cpp b/widget/gtk/IMContextWrapper.cpp
index 94ffa764771f..a90f52711ae3 100644
--- a/widget/gtk/IMContextWrapper.cpp
+++ b/widget/gtk/IMContextWrapper.cpp
@@ -1336,6 +1336,9 @@ IMContextWrapper::DispatchCompositionStart(GtkIMContext* aContext)
         return false;
     }
 
+    // Keep the last focused window alive
+    RefPtr lastFocusedWindow(mLastFocusedWindow);
+
     // XXX The composition start point might be changed by composition events
     //     even though we strongly hope it doesn't happen.
     //     Every composition event should have the start offset for the result
@@ -1347,7 +1350,6 @@ IMContextWrapper::DispatchCompositionStart(GtkIMContext* aContext)
         mProcessingKeyEvent->type == GDK_KEY_PRESS) {
         // If this composition is started by a native keydown event, we need to
         // dispatch our keydown event here (before composition start).
-        nsCOMPtr kungFuDeathGrip = mLastFocusedWindow;
         bool isCancelled;
         mLastFocusedWindow->DispatchKeyDownEvent(mProcessingKeyEvent,
                                                  &isCancelled);
@@ -1355,8 +1357,8 @@ IMContextWrapper::DispatchCompositionStart(GtkIMContext* aContext)
             ("0x%p   DispatchCompositionStart(), FAILED, keydown event "
              "is dispatched",
              this));
-        if (static_cast(kungFuDeathGrip.get())->IsDestroyed() ||
-            kungFuDeathGrip != mLastFocusedWindow) {
+        if (lastFocusedWindow->IsDestroyed() ||
+            lastFocusedWindow != mLastFocusedWindow) {
             MOZ_LOG(gGtkIMLog, LogLevel::Error,
                 ("0x%p   DispatchCompositionStart(), FAILED, the focused "
                  "widget was destroyed/changed by keydown event",
@@ -1381,7 +1383,6 @@ IMContextWrapper::DispatchCompositionStart(GtkIMContext* aContext)
          this, mCompositionStart));
     mCompositionState = eCompositionState_CompositionStartDispatched;
     nsEventStatus status;
-    RefPtr lastFocusedWindow = mLastFocusedWindow;
     dispatcher->StartComposition(status);
     if (lastFocusedWindow->IsDestroyed() ||
         lastFocusedWindow != mLastFocusedWindow) {
@@ -1417,7 +1418,6 @@ IMContextWrapper::DispatchCompositionChangeEvent(
             ("0x%p   DispatchCompositionChangeEvent(), the composition "
              "wasn't started, force starting...",
              this));
-        nsCOMPtr kungFuDeathGrip = mLastFocusedWindow;
         if (!DispatchCompositionStart(aContext)) {
             return false;
         }
@@ -1522,7 +1522,6 @@ IMContextWrapper::DispatchCompositionCommitEvent(
             ("0x%p   DispatchCompositionCommitEvent(), "
              "the composition wasn't started, force starting...",
              this));
-        nsCOMPtr kungFuDeathGrip(mLastFocusedWindow);
         if (!DispatchCompositionStart(aContext)) {
             return false;
         }
diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp
index 7bbd52587fdb..cf41aa40cad7 100644
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -219,8 +219,8 @@ WidgetShutdownObserver::Observe(nsISupports *aSubject,
                                 const char16_t *aData)
 {
   if (mWidget && !strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
-    nsCOMPtr kungFuDeathGrip(mWidget);
-    mWidget->Shutdown();
+    RefPtr widget(mWidget);
+    widget->Shutdown();
   }
   return NS_OK;
 }
diff --git a/xpcom/base/moz.build b/xpcom/base/moz.build
index 26409f1390ba..e9ae19d153e7 100644
--- a/xpcom/base/moz.build
+++ b/xpcom/base/moz.build
@@ -157,3 +157,6 @@ LOCAL_INCLUDES += [
 
 if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
     CXXFLAGS += CONFIG['TK_CFLAGS']
+
+if CONFIG['MOZ_RUST']:
+    DEFINES['MOZ_RUST'] = True
diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp
index 36288d2037ac..019a6bba1c3d 100644
--- a/xpcom/base/nsDebugImpl.cpp
+++ b/xpcom/base/nsDebugImpl.cpp
@@ -147,6 +147,22 @@ nsDebugImpl::Abort(const char* aFile, int32_t aLine)
   return NS_OK;
 }
 
+#ifdef MOZ_RUST
+// From toolkit/library/rust/lib.rs
+extern "C" void intentional_panic(const char* message);
+#endif
+
+NS_IMETHODIMP
+nsDebugImpl::RustPanic(const char* aMessage)
+{
+#ifdef MOZ_RUST
+  intentional_panic(aMessage);
+  return NS_OK;
+#else
+  return NS_ERROR_NOT_IMPLEMENTED;
+#endif
+}
+
 NS_IMETHODIMP
 nsDebugImpl::GetIsDebugBuild(bool* aResult)
 {
diff --git a/xpcom/base/nsIDebug2.idl b/xpcom/base/nsIDebug2.idl
index 4401f8a917af..1fa69190c8d1 100644
--- a/xpcom/base/nsIDebug2.idl
+++ b/xpcom/base/nsIDebug2.idl
@@ -79,4 +79,11 @@ interface nsIDebug2 : nsISupports
      */
     void abort(in string aFile, 
                in long aLine);
+
+    /**
+     * Request the process to trigger a fatal panic!() from Rust code.
+     *
+     * @param aMessage the string to pass to panic!().
+     */
+    void rustPanic(in string aMessage);
 };
diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp
index c93dee217869..b9eb8e275f49 100644
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -1987,7 +1987,6 @@ nsComponentManagerImpl::RemoveBootstrappedManifestLocation(nsIFile* aLocation)
     return NS_ERROR_FAILURE;
   }
 
-  nsCOMPtr manifest;
   nsString path;
   nsresult rv = aLocation->GetPath(path);
   if (NS_FAILED(rv)) {
diff --git a/xpcom/tests/TestCOMPtr.cpp b/xpcom/tests/TestCOMPtr.cpp
index bedcd43b62bc..a80572551a55 100644
--- a/xpcom/tests/TestCOMPtr.cpp
+++ b/xpcom/tests/TestCOMPtr.cpp
@@ -7,6 +7,7 @@
 #include 
 #include "nsCOMPtr.h"
 #include "nsISupports.h"
+#include "mozilla/Unused.h"
 
 #define NS_IFOO_IID \
 { 0x6f7652e0,  0xee43, 0x11d1, \
@@ -360,6 +361,7 @@ main()
     {
       printf("\n### Test  6: will a |nsCOMPtr| call the correct destructor?\n");
       nsCOMPtr foop( do_QueryInterface(new IBar) );
+      mozilla::Unused << foop;
     }
 
     {
diff --git a/xpcom/tests/TestNsRefPtr.cpp b/xpcom/tests/TestNsRefPtr.cpp
index 5c0fa7bfe168..29ae09314f2f 100644
--- a/xpcom/tests/TestNsRefPtr.cpp
+++ b/xpcom/tests/TestNsRefPtr.cpp
@@ -9,6 +9,7 @@
 #include "nsAutoPtr.h"
 #include "nsISupports.h"
 #include "nsQueryObject.h"
+#include "mozilla/Unused.h"
 
 #define NS_FOO_IID \
 { 0x6f7652e0,  0xee43, 0x11d1, \
@@ -431,6 +432,7 @@ main()
     {
       printf("\n### Test  6: will a |nsCOMPtr| call the correct destructor?\n");
       RefPtr foop( do_QueryObject(new Bar) );
+      mozilla::Unused << foop;
     }
 
     {