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.

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

mercurial