diff --git a/browser/base/content/test/browser_sanitizeDialog_treeView.js b/browser/base/content/test/browser_sanitizeDialog_treeView.js index 654ac7bc5d45..9abe1d6a7406 100644 --- a/browser/base/content/test/browser_sanitizeDialog_treeView.js +++ b/browser/base/content/test/browser_sanitizeDialog_treeView.js @@ -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); } }, diff --git a/browser/devtools/styleinspector/test/browser/browser_ruleview_editor.js b/browser/devtools/styleinspector/test/browser/browser_ruleview_editor.js index 181d67eb3db8..0aad26422486 100644 --- a/browser/devtools/styleinspector/test/browser/browser_ruleview_editor.js +++ b/browser/devtools/styleinspector/test/browser/browser_ruleview_editor.js @@ -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) }); diff --git a/browser/devtools/styleinspector/test/browser/browser_ruleview_ui.js b/browser/devtools/styleinspector/test/browser/browser_ruleview_ui.js index c0767aaffe02..636d5dc5f891 100644 --- a/browser/devtools/styleinspector/test/browser/browser_ruleview_ui.js +++ b/browser/devtools/styleinspector/test/browser/browser_ruleview_ui.js @@ -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); } }); diff --git a/content/html/content/test/test_bug388794.html b/content/html/content/test/test_bug388794.html index 866adabcca98..a6cc4778c071 100644 --- a/content/html/content/test/test_bug388794.html +++ b/content/html/content/test/test_bug388794.html @@ -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) { diff --git a/content/html/content/test/test_bug424698.html b/content/html/content/test/test_bug424698.html index 9bd6ea5ff3aa..a8f046d9527e 100644 --- a/content/html/content/test/test_bug424698.html +++ b/content/html/content/test/test_bug424698.html @@ -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"); diff --git a/content/html/content/test/test_bug558788-1.html b/content/html/content/test/test_bug558788-1.html index 94b7a5f00ea5..4e999b1f9650 100644 --- a/content/html/content/test/test_bug558788-1.html +++ b/content/html/content/test/test_bug558788-1.html @@ -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) { diff --git a/docshell/test/navigation/test_bug386782.html b/docshell/test/navigation/test_bug386782.html index 609d7912a983..9d474d0a5f6b 100644 --- a/docshell/test/navigation/test_bug386782.html +++ b/docshell/test/navigation/test_bug386782.html @@ -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(); diff --git a/docshell/test/navigation/test_bug430624.html b/docshell/test/navigation/test_bug430624.html index 9fc92e4cd305..31c5b8648d04 100644 --- a/docshell/test/navigation/test_bug430624.html +++ b/docshell/test/navigation/test_bug430624.html @@ -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"); diff --git a/docshell/test/navigation/test_bug430723.html b/docshell/test/navigation/test_bug430723.html index 0179f4cdb3f4..5e18b10d23d5 100644 --- a/docshell/test/navigation/test_bug430723.html +++ b/docshell/test/navigation/test_bug430723.html @@ -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, diff --git a/editor/composer/test/test_bug389350.html b/editor/composer/test/test_bug389350.html index bf1d514addbf..1400d3c1b980 100644 --- a/editor/composer/test/test_bug389350.html +++ b/editor/composer/test/test_bug389350.html @@ -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 = "
abc"; var result = e.contentDocument.documentElement.innerHTML; is(result, expected, "iframe with designmode on had incorrect content"); diff --git a/editor/libeditor/html/tests/test_bug432225.html b/editor/libeditor/html/tests/test_bug432225.html index afda7fbd61fd..91deb43270f9 100644 --- a/editor/libeditor/html/tests/test_bug432225.html +++ b/editor/libeditor/html/tests/test_bug432225.html @@ -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); } diff --git a/editor/libeditor/html/tests/test_bug455992.html b/editor/libeditor/html/tests/test_bug455992.html index d4f4be27ba8f..16fb67defa83 100644 --- a/editor/libeditor/html/tests/test_bug455992.html +++ b/editor/libeditor/html/tests/test_bug455992.html @@ -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" ? " " : "this is a paragraph carrying id 'foo'
"); 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" && diff --git a/editor/libeditor/text/tests/test_bug641466.html b/editor/libeditor/text/tests/test_bug641466.html index 4a77b0b8962f..73aff98301b8 100644 --- a/editor/libeditor/text/tests/test_bug641466.html +++ b/editor/libeditor/text/tests/test_bug641466.html @@ -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); } diff --git a/layout/base/tests/bug106855-1-ref.html b/layout/base/tests/bug106855-1-ref.html index 7bfb81815f1f..3344ad1a4924 100644 --- a/layout/base/tests/bug106855-1-ref.html +++ b/layout/base/tests/bug106855-1-ref.html @@ -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