browser/base/content/test/general/browser_drag.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 function test()
     2 {
     3   waitForExplicitFinish();
     5   let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
     6                      getService(Ci.mozIJSSubScriptLoader);
     7   let ChromeUtils = {};
     8   scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js", ChromeUtils);
    10   // ---- Test dragging the proxy icon ---
    11   var value = content.location.href;
    12   var urlString = value + "\n" + content.document.title;
    13   var htmlString = "<a href=\"" + value + "\">" + value + "</a>";
    14   var expected = [ [
    15     { type  : "text/x-moz-url",
    16       data  : urlString },
    17     { type  : "text/uri-list",
    18       data  : value },
    19     { type  : "text/plain",
    20       data  : value },
    21     { type  : "text/html",
    22       data  : htmlString }
    23   ] ];
    24   // set the valid attribute so dropping is allowed
    25   var oldstate = gURLBar.getAttribute("pageproxystate");
    26   gURLBar.setAttribute("pageproxystate", "valid");
    27   var dt = EventUtils.synthesizeDragStart(document.getElementById("identity-box"), expected);
    28   is(dt, null, "drag on proxy icon");
    29   gURLBar.setAttribute("pageproxystate", oldstate);
    30   // Now, the identity information panel is opened by the proxy icon click.
    31   // We need to close it for next tests.
    32   EventUtils.synthesizeKey("VK_ESCAPE", {}, window);
    34   // now test dragging onto a tab
    35   var tab = gBrowser.addTab("about:blank", {skipAnimation: true});
    36   var browser = gBrowser.getBrowserForTab(tab);
    38   browser.addEventListener("load", function () {
    39     is(browser.contentWindow.location, "http://mochi.test:8888/", "drop on tab");
    40     gBrowser.removeTab(tab);
    41     finish();
    42   }, true);
    44   ChromeUtils.synthesizeDrop(tab, tab, [[{type: "text/uri-list", data: "http://mochi.test:8888/"}]], "copy", window);
    45 }

mercurial