Bug 1500833: Add a test which adds animation then immediately removes that. r=pbro
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Thu, 25 Oct 2018 00:41:00 +0000
changeset 491266 ece9ea20335f74562cc8f9c771d4149c0760703b
parent 491265 980d3b8e603b3cdebf7cc647b39b01576f0178b0
child 491267 4ef080fed9d2246509f6ebf04652e60f7d76402e
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerspbro
bugs1500833
milestone65.0a1
Bug 1500833: Add a test which adds animation then immediately removes that. r=pbro Depends on D9616 Differential Revision: https://phabricator.services.mozilla.com/D9617
devtools/client/inspector/animation/test/browser.ini
devtools/client/inspector/animation/test/browser_animation_logic_mutations_add_remove_immediately.js
devtools/client/inspector/animation/test/doc_mutations_add_remove_immediately.html
--- a/devtools/client/inspector/animation/test/browser.ini
+++ b/devtools/client/inspector/animation/test/browser.ini
@@ -4,16 +4,17 @@ subsuite = devtools
 support-files =
   current-time-scrubber_head.js
   doc_custom_playback_rate.html
   doc_frame_script.js
   doc_infinity_duration.html
   doc_multi_easings.html
   doc_multi_keyframes.html
   doc_multi_timings.html
+  doc_mutations_add_remove_immediately.html
   doc_mutations_fast.html
   doc_negative_playback_rate.html
   doc_overflowed_delay_end_delay.html
   doc_pseudo.html
   doc_short_duration.html
   doc_simple_animation.html
   head.js
   keyframes-graph_keyframe-marker_head.js
@@ -63,16 +64,17 @@ skip-if = (verify && !debug)
 skip-if = (os == "win" && ccov) # Bug 1490981
 [browser_animation_keyframes-progress-bar_after-resuming.js]
 [browser_animation_logic_adjust-time.js]
 [browser_animation_logic_adjust-time-with-playback-rate.js]
 [browser_animation_logic_auto-stop.js]
 [browser_animation_logic_avoid-updating-during-hiding.js]
 [browser_animation_logic_created-time.js]
 [browser_animation_logic_mutations.js]
+[browser_animation_logic_mutations_add_remove_immediately.js]
 [browser_animation_logic_mutations_fast.js]
 skip-if= true # Bug 1500046
 [browser_animation_logic_mutations_properties.js]
 [browser_animation_logic_overflowed_delay_end-delay.js]
 skip-if = debug #bug 1480027
 [browser_animation_logic_scroll-amount.js]
 [browser_animation_pause-resume-button.js]
 [browser_animation_pause-resume-button_end-time.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/animation/test/browser_animation_logic_mutations_add_remove_immediately.js
@@ -0,0 +1,25 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test whether the animation inspector will not crash when add animation then remove
+// immediately.
+
+add_task(async function() {
+  const tab = await addTab(URL_ROOT + "doc_mutations_add_remove_immediately.html");
+  const { inspector, panel } = await openAnimationInspector();
+
+  info("Check state of the animation inspector after fast mutations");
+  const onDispatch = waitForDispatch(inspector, "UPDATE_ANIMATIONS", () => 1);
+  await startMutation(tab);
+  await onDispatch;
+  ok(panel.querySelector(".animation-error-message"),
+     "No animations message should display");
+});
+
+async function startMutation(tab) {
+  await ContentTask.spawn(tab.linkedBrowser, {}, async function() {
+    await content.wrappedJSObject.startMutation();
+  });
+}
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/animation/test/doc_mutations_add_remove_immediately.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8">
+  </head>
+  <body>
+    <div></div>
+
+    <script>
+    "use strict";
+
+    // This function is called from test.
+    // eslint-disable-next-line
+    function startMutation() {
+      const target = document.querySelector("div");
+      const animation = target.animate({ opacity: [1, 0] }, 100000);
+      animation.currentTime = 1;
+      animation.cancel();
+    }
+    </script>
+  </body>
+</html>