Bug 881832 - Fix hover_helper to handle that multiple resizes due to :hover oscillation are now coalesced and don't fire resize events. r=dbaron

This commit is contained in:
Matt Woodrow 2016-05-12 12:08:31 +12:00
Родитель fdb3066641
Коммит 26046e381f
1 изменённых файлов: 47 добавлений и 62 удалений

Просмотреть файл

@ -146,126 +146,111 @@ function step6() {
step6called = true; step6called = true;
is(getComputedStyle(divtwo, "").backgroundColor, "transparent", is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
":hover does not apply"); ":hover does not apply");
setResize("step7()");
synthesizeMouse(divtwoparent, 2, 5, moveEvent, window); synthesizeMouse(divtwoparent, 2, 5, moveEvent, window);
setTimeout(step7, 500); // time to detect oscillations if they exist
} }
var step7called = false; var step7called = false;
function step7() { function step7() {
is(step7called, false, "step7 called only once"); is(step7called, false, "step7 called only once (more than two cycles of oscillation)");
if (step7called)
return;
step7called = true; step7called = true;
if (getComputedStyle(iframe, "").width == "50px") {
// The two resize events may be coalesced into a single one.
step8();
return;
}
is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
":hover applies");
setResize("step8()");
/* expect to get a second resize from the oscillation */
}
var step8called = false;
function step8() {
is(step8called, false, "step8 called only once (more than two cycles of oscillation)");
if (step8called)
return;
step8called = true;
is(getComputedStyle(divtwo, "").backgroundColor, "transparent", is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
":hover does not apply"); ":hover does not apply");
setTimeout(step9, 500); // time to detect oscillations if they exist setTimeout(step8, 500); // time to detect oscillations if they exist
} }
/* test the same case with scrolltop */ /* test the same case with scrolltop */
var step8called = false;
function step8() {
is(step8called, false, "step8 called only once");
step8called = true;
iframe.contentDocument.body.removeAttribute("onresize");
/* move the mouse out of the way */
synthesizeMouse(divtwoparent, 200, 5, moveEvent, window);
divtwoparent.scrollLeft = 5;
setResize("step9()");
synthesizeMouse(divtwoparent, 2, 5, moveEvent, window);
/* mouse now over 7, 5 */
}
var step9called = false; var step9called = false;
function step9() { function step9() {
is(step9called, false, "step9 called only once"); is(step9called, false, "step9 called only once");
step9called = true; step9called = true;
iframe.contentDocument.body.removeAttribute("onresize"); is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
/* move the mouse out of the way */ ":hover applies");
synthesizeMouse(divtwoparent, 200, 5, moveEvent, window);
divtwoparent.scrollLeft = 5;
setResize("step10()"); setResize("step10()");
synthesizeMouse(divtwoparent, 2, 5, moveEvent, window); divtwoparent.scrollLeft = 0; /* mouse now over 2,5 */
/* mouse now over 7, 5 */
} }
var step10called = false; var step10called = false;
function step10() { function step10() {
is(step10called, false, "step10 called only once"); is(step10called, false, "step10 called only once");
step10called = true; step10called = true;
is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
":hover applies");
setResize("step11()");
divtwoparent.scrollLeft = 0; /* mouse now over 2,5 */
}
var step11called = false;
function step11() {
is(step11called, false, "step11 called only once");
step11called = true;
if (getComputedStyle(iframe, "").width == "100px") { if (getComputedStyle(iframe, "").width == "100px") {
// The two resize events may be coalesced into a single one. // The two resize events may be coalesced into a single one.
step12(); step11();
return; return;
} }
is(getComputedStyle(divtwo, "").backgroundColor, "transparent", is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
":hover does not apply"); ":hover does not apply");
setResize("step12()"); setResize("step11()");
/* expect to get a second resize from the oscillation */ /* expect to get a second resize from the oscillation */
} }
var step11called = false;
function step11() {
is(step11called, false, "step11 called only once (more than two cycles of oscillation)");
if (step11called)
return;
step11called = true;
is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
":hover applies");
setTimeout(step12, 500); // time to detect oscillations if they exist
}
var step12called = false; var step12called = false;
function step12() { function step12() {
is(step12called, false, "step12 called only once (more than two cycles of oscillation)"); is(step12called, false, "step12 called only once");
if (step12called)
return;
step12called = true; step12called = true;
is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)", setResize("step13()");
":hover applies"); divtwoparent.scrollLeft = 25; /* mouse now over 27,5 */
setTimeout(step13, 500); // time to detect oscillations if they exist
} }
var step13called = false; var step13called = false;
function step13() { function step13() {
is(step13called, false, "step13 called only once"); is(step13called, false, "step13 called only once");
step13called = true; step13called = true;
is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
":hover does not apply");
setResize("step14()"); setResize("step14()");
divtwoparent.scrollLeft = 25; /* mouse now over 27,5 */ divtwoparent.scrollLeft = 0; /* mouse now over 2,5 */
} }
var step14called = false; var step14called = false;
function step14() { function step14() {
is(step14called, false, "step14 called only once"); is(step14called, false, "step14 called only once");
step14called = true; step14called = true;
is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
":hover does not apply");
setResize("step15()");
divtwoparent.scrollLeft = 0; /* mouse now over 2,5 */
}
var step15called = false;
function step15() {
is(step15called, false, "step15 called only once");
step15called = true;
if (getComputedStyle(iframe, "").width == "50px") { if (getComputedStyle(iframe, "").width == "50px") {
// The two resize events may be coalesced into a single one. // The two resize events may be coalesced into a single one.
step16(); step15();
return; return;
} }
is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)", is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
":hover applies"); ":hover applies");
setResize("step16()"); setResize("step15()");
/* expect to get a second resize from the oscillation */ /* expect to get a second resize from the oscillation */
} }
var step16called = false; var step15called = false;
function step16() { function step15() {
is(step16called, false, "step16 called only once (more than two cycles of oscillation)"); is(step15called, false, "step15 called only once (more than two cycles of oscillation)");
if (step16called) if (step15called)
return; return;
step16called = true; step15called = true;
is(getComputedStyle(divtwo, "").backgroundColor, "transparent", is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
":hover does not apply"); ":hover does not apply");
setTimeout(finish, 500); // time to detect oscillations if they exist setTimeout(finish, 500); // time to detect oscillations if they exist