зеркало из https://github.com/mozilla/gecko-dev.git
b=768838; fix intermittent test_bug549262 failure; r=ehsan
This commit is contained in:
Родитель
95b6837c70
Коммит
512feb5da3
|
@ -24,6 +24,13 @@ SpecialPowers.setBoolPref(smoothScrollPref, false);
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
var win = window.open("file_bug549262.html", "_blank",
|
||||
"width=600,height=600,scrollbars=yes");
|
||||
|
||||
// grab the timer right at the start
|
||||
var cwu = SpecialPowers.getDOMWindowUtils(win);
|
||||
function step() {
|
||||
cwu.advanceTimeAndRefresh(100);
|
||||
}
|
||||
|
||||
SimpleTest.waitForFocus(function() {
|
||||
// Make sure that pressing Space when a contenteditable element is not focused
|
||||
// will scroll the page.
|
||||
|
@ -32,80 +39,92 @@ SimpleTest.waitForFocus(function() {
|
|||
sc.focus();
|
||||
is(win.scrollY, 0, "Sanity check");
|
||||
synthesizeKey(" ", {}, win);
|
||||
setTimeout(function() {
|
||||
isnot(win.scrollY, 0, "Page is scrolled down");
|
||||
is(ed.textContent, "abc", "The content of the editable element has not changed");
|
||||
var oldY = win.scrollY;
|
||||
synthesizeKey(" ", {shiftKey: true}, win);
|
||||
setTimeout(function() {
|
||||
ok(win.scrollY < oldY, "Page is scrolled up");
|
||||
is(ed.textContent, "abc", "The content of the editable element has not changed");
|
||||
|
||||
// Make sure that pressing Space when a contenteditable element is focused
|
||||
// will not scroll the page, and will edit the element.
|
||||
ed.focus();
|
||||
win.getSelection().collapse(ed.firstChild, 1);
|
||||
oldY = win.scrollY;
|
||||
synthesizeKey(" ", {}, win);
|
||||
setTimeout(function() {
|
||||
ok(win.scrollY <= oldY, "Page is not scrolled down");
|
||||
is(ed.textContent, "a bc", "The content of the editable element has changed");
|
||||
sc.focus();
|
||||
synthesizeKey(" ", {}, win);
|
||||
setTimeout(function() {
|
||||
isnot(win.scrollY, 0, "Page is scrolled down");
|
||||
is(ed.textContent, "a bc", "The content of the editable element has not changed");
|
||||
ed.focus();
|
||||
win.getSelection().collapse(ed.firstChild, 3);
|
||||
synthesizeKey(" ", {shiftKey: true}, win);
|
||||
setTimeout(function() {
|
||||
isnot(win.scrollY, 0, "Page is not scrolled up");
|
||||
is(ed.textContent, "a b c", "The content of the editable element has changed");
|
||||
step();
|
||||
|
||||
// Now let's test the down/up keys
|
||||
sc = document.body;
|
||||
setTimeout(function() {
|
||||
ed.blur();
|
||||
sc.focus();
|
||||
oldY = win.scrollY;
|
||||
synthesizeKey("VK_UP", {}, win);
|
||||
setTimeout(function() {
|
||||
ok(win.scrollY < oldY, "Page is scrolled up");
|
||||
oldY = win.scrollY;
|
||||
ed.focus();
|
||||
win.getSelection().collapse(ed.firstChild, 3);
|
||||
synthesizeKey("VK_UP", {}, win);
|
||||
setTimeout(function() {
|
||||
is(win.scrollY, oldY, "Page is not scrolled up");
|
||||
is(win.getSelection().focusNode, ed.firstChild, "Correct element selected");
|
||||
is(win.getSelection().focusOffset, 0, "Selection should be moved to the beginning");
|
||||
win.getSelection().removeAllRanges();
|
||||
synthesizeMouse(sc, 300, 300, {}, win);
|
||||
synthesizeKey("VK_DOWN", {}, win);
|
||||
setTimeout(function() {
|
||||
ok(win.scrollY > oldY, "Page is scrolled down");
|
||||
ed.focus();
|
||||
win.getSelection().collapse(ed.firstChild, 3);
|
||||
oldY = win.scrollY;
|
||||
synthesizeKey("VK_DOWN", {}, win);
|
||||
setTimeout(function() {
|
||||
is(win.scrollY, oldY, "Page is not scrolled down");
|
||||
is(win.getSelection().focusNode, ed.firstChild, "Correct element selected");
|
||||
is(win.getSelection().focusOffset, ed.textContent.length, "Selection should be moved to the end");
|
||||
isnot(win.scrollY, 0, "Page is scrolled down");
|
||||
is(ed.textContent, "abc", "The content of the editable element has not changed");
|
||||
var oldY = win.scrollY;
|
||||
synthesizeKey(" ", {shiftKey: true}, win);
|
||||
|
||||
win.close();
|
||||
SpecialPowers.clearUserPref(smoothScrollPref);
|
||||
SimpleTest.finish();
|
||||
}, 20);
|
||||
}, 20);
|
||||
}, 20);
|
||||
}, 20);
|
||||
}, 20);
|
||||
}, 20);
|
||||
}, 20);
|
||||
}, 20);
|
||||
}, 20);
|
||||
}, 20);
|
||||
step();
|
||||
|
||||
ok(win.scrollY < oldY, "Page is scrolled up");
|
||||
is(ed.textContent, "abc", "The content of the editable element has not changed");
|
||||
|
||||
// Make sure that pressing Space when a contenteditable element is focused
|
||||
// will not scroll the page, and will edit the element.
|
||||
ed.focus();
|
||||
win.getSelection().collapse(ed.firstChild, 1);
|
||||
oldY = win.scrollY;
|
||||
synthesizeKey(" ", {}, win);
|
||||
|
||||
step();
|
||||
|
||||
ok(win.scrollY <= oldY, "Page is not scrolled down");
|
||||
is(ed.textContent, "a bc", "The content of the editable element has changed");
|
||||
sc.focus();
|
||||
synthesizeKey(" ", {}, win);
|
||||
|
||||
step();
|
||||
|
||||
isnot(win.scrollY, 0, "Page is scrolled down");
|
||||
is(ed.textContent, "a bc", "The content of the editable element has not changed");
|
||||
ed.focus();
|
||||
win.getSelection().collapse(ed.firstChild, 3);
|
||||
synthesizeKey(" ", {shiftKey: true}, win);
|
||||
|
||||
step();
|
||||
|
||||
isnot(win.scrollY, 0, "Page is not scrolled up");
|
||||
is(ed.textContent, "a b c", "The content of the editable element has changed");
|
||||
|
||||
// Now let's test the down/up keys
|
||||
sc = document.body;
|
||||
|
||||
step();
|
||||
|
||||
ed.blur();
|
||||
sc.focus();
|
||||
oldY = win.scrollY;
|
||||
synthesizeKey("VK_UP", {}, win);
|
||||
|
||||
step();
|
||||
|
||||
ok(win.scrollY < oldY, "Page is scrolled up");
|
||||
oldY = win.scrollY;
|
||||
ed.focus();
|
||||
win.getSelection().collapse(ed.firstChild, 3);
|
||||
synthesizeKey("VK_UP", {}, win);
|
||||
|
||||
step();
|
||||
|
||||
is(win.scrollY, oldY, "Page is not scrolled up");
|
||||
is(win.getSelection().focusNode, ed.firstChild, "Correct element selected");
|
||||
is(win.getSelection().focusOffset, 0, "Selection should be moved to the beginning");
|
||||
win.getSelection().removeAllRanges();
|
||||
synthesizeMouse(sc, 300, 300, {}, win);
|
||||
synthesizeKey("VK_DOWN", {}, win);
|
||||
|
||||
step();
|
||||
|
||||
ok(win.scrollY > oldY, "Page is scrolled down");
|
||||
ed.focus();
|
||||
win.getSelection().collapse(ed.firstChild, 3);
|
||||
oldY = win.scrollY;
|
||||
synthesizeKey("VK_DOWN", {}, win);
|
||||
|
||||
step();
|
||||
|
||||
is(win.scrollY, oldY, "Page is not scrolled down");
|
||||
is(win.getSelection().focusNode, ed.firstChild, "Correct element selected");
|
||||
is(win.getSelection().focusOffset, ed.textContent.length, "Selection should be moved to the end");
|
||||
|
||||
win.close();
|
||||
SpecialPowers.clearUserPref(smoothScrollPref);
|
||||
cwu.restoreNormalRefresh();
|
||||
|
||||
SimpleTest.finish();
|
||||
}, win);
|
||||
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче