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.

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

mercurial