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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1
michael@0 2 function test() {
michael@0 3 waitForExplicitFinish();
michael@0 4
michael@0 5 let tab = gBrowser.addTab();
michael@0 6 gBrowser.selectedTab = tab;
michael@0 7 tab.linkedBrowser.addEventListener("load", function(aEvent) {
michael@0 8 tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
michael@0 9
michael@0 10 ok(true, "Load listener called");
michael@0 11 waitForFocus(onFocus, content);
michael@0 12 }, true);
michael@0 13
michael@0 14 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>";
michael@0 15 }
michael@0 16
michael@0 17 function onFocus() {
michael@0 18 EventUtils.synthesizeKey("f", { accelKey: true });
michael@0 19 ok(gFindBarInitialized, "find bar is now initialized");
michael@0 20
michael@0 21 EventUtils.synthesizeKey("d", {});
michael@0 22 EventUtils.synthesizeKey("i", {});
michael@0 23 EventUtils.synthesizeKey("v", {});
michael@0 24 // finds the div in the green box
michael@0 25
michael@0 26 EventUtils.synthesizeKey("g", { accelKey: true });
michael@0 27 // finds the div in the red box
michael@0 28
michael@0 29 var rect = content.document.getElementById("s").getBoundingClientRect();
michael@0 30 ok(rect.left >= 0, "scroll should include find result");
michael@0 31
michael@0 32 // clear the find bar
michael@0 33 EventUtils.synthesizeKey("a", { accelKey: true });
michael@0 34 EventUtils.synthesizeKey("VK_DELETE", { });
michael@0 35
michael@0 36 gFindBar.close();
michael@0 37 gBrowser.removeCurrentTab();
michael@0 38 finish();
michael@0 39 }

mercurial