Bug 1193762 part 8 - Fix things that will break; r=froydnj
authorAryeh Gregor <ayg@aryeh.name>
Sun, 01 May 2016 21:29:23 +0300
changeset 295684 c01fbb04e9a885c35ba47532e17e0eab9d73fdc7
parent 295683 5c6e39260feb78127f51cc66a5ac19b568c39f30
child 295685 a0daadf6943ce11e9858cdcb7aacfd63dfc0ce39
push id19015
push usercbook@mozilla.com
push dateMon, 02 May 2016 09:39:23 +0000
treeherderfx-team@2080375bc69d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1193762
milestone49.0a1
Bug 1193762 part 8 - Fix things that will break; r=froydnj It looks like VC++ doesn't like comparisons of nsCOMPtr to 0 after this change, but those are bad style anyway, so I removed them from TestCOMPtr.cpp instead of trying to make them work.
dom/base/nsFrameLoader.cpp
dom/base/nsGlobalWindow.cpp
dom/canvas/OffscreenCanvas.cpp
dom/html/HTMLMediaElement.cpp
dom/plugins/base/nsPluginHost.cpp
dom/plugins/base/nsPluginStreamListenerPeer.cpp
dom/security/nsCSPParser.cpp
editor/libeditor/nsHTMLAnonymousUtils.cpp
editor/libeditor/nsHTMLEditor.cpp
editor/libeditor/nsWSRunObject.cpp
editor/libeditor/nsWSRunObject.h
gfx/layers/apz/util/ActiveElementManager.cpp
gfx/layers/apz/util/ActiveElementManager.h
layout/base/nsDocumentViewer.cpp
media/mtransport/test/mtransport_test_utils.h
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
xpcom/tests/TestCOMPtr.cpp
xpcom/tests/TestRegistrationOrder.cpp
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -1343,19 +1343,19 @@ nsFrameLoader::SwapWithOtherLoader(nsFra
   otherParentItem->AddChild(ourDocshell);
 
   // Restore the correct chrome event handlers.
   ourDocshell->SetChromeEventHandler(otherChromeEventHandler);
   otherDocshell->SetChromeEventHandler(ourChromeEventHandler);
   // Restore the correct treeowners
   // (and also chrome event handlers for content frames only).
   SetTreeOwnerAndChromeEventHandlerOnDocshellTree(ourDocshell, otherOwner,
-    ourType == nsIDocShellTreeItem::typeContent ? otherChromeEventHandler : nullptr);
+    ourType == nsIDocShellTreeItem::typeContent ? otherChromeEventHandler.get() : nullptr);
   SetTreeOwnerAndChromeEventHandlerOnDocshellTree(otherDocshell, ourOwner,
-    ourType == nsIDocShellTreeItem::typeContent ? ourChromeEventHandler : nullptr);
+    ourType == nsIDocShellTreeItem::typeContent ? ourChromeEventHandler.get() : nullptr);
 
   // Switch the owner content before we start calling AddTreeItemToTreeOwner.
   // Note that we rely on this to deal with setting mObservingOwnerContent to
   // false and calling RemoveMutationObserver as needed.
   SetOwnerContent(otherContent);
   aOther->SetOwnerContent(ourContent);
 
   AddTreeItemToTreeOwner(ourDocshell, otherOwner, otherParentType, nullptr);
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -7077,17 +7077,17 @@ nsGlobalWindow::PrintOuter(ErrorResult& 
     aError.Throw(NS_ERROR_NOT_AVAILABLE);
     return;
   }
 
   nsCOMPtr<nsIWebBrowserPrint> webBrowserPrint;
   if (NS_SUCCEEDED(GetInterface(NS_GET_IID(nsIWebBrowserPrint),
                                 getter_AddRefs(webBrowserPrint)))) {
     nsAutoSyncOperation sync(GetCurrentInnerWindowInternal() ?
-                               GetCurrentInnerWindowInternal()->mDoc :
+                               GetCurrentInnerWindowInternal()->mDoc.get() :
                                nullptr);
 
     nsCOMPtr<nsIPrintSettingsService> printSettingsService =
       do_GetService("@mozilla.org/gfx/printsettings-service;1");
 
     nsCOMPtr<nsIPrintSettings> printSettings;
     if (printSettingsService) {
       bool printSettingsAreGlobal =
--- a/dom/canvas/OffscreenCanvas.cpp
+++ b/dom/canvas/OffscreenCanvas.cpp
@@ -217,17 +217,18 @@ OffscreenCanvas::ToCloneData()
   return new OffscreenCanvasCloneData(mCanvasRenderer, mWidth, mHeight,
                                       mCompositorBackendType, mNeutered, mIsWriteOnly);
 }
 
 already_AddRefed<ImageBitmap>
 OffscreenCanvas::TransferToImageBitmap()
 {
   ErrorResult rv;
-  RefPtr<ImageBitmap> result = ImageBitmap::CreateFromOffscreenCanvas(GetGlobalObject(), *this, rv);
+  nsCOMPtr<nsIGlobalObject> globalObject = GetGlobalObject();
+  RefPtr<ImageBitmap> result = ImageBitmap::CreateFromOffscreenCanvas(globalObject, *this, rv);
 
   // Clear the content.
   if ((mCurrentContextType == CanvasContextType::WebGL1 ||
        mCurrentContextType == CanvasContextType::WebGL2))
   {
     WebGLContext* webGL = static_cast<WebGLContext*>(mCurrentContext.get());
     webGL->ClearScreen();
   }
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1902,17 +1902,17 @@ class HTMLMediaElement::CaptureStreamTra
   public DecoderPrincipalChangeObserver
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CaptureStreamTrackSource,
                                            MediaStreamTrackSource)
 
   explicit CaptureStreamTrackSource(HTMLMediaElement* aElement)
-    : MediaStreamTrackSource(nsCOMPtr<nsIPrincipal>(aElement->GetCurrentPrincipal()),
+    : MediaStreamTrackSource(nsCOMPtr<nsIPrincipal>(aElement->GetCurrentPrincipal()).get(),
                              true,
                              nsString())
     , mElement(aElement)
   {
     MOZ_ASSERT(mElement);
     mElement->AddDecoderPrincipalChangeObserver(this);
   }
 
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -3373,17 +3373,18 @@ nsresult nsPluginHost::NewPluginURLStrea
 
   if (aURL.Length() <= 0)
     return NS_OK;
 
   // get the base URI for the plugin to create an absolute url
   // in case aURL is relative
   RefPtr<nsPluginInstanceOwner> owner = aInstance->GetOwner();
   if (owner) {
-    rv = NS_MakeAbsoluteURI(absUrl, aURL, nsCOMPtr<nsIURI>(owner->GetBaseURI()));
+    nsCOMPtr<nsIURI> baseURI = owner->GetBaseURI();
+    rv = NS_MakeAbsoluteURI(absUrl, aURL, baseURI);
   }
 
   if (absUrl.IsEmpty())
     absUrl.Assign(aURL);
 
   rv = NS_NewURI(getter_AddRefs(url), absUrl);
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/dom/plugins/base/nsPluginStreamListenerPeer.cpp
+++ b/dom/plugins/base/nsPluginStreamListenerPeer.cpp
@@ -99,17 +99,20 @@ nsPluginByteRangeStreamListener::OnStart
 
   nsCOMPtr<nsIStreamListener> finalStreamListener = do_QueryReferent(mWeakPtrPluginStreamListenerPeer);
   if (!finalStreamListener)
     return NS_ERROR_FAILURE;
 
   nsPluginStreamListenerPeer *pslp =
     static_cast<nsPluginStreamListenerPeer*>(finalStreamListener.get());
 
-  NS_ASSERTION(pslp->mRequests.IndexOfObject(GetBaseRequest(request)) != -1,
+#ifdef DEBUG
+  nsCOMPtr<nsIRequest> baseRequest = GetBaseRequest(request);
+#endif
+  NS_ASSERTION(pslp->mRequests.IndexOfObject(baseRequest) != -1,
                "Untracked byte-range request?");
 
   nsCOMPtr<nsIStreamConverterService> serv = do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID, &rv);
   if (NS_SUCCEEDED(rv)) {
     rv = serv->AsyncConvertData(MULTIPART_BYTERANGES,
                                 "*/*",
                                 finalStreamListener,
                                 nullptr,
@@ -426,17 +429,18 @@ nsPluginStreamListenerPeer::SetupPluginC
 NS_IMETHODIMP
 nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request,
                                            nsISupports* aContext)
 {
   nsresult rv = NS_OK;
   PROFILER_LABEL("nsPluginStreamListenerPeer", "OnStartRequest",
     js::ProfileEntry::Category::OTHER);
 
-  if (mRequests.IndexOfObject(GetBaseRequest(request)) == -1) {
+  nsCOMPtr<nsIRequest> baseRequest = GetBaseRequest(request);
+  if (mRequests.IndexOfObject(baseRequest) == -1) {
     NS_ASSERTION(mRequests.Count() == 0,
                  "Only our initial stream should be unknown!");
     TrackRequest(request);
   }
 
   if (mHaveFiredOnStartRequest) {
     return NS_OK;
   }
@@ -883,17 +887,18 @@ nsPluginStreamListenerPeer::UseExistingP
 }
 
 NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request,
                                                           nsISupports* aContext,
                                                           nsIInputStream *aIStream,
                                                           uint64_t sourceOffset,
                                                           uint32_t aLength)
 {
-  if (mRequests.IndexOfObject(GetBaseRequest(request)) == -1) {
+  nsCOMPtr<nsIRequest> baseRequest = GetBaseRequest(request);
+  if (mRequests.IndexOfObject(baseRequest) == -1) {
     MOZ_ASSERT(false, "Received OnDataAvailable for untracked request.");
     return NS_ERROR_UNEXPECTED;
   }
 
   if (mRequestFailed)
     return NS_ERROR_FAILURE;
 
   if (mAbort) {
--- a/dom/security/nsCSPParser.cpp
+++ b/dom/security/nsCSPParser.cpp
@@ -573,17 +573,18 @@ nsCSPParser::keywordSource()
 
   // Special case handling for 'self' which is not stored internally as a keyword,
   // but rather creates a nsCSPHostSrc using the selfURI
   if (CSP_IsKeyword(mCurToken, CSP_SELF)) {
     return CSP_CreateHostSrcFromURI(mSelfURI);
   }
 
   if (CSP_IsKeyword(mCurToken, CSP_UNSAFE_INLINE)) {
-      nsCOMPtr<nsIDocument> doc = do_QueryReferent(mCSPContext->GetLoadingContext());
+      nsWeakPtr ctx = mCSPContext->GetLoadingContext();
+      nsCOMPtr<nsIDocument> doc = do_QueryReferent(ctx);
       if (doc) {
         doc->SetHasUnsafeInlineCSP(true);
       }
     // make sure script-src only contains 'unsafe-inline' once;
     // ignore duplicates and log warning
     if (mUnsafeInlineKeywordSrc) {
       const char16_t* params[] = { mCurToken.get() };
       logWarningErrorToConsole(nsIScriptError::warningFlag, "ignoringDuplicateSrc",
@@ -592,17 +593,18 @@ nsCSPParser::keywordSource()
     }
     // cache if we encounter 'unsafe-inline' so we can invalidate (ignore) it in
     // case that script-src directive also contains hash- or nonce-.
     mUnsafeInlineKeywordSrc = new nsCSPKeywordSrc(CSP_KeywordToEnum(mCurToken));
     return mUnsafeInlineKeywordSrc;
   }
 
   if (CSP_IsKeyword(mCurToken, CSP_UNSAFE_EVAL)) {
-    nsCOMPtr<nsIDocument> doc = do_QueryReferent(mCSPContext->GetLoadingContext());
+    nsWeakPtr ctx = mCSPContext->GetLoadingContext();
+    nsCOMPtr<nsIDocument> doc = do_QueryReferent(ctx);
     if (doc) {
       doc->SetHasUnsafeEvalCSP(true);
     }
     return new nsCSPKeywordSrc(CSP_KeywordToEnum(mCurToken));
   }
   return nullptr;
 }
 
--- a/editor/libeditor/nsHTMLAnonymousUtils.cpp
+++ b/editor/libeditor/nsHTMLAnonymousUtils.cpp
@@ -143,18 +143,18 @@ nsHTMLEditor::CreateAnonymousElement(con
   nsCOMPtr<nsIDocument> doc = GetDocument();
   NS_ENSURE_TRUE(doc, NS_ERROR_NULL_POINTER);
 
   // Get the pres shell
   nsCOMPtr<nsIPresShell> ps = GetPresShell();
   NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
 
   // Create a new node through the element factory
-  nsCOMPtr<Element> newContent =
-    CreateHTMLContent(nsCOMPtr<nsIAtom>(NS_Atomize(aTag)));
+  nsCOMPtr<nsIAtom> tagAtom = NS_Atomize(aTag);
+  nsCOMPtr<Element> newContent = CreateHTMLContent(tagAtom);
   NS_ENSURE_STATE(newContent);
 
   nsCOMPtr<nsIDOMElement> newElement = do_QueryInterface(newContent);
   NS_ENSURE_TRUE(newElement, NS_ERROR_FAILURE);
 
   // add the "hidden" class if needed
   nsresult res;
   if (aIsCreatedHidden) {
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/nsHTMLEditor.cpp
@@ -2546,18 +2546,18 @@ nsHTMLEditor::CreateElementWithDefaults(
     realTagName.Assign('a');
   } else {
     realTagName = tagName;
   }
   // We don't use editor's CreateElement because we don't want to go through
   // the transaction system
 
   // New call to use instead to get proper HTML element, bug 39919
-  nsCOMPtr<Element> newElement =
-    CreateHTMLContent(nsCOMPtr<nsIAtom>(NS_Atomize(realTagName)));
+  nsCOMPtr<nsIAtom> realTagAtom = NS_Atomize(realTagName);
+  nsCOMPtr<Element> newElement = CreateHTMLContent(realTagAtom);
   if (!newElement) {
     return nullptr;
   }
 
   // Mark the new element dirty, so it will be formatted
   ErrorResult rv;
   newElement->SetAttribute(NS_LITERAL_STRING("_moz_dirty"), EmptyString(), rv);
 
--- a/editor/libeditor/nsWSRunObject.cpp
+++ b/editor/libeditor/nsWSRunObject.cpp
@@ -597,29 +597,29 @@ nsWSRunObject::AdjustWhitespace()
   return res;
 }
 
 
 //--------------------------------------------------------------------------------------------
 //   protected methods
 //--------------------------------------------------------------------------------------------
 
-already_AddRefed<nsINode>
+nsINode*
 nsWSRunObject::GetWSBoundingParent()
 {
   NS_ENSURE_TRUE(mNode, nullptr);
   OwningNonNull<nsINode> wsBoundingParent = *mNode;
   while (!IsBlockNode(wsBoundingParent)) {
     nsCOMPtr<nsINode> parent = wsBoundingParent->GetParentNode();
     if (!parent || !mHTMLEditor->IsEditable(parent)) {
       break;
     }
     wsBoundingParent = parent;
   }
-  return wsBoundingParent.forget();
+  return wsBoundingParent;
 }
 
 nsresult
 nsWSRunObject::GetWSNodes()
 {
   // collect up an array of nodes that are contiguous with the insertion point
   // and which contain only whitespace.  Stop if you reach non-ws text or a new
   // block boundary.
@@ -1758,17 +1758,17 @@ nsWSRunObject::CheckTrailingNBSPOfRun(WS
       // now check that what is to the right of it is compatible with replacing
       // nbsp with space
       if (aRun->mRightType == WSType::text ||
           aRun->mRightType == WSType::special ||
           aRun->mRightType == WSType::br) {
         rightCheck = true;
       }
       if ((aRun->mRightType & WSType::block) &&
-          IsBlockNode(nsCOMPtr<nsINode>(GetWSBoundingParent()))) {
+          IsBlockNode(GetWSBoundingParent())) {
         // We are at a block boundary.  Insert a <br>.  Why?  Well, first note
         // that the br will have no visible effect since it is up against a
         // block boundary.  |foo<br><p>bar| renders like |foo<p>bar| and
         // similarly |<p>foo<br></p>bar| renders like |<p>foo</p>bar|.  What
         // this <br> addition gets us is the ability to convert a trailing nbsp
         // to a space.  Consider: |<body>foo. '</body>|, where ' represents
         // selection.  User types space attempting to put 2 spaces after the
         // end of their sentence.  We used to do this as: |<body>foo.
--- a/editor/libeditor/nsWSRunObject.h
+++ b/editor/libeditor/nsWSRunObject.h
@@ -299,17 +299,17 @@ class MOZ_STACK_CLASS nsWSRunObject
     // protected methods ---------------------------------------------------------
     // tons of utility methods.
 
     /**
      * Return the node which we will handle white-space under. This is the
      * closest block within the DOM subtree we're editing, or if none is
      * found, the (inline) root of the editable subtree.
      */
-    already_AddRefed<nsINode> GetWSBoundingParent();
+    nsINode* GetWSBoundingParent();
 
     nsresult GetWSNodes();
     void     GetRuns();
     void     ClearRuns();
     void     MakeSingleWSRun(WSType aType);
     nsIContent* GetPreviousWSNodeInner(nsINode* aStartNode,
                                        nsINode* aBlockParent);
     nsIContent* GetPreviousWSNode(::DOMPoint aPoint, nsINode* aBlockParent);
--- a/gfx/layers/apz/util/ActiveElementManager.cpp
+++ b/gfx/layers/apz/util/ActiveElementManager.cpp
@@ -204,17 +204,17 @@ ActiveElementManager::ResetActive()
 void
 ActiveElementManager::ResetTouchBlockState()
 {
   mTarget = nullptr;
   mCanBePanSet = false;
 }
 
 void
-ActiveElementManager::SetActiveTask(dom::Element* aTarget)
+ActiveElementManager::SetActiveTask(const nsCOMPtr<dom::Element>& aTarget)
 {
   AEM_LOG("mSetActiveTask %p running\n", mSetActiveTask);
 
   // This gets called from mSetActiveTask's Run() method. The message loop
   // deletes the task right after running it, so we need to null out
   // mSetActiveTask to make sure we're not left with a dangling pointer.
   mSetActiveTask = nullptr;
   SetActive(aTarget);
--- a/gfx/layers/apz/util/ActiveElementManager.h
+++ b/gfx/layers/apz/util/ActiveElementManager.h
@@ -89,16 +89,16 @@ private:
    */
   bool mActiveElementUsesStyle;
 
   // Helpers
   void TriggerElementActivation();
   void SetActive(dom::Element* aTarget);
   void ResetActive();
   void ResetTouchBlockState();
-  void SetActiveTask(dom::Element* aTarget);
+  void SetActiveTask(const nsCOMPtr<dom::Element>& aTarget);
   void CancelTask();
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif /* mozilla_layers_ActiveElementManager_h */
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -1333,32 +1333,34 @@ AttachContainerRecurse(nsIDocShell* aShe
     nsIDocument* doc = viewer->GetDocument();
     if (doc) {
       doc->SetContainer(static_cast<nsDocShell*>(aShell));
     }
     RefPtr<nsPresContext> pc;
     viewer->GetPresContext(getter_AddRefs(pc));
     if (pc) {
       pc->SetContainer(static_cast<nsDocShell*>(aShell));
-      pc->SetLinkHandler(nsCOMPtr<nsILinkHandler>(do_QueryInterface(aShell)));
+      nsCOMPtr<nsILinkHandler> handler = do_QueryInterface(aShell);
+      pc->SetLinkHandler(handler);
     }
     nsCOMPtr<nsIPresShell> presShell;
     viewer->GetPresShell(getter_AddRefs(presShell));
     if (presShell) {
       presShell->SetForwardingContainer(WeakPtr<nsDocShell>());
     }
   }
 
   // Now recurse through the children
   int32_t childCount;
   aShell->GetChildCount(&childCount);
   for (int32_t i = 0; i < childCount; ++i) {
     nsCOMPtr<nsIDocShellTreeItem> childItem;
     aShell->GetChildAt(i, getter_AddRefs(childItem));
-    AttachContainerRecurse(nsCOMPtr<nsIDocShell>(do_QueryInterface(childItem)));
+    nsCOMPtr<nsIDocShell> shell = do_QueryInterface(childItem);
+    AttachContainerRecurse(shell);
   }
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::Open(nsISupports *aState, nsISHEntry *aSHEntry)
 {
   NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_INITIALIZED);
 
@@ -1376,17 +1378,18 @@ nsDocumentViewer::Open(nsISupports *aSta
   // Rehook the child presentations.  The child shells are still in
   // session history, so get them from there.
 
   if (aSHEntry) {
     nsCOMPtr<nsIDocShellTreeItem> item;
     int32_t itemIndex = 0;
     while (NS_SUCCEEDED(aSHEntry->ChildShellAt(itemIndex++,
                                                getter_AddRefs(item))) && item) {
-      AttachContainerRecurse(nsCOMPtr<nsIDocShell>(do_QueryInterface(item)));
+      nsCOMPtr<nsIDocShell> shell = do_QueryInterface(item);
+      AttachContainerRecurse(shell);
     }
   }
   
   SyncParentSubDocMap();
 
   if (mFocusListener && mDocument) {
     mDocument->AddEventListener(NS_LITERAL_STRING("focus"), mFocusListener,
                                 false, false);
@@ -1502,17 +1505,18 @@ DetachContainerRecurse(nsIDocShell *aShe
   }
 
   // Now recurse through the children
   int32_t childCount;
   aShell->GetChildCount(&childCount);
   for (int32_t i = 0; i < childCount; ++i) {
     nsCOMPtr<nsIDocShellTreeItem> childItem;
     aShell->GetChildAt(i, getter_AddRefs(childItem));
-    DetachContainerRecurse(nsCOMPtr<nsIDocShell>(do_QueryInterface(childItem)));
+    nsCOMPtr<nsIDocShell> shell = do_QueryInterface(childItem);
+    DetachContainerRecurse(shell);
   }
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::Destroy()
 {
   NS_ASSERTION(mDocument, "No document in Destroy()!");
 
@@ -1621,17 +1625,18 @@ nsDocumentViewer::Destroy()
     }
 
     // Do the same for our children.  Note that we need to get the child
     // docshells from the SHEntry now; the docshell will have cleared them.
     nsCOMPtr<nsIDocShellTreeItem> item;
     int32_t itemIndex = 0;
     while (NS_SUCCEEDED(shEntry->ChildShellAt(itemIndex++,
                                               getter_AddRefs(item))) && item) {
-      DetachContainerRecurse(nsCOMPtr<nsIDocShell>(do_QueryInterface(item)));
+      nsCOMPtr<nsIDocShell> shell = do_QueryInterface(item);
+      DetachContainerRecurse(shell);
     }
 
     return NS_OK;
   }
 
   // The document was not put in the bfcache
 
   if (mPresShell) {
--- a/media/mtransport/test/mtransport_test_utils.h
+++ b/media/mtransport/test/mtransport_test_utils.h
@@ -28,17 +28,17 @@ class MtransportTestUtils {
   void InitServices() {
     nsresult rv;
     sts_target_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
     MOZ_ASSERT(NS_SUCCEEDED(rv));
     sts_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
     MOZ_ASSERT(NS_SUCCEEDED(rv));
   }
 
-  nsCOMPtr<nsIEventTarget> sts_target() { return sts_target_; }
+  nsIEventTarget* sts_target() { return sts_target_; }
 
  private:
   nsCOMPtr<nsIEventTarget> sts_target_;
   nsCOMPtr<nsPISocketTransportService> sts_;
 };
 
 
 #define CHECK_ENVIRONMENT_FLAG(envname) \
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
@@ -325,17 +325,17 @@ public:
 
   // Get the main thread
   nsCOMPtr<nsIThread> GetMainThread() {
     PC_AUTO_ENTER_API_CALL_NO_CHECK();
     return mThread;
   }
 
   // Get the STS thread
-  nsCOMPtr<nsIEventTarget> GetSTSThread() {
+  nsIEventTarget* GetSTSThread() {
     PC_AUTO_ENTER_API_CALL_NO_CHECK();
     return mSTSThread;
   }
 
   nsPIDOMWindowInner* GetWindow() const {
     PC_AUTO_ENTER_API_CALL_NO_CHECK();
     return mWindow;
   }
--- a/xpcom/tests/TestCOMPtr.cpp
+++ b/xpcom/tests/TestCOMPtr.cpp
@@ -375,26 +375,16 @@ main()
 
       nsCOMPtr<IFoo> foo2p( do_QueryInterface(new IFoo) );
 
       if ( foo1p != foo2p )
         printf("foo1p != foo2p\n");
       else
         printf("foo1p == foo2p\n");
 
-      printf("\n### Test  7.5: can you compare a |nsCOMPtr| with NULL, 0, nullptr [!=]?\n");
-      if ( foo1p != 0 )
-      	printf("foo1p != 0\n");
-      if ( 0 != foo1p )
-      	printf("0 != foo1p\n");
-      if ( foo1p == 0 )
-      	printf("foo1p == 0\n");
-      if ( 0 == foo1p )
-      	printf("0 == foo1p\n");
-			
 
       IFoo* raw_foo2p = foo2p.get();
 
       printf("\n### Test  8: can you compare a |nsCOMPtr| with a raw interface pointer [!=]?\n");
       if ( foo1p.get() != raw_foo2p )
         printf("foo1p != raw_foo2p\n");
       else
         printf("foo1p == raw_foo2p\n");
@@ -424,124 +414,118 @@ main()
 #endif
 
       printf("\n### Test 12: bare pointer test?\n");
       if ( foo1p )
         printf("foo1p is not NULL\n");
       else
         printf("foo1p is NULL\n");
 
-      printf("\n### Test 13: numeric pointer test?\n");
-      if ( foo1p == 0 )
-        printf("foo1p is NULL\n");
-      else
-        printf("foo1p is not NULL\n");
-
 #if 0
 			if ( foo1p == 1 )
 				printf("foo1p allowed compare with in\n");
 #endif
 
-      printf("\n### Test 14: how about when two |nsCOMPtr|s referring to the same object go out of scope?\n");
+      printf("\n### Test 13: how about when two |nsCOMPtr|s referring to the same object go out of scope?\n");
     }
 
     {
-      printf("\n### Test 15,16 ...setup...\n");
+      printf("\n### Test 14,15 ...setup...\n");
       IFoo* raw_foo1p = new IFoo;
       raw_foo1p->AddRef();
 
       IFoo* raw_foo2p = new IFoo;
       raw_foo2p->AddRef();
 
-      printf("\n### Test 15: what if I don't want to |AddRef| when I construct?\n");
+      printf("\n### Test 14: what if I don't want to |AddRef| when I construct?\n");
       nsCOMPtr<IFoo> foo1p( dont_AddRef(raw_foo1p) );
       //nsCOMPtr<IFoo> foo1p = dont_AddRef(raw_foo1p);
 
-      printf("\n### Test 16: what if I don't want to |AddRef| when I assign in?\n");
+      printf("\n### Test 15: what if I don't want to |AddRef| when I assign in?\n");
       nsCOMPtr<IFoo> foo2p;
       foo2p = dont_AddRef(raw_foo2p);
     }
 
 
 
 
 
 
 
     {
-    	printf("\n### setup for Test 17\n");
+      printf("\n### setup for Test 16\n");
       nsCOMPtr<IFoo> foop;
-      printf("### Test 17: basic parameter behavior?\n");
+      printf("### Test 16: basic parameter behavior?\n");
       CreateIFoo( nsGetterAddRefs<IFoo>(foop) );
     }
+    printf("### End Test 16\n");
+
+
+    {
+      printf("\n### setup for Test 17\n");
+      nsCOMPtr<IFoo> foop;
+      printf("### Test 17: basic parameter behavior, using the short form?\n");
+      CreateIFoo( getter_AddRefs(foop) );
+    }
     printf("### End Test 17\n");
 
 
     {
-    	printf("\n### setup for Test 18\n");
+      printf("\n### setup for Test 18, 19\n");
       nsCOMPtr<IFoo> foop;
-      printf("### Test 18: basic parameter behavior, using the short form?\n");
-      CreateIFoo( getter_AddRefs(foop) );
-    }
-    printf("### End Test 18\n");
-
-
-    {
-    	printf("\n### setup for Test 19, 20\n");
-      nsCOMPtr<IFoo> foop;
-      printf("### Test 19: reference parameter behavior?\n");
+      printf("### Test 18: reference parameter behavior?\n");
       set_a_IFoo(address_of(foop));
 
-      printf("### Test 20: return value behavior?\n");
+      printf("### Test 19: return value behavior?\n");
       foop = return_a_IFoo();
     }
-    printf("### End Test 19, 20\n");
+    printf("### End Test 18, 19\n");
 
 		{
-    	printf("\n### setup for Test 21\n");
+      printf("\n### setup for Test 20\n");
 			nsCOMPtr<IFoo> fooP;
 
-			printf("### Test 21: is |QueryInterface| called on assigning in a raw pointer?\n");
+			printf("### Test 20: is |QueryInterface| called on assigning in a raw pointer?\n");
 			fooP = do_QueryInterface(new IFoo);
 		}
-    printf("### End Test 21\n");
+    printf("### End Test 20\n");
 
 		{
-    	printf("\n### setup for Test 22\n");
+      printf("\n### setup for Test 21\n");
 			nsCOMPtr<IFoo> fooP;
 			fooP = do_QueryInterface(new IFoo);
 
 			nsCOMPtr<IFoo> foo2P;
 
-			printf("### Test 22: is |QueryInterface| _not_ called when assigning in a smart-pointer of the same type?\n");
+			printf("### Test 21: is |QueryInterface| _not_ called when assigning in a smart-pointer of the same type?\n");
 			foo2P = fooP;
 		}
-    printf("### End Test 22\n");
+    printf("### End Test 21\n");
 
 		{
-    	printf("\n### setup for Test 23\n");
+      printf("\n### setup for Test 22\n");
 			nsCOMPtr<IBar> barP( do_QueryInterface(new IBar) );
 
-			printf("### Test 23: is |QueryInterface| called when assigning in a smart-pointer of a different type?\n");
+			printf("### Test 22: is |QueryInterface| called when assigning in a smart-pointer of a different type?\n");
 
 			nsCOMPtr<IFoo> fooP( do_QueryInterface(barP) );
 			if ( fooP )
 				printf("an IBar* is an IFoo*\n");
 		}
-    printf("### End Test 23\n");
+    printf("### End Test 22\n");
 
 
 		{
-    	printf("\n### setup for Test 24\n");
+      printf("\n### setup for Test 23\n");
 			nsCOMPtr<IFoo> fooP( do_QueryInterface(new IFoo) );
 
-			printf("### Test 24: does |forget| avoid an AddRef/Release when assigning to another nsCOMPtr?\n");
+			printf("### Test 23: does |forget| avoid an AddRef/Release when assigning to another nsCOMPtr?\n");
       nsCOMPtr<IFoo> fooP2( fooP.forget() );
 		}
-    printf("### End Test 24\n");
+    printf("### End Test 23\n");
 
 		{
 			nsCOMPtr<IFoo> fooP;
 
 			AnIFooPtrPtrContext( getter_AddRefs(fooP) );
 			AVoidPtrPtrContext( getter_AddRefs(fooP) );
 		}
 
@@ -549,15 +533,15 @@ main()
 		{
 			nsCOMPtr<nsISupports> supportsP;
 
 			AVoidPtrPtrContext( getter_AddRefs(supportsP) );
 			AnISupportsPtrPtrContext( getter_AddRefs(supportsP) );
 		}
 
 
-    printf("\n### Test 25: will a static |nsCOMPtr| |Release| before program termination?\n");
+    printf("\n### Test 24: will a static |nsCOMPtr| |Release| before program termination?\n");
     gFoop = do_QueryInterface(new IFoo);
     
     printf("<<main()\n");
     return 0;
   }
 
--- a/xpcom/tests/TestRegistrationOrder.cpp
+++ b/xpcom/tests/TestRegistrationOrder.cpp
@@ -165,22 +165,23 @@ int main(int argc, char** argv)
     char curr = argv[1][i];
     regPath[i] = (curr == '/') ? '\\' : curr;
   }
   regPath[regPathLen] = '\0';
 #else
   const char *regPath = argv[1];
 #endif
 
-  XRE_AddManifestLocation(NS_EXTENSION_LOCATION,
-                          nsCOMPtr<nsIFile>(GetRegDirectory(regPath, "core", "component.manifest")));
-  XRE_AddManifestLocation(NS_EXTENSION_LOCATION,
-                          nsCOMPtr<nsIFile>(GetRegDirectory(regPath, "extension", "extComponent.manifest")));
-  XRE_AddJarManifestLocation(NS_EXTENSION_LOCATION,
-                          nsCOMPtr<nsIFile>(GetRegDirectory(regPath, "extension2.jar", nullptr)));
+  nsCOMPtr<nsIFile> file =
+    GetRegDirectory(regPath, "core", "component.manifest");
+  XRE_AddManifestLocation(NS_EXTENSION_LOCATION, file);
+  file = GetRegDirectory(regPath, "extension", "extComponent.manifest");
+  XRE_AddManifestLocation(NS_EXTENSION_LOCATION, file);
+  file = GetRegDirectory(regPath, "extension2.jar", nullptr);
+  XRE_AddJarManifestLocation(NS_EXTENSION_LOCATION, file);
   ScopedXPCOM xpcom("RegistrationOrder");
   if (xpcom.failed())
     return 1;
 
   int rv = 0;
   if (NS_FAILED(TestRegular()))
     rv = 1;