Bug 1167423 - patch 3 - Handle return values of FallibleTArray functions in MutationObserver, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 25 May 2015 12:50:15 +0100
changeset 245464 c85d3209f1578e50c9857018161a99e47fe31e58
parent 245463 84ea22e04a6272a6291797e8638c258ee18a69dd
child 245465 a0dda76be94a371ae313376365c77f2960c2d53b
push id28806
push userphilringnalda@gmail.com
push dateTue, 26 May 2015 02:10:16 +0000
treeherdermozilla-central@4362d9251296 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1167423
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1167423 - patch 3 - Handle return values of FallibleTArray functions in MutationObserver, r=smaug
dom/base/nsDOMMutationObserver.cpp
dom/base/nsDOMMutationObserver.h
dom/webidl/MutationObserver.webidl
--- a/dom/base/nsDOMMutationObserver.cpp
+++ b/dom/base/nsDOMMutationObserver.cpp
@@ -688,17 +688,19 @@ nsDOMMutationObserver::TakeRecords(
     current->mNext.swap(next);
     *aRetVal.AppendElement() = current.forget();
     current.swap(next);
   }
   ClearPendingRecords();
 }
 
 void
-nsDOMMutationObserver::GetObservingInfo(nsTArray<Nullable<MutationObservingInfo> >& aResult)
+nsDOMMutationObserver::GetObservingInfo(
+                         nsTArray<Nullable<MutationObservingInfo>>& aResult,
+                         mozilla::ErrorResult& aRv)
 {
   aResult.SetCapacity(mReceivers.Count());
   for (int32_t i = 0; i < mReceivers.Count(); ++i) {
     MutationObservingInfo& info = aResult.AppendElement()->SetValue();
     nsMutationReceiver* mr = mReceivers[i];
     info.mChildList = mr->ChildList();
     info.mAttributes.Construct(mr->Attributes());
     info.mCharacterData.Construct(mr->CharacterData());
@@ -707,17 +709,20 @@ nsDOMMutationObserver::GetObservingInfo(
     info.mCharacterDataOldValue.Construct(mr->CharacterDataOldValue());
     info.mAnimations.Construct(mr->Animations());
     nsCOMArray<nsIAtom>& filters = mr->AttributeFilter();
     if (filters.Count()) {
       info.mAttributeFilter.Construct();
       mozilla::dom::Sequence<nsString>& filtersAsStrings =
         info.mAttributeFilter.Value();
       for (int32_t j = 0; j < filters.Count(); ++j) {
-        filtersAsStrings.AppendElement(nsDependentAtomString(filters[j]));
+        if (!filtersAsStrings.AppendElement(nsDependentAtomString(filters[j]))) {
+          aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
+          return;
+        }
       }
     }
     info.mObservedNode = mr->Target();
   }
 }
 
 // static
 already_AddRefed<nsDOMMutationObserver>
--- a/dom/base/nsDOMMutationObserver.h
+++ b/dom/base/nsDOMMutationObserver.h
@@ -488,17 +488,18 @@ public:
                mozilla::ErrorResult& aRv);
 
   void Disconnect();
 
   void TakeRecords(nsTArray<nsRefPtr<nsDOMMutationRecord> >& aRetVal);
 
   void HandleMutation();
 
-  void GetObservingInfo(nsTArray<Nullable<MutationObservingInfo> >& aResult);
+  void GetObservingInfo(nsTArray<Nullable<MutationObservingInfo>>& aResult,
+                        mozilla::ErrorResult& aRv);
 
   mozilla::dom::MutationCallback* MutationCallback() { return mCallback; }
 
   void AppendMutationRecord(already_AddRefed<nsDOMMutationRecord> aRecord)
   {
     nsRefPtr<nsDOMMutationRecord> record = aRecord;
     MOZ_ASSERT(record);
     if (!mLastPendingMutation) {
--- a/dom/webidl/MutationObserver.webidl
+++ b/dom/webidl/MutationObserver.webidl
@@ -38,17 +38,17 @@ interface MutationRecord {
 
 [Constructor(MutationCallback mutationCallback)]
 interface MutationObserver {
   [Throws]
   void observe(Node target, optional MutationObserverInit options);
   void disconnect();
   sequence<MutationRecord> takeRecords();
 
-  [ChromeOnly]
+  [ChromeOnly, Throws]
   sequence<MutationObservingInfo?> getObservingInfo();
   [ChromeOnly]
   readonly attribute MutationCallback mutationCallback;
 };
 
 callback MutationCallback = void (sequence<MutationRecord> mutations, MutationObserver observer);
 
 dictionary MutationObserverInit {