diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /toolkit/content/tests/chrome | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/content/tests/chrome')
26 files changed, 291 insertions, 148 deletions
diff --git a/toolkit/content/tests/chrome/bug263683_window.xhtml b/toolkit/content/tests/chrome/bug263683_window.xhtml index b124361fd7..74846e3c27 100644 --- a/toolkit/content/tests/chrome/bug263683_window.xhtml +++ b/toolkit/content/tests/chrome/bug263683_window.xhtml @@ -176,7 +176,7 @@ const matches = JSON.parse(gFindBar._foundMatches.dataset.l10nArgs); is(matches.total, 2, "Found correct amount of matches") - await SpecialPowers.spawn(gBrowser, [], async function(args) { + await SpecialPowers.spawn(gBrowser, [], async function() { function getSelection(docShell) { let controller = docShell.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsISelectionDisplay) diff --git a/toolkit/content/tests/chrome/bug366992_window.xhtml b/toolkit/content/tests/chrome/bug366992_window.xhtml index 698d26b43a..ee595706f5 100644 --- a/toolkit/content/tests/chrome/bug366992_window.xhtml +++ b/toolkit/content/tests/chrome/bug366992_window.xhtml @@ -46,7 +46,7 @@ isCommandEnabled(aCommand) { return aCommand == "cmd_delete"; }, - doCommand(aCommand) { } + doCommand() { } } function ok(condition, message) { diff --git a/toolkit/content/tests/chrome/chrome.toml b/toolkit/content/tests/chrome/chrome.toml index 3391a2923d..986822ac48 100644 --- a/toolkit/content/tests/chrome/chrome.toml +++ b/toolkit/content/tests/chrome/chrome.toml @@ -226,6 +226,8 @@ support-files = [ ["test_menulist_initial_selection.xhtml"] +["test_menulist_initial_selection_with_connected_callback.xhtml"] + ["test_menulist_keynav.xhtml"] ["test_menulist_null_value.xhtml"] diff --git a/toolkit/content/tests/chrome/file_editor_with_autocomplete.js b/toolkit/content/tests/chrome/file_editor_with_autocomplete.js index 78611efc70..acf2c9e9df 100644 --- a/toolkit/content/tests/chrome/file_editor_with_autocomplete.js +++ b/toolkit/content/tests/chrome/file_editor_with_autocomplete.js @@ -195,7 +195,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text exactly matches the case: type 'Mo'", completeDefaultIndex: false, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("M", { shiftKey: true }, aWindow); synthesizeKey("o", {}, aWindow); return true; @@ -212,7 +212,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text exactly matches the case: select 'Mozilla' to complete the word", completeDefaultIndex: false, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("KEY_ArrowDown", {}, aWindow); synthesizeKey("KEY_Enter", {}, aWindow); return true; @@ -226,7 +226,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text exactly matches the case: undo the word, but typed text shouldn't be canceled", completeDefaultIndex: false, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("z", { accelKey: true }, aWindow); return true; }, @@ -239,7 +239,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text exactly matches the case: undo the typed text", completeDefaultIndex: false, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("z", { accelKey: true }, aWindow); return true; }, @@ -252,7 +252,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text exactly matches the case: redo the typed text", completeDefaultIndex: false, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow); return true; }, @@ -265,7 +265,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text exactly matches the case: redo the word", completeDefaultIndex: false, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow); return true; }, @@ -278,7 +278,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text exactly matches the case: removing all text for next test...", completeDefaultIndex: false, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("a", { accelKey: true }, aWindow); synthesizeKey("KEY_Backspace", {}, aWindow); return true; @@ -293,7 +293,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case: type 'mo'", completeDefaultIndex: false, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("m", {}, aWindow); synthesizeKey("o", {}, aWindow); return true; @@ -310,7 +310,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case: select 'Mozilla' to complete the word", completeDefaultIndex: false, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("KEY_ArrowDown", {}, aWindow); synthesizeKey("KEY_Enter", {}, aWindow); return true; @@ -324,7 +324,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case: undo the word, but typed text shouldn't be canceled", completeDefaultIndex: false, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("z", { accelKey: true }, aWindow); return true; }, @@ -337,7 +337,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case: undo the typed text", completeDefaultIndex: false, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("z", { accelKey: true }, aWindow); return true; }, @@ -350,7 +350,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case: redo the typed text", completeDefaultIndex: false, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow); return true; }, @@ -363,7 +363,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case: redo the word", completeDefaultIndex: false, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow); return true; }, @@ -376,7 +376,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case: removing all text for next test...", completeDefaultIndex: false, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("a", { accelKey: true }, aWindow); synthesizeKey("KEY_Backspace", {}, aWindow); return true; @@ -392,7 +392,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text exactly matches the case (completeDefaultIndex is true): type 'Mo'", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("M", { shiftKey: true }, aWindow); synthesizeKey("o", {}, aWindow); return true; @@ -410,7 +410,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text exactly matches the case (completeDefaultIndex is true): select 'Mozilla' to complete the word", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("KEY_ArrowDown", {}, aWindow); synthesizeKey("KEY_Enter", {}, aWindow); return true; @@ -424,7 +424,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text exactly matches the case (completeDefaultIndex is true): undo the word, but typed text shouldn't be canceled", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("z", { accelKey: true }, aWindow); return true; }, @@ -437,7 +437,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text exactly matches the case (completeDefaultIndex is true): undo the typed text", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("z", { accelKey: true }, aWindow); return true; }, @@ -450,7 +450,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text exactly matches the case (completeDefaultIndex is true): redo the typed text", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow); return true; }, @@ -466,7 +466,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text exactly matches the case (completeDefaultIndex is true): redo the word", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow); return true; }, @@ -479,7 +479,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text exactly matches the case (completeDefaultIndex is true): removing all text for next test...", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("a", { accelKey: true }, aWindow); synthesizeKey("KEY_Backspace", {}, aWindow); return true; @@ -494,7 +494,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): type 'mo'", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("m", {}, aWindow); synthesizeKey("o", {}, aWindow); return true; @@ -512,7 +512,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): select 'Mozilla' to complete the word", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("KEY_ArrowDown", {}, aWindow); synthesizeKey("KEY_Enter", {}, aWindow); return true; @@ -528,7 +528,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): undo the selected word, but typed text shouldn't be canceled", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("z", { accelKey: true }, aWindow); return true; }, @@ -541,7 +541,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): undo the word, but typed text shouldn't be canceled", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("z", { accelKey: true }, aWindow); return true; }, @@ -554,7 +554,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): undo the typed text", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("z", { accelKey: true }, aWindow); return true; }, @@ -571,7 +571,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): redo the typed text", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow); return true; }, @@ -587,7 +587,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): redo the default index word", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow); return true; }, @@ -600,7 +600,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): redo the word", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow); return true; }, @@ -613,7 +613,7 @@ nsDoTestsForEditorWithAutoComplete.prototype = { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): removing all text for next test...", completeDefaultIndex: true, - execute(aWindow, aTarget) { + execute(aWindow) { synthesizeKey("a", { accelKey: true }, aWindow); synthesizeKey("KEY_Backspace", {}, aWindow); return true; diff --git a/toolkit/content/tests/chrome/popup_trigger.js b/toolkit/content/tests/chrome/popup_trigger.js index 003af044e5..71846a01ea 100644 --- a/toolkit/content/tests/chrome/popup_trigger.js +++ b/toolkit/content/tests/chrome/popup_trigger.js @@ -238,7 +238,7 @@ var popupTests = [ // rollup this way. // synthesizeMouse(gTrigger, 0, -12, { }); }, - result(testname, step) { + result(testname) { is(gMenuPopup.anchorNode, null, testname + " anchorNode"); is(gMenuPopup.triggerNode, null, testname + " triggerNode"); checkClosed("trigger", testname); @@ -532,7 +532,7 @@ var popupTests = [ // event to openPopup to check the trigger node. testname: "open popup anchored with override", events: ["popupshowing thepopup 0010", "popupshown thepopup"], - test(testname, step) { + test() { // attribute overrides the position passed in gMenuPopup.setAttribute("position", "end_after"); gExpectedTriggerNode = gCachedEvent.target; @@ -546,7 +546,7 @@ var popupTests = [ gCachedEvent ); }, - result(testname, step) { + result(testname) { gExpectedTriggerNode = null; is(gMenuPopup.anchorNode, gTrigger, testname + " anchorNode"); is( @@ -564,7 +564,7 @@ var popupTests = [ "popuphidden thepopup", "DOMMenuInactive thepopup", ], - test(testname, step) { + test(testname) { synthesizeKey("KEY_Escape"); checkClosed("trigger", testname); }, @@ -574,12 +574,12 @@ var popupTests = [ testname: "open popup anchored with offsets", events: ["popupshowing thepopup", "popupshown thepopup"], autohide: "thepopup", - test(testname, step) { + test() { // attribute is empty so does not override gMenuPopup.setAttribute("position", ""); gMenuPopup.openPopup(gTrigger, "before_start", 5, 10, true, true); }, - result(testname, step) { + result(testname) { compareEdge(gTrigger, gMenuPopup, "before_start", 5, 10, testname); }, }, @@ -588,10 +588,10 @@ var popupTests = [ // to the viewport. testname: "open popup unanchored", events: ["popupshowing thepopup", "popupshown thepopup"], - test(testname, step) { + test() { gMenuPopup.openPopup(null, "after_start", 6, 8, false); }, - result(testname, step) { + result(testname) { var rect = gMenuPopup.getBoundingClientRect(); ok( rect.left == 6 && rect.top == 8 && rect.right && rect.bottom, @@ -607,11 +607,11 @@ var popupTests = [ "popuphiding thepopup", "popuphidden thepopup", ], - test(testname, step) { + test() { var item3 = document.getElementById("item3"); synthesizeMouse(item3, 4, 4, {}); }, - result(testname, step) { + result(testname) { checkClosed("trigger", testname); }, }, @@ -625,18 +625,18 @@ var popupTests = [ "popuphidden thepopup", "DOMMenuInactive thepopup", ], - test(testname, step) { + test() { gMenuPopup.hidePopup(); }, }, { testname: "open popup at screen", events: ["popupshowing thepopup", "popupshown thepopup"], - test(testname, step) { + test() { gExpectedTriggerNode = "notset"; gMenuPopup.openPopupAtScreen(gScreenX + 24, gScreenY + 20, false); }, - result(testname, step) { + result(testname) { gExpectedTriggerNode = null; is(gMenuPopup.anchorNode, null, testname + " anchorNode"); is(gMenuPopup.triggerNode, null, testname + " triggerNode"); @@ -670,7 +670,7 @@ var popupTests = [ { testname: "open context popup at screen", events: ["popupshowing thepopup 0010", "popupshown thepopup"], - test(testname, step) { + test() { gExpectedTriggerNode = gCachedEvent.target; gMenuPopup.openPopupAtScreen( gScreenX + 8, @@ -679,7 +679,7 @@ var popupTests = [ gCachedEvent ); }, - result(testname, step) { + result(testname) { gExpectedTriggerNode = null; is(gMenuPopup.anchorNode, null, testname + " anchorNode"); is( @@ -873,7 +873,7 @@ var popupTests = [ testname: "open context popup at screen with all modifiers set", events: ["popupshowing thepopup 1111", "popupshown thepopup"], autohide: "thepopup", - test(testname, step) { + test() { gMenuPopup.openPopupAtScreen( gScreenX + 8, gScreenY + 16, @@ -885,10 +885,10 @@ var popupTests = [ { testname: "open popup with open property", events: ["popupshowing thepopup", "popupshown thepopup"], - test(testname, step) { + test() { openMenu(gTrigger); }, - result(testname, step) { + result(testname) { checkOpen("trigger", testname); if (gIsMenu) { compareEdge(gTrigger, gMenuPopup, "after_start", 0, 0, testname); @@ -902,10 +902,10 @@ var popupTests = [ "DOMMenuItemActive submenu", "popupshown submenupopup", ], - test(testname, step) { + test() { openMenu(document.getElementById("submenu")); }, - result(testname, step) { + result(testname) { checkOpen("trigger", testname); checkOpen("submenu", testname); // XXXndeakin @@ -929,17 +929,17 @@ var popupTests = [ test() { gMenuPopup.hidePopup(); }, - result(testname, step) { + result(testname) { checkClosed("trigger", testname); checkClosed("submenu", testname); }, }, { testname: "open submenu with open property without parent open", - test(testname, step) { + test() { openMenu(document.getElementById("submenu")); }, - result(testname, step) { + result(testname) { checkClosed("trigger", testname); checkClosed("submenu", testname); }, @@ -950,11 +950,11 @@ var popupTests = [ return gIsMenu; }, events: ["popupshowing thepopup", "popupshown thepopup"], - test(testname, step) { + test() { gMenuPopup.setAttribute("position", "before_start"); openMenu(gTrigger); }, - result(testname, step) { + result(testname) { compareEdge(gTrigger, gMenuPopup, "before_start", 0, 0, testname); }, }, @@ -968,10 +968,10 @@ var popupTests = [ "popuphidden thepopup", "DOMMenuInactive thepopup", ], - test(testname, step) { + test() { closeMenu(gTrigger, gMenuPopup); }, - result(testname, step) { + result(testname) { checkClosed("trigger", testname); }, }, @@ -982,13 +982,13 @@ var popupTests = [ }, events: ["popupshowing thepopup", "popupshown thepopup"], autohide: "thepopup", - test(testname, step) { + test() { gMenuPopup.setAttribute("position", "start_after"); gMenuPopup.setAttribute("popupanchor", "topright"); gMenuPopup.setAttribute("popupalign", "bottomright"); openMenu(gTrigger); }, - result(testname, step) { + result(testname) { compareEdge(gTrigger, gMenuPopup, "start_after", 0, 0, testname); }, }, @@ -999,13 +999,13 @@ var popupTests = [ }, events: ["popupshowing thepopup", "popupshown thepopup"], autohide: "thepopup", - test(testname, step) { + test() { gMenuPopup.removeAttribute("position"); gMenuPopup.setAttribute("popupanchor", "bottomright"); gMenuPopup.setAttribute("popupalign", "topright"); openMenu(gTrigger); }, - result(testname, step) { + result(testname) { compareEdge(gTrigger, gMenuPopup, "after_end", 0, 0, testname); gMenuPopup.removeAttribute("popupanchor"); gMenuPopup.removeAttribute("popupalign"); @@ -1018,11 +1018,11 @@ var popupTests = [ }, events: ["popupshowing thepopup", "popupshown thepopup"], autohide: "thepopup", - test(testname, step) { + test() { gTrigger.focus(); synthesizeKey("KEY_ArrowDown", { altKey: !platformIsMac() }); }, - result(testname, step) { + result(testname) { checkOpen("trigger", testname); checkActive(gMenuPopup, "", testname); }, @@ -1033,11 +1033,11 @@ var popupTests = [ return gIsMenu; }, events: ["popupshowing thepopup", "popupshown thepopup"], - test(testname, step) { + test() { gTrigger.focus(); synthesizeKey("KEY_ArrowUp", { altKey: !platformIsMac() }); }, - result(testname, step) { + result(testname) { checkOpen("trigger", testname); checkActive(gMenuPopup, "", testname); }, @@ -1055,11 +1055,11 @@ var popupTests = [ "popuphiding thepopup", "popuphidden thepopup", ], - test(testname, step) { + test() { synthesizeKey("KEY_ArrowDown"); synthesizeKey("KEY_Enter"); }, - result(testname, step) { + result(testname) { checkClosed("trigger", testname); }, }, @@ -1070,11 +1070,11 @@ var popupTests = [ }, events: ["popupshowing thepopup", "popupshown thepopup"], autohide: "thepopup", - test(testname, step) { + test() { gTrigger.focus(); synthesizeKey(platformIsMac() ? " " : "KEY_F4"); }, - result(testname, step) { + result(testname) { checkOpen("trigger", testname); checkActive(gMenuPopup, "", testname); }, @@ -1085,7 +1085,7 @@ var popupTests = [ condition() { return gIsMenu; }, - test(testname, step) { + test() { gTrigger.focus(); if (platformIsMac()) { synthesizeKey("KEY_F4", { altKey: true }); @@ -1093,7 +1093,7 @@ var popupTests = [ synthesizeKey("", { metaKey: true }); } }, - result(testname, step) { + result(testname) { checkClosed("trigger", testname); }, }, @@ -1102,11 +1102,11 @@ var popupTests = [ condition() { return gIsMenu; }, - test(testname, step) { + test() { gTrigger.setAttribute("disabled", "true"); synthesizeMouse(gTrigger, 4, 4, {}); }, - result(testname, step) { + result(testname) { checkClosed("trigger", testname); gTrigger.removeAttribute("disabled"); }, @@ -1116,11 +1116,11 @@ var popupTests = [ testname: "openPopup with object argument", events: ["popupshowing thepopup 0000", "popupshown thepopup"], autohide: "thepopup", - test(testname, step) { + test(testname) { gMenuPopup.openPopup(gTrigger, { position: "before_start", x: 5, y: 7 }); checkOpen("trigger", testname); }, - result(testname, step) { + result(testname) { var triggerrect = gTrigger.getBoundingClientRect(); var popuprect = gMenuPopup.getBoundingClientRect(); is( @@ -1139,7 +1139,7 @@ var popupTests = [ testname: "openPopup with object argument with event", events: ["popupshowing thepopup 1000", "popupshown thepopup"], autohide: "thepopup", - test(testname, step) { + test(testname) { gMenuPopup.openPopup(gTrigger, { position: "after_start", x: 0, @@ -1153,10 +1153,10 @@ var popupTests = [ testname: "openPopup with no arguments", events: ["popupshowing thepopup", "popupshown thepopup"], autohide: "thepopup", - test(testname, step) { + test() { gMenuPopup.openPopup(); }, - result(testname, step) { + result(testname) { let isMenu = gTrigger.type == "menu"; // With no arguments, open in default menu position var triggerrect = gTrigger.getBoundingClientRect(); @@ -1184,7 +1184,7 @@ var popupTests = [ "DOMMenuItemActive submenu", "popupshown submenupopup", ], - test(testname, step) { + test(testname) { gMenuPopup.openPopup(gTrigger, "after_start", 0, 0, false, true); document .getElementById("submenupopup") @@ -1196,7 +1196,7 @@ var popupTests = [ { // remove the content nodes for the popup testname: "remove content", - test(testname, step) { + test() { var submenupopup = document.getElementById("submenupopup"); submenupopup.remove(); var popup = document.getElementById("thepopup"); diff --git a/toolkit/content/tests/chrome/test_arrowpanel.xhtml b/toolkit/content/tests/chrome/test_arrowpanel.xhtml index cd8d312e1d..f9f8a0eaf5 100644 --- a/toolkit/content/tests/chrome/test_arrowpanel.xhtml +++ b/toolkit/content/tests/chrome/test_arrowpanel.xhtml @@ -201,7 +201,7 @@ function* nextTest() // Test that a transition occurs when opening or closing the popup. if (matchMedia("(-moz-panel-animations").matches) { - function transitionEnded(event) { + function transitionEnded() { if ($("animatepanel").state != "open") { is($("animatepanel").state, "showing", "state is showing during transitionend"); ok(!animatedPopupShown, "popupshown not fired yet") diff --git a/toolkit/content/tests/chrome/test_labelcontrol.xhtml b/toolkit/content/tests/chrome/test_labelcontrol.xhtml index 06e7f96105..937d3e7403 100644 --- a/toolkit/content/tests/chrome/test_labelcontrol.xhtml +++ b/toolkit/content/tests/chrome/test_labelcontrol.xhtml @@ -40,7 +40,7 @@ function runTests() let checkboxLabel = $("checkbox-label"); is(checkboxLabel.control, "checkbox", "checkbox control"); is(checkboxLabel.labeledControlElement, checkbox, "checkbox labeledControlElement"); - is(checkbox.accessKey, "", "checkbox accessKey not set"); + is(checkbox.accessKey, null, "checkbox accessKey not set"); checkboxLabel.accessKey = "C"; is(checkbox.accessKey, "C", "checkbox accessKey set"); diff --git a/toolkit/content/tests/chrome/test_menuitem_blink.xhtml b/toolkit/content/tests/chrome/test_menuitem_blink.xhtml index 700a8a7465..ad76eee8bf 100644 --- a/toolkit/content/tests/chrome/test_menuitem_blink.xhtml +++ b/toolkit/content/tests/chrome/test_menuitem_blink.xhtml @@ -32,7 +32,7 @@ function test_crash() { var menupopup = document.getElementById("menupopup"); var menuitem = document.getElementById("menuitem"); menupopup.addEventListener("popupshown", function () { - menuitem.addEventListener("mouseup", function (e) { + menuitem.addEventListener("mouseup", function () { const observer = new MutationObserver((aMutationList, aObserver) => { for (const mutation of aMutationList) { if (mutation.attributeName != "_moz-menuactive") { diff --git a/toolkit/content/tests/chrome/test_menuitem_commands.xhtml b/toolkit/content/tests/chrome/test_menuitem_commands.xhtml index 60a35b36c5..a342b9d1d5 100644 --- a/toolkit/content/tests/chrome/test_menuitem_commands.xhtml +++ b/toolkit/content/tests/chrome/test_menuitem_commands.xhtml @@ -49,10 +49,10 @@ function runTestSet(suffix) var three = $("three" + suffix); var four = $("four" + suffix); - checkAttributes(one, "One", "", "", true, false); - checkAttributes(two, "", "", "false", false, false); + checkAttributes(one, "One", null, null, true, false); + checkAttributes(two, null, null, "false", false, false); checkAttributes(three, "Three", "T", "true", false, false); - checkAttributes(four, "Four", "F", "", false, false); + checkAttributes(four, "Four", "F", null, false, false); if (isMac && suffix) { var utils = window.windowUtils; @@ -62,8 +62,8 @@ function runTestSet(suffix) $("menu" + suffix).open = true; } - checkAttributes(one, "One", "", "", false, true); - checkAttributes(two, "Cat", "C", "", false, true); + checkAttributes(one, "One", null, null, false, true); + checkAttributes(two, "Cat", "C", null, false, true); checkAttributes(three, "Dog", "D", "false", true, true); checkAttributes(four, "Four", "F", "true", false, true); diff --git a/toolkit/content/tests/chrome/test_menulist_in_popup.xhtml b/toolkit/content/tests/chrome/test_menulist_in_popup.xhtml index 971fe90322..75fb19adcf 100644 --- a/toolkit/content/tests/chrome/test_menulist_in_popup.xhtml +++ b/toolkit/content/tests/chrome/test_menulist_in_popup.xhtml @@ -17,7 +17,7 @@ async function runTest() { let menulist = document.getElementById("menulist"); let menulistPopup = document.getElementById("menulistpopup"); - menulistPopup.addEventListener("popupshown", function(e) { + menulistPopup.addEventListener("popupshown", function() { ok(false, "Menulist popup shown"); }); diff --git a/toolkit/content/tests/chrome/test_menulist_initial_selection.xhtml b/toolkit/content/tests/chrome/test_menulist_initial_selection.xhtml index 19e9beae67..255318f5a7 100644 --- a/toolkit/content/tests/chrome/test_menulist_initial_selection.xhtml +++ b/toolkit/content/tests/chrome/test_menulist_initial_selection.xhtml @@ -29,6 +29,9 @@ async function runTest() { is(menulist2.value, "", "menulist2 should not be selected to the first item's value"); is(menulist2.label, "None", "menulist2 should not be selected to the first item's value"); + is(menulist1.menupopup.querySelectorAll('menuitem[selected="true"]').length, 1, "menulist1 should have only one selected item."); + is(menulist2.menupopup.querySelectorAll('menuitem[selected="true"]').length, 0, "menulist2 should have no selected items."); + SimpleTest.finish(); } @@ -37,17 +40,17 @@ async function runTest() { <panel> <menulist id="menulist1" value="" label="None"> - <menupopup id="menulistpopup"> + <menupopup id="menulistpopup1"> <menuitem value="1" label="One"/> <menuitem value="2" label="Two"/> <menuitem value="3" label="Three"/> </menupopup> </menulist> <menulist id="menulist2" value="" label="None" noinitialselection="true"> - <menupopup id="menulistpopup"> - <menuitem value="1" label="One"/> - <menuitem value="2" label="Two"/> - <menuitem value="3" label="Three"/> + <menupopup id="menulistpopup2"> + <menuitem value="4" label="Four"/> + <menuitem value="5" label="Five"/> + <menuitem value="6" label="Six"/> </menupopup> </menulist> </panel> diff --git a/toolkit/content/tests/chrome/test_menulist_initial_selection_with_connected_callback.xhtml b/toolkit/content/tests/chrome/test_menulist_initial_selection_with_connected_callback.xhtml new file mode 100644 index 0000000000..2c9b462948 --- /dev/null +++ b/toolkit/content/tests/chrome/test_menulist_initial_selection_with_connected_callback.xhtml @@ -0,0 +1,80 @@ +<window title="Menulist Initial Selection Connected Callback Test" + onload="setTimeout(runTest, 0)" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> +<script> +<![CDATA[ +SimpleTest.waitForExplicitFinish(); + +async function runTest() { + const panel = document.querySelector("panel"); + + // Dynamically initialize two menulists, one with the noinitialselection + // attribute and one without, but ensure that their delayConnectedCallback + // functions always return true to ensure that connectedCallback will not run yet. + const menulist1 = document.createXULElement("menulist"); + menulist1.delayConnectedCallback = () => true; + menulist1.setAttribute("id", "menulist1"); + menulist1.appendItem(/* label */ "One", /* id */ "1"); + menulist1.appendItem(/* label */ "Two", /* id */ "2"); + menulist1.appendItem(/* label */ "Three", /* id */ "3"); + is(menulist1.menupopup.querySelectorAll('menuitem[selected="true"]').length, 0, "menulist1 should have no selected items yet."); + + const menulist2 = document.createXULElement("menulist"); + menulist2.delayConnectedCallback = () => true; + menulist2.setAttribute("id", "menulist2"); + menulist2.setAttribute("noinitialselection", "true"); + menulist2.appendItem(/* label */ "Four", /* id */ "4"); + menulist2.appendItem(/* label */ "Five", /* id */ "5"); + menulist2.appendItem(/* label */ "Six", /* id */ "6"); + is(menulist2.menupopup.querySelectorAll('menuitem[selected="true"]').length, 0, "menulist2 should have no selected items yet."); + + // Set their values before allowing connectedCallback to run, simulating + // a race condition where an initial value is manually set before the + // connectedCallback is invoked. + menulist1.value = "2"; + panel.appendChild(menulist1); + menulist1.delayConnectedCallback = () => false; + menulist1.connectedCallback(); + + menulist2.value = "5"; + panel.appendChild(menulist2); + menulist2.delayConnectedCallback = () => false; + menulist2.connectedCallback(); + + const panelShown = new Promise(r => panel.addEventListener("popupshown", r, { once: true })); + info("opening panel"); + panel.openPopup(null, { x: 0, y: 0 }); + await panelShown; + info("panel opened"); + + is(menulist1.value, "2", "menulist1 should have the second menuitem's value"); + is(menulist1.label, "Two", "menulist1 should have the second menuitem's label"); + is(menulist1.menupopup.querySelectorAll('menuitem[selected="true"]').length, 1, "menulist1 should have only one selected item."); + + is(menulist2.value, "5", "menulist2 should not be selected to the second item's value"); + is(menulist2.label, "Five", "menulist2 should not be selected to the second item's value"); + is(menulist2.menupopup.querySelectorAll('menuitem[selected="true"]').length, 1, "menulist2 should have only one selected item."); + + menulist1.value = "3"; + menulist2.value = "6"; + + is(menulist1.value, "3", "menulist1 should have the third menuitem's value"); + is(menulist1.label, "Three", "menulist1 should have the third menuitem's label"); + is(menulist1.menupopup.querySelectorAll('menuitem[selected="true"]').length, 1, "menulist1 should have only one selected item."); + + is(menulist2.value, "6", "menulist2 should not be selected to the third item's value"); + is(menulist2.label, "Six", "menulist2 should not be selected to the third item's value"); + is(menulist2.menupopup.querySelectorAll('menuitem[selected="true"]').length, 1, "menulist2 should have only one selected item."); + + SimpleTest.finish(); +} + +]]> +</script> +<panel></panel> +</window> + + diff --git a/toolkit/content/tests/chrome/test_menulist_null_value.xhtml b/toolkit/content/tests/chrome/test_menulist_null_value.xhtml index 9312c236dc..e0ef42f5bd 100644 --- a/toolkit/content/tests/chrome/test_menulist_null_value.xhtml +++ b/toolkit/content/tests/chrome/test_menulist_null_value.xhtml @@ -34,7 +34,7 @@ function runTests() list.selectedItem = null; is(list.value, "", "Check list value after setting selectedItem to null"); - is(list.getAttribute("label"), "", "Check list label after setting selectedItem to null"); + is(list.getAttribute("label"), null, "Check list label after setting selectedItem to null"); // select something again to make sure the label is not already empty list.selectedIndex = 1; @@ -61,14 +61,14 @@ function runTests() // set the value to null and test it (bug 408940) list.value = null; is(list.value, "", "Check list value after setting value to null"); - is(list.getAttribute("label"), "", "Check list label after setting value to null"); + is(list.getAttribute("label"), null, "Check list label after setting value to null"); // select something again to make sure the label is not already empty list.selectedIndex = 1; // set the value to undefined and test it (bug 408940) list.value = undefined; is(list.value, "", "Check list value after setting value to undefined"); - is(list.getAttribute("label"), "", "Check list label after setting value to undefined"); + is(list.getAttribute("label"), null, "Check list label after setting value to undefined"); // select something again to make sure the label is not already empty list.selectedIndex = 1; @@ -76,7 +76,7 @@ function runTests() // and make sure the previous label is removed list.value = "this does not exist"; is(list.value, "this does not exist", "Check the list value after setting it to something not associated witn an existing menuitem"); - is(list.getAttribute("label"), "", "Check that the list label is empty after selecting a nonexistent item"); + is(list.getAttribute("label"), null, "Check that the list label is empty after selecting a nonexistent item"); SimpleTest.finish(); } diff --git a/toolkit/content/tests/chrome/test_notificationbox.xhtml b/toolkit/content/tests/chrome/test_notificationbox.xhtml index 8de985175a..9a2bc9d888 100644 --- a/toolkit/content/tests/chrome/test_notificationbox.xhtml +++ b/toolkit/content/tests/chrome/test_notificationbox.xhtml @@ -89,8 +89,8 @@ function testtag_notificationbox_buttonpressed(notification, button) } let buttonsPressedLog = ""; -function testtag_notificationbox_button1pressed(notification, button) { buttonsPressedLog += "button1"; return true; } -function testtag_notificationbox_button2pressed(notification, button) { buttonsPressedLog += "button2"; return true; } +function testtag_notificationbox_button1pressed() { buttonsPressedLog += "button1"; return true; } +function testtag_notificationbox_button2pressed() { buttonsPressedLog += "button2"; return true; } function testtag_notificationbox(nb) { @@ -227,7 +227,7 @@ var tests = nb.removeNotification(ntf); return ntf; }, - result(nb, ntf) { + result(nb) { testtag_notificationbox_State(nb, "removeNotification", null, 0); } }, @@ -394,7 +394,7 @@ var tests = nb.removeCurrentNotification(); return ntf; }, - result(nb, ntf) { + result(nb) { testtag_notificationbox_State(nb, "removeCurrentNotification", null, 0); } }, @@ -451,7 +451,7 @@ var tests = }, testtag_notificationbox_buttons_nopopup); return ntf; }, - result(nb, ntf) { + result(nb) { let buttons = nb.currentNotification.buttonContainer.querySelectorAll("* button"); buttons[0].focus(); @@ -510,7 +510,7 @@ var tests = } }, { - async test(nb, unused) { + async test(nb) { // add a number of notifications and check that they are added in order await nb.appendNotification("4", { label: "Four", priority: nb.PRIORITY_INFO_HIGH }, testtag_notificationbox_buttons); @@ -537,11 +537,11 @@ var tests = { // test closing notifications to make sure that the current notification is still set properly repeat: true, - test(nb, testidx) { + test() { this.repeat = false; return undefined; }, - result(nb, arr) { + result(nb) { let notificationOrder = [4, 7, 2, 8, 5, 6, 1, 9, 10, 3]; let allNotificationValues = [...nb.stack.children].map(n => n.getAttribute("value")); is(allNotificationValues.length, notificationOrder.length, "Expected number of notifications"); @@ -556,7 +556,7 @@ var tests = } }, { - async test(nb, ntf) { + async test(nb) { var exh = false; try { await nb.appendNotification("no", { label: "no", priority: -1 }); diff --git a/toolkit/content/tests/chrome/test_popup_keys.xhtml b/toolkit/content/tests/chrome/test_popup_keys.xhtml index 6b8dd31143..e72c496a59 100644 --- a/toolkit/content/tests/chrome/test_popup_keys.xhtml +++ b/toolkit/content/tests/chrome/test_popup_keys.xhtml @@ -37,7 +37,7 @@ let gLastFirstMenuActiveValue = null; function waitForEvent(target, eventName) { return new Promise(resolve => { - target.addEventListener(eventName, function eventOccurred(event) { + target.addEventListener(eventName, function eventOccurred() { resolve(); }, { once: true}); }); diff --git a/toolkit/content/tests/chrome/test_popup_moveToAnchor.xhtml b/toolkit/content/tests/chrome/test_popup_moveToAnchor.xhtml index a7800caaad..628ff2a851 100644 --- a/toolkit/content/tests/chrome/test_popup_moveToAnchor.xhtml +++ b/toolkit/content/tests/chrome/test_popup_moveToAnchor.xhtml @@ -20,7 +20,7 @@ <script> SimpleTest.waitForExplicitFinish(); -function runTest(id) +function runTest() { $("popup").openPopup($("button1"), "after_start"); } diff --git a/toolkit/content/tests/chrome/test_richlistbox.xhtml b/toolkit/content/tests/chrome/test_richlistbox.xhtml index 48303e0172..65f3626a8c 100644 --- a/toolkit/content/tests/chrome/test_richlistbox.xhtml +++ b/toolkit/content/tests/chrome/test_richlistbox.xhtml @@ -5,7 +5,6 @@ XUL Widget Test for listbox direction --> <window title="Listbox direction test" - onload="test_richlistbox()" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> @@ -26,8 +25,7 @@ function getScrollIndexAmount(aDirection) { return (4 * aDirection + richListBox.currentIndex); } -function test_richlistbox() -{ +add_task(function test_richlistbox() { var height = richListBox.clientHeight; var item; do { @@ -93,9 +91,22 @@ function test_richlistbox() richListBox.selectedItem = richListBox.firstChild; richListBox.firstChild.nextSibling.setAttribute("disabled", true); richListBox.focus(); + synthesizeKey("KEY_ArrowDown", {}, window); is(richListBox.selectedItems.length, 1, "one item selected"); - is(richListBox.selectedItems[0], richListBox.firstChild, "first item selected"); + is(richListBox.selectedItems[0], richListBox.getItemAtIndex(2), "skipped over disabled item on keydown"); + + synthesizeKey("KEY_ArrowUp", {}, window); + is(richListBox.selectedItems.length, 1, "one item selected"); + is(richListBox.selectedItems[0], richListBox.firstChild, "skipped over disabled item on keyup"); + + synthesizeMouseAtCenter(richListBox.getItemAtIndex(1), {}); + is(richListBox.selectedItems.length, 1, "one item selected"); + is(richListBox.selectedItems[0], richListBox.firstChild, "cannot select disabled item"); + + synthesizeMouseAtCenter(richListBox.getItemAtIndex(2), {}); + is(richListBox.selectedItems.length, 1, "one item selected"); + is(richListBox.selectedItems[0], richListBox.getItemAtIndex(2), "can select enabled item"); // Selected item re-insertion should keep the item selected. richListBox.clearSelection(); @@ -107,9 +118,7 @@ function test_richlistbox() richListBox.append(item); is(richListBox.selectedItems.length, 1, "one item selected"); is(richListBox.selectedItems[0], item, "last (previosly first) item selected"); - - SimpleTest.finish(); -} +}); ]]> </script> diff --git a/toolkit/content/tests/chrome/test_tree_view.xhtml b/toolkit/content/tests/chrome/test_tree_view.xhtml index 5e45161c6c..c9ec889995 100644 --- a/toolkit/content/tests/chrome/test_tree_view.xhtml +++ b/toolkit/content/tests/chrome/test_tree_view.xhtml @@ -24,23 +24,23 @@ var view = value: "", rowCount: 8, getCellText(row, column) { return this.treeData[row % 4][column.index]; }, - getCellValue(row, column) { return this.value; }, + getCellValue() { 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; }, + isContainer() { return false; }, + isContainerOpen() { return false; }, + isContainerEmpty() { return false; }, + isSeparator() { return false; }, + isSorted() { 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 ""; }, + getParentIndex() { return -1; }, + getLevel() { return 0; }, + hasNextSibling(row) { return row != this.rowCount - 1; }, + getImageSrc() { return ""; }, + cycleHeader() { }, + getRowProperties() { return ""; }, + getCellProperties() { return ""; }, getColumnProperties(column) { if (!column.index) { diff --git a/toolkit/content/tests/chrome/window_chromemargin.xhtml b/toolkit/content/tests/chrome/window_chromemargin.xhtml index 81bcba62fe..8c7cf5c0d3 100644 --- a/toolkit/content/tests/chrome/window_chromemargin.xhtml +++ b/toolkit/content/tests/chrome/window_chromemargin.xhtml @@ -16,15 +16,19 @@ function ok(condition, message) { window.arguments[0].SimpleTest.ok(condition, message); } +function is(a, b, message) { + window.arguments[0].SimpleTest.is(a, b, message); +} + function doSingleTest(param) { var exception = null; try { document.documentElement.removeAttribute("chromemargin"); document.documentElement.setAttribute("chromemargin", param); - ok(document. + is(document. documentElement. - getAttribute("chromemargin") == param, "couldn't set/get chromemargin?"); + getAttribute("chromemargin"), param, "couldn't set/get chromemargin?"); } catch (ex) { exception = ex; } @@ -44,7 +48,7 @@ function runTests() // test remove doc.removeAttribute("chromemargin"); - ok(doc.getAttribute("chromemargin") == "", "couldn't remove chromemargin?"); + is(doc.getAttribute("chromemargin"), null, "couldn't remove chromemargin?"); // we already test these really well in a c++ test in widget doSingleTest("1,2,3,4"); diff --git a/toolkit/content/tests/chrome/window_cursorsnap_dialog.xhtml b/toolkit/content/tests/chrome/window_cursorsnap_dialog.xhtml index d5c0e2753e..fa239a87af 100644 --- a/toolkit/content/tests/chrome/window_cursorsnap_dialog.xhtml +++ b/toolkit/content/tests/chrome/window_cursorsnap_dialog.xhtml @@ -60,7 +60,7 @@ function finish() window.close(); } -function onMouseMove(aEvent) +function onMouseMove() { var button = document.getElementById("dialog").getButton("accept"); if (button.disabled) diff --git a/toolkit/content/tests/chrome/window_keys.xhtml b/toolkit/content/tests/chrome/window_keys.xhtml index 77a098ef0b..51f3be0a33 100644 --- a/toolkit/content/tests/chrome/window_keys.xhtml +++ b/toolkit/content/tests/chrome/window_keys.xhtml @@ -82,7 +82,7 @@ function runTest() document.documentElement.appendChild(keyset); iterateKeys(true, "appended"); - var accelText = menuitem => menuitem.getAttribute("acceltext").toLowerCase(); + var accelText = menuitem => (menuitem.getAttribute("acceltext") || "").toLowerCase(); $("menubutton").open = true; diff --git a/toolkit/content/tests/chrome/window_largemenu.xhtml b/toolkit/content/tests/chrome/window_largemenu.xhtml index d84b045e78..8e6b6718b4 100644 --- a/toolkit/content/tests/chrome/window_largemenu.xhtml +++ b/toolkit/content/tests/chrome/window_largemenu.xhtml @@ -363,8 +363,8 @@ function testPopupMovement() is(screenX, expectedx, gTests[gTestIndex] + " (6000, 100) x"); is(screenY, 100, gTests[gTestIndex] + " (6000, 100) y"); - is(popup.getAttribute("left"), "", gTests[gTestIndex] + " left is empty after moving"); - is(popup.getAttribute("top"), "", gTests[gTestIndex] + " top is empty after moving"); + is(popup.getAttribute("left"), null, gTests[gTestIndex] + " left is empty after moving"); + is(popup.getAttribute("top"), null, gTests[gTestIndex] + " top is empty after moving"); popup.setAttribute("left", "80"); popup.setAttribute("top", "82"); [screenX, screenY] = getScreenXY(popup); @@ -387,8 +387,8 @@ function testPopupMovement() is(screenX, expectedx, gTests[gTestIndex] + " move after set left and top x to -1"); is(screenY, expectedy, gTests[gTestIndex] + " move after set left and top y to -1"); - is(popup.getAttribute("left"), "", gTests[gTestIndex] + " left is not set after moving to -1"); - is(popup.getAttribute("top"), "", gTests[gTestIndex] + " top is not set after moving to -1"); + is(popup.getAttribute("left"), null, gTests[gTestIndex] + " left is not set after moving to -1"); + is(popup.getAttribute("top"), null, gTests[gTestIndex] + " top is not set after moving to -1"); popup.hidePopup(); } diff --git a/toolkit/content/tests/chrome/window_maximized_persist.xhtml b/toolkit/content/tests/chrome/window_maximized_persist.xhtml index f7eb695f0f..10f7d36d07 100644 --- a/toolkit/content/tests/chrome/window_maximized_persist.xhtml +++ b/toolkit/content/tests/chrome/window_maximized_persist.xhtml @@ -8,7 +8,7 @@ id="window" persist="height width sizemode"> <script type="application/javascript"><![CDATA[ - window.addEventListener("sizemodechange", evt => { + window.addEventListener("sizemodechange", () => { window.arguments[0].postMessage("sizemodechange", "*"); }); ]]></script> diff --git a/toolkit/content/tests/chrome/window_maximized_persist_with_no_titlebar.xhtml b/toolkit/content/tests/chrome/window_maximized_persist_with_no_titlebar.xhtml index 83fede7fae..e104dfa652 100644 --- a/toolkit/content/tests/chrome/window_maximized_persist_with_no_titlebar.xhtml +++ b/toolkit/content/tests/chrome/window_maximized_persist_with_no_titlebar.xhtml @@ -9,7 +9,7 @@ id="window" persist="height width sizemode"> <script type="application/javascript"><![CDATA[ - window.addEventListener("sizemodechange", evt => { + window.addEventListener("sizemodechange", () => { window.arguments[0].postMessage("sizemodechange", "*"); }); ]]></script> diff --git a/toolkit/content/tests/chrome/window_popup_anchoratrect.xhtml b/toolkit/content/tests/chrome/window_popup_anchoratrect.xhtml index 524a95b643..2262ba08e9 100644 --- a/toolkit/content/tests/chrome/window_popup_anchoratrect.xhtml +++ b/toolkit/content/tests/chrome/window_popup_anchoratrect.xhtml @@ -79,7 +79,7 @@ let tests = [ }, ]; -function runTest(id) +function runTest() { menupopup = $("popup"); nextTest(); diff --git a/toolkit/content/tests/chrome/window_tooltip.xhtml b/toolkit/content/tests/chrome/window_tooltip.xhtml index b78075de45..e6ee5c6b42 100644 --- a/toolkit/content/tests/chrome/window_tooltip.xhtml +++ b/toolkit/content/tests/chrome/window_tooltip.xhtml @@ -30,6 +30,8 @@ var gOriginalWidth = -1; var gOriginalHeight = -1; var gButton = null; +const kTooltipOffsetVertical = 10; + function runTest() { startPopupTests(popupTests); @@ -112,7 +114,7 @@ var popupTests = [ Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 6), testname + " left position of tooltip"); is(Math.round(rect.top), - Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6), + Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6 + kTooltipOffsetVertical), testname + " top position of tooltip"); var labelrect = document.getElementById("label").getBoundingClientRect(); @@ -159,7 +161,7 @@ var popupTests = [ Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 4), testname + " left position of tooltip"); is(Math.round(rect.top), - Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 4), + Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 4 + kTooltipOffsetVertical), testname + " top position of tooltip"); var labelrect = document.getElementById("label").getBoundingClientRect(); @@ -204,7 +206,7 @@ var popupTests = [ Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 6), testname + " left position of tooltip"); is(Math.round(rect.top), - Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6), + Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6 + kTooltipOffsetVertical), testname + " top position of tooltip"); var labelrect = document.getElementById("label").getBoundingClientRect(); @@ -327,7 +329,43 @@ var popupTests = [ // that the original height has increased by at least 10 pixels ok(gOriginalHeight + 10 < rect.bottom - rect.top, testname + " tooltip is wrapped"); } -} +}, +{ + testname: "anchored tooltip with no offset", + events: ["popupshowing thetooltip", "popupshown thetooltip"], + autohide: "thetooltip", + test() { + gButton = document.getElementById("withtooltip"); + document + .getElementById("thetooltip") + .setAttribute( + "onpopupshowing", + "this.moveToAnchor(this.triggerNode, 'after_start');" + ); + disableNonTestMouse(true); + synthesizeMouse(gButton, 2, 2, { type: "mouseover" }); + synthesizeMouse(gButton, 4, 4, { type: "mousemove" }); + synthesizeMouse(gButton, 6, 6, { type: "mousemove" }); + disableNonTestMouse(false); + }, + result(testname) { + var buttonrect = document + .getElementById("withtooltip") + .getBoundingClientRect(); + var tooltip = document.getElementById("thetooltip"); + var rect = tooltip.getBoundingClientRect(); + var popupstyle = window.getComputedStyle(tooltip); + + // Offset does not apply to anchored tooltips + is( + Math.round(rect.top), + Math.round(buttonrect.bottom + parseFloat(popupstyle.marginTop)), + testname + " top position of tooltip" + ); + + tooltip.removeAttribute("onpopupshowing"); + }, +}, ]; var waitSteps = 0; @@ -359,7 +397,14 @@ function moveWindowTo(x, y, callback, arg) } } -window.arguments[0].SimpleTest.waitForFocus(runTest, window); +(async function() { + let parent = window.arguments[0]; + await Promise.all([ + parent.SimpleTest.promiseFocus(window), + parent.SpecialPowers.pushPrefEnv({set: [["ui.tooltipOffsetVertical", kTooltipOffsetVertical]]}), + ]); + runTest(); +})(); ]]> </script> |