mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bd96b74b10
--HG-- rename : testing/mochitest/tests/SimpleTest/tests/test_synthesizeDragStart.xul => testing/mochitest/chrome/test_synthesizeDragStart.xul rename : testing/mochitest/tests/SimpleTest/tests/test_synthesizeDrop.xul => testing/mochitest/chrome/test_synthesizeDrop.xul
163 lines
5.7 KiB
XML
163 lines
5.7 KiB
XML
<?xml version="1.0"?>
|
|
<!--
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
*
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
* the License. You may obtain a copy of the License at
|
|
* http://www.mozilla.org/MPL/
|
|
*
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
* for the specific language governing rights and limitations under the
|
|
* License.
|
|
*
|
|
* The Original Code is mozilla.org code.
|
|
*
|
|
* The Initial Developer of the Original Code is
|
|
* Mozilla Corporation.
|
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
|
* the Initial Developer. All Rights Reserved.
|
|
*
|
|
* Contributor(s):
|
|
* Phil Lacy <philbaseless-firefox@yahoo.com> (Original Author)
|
|
*
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
* the provisions above, a recipient may use your version of this file under
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
*
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
/**
|
|
* Assure EventUtils can perform synthesizeDragStart as specified
|
|
*/
|
|
|
|
SimpleTest/tests/test_synthesizeDragStart.xul
|
|
|
|
complete one flavor drag of simple text
|
|
check match of [[]]
|
|
complete 2 flavor drag
|
|
check order
|
|
complete File flavor drag
|
|
check if nsIFile can be determined
|
|
|
|
-->
|
|
<window title="Mozilla Bug 462172 extra tests for synthesizeDragStart"
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
onload="setTimeout(test,0)">
|
|
<script type="application/javascript"
|
|
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
|
<script type="application/javascript"
|
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
|
<script type="application/javascript"
|
|
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
|
<script type="application/javascript">
|
|
<![CDATA[
|
|
|
|
/** Test for Bug 462172 synthesizeDragStart**/
|
|
var testFile = Components.classes["@mozilla.org/file/directory_service;1"].
|
|
getService(Components.interfaces.nsIProperties).
|
|
get("CurWorkD", Components.interfaces.nsIFile);
|
|
var regularDtForDrag1 = null;
|
|
|
|
function doOnDragStart(aEvent)
|
|
{
|
|
var dt = aEvent.dataTransfer;
|
|
switch (aEvent.currentTarget.id) {
|
|
case "drag2" :
|
|
dt.setData("text/plain", "this is text/plain");
|
|
case "drag1" :
|
|
regularDtForDrag1 = dt;
|
|
dt.setData("text/uri-list", "http://www.mozilla.org/");
|
|
break;
|
|
case "dragfile" :
|
|
dt.mozSetDataAt("application/x-moz-file", testFile, 0);
|
|
break;
|
|
}
|
|
dt.effectAllowed = "all";
|
|
}
|
|
|
|
// this is the expected data arrays
|
|
// for testing drag of 2 items create 2 inner arrays
|
|
var drag1 = [[
|
|
{ type : "text/uri-list",
|
|
data : "http://www.mozilla.org/" }
|
|
]];
|
|
var drag2items = [[
|
|
{ type : "text/uri-list",
|
|
data : "http://www.mozilla.org/" }
|
|
],[
|
|
{ type : "text/uri-list",
|
|
data : "http://www.mozilla.org/" }
|
|
]];
|
|
var drag1WrongFlavor = [[
|
|
{ type : "text/plain",
|
|
data : "this is text/plain" }
|
|
]];
|
|
var drag2 = [[
|
|
{ type : "text/plain",
|
|
data : "this is text/plain" },
|
|
{ type : "text/uri-list",
|
|
data : "http://www.mozilla.org/" }
|
|
]];
|
|
var drag2WrongOrder = [[
|
|
{ type : "text/uri-list",
|
|
data : "http://www.mozilla.org/" },
|
|
{ type : "text/plain",
|
|
data : "this is text/plain" }
|
|
]];
|
|
var dragfile = [[
|
|
{ type : "application/x-moz-file",
|
|
data : testFile,
|
|
eqTest : function(actualData, expectedData) {return expectedData.equals(actualData);} }
|
|
]];
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
function test() {
|
|
|
|
var result;
|
|
// Now we can run our tests
|
|
result = synthesizeDragStart($("drag1"), drag1, window);
|
|
is(result, null, "drag1 is text/uri-list");
|
|
result = synthesizeDragStart($("drag1"), drag1WrongFlavor, window);
|
|
isnot(result, null, "drag1 is not text/plain");
|
|
result = synthesizeDragStart($("drag1"), drag2items, window);
|
|
isnot(result, null, "drag1 is not 2 items");
|
|
result = synthesizeDragStart($("drag2"), drag2, window);
|
|
is(result, null, "drag2 is ordered text/plain then text/uri-list");
|
|
result = synthesizeDragStart($("drag2"), drag1, window);
|
|
isnot(result, null, "drag2 is not one flavor");
|
|
result = synthesizeDragStart($("drag2"), drag2WrongOrder, window);
|
|
isnot(result, null, "drag2 is not ordered text/uri-list then text/plain");
|
|
result = synthesizeDragStart($("dragfile"), dragfile, window);
|
|
is(result, null, "dragfile is nsIFile");
|
|
result = synthesizeDragStart($("drag1"), null, window);
|
|
is(result, regularDtForDrag1, "synthesizeDragStart accepts null expectedDragData");
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
]]>
|
|
</script>
|
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
<p id="display"></p>
|
|
<div id="content" style="display:none;"></div>
|
|
<pre id="test"></pre>
|
|
<div id="drag1" ondragstart="doOnDragStart(event);">Need some space here</div>
|
|
<div id="drag2" ondragstart="doOnDragStart(event);">Need more space</div>
|
|
<div id="dragfile" ondragstart="doOnDragStart(event);">Sure why not here too</div>
|
|
</body>
|
|
</window>
|