Bug 1453032 - Part 2: Add a test that avoids reselecting the node when the node is already selected. r=gl
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Thu, 26 Apr 2018 10:23:29 +0900
changeset 472318 afbec7f03bd8ced52be05199cb45ff844e456a75
parent 472317 d7008cb7d66a3a7984873d1b6b9201d76f31a0f1
child 472319 d10c828a7c3eb914687fe8bb6df31ceecc38df21
child 472322 c552490c8659bf2e7d279ed28d46fb5d5a245a96
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1453032
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1453032 - Part 2: Add a test that avoids reselecting the node when the node is already selected. r=gl MozReview-Commit-ID: L0SbpdEV93K
devtools/client/inspector/animation/test/browser.ini
devtools/client/inspector/animation/test/browser_animation_animation-target.js
devtools/client/inspector/animation/test/browser_animation_animation-target_select.js
--- a/devtools/client/inspector/animation/test/browser.ini
+++ b/devtools/client/inspector/animation/test/browser.ini
@@ -20,16 +20,17 @@ support-files =
 [browser_animation_animated-property-list_unchanged-items.js]
 [browser_animation_animated-property-name.js]
 [browser_animation_animation-detail_close-button.js]
 [browser_animation_animation-detail_title.js]
 [browser_animation_animation-detail_visibility.js]
 [browser_animation_animation-list.js]
 [browser_animation_animation-target.js]
 [browser_animation_animation-target_highlight.js]
+[browser_animation_animation-target_select.js]
 [browser_animation_animation-timeline-tick.js]
 [browser_animation_current-time-label.js]
 [browser_animation_current-time-scrubber.js]
 [browser_animation_empty_on_invalid_nodes.js]
 [browser_animation_inspector_exists.js]
 [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]
--- a/devtools/client/inspector/animation/test/browser_animation_animation-target.js
+++ b/devtools/client/inspector/animation/test/browser_animation_animation-target.js
@@ -2,42 +2,41 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 // Test for following AnimationTarget component works.
 // * element existance
 // * number of elements
 // * content of element
-// * select an animated node by clicking on inspect node
 // * title of inspect icon
 
+const TEST_DATA = [
+  { expectedTextContent: "div.ball.animated" },
+  { expectedTextContent: "div.ball.long" },
+];
+
 add_task(async function() {
   await addTab(URL_ROOT + "doc_simple_animation.html");
   await removeAnimatedElementsExcept([".animated", ".long"]);
   const { animationInspector, panel } = await openAnimationInspector();
 
   info("Checking the animation target elements existance");
   const animationItemEls = panel.querySelectorAll(".animation-list .animation-item");
   is(animationItemEls.length, animationInspector.state.animations.length,
      "Number of animation target element should be same to number of animations " +
      "that displays");
 
-  for (const animationItemEl of animationItemEls) {
+  for (let i = 0; i < animationItemEls.length; i++) {
+    const animationItemEl = animationItemEls[i];
     const animationTargetEl = animationItemEl.querySelector(".animation-target");
     ok(animationTargetEl,
       "The animation target element should be in each animation item element");
+
+    info("Checking the content of animation target");
+    const testData = TEST_DATA[i];
+    is(animationTargetEl.textContent, testData.expectedTextContent,
+       "The target element's content is correct");
+    ok(animationTargetEl.querySelector(".objectBox"), "objectBox is in the page exists");
+    ok(animationTargetEl.querySelector(".open-inspector").title,
+       INSPECTOR_L10N.getStr("inspector.nodePreview.highlightNodeLabel"));
   }
-
-  info("Checking the selecting an animated node by clicking the target node");
-  await clickOnTargetNode(animationInspector, panel, 0);
-  is(panel.querySelectorAll(".animation-target").length, 1,
-    "The length of animations should be 1");
-
-  info("Checking the content of animation target");
-  const animationTargetEl =
-    panel.querySelector(".animation-list .animation-item .animation-target");
-  is(animationTargetEl.textContent, "div.ball.animated",
-    "The target element's content is correct");
-  ok(animationTargetEl.querySelector(".objectBox"), "objectBox is in the page exists");
-  ok(animationTargetEl.querySelector(".open-inspector").title,
-     INSPECTOR_L10N.getStr("inspector.nodePreview.highlightNodeLabel"));
 });
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/animation/test/browser_animation_animation-target_select.js
@@ -0,0 +1,32 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test for following selection feature related AnimationTarget component works:
+// * select an animated node by clicking on target node
+// * select selected node by clicking on target node
+
+add_task(async function() {
+  await addTab(URL_ROOT + "doc_simple_animation.html");
+  await removeAnimatedElementsExcept([".multi", ".long"]);
+  const { animationInspector, panel } = await openAnimationInspector();
+
+  info("Check selecting an animated node by clicking on the target node");
+  await clickOnTargetNode(animationInspector, panel, 0);
+  is(panel.querySelectorAll(".animation-target").length, 2,
+     "The length of animations should be 2, because .multi node has two animations");
+
+  info("Check to avoid reselecting the already selected node");
+  let isUpdated = false;
+  const listener = () => {
+    isUpdated = true;
+  };
+  animationInspector.on("animation-target-rendered", listener);
+  const targetEl = panel.querySelectorAll(".animation-target .objectBox")[0];
+  targetEl.scrollIntoView(false);
+  EventUtils.synthesizeMouseAtCenter(targetEl, {}, targetEl.ownerGlobal);
+  await wait(500);
+  ok(!isUpdated, "Components should not have updated");
+  animationInspector.off("animation-target-rendered", listener);
+});