Bug 1656291 - Enable all ESLint rules for remaining xhtml files in toolkit/content/tests/chrome/. r=Standard8

Depends on D87183

Differential Revision: https://phabricator.services.mozilla.com/D87961
This commit is contained in:
Sonia Singla 2020-09-07 12:57:10 +00:00
Родитель d4ff3ccf97
Коммит 6a17dca89f
43 изменённых файлов: 383 добавлений и 497 удалений

Просмотреть файл

@ -562,85 +562,6 @@ module.exports = {
"object-shorthand": "off",
},
},
{
files: [
"toolkit/content/tests/chrome/test_menulist_keynav.xhtml",
"toolkit/content/tests/chrome/test_mousescroll.xhtml",
"toolkit/content/tests/chrome/test_mozinputbox_dictionary.xhtml",
"toolkit/content/tests/chrome/test_notificationbox.xhtml",
"toolkit/content/tests/chrome/test_panel_focus.xhtml",
"toolkit/content/tests/chrome/test_popup_keys.xhtml",
"toolkit/content/tests/chrome/test_popup_scaled.xhtml",
"toolkit/content/tests/chrome/test_popupincontent.xhtml",
"toolkit/content/tests/chrome/test_popupremoving.xhtml",
"toolkit/content/tests/chrome/test_popupremoving_frame.xhtml",
"toolkit/content/tests/chrome/test_position.xhtml",
"toolkit/content/tests/chrome/test_preferences.xhtml",
"toolkit/content/tests/chrome/test_richlistbox.xhtml",
"toolkit/content/tests/chrome/test_righttoleft.xhtml",
"toolkit/content/tests/chrome/test_screenPersistence.xhtml",
"toolkit/content/tests/chrome/test_scrollbar.xhtml",
"toolkit/content/tests/chrome/test_showcaret.xhtml",
"toolkit/content/tests/chrome/test_tabbox.xhtml",
"toolkit/content/tests/chrome/test_textbox_search.xhtml",
"toolkit/content/tests/chrome/test_tree_view.xhtml",
"toolkit/content/tests/chrome/window_browser_drop.xhtml",
"toolkit/content/tests/chrome/window_cursorsnap_dialog.xhtml",
"toolkit/content/tests/chrome/window_cursorsnap_wizard.xhtml",
"toolkit/content/tests/chrome/window_keys.xhtml",
"toolkit/content/tests/chrome/window_largemenu.xhtml",
"toolkit/content/tests/chrome/window_panel.xhtml",
"toolkit/content/tests/chrome/window_panel_anchoradjust.xhtml",
"toolkit/content/tests/chrome/window_popup_preventdefault_chrome.xhtml",
"toolkit/content/tests/chrome/window_preferences.xhtml",
"toolkit/content/tests/chrome/window_preferences3.xhtml",
"toolkit/content/tests/chrome/window_preferences_beforeaccept.xhtml",
"toolkit/content/tests/chrome/window_preferences_commandretarget.xhtml",
"toolkit/content/tests/chrome/window_preferences_disabled.xhtml",
"toolkit/content/tests/chrome/window_preferences_onsyncfrompreference.xhtml",
"toolkit/content/tests/chrome/window_subframe_origin.xhtml",
"toolkit/content/tests/chrome/window_titlebar.xhtml",
"toolkit/content/tests/chrome/window_tooltip.xhtml",
"toolkit/content/tests/widgets/test_contextmenu_menugroup.xhtml",
"toolkit/content/tests/widgets/test_contextmenu_nested.xhtml",
"toolkit/content/tests/widgets/test_editor_currentURI.xhtml",
"toolkit/content/tests/widgets/test_popupanchor.xhtml",
"toolkit/content/tests/widgets/test_popupreflows.xhtml",
"toolkit/content/tests/widgets/window_menubar.xhtml",
"toolkit/modules/tests/chrome/test_bug544442_checkCert.xhtml",
"toolkit/profile/test/test_create_profile.xhtml",
],
rules: {
"object-shorthand": "off",
"consistent-return": "off",
"mozilla/consistent-if-bracing": "off",
"mozilla/no-compare-against-boolean-literals": "off",
"mozilla/no-useless-parameters": "off",
"mozilla/no-useless-removeEventListener": "off",
"mozilla/prefer-boolean-length-check": "off",
"mozilla/use-cc-etc": "off",
"mozilla/use-chromeutils-generateqi": "off",
"mozilla/use-chromeutils-import": "off",
"mozilla/use-default-preference-values": "off",
"mozilla/use-services": "off",
"no-caller": "off",
"no-else-return": "off",
"no-eval": "off",
"no-fallthrough": "off",
"no-irregular-whitespace": "off",
"no-lonely-if": "off",
"no-nested-ternary": "off",
"no-redeclare": "off",
"no-sequences": "off",
"no-shadow": "off",
"no-throw-literal": "off",
"no-undef": "off",
"no-unneeded-ternary": "off",
"no-unused-vars": "off",
"no-useless-concat": "off",
"no-useless-return": "off",
},
},
{
files: [
"accessible/**",

Просмотреть файл

@ -138,9 +138,8 @@ function differentPressed()
gOpenPhase = true;
list.addEventListener("popupshown", function popupShownListener() {
list.removeEventListener("popupshown", popupShownListener, false);
pressLetter();
}, false);
}, { once: true});
list.open = true;
}
@ -199,7 +198,7 @@ function keyCheck(list, key, index, defaultindex, testname)
var defaultitem = $("i" + defaultindex || 1);
synthesizeKeyExpectEvent(key, { }, item, expectCommandEvent ? "command" : "!command", testname);
is(list.selectedItem, expectCommandEvent ? item : defaultitem, testname + " selectedItem" + "----" + list.selectedItem.id);
is(list.selectedItem, expectCommandEvent ? item : defaultitem, testname + " selectedItem----" + list.selectedItem.id);
}
function checkModifiers(event)
@ -214,8 +213,8 @@ function checkModifiers(event)
function checkEnter()
{
list.addEventListener("popuphidden", checkEnterWithModifiers, false);
list.addEventListener("command", checkModifiers, false);
list.addEventListener("popuphidden", checkEnterWithModifiers);
list.addEventListener("command", checkModifiers);
list.open = true;
synthesizeKey("KEY_Enter");
}
@ -225,9 +224,9 @@ function checkEnterWithModifiers()
is(gModifiers, 1, "modifiers checked when not set");
ok(!list.open, "list closed on enter press");
list.removeEventListener("popuphidden", checkEnterWithModifiers, false);
list.removeEventListener("popuphidden", checkEnterWithModifiers);
list.addEventListener("popuphidden", verifyPopupOnClose, false);
list.addEventListener("popuphidden", verifyPopupOnClose);
list.open = true;
synthesizeKey("KEY_Enter", {shiftKey: true, ctrlKey: true, altKey: true, metaKey: true});
@ -238,7 +237,7 @@ function verifyPopupOnClose()
is(gModifiers, 2, "modifiers checked when set");
ok(!list.open, "list closed on enter press with modifiers");
list.removeEventListener("popuphidden", verifyPopupOnClose, false);
list.removeEventListener("popuphidden", verifyPopupOnClose);
list = $("list2");
list.focus();
@ -251,7 +250,7 @@ function checkCursorNavigation()
list.addEventListener("command", event => {
is(event.target, list.selectedItem, "command event fired on selected item");
commandEventsCount++;
}, false);
});
is(list.selectedIndex, 1, "selectedIndex before cursor down");
synthesizeKey("KEY_ArrowDown");

Просмотреть файл

@ -156,7 +156,7 @@ function* testArrowScrollbox(id)
var orientIsHorizontal = (orient == "horizontal");
scrollbox.scrollTo(aStart, aStart);
for (var i = orientIsHorizontal ? 2 : 0; i >= 0; i--) {
for (let i = orientIsHorizontal ? 2 : 0; i >= 0; i--) {
// Note, vertical mouse scrolling is allowed to scroll horizontal
// arrowscrollboxes, because many users have no horizontal mouse scroll
// capability
@ -189,7 +189,7 @@ function* testArrowScrollbox(id)
}
scrollbox.scrollTo(aStart, aStart);
for (var i = orientIsHorizontal ? 2 : 0; i >= 0; i--) {
for (let i = orientIsHorizontal ? 2 : 0; i >= 0; i--) {
// horizontal mouse scrolling is never allowed to scroll vertical
// arrowscrollboxes
let expected = (!i && orientIsHorizontal) ? aExpected : aStart;

Просмотреть файл

@ -79,7 +79,7 @@ function runContextMenuTest()
var undoAddDict = inputBox.getMenuItem("spell-undo-add-to-dictionary");
ok(!undoAddDict.hidden, "Is Undo Add to Dictioanry visible?");
var separator = inputBox.getMenuItem("spell-suggestions-separator");
separator = inputBox.getMenuItem("spell-suggestions-separator");
ok(!separator.hidden, "Is separator hidden?");
undoAddDict.doCommand();

Просмотреть файл

@ -79,14 +79,14 @@ function testtag_notification_eventCallback(expectedEvents, ntf, testName)
var tests =
[
{
test: function(nb, ntf) {
test(nb, ntf) {
// append a new notification
var ntf = nb.appendNotification("Notification", "note", "happy.png",
ntf = nb.appendNotification("Notification", "note", "happy.png",
nb.PRIORITY_INFO_LOW, testtag_notificationbox_buttons);
SimpleTest.is(ntf && ntf.localName == "notification", true, "append notification");
return ntf;
},
result: function(nb, ntf) {
result(nb, ntf) {
testtag_notificationbox_State(nb, "append", ntf, 1);
testtag_notification_State(nb, ntf, "append", "Notification", "note",
"happy.png", nb.PRIORITY_INFO_LOW);
@ -101,36 +101,36 @@ var tests =
}
},
{
test: function(nb, ntf) {
test(nb, ntf) {
// check that notifications can be removed properly
nb.removeNotification(ntf);
return ntf;
},
result: function(nb, ntf) {
result(nb, ntf) {
testtag_notificationbox_State(nb, "removeNotification", null, 0);
}
},
{
test: function(nb, ntf) {
test(nb, ntf) {
// append a new notification, but now with an event callback
var ntf = nb.appendNotification("Notification", "note", "happy.png",
ntf = nb.appendNotification("Notification", "note", "happy.png",
nb.PRIORITY_INFO_LOW,
testtag_notificationbox_buttons,
notification_eventCallback);
SimpleTest.is(ntf && ntf.localName == "notification", true, "append notification with callback");
return ntf;
},
result: function(nb, ntf) {
result(nb, ntf) {
testtag_notificationbox_State(nb, "append with callback", ntf, 1);
return ntf;
}
},
{
test: function(nb, ntf) {
test(nb, ntf) {
nb.removeNotification(ntf);
return ntf;
},
result: function(nb, ntf) {
result(nb, ntf) {
testtag_notificationbox_State(nb, "removeNotification with callback",
null, 0);
@ -139,28 +139,28 @@ var tests =
}
},
{
test: function(nb, ntf) {
var ntf = nb.appendNotification("Notification", "note", "happy.png",
test(nb, ntf) {
ntf = nb.appendNotification("Notification", "note", "happy.png",
nb.PRIORITY_INFO_LOW,
testtag_notificationbox_buttons,
notification_eventCallback);
SimpleTest.is(ntf && ntf.localName == "notification", true, "append notification with callback");
return ntf;
},
result: function(nb, ntf) {
result(nb, ntf) {
testtag_notificationbox_State(nb, "append with callback", ntf, 1);
return ntf;
}
},
{
test: function(rb, ntf) {
test(rb, ntf) {
// Dismissing the notification instead of removing it should
// fire a dismissed "event" on the callback, followed by
// a removed "event".
ntf.dismiss();
return ntf;
},
result: function(nb, ntf) {
result(nb, ntf) {
testtag_notificationbox_State(nb, "called dismiss()", null, 0);
testtag_notification_eventCallback(["dismissed", "removed"], ntf,
"dismiss()");
@ -168,7 +168,7 @@ var tests =
}
},
{
test: function(nb, ntf) {
test(nb, ntf) {
ntf = nb.appendNotification(
"Notification", "note", "happy.png",
nb.PRIORITY_WARNING_LOW,
@ -179,7 +179,7 @@ var tests =
return ntf;
},
result: function(nb, ntf) {
result(nb, ntf) {
testtag_notificationbox_State(nb, "append", ntf, 1);
testtag_notification_State(nb, ntf, "append", "Notification", "note",
"happy.png", nb.PRIORITY_WARNING_LOW);
@ -190,7 +190,7 @@ var tests =
},
{
repeat: true,
test: function(nb, arr) {
test(nb, arr) {
var idx = arr[0];
var ntf = arr[1];
switch (idx) {
@ -210,8 +210,9 @@ var tests =
return [idx, ntf];
}
return ntf;
},
result: function(nb, arr) {
result(nb, arr) {
var idx = arr[0];
var ntf = arr[1];
switch (idx) {
@ -234,17 +235,18 @@ var tests =
this.repeat = false;
}
return ntf;
}
},
{
test: function(nb, ntf) {
test(nb, ntf) {
// append another notification
var ntf = nb.appendNotification("Notification", "note", "happy.png",
ntf = nb.appendNotification("Notification", "note", "happy.png",
nb.PRIORITY_INFO_MEDIUM, testtag_notificationbox_buttons);
SimpleTest.is(ntf && ntf.localName == "notification", true, "append notification again");
return ntf;
},
result: function(nb, ntf) {
result(nb, ntf) {
// check that appending a second notification after removing the first one works
testtag_notificationbox_State(nb, "append again", ntf, 1);
testtag_notification_State(nb, ntf, "append again", "Notification", "note",
@ -253,22 +255,22 @@ var tests =
}
},
{
test: function(nb, ntf) {
test(nb, ntf) {
// check the removeCurrentNotification method
nb.removeCurrentNotification();
return ntf;
},
result: function(nb, ntf) {
result(nb, ntf) {
testtag_notificationbox_State(nb, "removeCurrentNotification", null, 0);
}
},
{
test: function(nb, ntf) {
var ntf = nb.appendNotification("Notification", "note", "happy.png",
test(nb, ntf) {
ntf = nb.appendNotification("Notification", "note", "happy.png",
nb.PRIORITY_INFO_HIGH, testtag_notificationbox_buttons);
return ntf;
},
result: function(nb, ntf) {
result(nb, ntf) {
// test the removeAllNotifications method
testtag_notificationbox_State(nb, "append info_high", ntf, 1);
SimpleTest.is(ntf.priority, nb.PRIORITY_INFO_HIGH,
@ -277,7 +279,7 @@ var tests =
}
},
{
test: function(nb, unused) {
test(nb, unused) {
// add a number of notifications and check that they are added in order
nb.appendNotification("Four", "4", null, nb.PRIORITY_INFO_HIGH, testtag_notificationbox_buttons);
nb.appendNotification("Seven", "7", null, nb.PRIORITY_WARNING_HIGH, testtag_notificationbox_buttons);
@ -291,7 +293,7 @@ var tests =
nb.appendNotification("Three", "3", null, nb.PRIORITY_INFO_MEDIUM, null);
return ntf;
},
result: function(nb, ntf) {
result(nb, ntf) {
is(nb.currentNotification, ntf, "appendNotification last notification");
is(nb.currentNotification.getAttribute("value"), "10", "appendNotification order");
return 1;
@ -300,7 +302,7 @@ var tests =
{
// test closing notifications to make sure that the current notification is still set properly
repeat: true,
test: function(nb, testidx) {
test(nb, testidx) {
switch (testidx) {
case 1:
nb.getNotificationWithValue("10").close();
@ -321,8 +323,9 @@ var tests =
nb.removeCurrentNotification();
return [6, 4];
}
return testidx;
},
result: function(nb, arr) {
result(nb, arr) {
// arr is [testindex, expectedvalue]
is(nb.currentNotification.getAttribute("value"), "" + arr[1], "close order " + arr[0]);
is(nb.allNotifications.length, 10 - arr[0], "close order " + arr[0] + " count");
@ -332,7 +335,7 @@ var tests =
}
},
{
test: function(nb, ntf) {
test(nb, ntf) {
var exh = false;
try {
nb.appendNotification("no", "no", "no", 0, null);
@ -353,23 +356,23 @@ var tests =
var appendPriorityTests = [
{
test: function(nb, priority) {
test(nb, priority) {
var ntf = nb.appendNotification("Notification", "note", "happy.png",
priority, testtag_notificationbox_buttons);
SimpleTest.is(ntf && ntf.localName == "notification", true, "append notification " + priority);
return [ntf, priority];
},
result: function(nb, obj) {
result(nb, obj) {
SimpleTest.is(obj[0].priority, obj[1], "notification.priority " + obj[1]);
return obj[1];
}
},
{
test: function(nb, priority) {
test(nb, priority) {
nb.removeCurrentNotification();
return priority;
},
result: function(nb, priority) {
result(nb, priority) {
if (priority == nb.PRIORITY_CRITICAL_HIGH) {
let ntf = nb.appendNotification("Notification", "note", "happy.png",
nb.PRIORITY_INFO_LOW, testtag_notificationbox_buttons);
@ -420,9 +423,9 @@ function testtag_notification_State(nb, ntf, testid, label, value, image, priori
function checkPopupTest(nb, ntf)
{
if (nb._animating)
if (nb._animating) {
setTimeout(checkPopupTest, ntf);
else {
} else {
var evt = new Event("");
ntf.dispatchEvent(evt);
evt.target.buttonInfo = testtag_notificationbox_buttons[0];

Просмотреть файл

@ -38,9 +38,8 @@ var gKeyPressCount = 0;
function waitForEvent(target, eventName) {
return new Promise(resolve => {
target.addEventListener(eventName, function eventOccurred(event) {
target.removeEventListener(eventName, eventOccurred, false);
resolve();
}, false);
}, { once: true});
});
}

Просмотреть файл

@ -71,6 +71,7 @@ function nextTest()
else {
screenTest = true;
var rootElement = document.documentElement;
let x, y;
// - the iframe is at 4×, but out here css pixels are only 2× device pixels
// - the popup manager rounds off (or truncates) the coordinates to

Просмотреть файл

@ -67,13 +67,13 @@ function nextTest()
step = "large menu";
popup.removeAttribute("left");
popup.removeAttribute("top");
for (var i = 0; i < 80; i++)
for (let i = 0; i < 80; i++)
menu.appendItem("Test", "");
synthesizeMouse(menu, 2, 2, { });
break;
case "large menu":
step = "shorter menu again";
for (var i = 0; i < 80; i++)
for (let i = 0; i < 80; i++)
popup.lastChild.remove();
synthesizeMouse(menu, 2, 2, { });
break;

Просмотреть файл

@ -90,8 +90,8 @@
SimpleTest.waitForExplicitFinish();
var gKey = "";
gTriggerMutation = null;
gChangeMutation = null;
let gTriggerMutation = null;
let gChangeMutation = null;
function nextTest()
{

Просмотреть файл

@ -24,7 +24,7 @@ var gMenus = [];
function popupsOpened()
{
var framedoc = $("frame").contentDocument;
framedoc.addEventListener("DOMAttrModified", modified, false);
framedoc.addEventListener("DOMAttrModified", modified);
// this is the order in which the menus should be hidden (reverse of the
// order they were opened in). The second menu is removed during the
@ -61,7 +61,7 @@ function modified(event)
}
is(event.target, gMenus.shift(), event.target.id + " hidden");
if (gMenus.length == 0)
if (!gMenus.length)
SimpleTest.finish();
}

Просмотреть файл

@ -63,7 +63,6 @@ SimpleTest.waitForExplicitFinish();
function runTest()
{
var winwidth = document.documentElement.getBoundingClientRect().width;
var innerscroll = $("innerscroll").getBoundingClientRect().width;
var box1 = $("box1");
checkPosition("box1", box1, 0, 0, winwidth, 46);

Просмотреть файл

@ -12,8 +12,7 @@
<![CDATA[
SimpleTest.waitForExplicitFinish();
const kPref = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefBranch);
const kPref = SpecialPowers.Services.prefs;
// preference values, set 1
const kPrefValueSet1 =
@ -97,8 +96,11 @@
{
// read preference data via XPCOM
var result = CreateEmptyPrefValueSet();
// eslint-disable-next-line mozilla/use-default-preference-values
try {result.int = kPref.getIntPref ("tests.static_preference_int") } catch (ignored) {};
// eslint-disable-next-line mozilla/use-default-preference-values
try {result.bool = kPref.getBoolPref("tests.static_preference_bool") } catch (ignored) {};
// eslint-disable-next-line mozilla/use-default-preference-values
try {result.string = kPref.getCharPref("tests.static_preference_string")} catch (ignored) {};
try
{
@ -449,8 +451,8 @@
// - test deferred reset in child window
InitTestPrefs(true);
window.browsingContext.topChromeWindow.openDialog("window_preferences2.xhtml", "", "modal", RunResetPrefTest, false);
expected = kPrefValueSet1;
found = ReadPrefsFromSystem();
let expected = kPrefValueSet1;
let found = ReadPrefsFromSystem();
ok(found.int === expected.int, "instant reset deferred int" );
ok(found.bool === expected.bool, "instant reset deferred bool" );
ok(found.string === expected.string, "instant reset deferred string" );

Просмотреть файл

@ -67,7 +67,7 @@ function test_richlistbox()
richListBox.selectedItem = richListBox.firstChild;
richListBox.focus();
synthesizeKey("KEY_ArrowDown", {shiftKey: true}, window);
items = [richListBox.selectedItems[0],
let items = [richListBox.selectedItems[0],
richListBox.selectedItems[1]];
is(items[0], richListBox.firstChild, "The last element should still be selected");
is(items[1], richListBox.firstChild.nextSibling, "Both elements should now be selected");
@ -81,9 +81,8 @@ function test_richlistbox()
is(items[0], richListBox.firstChild, "The last element should still be selected");
is(items[1], richListBox.firstChild.nextSibling, "Both elements should now be selected");
richListBox.addEventListener("keypress", function(aEvent) {
richListBox.removeEventListener("keypress", arguments.callee, true);
aEvent.preventDefault();
}, true);
}, { useCapture: true, once: true });
richListBox.selectedIndex = 1;
sendKey("HOME");
is(richListBox.selectedIndex, 1, "A stopped event should return indexing to normal");

Просмотреть файл

@ -38,8 +38,7 @@
SimpleTest.waitForFocus(checkTest2, win);
}
function checkTest2() {
let runTime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
let runTime = SpecialPowers.Services.appinfo;
if (runTime.OS != "Linux") {
is(win.screenX, 80, "The window should be placed now at x=80px");
is(win.screenY, 80, "The window should be placed now at y=80px");

Просмотреть файл

@ -29,7 +29,7 @@
var scrollbarTester = {
scrollbar: null,
middlePref: false,
startTest: function() {
startTest() {
this.scrollbar = $("scroller");
this.middlePref = this.getMiddlePref();
var self = this;
@ -42,14 +42,13 @@ var scrollbarTester = {
});
SimpleTest.finish();
},
testThumbDragging: function(button, withAlt, withShift) {
testThumbDragging(button, withAlt, withShift) {
this.reset();
var x = 160; // on the right half of the thumb
var y = 5;
var isMac = navigator.platform.includes("Mac");
var runtime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
let runtime = SpecialPowers.Services.appinfo;
var isGtk = runtime.widgetToolkit.includes("gtk");
// Start the drag.
@ -67,7 +66,7 @@ var scrollbarTester = {
"thumb with the middle mouse button should center it "+
"around the cursor.")
}
// Move one pixel to the right.
this.mousemove(x+1, y, button, withAlt, withShift);
var newPos2 = this.getPos();
@ -76,16 +75,14 @@ var scrollbarTester = {
ok(newPos2 - newPos < 3, "Scrollbar shouldn't move further than the mouse when dragged.");
ok(button == 0 || (button == 1 && this.middlePref) || (button == 2 && isGtk),
"Dragging the scrollbar should only be possible with the left mouse button.");
} else {
} else if (button == 0) {
// Dragging had no effect.
if (button == 0) {
ok(false, "Dragging the scrollbar thumb should work.");
} else if (button == 1 && this.middlePref && (!isGtk && !isMac)) {
ok(false, "When middlemouse.scrollbarPosition is on, dragging the "+
"scrollbar thumb should be possible using the middle mouse button.");
} else {
ok(true, "Dragging works correctly.");
}
ok(false, "Dragging the scrollbar thumb should work.");
} else if (button == 1 && this.middlePref && (!isGtk && !isMac)) {
ok(false, "When middlemouse.scrollbarPosition is on, dragging the "+
"scrollbar thumb should be possible using the middle mouse button.");
} else {
ok(true, "Dragging works correctly.");
}
// Release the mouse button.
@ -94,33 +91,31 @@ var scrollbarTester = {
ok(newPos3 == newPos2,
"Releasing the mouse button after dragging the thumb shouldn't move it.");
},
getMiddlePref: function() {
getMiddlePref() {
// It would be better to test with different middlePref settings,
// but the setting is only queried once, at browser startup, so
// changing it here wouldn't have any effect
var prefService = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefService);
var mouseBranch = prefService.getBranch("middlemouse.");
var mouseBranch = SpecialPowers.Services.prefs.getBranch("middlemouse.");
return mouseBranch.getBoolPref("scrollbarPosition");
},
setPos: function(pos) {
setPos(pos) {
this.scrollbar.setAttribute("curpos", pos);
},
getPos: function() {
getPos() {
return this.scrollbar.getAttribute("curpos");
},
reset: function() {
reset() {
this.setPos(0);
},
mousedown: function(x, y, button, alt, shift) {
mousedown(x, y, button, alt, shift) {
synthesizeMouse(this.scrollbar, x, y, { type: "mousedown", 'button': button,
altKey: alt, shiftKey: shift });
},
mousemove: function(x, y, button, alt, shift) {
mousemove(x, y, button, alt, shift) {
synthesizeMouse(this.scrollbar, x, y, { type: "mousemove", 'button': button,
altKey: alt, shiftKey: shift });
},
mouseup: function(x, y, button, alt, shift) {
mouseup(x, y, button, alt, shift) {
synthesizeMouse(this.scrollbar, x, y, { type: "mouseup", 'button': button,
altKey: alt, shiftKey: shift });
}

Просмотреть файл

@ -34,15 +34,15 @@ function runTest()
var listener = function() {
if (!(frames[0].scrollY > 0)) {
window.content.removeEventListener("scroll", listener, false);
window.content.removeEventListener("scroll", listener);
}
}
window.frames[0].addEventListener("scroll", listener, false);
window.frames[0].addEventListener("scroll", listener);
var sel1 = frames[0].getSelection();
sel1 = frames[0].getSelection();
sel1.collapse(frames[0].document.body, 0);
var sel2 = frames[1].getSelection();
sel2 = frames[1].getSelection();
sel2.collapse(frames[1].document.body, 0);
window.frames[0].focus();
@ -60,16 +60,15 @@ function runTest()
ok(sel2.anchorOffset > 0, "focusOffset for showcaret");
otherWindow = window.browsingContext.topChromeWindow.open("window_showcaret.xhtml", "_blank", "chrome,width=400,height=200");
otherWindow.addEventListener("focus", otherWindowFocused, false);
otherWindow.addEventListener("focus", otherWindowFocused);
}
function otherWindowFocused()
{
otherWindow.removeEventListener("focus", otherWindowFocused, false);
otherWindow.removeEventListener("focus", otherWindowFocused);
// enable caret browsing temporarily to test caret movement
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
let prefs = SpecialPowers.Services.prefs;
prefs.setBoolPref("accessibility.browsewithcaret", true);
var hbox = otherWindow.document.documentElement.firstChild;

Просмотреть файл

@ -195,11 +195,10 @@ function test_tabbox_focus()
var textboxExtra = $("textbox-extra");
textboxExtra.addEventListener("focus", function () {
textboxExtra.removeEventListener("focus", arguments.callee, true);
is(document.activeElement, textboxExtra, "focus in tab with focus currently in textbox that is sibling of tabs");
SimpleTest.finish();
}, true);
}, {once: true});
tabbox.selectedIndex = 0;
textboxExtra.hidden = false;
@ -214,9 +213,8 @@ function test_tabbox_focus()
function when_tab_focused(tab, callback) {
tab.addEventListener("focus", function onFocused() {
tab.removeEventListener("focus", onFocused, true);
SimpleTest.executeSoon(callback);
}, true);
}, {once: true});
}
]]>

Просмотреть файл

@ -145,7 +145,7 @@ function doTests() {
gExpectedValue = false;
textbox.value = "foo";
iconClick(searchIcon);
ok(gExpectedValue == false, "search *not* triggered when clicking the search icon in search button mode while the textbox is disabled");
ok(!gExpectedValue, "search *not* triggered when clicking the search icon in search button mode while the textbox is disabled");
is(icons.selectedPanel, searchIcon, "search icon persists in search button mode when trying to submit while the textbox is disabled");
textbox.disabled = false;
ok(!searchIcon.hasAttribute("disabled"), "disabled attribute removed from the search icon");

Просмотреть файл

@ -13,7 +13,7 @@
<script>
<![CDATA[
/* import-globals-from ../widgets/tree_shared.js */
// This is our custom view, based on the treeview interface
var view =
{
@ -23,25 +23,25 @@ var view =
["John", "99 Westminster Avenue"]],
value: "",
rowCount: 8,
getCellText: function(row, column) { return this.treeData[row % 4][column.index]; },
getCellValue: function(row, column) { return this.value; },
setCellText: function(row, column, val) { this.treeData[row % 4][column.index] = val; },
setCellValue: function(row, column, val) { this.value = val; },
setTree: function(tree) { this.tree = tree; },
isContainer: function(row) { return false; },
isContainerOpen: function(row) { return false; },
isContainerEmpty: function(row) { return false; },
isSeparator: function(row) { return false; },
isSorted: function(row) { return false; },
isEditable: function(row, column) { return row != 2 || column.index != 1; },
getParentIndex: function(row, column) { return -1; },
getLevel: function(row) { return 0; },
hasNextSibling: function(row, column) { return row != this.rowCount - 1; },
getImageSrc: function(row, column) { return ""; },
cycleHeader: function(column) { },
getRowProperties: function(row) { return ""; },
getCellProperties: function(row, column) { return ""; },
getColumnProperties: function(column)
getCellText(row, column) { return this.treeData[row % 4][column.index]; },
getCellValue(row, column) { return this.value; },
setCellText(row, column, val) { this.treeData[row % 4][column.index] = val; },
setCellValue(row, column, val) { this.value = val; },
setTree(tree) { this.tree = tree; },
isContainer(row) { return false; },
isContainerOpen(row) { return false; },
isContainerEmpty(row) { return false; },
isSeparator(row) { return false; },
isSorted(row) { return false; },
isEditable(row, column) { return row != 2 || column.index != 1; },
getParentIndex(row, column) { return -1; },
getLevel(row) { return 0; },
hasNextSibling(row, column) { return row != this.rowCount - 1; },
getImageSrc(row, column) { return ""; },
cycleHeader(column) { },
getRowProperties(row) { return ""; },
getCellProperties(row, column) { return ""; },
getColumnProperties(column)
{
if (!column.index) {
return "one two";

Просмотреть файл

@ -60,7 +60,7 @@ async function expectLink(browser, expectedLinks, data, testid, onbody=false) {
let lastLinksPromise = new Promise(resolve => {
browser.droppedLinkHandler = function(event, links) {
info(`droppedLinkHandler called, received links ${JSON.stringify(links)}`);
if (expectedLinks.length == 0) {
if (!expectedLinks.length) {
ok(false, `droppedLinkHandler called for ${JSON.stringify(links)} which we didn't expect.`);
}
lastLinks = links;
@ -74,14 +74,14 @@ async function expectLink(browser, expectedLinks, data, testid, onbody=false) {
}
let links;
if (browser.isRemoteBrowser) {
let remoteLinks = await dropOnRemoteBrowserAsync(browser, data, expectedLinks.length != 0);
let remoteLinks = await dropOnRemoteBrowserAsync(browser, data, expectedLinks.length);
is(remoteLinks.length, expectedLinks.length, testid + " remote links length");
for (let i = 0, length = remoteLinks.length; i < length; i++) {
is(remoteLinks[i].url, expectedLinks[i].url, testid + "[" + i + "] remote link");
is(remoteLinks[i].name, expectedLinks[i].name, testid + "[" + i + "] remote name");
}
if (expectedLinks.length == 0) {
if (!expectedLinks.length) {
// There is no way to check if nothing happens asynchronously.
return;
}

Просмотреть файл

@ -42,17 +42,15 @@ var gRetry;
function finishByTimeout()
{
var button = document.getElementById("dialog").getButton("accept");
if (button.disabled)
if (button.disabled) {
ok(true, "cursor is NOT snapped to the disabled button (dialog)");
else if (button.hidden)
} else if (button.hidden) {
ok(true, "cursor is NOT snapped to the hidden button (dialog)");
else {
if (!canRetryTest()) {
ok(false, "cursor is NOT snapped to the default button (dialog)");
} else {
// otherwise, this may be unexpected timeout, we should retry the test.
gRetry = true;
}
} else if (!canRetryTest()) {
ok(false, "cursor is NOT snapped to the default button (dialog)");
} else {
// otherwise, this may be unexpected timeout, we should retry the test.
gRetry = true;
}
finish();
}
@ -78,7 +76,7 @@ function onMouseMove(aEvent)
function onload()
{
var button = document.getElementById("dialog").getButton("accept");
button.addEventListener("mousemove", onMouseMove, false);
button.addEventListener("mousemove", onMouseMove);
if (window.arguments[0].gDisable) {
button.disabled = true;

Просмотреть файл

@ -49,17 +49,15 @@ var gRetry = false;
function finishByTimeout()
{
var button = document.getElementById("wizard").getButton("next");
if (button.disabled)
if (button.disabled) {
ok(true, "cursor is NOT snapped to the disabled button (wizard)");
else if (button.hidden)
} else if (button.hidden) {
ok(true, "cursor is NOT snapped to the hidden button (wizard)");
else {
if (!canRetryTest()) {
ok(false, "cursor is NOT snapped to the default button (wizard)");
} else {
// otherwise, this may be unexpected timeout, we should retry the test.
gRetry = true;
}
} else if (!canRetryTest()) {
ok(false, "cursor is NOT snapped to the default button (wizard)");
} else {
// otherwise, this may be unexpected timeout, we should retry the test.
gRetry = true;
}
finish();
}
@ -85,7 +83,7 @@ function onMouseMove()
function onload()
{
var button = document.getElementById("wizard").getButton("next");
button.addEventListener("mousemove", onMouseMove, false);
button.addEventListener("mousemove", onMouseMove);
if (window.opener.wrappedJSObject.gDisable) {
button.disabled = true;

Просмотреть файл

@ -65,7 +65,7 @@ function runTest()
keyset.setAttribute("disabled", "true");
iterateKeys(false, "disabled");
var keyset = document.getElementById("keyset");
keyset = document.getElementById("keyset");
keyset.removeAttribute("disabled");
iterateKeys(true, "reenabled");

Просмотреть файл

@ -35,9 +35,9 @@ function getScreenXY(element)
}
// a hacky way to get the screen position of an element without using the box object
window.addEventListener("mousedown", mouseFn, false);
window.addEventListener("mousedown", mouseFn);
synthesizeMouse(element, 1, 1, { });
window.removeEventListener("mousedown", mouseFn, false);
window.removeEventListener("mousedown", mouseFn);
return [screenX, screenY];
}
@ -60,7 +60,7 @@ function runTests()
function nextTest()
{
gOverflowed = false, gUnderflowed = false;
gOverflowed = false; gUnderflowed = false;
var y = screen.height;
if (gTestIndex == 1) // open with bottom overlap test:
@ -158,7 +158,7 @@ function popupShown()
is(scrollbox.scrollTop, expectedScrollPos, "menu scroll position")
hidePopup();
return hidePopup();
}
function is(l, r, n) { window.arguments[0].SimpleTest.is(l,r,n); }
@ -227,8 +227,9 @@ function contextMenuPopupShown()
var labelrect = document.getElementById("label").getBoundingClientRect();
// Click to open popup in popupHidden() occurs at (4,4) in label's coordinate space
var clickX = clickY = 4;
var clickX = 4;
var clickY = 4;
var testPopupAppearedRightOfCursor = true;
switch (gTests[gTestIndex]) {
case "context menu enough space below":
@ -311,11 +312,10 @@ function nextContextMenuTest(desiredHeight)
function testPopupMovement()
{
var button = document.getElementById("label");
var isPanelTest = (gTests[gTestIndex] == "panel movement");
var popup = document.getElementById(isPanelTest ? "panel" : "popup");
var screenX, screenY, buttonScreenX, buttonScreenY;
var screenX, screenY;
var rect = popup.getBoundingClientRect();
var overlapOSChrome = !platformIsMac();

Просмотреть файл

@ -124,7 +124,7 @@ var tests = [
{
testname: "normal panel",
attrs: { },
test: function(panel) {
test(panel) {
var screenRect = panel.getOuterScreenRect();
is(screenRect.left, 0, this.testname + " screen left before open");
is(screenRect.top, 0, this.testname + " screen top before open");
@ -133,10 +133,10 @@ var tests = [
panel.openPopupAtScreen(200, 210);
},
result: function(testname, panel) {
result(testname, panel) {
var panelrect = panel.getBoundingClientRect();
is(panelrect.left, 200 - mozInnerScreenX, testname + "left");
is(panelrect.top, 210 - mozInnerScreenY, testname + "top");
is(panelrect.left, 200 - window.mozInnerScreenX, testname + "left");
is(panelrect.top, 210 - window.mozInnerScreenY, testname + "top");
is(panelrect.width, 120, testname + "width");
is(panelrect.height, 40, testname + "height");
@ -151,7 +151,7 @@ var tests = [
// only noautohide panels support titlebars, so one shouldn't be shown here
testname: "autohide panel with titlebar",
attrs: { titlebar: "normal" },
test: function(panel) {
test(panel) {
var screenRect = panel.getOuterScreenRect();
is(screenRect.left, 0, this.testname + " screen left before open");
is(screenRect.top, 0, this.testname + " screen top before open");
@ -160,10 +160,10 @@ var tests = [
panel.openPopupAtScreen(200, 210);
},
result: function(testname, panel) {
result(testname, panel) {
var panelrect = panel.getBoundingClientRect();
is(panelrect.left, 200 - mozInnerScreenX, testname + "left");
is(panelrect.top, 210 - mozInnerScreenY, testname + "top");
is(panelrect.left, 200 - window.mozInnerScreenX, testname + "left");
is(panelrect.top, 210 - window.mozInnerScreenY, testname + "top");
is(panelrect.width, 120, testname + "width");
is(panelrect.height, 40, testname + "height");
@ -177,7 +177,7 @@ var tests = [
{
testname: "noautohide panel with titlebar",
attrs: { noautohide: true, titlebar: "normal" },
test: function(panel) {
test(panel) {
waitSteps = 25;
var screenRect = panel.getOuterScreenRect();
@ -188,13 +188,13 @@ var tests = [
panel.openPopupAtScreen(200, 210);
},
result: function(testname, panel) {
result(testname, panel) {
var panelrect = panel.getBoundingClientRect();
ok(panelrect.left >= 200 - mozInnerScreenX, testname + "left");
ok(panelrect.left >= 200 - window.mozInnerScreenX, testname + "left");
if (!navigator.platform.includes("Linux")) {
ok(panelrect.top >= 210 - mozInnerScreenY + 10, testname + "top greater");
ok(panelrect.top >= 210 - window.mozInnerScreenY + 10, testname + "top greater");
}
ok(panelrect.top <= 210 - mozInnerScreenY + 36, testname + "top less");
ok(panelrect.top <= 210 - window.mozInnerScreenY + 36, testname + "top less");
is(panelrect.width, 120, testname + "width");
is(panelrect.height, 40, testname + "height");
@ -232,13 +232,13 @@ var tests = [
// The panel should be allowed to appear and remain offscreen
testname: "normal panel with flip='none' off-screen",
attrs: { "flip": "none" },
test: function(panel) {
panel.openPopup(document.documentElement, "", -100 - mozInnerScreenX, -100 - mozInnerScreenY, false, false, null);
test(panel) {
panel.openPopup(document.documentElement, "", -100 - window.mozInnerScreenX, -100 - window.mozInnerScreenY, false, false, null);
},
result: function(testname, panel) {
result(testname, panel) {
var panelrect = panel.getBoundingClientRect();
is(panelrect.left, -100 - mozInnerScreenX, testname + "left");
is(panelrect.top, -100 - mozInnerScreenY, testname + "top");
is(panelrect.left, -100 - window.mozInnerScreenX, testname + "left");
is(panelrect.top, -100 - window.mozInnerScreenY, testname + "top");
is(panelrect.width, 120, testname + "width");
is(panelrect.height, 40, testname + "height");
@ -253,18 +253,18 @@ var tests = [
// The panel should be allowed to remain offscreen after moving and it should follow the anchor
testname: "normal panel with flip='none' moved off-screen",
attrs: { "flip": "none" },
test: function(panel) {
panel.openPopup(document.documentElement, "", -100 - mozInnerScreenX, -100 - mozInnerScreenY, false, false, null);
test(panel) {
panel.openPopup(document.documentElement, "", -100 - window.mozInnerScreenX, -100 - window.mozInnerScreenY, false, false, null);
window.moveBy(-50, -50);
},
result: function(testname, panel) {
result(testname, panel) {
if (navigator.platform.includes("Linux")) {
// The window position doesn't get updated immediately on Linux.
return;
}
var panelrect = panel.getBoundingClientRect();
is(panelrect.left, -150 - mozInnerScreenX, testname + "left");
is(panelrect.top, -150 - mozInnerScreenY, testname + "top");
is(panelrect.left, -150 - window.mozInnerScreenX, testname + "left");
is(panelrect.top, -150 - window.mozInnerScreenY, testname + "top");
is(panelrect.width, 120, testname + "width");
is(panelrect.height, 40, testname + "height");

Просмотреть файл

@ -132,7 +132,7 @@ function runTests() {
await popupshown;
popuphidden = waitForPanel(panel, "popuphidden");
menupopuphidden = waitForPanel(menupopup, "popuphidden");
let menupopuphidden = waitForPanel(menupopup, "popuphidden");
menupopup.hidePopup();
await popuphidden;
await menupopuphidden;

Просмотреть файл

@ -16,8 +16,7 @@ var gBlockHiding = true;
var gShownNotAllowed = true;
var gHiddenNotAllowed = true;
var fm = Components.classes["@mozilla.org/focus-manager;1"].
getService(Components.interfaces.nsIFocusManager);
var fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
var is = function(l, r, v) { window.arguments[0].SimpleTest.is(l, r, v); }
var isnot = function(l, r, v) { window.arguments[0].SimpleTest.isnot(l, r, v); }

Просмотреть файл

@ -14,6 +14,7 @@
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript">
<![CDATA[
/* import-globals-from ../../preferencesBindings.js */
function RunTest(aArgs)
{
// run test

Просмотреть файл

@ -15,6 +15,7 @@
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript">
<![CDATA[
/* import-globals-from ../../preferencesBindings.js */
function RunTest(aArgs)
{
// run test

Просмотреть файл

@ -14,6 +14,7 @@
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript">
<![CDATA[
/* import-globals-from ../../preferencesBindings.js */
function onDialogLoad() {
document.addEventListener("beforeaccept", beforeAccept);
var pref = Preferences.get("tests.beforeaccept.dialogShown");
@ -24,7 +25,7 @@
}
function beforeAccept(event) {
var beforeAcceptPref = Preferences.get("tests.beforeaccept.called");
var beforeAcceptPref = window.Preferences.get("tests.beforeaccept.called");
var oldValue = beforeAcceptPref.value;
beforeAcceptPref.value = true;

Просмотреть файл

@ -15,6 +15,7 @@
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript">
<![CDATA[
/* import-globals-from ../../preferencesBindings.js */
function RunTest(aArgs)
{
aArgs[0](this);

Просмотреть файл

@ -15,6 +15,7 @@
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript">
<![CDATA[
/* import-globals-from ../../preferencesBindings.js */
function RunTest(aArgs)
{
aArgs[0](this);

Просмотреть файл

@ -19,7 +19,8 @@
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript">
<![CDATA[
Preferences.addAll([
/* import-globals-from ../../preferencesBindings.js */
Preferences.addAll([
{ id: "tests.onsyncfrompreference.pref1", type: "int" },
{ id: "tests.onsyncfrompreference.pref2", type: "int" },
{ id: "tests.onsyncfrompreference.pref3", type: "int" },

Просмотреть файл

@ -26,7 +26,6 @@ function runTests()
window.arguments[0].SimpleTest.waitForFocus(runTests, window);
function mouseMove(e) {
var element = e.target;
var el = document.getElementById("parentcap");
el.label = "client: (" + e.clientX + "," + e.clientY + ")";
window.arguments[0].SimpleTest.is(e.clientX, 1, "mouse event clientX");
@ -35,7 +34,7 @@ function mouseMove(e) {
frames[0].runTests();
}
window.addEventListener("mousemove",mouseMove, false);
window.addEventListener("mousemove",mouseMove);
</script>
</window>

Просмотреть файл

@ -103,7 +103,7 @@ function test_titlebar()
origoldy = window.screenY;
var mousedownListener = event => mouseDownTarget = event.originalTarget;
window.addEventListener("mousedown", mousedownListener, false);
window.addEventListener("mousedown", mousedownListener);
synthesizeMouse(label, 2, 2, { type: "mousedown" });
SimpleTest.is(mouseDownTarget, titlebar, "movedown on titlebar");
waitForWindowMove(label, 22, 22, test_titlebar_step2, mousedownListener);
@ -129,7 +129,7 @@ function test_titlebar_step2(mousedownListener)
SimpleTest.is(window.screenY, origoldy + 20, "mouse on label move window vertical");
synthesizeMouse(label, 22, 22, { type: "mouseup" });
window.removeEventListener("mousedown", mousedownListener, false);
window.removeEventListener("mousedown", mousedownListener);
document.getElementById("panel").openPopupAtScreen(window.screenX + 50, window.screenY + 60, false);
}
@ -207,13 +207,12 @@ function popuphidden(nextPopup)
var panel = document.getElementById(nextPopup);
if (panel.id == "panelnoautohide") {
panel.openPopupAtScreen(window.screenX + 50, window.screenY + 60, false);
}
else {
} else {
panel.openPopup(document.getElementById("button"), "after_start");
}
}
else
} else {
window.arguments[0].done(window);
}
}
]]>

Просмотреть файл

@ -27,7 +27,7 @@
<script class="testbody" type="application/javascript">
<![CDATA[
/* import-globals-from ../widgets/popup_shared.js */
var gOriginalWidth = -1;
var gOriginalHeight = -1;
var gButton = null;
@ -44,7 +44,6 @@ function checkCoords(event)
var mod = (gTestIndex == 5) ? 4 : 6;
var rect = gButton.getBoundingClientRect();
var popupstyle = window.getComputedStyle(gButton);
is(event.clientX, Math.round(rect.left + mod),
"step " + (gTestIndex + 1) + " clientX");
is(event.clientY, Math.round(rect.top + mod),
@ -57,7 +56,7 @@ var popupTests = [
{
testname: "hover tooltiptext attribute",
events: [ "popupshowing #tooltip", "popupshown #tooltip" ],
test: function() {
test() {
gButton = document.getElementById("withtext");
disableNonTestMouse(true);
synthesizeMouse(gButton, 2, 2, { type: "mouseover" });
@ -70,7 +69,7 @@ var popupTests = [
testname: "close tooltip",
events: [ "popuphiding #tooltip", "popuphidden #tooltip",
"DOMMenuInactive #tooltip" ],
test: function() {
test() {
disableNonTestMouse(true);
synthesizeMouse(document.documentElement, 2, 2, { type: "mousemove" });
disableNonTestMouse(false);
@ -79,7 +78,7 @@ var popupTests = [
{
testname: "hover inherited tooltip",
events: [ "popupshowing #tooltip", "popupshown #tooltip" ],
test: function() {
test() {
gButton = document.getElementById("without");
disableNonTestMouse(true);
synthesizeMouse(gButton, 2, 2, { type: "mouseover" });
@ -93,7 +92,7 @@ var popupTests = [
events: [ "popuphiding #tooltip", "popuphidden #tooltip",
"DOMMenuInactive #tooltip",
"popupshowing thetooltip", "popupshown thetooltip" ],
test: function() {
test() {
gButton = document.getElementById("withtooltip");
gExpectedTriggerNode = gButton;
disableNonTestMouse(true);
@ -102,7 +101,7 @@ var popupTests = [
synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
disableNonTestMouse(false);
},
result: function(testname) {
result(testname) {
var tooltip = document.getElementById("thetooltip");
gExpectedTriggerNode = null;
is(tooltip.triggerNode, gButton, testname + " triggerNode");
@ -139,11 +138,11 @@ var popupTests = [
testname: "click to close tooltip",
events: [ "popuphiding thetooltip", "popuphidden thetooltip",
"command withtooltip", "DOMMenuInactive thetooltip" ],
test: function() {
test() {
gButton = document.getElementById("withtooltip");
synthesizeMouse(gButton, 2, 2, { });
},
result: function(testname) {
result(testname) {
var tooltip = document.getElementById("thetooltip");
is(tooltip.triggerNode, null, testname + " triggerNode");
is(document.popupNode, null, testname + " document.popupNode");
@ -153,7 +152,7 @@ var popupTests = [
{
testname: "hover tooltip after size increased",
events: [ "popupshowing thetooltip", "popupshown thetooltip" ],
test: function() {
test() {
var label = document.getElementById("label");
label.removeAttribute("value");
label.textContent = "This is a longer tooltip than before\nIt has multiple lines\nIt is testing tooltip sizing\n";
@ -164,11 +163,10 @@ var popupTests = [
synthesizeMouse(gButton, 4, 4, { type: "mousemove" });
disableNonTestMouse(false);
},
result: function(testname) {
result(testname) {
var buttonrect = document.getElementById("withtooltip").getBoundingClientRect();
var rect = document.getElementById("thetooltip").getBoundingClientRect();
var popupstyle = window.getComputedStyle(document.getElementById("thetooltip"));
var buttonstyle = window.getComputedStyle(document.getElementById("withtooltip"));
is(Math.round(rect.left),
Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 4),
@ -191,7 +189,7 @@ var popupTests = [
testname: "close tooltip with hidePopup",
events: [ "popuphiding thetooltip", "popuphidden thetooltip",
"DOMMenuInactive thetooltip" ],
test: function() {
test() {
document.getElementById("thetooltip").hidePopup();
},
},
@ -199,7 +197,7 @@ var popupTests = [
testname: "hover tooltip after size decreased",
events: [ "popupshowing thetooltip", "popupshown thetooltip" ],
autohide: "thetooltip",
test: function() {
test() {
var label = document.getElementById("label");
label.value = "This is a tooltip";
gButton = document.getElementById("withtooltip");
@ -209,11 +207,10 @@ var popupTests = [
synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
disableNonTestMouse(false);
},
result: function(testname) {
result(testname) {
var buttonrect = document.getElementById("withtooltip").getBoundingClientRect();
var rect = document.getElementById("thetooltip").getBoundingClientRect();
var popupstyle = window.getComputedStyle(document.getElementById("thetooltip"));
var buttonstyle = window.getComputedStyle(document.getElementById("withtooltip"));
is(Math.round(rect.left),
Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 6),
@ -234,13 +231,13 @@ var popupTests = [
testname: "hover tooltip at bottom edge of screen",
events: [ "popupshowing thetooltip", "popupshown thetooltip" ],
autohide: "thetooltip",
condition: function() {
condition() {
// Only checking OSX here because on other platforms popups and tooltips behave the same way
// when there's not enough space to show them below (by flipping vertically)
// However, on OSX most popups are not flipped but tooltips are.
return navigator.platform.indexOf("Mac") > -1;
},
test: function() {
test() {
var buttonRect = document.getElementById("withtext").getBoundingClientRect();
var windowY = screen.height -
(window.mozInnerScreenY - window.screenY ) - buttonRect.bottom;
@ -254,7 +251,7 @@ var popupTests = [
disableNonTestMouse(false);
});
},
result: function(testname) {
result(testname) {
var buttonrect = document.getElementById("withtooltip").getBoundingClientRect();
var rect = document.getElementById("thetooltip").getBoundingClientRect();
var popupstyle = window.getComputedStyle(document.getElementById("thetooltip"));
@ -267,7 +264,7 @@ var popupTests = [
{
testname: "open tooltip for keyclose",
events: [ "popupshowing thetooltip", "popupshown thetooltip" ],
test: function() {
test() {
gButton = document.getElementById("withtooltip");
gExpectedTriggerNode = gButton;
disableNonTestMouse(true);
@ -279,48 +276,47 @@ var popupTests = [
},
{
testname: "close tooltip with modifiers",
test: function() {
test() {
// Press all of the modifiers; the tooltip should remain open on all platforms.
synthesizeKey("KEY_Shift");
synthesizeKey("KEY_Control");
synthesizeKey("KEY_Alt");
synthesizeKey("KEY_Alt");
},
result: function() {
result() {
is(document.getElementById("thetooltip").state, "open", "tooltip still open after modifiers pressed")
}
},
{
testname: "close tooltip with key",
events: function() {
events() {
if (navigator.platform.indexOf("Win") > -1) {
return [];
}
else {
return [ "popuphiding thetooltip", "popuphidden thetooltip",
return [ "popuphiding thetooltip", "popuphidden thetooltip",
"DOMMenuInactive thetooltip" ];
}
},
test: function() {
test() {
sendString("a");
},
result: function() {
result() {
let expectedState = (navigator.platform.indexOf("Win") > -1) ? "open" : "closed";
is(document.getElementById("thetooltip").state, expectedState, "tooltip closed after key pressed")
}
},
{
testname: "close tooltip with hidePopup again",
condition: function() { return navigator.platform.indexOf("Win") > -1; },
condition() { return navigator.platform.indexOf("Win") > -1; },
events: [ "popuphiding thetooltip", "popuphidden thetooltip",
"DOMMenuInactive thetooltip" ],
test: function() {
test() {
document.getElementById("thetooltip").hidePopup();
},
}
];
var waitSteps = 0;
var oldx, oldy;
function moveWindowTo(x, y, callback, arg)
{
if (!waitSteps) {

Просмотреть файл

@ -33,58 +33,58 @@ ok(gMenuPopup, "Got the reference to the context menu");
var popupTests = [
{
testname: "one-down-key",
condition: function() { return (!navigator.platform.includes("Mac")); },
condition() { return (!navigator.platform.includes("Mac")); },
events: [ "popupshowing context", "popupshown context", "DOMMenuItemActive a" ],
test: function () {
test() {
synthesizeMouse($("popuparea"), 4, 4, {});
synthesizeKey("KEY_ArrowDown");
},
result: function (testname) {
result(testname) {
checkActive(gMenuPopup, "a", testname);
}
},
{
testname: "two-down-keys",
condition: function() { return (!navigator.platform.includes("Mac")); },
condition() { return (!navigator.platform.includes("Mac")); },
events: [ "DOMMenuItemInactive a", "DOMMenuItemActive b" ],
test: () => synthesizeKey("KEY_ArrowDown"),
result: function (testname) {
result(testname) {
checkActive(gMenuPopup, "b", testname);
}
},
{
testname: "three-down-keys",
condition: function() { return (!navigator.platform.includes("Mac")); },
condition() { return (!navigator.platform.includes("Mac")); },
events: [ "DOMMenuItemInactive b", "DOMMenuItemActive c" ],
test: () => synthesizeKey("KEY_ArrowDown"),
result: function (testname) {
result(testname) {
checkActive(gMenuPopup, "c", testname);
}
},
{
testname: "three-down-keys-one-up-key",
condition: function() { return (!navigator.platform.includes("Mac")); },
condition() { return (!navigator.platform.includes("Mac")); },
events: [ "DOMMenuItemInactive c", "DOMMenuItemActive b" ],
test: () => synthesizeKey("KEY_ArrowUp"),
result: function (testname) {
result (testname) {
checkActive(gMenuPopup, "b", testname);
}
},
{
testname: "three-down-keys-two-up-keys",
condition: function() { return (!navigator.platform.includes("Mac")); },
condition() { return (!navigator.platform.includes("Mac")); },
events: [ "DOMMenuItemInactive b", "DOMMenuItemActive a" ],
test: () => synthesizeKey("KEY_ArrowUp"),
result: function (testname) {
result(testname) {
checkActive(gMenuPopup, "a", testname);
}
},
{
testname: "three-down-keys-three-up-key",
condition: function() { return (!navigator.platform.includes("Mac")); },
condition() { return (!navigator.platform.includes("Mac")); },
events: [ "DOMMenuItemInactive a", "DOMMenuItemActive c" ],
test: () => synthesizeKey("KEY_ArrowUp"),
result: function (testname) {
result(testname) {
checkActive(gMenuPopup, "c", testname);
}
},

Просмотреть файл

@ -41,7 +41,7 @@ var popupTests = [
testname: "open outer popup",
events: [ "popupshowing outermain", "popupshown outermain" ],
test: () => synthesizeMouse($("popuparea"), 4, 4, {}),
result: function (testname) {
result (testname) {
is($("outermain").triggerNode, $("popuparea"), testname);
is(document.popupNode, $("popuparea"), testname + " document.popupNode");
}
@ -49,11 +49,11 @@ var popupTests = [
{
testname: "open inner popup",
events: [ "DOMMenuItemActive outermenu", "popupshowing innermain", "popupshown innermain" ],
test: function () {
test () {
synthesizeMouse($("outermenu"), 4, 4, { type: "mousemove" });
synthesizeMouse($("outermenu"), 2, 2, { type: "mousemove" });
},
result: function (testname) {
result (testname) {
is($("outermain").triggerNode, $("popuparea"), testname + " outer");
is($("innermain").triggerNode, $("popuparea"), testname + " inner");
is($("outercontext").triggerNode, null, testname + " outer context");
@ -62,10 +62,10 @@ var popupTests = [
},
{
testname: "open outer context",
condition: function() { return (!navigator.platform.includes("Mac")); },
condition() { return (!navigator.platform.includes("Mac")); },
events: [ "popupshowing outercontext", "popupshown outercontext" ],
test: () => synthesizeMouse($("innermenu"), 4, 4, { type: "contextmenu", button: 2 }),
result: function (testname) {
result (testname) {
is($("outermain").triggerNode, $("popuparea"), testname + " outer");
is($("innermain").triggerNode, $("popuparea"), testname + " inner");
is($("outercontext").triggerNode, $("innermenu"), testname + " outer context");
@ -74,15 +74,15 @@ var popupTests = [
},
{
testname: "open inner context",
condition: function() { return (!navigator.platform.includes("Mac")); },
condition() { return (!navigator.platform.includes("Mac")); },
events: [ "DOMMenuItemActive outercontextmenu", "popupshowing innercontext", "popupshown innercontext" ],
test: function () {
test () {
synthesizeMouse($("outercontextmenu"), 4, 4, { type: "mousemove" });
setTimeout(function() {
synthesizeMouse($("outercontextmenu"), 2, 2, { type: "mousemove" });
}, 1000);
},
result: function (testname) {
result (testname) {
is($("outermain").triggerNode, $("popuparea"), testname + " outer");
is($("innermain").triggerNode, $("popuparea"), testname + " inner");
is($("outercontext").triggerNode, $("innermenu"), testname + " outer context");
@ -92,14 +92,14 @@ var popupTests = [
},
{
testname: "close context",
condition: function() { return (!navigator.platform.includes("Mac")); },
condition() { return (!navigator.platform.includes("Mac")); },
events: [ "popuphiding innercontext", "popuphidden innercontext",
"popuphiding outercontext", "popuphidden outercontext",
"DOMMenuInactive innercontext",
"DOMMenuItemInactive outercontextmenu", "DOMMenuItemInactive outercontextmenu",
"DOMMenuInactive outercontext" ],
test: () => $("outercontext").hidePopup(),
result: function (testname) {
result (testname) {
is($("outermain").triggerNode, $("popuparea"), testname + " outer");
is($("innermain").triggerNode, $("popuparea"), testname + " inner");
is($("outercontext").triggerNode, null, testname + " outer context");
@ -116,7 +116,7 @@ var popupTests = [
"DOMMenuInactive outermain" ],
test: () => $("outermain").hidePopup(),
result: function (testname) {
result (testname) {
is($("outermain").triggerNode, null, testname + " outer");
is($("innermain").triggerNode, null, testname + " inner");
is($("outercontext").triggerNode, null, testname + " outer context");

Просмотреть файл

@ -50,7 +50,7 @@ function isArrowPositionedOn(side, offset) {
ok(arrowMidY >= panelMidY, "arrow should be on the bottom of the panel");
break;
default:
ok(false, "invalid position " + where);
ok(false, "invalid position " + side);
break;
}
// Now check the arrow really is pointing where we expect. The middle of
@ -91,9 +91,8 @@ function openPopup(position, callback) {
function waitForPopupPositioned(actionFn, callback)
{
panel.addEventListener("popuppositioned", function listener() {
panel.removeEventListener("popuppositioned", listener, false);
SimpleTest.executeSoon(callback);
}, false);
}, {once: true});
actionFn();
}
@ -116,13 +115,11 @@ function _openPopup(position, callback) {
callback();
};
panel.addEventListener("popupshown", function popupshown() {
panel.removeEventListener("popupshown", popupshown);
onEvent();
});
}, {once: true});
arrow.addEventListener("load", function imageload() {
arrow.removeEventListener("load", imageload);
onEvent();
});
}, {once: true});
panel.openPopup(anchor, position);
}

Просмотреть файл

@ -22,7 +22,7 @@ let panel, anchor, arrow;
// done by the panel.
let observer = {
reflows: [],
reflow: function (start, end) {
reflow (start, end) {
// Ignore reflows triggered by native code
// (Reflows from native code only have an empty stack after the first frame)
var path = (new Error().stack).split("\n").slice(1).join("");
@ -33,7 +33,7 @@ let observer = {
this.reflows.push(new Error().stack);
},
reflowInterruptible: function (start, end) {
reflowInterruptible (start, end) {
// We're not interested in interruptible reflows. Why, you ask? Because
// we've simply cargo-culted this test from browser_tabopen_reflows.js!
},
@ -64,9 +64,8 @@ function countReflows(testfn, expected) {
function openPopup() {
return new Promise(resolve => {
panel.addEventListener("popupshown", function popupshown() {
panel.removeEventListener("popupshown", popupshown);
resolve();
});
}, {once: true});
panel.openPopup(anchor, "before_start");
});
}

Просмотреть файл

@ -80,7 +80,7 @@
<script class="testbody" type="application/javascript">
<![CDATA[
let gFilePopup;
window.opener.SimpleTest.waitForFocus(function () {
gFilePopup = document.getElementById("filepopup");
var filemenu = document.getElementById("filemenu");
@ -118,8 +118,8 @@ var popupTests = [
testname: "press on menu",
events: [ "popupshowing filepopup", "DOMMenuBarActive menubar",
"DOMMenuItemActive filemenu", "popupshown filepopup" ],
test: function() { synthesizeMouse(document.getElementById("filemenu"), 8, 8, { }); },
result: function (testname) {
test() { synthesizeMouse(document.getElementById("filemenu"), 8, 8, { }); },
result (testname) {
checkActive(gFilePopup, "", testname);
checkOpen("filemenu", testname);
is(document.getElementById("filemenu").openedWithKey, false, testname + " openedWithKey");
@ -130,42 +130,42 @@ var popupTests = [
// highlights the first item
testname: "cursor down no selection",
events: [ "DOMMenuItemActive item1" ],
test: function() { synthesizeKey("KEY_ArrowDown"); },
result: function(testname) { checkActive(gFilePopup, "item1", testname); }
test() { synthesizeKey("KEY_ArrowDown"); },
result(testname) { checkActive(gFilePopup, "item1", testname); }
},
{
// check that pressing cursor up wraps and highlights the last item
testname: "cursor up wrap",
events: [ "DOMMenuItemInactive item1", "DOMMenuItemActive item3" ],
test: function() { synthesizeKey("KEY_ArrowUp"); },
result: function(testname) { checkActive(gFilePopup, "item3", testname); }
test() { synthesizeKey("KEY_ArrowUp"); },
result(testname) { checkActive(gFilePopup, "item3", testname); }
},
{
// check that pressing cursor down wraps and highlights the first item
testname: "cursor down wrap",
events: [ "DOMMenuItemInactive item3", "DOMMenuItemActive item1" ],
test: function() { synthesizeKey("KEY_ArrowDown"); },
result: function(testname) { checkActive(gFilePopup, "item1", testname); }
test() { synthesizeKey("KEY_ArrowDown"); },
result(testname) { checkActive(gFilePopup, "item1", testname); }
},
{
// check that pressing cursor down highlights the second item
testname: "cursor down",
events: [ "DOMMenuItemInactive item1", "DOMMenuItemActive item2" ],
test: function() { synthesizeKey("KEY_ArrowDown"); },
result: function(testname) { checkActive(gFilePopup, "item2", testname); }
test() { synthesizeKey("KEY_ArrowDown"); },
result(testname) { checkActive(gFilePopup, "item2", testname); }
},
{
// check that pressing cursor up highlights the second item
testname: "cursor up",
events: [ "DOMMenuItemInactive item2", "DOMMenuItemActive item1" ],
test: function() { synthesizeKey("KEY_ArrowUp"); },
result: function(testname) { checkActive(gFilePopup, "item1", testname); }
test() { synthesizeKey("KEY_ArrowUp"); },
result(testname) { checkActive(gFilePopup, "item1", testname); }
},
{
// cursor right should skip the disabled menu and move to the edit menu
testname: "cursor right skip disabled",
events: function() {
events() {
var elist = [
// the file menu gets deactivated, the file menu gets hidden, then
// the edit menu is activated
@ -187,8 +187,8 @@ var popupTests = [
elist.push("popupshown editpopup");
return elist;
},
test: function() { synthesizeKey("KEY_ArrowRight"); },
result: function(testname) {
test() { synthesizeKey("KEY_ArrowRight"); },
result(testname) {
var expected = (navigator.platform.indexOf("Win") == 0) ? "cut" : "copy";
checkActive(document.getElementById("editpopup"), expected, testname);
checkClosed("filemenu", testname);
@ -200,21 +200,20 @@ var popupTests = [
// on Windows, a disabled item is selected, so pressing RETURN should close
// the menu but not fire a command event
testname: "enter on disabled",
events: function() {
events() {
if (navigator.platform.indexOf("Win") == 0)
return [ "popuphiding editpopup", "popuphidden editpopup",
"DOMMenuItemInactive cut", "DOMMenuInactive editpopup",
"DOMMenuBarInactive menubar",
"DOMMenuItemInactive editmenu", "DOMMenuItemInactive editmenu" ];
else
return [ "DOMMenuItemInactive copy", "DOMMenuInactive editpopup",
"DOMMenuBarInactive menubar",
"DOMMenuItemInactive editmenu", "DOMMenuItemInactive editmenu",
"command copy", "popuphiding editpopup", "popuphidden editpopup",
"DOMMenuItemInactive copy" ];
},
test: function() { synthesizeKey("KEY_Enter"); },
result: function(testname) {
test() { synthesizeKey("KEY_Enter"); },
result(testname) {
checkClosed("editmenu", testname);
is(document.getElementById("editmenu").openedWithKey, false, testname + " openedWithKey");
}
@ -222,13 +221,13 @@ var popupTests = [
{
// pressing Alt + a key should open the corresponding menu
testname: "open with accelerator",
events: function() {
events() {
return [ "DOMMenuBarActive menubar",
"popupshowing viewpopup", "DOMMenuItemActive viewmenu",
"DOMMenuItemActive toolbar", "popupshown viewpopup" ];
},
test: function() { synthesizeKey("V", { altKey: true }); },
result: function(testname) {
test() { synthesizeKey("V", { altKey: true }); },
result(testname) {
checkOpen("viewmenu", testname);
is(document.getElementById("viewmenu").openedWithKey, true, testname + " openedWithKey");
}
@ -236,16 +235,15 @@ var popupTests = [
{
// open the submenu with the cursor right key
testname: "open submenu with cursor right",
events: function() {
events() {
// on Windows, the disabled 'navigation' item can stll be highlihted
if (navigator.platform.indexOf("Win") == 0)
return [ "popupshowing toolbarpopup", "DOMMenuItemActive navigation",
"popupshown toolbarpopup" ];
else
return [ "popupshowing toolbarpopup", "popupshown toolbarpopup" ];
},
test: function() { synthesizeKey("KEY_ArrowRight"); },
result: function(testname) {
test() { synthesizeKey("KEY_ArrowRight"); },
result(testname) {
checkOpen("viewmenu", testname);
checkOpen("toolbar", testname);
}
@ -253,18 +251,17 @@ var popupTests = [
{
// close the submenu with the cursor left key
testname: "close submenu with cursor left",
events: function() {
events() {
if (navigator.platform.indexOf("Win") == 0)
return [ "popuphiding toolbarpopup", "popuphidden toolbarpopup",
"DOMMenuItemInactive navigation", "DOMMenuInactive toolbarpopup",
"DOMMenuItemActive toolbar" ];
else
return [ "popuphiding toolbarpopup", "popuphidden toolbarpopup",
"DOMMenuInactive toolbarpopup",
"DOMMenuItemActive toolbar" ];
},
test: function() { synthesizeKey("KEY_ArrowLeft"); },
result: function(testname) {
test() { synthesizeKey("KEY_ArrowLeft"); },
result(testname) {
checkOpen("viewmenu", testname);
checkClosed("toolbar", testname);
}
@ -272,16 +269,15 @@ var popupTests = [
{
// open the submenu with the enter key
testname: "open submenu with enter",
events: function() {
events() {
// on Windows, the disabled 'navigation' item can stll be highlighted
if (navigator.platform.indexOf("Win") == 0)
return [ "popupshowing toolbarpopup", "DOMMenuItemActive navigation",
"popupshown toolbarpopup" ];
else
return [ "popupshowing toolbarpopup", "popupshown toolbarpopup" ];
},
test: function() { synthesizeKey("KEY_Enter"); },
result: function(testname) {
test() { synthesizeKey("KEY_Enter"); },
result(testname) {
checkOpen("viewmenu", testname);
checkOpen("toolbar", testname);
},
@ -289,18 +285,17 @@ var popupTests = [
{
// close the submenu with the escape key
testname: "close submenu with escape",
events: function() {
events() {
if (navigator.platform.indexOf("Win") == 0)
return [ "popuphiding toolbarpopup", "popuphidden toolbarpopup",
"DOMMenuItemInactive navigation", "DOMMenuInactive toolbarpopup",
"DOMMenuItemActive toolbar" ];
else
return [ "popuphiding toolbarpopup", "popuphidden toolbarpopup",
"DOMMenuInactive toolbarpopup",
"DOMMenuItemActive toolbar" ];
},
test: function() { synthesizeKey("KEY_Escape"); },
result: function(testname) {
test() { synthesizeKey("KEY_Escape"); },
result(testname) {
checkOpen("viewmenu", testname);
checkClosed("toolbar", testname);
},
@ -308,17 +303,16 @@ var popupTests = [
{
// open the submenu with the enter key again
testname: "open submenu with enter again",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: function() {
condition() { return (navigator.platform.indexOf("Win") == 0) },
events() {
// on Windows, the disabled 'navigation' item can stll be highlighted
if (navigator.platform.indexOf("Win") == 0)
return [ "popupshowing toolbarpopup", "DOMMenuItemActive navigation",
"popupshown toolbarpopup" ];
else
return [ "popupshowing toolbarpopup", "popupshown toolbarpopup" ];
},
test: function() { synthesizeKey("KEY_Enter"); },
result: function(testname) {
test() { synthesizeKey("KEY_Enter"); },
result(testname) {
checkOpen("viewmenu", testname);
checkOpen("toolbar", testname);
},
@ -326,7 +320,7 @@ var popupTests = [
{
// while a submenu is open, switch to the next toplevel menu with the cursor right key
testname: "while a submenu is open, switch to the next menu with the cursor right",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
condition() { return (navigator.platform.indexOf("Win") == 0) },
events: [ "DOMMenuItemInactive viewmenu", "DOMMenuItemActive helpmenu",
"popuphiding toolbarpopup", "popuphidden toolbarpopup",
"popuphiding viewpopup", "popuphidden viewpopup",
@ -334,8 +328,8 @@ var popupTests = [
"DOMMenuInactive toolbarpopup", "DOMMenuItemInactive toolbar",
"DOMMenuInactive viewpopup", "DOMMenuItemActive contents",
"popupshown helppopup" ],
test: function() { synthesizeKey("KEY_ArrowRight"); },
result: function(testname) {
test() { synthesizeKey("KEY_ArrowRight"); },
result(testname) {
checkOpen("helpmenu", testname);
checkClosed("toolbar", testname);
checkClosed("viewmenu", testname);
@ -344,36 +338,35 @@ var popupTests = [
{
// close the main menu with the escape key
testname: "close menubar menu with escape",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
condition() { return (navigator.platform.indexOf("Win") == 0) },
events: [ "popuphiding helppopup", "popuphidden helppopup",
"DOMMenuItemInactive contents", "DOMMenuInactive helppopup",
"DOMMenuBarInactive menubar", "DOMMenuItemInactive helpmenu" ],
test: function() { synthesizeKey("KEY_Escape"); },
result: function(testname) { checkClosed("viewmenu", testname); },
test() { synthesizeKey("KEY_Escape"); },
result(testname) { checkClosed("viewmenu", testname); },
},
{
// close the main menu with the escape key
testname: "close menubar menu with escape",
condition: function() { return (navigator.platform.indexOf("Win") != 0) },
condition() { return (navigator.platform.indexOf("Win") != 0) },
events: [ "popuphiding viewpopup", "popuphidden viewpopup",
"DOMMenuItemInactive toolbar", "DOMMenuInactive viewpopup",
"DOMMenuBarInactive menubar",
"DOMMenuItemInactive viewmenu" ],
test: function() { synthesizeKey("KEY_Escape"); },
result: function(testname) { checkClosed("viewmenu", testname); },
test() { synthesizeKey("KEY_Escape"); },
result(testname) { checkClosed("viewmenu", testname); },
},
{
// Pressing Alt should highlight the first menu but not open it,
// but it should be ignored if the alt keydown event is consumed.
testname: "alt shouldn't activate menubar if keydown event is consumed",
test: function() {
test() {
document.addEventListener("keydown", function (aEvent) {
document.removeEventListener("keydown", arguments.callee, true);
aEvent.preventDefault();
}, true);
}, {once: true});
synthesizeKey("KEY_Alt");
},
result: function(testname) {
result(testname) {
ok(!document.getElementById("filemenu").openedWithKey, testname);
checkClosed("filemenu", testname);
},
@ -382,14 +375,13 @@ var popupTests = [
// Pressing Alt should highlight the first menu but not open it,
// but it should be ignored if the alt keyup event is consumed.
testname: "alt shouldn't activate menubar if keyup event is consumed",
test: function() {
test() {
document.addEventListener("keyup", function (aEvent) {
document.removeEventListener("keyup", arguments.callee, true);
aEvent.preventDefault();
}, true);
}, {once: true});
synthesizeKey("KEY_Alt");
},
result: function(testname) {
result(testname) {
ok(!document.getElementById("filemenu").openedWithKey, testname);
checkClosed("filemenu", testname);
},
@ -398,8 +390,8 @@ var popupTests = [
// Pressing Alt should highlight the first menu but not open it.
testname: "alt to activate menubar",
events: [ "DOMMenuBarActive menubar", "DOMMenuItemActive filemenu" ],
test: function() { synthesizeKey("KEY_Alt"); },
result: function(testname) {
test() { synthesizeKey("KEY_Alt"); },
result(testname) {
is(document.getElementById("filemenu").openedWithKey, true, testname + " openedWithKey");
checkClosed("filemenu", testname);
},
@ -408,15 +400,15 @@ var popupTests = [
// pressing cursor left should select the previous menu but not open it
testname: "cursor left on active menubar",
events: [ "DOMMenuItemInactive filemenu", "DOMMenuItemActive helpmenu" ],
test: function() { synthesizeKey("KEY_ArrowLeft"); },
result: function(testname) { checkClosed("helpmenu", testname); },
test() { synthesizeKey("KEY_ArrowLeft"); },
result(testname) { checkClosed("helpmenu", testname); },
},
{
// pressing cursor right should select the previous menu but not open it
testname: "cursor right on active menubar",
events: [ "DOMMenuItemInactive helpmenu", "DOMMenuItemActive filemenu" ],
test: function() { synthesizeKey("KEY_ArrowRight"); },
result: function(testname) { checkClosed("filemenu", testname); },
test() { synthesizeKey("KEY_ArrowRight"); },
result(testname) { checkClosed("filemenu", testname); },
},
{
// pressing a character should act as an accelerator and open the menu
@ -424,8 +416,8 @@ var popupTests = [
events: [ "popupshowing helppopup",
"DOMMenuItemInactive filemenu", "DOMMenuItemActive helpmenu",
"DOMMenuItemActive contents", "popupshown helppopup" ],
test: function() { sendChar("h"); },
result: function(testname) {
test() { sendChar("h"); },
result(testname) {
checkOpen("helpmenu", testname);
is(document.getElementById("helpmenu").openedWithKey, true, testname + " openedWithKey");
},
@ -434,15 +426,15 @@ var popupTests = [
// check that pressing cursor up skips non menuitems
testname: "cursor up wrap",
events: [ "DOMMenuItemInactive contents", "DOMMenuItemActive about" ],
test: function() { synthesizeKey("KEY_ArrowUp"); },
result: function(testname) { }
test() { synthesizeKey("KEY_ArrowUp"); },
result(testname) { }
},
{
// check that pressing cursor down skips non menuitems
testname: "cursor down wrap",
events: [ "DOMMenuItemInactive about", "DOMMenuItemActive contents" ],
test: function() { synthesizeKey("KEY_ArrowDown"); },
result: function(testname) { }
test() { synthesizeKey("KEY_ArrowDown"); },
result(testname) { }
},
{
// check that pressing a menuitem's accelerator selects it
@ -454,15 +446,15 @@ var popupTests = [
"command amenu", "popuphiding helppopup", "popuphidden helppopup",
"DOMMenuItemInactive amenu",
],
test: function() { sendChar("m"); },
result: function(testname) { checkClosed("helpmenu", testname); }
test() { sendChar("m"); },
result(testname) { checkClosed("helpmenu", testname); }
},
{
// pressing F10 should highlight the first menu. On Linux, the menu is opened.
testname: "F10 to activate menubar",
events: pressF10Events(),
test: function() { synthesizeKey("KEY_F10"); },
result: function(testname) {
test() { synthesizeKey("KEY_F10"); },
result(testname) {
is(document.getElementById("filemenu").openedWithKey, true, testname + " openedWithKey");
if (navigator.platform.includes("Linux"))
checkOpen("filemenu", testname);
@ -489,8 +481,8 @@ var popupTests = [
// "accelerator on active menubar" because menus opened from a
// shortcut key are fired asynchronously
"DOMMenuItemActive contents", "popupshown helppopup" ],
test: function() { synthesizeKey("KEY_ArrowLeft"); synthesizeKey("KEY_ArrowDown"); },
result: function(testname) {
test() { synthesizeKey("KEY_ArrowLeft"); synthesizeKey("KEY_ArrowDown"); },
result(testname) {
is(document.getElementById("helpmenu").openedWithKey, true, testname + " openedWithKey");
}
},
@ -502,16 +494,16 @@ var popupTests = [
events: (navigator.platform.includes("Linux")) ?
[ "DOMMenuItemActive one" ] :
[ "DOMMenuItemInactive contents", "DOMMenuItemActive one" ],
test: function() { sendChar("o"); },
result: function(testname) { checkOpen("helpmenu", testname); }
test() { sendChar("o"); },
result(testname) { checkOpen("helpmenu", testname); }
},
{
// pressing the letter again should select the next one that starts with
// that letter
testname: "menuitem with no accelerator again",
events: [ "DOMMenuItemInactive one", "DOMMenuItemActive only" ],
test: function() { sendChar("o"); },
result: function(testname) {
test() { sendChar("o"); },
result(testname) {
// 'only' is a menu but it should not be open
checkOpen("helpmenu", testname);
checkClosed("only", testname);
@ -521,16 +513,16 @@ var popupTests = [
// pressing the letter again when the next item is disabled should still
// select the disabled item
testname: "menuitem with no accelerator disabled",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
condition() { return (navigator.platform.indexOf("Win") == 0) },
events: [ "DOMMenuItemInactive only", "DOMMenuItemActive other" ],
test: function() { sendChar("o"); },
result: function(testname) { }
test() { sendChar("o"); },
result(testname) { }
},
{
// when only one menuitem starting with that letter exists, it should be
// selected and the menu closed
testname: "menuitem with no accelerator single",
events: function() {
events() {
var elist = [ "DOMMenuItemInactive other", "DOMMenuItemActive third",
"DOMMenuItemInactive third", "DOMMenuInactive helppopup",
"DOMMenuBarInactive menubar",
@ -543,34 +535,34 @@ var popupTests = [
elist[0] = "DOMMenuItemInactive only";
return elist;
},
test: function() { sendChar("t"); },
result: function(testname) { checkClosed("helpmenu", testname); }
test() { sendChar("t"); },
result(testname) { checkClosed("helpmenu", testname); }
},
{
// pressing F10 should highlight the first menu but not open it
testname: "F10 to activate menubar again",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
condition() { return (navigator.platform.indexOf("Win") == 0) },
events: [ "DOMMenuBarActive menubar", "DOMMenuItemActive filemenu" ],
test: function() { synthesizeKey("KEY_F10"); },
result: function(testname) { checkClosed("filemenu", testname); },
test() { synthesizeKey("KEY_F10"); },
result(testname) { checkClosed("filemenu", testname); },
},
{
// pressing an accelerator for a disabled item should deactivate the menubar
testname: "accelerator for disabled menu",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
condition() { return (navigator.platform.indexOf("Win") == 0) },
events: [ "DOMMenuItemInactive filemenu", "DOMMenuBarInactive menubar" ],
test: function() { sendChar("s"); },
result: function(testname) {
test() { sendChar("s"); },
result(testname) {
checkClosed("secretmenu", testname);
is(document.getElementById("filemenu").openedWithKey, false, testname + " openedWithKey");
},
},
{
testname: "press on disabled menu",
test: function() {
test() {
synthesizeMouse(document.getElementById("secretmenu"), 8, 8, { });
},
result: function (testname) {
result (testname) {
checkClosed("secretmenu", testname);
}
},
@ -578,20 +570,20 @@ var popupTests = [
testname: "press on second menu with shift",
events: [ "popupshowing editpopup", "DOMMenuBarActive menubar",
"DOMMenuItemActive editmenu", "popupshown editpopup" ],
test: function() {
test() {
synthesizeMouse(document.getElementById("editmenu"), 8, 8, { shiftKey : true });
},
result: function (testname) {
result (testname) {
checkOpen("editmenu", testname);
checkActive(document.getElementById("menubar"), "editmenu", testname);
}
},
{
testname: "press on disabled menuitem",
test: function() {
test() {
synthesizeMouse(document.getElementById("cut"), 8, 8, { });
},
result: function (testname) {
result (testname) {
checkOpen("editmenu", testname);
}
},
@ -604,10 +596,10 @@ var popupTests = [
"command copy", "popuphiding editpopup", "popuphidden editpopup",
"DOMMenuItemInactive copy",
],
test: function() {
test() {
synthesizeMouse(document.getElementById("copy"), 8, 8, { });
},
result: function (testname) {
result (testname) {
checkClosed("editmenu", testname);
}
},
@ -617,8 +609,8 @@ var popupTests = [
testname: "press on menu after menuitem selected",
events: [ "popupshowing editpopup", "DOMMenuBarActive menubar",
"DOMMenuItemActive editmenu", "popupshown editpopup" ],
test: function() { synthesizeMouse(document.getElementById("editmenu"), 8, 8, { }); },
result: function (testname) {
test() { synthesizeMouse(document.getElementById("editmenu"), 8, 8, { }); },
result (testname) {
checkActive(document.getElementById("editpopup"), "", testname);
checkOpen("editmenu", testname);
}
@ -632,70 +624,70 @@ var popupTests = [
"command paste", "popuphiding editpopup", "popuphidden editpopup",
"DOMMenuItemInactive paste",
],
test: function() {
test() {
synthesizeMouse(document.getElementById("paste"), 8, 8, { });
},
result: function (testname) {
result (testname) {
checkClosed("editmenu", testname);
}
},
{
testname: "F10 to activate menubar for tab deactivation",
events: pressF10Events(),
test: function() { synthesizeKey("KEY_F10"); },
test() { synthesizeKey("KEY_F10"); },
},
{
testname: "Deactivate menubar with tab key",
events: closeAfterF10Events(true),
test: function() { synthesizeKey("KEY_Tab"); },
result: function(testname) {
test() { synthesizeKey("KEY_Tab"); },
result(testname) {
is(document.getElementById("filemenu").openedWithKey, false, testname + " openedWithKey");
}
},
{
testname: "F10 to activate menubar for escape deactivation",
events: pressF10Events(),
test: function() { synthesizeKey("KEY_F10"); },
test() { synthesizeKey("KEY_F10"); },
},
{
testname: "Deactivate menubar with escape key",
events: closeAfterF10Events(false),
test: function() { synthesizeKey("KEY_Escape"); },
result: function(testname) {
test() { synthesizeKey("KEY_Escape"); },
result(testname) {
is(document.getElementById("filemenu").openedWithKey, false, testname + " openedWithKey");
}
},
{
testname: "F10 to activate menubar for f10 deactivation",
events: pressF10Events(),
test: function() { synthesizeKey("KEY_F10"); },
test() { synthesizeKey("KEY_F10"); },
},
{
testname: "Deactivate menubar with f10 key",
events: closeAfterF10Events(true),
test: function() { synthesizeKey("KEY_F10"); },
result: function(testname) {
test() { synthesizeKey("KEY_F10"); },
result(testname) {
is(document.getElementById("filemenu").openedWithKey, false, testname + " openedWithKey");
}
},
{
testname: "F10 to activate menubar for alt deactivation",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
condition() { return (navigator.platform.indexOf("Win") == 0) },
events: [ "DOMMenuBarActive menubar", "DOMMenuItemActive filemenu" ],
test: function() { synthesizeKey("KEY_F10"); },
test() { synthesizeKey("KEY_F10"); },
},
{
testname: "Deactivate menubar with alt key",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
condition() { return (navigator.platform.indexOf("Win") == 0) },
events: [ "DOMMenuBarInactive menubar", "DOMMenuItemInactive filemenu" ],
test: function() { synthesizeKey("KEY_Alt"); },
result: function(testname) {
test() { synthesizeKey("KEY_Alt"); },
result(testname) {
is(document.getElementById("filemenu").openedWithKey, false, testname + " openedWithKey");
}
},
{
testname: "Don't activate menubar with mousedown during alt key auto-repeat",
test: function() {
test() {
synthesizeKey("KEY_Alt", {type: "keydown"});
synthesizeMouse(document.getElementById("menubar"), 8, -30, { type: "mousedown", altKey: true });
synthesizeKey("KEY_Alt", {type: "keydown"});
@ -703,7 +695,7 @@ var popupTests = [
synthesizeKey("KEY_Alt", {type: "keydown"});
synthesizeKey("KEY_Alt", {type: "keyup"});
},
result: function (testname) {
result (testname) {
checkActive(document.getElementById("menubar"), "", testname);
}
},
@ -713,8 +705,8 @@ var popupTests = [
events: [ "DOMMenuBarActive menubar",
"popupshowing filepopup", "DOMMenuItemActive filemenu",
"DOMMenuItemActive item1", "popupshown filepopup" ],
test: function() { synthesizeKey("F", { altKey: true }); },
result: function (testname) {
test() { synthesizeKey("F", { altKey: true }); },
result (testname) {
checkOpen("filemenu", testname);
}
},
@ -724,10 +716,10 @@ var popupTests = [
"DOMMenuItemInactive item1", "DOMMenuInactive filepopup",
"DOMMenuBarInactive menubar", "DOMMenuItemInactive filemenu",
"DOMMenuItemInactive filemenu" ],
test: function() {
test() {
synthesizeKey("KEY_Alt");
},
result: function (testname) {
result (testname) {
checkClosed("filemenu", testname);
}
},
@ -736,13 +728,13 @@ var popupTests = [
// between them.
{
testname: "Open file menu by accelerator",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: function() {
condition() { return (navigator.platform.indexOf("Win") == 0) },
events() {
return [ "DOMMenuBarActive menubar", "popupshowing filepopup",
"DOMMenuItemActive filemenu", "DOMMenuItemActive item1",
"popupshown filepopup" ];
},
test: function() {
test() {
synthesizeKey("KEY_Alt", {type: "keydown"});
synthesizeKey("f", {altKey: true});
synthesizeKey("KEY_Alt", {type: "keyup"});
@ -750,38 +742,38 @@ var popupTests = [
},
{
testname: "Close file menu by click at outside of popup menu",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: function() {
condition() { return (navigator.platform.indexOf("Win") == 0) },
events() {
return [ "popuphiding filepopup", "popuphidden filepopup",
"DOMMenuItemInactive item1", "DOMMenuInactive filepopup",
"DOMMenuBarInactive menubar", "DOMMenuItemInactive filemenu",
"DOMMenuItemInactive filemenu" ];
},
test: function() {
test() {
// XXX hidePopup() causes DOMMenuItemInactive event to be fired twice.
document.getElementById("filepopup").hidePopup();
}
},
{
testname: "Alt keydown set focus the menubar",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: function() {
condition() { return (navigator.platform.indexOf("Win") == 0) },
events() {
return [ "DOMMenuBarActive menubar", "DOMMenuItemActive filemenu" ];
},
test: function() {
test() {
synthesizeKey("KEY_Alt");
},
result: function (testname) {
result (testname) {
checkClosed("filemenu", testname);
}
},
{
testname: "unset focus the menubar",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: function() {
condition() { return (navigator.platform.indexOf("Win") == 0) },
events() {
return [ "DOMMenuBarInactive menubar", "DOMMenuItemInactive filemenu" ];
},
test: function() {
test() {
synthesizeKey("KEY_Alt");
}
},
@ -790,27 +782,25 @@ var popupTests = [
{
testname: "Alt key state before deactivating the window shouldn't prevent " +
"next Alt key handling",
condition: function() { return (navigator.platform.indexOf("Win") == 0) },
events: function() {
condition() { return (navigator.platform.indexOf("Win") == 0) },
events() {
return [ "DOMMenuBarActive menubar", "DOMMenuItemActive filemenu" ];
},
test: function() {
test() {
synthesizeKey("KEY_Alt", {type: "keydown"});
synthesizeKey("KEY_Tab", {type: "keydown"}); // cancels the Alt key
var thisWindow = window;
var newWindow =
window.open("data:text/html,", "_blank", "width=100,height=100");
newWindow.addEventListener("focus", function () {
newWindow.removeEventListener("focus", arguments.callee, false);
thisWindow.addEventListener("focus", function () {
thisWindow.removeEventListener("focus", arguments.callee, false);
setTimeout(function () {
synthesizeKey("KEY_Alt", {}, thisWindow);
}, 0);
}, false);
}, {once: true});
newWindow.close();
thisWindow.focus();
}, false);
}, {once: true});
}
}

Просмотреть файл

@ -119,9 +119,7 @@ function testXHRLoad(aEvent) {
"passed to checkCert has an element that has the same issuerName and " +
"commonName as the certificate's and builtin certificates aren't enforced");
var mockChannel = { originalURI: Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService).
newURI("http://example.com/") };
var mockChannel = { originalURI: SpecialPowers.Services.io.newURI("http://example.com/") };
certs = [ ];
is(getCheckCertResult(mockChannel, false, certs), Cr.NS_ERROR_UNEXPECTED,

Просмотреть файл

@ -25,18 +25,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=543854
const ASCIIName = "myprofile";
const UnicodeName = "\u09A0\u09BE\u0995\u09C1\u09B0"; // A Bengali name
var gDirService;
var gIOService;
var gDirService = SpecialPowers.Services.dirsvc;
var gIOService = SpecialPowers.Services.io;
var gProfileService;
var gDefaultLocalProfileParent;
gDirService = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
gIOService = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
gProfileService = Cc["@mozilla.org/toolkit/profile-service;1"].
getService(Ci.nsIToolkitProfileService);