Bug 988144 - UITour: Highlight effects don't occur if a highlight is moved to a different target with the same effect. r=Unfocused a=Sylvestre
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 26 Mar 2014 03:00:18 -0700
changeset 192354 80553357e2da86192ad9634812398d1d818c684c
parent 192353 b8da42fcc3021b8f77b7ad2b72562b98acf5e318
child 192355 4a0223fb8ac0fe0008d7b6c99a6c7d8fb1a75c4a
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersUnfocused, Sylvestre
bugs988144
milestone30.0a2
Bug 988144 - UITour: Highlight effects don't occur if a highlight is moved to a different target with the same effect. r=Unfocused a=Sylvestre
browser/modules/UITour.jsm
browser/modules/test/browser_UITour.js
--- a/browser/modules/UITour.jsm
+++ b/browser/modules/UITour.jsm
@@ -796,16 +796,19 @@ this.UITour = {
       let effect = aEffect;
       if (effect == "random") {
         // Exclude "random" from the randomly selected effects.
         let randomEffect = 1 + Math.floor(Math.random() * (this.highlightEffects.length - 1));
         if (randomEffect == this.highlightEffects.length)
           randomEffect--; // On the order of 1 in 2^62 chance of this happening.
         effect = this.highlightEffects[randomEffect];
       }
+      // Toggle the effect attribute to "none" and flush layout before setting it so the effect plays.
+      highlighter.setAttribute("active", "none");
+      aTargetEl.ownerDocument.defaultView.getComputedStyle(highlighter).animationName;
       highlighter.setAttribute("active", effect);
       highlighter.parentElement.setAttribute("targetName", aTarget.targetName);
       highlighter.parentElement.hidden = false;
 
       let targetRect = aTargetEl.getBoundingClientRect();
       let highlightHeight = targetRect.height;
       let highlightWidth = targetRect.width;
       let minDimension = Math.min(highlightHeight, highlightWidth);
--- a/browser/modules/test/browser_UITour.js
+++ b/browser/modules/test/browser_UITour.js
@@ -149,19 +149,30 @@ let tests = [
       gContentAPI.showHighlight("urlbar", "none");
       waitForHighlightWithEffect(highlight, "none", checkZoomEffect, "There should be no effect");
     }
     function checkZoomEffect() {
       gContentAPI.showHighlight("urlbar", "zoom");
       waitForHighlightWithEffect(highlight, "zoom", () => {
         let style = window.getComputedStyle(highlight);
         is(style.animationName, "uitour-zoom", "The animation-name should be uitour-zoom");
-        checkRandomEffect();
+        checkSameEffectOnDifferentTarget();
       }, "There should be a zoom effect");
     }
+    function checkSameEffectOnDifferentTarget() {
+      gContentAPI.showHighlight("appMenu", "wobble");
+      waitForHighlightWithEffect(highlight, "wobble", () => {
+        highlight.addEventListener("animationstart", function onAnimationStart(aEvent) {
+          highlight.removeEventListener("animationstart", onAnimationStart);
+          ok(true, "Animation occurred again even though the effect was the same");
+          checkRandomEffect();
+        });
+        gContentAPI.showHighlight("backForward", "wobble");
+      }, "There should be a wobble effect");
+    }
     function checkRandomEffect() {
       function waitForActiveHighlight(highlightEl, next, error) {
         return waitForCondition(() => highlightEl.hasAttribute("active"),
                                 next,
                                 error);
       }
 
       gContentAPI.hideHighlight();