зеркало из https://github.com/mozilla/gecko-dev.git
backout 34b8fe028357
This commit is contained in:
Родитель
729f289529
Коммит
5ff35fa5ae
|
@ -401,9 +401,8 @@ WindowHelper.prototype = {
|
|||
let key = aDelta < 0 ? "UP" : "DOWN";
|
||||
let abs = Math.abs(aDelta);
|
||||
let treechildren = this.getTree().treeBoxObject.treeBody;
|
||||
treechildren.focus();
|
||||
for (let i = 0; i < abs; i++) {
|
||||
EventUtils.sendKey(key);
|
||||
EventUtils.sendKey(key, treechildren);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ function testReturnCommit()
|
|||
start: function() {
|
||||
is(span.inplaceEditor.input.value, "explicit initial", "Explicit initial value should be used.");
|
||||
span.inplaceEditor.input.value = "Test Value";
|
||||
EventUtils.sendKey("return");
|
||||
EventUtils.sendKey("return", span.inplaceEditor.input);
|
||||
},
|
||||
done: expectDone("Test Value", true, testBlurCommit)
|
||||
});
|
||||
|
@ -74,7 +74,7 @@ function testAdvanceCharCommit()
|
|||
start: function() {
|
||||
let input = span.inplaceEditor.input;
|
||||
for each (let ch in "Test:") {
|
||||
EventUtils.sendChar(ch);
|
||||
EventUtils.sendChar(ch, input);
|
||||
}
|
||||
},
|
||||
done: expectDone("Test", true, testEscapeCancel)
|
||||
|
@ -91,7 +91,7 @@ function testEscapeCancel()
|
|||
initial: "initial text",
|
||||
start: function() {
|
||||
span.inplaceEditor.input.value = "Test Value";
|
||||
EventUtils.sendKey("escape");
|
||||
EventUtils.sendKey("escape", span.inplaceEditor.input);
|
||||
},
|
||||
done: expectDone("initial text", false, finishTest)
|
||||
});
|
||||
|
|
|
@ -120,7 +120,7 @@ function testCreateNew()
|
|||
|
||||
aEditor.input.blur();
|
||||
});
|
||||
EventUtils.sendKey("return", ruleDialog);
|
||||
EventUtils.sendKey("return", input);
|
||||
});
|
||||
|
||||
EventUtils.synthesizeMouse(elementRuleEditor.closeBrace, 1, 1,
|
||||
|
@ -148,11 +148,11 @@ function testEditProperty()
|
|||
});
|
||||
|
||||
for each (let ch in "red;") {
|
||||
EventUtils.sendChar(ch, ruleDialog);
|
||||
EventUtils.sendChar(ch, input);
|
||||
}
|
||||
});
|
||||
for each (let ch in "border-color:") {
|
||||
EventUtils.sendChar(ch, ruleDialog);
|
||||
EventUtils.sendChar(ch, input);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -62,8 +62,7 @@ var hrefs = {
|
|||
|
||||
function submitForm(idNum) {
|
||||
$("test"+idNum).setAttribute("onload", "frameLoaded(this)");
|
||||
$("test" + idNum + "image").focus();
|
||||
sendKey("return");
|
||||
sendKey("return", "test" + idNum + "image");
|
||||
}
|
||||
|
||||
function submitFormMouse(idNum) {
|
||||
|
|
|
@ -76,7 +76,7 @@ is(i.value, "test3", "Setting textarea defaultValue after hide/show should work"
|
|||
i = $("target2");
|
||||
i.focus(); // Otherwise editor gets confused when we send the key events
|
||||
is(i.value, "", "Textarea value should be empty string in second control");
|
||||
sendString("2test2");
|
||||
sendString("2test2", "target2");
|
||||
is(i.value, "2test2", 'We just typed the string "2test2"');
|
||||
i.defaultValue = "2test3";
|
||||
is(i.value, "2test2", "Setting textarea defaultValue after typing should not work");
|
||||
|
|
|
@ -121,7 +121,7 @@ function checkInputEmail()
|
|||
synthesizeKey("a", {});
|
||||
checkInvalidApplies(element);
|
||||
|
||||
sendString("@b.c");
|
||||
sendString("@b.c", element);
|
||||
checkValidApplies(element);
|
||||
|
||||
synthesizeKey("VK_BACK_SPACE", {});
|
||||
|
@ -151,7 +151,7 @@ function checkInputURL()
|
|||
synthesizeKey("h", {});
|
||||
checkInvalidApplies(element);
|
||||
|
||||
sendString("ttp://mozilla.org");
|
||||
sendString("ttp://mozilla.org", element);
|
||||
checkValidApplies(element);
|
||||
|
||||
for (var i=0; i<13; ++i) {
|
||||
|
|
|
@ -66,7 +66,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=386782
|
|||
// WARNING: If the following test fails, give the setTimeout() in the onload()
|
||||
// a bit longer; the doc hasn't had enough time to setup its editor.
|
||||
is(gTest.window.document.body.innerHTML, gTest.expectedBodyBeforeEdit, "Is doc setup yet");
|
||||
sendString('EDITED ', gTest.window);
|
||||
|
||||
sendChar('E', gTest.window.document.body);
|
||||
sendChar('D', gTest.window.document.body);
|
||||
sendChar('I', gTest.window.document.body);
|
||||
sendChar('T', gTest.window.document.body);
|
||||
sendChar('E', gTest.window.document.body);
|
||||
sendChar('D', gTest.window.document.body);
|
||||
sendChar(' ', gTest.window.document.body);
|
||||
is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterEdit, "Editing failed.");
|
||||
|
||||
gTest.window.location = 'data:text/html;charset=utf-8,SomeOtherDocument';
|
||||
|
@ -96,7 +103,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=386782
|
|||
|
||||
// Check that we can still edit the page.
|
||||
gTest.window.document.body.focus();
|
||||
sendString('TWICE ', gTest.window);
|
||||
sendChar('T', gTest.window.document.body);
|
||||
sendChar('W', gTest.window.document.body);
|
||||
sendChar('I', gTest.window.document.body);
|
||||
sendChar('C', gTest.window.document.body);
|
||||
sendChar('E', gTest.window.document.body);
|
||||
sendChar(' ', gTest.window.document.body);
|
||||
is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterSecondEdit, "Can we still edit?");
|
||||
|
||||
gTest.window.close();
|
||||
|
|
|
@ -36,8 +36,12 @@ function onReload() {
|
|||
|
||||
function doTest() {
|
||||
var bodyElement = window.frames[0].frameElement.contentDocument.body;
|
||||
bodyElement.focus();
|
||||
sendString('Still ', window.frames[0].frameElement.contentWindow);
|
||||
sendChar('S', bodyElement);
|
||||
sendChar('t', bodyElement);
|
||||
sendChar('i', bodyElement);
|
||||
sendChar('l', bodyElement);
|
||||
sendChar('l', bodyElement);
|
||||
sendChar(' ', bodyElement);
|
||||
|
||||
is(bodyElement.innerHTML, "Still contentEditable", "Check we're contentEditable after reload");
|
||||
|
||||
|
|
|
@ -62,20 +62,15 @@ var step1 =function() {
|
|||
// Navigate down and up.
|
||||
is(testWindow.document.body.scrollTop, 0,
|
||||
"Page1: Ensure we scrollpane is at the top before we start scrolling.");
|
||||
testWindow.focus();
|
||||
sendKey('DOWN', testWindow);
|
||||
SimpleTest.executeSoon(function() {
|
||||
isnot(testWindow.document.body.scrollTop, 0,
|
||||
"Page1: Ensure we can scroll down.");
|
||||
sendKey('UP', testWindow);
|
||||
SimpleTest.executeSoon(function() {
|
||||
is(testWindow.document.body.scrollTop, 0,
|
||||
"Page1: Ensure we can scroll up, back to the top.");
|
||||
|
||||
// Nav to blue box page. This should fire step2.
|
||||
testWindow.location = gTallBlueBoxURI;
|
||||
});
|
||||
});
|
||||
sendKey('UP', testWindow);
|
||||
setTimeout(function() {
|
||||
is(testWindow.document.body.scrollTop, 0,
|
||||
"Page1: Ensure we can scroll down and up, back to the top.");
|
||||
|
||||
// Nav to blue box page. This should fire step2.
|
||||
testWindow.location = gTallBlueBoxURI;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,7 +80,6 @@ var step2 =function() {
|
|||
// Scroll around a bit.
|
||||
is(testWindow.document.body.scrollTop, 0,
|
||||
"Page2: Ensure we scrollpane is at the top before we start scrolling.");
|
||||
testWindow.focus();
|
||||
sendKey('DOWN', testWindow);
|
||||
sendKey('DOWN', testWindow);
|
||||
sendKey('DOWN', testWindow);
|
||||
|
@ -105,7 +99,6 @@ var step3 =function() {
|
|||
// Check we can still scroll with the keys.
|
||||
is(testWindow.document.body.scrollTop, 0,
|
||||
"Page1Again: Ensure scroll pane at top before we scroll.");
|
||||
testWindow.focus();
|
||||
sendKey('DOWN', testWindow);
|
||||
setTimeout(function() {
|
||||
isnot(testWindow.document.body.scrollTop, 0,
|
||||
|
|
|
@ -15,7 +15,9 @@ function runTest() {
|
|||
e.contentDocument.designMode='on';
|
||||
e.style.display='block';
|
||||
e.focus();
|
||||
sendString('abc');
|
||||
sendChar('a', e.contentDocument);
|
||||
sendChar('b', e.contentDocument);
|
||||
sendChar('c', e.contentDocument);
|
||||
var expected = "<head></head><body>abc</body>";
|
||||
var result = e.contentDocument.documentElement.innerHTML;
|
||||
is(result, expected, "iframe with designmode on had incorrect content");
|
||||
|
|
|
@ -58,7 +58,12 @@ function addWords(aLimit) {
|
|||
return;
|
||||
}
|
||||
getEdit().focus();
|
||||
sendString('aa OK ');
|
||||
sendChar('a', editDoc());
|
||||
sendChar('a', editDoc());
|
||||
sendChar(' ', editDoc());
|
||||
sendChar('O', editDoc());
|
||||
sendChar('K', editDoc());
|
||||
sendChar(' ', editDoc());
|
||||
gMisspeltWords.push("aa");
|
||||
setTimeout(function() { addWords(aLimit-1); }, 0);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ function runTest() {
|
|||
function test_begin_bs(e) {
|
||||
const msg = "BACKSPACE at beginning of contenteditable inline element";
|
||||
var before = e.parentNode.childNodes[0].nodeValue;
|
||||
sendKey("back_space");
|
||||
sendKey("back_space", e);
|
||||
is(e.parentNode.childNodes[0].nodeValue, before, msg + " with id=" + e.id);
|
||||
is(e.innerHTML, "X", msg + " with id=" + e.id);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ function runTest() {
|
|||
function test_begin_space(e) {
|
||||
const msg = "SPACE at beginning of contenteditable inline element";
|
||||
var before = e.parentNode.childNodes[0].nodeValue;
|
||||
sendChar(" ");
|
||||
sendChar(" ", e);
|
||||
is(e.parentNode.childNodes[0].nodeValue, before, msg + " with id=" + e.id);
|
||||
is(e.innerHTML, " X", msg + " with id=" + e.id);
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ function runTest() {
|
|||
function test_end_delete(e) {
|
||||
const msg = "DEL at end of contenteditable inline element";
|
||||
var before = e.parentNode.childNodes[2].nodeValue;
|
||||
sendKey("right");
|
||||
sendKey("delete");
|
||||
sendKey("right", e);
|
||||
sendKey("delete", e);
|
||||
is(e.parentNode.childNodes[2].nodeValue, before, msg + " with id=" + e.id);
|
||||
is(e.innerHTML, "X", msg + " with id=" + e.id);
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ function runTest() {
|
|||
function test_end_space(e) {
|
||||
const msg = "SPACE at end of contenteditable inline element";
|
||||
var before = e.parentNode.childNodes[2].nodeValue;
|
||||
sendKey("right");
|
||||
sendChar(" ");
|
||||
sendKey("right", e);
|
||||
sendChar(" ", e);
|
||||
is(e.parentNode.childNodes[2].nodeValue, before, msg + " with id=" + e.id);
|
||||
is(e.innerHTML, "X" + (e.tagName=="SPAN" ? " " : " <br>"), msg + " with id=" + e.id);
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ function runTest() {
|
|||
function test_end_bs(e) {
|
||||
const msg = "Deleting all text in contenteditable inline element";
|
||||
var before = e.parentNode.childNodes[0].nodeValue;
|
||||
sendKey("right");
|
||||
sendKey("back_space");
|
||||
sendKey("back_space");
|
||||
sendKey("right", e);
|
||||
sendKey("back_space", e);
|
||||
sendKey("back_space", e);
|
||||
is(e.parentNode.childNodes[0].nodeValue, before, msg + " with id=" + e.id);
|
||||
is(e.innerHTML, "", msg + " with id=" + e.id);
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ function runTest() {
|
|||
var doc = e.contentDocument;
|
||||
doc.body.setAttribute("contenteditable", "true");
|
||||
doc.body.focus();
|
||||
sendKey("right");
|
||||
sendKey("back_space");
|
||||
sendKey("right", doc.body);
|
||||
sendKey("back_space", doc.body);
|
||||
is(doc.body.innerHTML, "<br>", msg + " with id=" + e.id);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ function runTest() {
|
|||
range.setEnd(li1.nextSibling,0);
|
||||
selection.addRange(range);
|
||||
|
||||
sendKey('delete');
|
||||
sendKey('delete', li1);
|
||||
is(doc.body.innerHTML,'<ul><li>two</li><ul><li>a</li></ul></ul>','delete 1st LI');
|
||||
|
||||
var li2 = setupIframe(i1,'<ul><li id="li2">two</li><ul><li>a</li></ul></ul>','li2')
|
||||
|
@ -43,7 +43,7 @@ function runTest() {
|
|||
range.setEnd(li2.nextSibling.firstChild,0);
|
||||
selection.addRange(range);
|
||||
|
||||
sendKey('delete');
|
||||
sendKey('delete', li2);
|
||||
is(doc.body.innerHTML,'<ul><ul><li>a</li></ul></ul>','delete 2nd LI');
|
||||
|
||||
SimpleTest.finish();
|
||||
|
|
|
@ -57,13 +57,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=607584
|
|||
{
|
||||
var editor = this.mEditor.getEditor(this.mEditor.contentWindow);
|
||||
if (editor) {
|
||||
this.mEditor.focus();
|
||||
editor instanceof Components.interfaces.nsIHTMLEditor;
|
||||
editor.returnInParagraphCreatesNewParagraph = true;
|
||||
editor.insertHTML("<p id='foo'>this is a paragraph carrying id 'foo'</p>");
|
||||
var p = editor.document.getElementById('foo')
|
||||
editor.beginningOfDocument();
|
||||
sendKey("return");
|
||||
sendKey("return", p);
|
||||
var firstP = p.parentNode.firstElementChild;
|
||||
var lastP = p.parentNode.lastElementChild;
|
||||
var isOk = firstP.nodeName.toLowerCase() == "p" &&
|
||||
|
|
|
@ -26,10 +26,10 @@ SimpleTest.waitForFocus(function() {
|
|||
element.focus();
|
||||
element.selectionStart = 4;
|
||||
element.selectionEnd = 4;
|
||||
synthesizeKey("VK_BACK_SPACE", {});
|
||||
synthesizeKey("VK_BACK_SPACE", {});
|
||||
synthesizeKey("VK_BACK_SPACE", {});
|
||||
synthesizeKey("VK_BACK_SPACE", {});
|
||||
synthesizeKey("VK_BACKSPACE", {});
|
||||
synthesizeKey("VK_BACKSPACE", {});
|
||||
synthesizeKey("VK_BACKSPACE", {});
|
||||
synthesizeKey("VK_BACKSPACE", {});
|
||||
|
||||
ok(element.value, "", "4 backspaces should delete all of the characters in the " + element.localName);
|
||||
}
|
||||
|
|
|
@ -17,10 +17,10 @@ y
|
|||
var area = document.getElementById('t');
|
||||
area.focus();
|
||||
|
||||
sendKey('RIGHT'); // now after "A"
|
||||
sendKey('RIGHT'); //
|
||||
sendKey('RIGHT'); //
|
||||
sendKey('RIGHT'); // now at the last line
|
||||
sendKey('RIGHT', window); // now after "A"
|
||||
sendKey('RIGHT', window); //
|
||||
sendKey('RIGHT', window); //
|
||||
sendKey('RIGHT', window); // now at the last line
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
|
|
@ -17,9 +17,9 @@ y
|
|||
var area = document.getElementById('t');
|
||||
area.focus();
|
||||
|
||||
sendKey('DOWN'); // now after "A"
|
||||
sendKey('DOWN'); //
|
||||
sendKey('DOWN'); // now at the last line
|
||||
sendKey('DOWN', window); // now after "A"
|
||||
sendKey('DOWN', window); //
|
||||
sendKey('DOWN', window); // now at the last line
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -17,10 +17,10 @@ y
|
|||
var area = document.getElementById('t');
|
||||
area.focus();
|
||||
|
||||
sendKey('DOWN'); // now after "A"
|
||||
sendKey('DOWN'); //
|
||||
sendKey('DOWN'); //
|
||||
sendKey('DOWN'); // now at the last line
|
||||
sendKey('DOWN', window); // now after "A"
|
||||
sendKey('DOWN', window); //
|
||||
sendKey('DOWN', window); //
|
||||
sendKey('DOWN', window); // now at the last line
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
var area = document.getElementById('t');
|
||||
area.focus();
|
||||
|
||||
sendKey('ENTER'); // press Enter once
|
||||
sendKey('ENTER', "t"); // press Enter once
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
var area = document.getElementById('t');
|
||||
area.focus();
|
||||
|
||||
sendKey('ENTER'); // press Enter twice
|
||||
sendKey('ENTER');
|
||||
sendKey('BACK_SPACE'); // press Backspace once
|
||||
sendKey('ENTER', "t"); // press Enter twice
|
||||
sendKey('ENTER', "t");
|
||||
sendKey('BACK_SPACE', "t"); // press Backspace once
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
range.setEnd(p.firstChild, 0);
|
||||
sel.addRange(range);
|
||||
|
||||
sendKey('UP'); // move UP
|
||||
sendChar('A'); // insert "A"
|
||||
sendKey('UP', div); // move UP
|
||||
sendChar('A', div); // insert "A"
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -19,12 +19,12 @@ x
|
|||
sel.addRange(range);
|
||||
p.parentNode.focus();
|
||||
|
||||
sendKey('DOWN'); // now after "1"
|
||||
sendKey('DOWN'); // now make sure we get to the end
|
||||
sendKey('DOWN'); // now make sure we get to the end
|
||||
sendKey('DOWN'); // now make sure we get to the end
|
||||
sendKey('DOWN'); // now make sure we get to the end
|
||||
sendKey('DOWN'); // now make sure we get to the end
|
||||
sendKey('DOWN', window); // now after "1"
|
||||
sendKey('DOWN', window); // now make sure we get to the end
|
||||
sendKey('DOWN', window); // now make sure we get to the end
|
||||
sendKey('DOWN', window); // now make sure we get to the end
|
||||
sendKey('DOWN', window); // now make sure we get to the end
|
||||
sendKey('DOWN', window); // now make sure we get to the end
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -19,12 +19,12 @@ x
|
|||
sel.addRange(range);
|
||||
p.parentNode.focus();
|
||||
|
||||
sendKey('DOWN'); // now after "1"
|
||||
sendKey('DOWN'); // now below the P element
|
||||
sendKey('UP'); // now before the "1"
|
||||
sendKey('UP'); // now before the "A"
|
||||
sendKey('UP'); // now before the "A"
|
||||
sendKey('UP'); // now before the "A"
|
||||
sendKey('DOWN', window); // now after "1"
|
||||
sendKey('DOWN', window); // now below the P element
|
||||
sendKey('UP', window); // now before the "1"
|
||||
sendKey('UP', window); // now before the "A"
|
||||
sendKey('UP', window); // now before the "A"
|
||||
sendKey('UP', window); // now before the "A"
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
sel.addRange(range);
|
||||
x.focus();
|
||||
|
||||
sendKey('RIGHT'); // Try to move the caret one position to the right
|
||||
sendKey('RIGHT', window); // Try to move the caret one position to the right
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
sel.addRange(range);
|
||||
x.focus();
|
||||
|
||||
sendKey('RIGHT'); // Try to move the caret one position to the right
|
||||
sendKey('RIGHT', window); // Try to move the caret one position to the right
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -15,7 +15,7 @@ noteditable<span id="x" contenteditable="true">navigable|unnavigable</span><br /
|
|||
sel.addRange(range);
|
||||
x.focus();
|
||||
|
||||
sendKey('RIGHT'); // Try to move the caret one position to the right
|
||||
sendKey('RIGHT', window); // Try to move the caret one position to the right
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
sel.addRange(range);
|
||||
x.focus();
|
||||
|
||||
sendKey('RIGHT'); // Try to move the caret one position to the right
|
||||
sendKey('RIGHT', window); // Try to move the caret one position to the right
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
var t = document.querySelector("textarea");
|
||||
t.focus();
|
||||
t.selectionStart = t.selectionEnd = t.value.length;
|
||||
sendKey('ENTER');
|
||||
sendKey('ENTER', "target");
|
||||
document.body.appendChild(document.createTextNode(t.selectionStart + " - " + t.selectionEnd));
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
var t = document.querySelector("textarea");
|
||||
t.focus();
|
||||
t.selectionStart = t.selectionEnd = t.value.length;
|
||||
sendKey('ENTER');
|
||||
sendKey('ENTER', "target");
|
||||
document.body.appendChild(document.createTextNode(t.selectionStart + " - " + t.selectionEnd));
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
var t = document.querySelector("textarea");
|
||||
t.focus();
|
||||
t.selectionStart = t.selectionEnd = t.value.length;
|
||||
sendKey('ENTER');
|
||||
sendKey('ENTER', "target");
|
||||
document.body.appendChild(document.createTextNode(t.selectionStart + " - " + t.selectionEnd));
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
function test() {
|
||||
document.querySelector("div").focus();
|
||||
// type a character, then press backspace to delete it
|
||||
sendChar("X");
|
||||
sendKey("BACK_SPACE");
|
||||
sendKey("X", "div1");
|
||||
sendKey("BACK_SPACE", "div1");
|
||||
document.documentElement.removeAttribute("class");
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
function test() {
|
||||
document.querySelector("div").focus();
|
||||
// type a character, then press backspace to delete it
|
||||
sendChar("X");
|
||||
sendKey("BACK_SPACE");
|
||||
sendKey("X", "div1");
|
||||
sendKey("BACK_SPACE", "div1");
|
||||
document.documentElement.removeAttribute("class");
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
function test() {
|
||||
document.querySelector("div").focus();
|
||||
// type a character, then press backspace to delete it
|
||||
sendChar("X");
|
||||
sendKey("BACK_SPACE");
|
||||
sendKey("X", "div1");
|
||||
sendKey("BACK_SPACE", "div1");
|
||||
document.documentElement.removeAttribute("class");
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
window.addEventListener("message",
|
||||
function(evt) {
|
||||
doIs(evt.data, "start", "Unexpected message");
|
||||
$("target").focus();
|
||||
sendString("Test");
|
||||
var t = $("target");
|
||||
doIs(t.value, "Test", "Typing should work");
|
||||
|
|
|
@ -83,7 +83,7 @@ is($("target").value, "abc", "Typing should be limited by maxlength");
|
|||
$("target").value = "";
|
||||
sendString("ad");
|
||||
sendKey("left");
|
||||
sendString("bc");
|
||||
sendString("bc")
|
||||
is($("target").value, "abd", "Typing should be limited by maxlength again");
|
||||
|
||||
</script>
|
||||
|
|
|
@ -78,10 +78,10 @@ function pageUpDownTest(id,index) {
|
|||
var elm = document.getElementById(id);
|
||||
elm.focus();
|
||||
elm.selectedIndex = 0;
|
||||
sendKey("page_down");
|
||||
sendKey("page_down");
|
||||
sendKey("page_up");
|
||||
sendKey("page_down");
|
||||
sendKey("page_down", elm);
|
||||
sendKey("page_down", elm);
|
||||
sendKey("page_up", elm);
|
||||
sendKey("page_down", elm);
|
||||
is(elm.selectedIndex, index, "pageUpDownTest: selectedIndex for " + id + " is " + index);
|
||||
}
|
||||
|
||||
|
@ -89,10 +89,10 @@ function upDownTest(id,index) {
|
|||
var elm = document.getElementById(id);
|
||||
elm.focus();
|
||||
elm.selectedIndex = 0;
|
||||
sendKey("down");
|
||||
sendKey("down");
|
||||
sendKey("up");
|
||||
sendKey("down");
|
||||
sendKey("down", elm);
|
||||
sendKey("down", elm);
|
||||
sendKey("up", elm);
|
||||
sendKey("down", elm);
|
||||
is(elm.selectedIndex, index, "upDownTest: selectedIndex for " + id + " is " + index);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,11 +48,11 @@ var elm = document.getElementById(id);
|
|||
elm.focus();
|
||||
var x = document.body.offsetHeight;
|
||||
$(id).addEventListener("input", inputListener, false);
|
||||
sendChar('1');
|
||||
sendChar('1',elm);
|
||||
is(inputHappened, true, "How come no input?");
|
||||
sendChar('3');
|
||||
sendKey('LEFT')
|
||||
sendChar('2');
|
||||
sendChar('3',elm);
|
||||
sendKey('LEFT',elm)
|
||||
sendChar('2',elm);
|
||||
elm.blur();
|
||||
x = document.body.offsetHeight;
|
||||
is(elm.value, '123', id + " edit");
|
||||
|
@ -61,14 +61,14 @@ test_edit_cmds(id)
|
|||
id = 'bug446663_b'
|
||||
elm = document.getElementById(id);
|
||||
elm.focus();
|
||||
sendChar('1');
|
||||
sendChar('1',elm);
|
||||
elm.style.display = 'none'
|
||||
var x = document.body.offsetHeight;
|
||||
elm.style.display = 'inline'
|
||||
x = document.body.offsetHeight;
|
||||
sendChar('3');
|
||||
sendKey('LEFT')
|
||||
sendChar('2');
|
||||
sendChar('3',elm);
|
||||
sendKey('LEFT',elm)
|
||||
sendChar('2',elm);
|
||||
elm.blur();
|
||||
x = document.body.offsetHeight;
|
||||
is(elm.value, '123', id + " edit");
|
||||
|
|
|
@ -59,14 +59,13 @@ function runTests(callback, type) {
|
|||
|
||||
// Make sure that the control accepts input events without explicit initialization
|
||||
is(c.value, "", "Control is empty initially");
|
||||
c.focus();
|
||||
sendChar("a");
|
||||
sendChar("a", c);
|
||||
is(c.value, "a", "Control accepts input without explicit initialization");
|
||||
// Make sure that the control retains its caret position
|
||||
c.focus();
|
||||
c.blur();
|
||||
c.focus();
|
||||
sendChar("b");
|
||||
sendChar("b", c);
|
||||
is(c.value, "ab", "Control retains caret position after being re-focused");
|
||||
|
||||
var d = document.createElement("input");
|
||||
|
@ -77,9 +76,8 @@ function runTests(callback, type) {
|
|||
// Make sure dynamically injected inputs work as expected
|
||||
is(d.value, "", "Dynamic control's initial value should be empty");
|
||||
d.value = "new";
|
||||
d.focus();
|
||||
is(d.value, "new", "Dynamic control's value can be set before initialization");
|
||||
sendChar("x");
|
||||
sendChar("x", d);
|
||||
is(d.value, "xnew", "Dynamic control accepts keyboard input without explicit initialization");
|
||||
$("display").removeChild(d);
|
||||
is(d.value, "xnew", "Dynamic control retains value after being removed from the document");
|
||||
|
|
|
@ -41,11 +41,11 @@ function pageUpDownTest(id,index) {
|
|||
var elm = document.getElementById(id);
|
||||
elm.focus();
|
||||
elm.selectedIndex = 0;
|
||||
sendKey("page_down");
|
||||
sendKey("page_down");
|
||||
sendKey("page_down");
|
||||
sendKey("page_up");
|
||||
sendKey("page_down");
|
||||
sendKey("page_down", elm);
|
||||
sendKey("page_down", elm);
|
||||
sendKey("page_down", elm);
|
||||
sendKey("page_up", elm);
|
||||
sendKey("page_down", elm);
|
||||
is(elm.selectedIndex, index, "pageUpDownTest: selectedIndex for " + id + " is " + index);
|
||||
}
|
||||
|
||||
|
@ -53,11 +53,11 @@ function upDownTest(id,index) {
|
|||
var elm = document.getElementById(id);
|
||||
elm.focus();
|
||||
elm.selectedIndex = 0;
|
||||
sendKey("down");
|
||||
sendKey("down");
|
||||
sendKey("down");
|
||||
sendKey("up");
|
||||
sendKey("down");
|
||||
sendKey("down", elm);
|
||||
sendKey("down", elm);
|
||||
sendKey("down", elm);
|
||||
sendKey("up", elm);
|
||||
sendKey("down", elm);
|
||||
is(elm.selectedIndex, index, "upDownTest: selectedIndex for " + id + " is " + index);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ function runTests() {
|
|||
// record scrolltop
|
||||
scrollTopBefore = doc.body.scrollTop;
|
||||
// send up arrow key event
|
||||
sendKey("UP");
|
||||
sendKey("UP", doc.body);
|
||||
|
||||
setTimeout("finish();", 0);
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ function testReturnToOwner() {
|
|||
tab1 = Browser.addTab("about:blank", true);
|
||||
tab2 = Browser.addTab("about:blank", true, tab1);
|
||||
is(Browser.selectedTab, tab2, "tab2 is selected");
|
||||
EventUtils.sendKey("ESCAPE");
|
||||
EventUtils.sendKey("ESCAPE", window);
|
||||
is(Browser.selectedTab, tab1, "tab1 is selected");
|
||||
closeTabs();
|
||||
testContextMenu();
|
||||
|
|
|
@ -47,7 +47,7 @@ function closeSelect() {
|
|||
let selectui = document.getElementById("select-container");
|
||||
is(selectui.hidden, false, "Select UI should be open");
|
||||
|
||||
EventUtils.sendKey("ESCAPE");
|
||||
EventUtils.sendKey("ESCAPE", window);
|
||||
|
||||
waitFor(tapOnMultiSelect, function() { return document.getElementById("select-container").hidden == true; });
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ function onUIReady() {
|
|||
is(selectui.hidden, false, "Select UI should be open");
|
||||
is(SelectHelperUI._selectedIndexes, 7, "Select UI should have the 8th option selected:" + SelectHelperUI._selectedIndexes);
|
||||
|
||||
EventUtils.sendKey("ESCAPE");
|
||||
EventUtils.sendKey("ESCAPE", window);
|
||||
|
||||
// Close our tab when finished
|
||||
Browser.closeTab(new_tab);
|
||||
|
|
|
@ -73,39 +73,105 @@ function sendMouseEvent(aEvent, aTarget, aWindow) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Send the char aChar to the focused element. This method handles casing of
|
||||
* chars (sends the right charcode, and sends a shift key for uppercase chars).
|
||||
* No other modifiers are handled at this point.
|
||||
* Send the char aChar to the node with id aTarget. If aTarget is not
|
||||
* provided, use "target". This method handles casing of chars (sends the
|
||||
* right charcode, and sends a shift key for uppercase chars). No other
|
||||
* modifiers are handled at this point.
|
||||
*
|
||||
* For now this method only works for English letters (lower and upper case)
|
||||
* and the digits 0-9.
|
||||
*
|
||||
* Returns true if the keypress event was accepted (no calls to preventDefault
|
||||
* or anything like that), false otherwise.
|
||||
*/
|
||||
function sendChar(aChar, aWindow) {
|
||||
function sendChar(aChar, aTarget) {
|
||||
// DOM event charcodes match ASCII (JS charcodes) for a-zA-Z0-9.
|
||||
var hasShift = (aChar == aChar.toUpperCase());
|
||||
synthesizeKey(aChar, { shiftKey: hasShift }, aWindow);
|
||||
var charCode = aChar.charCodeAt(0);
|
||||
var keyCode = charCode;
|
||||
if (!hasShift) {
|
||||
// For lowercase letters, the keyCode is actually 32 less than the charCode
|
||||
keyCode -= 0x20;
|
||||
}
|
||||
|
||||
return __doEventDispatch(aTarget, charCode, keyCode, hasShift);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the string aStr to the focused element.
|
||||
* Send the string aStr to the node with id aTarget. If aTarget is not
|
||||
* provided, use "target".
|
||||
*
|
||||
* For now this method only works for English letters (lower and upper case)
|
||||
* and the digits 0-9.
|
||||
*/
|
||||
function sendString(aStr, aWindow) {
|
||||
function sendString(aStr, aTarget) {
|
||||
for (var i = 0; i < aStr.length; ++i) {
|
||||
sendChar(aStr.charAt(i), aWindow);
|
||||
sendChar(aStr.charAt(i), aTarget);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the non-character key aKey to the focused node. The name of the key
|
||||
* should be a lowercase version of the part that comes after "DOM_VK_" in the
|
||||
* KeyEvent constant name for this key. No modifiers are handled at this point.
|
||||
* Send the non-character key aKey to the node with id aTarget. If aTarget is
|
||||
* not provided, use "target". The name of the key should be a lowercase
|
||||
* version of the part that comes after "DOM_VK_" in the KeyEvent constant
|
||||
* name for this key. No modifiers are handled at this point.
|
||||
*
|
||||
* Returns true if the keypress event was accepted (no calls to preventDefault
|
||||
* or anything like that), false otherwise.
|
||||
*/
|
||||
function sendKey(aKey, aWindow) {
|
||||
keyName = "VK_" + aKey.toUpperCase();
|
||||
synthesizeKey(keyName, { shiftKey: false }, aWindow);
|
||||
function sendKey(aKey, aTarget) {
|
||||
keyName = "DOM_VK_" + aKey.toUpperCase();
|
||||
|
||||
if (!KeyEvent[keyName]) {
|
||||
throw "Unknown key: " + keyName;
|
||||
}
|
||||
|
||||
return __doEventDispatch(aTarget, 0, KeyEvent[keyName], false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually perform event dispatch given a charCode, keyCode, and boolean for
|
||||
* whether "shift" was pressed. Send the event to the node with id aTarget. If
|
||||
* aTarget is not provided, use "target".
|
||||
*
|
||||
* Returns true if the keypress event was accepted (no calls to preventDefault
|
||||
* or anything like that), false otherwise.
|
||||
*/
|
||||
function __doEventDispatch(aTarget, aCharCode, aKeyCode, aHasShift) {
|
||||
if (aTarget === undefined) {
|
||||
aTarget = "target";
|
||||
}
|
||||
|
||||
var event = document.createEvent("KeyEvents");
|
||||
event.initKeyEvent("keydown", true, true, document.defaultView,
|
||||
false, false, aHasShift, false,
|
||||
aKeyCode, 0);
|
||||
var accepted = SpecialPowers.dispatchEvent(window, aTarget, event);
|
||||
|
||||
// Preventing the default keydown action also prevents the default
|
||||
// keypress action.
|
||||
event = document.createEvent("KeyEvents");
|
||||
if (aCharCode) {
|
||||
event.initKeyEvent("keypress", true, true, document.defaultView,
|
||||
false, false, aHasShift, false,
|
||||
0, aCharCode);
|
||||
} else {
|
||||
event.initKeyEvent("keypress", true, true, document.defaultView,
|
||||
false, false, aHasShift, false,
|
||||
aKeyCode, 0);
|
||||
}
|
||||
if (!accepted) {
|
||||
event.preventDefault();
|
||||
}
|
||||
accepted = SpecialPowers.dispatchEvent(window, aTarget, event);
|
||||
|
||||
// Always send keyup
|
||||
var event = document.createEvent("KeyEvents");
|
||||
event.initKeyEvent("keyup", true, true, document.defaultView,
|
||||
false, false, aHasShift, false,
|
||||
aKeyCode, 0);
|
||||
SpecialPowers.dispatchEvent(window, aTarget, event);
|
||||
return accepted;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -327,12 +393,9 @@ function synthesizeKey(aKey, aEvent, aWindow)
|
|||
var utils = _getDOMWindowUtils(aWindow);
|
||||
if (utils) {
|
||||
var keyCode = 0, charCode = 0;
|
||||
if (aKey.indexOf("VK_") == 0) {
|
||||
if (aKey.indexOf("VK_") == 0)
|
||||
keyCode = KeyEvent["DOM_" + aKey];
|
||||
if (!keyCode) {
|
||||
throw "Unknown key: " + aKey;
|
||||
}
|
||||
} else {
|
||||
else {
|
||||
charCode = aKey.charCodeAt(0);
|
||||
keyCode = _computeKeyCodeFromChar(aKey.charAt(0));
|
||||
}
|
||||
|
@ -347,7 +410,6 @@ function synthesizeKey(aKey, aEvent, aWindow)
|
|||
} else {
|
||||
var keyDownDefaultHappened =
|
||||
utils.sendKeyEvent("keydown", keyCode, 0, modifiers);
|
||||
// XXX Shouldn't dispatch keypress event if the key is a modifier key.
|
||||
utils.sendKeyEvent("keypress", charCode ? 0 : keyCode, charCode,
|
||||
modifiers, !keyDownDefaultHappened);
|
||||
utils.sendKeyEvent("keyup", keyCode, 0, modifiers);
|
||||
|
|
|
@ -44,13 +44,13 @@ is(press2, true, "synthesizeKey should dispatch keyPress with default prevented"
|
|||
|
||||
var press3 = false;
|
||||
$("testKeyEvent3").focus();
|
||||
sendChar("x")
|
||||
sendChar("x", "testKeyEvent3")
|
||||
is($("testKeyEvent3").value, "x", "sendChar should work");
|
||||
is(press3, true, "sendChar should dispatch keyPress");
|
||||
|
||||
var press4 = false;
|
||||
$("testKeyEvent4").focus();
|
||||
sendChar("x")
|
||||
sendChar("x", "testKeyEvent4")
|
||||
is($("testKeyEvent4").value, "", "sendChar should respect keydown preventDefault");
|
||||
is(press4, true, "sendChar should dispatch keyPress with default prevented");
|
||||
|
||||
|
|
|
@ -46,19 +46,17 @@ function starttest() {
|
|||
check = false;
|
||||
$("testKeyEvent").addEventListener("keypress", function() { check = true; }, false);
|
||||
$("testKeyEvent").focus();
|
||||
sendChar("x");
|
||||
sendChar("x", "testKeyEvent");
|
||||
is($("testKeyEvent").value, "x", "sendChar should work");
|
||||
is(check, true, "sendChar should dispatch keyPress");
|
||||
$("testKeyEvent").value = "";
|
||||
|
||||
$("testStrEvent").focus();
|
||||
sendString("string");
|
||||
sendString("string", "testStrEvent");
|
||||
is($("testStrEvent").value, "string", "sendString should work");
|
||||
$("testStrEvent").value = "";
|
||||
|
||||
check = false;
|
||||
$("testKeyEvent").focus();
|
||||
sendKey("DOWN");
|
||||
sendKey("DOWN", "testKeyEvent");
|
||||
is(check, true, "sendKey should dispatch keyPress");
|
||||
|
||||
/* test synthesizeMouse* */
|
||||
|
|
|
@ -643,7 +643,7 @@ function runTest(testNum) {
|
|||
// the username.
|
||||
uname.focus();
|
||||
doKey("right");
|
||||
sendChar("X");
|
||||
sendChar("X", uname);
|
||||
// Trigger the 'blur' event on uname
|
||||
pword.focus();
|
||||
checkACForm("sXingleuser5", "singlepass5");
|
||||
|
@ -722,15 +722,14 @@ function runTest(testNum) {
|
|||
pwmgr.removeLogin(login7);
|
||||
|
||||
testNum = 699;
|
||||
gNextTestWillOpenPopup = true;
|
||||
gNextTestWillOpenPopup = false;
|
||||
break;
|
||||
|
||||
case 700:
|
||||
// Turn our attention to form9 to test the dropdown - bug 497541
|
||||
uname = $_(9, "uname");
|
||||
pword = $_(9, "pword");
|
||||
uname.focus();
|
||||
sendString("form9userAB");
|
||||
sendString("form9userAB", uname);
|
||||
gNextTestWillOpenPopup = true;
|
||||
break;
|
||||
|
||||
|
@ -738,7 +737,7 @@ function runTest(testNum) {
|
|||
checkACForm("form9userAB", "");
|
||||
uname.focus();
|
||||
doKey("left");
|
||||
sendChar("A");
|
||||
sendChar("A", uname);
|
||||
gNextTestWillOpenPopup = false;
|
||||
break;
|
||||
|
||||
|
@ -754,8 +753,7 @@ function runTest(testNum) {
|
|||
|
||||
case 703:
|
||||
pwmgr.addLogin(login8C);
|
||||
uname.focus();
|
||||
sendChar("z");
|
||||
sendChar("z", uname);
|
||||
gNextTestWillOpenPopup = false;
|
||||
break;
|
||||
|
||||
|
|
|
@ -477,22 +477,19 @@ function runTest(testNum) {
|
|||
input = $_(5, "field3");
|
||||
restoreForm();
|
||||
testNum = 199;
|
||||
input.focus();
|
||||
sendChar("a");
|
||||
sendChar("a", input);
|
||||
break;
|
||||
|
||||
/* Test filtering as characters are typed. */
|
||||
|
||||
case 200:
|
||||
checkMenuEntries(["a", "aa", "aaz", "aa\xe6", "az"]);
|
||||
input.focus();
|
||||
sendChar("a");
|
||||
sendChar("a", input);
|
||||
break;
|
||||
|
||||
case 201:
|
||||
checkMenuEntries(["aa", "aaz", "aa\xe6"]);
|
||||
input.focus();
|
||||
sendChar("\xc6");
|
||||
sendChar("\xc6", input);
|
||||
break;
|
||||
|
||||
case 202:
|
||||
|
@ -507,31 +504,27 @@ function runTest(testNum) {
|
|||
|
||||
case 204:
|
||||
checkMenuEntries(["a", "aa", "aaz", "aa\xe6", "az"]);
|
||||
input.focus();
|
||||
sendChar("z");
|
||||
sendChar("z", input);
|
||||
break;
|
||||
|
||||
case 205:
|
||||
ok(getMenuEntries().length > 0, "checking typing in middle of text");
|
||||
input.focus();
|
||||
doKey("left");
|
||||
sendChar("a");
|
||||
sendChar("a", input);
|
||||
break;
|
||||
|
||||
case 206:
|
||||
checkMenuEntries(["aaz"]);
|
||||
fh.addEntry("field3", "aazq");
|
||||
input.focus();
|
||||
doKey("right");
|
||||
sendChar("q");
|
||||
sendChar("q", input);
|
||||
break;
|
||||
|
||||
case 207:
|
||||
// check that results were cached
|
||||
checkMenuEntries([]);
|
||||
fh.addEntry("field3", "aazqq");
|
||||
input.focus();
|
||||
sendChar("q");
|
||||
sendChar("q", input);
|
||||
break;
|
||||
|
||||
case 208:
|
||||
|
@ -543,8 +536,7 @@ function runTest(testNum) {
|
|||
input = $_(6, "field4");
|
||||
restoreForm();
|
||||
testNum = 249;
|
||||
input.focus();
|
||||
sendChar("a");
|
||||
sendChar("a", input);
|
||||
break;
|
||||
|
||||
/* Test substring matches and word boundary bonuses */
|
||||
|
@ -552,8 +544,7 @@ function runTest(testNum) {
|
|||
case 250:
|
||||
// alphabetical results for first character
|
||||
checkMenuEntries(["aa a\xe6", "aba\xe6", "a\xe6"]);
|
||||
input.focus();
|
||||
sendChar("\xc6");
|
||||
sendChar("\xc6", input);
|
||||
break;
|
||||
|
||||
case 251:
|
||||
|
@ -562,36 +553,31 @@ function runTest(testNum) {
|
|||
checkMenuEntries(["a\xe6", "aa a\xe6", "aba\xe6"]);
|
||||
|
||||
restoreForm();
|
||||
input.focus();
|
||||
sendChar("b");
|
||||
sendChar("b", input);
|
||||
break;
|
||||
|
||||
case 252:
|
||||
checkMenuEntries(["bc d\xe6"]);
|
||||
input.focus();
|
||||
sendChar(" ");
|
||||
sendChar(" ", input);
|
||||
break;
|
||||
|
||||
case 253:
|
||||
// check that trailing space has no effect after single char.
|
||||
checkMenuEntries(["bc d\xe6"]);
|
||||
input.focus();
|
||||
sendChar("\xc6");
|
||||
sendChar("\xc6", input);
|
||||
break;
|
||||
|
||||
case 254:
|
||||
// check multi-word substring matches
|
||||
checkMenuEntries(["bc d\xe6", "aba\xe6"]);
|
||||
input.focus();
|
||||
doKey("left");
|
||||
sendChar("d");
|
||||
sendChar("d", input);
|
||||
break;
|
||||
|
||||
case 255:
|
||||
// check inserting in multi-word searches
|
||||
checkMenuEntries(["bc d\xe6"]);
|
||||
input.focus();
|
||||
sendChar("z");
|
||||
sendChar("z", input);
|
||||
break;
|
||||
|
||||
case 256:
|
||||
|
@ -644,8 +630,7 @@ function runTest(testNum) {
|
|||
input.maxLength = 4;
|
||||
|
||||
// now again with a character typed
|
||||
input.focus();
|
||||
sendChar("1");
|
||||
sendChar("1", input);
|
||||
doKey("escape");
|
||||
doKey("down");
|
||||
break;
|
||||
|
|
|
@ -44,20 +44,19 @@ SimpleTest.waitForExplicitFinish();
|
|||
function testListbox(id)
|
||||
{
|
||||
var listbox = document.getElementById(id);
|
||||
listbox.focus();
|
||||
is(listbox.getRowCount(), 7, id + ": Returned the wrong number of rows");
|
||||
is(listbox.getItemAtIndex(2).id, id + "_item3", id + ": Should still return hidden items");
|
||||
listbox.selectedIndex = 0;
|
||||
is(listbox.selectedItem.id, id + "_item1", id + ": First item was not selected");
|
||||
sendKey("DOWN");
|
||||
sendKey("DOWN", id);
|
||||
is(listbox.selectedItem.id, id + "_item2", id + ": Down didn't move to second item");
|
||||
sendKey("DOWN");
|
||||
sendKey("DOWN", id);
|
||||
is(listbox.selectedItem.id, id + "_item4", id + ": Down didn't skip hidden item");
|
||||
sendKey("DOWN");
|
||||
sendKey("DOWN", id);
|
||||
is(listbox.selectedItem.id, id + "_item6", id + ": Down didn't skip collapsed item");
|
||||
sendKey("UP");
|
||||
sendKey("UP", id);
|
||||
is(listbox.selectedItem.id, id + "_item4", id + ": Up didn't skip collapsed item");
|
||||
sendKey("UP");
|
||||
sendKey("UP", id);
|
||||
is(listbox.selectedItem.id, id + "_item2", id + ": Up didn't skip hidden item");
|
||||
listbox.selectAll();
|
||||
is(listbox.selectedItems.length, 7, id + ": Should have still selected all items");
|
||||
|
@ -66,7 +65,7 @@ function testListbox(id)
|
|||
listbox.selectedIndex = 2;
|
||||
ok(listbox.selectedItem == listbox.getItemAtIndex(2), id + ": Should have selected the hidden item");
|
||||
listbox.selectedIndex = 0;
|
||||
sendKey("END");
|
||||
sendKey("END", id);
|
||||
is(listbox.selectedItem.id, id + "_item6", id + ": Should have moved to the last unhidden item");
|
||||
sendMouseEvent({type: 'click'}, id + "_item1");
|
||||
ok(listbox.selectedItem == listbox.getItemAtIndex(0), id + ": Should have selected the first item");
|
||||
|
@ -74,9 +73,9 @@ function testListbox(id)
|
|||
sendMouseEvent({type: 'click', shiftKey: true}, id + "_item6");
|
||||
is(listbox.selectedItems.length, 4, id + ": Should have selected all visible items");
|
||||
listbox.selectedIndex = 0;
|
||||
sendKey("PAGE_DOWN");
|
||||
sendKey("PAGE_DOWN", id);
|
||||
is(listbox.selectedItem.id, id + "_item6", id + ": Page down should go to the last visible item");
|
||||
sendKey("PAGE_UP");
|
||||
sendKey("PAGE_UP", id);
|
||||
is(listbox.selectedItem.id, id + "_item1", id + ": Page up should go to the first visible item");
|
||||
}
|
||||
|
||||
|
|
|
@ -71,24 +71,23 @@ function testRichlistbox()
|
|||
{
|
||||
var id = "richlistbox";
|
||||
var listbox = document.getElementById(id);
|
||||
listbox.focus();
|
||||
listbox.selectedIndex = 0;
|
||||
sendKey("PAGE_DOWN");
|
||||
sendKey("PAGE_DOWN", id);
|
||||
is(listbox.selectedItem.id, id + "_item7", id + ": Page down should go to the item one visible page away");
|
||||
is(listbox.getIndexOfFirstVisibleRow(), 6, id + ": Page down should have scrolled down a visible page");
|
||||
sendKey("PAGE_DOWN");
|
||||
sendKey("PAGE_DOWN", id);
|
||||
is(listbox.selectedItem.id, id + "_item11", id + ": Second page down should go to the item two visible pages away");
|
||||
is(listbox.getIndexOfFirstVisibleRow(), 9, id + ": Second page down should not scroll beyond the end");
|
||||
sendKey("PAGE_DOWN");
|
||||
sendKey("PAGE_DOWN", id);
|
||||
is(listbox.selectedItem.id, id + "_item14", id + ": Third page down should go to the last visible item");
|
||||
is(listbox.getIndexOfFirstVisibleRow(), 9, id + ": Third page down should not have scrolled at all");
|
||||
sendKey("PAGE_UP");
|
||||
sendKey("PAGE_UP", id);
|
||||
is(listbox.selectedItem.id, id + "_item10", id + ": Page up should go to the item one visible page away");
|
||||
is(listbox.getIndexOfFirstVisibleRow(), 5, id + ": Page up should scroll up a visible page");
|
||||
sendKey("PAGE_UP");
|
||||
sendKey("PAGE_UP", id);
|
||||
is(listbox.selectedItem.id, id + "_item6", id + ": Second page up should go to the item two visible pages away");
|
||||
is(listbox.getIndexOfFirstVisibleRow(), 0, id + ": Second page up should not scroll beyond the start");
|
||||
sendKey("PAGE_UP");
|
||||
sendKey("PAGE_UP", id);
|
||||
is(listbox.selectedItem.id, id + "_item1", id + ": Third page up should return to the first visible item");
|
||||
is(listbox.getIndexOfFirstVisibleRow(), 0, id + ": Third page up should not have scrolled at all");
|
||||
}
|
||||
|
@ -106,25 +105,24 @@ function testListbox()
|
|||
|
||||
var rowHeight = listbox.firstChild.getBoundingClientRect().height;
|
||||
|
||||
listbox.focus();
|
||||
listbox.selectedIndex = 0;
|
||||
sendKey("PAGE_DOWN");
|
||||
sendKey("PAGE_DOWN", id);
|
||||
is(listbox.selectedItem.id, id + "_item8", id + ": Page down should go to the item one visible page away");
|
||||
is(listbox.getIndexOfFirstVisibleRow(), 7, id + ": Page down should have scrolled down a visible page");
|
||||
sendKey("PAGE_DOWN");
|
||||
sendKey("PAGE_DOWN", id);
|
||||
is(listbox.selectedItem.id, id + "_item13", id + ": Second page down should go to the item two visible pages away");
|
||||
is(listbox.getIndexOfFirstVisibleRow(), 9, id + ": Second page down should not scroll beyond the end");
|
||||
sendKey("PAGE_DOWN");
|
||||
sendKey("PAGE_DOWN", id);
|
||||
is(listbox.selectedItem.id, id + "_item14", id + ": Third page down should go to the last visible item");
|
||||
is(listbox.getIndexOfFirstVisibleRow(), 9, id + ": Third page down should not have scrolled at all");
|
||||
sendKey("PAGE_UP");
|
||||
sendKey("PAGE_UP", id);
|
||||
is(listbox.selectedItem.id, id + "_item9", id + ": Page up should go to the item one visible page away");
|
||||
// the listScrollbox seems to go haywire when scrolling up with hidden listitems
|
||||
todo_is(listbox.getIndexOfFirstVisibleRow(), 3, id + ": Page up should scroll up a visible page");
|
||||
sendKey("PAGE_UP");
|
||||
sendKey("PAGE_UP", id);
|
||||
is(listbox.selectedItem.id, id + "_item2", id + ": Second page up should go to the item two visible pages away");
|
||||
is(listbox.getIndexOfFirstVisibleRow(), 0, id + ": Second page up should not scroll beyond the start");
|
||||
sendKey("PAGE_UP");
|
||||
sendKey("PAGE_UP", id);
|
||||
is(listbox.selectedItem.id, id + "_item1", id + ": Third page up should return to the first visible item");
|
||||
is(listbox.getIndexOfFirstVisibleRow(), 0, id + ": Third page up should not have scrolled at all");
|
||||
|
||||
|
|
|
@ -46,25 +46,24 @@ function test_richlistbox()
|
|||
// richlistboxes respond differently when a user initiates a selection
|
||||
richListBox.dir = "reverse";
|
||||
var count = richListBox.itemCount;
|
||||
richListBox.focus();
|
||||
richListBox.selectedIndex = count - 1;
|
||||
sendKey("DOWN");
|
||||
sendKey("DOWN", richListBox);
|
||||
is(richListBox.currentIndex, count - 2, "Selection should move to the next item");
|
||||
sendKey("UP");
|
||||
sendKey("UP", richListBox);
|
||||
is(richListBox.currentIndex, count - 1, "Selection should move to the previous item");
|
||||
sendKey("END");
|
||||
sendKey("END", richListBox);
|
||||
is(richListBox.currentIndex, 0, "Selection should move to the last item");
|
||||
sendKey("HOME");
|
||||
sendKey("HOME", richListBox);
|
||||
is(richListBox.currentIndex, count - 1, "Selection should move to the first item");
|
||||
var currentIndex = richListBox.currentIndex;
|
||||
var index = getScrollIndexAmount(-1);
|
||||
sendKey("PAGE_DOWN");
|
||||
sendKey("PAGE_DOWN", richListBox);
|
||||
is(richListBox.currentIndex, index, "Selection should move to one page down");
|
||||
ok(richListBox.currentIndex < currentIndex, "Selection should move downwards");
|
||||
sendKey("END");
|
||||
sendKey("END", richListBox);
|
||||
currentIndex = richListBox.currentIndex;
|
||||
index = getScrollIndexAmount(1);
|
||||
sendKey("PAGE_UP");
|
||||
sendKey("PAGE_UP", richListBox);
|
||||
is(richListBox.currentIndex, index, "Selection should move to one page up");
|
||||
ok(richListBox.currentIndex > currentIndex, "Selection should move upwards");
|
||||
richListBox.selectedItem = richListBox.lastChild;
|
||||
|
@ -88,29 +87,29 @@ function test_richlistbox()
|
|||
aEvent.preventDefault();
|
||||
}, true);
|
||||
richListBox.selectedIndex = 1;
|
||||
sendKey("HOME");
|
||||
sendKey("HOME", richListBox);
|
||||
is(richListBox.selectedIndex, 1, "A stopped event should return indexing to normal");
|
||||
|
||||
// direction = "normal"
|
||||
richListBox.dir = "normal";
|
||||
richListBox.selectedIndex = 0;
|
||||
sendKey("DOWN");
|
||||
sendKey("DOWN", richListBox);
|
||||
is(richListBox.currentIndex, 1, "Selection should move to the next item");
|
||||
sendKey("UP");
|
||||
sendKey("UP", richListBox);
|
||||
is(richListBox.currentIndex, 0, "Selection should move to the previous item");
|
||||
sendKey("END");
|
||||
sendKey("END", richListBox);
|
||||
is(richListBox.currentIndex, count - 1, "Selection should move to the last item");
|
||||
sendKey("HOME");
|
||||
sendKey("HOME", richListBox);
|
||||
is(richListBox.currentIndex, 0, "Selection should move to the first item");
|
||||
var currentIndex = richListBox.currentIndex;
|
||||
var index = richListBox.scrollOnePage(1);
|
||||
sendKey("PAGE_DOWN");
|
||||
sendKey("PAGE_DOWN", richListBox);
|
||||
is(richListBox.currentIndex, index, "Selection should move to one page down");
|
||||
ok(richListBox.currentIndex > currentIndex, "Selection should move downwards");
|
||||
sendKey("END");
|
||||
sendKey("END", richListBox);
|
||||
currentIndex = richListBox.currentIndex;
|
||||
index = richListBox.scrollOnePage(-1) + richListBox.currentIndex;
|
||||
sendKey("PAGE_UP");
|
||||
sendKey("PAGE_UP", richListBox);
|
||||
is(richListBox.currentIndex, index, "Selection should move to one page up");
|
||||
ok(richListBox.currentIndex < currentIndex, "Selection should move upwards");
|
||||
richListBox.selectedItem = richListBox.firstChild;
|
||||
|
|
Загрузка…
Ссылка в новой задаче