Bug 1253470 - Part 1: Produce console warnings for invalid duration. r=birtles
authorDaisuke Akatsuka <daisuke@mozilla-japan.org>
Fri, 18 Mar 2016 10:07:10 +0900
changeset 289741 5cdab04704f1a10a8ee278e594fc22b9d560d26f
parent 289740 d5e77c8d64c984f80b9fec8ba00507427e60d420
child 289742 ad28fd60184e2719acd520164860d0e7322e3f58
push id30108
push usercbook@mozilla.com
push dateTue, 22 Mar 2016 11:14:31 +0000
treeherdermozilla-central@ea6298e1b4f7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1253470
milestone48.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 1253470 - Part 1: Produce console warnings for invalid duration. r=birtles
dom/animation/TimingParams.h
dom/bindings/Errors.msg
--- a/dom/animation/TimingParams.h
+++ b/dom/animation/TimingParams.h
@@ -48,22 +48,23 @@ struct TimingParams
   static Maybe<StickyTimeDuration> ParseDuration(DoubleOrString& aDuration,
                                                  ErrorResult& aRv)
   {
     Maybe<StickyTimeDuration> result;
     if (aDuration.IsUnrestrictedDouble()) {
       double durationInMs = aDuration.GetAsUnrestrictedDouble();
       if (durationInMs >= 0) {
         result.emplace(StickyTimeDuration::FromMilliseconds(durationInMs));
-        return result;
+      } else {
+        aRv.ThrowTypeError<dom::MSG_ENFORCE_RANGE_OUT_OF_RANGE>(
+          NS_LITERAL_STRING("duration"));
       }
-    } else if (aDuration.GetAsString().EqualsLiteral("auto")) {
-      return result;
+    } else if (!aDuration.GetAsString().EqualsLiteral("auto")) {
+      aRv.ThrowTypeError<dom::MSG_INVALID_DURATION_ERROR>();
     }
-    aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
     return result;
   }
 
   static void ValidateIterationStart(double aIterationStart,
                                      ErrorResult& aRv)
   {
     if (aIterationStart < 0) {
       aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
--- a/dom/bindings/Errors.msg
+++ b/dom/bindings/Errors.msg
@@ -87,8 +87,9 @@ MSG_DEF(MSG_PROMISE_CAPABILITY_HAS_SOMET
 MSG_DEF(MSG_PROMISE_RESOLVE_FUNCTION_NOT_CALLABLE, 0, JSEXN_TYPEERR, "A Promise subclass passed a non-callable value as the resolve function.")
 MSG_DEF(MSG_PROMISE_REJECT_FUNCTION_NOT_CALLABLE, 0, JSEXN_TYPEERR, "A Promise subclass passed a non-callable value as the reject function.")
 MSG_DEF(MSG_PROMISE_ARG_NOT_ITERABLE, 1, JSEXN_TYPEERR, "{0} is not iterable")
 MSG_DEF(MSG_IS_NOT_PROMISE, 1, JSEXN_TYPEERR, "{0} is not a Promise")
 MSG_DEF(MSG_SW_INSTALL_ERROR, 2, JSEXN_TYPEERR, "ServiceWorker script at {0} for scope {1} encountered an error during installation.")
 MSG_DEF(MSG_SW_SCRIPT_THREW, 2, JSEXN_TYPEERR, "ServiceWorker script at {0} for scope {1} threw an exception during script evaluation.")
 MSG_DEF(MSG_TYPEDARRAY_IS_SHARED, 1, JSEXN_TYPEERR, "{0} can't be a typed array on SharedArrayBuffer")
 MSG_DEF(MSG_CACHE_ADD_FAILED_RESPONSE, 3, JSEXN_TYPEERR, "Cache got {0} response with bad status {1} while trying to add request {2}")
+MSG_DEF(MSG_INVALID_DURATION_ERROR, 0, JSEXN_TYPEERR, "Invalid duration.")
\ No newline at end of file