Bug 1239889 part 1 - Throw if the animation target does not have a current document; r=heycam
authorBrian Birtles <birtles@gmail.com>
Fri, 05 Feb 2016 14:11:04 +1100
changeset 329124 3bb3381dc5f82da9ce39eb8f8177721c58839029
parent 329123 d0382e8ba2696c4ae7835379b4480ec118b5d180
child 329125 6b16abc856972cf48e0254d881d8e1ad1ad7f353
push id10471
push usergijskruitbosch@gmail.com
push dateFri, 05 Feb 2016 12:52:29 +0000
reviewersheycam
bugs1239889, 1245748
milestone47.0a1
Bug 1239889 part 1 - Throw if the animation target does not have a current document; r=heycam This is just a temporary measure to avoid a failed assertion / crash until we fix bug 1245748.
dom/animation/KeyframeEffect.cpp
dom/base/domerr.msg
xpcom/base/ErrorList.h
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -1627,16 +1627,22 @@ KeyframeEffectReadOnly::Constructor(
     ErrorResult& aRv)
 {
   if (!aTarget) {
     // We don't support null targets yet.
     aRv.Throw(NS_ERROR_DOM_ANIM_NO_TARGET_ERR);
     return nullptr;
   }
 
+  if (!aTarget->GetCurrentDoc()) {
+    // Bug 1245748: We don't support targets that are not in a document yet.
+    aRv.Throw(NS_ERROR_DOM_ANIM_TARGET_NOT_IN_DOC_ERR);
+    return nullptr;
+  }
+
   InfallibleTArray<AnimationProperty> animationProperties;
   BuildAnimationPropertyList(aGlobal.Context(), aTarget, aFrames,
                              animationProperties, aRv);
 
   if (aRv.Failed()) {
     return nullptr;
   }
 
--- a/dom/base/domerr.msg
+++ b/dom/base/domerr.msg
@@ -114,16 +114,17 @@ DOM4_MSG_DEF(BtUnhandledError,    "Unhan
 DOM4_MSG_DEF(BtAuthFailureError,  "Authentication failure",  NS_ERROR_DOM_BLUETOOTH_AUTH_FAILURE)
 DOM4_MSG_DEF(BtRmtDevDownError,   "Remote device down",  NS_ERROR_DOM_BLUETOOTH_RMT_DEV_DOWN)
 DOM4_MSG_DEF(BtAuthRejectedError, "Authentication rejected",  NS_ERROR_DOM_BLUETOOTH_AUTH_REJECTED)
 
 /* Web Animations errors */
 
 DOM4_MSG_DEF(NotSupportedError, "Animation to or from an underlying value is not yet supported.", NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR)
 DOM4_MSG_DEF(NotSupportedError, "Animation with no target is not yet supported.", NS_ERROR_DOM_ANIM_NO_TARGET_ERR)
+DOM4_MSG_DEF(NotSupportedError, "Animation with a target not bound to a document is not yet supported.", NS_ERROR_DOM_ANIM_TARGET_NOT_IN_DOC_ERR)
 
 /* common global codes (from nsError.h) */
 
 DOM_MSG_DEF(NS_OK                                  , "Success")
 DOM_MSG_DEF(NS_ERROR_NOT_INITIALIZED               , "Component not initialized")
 DOM_MSG_DEF(NS_ERROR_ALREADY_INITIALIZED           , "Component already initialized")
 DOM_MSG_DEF(NS_ERROR_NOT_IMPLEMENTED               , "Method not implemented")
 DOM_MSG_DEF(NS_NOINTERFACE                         , "Component does not have requested interface")
--- a/xpcom/base/ErrorList.h
+++ b/xpcom/base/ErrorList.h
@@ -928,16 +928,17 @@
 #undef MODULE
 
   /* ======================================================================= */
   /* 39: NS_ERROR_MODULE_DOM_ANIM */
   /* ======================================================================= */
 #define MODULE NS_ERROR_MODULE_DOM_ANIM
   ERROR(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR,              FAILURE(1)),
   ERROR(NS_ERROR_DOM_ANIM_NO_TARGET_ERR,                  FAILURE(2)),
+  ERROR(NS_ERROR_DOM_ANIM_TARGET_NOT_IN_DOC_ERR,          FAILURE(3)),
 #undef MODULE
 
   /* ======================================================================= */
   /* 40: NS_ERROR_MODULE_DOM_PUSH */
   /* ======================================================================= */
 #define MODULE NS_ERROR_MODULE_DOM_PUSH
   ERROR(NS_ERROR_DOM_PUSH_INVALID_REGISTRATION_ERR, FAILURE(1)),
   ERROR(NS_ERROR_DOM_PUSH_DENIED_ERR, FAILURE(2)),