DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (a81015259a98)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
<!DOCTYPE HTML>
<html>
<head>
  <title>Test for :hover</title>
  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
  <style type="text/css">

  div#one { height: 10px; width: 10px; }
  div#one:hover { background: #00f; }
  div#one > div { height: 5px; width: 20px; }
  div#one > div:hover { background: #f00; }

  div#twoparent { overflow: hidden; height: 20px; }
  div#two { width: 10px; height: 10px; }
  div#two:hover { margin-left: 5px; background: #0f0; }
  div#two + iframe { width: 50px; height: 10px; }
  div#two:hover + iframe { width: 100px; }

  </style>
</head>
<!-- need a set timeout because we need things to start after painting suppression ends -->
<body onload="setTimeout(step1, 0)">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<div id="display" style="position: absolute; top: 0; left: 0; width: 300px; height: 300px">

  <div id="one"><div></div></div>

  <div id="twoparent">
    <div id="two"></div>
    <iframe id="twoi" src="hover_empty.html"></iframe>
    <div style="width: 5000px; height: 10px;"></div>
  </div>

</div>
<pre id="test">
<script type="application/javascript">

var imports = [ "SimpleTest", "is", "isnot", "ok" ];
for each (var name in imports) {
    window[name] = window.opener.wrappedJSObject[name];
}

var div = document.getElementById("display");
var divtwo = document.getElementById("two");
var iframe = document.getElementById("twoi");
var divtwoparent = document.getElementById("twoparent");

iframe.contentDocument.open();
iframe.contentDocument.write("<style type='text/css'>html, body { margin: 0; padding: 0; }<\/style><body>");
iframe.contentDocument.close();

var moveEvent = { type: "mousemove", clickCount: "0" };

function setResize(str) {
  var handler = function() {
    iframe.contentWindow.removeEventListener("resize", arguments.callee, false);
    setTimeout(str, 100);
  };
  iframe.contentWindow.addEventListener("resize", handler, false);
}

function step1() {
    /** test basic hover **/
    var divone = document.getElementById("one");
    synthesizeMouse(divone, 5, 7, moveEvent, window);
    is(getComputedStyle(divone, "").backgroundColor, "rgb(0, 0, 255)",
       ":hover applies");
    is(getComputedStyle(divone.firstChild, "").backgroundColor, "transparent",
       ":hover does not apply");
    synthesizeMouse(divone, 5, 2, moveEvent, window);
    is(getComputedStyle(divone, "").backgroundColor, "rgb(0, 0, 255)",
       ":hover applies hierarchically");
    is(getComputedStyle(divone.firstChild, "").backgroundColor, "rgb(255, 0, 0)",
       ":hover applies");
    synthesizeMouse(divone, 15, 7, moveEvent, window);
    is(getComputedStyle(divone, "").backgroundColor, "transparent",
       ":hover does not apply");
    is(getComputedStyle(divone.firstChild, "").backgroundColor, "transparent",
       ":hover does not apply");
    synthesizeMouse(divone, 15, 2, moveEvent, window);
    is(getComputedStyle(divone, "").backgroundColor, "rgb(0, 0, 255)",
       ":hover applies hierarchically");
    is(getComputedStyle(divone.firstChild, "").backgroundColor, "rgb(255, 0, 0)",
       ":hover applies");

    /** Test for Bug 302561 **/
    setResize("step2();");
    is(iframe.contentDocument.body.offsetWidth, 50,
       ":hover does not apply (iframe body width)");
    synthesizeMouse(divtwoparent, 7, 5, moveEvent, window);
    is(iframe.contentDocument.body.offsetWidth, 100,
       ":hover applies (iframe body width)");
}

var step2called = false;
function step2() {
    is(step2called, false, "step2 called only once");
    step2called = true;
    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
       ":hover applies");
    is(iframe.contentDocument.body.offsetWidth, 100,
       ":hover applies (iframe body width)");
    setResize("step3()");
    synthesizeMouse(divtwoparent, 2, 5, moveEvent, window);
    is(iframe.contentDocument.body.offsetWidth, 50,
       ":hover does not apply (iframe body width)");
}

var step3called = false;
function step3() {
    is(step3called, false, "step3 called only once");
    step3called = true;
    if (getComputedStyle(iframe, "").width == "100px") {
        // The two resize events may be coalesced into a single one.
        step4();
        return;
    }
    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
       ":hover does not apply");
    setResize("step4()");
    /* expect to get a second resize from the oscillation */
}

var step4called = false;
function step4() {
    is(step4called, false, "step4 called only once (more than two cycles of oscillation)");
    if (step4called)
        return;
    step4called = true;
    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
       ":hover applies");
    setTimeout(step5, 500); // time to detect oscillations if they exist
}

var step5called = false;
function step5() {
    is(step5called, false, "step5 called only once");
    step5called = true;
    setResize("step6()");
    synthesizeMouse(divtwoparent, 25, 5, moveEvent, window);
}

var step6called = false;
function step6() {
    is(step6called, false, "step6 called only once");
    step6called = true;
    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
       ":hover does not apply");
    setResize("step7()");
    synthesizeMouse(divtwoparent, 2, 5, moveEvent, window);
}

var step7called = false;
function step7() {
    is(step7called, false, "step7 called only once");
    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",
       ":hover does not apply");
    setTimeout(step9, 500); // time to detect oscillations if they exist
}

/* test the same case with scrolltop */

var step9called = false;
function step9() {
    is(step9called, false, "step9 called only once");
    step9called = true;
    iframe.contentDocument.body.removeAttribute("onresize");
    /* move the mouse out of the way */
    synthesizeMouse(divtwoparent, 200, 5, moveEvent, window);
    divtwoparent.scrollLeft = 5;
    setResize("step10()");
    synthesizeMouse(divtwoparent, 2, 5, moveEvent, window);
    /* mouse now over 7, 5 */
}

var step10called = false;
function step10() {
    is(step10called, false, "step10 called only once");
    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") {
        // The two resize events may be coalesced into a single one.
        step12();
        return;
    }
    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
       ":hover does not apply");
    setResize("step12()");
    /* expect to get a second resize from the oscillation */
}

var step12called = false;
function step12() {
    is(step12called, false, "step12 called only once (more than two cycles of oscillation)");
    if (step12called)
        return;
    step12called = true;
    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
       ":hover applies");
    setTimeout(step13, 500); // time to detect oscillations if they exist
}

var step13called = false;
function step13() {
    is(step13called, false, "step13 called only once");
    step13called = true;
    setResize("step14()");
    divtwoparent.scrollLeft = 25; /* mouse now over 27,5 */
}

var step14called = false;
function step14() {
    is(step14called, false, "step14 called only once");
    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") {
        // The two resize events may be coalesced into a single one.
        step16();
        return;
    }
    is(getComputedStyle(divtwo, "").backgroundColor, "rgb(0, 255, 0)",
       ":hover applies");
    setResize("step16()");
    /* expect to get a second resize from the oscillation */
}

var step16called = false;
function step16() {
    is(step16called, false, "step16 called only once (more than two cycles of oscillation)");
    if (step16called)
        return;
    step16called = true;
    is(getComputedStyle(divtwo, "").backgroundColor, "transparent",
       ":hover does not apply");
    setTimeout(finish, 500); // time to detect oscillations if they exist
}

function finish() {
    document.getElementById("display").style.display = "none";

    var tester = window.SimpleTest;
    window.close();
    tester.finish();
}

</script>
</pre>
</body>
</html>