var gPopupTests = null; var gTestIndex = -1; var gTestStepIndex = 0; var gTestEventIndex = 0; var gActualEvents = []; var gAutoHide = false; var gExpectedEventDetails = null; var gExpectedTriggerNode = null; var gWindowUtils; var gPopupWidth = -1,
gPopupHeight = -1;
if (!window.opener && window.arguments) {
window.opener = window.arguments[0];
}
function finish() { if (window.opener) {
window.close();
window.opener.SimpleTest.finish(); return;
}
SimpleTest.finish();
}
function ok(condition, message) { if (window.opener) {
window.opener.SimpleTest.ok(condition, message);
} else {
SimpleTest.ok(condition, message);
}
}
function info(message) { if (window.opener) {
window.opener.SimpleTest.info(message);
} else {
SimpleTest.info(message);
}
}
function is(left, right, message) { if (window.opener) {
window.opener.SimpleTest.is(left, right, message);
} else {
SimpleTest.is(left, right, message);
}
}
function disableNonTestMouse(aDisable) {
gWindowUtils.disableNonTestMouseEvents(aDisable);
}
function eventOccurred(event) { if (gPopupTests.length <= gTestIndex) {
ok(false, "Extra " + event.type + " event fired"); return;
}
var test = gPopupTests[gTestIndex]; if ("autohide" in test && gAutoHide) { if (event.type == "DOMMenuInactive") {
gAutoHide = false;
setTimeout(goNextStep, 0);
} return;
}
var events = test.events; if (typeof events == "function") {
events = events();
} if (events) { if (events.length <= gTestEventIndex) {
ok( false, "Extra " +
event.type + " event fired for " +
event.target.id + " " +
gPopupTests[gTestIndex].testname
); return;
}
var step = null; var test = gPopupTests[gTestIndex]; if ("steps" in test) {
gTestStepIndex++;
step = test.steps[gTestStepIndex]; if (gTestStepIndex < test.steps.length) {
test.test(test.testname, step); return;
}
}
goNext();
}
function goNext() { // We want to continue after the next animation frame so that // we're in a stable state and don't get spurious mouse events at unexpected targets.
window.requestAnimationFrame(function () {
setTimeout(goNextStepSync, 0);
});
}
function goNextStepSync() { if (
gTestIndex >= 0 && "end" in gPopupTests[gTestIndex] &&
gPopupTests[gTestIndex].end
) {
finish(); return;
}
gTestIndex++;
gTestStepIndex = 0; if (gTestIndex < gPopupTests.length) { var test = gPopupTests[gTestIndex]; // Set the location hash so it's easy to see which test is running
document.location.hash = test.testname;
info("Starting " + test.testname);
// skip the test if the condition returns false if ("condition" in test && !test.condition()) {
goNext(); return;
}
// start with the first step if there are any var step = null; if ("steps" in test) {
step = test.steps[gTestStepIndex];
}
test.test(test.testname, step);
// no events to check for so just check the result if (!("events" in test)) {
checkResult();
} elseif (typeof test.events == "function" && !test.events().length) {
checkResult();
}
} else {
finish();
}
}
function openMenu(menu) { if ("open" in menu) {
menu.open = true;
} elseif (menu.hasMenu()) {
menu.openMenu(true);
} else {
synthesizeMouse(menu, 4, 4, {});
}
}
function closeMenu(menu, popup) { if ("open" in menu) {
menu.open = false;
} elseif (menu.hasMenu()) {
menu.openMenu(false);
} else {
popup.hidePopup();
}
}
function checkActive(popup, id, testname) { var activeok = true; var children = popup.childNodes; for (var c = 0; c < children.length; c++) { var child = children[c]; if (
(id == child.id && child.getAttribute(menuactiveAttribute) != "true") ||
(id != child.id && child.hasAttribute(menuactiveAttribute) != "")
) {
activeok = false; break;
}
}
ok(activeok, testname + " item " + (id ? id : "none") + " active");
}
function checkOpen(menuid, testname) { var menu = document.getElementById(menuid); if ("open" in menu) {
ok(menu.open, testname + " " + menuid + " menu is open");
} elseif (menu.hasMenu()) {
ok(
menu.getAttribute("open") == "true",
testname + " " + menuid + " menu is open"
);
}
}
function checkClosed(menuid, testname) { var menu = document.getElementById(menuid); if ("open" in menu) {
ok(!menu.open, testname + " " + menuid + " menu is open");
} elseif (menu.hasMenu()) {
ok(!menu.hasAttribute("open"), testname + " " + menuid + " menu is closed");
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.