Bug 1067769 - Part 14: Test for our animation mutation observer. r=birtles draft
authorBoris Chiou <boris.chiou@gmail.com>
Thu, 28 Apr 2016 23:22:44 +0800
changeset 357400 218ac06dcb2b9d75d4078c66aa0f112678d42ba0
parent 357399 9620f2a3bbaed34456e340ccef5738272beb954d
child 357401 6c6f94413599326e05ff0c838e15eb231d801a67
push id16759
push userbchiou@mozilla.com
push dateThu, 28 Apr 2016 15:27:13 +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);