Bug 1445392: Avoid posting a slotchange event microtask during shutdown. r?smaug draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 07 May 2018 20:49:47 +0200
changeset 792163 9dbd9fec54451984b7a530522a91885cd7ceecd7
parent 792162 9df0ae05136917ef1272686ea6aa868af5b4eb9e
push id109016
push userbmo:emilio@crisal.io
push dateMon, 07 May 2018 19:18:38 +0000
reviewerssmaug
bugs1445392
milestone61.0a1
Bug 1445392: Avoid posting a slotchange event microtask during shutdown. r?smaug Not sure if moving stuff to nsXPCOM is acceptable or if I should add an NS_* function instead. MozReview-Commit-ID: 1ga6cDVRX5
dom/html/HTMLSlotElement.cpp
xpcom/build/nsXPCOM.h
xpcom/build/nsXPCOMPrivate.h
--- a/dom/html/HTMLSlotElement.cpp
+++ b/dom/html/HTMLSlotElement.cpp
@@ -215,16 +215,22 @@ HTMLSlotElement::ClearAssignedNodes()
 
 void
 HTMLSlotElement::EnqueueSlotChangeEvent()
 {
   if (mInSignalSlotList) {
     return;
   }
 
+  // FIXME(bug 1459704): Need to figure out how to deal with microtasks posted
+  // during shutdown.
+  if (gXPCOMThreadsShutDown) {
+    return;
+  }
+
   DocGroup* docGroup = OwnerDoc()->GetDocGroup();
   if (!docGroup) {
     return;
   }
 
   mInSignalSlotList = true;
   docGroup->SignalSlotChange(*this);
 }
--- a/xpcom/build/nsXPCOM.h
+++ b/xpcom/build/nsXPCOM.h
@@ -24,16 +24,21 @@ DECL_CLASS(nsIComponentManager);
 DECL_CLASS(nsIComponentRegistrar);
 DECL_CLASS(nsIServiceManager);
 DECL_CLASS(nsIFile);
 DECL_CLASS(nsIDirectoryServiceProvider);
 DECL_CLASS(nsIMemory);
 DECL_CLASS(nsIDebug2);
 
 #ifdef __cplusplus
+extern bool gXPCOMShuttingDown;
+extern bool gXPCOMThreadsShutDown;
+#endif
+
+#ifdef __cplusplus
 #include "nsStringFwd.h"
 namespace mozilla {
 struct Module;
 } // namespace mozilla
 #endif
 
 /**
  * Initialises XPCOM. You must call one of the NS_InitXPCOM methods
--- a/xpcom/build/nsXPCOMPrivate.h
+++ b/xpcom/build/nsXPCOMPrivate.h
@@ -111,19 +111,16 @@ void LogTerm();
 #define MAXPATHLEN _MAX_PATH
 #elif defined(CCHMAXPATH)
 #define MAXPATHLEN CCHMAXPATH
 #else
 #define MAXPATHLEN 1024
 #endif
 #endif
 
-extern bool gXPCOMShuttingDown;
-extern bool gXPCOMThreadsShutDown;
-
 // Needed by the IPC layer from off the main thread
 extern char16_t* gGREBinPath;
 
 namespace mozilla {
 namespace services {
 
 /**
  * Clears service cache, sets gXPCOMShuttingDown