Bug 1317409 - Handle failing node adoption properly. r=peterv, a=ritu
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 17 Nov 2016 15:54:12 +0200
changeset 462128 c3a677de3a52e662dade40abcf3d0da156ee1a26
parent 462127 b6520a9a6d19006ed8d28fa60f92dbb379ab80be
child 462129 a68998d0287fdf9d5ee1819bb212926f448068ad
push id41678
push userfelipc@gmail.com
push dateMon, 16 Jan 2017 20:19:38 +0000
reviewerspeterv, ritu
bugs1317409
milestone50.1.0
Bug 1317409 - Handle failing node adoption properly. r=peterv, a=ritu
dom/base/nsNodeUtils.cpp
--- a/dom/base/nsNodeUtils.cpp
+++ b/dom/base/nsNodeUtils.cpp
@@ -565,18 +565,23 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNod
     if (aReparentScope) {
       AutoJSContext cx;
       JS::Rooted<JSObject*> wrapper(cx);
       if ((wrapper = aNode->GetWrapper())) {
         MOZ_ASSERT(IsDOMObject(wrapper));
         JSAutoCompartment ac(cx, wrapper);
         rv = ReparentWrapper(cx, wrapper);
         if (NS_FAILED(rv)) {
+          if (wasRegistered) {
+            aNode->OwnerDoc()->UnregisterActivityObserver(aNode->AsElement());
+          }
           aNode->mNodeInfo.swap(newNodeInfo);
-
+          if (wasRegistered) {
+            aNode->OwnerDoc()->RegisterActivityObserver(aNode->AsElement());
+          }
           return rv;
         }
       }
     }
   }
 
   if (aDeep && (!aClone || !aNode->IsNodeOfType(nsINode::eATTRIBUTE))) {
     // aNode's children.