Bug 1462229 - Part 4: Add test for fast removal. r?gl
MozReview-Commit-ID: 2Fr3v7OwkMm
--- a/devtools/client/inspector/animation/test/browser.ini
+++ b/devtools/client/inspector/animation/test/browser.ini
@@ -2,16 +2,17 @@
tags = devtools
subsuite = devtools
support-files =
doc_custom_playback_rate.html
doc_frame_script.js
doc_multi_easings.html
doc_multi_keyframes.html
doc_multi_timings.html
+ doc_mutations_fast.html
doc_pseudo.html
doc_simple_animation.html
head.js
!/devtools/client/inspector/test/head.js
!/devtools/client/inspector/test/shared-head.js
!/devtools/client/shared/test/frame-script-utils.js
!/devtools/client/shared/test/shared-head.js
!/devtools/client/shared/test/telemetry-test-helpers.js
@@ -38,16 +39,17 @@ support-files =
[browser_animation_keyframes-graph_computed-value-path.js]
[browser_animation_keyframes-graph_computed-value-path_easing-hint.js]
[browser_animation_keyframes-graph_keyframe-marker.js]
[browser_animation_keyframes-progress-bar.js]
[browser_animation_keyframes-progress-bar_after-resuming.js]
[browser_animation_logic_auto-stop.js]
[browser_animation_logic_avoid-updating-during-hiding.js]
[browser_animation_logic_mutations.js]
+[browser_animation_logic_mutations_fast.js]
[browser_animation_pause-resume-button.js]
[browser_animation_pause-resume-button_end-time.js]
[browser_animation_pause-resume-button_respectively.js]
[browser_animation_pause-resume-button_spacebar.js]
[browser_animation_playback-rate-selector.js]
[browser_animation_pseudo-element.js]
[browser_animation_rewind-button.js]
[browser_animation_summary-graph_animation-name.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/animation/test/browser_animation_logic_mutations_fast.js
@@ -0,0 +1,22 @@
+/* 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 remove/add animations faster.
+
+add_task(async function() {
+ const tab = await addTab(URL_ROOT + "doc_mutations_fast.html");
+ const { inspector } = await openAnimationInspector();
+
+ info("Check state of the animation inspector after fast mutations");
+ await startFastMutations(tab);
+ ok(inspector.panelWin.document.getElementById("animation-container"),
+ "Animation inspector should be live");
+});
+
+async function startFastMutations(tab) {
+ await ContentTask.spawn(tab.linkedBrowser, {}, async function() {
+ await content.wrappedJSObject.startFastMutations();
+ });
+}
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/animation/test/doc_mutations_fast.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8">
+ <style>
+ div {
+ background-color: lime;
+ height: 20px;
+ opacity: 1;
+ transition: 0.5s opacity;
+ }
+
+ .transition {
+ opacity: 0;
+ }
+ </style>
+ </head>
+ <body>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+
+ <script>
+ "use strict";
+
+ // This function is called from test.
+ // eslint-disable-next-line
+ async function startFastMutations() {
+ const targets = document.querySelectorAll("div");
+
+ for (let i = 0; i < 10; i++) {
+ for (const target of targets) {
+ target.classList.toggle("transition");
+ await wait(15);
+ }
+ }
+ }
+
+ async function wait(ms) {
+ return new Promise(resolve => {
+ setTimeout(resolve, ms);
+ });
+ }
+ </script>
+ </body>
+</html>