зеркало из https://github.com/mozilla/pjs.git
Bug 572969 [SeaMonkey][OSX] Mochitest-3 test_(htmleditor|texteditor)_keyevent_handling.html has 96 (perma)failures r=ehsan
This commit is contained in:
Родитель
59205bf1f7
Коммит
b3c8454ce3
|
@ -62,8 +62,7 @@ function runTests()
|
|||
};
|
||||
|
||||
function check(aDescription,
|
||||
aFiredOnCapture, aPreventedOnCapture,
|
||||
aFiredOnBubbling, aPreventedOnBubbling)
|
||||
aFiredOnCapture, aFiredOnBubbling, aPreventedOnBubbling)
|
||||
{
|
||||
function getDesciption(aExpected)
|
||||
{
|
||||
|
@ -71,10 +70,17 @@ function runTests()
|
|||
}
|
||||
is(capturingPhase.fired, aFiredOnCapture,
|
||||
getDesciption(aFiredOnCapture) + "fired on capture phase");
|
||||
is(capturingPhase.prevented, aPreventedOnCapture,
|
||||
getDesciption(aPreventedOnCapture) + "prevented on capture phase");
|
||||
is(bubblingPhase.fired, aFiredOnBubbling,
|
||||
getDesciption(aFiredOnBubbling) + "fired on bubbling phase");
|
||||
|
||||
// If the event is fired on bubbling phase and it was already prevented
|
||||
// on capture phase, it must be prevented on bubbling phase too.
|
||||
if (capturingPhase.prevented) {
|
||||
todo(false, aDescription +
|
||||
" was consumed already, so, we cannot test the editor behavior actually");
|
||||
aPreventedOnBubbling = true;
|
||||
}
|
||||
|
||||
is(bubblingPhase.prevented, aPreventedOnBubbling,
|
||||
getDesciption(aPreventedOnBubbling) + "prevented on bubbling phase");
|
||||
}
|
||||
|
@ -132,22 +138,22 @@ function runTests()
|
|||
// Only when editor is editable, it consumes.
|
||||
reset("");
|
||||
synthesizeKey("VK_META", { });
|
||||
check(aDescription + "Meta", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "Meta", true, true, !aIsReadonly);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_SHIFT", { });
|
||||
check(aDescription + "Shift", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "Shift", true, true, !aIsReadonly);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_CONTROL", { });
|
||||
check(aDescription + "Control", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "Control", true, true, !aIsReadonly);
|
||||
|
||||
// Alt key press event installs menubar key event listener, so,
|
||||
// we should pass Alt key testing on Windows and Linux.
|
||||
if (!kIsWin && !kIsLinux) {
|
||||
reset("");
|
||||
synthesizeKey("VK_ALT", { });
|
||||
check(aDescription + "Alt", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "Alt", true, true, !aIsReadonly);
|
||||
}
|
||||
|
||||
// Backspace key:
|
||||
|
@ -156,23 +162,23 @@ function runTests()
|
|||
// Otherwise, editor doesn't consume the event.
|
||||
reset("");
|
||||
synthesizeKey("VK_BACK_SPACE", { });
|
||||
check(aDescription + "Backspace", true, false, true, true);
|
||||
check(aDescription + "Backspace", true, true, true);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_BACK_SPACE", { shiftKey: true });
|
||||
check(aDescription + "Shift+Backspace", true, false, true, true);
|
||||
check(aDescription + "Shift+Backspace", true, true, true);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_BACK_SPACE", { ctrlKey: true });
|
||||
check(aDescription + "Ctrl+Backspace", true, false, true, aIsReadonly);
|
||||
check(aDescription + "Ctrl+Backspace", true, true, aIsReadonly);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_BACK_SPACE", { altKey: true });
|
||||
check(aDescription + "Alt+Backspace", true, false, true, aIsReadonly);
|
||||
check(aDescription + "Alt+Backspace", true, true, aIsReadonly);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_BACK_SPACE", { metaKey: true });
|
||||
check(aDescription + "Meta+Backspace", true, false, true, aIsReadonly);
|
||||
check(aDescription + "Meta+Backspace", true, true, aIsReadonly);
|
||||
|
||||
// Delete key:
|
||||
// If editor is readonly, it doesn't consume.
|
||||
|
@ -180,23 +186,23 @@ function runTests()
|
|||
// Otherwise, editor doesn't consume the event.
|
||||
reset("");
|
||||
synthesizeKey("VK_DELETE", { });
|
||||
check(aDescription + "Delete", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "Delete", true, true, !aIsReadonly);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_DELETE", { shiftKey: true });
|
||||
check(aDescription + "Shift+Delete", true, false, true, false);
|
||||
check(aDescription + "Shift+Delete", true, true, false);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_DELETE", { ctrlKey: true });
|
||||
check(aDescription + "Ctrl+Delete", true, false, true, false);
|
||||
check(aDescription + "Ctrl+Delete", true, true, false);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_DELETE", { altKey: true });
|
||||
check(aDescription + "Alt+Delete", true, false, true, false);
|
||||
check(aDescription + "Alt+Delete", true, true, false);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_DELETE", { metaKey: true });
|
||||
check(aDescription + "Meta+Delete", true, false, true, false);
|
||||
check(aDescription + "Meta+Delete", true, true, false);
|
||||
|
||||
// Return key:
|
||||
// If editor is readonly, it doesn't consume.
|
||||
|
@ -206,30 +212,30 @@ function runTests()
|
|||
reset("a");
|
||||
synthesizeKey("VK_RETURN", { });
|
||||
check(aDescription + "Return",
|
||||
true, false, true, !aIsReadonly);
|
||||
true, true, !aIsReadonly);
|
||||
is(aElement.innerHTML, aIsReadonly ? "a" : "a<br><br>",
|
||||
aDescription + "Return");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_RETURN", { shiftKey: true });
|
||||
check(aDescription + "Shift+Return",
|
||||
true, false, true, !aIsReadonly);
|
||||
true, true, !aIsReadonly);
|
||||
is(aElement.innerHTML, aIsReadonly ? "a" : "a<br><br>",
|
||||
aDescription + "Shift+Return");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_RETURN", { ctrlKey: true });
|
||||
check(aDescription + "Ctrl+Return", true, false, true, false);
|
||||
check(aDescription + "Ctrl+Return", true, true, false);
|
||||
is(aElement.innerHTML, "a", aDescription + "Ctrl+Return");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_RETURN", { altKey: true });
|
||||
check(aDescription + "Alt+Return", true, false, true, false);
|
||||
check(aDescription + "Alt+Return", true, true, false);
|
||||
is(aElement.innerHTML, "a", aDescription + "Alt+Return");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_RETURN", { metaKey: true });
|
||||
check(aDescription + "Meta+Return", true, false, true, false);
|
||||
check(aDescription + "Meta+Return", true, true, false);
|
||||
is(aElement.innerHTML, "a", aDescription + "Meta+Return");
|
||||
|
||||
// Enter key (same as Return key):
|
||||
|
@ -240,30 +246,30 @@ function runTests()
|
|||
reset("a");
|
||||
synthesizeKey("VK_ENTER", { });
|
||||
check(aDescription + "Enter",
|
||||
true, false, true, !aIsReadonly);
|
||||
true, true, !aIsReadonly);
|
||||
is(aElement.innerHTML, aIsReadonly ? "a" : "a<br><br>",
|
||||
aDescription + "Enter");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_ENTER", { shiftKey: true });
|
||||
check(aDescription + "Shift+Enter",
|
||||
true, false, true, !aIsReadonly);
|
||||
true, true, !aIsReadonly);
|
||||
is(aElement.innerHTML, aIsReadonly ? "a" : "a<br><br>",
|
||||
aDescription + "Shift+Enter");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_ENTER", { ctrlKey: true });
|
||||
check(aDescription + "Ctrl+Enter", true, false, true, false);
|
||||
check(aDescription + "Ctrl+Enter", true, true, false);
|
||||
is(aElement.innerHTML, "a", aDescription + "Ctrl+Enter");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_ENTER", { altKey: true });
|
||||
check(aDescription + "Alt+Enter", true, false, true, false);
|
||||
check(aDescription + "Alt+Enter", true, true, false);
|
||||
is(aElement.innerHTML, "a", aDescription + "Alt+Enter");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_ENTER", { metaKey: true });
|
||||
check(aDescription + "Meta+Enter", true, false, true, false);
|
||||
check(aDescription + "Meta+Enter", true, true, false);
|
||||
is(aElement.innerHTML, "a", aDescription + "Meta+Enter");
|
||||
|
||||
// Tab key:
|
||||
|
@ -272,7 +278,7 @@ function runTests()
|
|||
reset("a");
|
||||
synthesizeKey("VK_TAB", { });
|
||||
check(aDescription + "Tab",
|
||||
true, false, true, !aIsTabbable && !aIsReadonly);
|
||||
true, true, !aIsTabbable && !aIsReadonly);
|
||||
is(aElement.innerHTML,
|
||||
aIsTabbable || aIsReadonly ? "a" :
|
||||
aIsPlaintext ? "a\t" : "a <br>",
|
||||
|
@ -282,29 +288,29 @@ function runTests()
|
|||
|
||||
reset("a");
|
||||
synthesizeKey("VK_TAB", { shiftKey: true });
|
||||
check(aDescription + "Shift+Tab", true, false, true, false);
|
||||
check(aDescription + "Shift+Tab", true, true, false);
|
||||
is(aElement.innerHTML, "a", aDescription + "Shift+Tab");
|
||||
is(fm.focusedElement, aElement,
|
||||
aDescription + "focus moved unexpectedly (Shift+Tab)");
|
||||
|
||||
// Ctrl+Tab is consumed by tabbrowser.
|
||||
// Ctrl+Tab may be consumed by tabbrowser but editor shouldn't consume this.
|
||||
reset("a");
|
||||
synthesizeKey("VK_TAB", { ctrlKey: true });
|
||||
check(aDescription + "Ctrl+Tab", true, true, true, true);
|
||||
check(aDescription + "Ctrl+Tab", true, true, false);
|
||||
is(aElement.innerHTML, "a", aDescription + "Ctrl+Tab");
|
||||
is(fm.focusedElement, aElement,
|
||||
aDescription + "focus moved unexpectedly (Ctrl+Tab)");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_TAB", { altKey: true });
|
||||
check(aDescription + "Alt+Tab", true, false, true, false);
|
||||
check(aDescription + "Alt+Tab", true, true, false);
|
||||
is(aElement.innerHTML, "a", aDescription + "Alt+Tab");
|
||||
is(fm.focusedElement, aElement,
|
||||
aDescription + "focus moved unexpectedly (Alt+Tab)");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_TAB", { metaKey: true });
|
||||
check(aDescription + "Meta+Tab", true, false, true, false);
|
||||
check(aDescription + "Meta+Tab", true, true, false);
|
||||
is(aElement.innerHTML, "a", aDescription + "Meta+Tab");
|
||||
is(fm.focusedElement, aElement,
|
||||
aDescription + "focus moved unexpectedly (Meta+Tab)");
|
||||
|
@ -314,7 +320,7 @@ function runTests()
|
|||
resetForIndent("<ul><li id=\"target\">ul list item</li></ul>");
|
||||
synthesizeKey("VK_TAB", { });
|
||||
check(aDescription + "Tab on UL",
|
||||
true, false, true, !aIsTabbable && !aIsReadonly);
|
||||
true, true, !aIsTabbable && !aIsReadonly);
|
||||
is(aElement.innerHTML,
|
||||
aIsReadonly || aIsTabbable ?
|
||||
"<ul><li id=\"target\">ul list item</li></ul>" :
|
||||
|
@ -325,7 +331,7 @@ function runTests()
|
|||
aDescription + "focus moved unexpectedly (Tab on UL)");
|
||||
synthesizeKey("VK_TAB", { shiftKey: true });
|
||||
check(aDescription + "Shift+Tab after Tab on UL",
|
||||
true, false, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
|
||||
true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
|
||||
// XXX why do we fail to outdent on non-tabbable HTML editor?
|
||||
is(aElement.innerHTML,
|
||||
aIsReadonly || aIsTabbable ?
|
||||
|
@ -339,7 +345,7 @@ function runTests()
|
|||
resetForIndent("<ul><li id=\"target\">ul list item</li></ul>");
|
||||
synthesizeKey("VK_TAB", { shiftKey: true });
|
||||
check(aDescription + "Shift+Tab on UL",
|
||||
true, false, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
|
||||
true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
|
||||
is(aElement.innerHTML,
|
||||
aIsReadonly || aIsTabbable ?
|
||||
"<ul><li id=\"target\">ul list item</li></ul>" :
|
||||
|
@ -349,10 +355,10 @@ function runTests()
|
|||
is(fm.focusedElement, aElement,
|
||||
aDescription + "focus moved unexpectedly (Shift+Tab on UL)");
|
||||
|
||||
// Ctrl+Tab is consumed by tabbrowser.
|
||||
// Ctrl+Tab may be consumed by tabbrowser but editor shouldn't consume this.
|
||||
resetForIndent("<ul><li id=\"target\">ul list item</li></ul>");
|
||||
synthesizeKey("VK_TAB", { ctrlKey: true });
|
||||
check(aDescription + "Ctrl+Tab on UL", true, true, true, true);
|
||||
check(aDescription + "Ctrl+Tab on UL", true, true, false);
|
||||
is(aElement.innerHTML, "<ul><li id=\"target\">ul list item</li></ul>",
|
||||
aDescription + "Ctrl+Tab on UL");
|
||||
is(fm.focusedElement, aElement,
|
||||
|
@ -360,7 +366,7 @@ function runTests()
|
|||
|
||||
resetForIndent("<ul><li id=\"target\">ul list item</li></ul>");
|
||||
synthesizeKey("VK_TAB", { altKey: true });
|
||||
check(aDescription + "Alt+Tab on UL", true, false, true, false);
|
||||
check(aDescription + "Alt+Tab on UL", true, true, false);
|
||||
is(aElement.innerHTML, "<ul><li id=\"target\">ul list item</li></ul>",
|
||||
aDescription + "Alt+Tab on UL");
|
||||
is(fm.focusedElement, aElement,
|
||||
|
@ -368,7 +374,7 @@ function runTests()
|
|||
|
||||
resetForIndent("<ul><li id=\"target\">ul list item</li></ul>");
|
||||
synthesizeKey("VK_TAB", { metaKey: true });
|
||||
check(aDescription + "Meta+Tab on UL", true, false, true, false);
|
||||
check(aDescription + "Meta+Tab on UL", true, true, false);
|
||||
is(aElement.innerHTML, "<ul><li id=\"target\">ul list item</li></ul>",
|
||||
aDescription + "Meta+Tab on UL");
|
||||
is(fm.focusedElement, aElement,
|
||||
|
@ -378,7 +384,7 @@ function runTests()
|
|||
resetForIndent("<ol><li id=\"target\">ol list item</li></ol>");
|
||||
synthesizeKey("VK_TAB", { });
|
||||
check(aDescription + "Tab on OL",
|
||||
true, false, true, !aIsTabbable && !aIsReadonly);
|
||||
true, true, !aIsTabbable && !aIsReadonly);
|
||||
is(aElement.innerHTML,
|
||||
aIsReadonly || aIsTabbable ?
|
||||
"<ol><li id=\"target\">ol list item</li></ol>" :
|
||||
|
@ -389,7 +395,7 @@ function runTests()
|
|||
aDescription + "focus moved unexpectedly (Tab on OL)");
|
||||
synthesizeKey("VK_TAB", { shiftKey: true });
|
||||
check(aDescription + "Shift+Tab after Tab on OL",
|
||||
true, false, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
|
||||
true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
|
||||
// XXX why do we fail to outdent on non-tabbable HTML editor?
|
||||
is(aElement.innerHTML,
|
||||
aIsReadonly || aIsTabbable ?
|
||||
|
@ -403,7 +409,7 @@ function runTests()
|
|||
resetForIndent("<ol><li id=\"target\">ol list item</li></ol>");
|
||||
synthesizeKey("VK_TAB", { shiftKey: true });
|
||||
check(aDescription + "Shift+Tab on OL",
|
||||
true, false, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
|
||||
true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
|
||||
is(aElement.innerHTML,
|
||||
aIsReadonly || aIsTabbable ?
|
||||
"<ol><li id=\"target\">ol list item</li></ol>" :
|
||||
|
@ -413,10 +419,10 @@ function runTests()
|
|||
is(fm.focusedElement, aElement,
|
||||
aDescription + "focus moved unexpectedly (Shift+Tab on OL)");
|
||||
|
||||
// Ctrl+Tab is consumed by tabbrowser.
|
||||
// Ctrl+Tab may be consumed by tabbrowser but editor shouldn't consume this.
|
||||
resetForIndent("<ol><li id=\"target\">ol list item</li></ol>");
|
||||
synthesizeKey("VK_TAB", { ctrlKey: true });
|
||||
check(aDescription + "Ctrl+Tab on OL", true, true, true, true);
|
||||
check(aDescription + "Ctrl+Tab on OL", true, true, false);
|
||||
is(aElement.innerHTML, "<ol><li id=\"target\">ol list item</li></ol>",
|
||||
aDescription + "Ctrl+Tab on OL");
|
||||
is(fm.focusedElement, aElement,
|
||||
|
@ -424,7 +430,7 @@ function runTests()
|
|||
|
||||
resetForIndent("<ol><li id=\"target\">ol list item</li></ol>");
|
||||
synthesizeKey("VK_TAB", { altKey: true });
|
||||
check(aDescription + "Alt+Tab on OL", true, false, true, false);
|
||||
check(aDescription + "Alt+Tab on OL", true, true, false);
|
||||
is(aElement.innerHTML, "<ol><li id=\"target\">ol list item</li></ol>",
|
||||
aDescription + "Alt+Tab on OL");
|
||||
is(fm.focusedElement, aElement,
|
||||
|
@ -432,7 +438,7 @@ function runTests()
|
|||
|
||||
resetForIndent("<ol><li id=\"target\">ol list item</li></ol>");
|
||||
synthesizeKey("VK_TAB", { metaKey: true });
|
||||
check(aDescription + "Meta+Tab on OL", true, false, true, false);
|
||||
check(aDescription + "Meta+Tab on OL", true, true, false);
|
||||
is(aElement.innerHTML, "<ol><li id=\"target\">ol list item</li></ol>",
|
||||
aDescription + "Meta+Tab on OL");
|
||||
is(fm.focusedElement, aElement,
|
||||
|
@ -442,7 +448,7 @@ function runTests()
|
|||
resetForIndent("<table><tr><td id=\"target\">td</td></tr></table>");
|
||||
synthesizeKey("VK_TAB", { });
|
||||
check(aDescription + "Tab on TD",
|
||||
true, false, true, !aIsTabbable && !aIsReadonly);
|
||||
true, true, !aIsTabbable && !aIsReadonly);
|
||||
is(aElement.innerHTML,
|
||||
aIsTabbable || aIsReadonly ?
|
||||
"<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>" :
|
||||
|
@ -453,7 +459,7 @@ function runTests()
|
|||
aDescription + "focus moved unexpectedly (Tab on TD)");
|
||||
synthesizeKey("VK_TAB", { shiftKey: true });
|
||||
check(aDescription + "Shift+Tab after Tab on TD",
|
||||
true, false, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
|
||||
true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
|
||||
is(aElement.innerHTML,
|
||||
aIsTabbable || aIsReadonly ?
|
||||
"<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>" :
|
||||
|
@ -465,17 +471,17 @@ function runTests()
|
|||
|
||||
resetForIndent("<table><tr><td id=\"target\">td</td></tr></table>");
|
||||
synthesizeKey("VK_TAB", { shiftKey: true });
|
||||
check(aDescription + "Shift+Tab on TD", true, false, true, false);
|
||||
check(aDescription + "Shift+Tab on TD", true, true, false);
|
||||
is(aElement.innerHTML,
|
||||
"<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>",
|
||||
aDescription + "Shift+Tab on TD");
|
||||
is(fm.focusedElement, aElement,
|
||||
aDescription + "focus moved unexpectedly (Shift+Tab on TD)");
|
||||
|
||||
// Ctrl+Tab is consumed by tabbrowser.
|
||||
// Ctrl+Tab may be consumed by tabbrowser but editor shouldn't consume this.
|
||||
resetForIndent("<table><tr><td id=\"target\">td</td></tr></table>");
|
||||
synthesizeKey("VK_TAB", { ctrlKey: true });
|
||||
check(aDescription + "Ctrl+Tab on TD", true, true, true, true);
|
||||
check(aDescription + "Ctrl+Tab on TD", true, true, false);
|
||||
is(aElement.innerHTML,
|
||||
"<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>",
|
||||
aDescription + "Ctrl+Tab on TD");
|
||||
|
@ -484,7 +490,7 @@ function runTests()
|
|||
|
||||
resetForIndent("<table><tr><td id=\"target\">td</td></tr></table>");
|
||||
synthesizeKey("VK_TAB", { altKey: true });
|
||||
check(aDescription + "Alt+Tab on TD", true, false, true, false);
|
||||
check(aDescription + "Alt+Tab on TD", true, true, false);
|
||||
is(aElement.innerHTML,
|
||||
"<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>",
|
||||
aDescription + "Alt+Tab on TD");
|
||||
|
@ -493,7 +499,7 @@ function runTests()
|
|||
|
||||
resetForIndent("<table><tr><td id=\"target\">td</td></tr></table>");
|
||||
synthesizeKey("VK_TAB", { metaKey: true });
|
||||
check(aDescription + "Meta+Tab on TD", true, false, true, false);
|
||||
check(aDescription + "Meta+Tab on TD", true, true, false);
|
||||
is(aElement.innerHTML,
|
||||
"<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>",
|
||||
aDescription + "Meta+Tab on TD");
|
||||
|
@ -504,7 +510,7 @@ function runTests()
|
|||
resetForIndent("<table><tr><th id=\"target\">th</th></tr></table>");
|
||||
synthesizeKey("VK_TAB", { });
|
||||
check(aDescription + "Tab on TH",
|
||||
true, false, true, !aIsTabbable && !aIsReadonly);
|
||||
true, true, !aIsTabbable && !aIsReadonly);
|
||||
is(aElement.innerHTML,
|
||||
aIsTabbable || aIsReadonly ?
|
||||
"<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>" :
|
||||
|
@ -515,7 +521,7 @@ function runTests()
|
|||
aDescription + "focus moved unexpectedly (Tab on TH)");
|
||||
synthesizeKey("VK_TAB", { shiftKey: true });
|
||||
check(aDescription + "Shift+Tab after Tab on TH",
|
||||
true, false, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
|
||||
true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
|
||||
is(aElement.innerHTML,
|
||||
aIsTabbable || aIsReadonly ?
|
||||
"<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>" :
|
||||
|
@ -527,17 +533,17 @@ function runTests()
|
|||
|
||||
resetForIndent("<table><tr><th id=\"target\">th</th></tr></table>");
|
||||
synthesizeKey("VK_TAB", { shiftKey: true });
|
||||
check(aDescription + "Shift+Tab on TH", true, false, true, false);
|
||||
check(aDescription + "Shift+Tab on TH", true, true, false);
|
||||
is(aElement.innerHTML,
|
||||
"<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>",
|
||||
aDescription + "Shift+Tab on TH");
|
||||
is(fm.focusedElement, aElement,
|
||||
aDescription + "focus moved unexpectedly (Shift+Tab on TH)");
|
||||
|
||||
// Ctrl+Tab is consumed by tabbrowser.
|
||||
// Ctrl+Tab may be consumed by tabbrowser but editor shouldn't consume this.
|
||||
resetForIndent("<table><tr><th id=\"target\">th</th></tr></table>");
|
||||
synthesizeKey("VK_TAB", { ctrlKey: true });
|
||||
check(aDescription + "Ctrl+Tab on TH", true, true, true, true);
|
||||
check(aDescription + "Ctrl+Tab on TH", true, true, false);
|
||||
is(aElement.innerHTML,
|
||||
"<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>",
|
||||
aDescription + "Ctrl+Tab on TH");
|
||||
|
@ -546,7 +552,7 @@ function runTests()
|
|||
|
||||
resetForIndent("<table><tr><th id=\"target\">th</th></tr></table>");
|
||||
synthesizeKey("VK_TAB", { altKey: true });
|
||||
check(aDescription + "Alt+Tab on TH", true, false, true, false);
|
||||
check(aDescription + "Alt+Tab on TH", true, true, false);
|
||||
is(aElement.innerHTML,
|
||||
"<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>",
|
||||
aDescription + "Alt+Tab on TH");
|
||||
|
@ -555,7 +561,7 @@ function runTests()
|
|||
|
||||
resetForIndent("<table><tr><th id=\"target\">th</th></tr></table>");
|
||||
synthesizeKey("VK_TAB", { metaKey: true });
|
||||
check(aDescription + "Meta+Tab on TH", true, false, true, false);
|
||||
check(aDescription + "Meta+Tab on TH", true, true, false);
|
||||
is(aElement.innerHTML,
|
||||
"<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>",
|
||||
aDescription + "Meta+Tab on TH");
|
||||
|
@ -566,42 +572,42 @@ function runTests()
|
|||
// In all cases, esc key events are not consumed
|
||||
reset("abc");
|
||||
synthesizeKey("VK_ESCAPE", { });
|
||||
check(aDescription + "Esc", true, false, true, false);
|
||||
check(aDescription + "Esc", true, true, false);
|
||||
|
||||
reset("abc");
|
||||
synthesizeKey("VK_ESCAPE", { shiftKey: true });
|
||||
check(aDescription + "Shift+Esc", true, false, true, false);
|
||||
check(aDescription + "Shift+Esc", true, true, false);
|
||||
|
||||
reset("abc");
|
||||
synthesizeKey("VK_ESCAPE", { ctrlKey: true });
|
||||
check(aDescription + "Ctrl+Esc", true, false, true, false);
|
||||
check(aDescription + "Ctrl+Esc", true, true, false);
|
||||
|
||||
reset("abc");
|
||||
synthesizeKey("VK_ESCAPE", { altKey: true });
|
||||
check(aDescription + "Alt+Esc", true, false, true, false);
|
||||
check(aDescription + "Alt+Esc", true, true, false);
|
||||
|
||||
reset("abc");
|
||||
synthesizeKey("VK_ESCAPE", { metaKey: true });
|
||||
check(aDescription + "Meta+Esc", true, false, true, false);
|
||||
check(aDescription + "Meta+Esc", true, true, false);
|
||||
|
||||
// typical typing tests:
|
||||
reset("");
|
||||
synthesizeKey("M", { shiftKey: true });
|
||||
check(aDescription + "M", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "M", true, true, !aIsReadonly);
|
||||
synthesizeKey("o", { });
|
||||
check(aDescription + "o", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "o", true, true, !aIsReadonly);
|
||||
synthesizeKey("z", { });
|
||||
check(aDescription + "z", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "z", true, true, !aIsReadonly);
|
||||
synthesizeKey("i", { });
|
||||
check(aDescription + "i", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "i", true, true, !aIsReadonly);
|
||||
synthesizeKey("l", { });
|
||||
check(aDescription + "l", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "l", true, true, !aIsReadonly);
|
||||
synthesizeKey("l", { });
|
||||
check(aDescription + "l", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "l", true, true, !aIsReadonly);
|
||||
synthesizeKey("a", { });
|
||||
check(aDescription + "a", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "a", true, true, !aIsReadonly);
|
||||
synthesizeKey(" ", { });
|
||||
check(aDescription + "' '", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "' '", true, true, !aIsReadonly);
|
||||
is(aElement.innerHTML,
|
||||
aIsReadonly ? "" : aIsPlaintext ? "Mozilla " : "Mozilla <br>",
|
||||
aDescription + "typed \"Mozilla \"");
|
||||
|
|
|
@ -66,19 +66,26 @@ function runTests()
|
|||
};
|
||||
|
||||
function check(aDescription,
|
||||
aFiredOnCapture, aPreventedOnCapture,
|
||||
aFiredOnBubbling, aPreventedOnBubbling)
|
||||
aFiredOnCapture, aFiredOnBubbling, aPreventedOnBubbling)
|
||||
{
|
||||
function getDesciption(aExpected)
|
||||
{
|
||||
return aDescription + (aExpected ? " wasn't " : " was ");
|
||||
}
|
||||
|
||||
is(capturingPhase.fired, aFiredOnCapture,
|
||||
getDesciption(aFiredOnCapture) + "fired on capture phase");
|
||||
is(capturingPhase.prevented, aPreventedOnCapture,
|
||||
getDesciption(aPreventedOnCapture) + "prevented on capture phase");
|
||||
is(bubblingPhase.fired, aFiredOnBubbling,
|
||||
getDesciption(aFiredOnBubbling) + "fired on bubbling phase");
|
||||
|
||||
// If the event is fired on bubbling phase and it was already prevented
|
||||
// on capture phase, it must be prevented on bubbling phase too.
|
||||
if (capturingPhase.prevented) {
|
||||
todo(false, aDescription +
|
||||
" was consumed already, so, we cannot test the editor behavior actually");
|
||||
aPreventedOnBubbling = true;
|
||||
}
|
||||
|
||||
is(bubblingPhase.prevented, aPreventedOnBubbling,
|
||||
getDesciption(aPreventedOnBubbling) + "prevented on bubbling phase");
|
||||
}
|
||||
|
@ -117,22 +124,22 @@ function runTests()
|
|||
// Only when editor is editable, it consumes.
|
||||
reset("");
|
||||
synthesizeKey("VK_META", { });
|
||||
check(aDescription + "Meta", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "Meta", true, true, !aIsReadonly);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_SHIFT", { });
|
||||
check(aDescription + "Shift", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "Shift", true, true, !aIsReadonly);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_CONTROL", { });
|
||||
check(aDescription + "Control", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "Control", true, true, !aIsReadonly);
|
||||
|
||||
// Alt key press event installs menubar key event listener, so,
|
||||
// we should pass Alt key testing on Windows and Linux.
|
||||
if (!kIsWin && !kIsLinux) {
|
||||
reset("");
|
||||
synthesizeKey("VK_ALT", { });
|
||||
check(aDescription + "Alt", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "Alt", true, true, !aIsReadonly);
|
||||
}
|
||||
|
||||
// Backspace key:
|
||||
|
@ -142,28 +149,28 @@ function runTests()
|
|||
// bindings on nsTextControlFrame may consume it.
|
||||
reset("");
|
||||
synthesizeKey("VK_BACK_SPACE", { });
|
||||
check(aDescription + "Backspace", true, false, true, true);
|
||||
check(aDescription + "Backspace", true, true, true);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_BACK_SPACE", { shiftKey: true });
|
||||
check(aDescription + "Shift+Backspace", true, false, true, true);
|
||||
check(aDescription + "Shift+Backspace", true, true, true);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_BACK_SPACE", { ctrlKey: true });
|
||||
// Win: cmd_deleteWordBackward
|
||||
check(aDescription + "Ctrl+Backspace",
|
||||
true, false, true, aIsReadonly || kIsWin);
|
||||
true, true, aIsReadonly || kIsWin);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_BACK_SPACE", { altKey: true });
|
||||
// Win: cmd_undo
|
||||
// Mac: cmd_deleteWordBackward
|
||||
check(aDescription + "Alt+Backspace",
|
||||
true, false, true, aIsReadonly || kIsWin || kIsMac);
|
||||
true, true, aIsReadonly || kIsWin || kIsMac);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_BACK_SPACE", { metaKey: true });
|
||||
check(aDescription + "Meta+Backspace", true, false, true, aIsReadonly);
|
||||
check(aDescription + "Meta+Backspace", true, true, aIsReadonly);
|
||||
|
||||
// Delete key:
|
||||
// If editor is readonly, it doesn't consume.
|
||||
|
@ -174,33 +181,33 @@ function runTests()
|
|||
synthesizeKey("VK_DELETE", { });
|
||||
// Linux: native handler
|
||||
check(aDescription + "Delete",
|
||||
true, false, true, !aIsReadonly || kIsLinux);
|
||||
true, true, !aIsReadonly || kIsLinux);
|
||||
|
||||
reset("");
|
||||
// Win: cmd_cutOrDelete
|
||||
// Linux: cmd_cut
|
||||
synthesizeKey("VK_DELETE", { shiftKey: true });
|
||||
check(aDescription + "Shift+Delete",
|
||||
true, false, true, kIsWin || kIsLinux);
|
||||
true, true, kIsWin || kIsLinux);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_DELETE", { ctrlKey: true });
|
||||
// Win: cmd_deleteWordForward
|
||||
// Linux: cmd_copy
|
||||
check(aDescription + "Ctrl+Delete",
|
||||
true, false, true, kIsWin || kIsLinux);
|
||||
true, true, kIsWin || kIsLinux);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_DELETE", { altKey: true });
|
||||
// Mac: cmd_deleteWordForward
|
||||
check(aDescription + "Alt+Delete",
|
||||
true, false, true, kIsMac);
|
||||
true, true, kIsMac);
|
||||
|
||||
reset("");
|
||||
synthesizeKey("VK_DELETE", { metaKey: true });
|
||||
// Linux: native handler consumed.
|
||||
check(aDescription + "Meta+Delete",
|
||||
true, false, true, kIsLinux);
|
||||
true, true, kIsLinux);
|
||||
|
||||
// XXX input.value returns "\n" when it's empty, so, we should use dummy
|
||||
// value ("a") for the following tests.
|
||||
|
@ -213,30 +220,30 @@ function runTests()
|
|||
reset("a");
|
||||
synthesizeKey("VK_RETURN", { });
|
||||
check(aDescription + "Return",
|
||||
true, false, true, !aIsSingleLine && !aIsReadonly);
|
||||
true, true, !aIsSingleLine && !aIsReadonly);
|
||||
is(aElement.value, !aIsSingleLine && !aIsReadonly ? "a\n" : "a",
|
||||
aDescription + "Return");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_RETURN", { shiftKey: true });
|
||||
check(aDescription + "Shift+Return",
|
||||
true, false, true, !aIsSingleLine && !aIsReadonly);
|
||||
true, true, !aIsSingleLine && !aIsReadonly);
|
||||
is(aElement.value, !aIsSingleLine && !aIsReadonly ? "a\n" : "a",
|
||||
aDescription + "Shift+Return");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_RETURN", { ctrlKey: true });
|
||||
check(aDescription + "Ctrl+Return", true, false, true, false);
|
||||
check(aDescription + "Ctrl+Return", true, true, false);
|
||||
is(aElement.value, "a", aDescription + "Ctrl+Return");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_RETURN", { altKey: true });
|
||||
check(aDescription + "Alt+Return", true, false, true, false);
|
||||
check(aDescription + "Alt+Return", true, true, false);
|
||||
is(aElement.value, "a", aDescription + "Alt+Return");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_RETURN", { metaKey: true });
|
||||
check(aDescription + "Meta+Return", true, false, true, false);
|
||||
check(aDescription + "Meta+Return", true, true, false);
|
||||
is(aElement.value, "a", aDescription + "Meta+Return");
|
||||
|
||||
// Enter key (same as Return key):
|
||||
|
@ -247,30 +254,30 @@ function runTests()
|
|||
reset("a");
|
||||
synthesizeKey("VK_ENTER", { });
|
||||
check(aDescription + "Enter",
|
||||
true, false, true, !aIsSingleLine && !aIsReadonly);
|
||||
true, true, !aIsSingleLine && !aIsReadonly);
|
||||
is(aElement.value, !aIsSingleLine && !aIsReadonly ? "a\n" : "a",
|
||||
aDescription + "Enter");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_ENTER", { shiftKey: true });
|
||||
check(aDescription + "Shift+Enter",
|
||||
true, false, true, !aIsSingleLine && !aIsReadonly);
|
||||
true, true, !aIsSingleLine && !aIsReadonly);
|
||||
is(aElement.value, !aIsSingleLine && !aIsReadonly ? "a\n" : "a",
|
||||
aDescription + "Shift+Enter");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_ENTER", { ctrlKey: true });
|
||||
check(aDescription + "Ctrl+Enter", true, false, true, false);
|
||||
check(aDescription + "Ctrl+Enter", true, true, false);
|
||||
is(aElement.value, "a", aDescription + "Ctrl+Enter");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_ENTER", { altKey: true });
|
||||
check(aDescription + "Alt+Enter", true, false, true, false);
|
||||
check(aDescription + "Alt+Enter", true, true, false);
|
||||
is(aElement.value, "a", aDescription + "Alt+Enter");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_ENTER", { metaKey: true });
|
||||
check(aDescription + "Meta+Enter", true, false, true, false);
|
||||
check(aDescription + "Meta+Enter", true, true, false);
|
||||
is(aElement.value, "a", aDescription + "Meta+Enter");
|
||||
|
||||
// Tab key:
|
||||
|
@ -279,7 +286,7 @@ function runTests()
|
|||
reset("a");
|
||||
synthesizeKey("VK_TAB", { });
|
||||
check(aDescription + "Tab",
|
||||
true, false, true, !aIsTabbable && !aIsReadonly);
|
||||
true, true, !aIsTabbable && !aIsReadonly);
|
||||
// The tab char is converted to 4 space characters because textarea/input
|
||||
// elements are not preformatted editor.
|
||||
is(aElement.value, !aIsTabbable && !aIsReadonly ? "a " : "a",
|
||||
|
@ -289,29 +296,29 @@ function runTests()
|
|||
|
||||
reset("a");
|
||||
synthesizeKey("VK_TAB", { shiftKey: true });
|
||||
check(aDescription + "Shift+Tab", true, false, true, false);
|
||||
check(aDescription + "Shift+Tab", true, true, false);
|
||||
is(aElement.value, "a", aDescription + "Shift+Tab");
|
||||
is(fm.focusedElement, aElement,
|
||||
aDescription + "focus moved unexpectedly (Shift+Tab)");
|
||||
|
||||
// Ctrl+Tab is consumed by tabbrowser.
|
||||
// Ctrl+Tab may be consumed by tabbrowser but editor shouldn't consume this.
|
||||
reset("a");
|
||||
synthesizeKey("VK_TAB", { ctrlKey: true });
|
||||
check(aDescription + "Ctrl+Tab", true, true, true, true);
|
||||
check(aDescription + "Ctrl+Tab", true, true, false);
|
||||
is(aElement.value, "a", aDescription + "Ctrl+Tab");
|
||||
is(fm.focusedElement, aElement,
|
||||
aDescription + "focus moved unexpectedly (Ctrl+Tab)");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_TAB", { altKey: true });
|
||||
check(aDescription + "Alt+Tab", true, false, true, false);
|
||||
check(aDescription + "Alt+Tab", true, true, false);
|
||||
is(aElement.value, "a", aDescription + "Alt+Tab");
|
||||
is(fm.focusedElement, aElement,
|
||||
aDescription + "focus moved unexpectedly (Alt+Tab)");
|
||||
|
||||
reset("a");
|
||||
synthesizeKey("VK_TAB", { metaKey: true });
|
||||
check(aDescription + "Meta+Tab", true, false, true, false);
|
||||
check(aDescription + "Meta+Tab", true, true, false);
|
||||
is(aElement.value, "a", aDescription + "Meta+Tab");
|
||||
is(fm.focusedElement, aElement,
|
||||
aDescription + "focus moved unexpectedly (Meta+Tab)");
|
||||
|
@ -320,42 +327,42 @@ function runTests()
|
|||
// In all cases, esc key events are not consumed
|
||||
reset("abc");
|
||||
synthesizeKey("VK_ESCAPE", { });
|
||||
check(aDescription + "Esc", true, false, true, false);
|
||||
check(aDescription + "Esc", true, true, false);
|
||||
|
||||
reset("abc");
|
||||
synthesizeKey("VK_ESCAPE", { shiftKey: true });
|
||||
check(aDescription + "Shift+Esc", true, false, true, false);
|
||||
check(aDescription + "Shift+Esc", true, true, false);
|
||||
|
||||
reset("abc");
|
||||
synthesizeKey("VK_ESCAPE", { ctrlKey: true });
|
||||
check(aDescription + "Ctrl+Esc", true, false, true, false);
|
||||
check(aDescription + "Ctrl+Esc", true, true, false);
|
||||
|
||||
reset("abc");
|
||||
synthesizeKey("VK_ESCAPE", { altKey: true });
|
||||
check(aDescription + "Alt+Esc", true, false, true, false);
|
||||
check(aDescription + "Alt+Esc", true, true, false);
|
||||
|
||||
reset("abc");
|
||||
synthesizeKey("VK_ESCAPE", { metaKey: true });
|
||||
check(aDescription + "Meta+Esc", true, false, true, false);
|
||||
check(aDescription + "Meta+Esc", true, true, false);
|
||||
|
||||
// typical typing tests:
|
||||
reset("");
|
||||
synthesizeKey("M", { shiftKey: true });
|
||||
check(aDescription + "M", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "M", true, true, !aIsReadonly);
|
||||
synthesizeKey("o", { });
|
||||
check(aDescription + "o", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "o", true, true, !aIsReadonly);
|
||||
synthesizeKey("z", { });
|
||||
check(aDescription + "z", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "z", true, true, !aIsReadonly);
|
||||
synthesizeKey("i", { });
|
||||
check(aDescription + "i", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "i", true, true, !aIsReadonly);
|
||||
synthesizeKey("l", { });
|
||||
check(aDescription + "l", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "l", true, true, !aIsReadonly);
|
||||
synthesizeKey("l", { });
|
||||
check(aDescription + "l", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "l", true, true, !aIsReadonly);
|
||||
synthesizeKey("a", { });
|
||||
check(aDescription + "a", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "a", true, true, !aIsReadonly);
|
||||
synthesizeKey(" ", { });
|
||||
check(aDescription + "' '", true, false, true, !aIsReadonly);
|
||||
check(aDescription + "' '", true, true, !aIsReadonly);
|
||||
is(aElement.value, !aIsReadonly ? "Mozilla " : "",
|
||||
aDescription + "typed \"Mozilla \"");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче