tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_drag.js (1636B)


      1 async function test() {
      2  waitForExplicitFinish();
      3 
      4  // ---- Test dragging the proxy icon ---
      5  var value = content.location.href;
      6  var urlString = value + "\n" + content.document.title;
      7  var htmlString = '<a href="' + value + '">' + value + "</a>";
      8  var expected = [
      9    [
     10      { type: "text/x-moz-url", data: urlString },
     11      { type: "text/uri-list", data: value },
     12      { type: "text/plain", data: value },
     13      { type: "text/html", data: htmlString },
     14    ],
     15  ];
     16  // set the valid attribute so dropping is allowed
     17  var oldstate = gURLBar.getAttribute("pageproxystate");
     18  gURLBar.setPageProxyState("valid");
     19  let result = await EventUtils.synthesizePlainDragAndCancel(
     20    {
     21      srcElement: document.getElementById("identity-icon-box"),
     22    },
     23    expected
     24  );
     25  Assert.strictEqual(result, true, "dragging dataTransfer should be expected");
     26  gURLBar.setPageProxyState(oldstate);
     27  // Now, the identity information panel is opened by the proxy icon click.
     28  // We need to close it for next tests.
     29  EventUtils.synthesizeKey("VK_ESCAPE", {}, window);
     30 
     31  // now test dragging onto a tab
     32  var tab = BrowserTestUtils.addTab(gBrowser, "about:blank", {
     33    skipAnimation: true,
     34  });
     35  var browser = gBrowser.getBrowserForTab(tab);
     36 
     37  browser.addEventListener(
     38    "load",
     39    function () {
     40      is(
     41        browser.contentWindow.location,
     42        "http://mochi.test:8888/",
     43        "drop on tab"
     44      );
     45      gBrowser.removeTab(tab);
     46      finish();
     47    },
     48    true
     49  );
     50 
     51  EventUtils.synthesizeDrop(
     52    tab,
     53    tab,
     54    [[{ type: "text/uri-list", data: "http://mochi.test:8888/" }]],
     55    "copy",
     56    window
     57  );
     58 }