Bug 988144 - UITour: Highlight effects don't occur if a highlight is moved to a different target with the same effect. r=Unfocused
--- 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();