toolkit/content/tests/chrome/window_browser_drop.xul

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 <?xml version="1.0"?>
     2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     4 <window title="Browser Drop Tests"
     5         onload="loaded()"
     6         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     8   <script type="application/javascript"
     9           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    10   <script type="application/javascript"
    11           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    12   <script type="application/javascript"
    13           src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"/>
    15 <script>
    16 <![CDATA[
    18 var link = null, name = null;
    19 function handleLink(event, uri, linkname) { link = uri; name = linkname; }
    21 function runTest()
    22 {
    23   function expectLink(element, expectedLink, expectedName, data, testid)
    24   {
    25     link = "";
    26     name = "";
    27     synthesizeDrop(element, element, data, "", element.ownerDocument.defaultView);
    29     is(link, expectedLink, testid + " link");
    30     is(name, expectedName, testid + " name");
    31   }
    33   ["chrome", "content"].forEach(function (type) {
    34     var child = document.getElementById(type + "child");
    35     child.droppedLinkHandler = handleLink;
    37     expectLink(child, "http://www.mozilla.org", "http://www.mozilla.org",
    38                [ [ { type: "text/plain", data: "http://www.mozilla.org" } ] ],
    39                "text/plain drop on browser " + type);
    40     expectLink(child, "", "",
    41                [ [ { type: "text/link", data: "http://www.mozilla.org" } ] ],
    42                "text/link drop on browser " + type);
    43     expectLink(child, "http://www.example.com", "http://www.example.com",
    44                [ [ { type: "text/uri-list", data: "http://www.example.com\nhttp://www.mozilla.org" } ] ],
    45                "text/uri-list drop on browser " + type);
    46     expectLink(child, "http://www.example.com", "Example.com",
    47                [ [ { type: "text/x-moz-url", data: "http://www.example.com\nExample.com" } ] ],
    48                "text/x-moz-url drop on browser " + type);
    49     // dropping a chrome url should fail as we don't have a source node set,
    50     // defaulting to a source of file:///
    51     expectLink(child, "", "",
    52                [ [ { type: "text/x-moz-url", data: "chrome://browser/content/browser.xul" } ] ],
    53                "text/x-moz-url chrome url drop on browser " + type);
    54   });
    56   // stopPropagation should not prevent the browser link handling from occuring
    57   frames[1].wrappedJSObject.stopMode = true;
    58   var body = document.getElementById("contentchild").contentDocument.body;
    59   expectLink(body, "http://www.mozilla.org", "http://www.mozilla.org",
    60              [ [ { type: "text/uri-list", data: "http://www.mozilla.org" } ] ],
    61              "text/x-moz-url drop on browser with stopPropagation drop event");
    63   // canceling the event, however, should prevent the link from being handled
    64   frames[1].wrappedJSObject.cancelMode = true;
    65   expectLink(body, "", "",
    66              [ [ { type: "text/uri-list", data: "http://www.example.org" } ] ],
    67              "text/x-moz-url drop on browser with cancelled drop event");
    69   window.close();
    70   window.opener.wrappedJSObject.SimpleTest.finish();
    71 }
    73 function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); }
    74 function ok(v, n) { window.opener.wrappedJSObject.SimpleTest.ok(v,n); }
    76 function loaded()
    77 {
    78   SimpleTest.waitForFocus(runTest);
    79 }
    81 ]]>
    82 </script>
    84 <browser id="chromechild" src="about:blank"/>
    85 <browser id="contentchild" type="content" width="100" height="100"
    86          src="data:text/html,&lt;html draggable='true'&gt;&lt;body draggable='true' style='width: 100px; height: 100px;' ondragover='event.preventDefault()' ondrop='if (window.stopMode) event.stopPropagation(); if (window.cancelMode) event.preventDefault();'&gt;&lt;/body&gt;&lt;/html&gt;"/>
    88 </window>

mercurial