Bug 958687 - Fixes pseudo-class lock in highlighter intermittent test failure; r=jwalker
This commit is contained in:
@@ -54,7 +54,7 @@ function selectNode(aInspector)
|
||||
inspector.sidebar.once("ruleview-ready", function() {
|
||||
ruleview = inspector.sidebar.getWindowForTab("ruleview").ruleview.view;
|
||||
inspector.sidebar.select("ruleview");
|
||||
inspector.selection.setNode(div);
|
||||
inspector.selection.setNode(div, "test");
|
||||
inspector.once("inspector-updated", performTests);
|
||||
});
|
||||
}
|
||||
@@ -95,21 +95,21 @@ function performTests()
|
||||
|
||||
function testNavigate(callback)
|
||||
{
|
||||
inspector.selection.setNode(parentDiv);
|
||||
inspector.selection.setNode(parentDiv, "test");
|
||||
inspector.once("inspector-updated", () => {
|
||||
|
||||
// make sure it's still on after naving to parent
|
||||
is(DOMUtils.hasPseudoClassLock(div, pseudo), true,
|
||||
"pseudo-class lock is still applied after inspecting ancestor");
|
||||
|
||||
inspector.selection.setNode(div2);
|
||||
inspector.selection.setNode(div2, "test");
|
||||
inspector.selection.once("pseudoclass", () => {
|
||||
// make sure it's removed after naving to a non-hierarchy node
|
||||
is(DOMUtils.hasPseudoClassLock(div, pseudo), false,
|
||||
"pseudo-class lock is removed after inspecting sibling node");
|
||||
|
||||
// toggle it back on
|
||||
inspector.selection.setNode(div);
|
||||
inspector.selection.setNode(div, "test");
|
||||
inspector.once("inspector-updated", () => {
|
||||
inspector.togglePseudoClass(pseudo);
|
||||
inspector.once("computed-view-refreshed", callback);
|
||||
@@ -144,7 +144,7 @@ function testAdded(cb)
|
||||
// infobar selector contains pseudo-class
|
||||
let pseudoClassesBox = getHighlighter().querySelector(".highlighter-nodeinfobar-pseudo-classes");
|
||||
is(pseudoClassesBox.textContent, pseudo, "pseudo-class in infobar selector");
|
||||
cb();
|
||||
inspector.toolbox.highlighter.hideBoxModel().then(cb);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ function testRemovedFromUI(cb)
|
||||
showPickerOn(div, () => {
|
||||
let pseudoClassesBox = getHighlighter().querySelector(".highlighter-nodeinfobar-pseudo-classes");
|
||||
is(pseudoClassesBox.textContent, "", "pseudo-class removed from infobar selector");
|
||||
cb();
|
||||
inspector.toolbox.highlighter.hideBoxModel().then(cb);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -282,6 +282,23 @@ MarkupView.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Given the known reason, should the current selection be briefly highlighted
|
||||
* In a few cases, we don't want to highlight the node:
|
||||
* - If the reason is null (used to reset the selection),
|
||||
* - if it's "inspector-open" (when the inspector opens up, let's not highlight
|
||||
* the default node)
|
||||
* - if it's "navigateaway" (since the page is being navigated away from)
|
||||
* - if it's "test" (this is a special case for mochitest. In tests, we often
|
||||
* need to select elements but don't necessarily want the highlighter to come
|
||||
* and go after a delay as this might break test scenarios)
|
||||
*/
|
||||
_shouldNewSelectionBeHighlighted: function() {
|
||||
let reason = this._inspector.selection.reason;
|
||||
let unwantedReasons = ["inspector-open", "navigateaway", "test"];
|
||||
return reason && unwantedReasons.indexOf(reason) === -1;
|
||||
},
|
||||
|
||||
/**
|
||||
* Highlight the inspector selected node.
|
||||
*/
|
||||
@@ -291,8 +308,7 @@ MarkupView.prototype = {
|
||||
this.htmlEditor.hide();
|
||||
let done = this._inspector.updating("markup-view");
|
||||
if (selection.isNode()) {
|
||||
let reason = selection.reason;
|
||||
if (reason && reason !== "inspector-open" && reason !== "navigateaway") {
|
||||
if (this._shouldNewSelectionBeHighlighted()) {
|
||||
this._brieflyShowBoxModel(selection.nodeFront, {
|
||||
scrollIntoView: true
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user