browser/base/content/test/general/browser_drag.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_drag.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,45 @@
     1.4 +function test()
     1.5 +{
     1.6 +  waitForExplicitFinish();
     1.7 +
     1.8 +  let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
     1.9 +                     getService(Ci.mozIJSSubScriptLoader);
    1.10 +  let ChromeUtils = {};
    1.11 +  scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js", ChromeUtils);
    1.12 +
    1.13 +  // ---- Test dragging the proxy icon ---
    1.14 +  var value = content.location.href;
    1.15 +  var urlString = value + "\n" + content.document.title;
    1.16 +  var htmlString = "<a href=\"" + value + "\">" + value + "</a>";
    1.17 +  var expected = [ [
    1.18 +    { type  : "text/x-moz-url",
    1.19 +      data  : urlString },
    1.20 +    { type  : "text/uri-list",
    1.21 +      data  : value },
    1.22 +    { type  : "text/plain",
    1.23 +      data  : value },
    1.24 +    { type  : "text/html",
    1.25 +      data  : htmlString }
    1.26 +  ] ];
    1.27 +  // set the valid attribute so dropping is allowed
    1.28 +  var oldstate = gURLBar.getAttribute("pageproxystate");
    1.29 +  gURLBar.setAttribute("pageproxystate", "valid");
    1.30 +  var dt = EventUtils.synthesizeDragStart(document.getElementById("identity-box"), expected);
    1.31 +  is(dt, null, "drag on proxy icon");
    1.32 +  gURLBar.setAttribute("pageproxystate", oldstate);
    1.33 +  // Now, the identity information panel is opened by the proxy icon click.
    1.34 +  // We need to close it for next tests.
    1.35 +  EventUtils.synthesizeKey("VK_ESCAPE", {}, window);
    1.36 +
    1.37 +  // now test dragging onto a tab
    1.38 +  var tab = gBrowser.addTab("about:blank", {skipAnimation: true});
    1.39 +  var browser = gBrowser.getBrowserForTab(tab);
    1.40 +
    1.41 +  browser.addEventListener("load", function () {
    1.42 +    is(browser.contentWindow.location, "http://mochi.test:8888/", "drop on tab");
    1.43 +    gBrowser.removeTab(tab);
    1.44 +    finish();
    1.45 +  }, true);
    1.46 +
    1.47 +  ChromeUtils.synthesizeDrop(tab, tab, [[{type: "text/uri-list", data: "http://mochi.test:8888/"}]], "copy", window);
    1.48 +}

mercurial