Bug 1067769 - Part 14: Test for our animation mutation observer. r=birtles
authorBoris Chiou <boris.chiou@gmail.com>
Thu, 28 Apr 2016 23:22:44 +0800
changeset 357629 d6e8827792d47b3a36862d000f994d7838658479
parent 357628 89fbe8d41149051835207c8ac85867418e6e0750
child 357630 ad471499e704212e9161e169e832079d7b152ed1
push id16816
push userbmo:gasolin@mozilla.com
push dateFri, 29 Apr 2016 03:33:20 +0000
reviewersbirtles
bugs1067769
milestone49.0a1
Bug 1067769 - Part 14: Test for our animation mutation observer. r=birtles MozReview-Commit-ID: IQItWcNBscr
dom/animation/test/chrome/test_animation_observers.html
--- a/dom/animation/test/chrome/test_animation_observers.html
+++ b/dom/animation/test/chrome/test_animation_observers.html
@@ -1728,16 +1728,76 @@ addAsyncAnimTest("create_animation_witho
   yield await_frame();
   assert_records([], "no records after animation is added");
 
   anim.cancel();
   yield await_frame();
   assert_records([], "no records after animation is removed");
 });
 
+addAsyncAnimTest("set_animation_target",
+                 { observe: document, subtree: true }, function*() {
+  var anim = div.animate({ opacity: [ 0, 1 ] },
+                         { duration: 100 * MS_PER_SEC });
+
+  yield await_frame();
+  assert_records([{ added: [anim], changed: [], removed: [] }],
+                 "records after animation is added");
+
+  anim.effect.target = null;
+  yield await_frame();
+  assert_records([{ added: [], changed: [], removed: [anim] }],
+                 "records after setting null");
+
+  anim.effect.target = div;
+  yield await_frame();
+  assert_records([{ added: [anim], changed: [], removed: [] }],
+                 "records after setting a target");
+
+  var newTarget = document.createElement("div");
+  document.body.appendChild(newTarget);
+  anim.effect.target = newTarget;
+  yield await_frame();
+  assert_records([{ added: [], changed: [], removed: [anim] },
+                  { added: [anim], changed: [], removed: [] }],
+                 "records after setting a different target");
+
+  anim.cancel();
+  yield await_frame();
+  assert_records([{ added: [], changed: [], removed: [anim] }],
+                 "records after animation ends");
+
+  newTarget.remove();
+});
+
+addAsyncAnimTest("set_redundant_animation_target",
+                 { observe: div, subtree: true }, function*() {
+  var anim = div.animate({ opacity: [ 0, 1 ] },
+                         { duration: 100 * MS_PER_SEC });
+  yield await_frame();
+  assert_records([{ added: [anim], changed: [], removed: [] }],
+                 "records after animation is added");
+
+  anim.effect.target = div;
+  yield await_frame();
+  assert_records([], "no records after setting the same target");
+
+  anim.effect.target = null;
+  yield await_frame();
+  assert_records([{ added: [], changed: [], removed: [anim] }],
+                 "records after setting null");
+
+  anim.effect.target = null;
+  yield await_frame();
+  assert_records([], "records after setting redundant null");
+
+  anim.cancel();
+  yield await_frame();
+});
+
 // Run the tests.
 SimpleTest.requestLongerTimeout(2);
 SimpleTest.waitForExplicitFinish();
 
 runAllAsyncTests().then(function() {
   SimpleTest.finish();
 }, function(aError) {
   ok(false, "Something failed: " + aError);