browser/base/content/test/general/browser_bug567306.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.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/
     3  */
     5 const {Ci: interfaces, Cc: classes} = Components;
     7 let Clipboard = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
     8 let HasFindClipboard = Clipboard.supportsFindClipboard();
    10 function test() {
    11   waitForExplicitFinish();
    13   whenNewWindowLoaded(undefined, function (win) {
    14     whenDelayedStartupFinished(win, function () {
    15       let selectedBrowser = win.gBrowser.selectedBrowser;
    16       selectedBrowser.addEventListener("pageshow", function() {
    17         selectedBrowser.removeEventListener("pageshow", arguments.callee, true);
    18         ok(true, "pageshow listener called: " + win.content.location);
    19         waitForFocus(function () {
    20           onFocus(win);
    21         }, selectedBrowser.contentWindow);
    22       }, true);
    23       selectedBrowser.loadURI("data:text/html,<h1 id='h1'>Select Me</h1>");
    24     });
    25   });
    26 }
    28 function selectText(win) {
    29   let elt = win.document.getElementById("h1");
    30   let selection = win.getSelection();
    31   let range = win.document.createRange();
    32   range.setStart(elt, 0);
    33   range.setEnd(elt, 1);
    34   selection.removeAllRanges();
    35   selection.addRange(range);
    36 }
    38 function onFocus(win) {
    39   ok(!win.gFindBarInitialized, "find bar is not yet initialized");
    40   let findBar = win.gFindBar;
    41   selectText(win.content);
    42   findBar.onFindCommand();
    43   // When the OS supports the Find Clipboard (OSX), the find field value is
    44   // persisted across Fx sessions, thus not useful to test.
    45   if (!HasFindClipboard)
    46     is(findBar._findField.value, "Select Me", "Findbar is initialized with selection");
    47   findBar.close();
    48   win.close();
    49   finish();
    50 }

mercurial