Bug 956202 - split off UITour checking functions, r=Unfocused

This commit is contained in:
Gijs Kruitbosch 2014-01-09 21:53:22 +00:00
parent c5aa6552b3
commit 5b5e2949d6
2 changed files with 45 additions and 45 deletions

View File

@ -8,51 +8,6 @@ let gContentAPI;
Components.utils.import("resource:///modules/UITour.jsm");
function is_hidden(element) {
var style = element.ownerDocument.defaultView.getComputedStyle(element, "");
if (style.display == "none")
return true;
if (style.visibility != "visible")
return true;
if (style.display == "-moz-popup")
return ["hiding","closed"].indexOf(element.state) != -1;
// Hiding a parent element will hide all its children
if (element.parentNode != element.ownerDocument)
return is_hidden(element.parentNode);
return false;
}
function is_element_visible(element, msg) {
isnot(element, null, "Element should not be null, when checking visibility");
ok(!is_hidden(element), msg);
}
function waitForElementToBeVisible(element, nextTest, msg) {
waitForCondition(() => !is_hidden(element),
() => {
ok(true, msg);
nextTest();
},
"Timeout waiting for visibility: " + msg);
}
function waitForPopupAtAnchor(popup, anchorNode, nextTest, msg) {
waitForCondition(() => popup.popupBoxObject.anchorNode == anchorNode,
() => {
ok(true, msg);
is_element_visible(popup);
nextTest();
},
"Timeout waiting for popup at anchor: " + msg);
}
function is_element_hidden(element, msg) {
isnot(element, null, "Element should not be null, when checking visibility");
ok(is_hidden(element), msg);
}
function loadTestPage(callback, host = "https://example.com/") {
if (gTestTab)
gBrowser.removeTab(gTestTab);

View File

@ -22,3 +22,48 @@ function waitForCondition(condition, nextTest, errorMsg) {
}, 100);
var moveOn = function() { clearInterval(interval); nextTest(); };
}
function is_hidden(element) {
var style = element.ownerDocument.defaultView.getComputedStyle(element, "");
if (style.display == "none")
return true;
if (style.visibility != "visible")
return true;
if (style.display == "-moz-popup")
return ["hiding","closed"].indexOf(element.state) != -1;
// Hiding a parent element will hide all its children
if (element.parentNode != element.ownerDocument)
return is_hidden(element.parentNode);
return false;
}
function is_element_visible(element, msg) {
isnot(element, null, "Element should not be null, when checking visibility");
ok(!is_hidden(element), msg);
}
function waitForElementToBeVisible(element, nextTest, msg) {
waitForCondition(() => !is_hidden(element),
() => {
ok(true, msg);
nextTest();
},
"Timeout waiting for visibility: " + msg);
}
function waitForPopupAtAnchor(popup, anchorNode, nextTest, msg) {
waitForCondition(() => popup.popupBoxObject.anchorNode == anchorNode,
() => {
ok(true, msg);
is_element_visible(popup);
nextTest();
},
"Timeout waiting for popup at anchor: " + msg);
}
function is_element_hidden(element, msg) {
isnot(element, null, "Element should not be null, when checking visibility");
ok(is_hidden(element), msg);
}