Bug 988144 - UITour: Highlight effects don't occur if a highlight is moved to a different target with the same effect. r=Unfocused
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 26 Mar 2014 03:00:18 -0700
changeset 175335 9c128455092caad1d93a0734c046b7fe66e1fa5e
parent 175334 85244371da5db5c7be63f76249bcc31ecb82c572
child 175336 8b1a3307065af36d8c2f8ed8995e540b75a0eb34
push id5925
push usermozilla@noorenberghe.ca
push dateWed, 26 Mar 2014 10:00:56 +0000
treeherderfx-team@8b1a3307065a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersUnfocused
bugs988144
milestone31.0a1
Bug 988144 - UITour: Highlight effects don't occur if a highlight is moved to a different target with the same effect. r=Unfocused
browser/modules/UITour.jsm
browser/modules/test/browser_UITour.js
--- a/browser/modules/UITour.jsm
+++ b/browser/modules/UITour.jsm
@@ -812,16 +812,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();