Bug 841802 - Part 1: Add ErrorResult::ClearMessage(). r=bz
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Tue, 19 Feb 2013 22:30:28 +0900
changeset 133536 a093423c5e5b642b142746d1f3f71728c236d0eb
parent 133535 b143a7fb7f396327fadfaabb68ec2eb7d8522b0f
child 133537 3b15e153f662629e6466a526e640d16dbf2d3419
push id336
push userakeybl@mozilla.com
push dateMon, 17 Jun 2013 22:53:19 +0000
treeherdermozilla-release@574a39cdf657 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs841802
milestone21.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 841802 - Part 1: Add ErrorResult::ClearMessage(). r=bz
dom/bindings/BindingUtils.cpp
dom/bindings/ErrorResult.h
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -90,18 +90,26 @@ ErrorResult::ReportTypeError(JSContext* 
     args[i] = message->mArgs.ElementAt(i).get();
   }
   args[argCount] = nullptr;
 
   JS_ReportErrorNumberUCArray(aCx, dom::GetErrorMessage, nullptr,
                               static_cast<const unsigned>(message->mErrorNumber),
                               argCount > 0 ? args : nullptr);
 
-  delete message;
-  mMessage = nullptr;
+  ClearMessage();
+}
+
+void
+ErrorResult::ClearMessage()
+{
+  if (IsTypeError()) {
+    delete mMessage;
+    mMessage = nullptr;
+  }
 }
 
 namespace dom {
 
 bool
 DefineConstants(JSContext* cx, JSObject* obj, ConstantSpec* cs)
 {
   for (; cs->name; ++cs) {
--- a/dom/bindings/ErrorResult.h
+++ b/dom/bindings/ErrorResult.h
@@ -46,16 +46,17 @@ public:
     MOZ_ASSERT(NS_FAILED(rv), "Please don't try throwing success");
     MOZ_ASSERT(rv != NS_ERROR_TYPE_ERR, "Use ThrowTypeError()");
     MOZ_ASSERT(!IsTypeError(), "Don't overwite TypeError");
     mResult = rv;
   }
 
   void ThrowTypeError(const dom::ErrNum errorNumber, ...);
   void ReportTypeError(JSContext* cx);
+  void ClearMessage();
   bool IsTypeError() const { return ErrorCode() == NS_ERROR_TYPE_ERR; }
 
   // In the future, we can add overloads of Throw that take more
   // interesting things, like strings or DOM exception types or
   // something if desired.
 
   // Backwards-compat to make conversion simpler.  We don't call
   // Throw() here because people can easily pass success codes to