layout/xul/test/browser_bug703210.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/xul/test/browser_bug703210.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +function test() {
     1.5 +  waitForExplicitFinish();
     1.6 +
     1.7 +  gBrowser.selectedTab = gBrowser.addTab();
     1.8 +
     1.9 +  SpecialPowers.setIntPref("ui.tooltipDelay", 0);
    1.10 +
    1.11 +  let doStopPropagation = function (aEvent)
    1.12 +  {
    1.13 +    aEvent.stopPropagation();
    1.14 +  }
    1.15 +
    1.16 +  let onPopupShown = function (aEvent)
    1.17 +  {
    1.18 +    is(aEvent.originalTarget.localName, "tooltip", "tooltip is showing");
    1.19 +
    1.20 +    let doc = gBrowser.contentDocument;
    1.21 +    let win = gBrowser.contentWindow;
    1.22 +    let p2 = doc.getElementById("p2");
    1.23 +    setTimeout(function () {
    1.24 +      EventUtils.synthesizeMouseAtCenter(p2, { type: "mousemove" }, win); }, 0);
    1.25 +  }
    1.26 +
    1.27 +  let onPopupHiding = function (aEvent)
    1.28 +  {
    1.29 +    is(aEvent.originalTarget.localName, "tooltip", "tooltip is hiding");
    1.30 +
    1.31 +    let doc = gBrowser.contentDocument;
    1.32 +
    1.33 +    doc.removeEventListener("mousemove", doStopPropagation, true);
    1.34 +    doc.removeEventListener("mouseenter", doStopPropagation, true);
    1.35 +    doc.removeEventListener("mouseleave", doStopPropagation, true);
    1.36 +    doc.removeEventListener("mouseover", doStopPropagation, true);
    1.37 +    doc.removeEventListener("mouseout", doStopPropagation, true);
    1.38 +    document.removeEventListener("popupshown", onPopupShown, true);
    1.39 +    document.removeEventListener("popuphiding", onPopupHiding, true);
    1.40 +
    1.41 +    SpecialPowers.clearUserPref("ui.tooltipDelay");
    1.42 +
    1.43 +    gBrowser.removeCurrentTab();
    1.44 +    finish();
    1.45 +  }
    1.46 +
    1.47 +  let onLoad = function (aEvent)
    1.48 +  {
    1.49 +    let doc = gBrowser.contentDocument;
    1.50 +    let win = gBrowser.contentWindow;
    1.51 +    let p1 = doc.getElementById("p1");
    1.52 +    let p2 = doc.getElementById("p2");
    1.53 +
    1.54 +    EventUtils.synthesizeMouseAtCenter(p2, { type: "mousemove" }, win);
    1.55 +
    1.56 +    doc.addEventListener("mousemove", doStopPropagation, true);
    1.57 +    doc.addEventListener("mouseenter", doStopPropagation, true);
    1.58 +    doc.addEventListener("mouseleave", doStopPropagation, true);
    1.59 +    doc.addEventListener("mouseover", doStopPropagation, true);
    1.60 +    doc.addEventListener("mouseout", doStopPropagation, true);
    1.61 +    document.addEventListener("popupshown", onPopupShown, true);
    1.62 +    document.addEventListener("popuphiding", onPopupHiding, true);
    1.63 +
    1.64 +    EventUtils.synthesizeMouseAtCenter(p1, { type: "mousemove" }, win);
    1.65 +  }
    1.66 +
    1.67 +  gBrowser.selectedBrowser.addEventListener("load", function loadListener() {
    1.68 +    gBrowser.selectedBrowser.removeEventListener("load", loadListener, true);
    1.69 +    setTimeout(onLoad, 0);
    1.70 +  }, true);
    1.71 +
    1.72 +  content.location = "data:text/html," +
    1.73 +    "<p id=\"p1\" title=\"tooltip is here\">This paragraph has a tooltip.</p>" +
    1.74 +    "<p id=\"p2\">This paragraph doesn't have tooltip.</p>";
    1.75 +}

mercurial