browser/base/content/test/general/browser_visibleFindSelection.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/base/content/test/general/browser_visibleFindSelection.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,39 @@
     1.4 +
     1.5 +function test() {
     1.6 +  waitForExplicitFinish();
     1.7 +
     1.8 +  let tab = gBrowser.addTab();
     1.9 +  gBrowser.selectedTab = tab;
    1.10 +  tab.linkedBrowser.addEventListener("load", function(aEvent) {
    1.11 +    tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
    1.12 +
    1.13 +    ok(true, "Load listener called");
    1.14 +    waitForFocus(onFocus, content);
    1.15 +  }, true);
    1.16 +
    1.17 +  content.location = "data:text/html,<div style='position: absolute; left: 2200px; background: green; width: 200px; height: 200px;'>div</div><div style='position: absolute; left: 0px; background: red; width: 200px; height: 200px;'><span id='s'>div</span></div>";
    1.18 +}
    1.19 +
    1.20 +function onFocus() {
    1.21 +  EventUtils.synthesizeKey("f", { accelKey: true });
    1.22 +  ok(gFindBarInitialized, "find bar is now initialized");
    1.23 +
    1.24 +  EventUtils.synthesizeKey("d", {});
    1.25 +  EventUtils.synthesizeKey("i", {});
    1.26 +  EventUtils.synthesizeKey("v", {});
    1.27 +  // finds the div in the green box
    1.28 +
    1.29 +  EventUtils.synthesizeKey("g", { accelKey: true });
    1.30 +  // finds the div in the red box
    1.31 +
    1.32 +  var rect = content.document.getElementById("s").getBoundingClientRect();
    1.33 +  ok(rect.left >= 0, "scroll should include find result");
    1.34 +
    1.35 +  // clear the find bar
    1.36 +  EventUtils.synthesizeKey("a", { accelKey: true });
    1.37 +  EventUtils.synthesizeKey("VK_DELETE", { });
    1.38 +
    1.39 +  gFindBar.close();
    1.40 +  gBrowser.removeCurrentTab();
    1.41 +  finish();
    1.42 +}

mercurial