зеркало из https://github.com/mozilla/pjs.git
Bug 677626 - Add a profiling test suite for mochitest [tests]. r=jmaher
This commit is contained in:
Родитель
ceb84dbdec
Коммит
29f75e3672
|
@ -45,8 +45,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_STATIC_FILES = test_sample.xul \
|
||||
test_synthesizeDragStart.xul \
|
||||
test_synthesizeDrop.xul \
|
||||
test_sanityChromeUtils.xul \
|
||||
# Disabled until bug 652494 is resolved.
|
||||
# test_sanityException.xul \
|
||||
# test_sanityException2.xul \
|
||||
|
|
|
@ -0,0 +1,223 @@
|
|||
<?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 Foundation
|
||||
- Portions created by the Initial Developer are Copyright (C) 2011
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- 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 LGPL or the GPL. 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 ***** -->
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<window title="Test ChromeUtils functions"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<!-- ChromeUtils.js depends on EventUtils.js -->
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript">
|
||||
var start = new Date();
|
||||
</script>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script>
|
||||
<script type="text/javascript">
|
||||
var loadTime = new Date();
|
||||
</script>
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
SimpleTest.info("\nProfile::ChromeUtilsLoadTime: " + (loadTime - start) + "\n");
|
||||
var testFile = Components.classes["@mozilla.org/file/directory_service;1"].
|
||||
getService(Components.interfaces.nsIProperties).
|
||||
get("CurWorkD", Components.interfaces.nsIFile);
|
||||
var regularDtForDrag1 = null;
|
||||
var gSetDropEffect = true;
|
||||
var gData;
|
||||
var gEnter = false;
|
||||
var gOver = false;
|
||||
var dragDrop = [[
|
||||
{ type : "text/plain",
|
||||
data : "This is a test" }
|
||||
]];
|
||||
// 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);} }
|
||||
]];
|
||||
|
||||
function doOnDrop(aEvent) {
|
||||
gData = aEvent.dataTransfer.getData(dragDrop[0][0].type);
|
||||
aEvent.preventDefault(); // cancels event and keeps dropEffect
|
||||
// as was before event.
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
function doOnDragEnter(aEvent) {
|
||||
gEnter = true;
|
||||
aEvent.dataTransfer.effectAllowed = "all";
|
||||
aEvent.preventDefault(); // sets target this element
|
||||
}
|
||||
|
||||
function doOnDragOver(aEvent) {
|
||||
gOver = true;
|
||||
if (gSetDropEffect)
|
||||
aEvent.dataTransfer.dropEffect = "copy";
|
||||
aEvent.preventDefault();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function test() {
|
||||
var startTime = new Date();
|
||||
var result;
|
||||
|
||||
/* test synthesizeDragStart */
|
||||
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");
|
||||
|
||||
/* test synthesizeDrop */
|
||||
result = synthesizeDrop($("dragDrop"), $("dragDrop"), dragDrop, null, window);
|
||||
ok(gEnter, "Fired dragenter");
|
||||
ok(gOver, "Fired dragover");
|
||||
is(result, "copy", "copy is dropEffect");
|
||||
is(gData, dragDrop[0][0].data, "Received valid drop data");
|
||||
|
||||
gSetDropEffect = false;
|
||||
result = synthesizeDrop($("dragDrop"), $("dragDrop"), dragDrop, "link", window);
|
||||
is(result, "link", "link is dropEffect");
|
||||
gSetDropEffect = true;
|
||||
|
||||
$("textB").focus();
|
||||
var content = synthesizeQueryTextContent(0, 100);
|
||||
ok(content, "synthesizeQueryTextContent should not be null");
|
||||
ok(content.succeeded, "synthesizeQueryTextContent should succeed");
|
||||
is(content.text, "I haz a content", "synthesizeQueryTextContent should be 'I haz a content': " + content.text);
|
||||
|
||||
content = synthesizeQueryCaretRect(0);
|
||||
ok(content, "synthesizeQueryCaretRect should not be null");
|
||||
ok(content.succeeded, "synthesizeQueryCaretRect should succeed");
|
||||
|
||||
content = synthesizeQueryTextRect(0, 100);
|
||||
ok(content, "synthesizeQueryTextRect should not be null");
|
||||
ok(content.succeeded, "synthesizeQueryTextRect should succeed");
|
||||
|
||||
content = synthesizeQueryEditorRect();
|
||||
ok(content, "synthesizeQueryEditorRect should not be null");
|
||||
ok(content.succeeded, "synthesizeQueryEditorRect should succeed");
|
||||
|
||||
content = synthesizeCharAtPoint(0, 0);
|
||||
ok(content, "synthesizeCharAtPoint should not be null");
|
||||
ok(content.succeeded, "synthesizeCharAtPoint should succeed");
|
||||
|
||||
content = synthesizeSelectionSet(0, 100);
|
||||
ok(content, "synthesizeSelectionSet should not be null");
|
||||
is(content, true, "synthesizeSelectionSet should succeed");
|
||||
|
||||
var endTime = new Date();
|
||||
SimpleTest.info("\nProfile::ChromeUtilsRunTime: " + (endTime-startTime) + "\n");
|
||||
SimpleTest.finish();
|
||||
};
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml" onload="setTimeout('test()', 0)">
|
||||
<input id="textB" value="I haz a content"/>
|
||||
<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>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display:none;"></div>
|
||||
<pre id="test"></pre>
|
||||
<div id="dragDrop" ondragover ="doOnDragOver(event);"
|
||||
ondragenter ="doOnDragEnter(event);"
|
||||
ondragleave ="doOnDragLeave(event);"
|
||||
ondrop ="doOnDrop(event);">
|
||||
Need some depth and height to drag 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>
|
|
@ -1,160 +0,0 @@
|
|||
<?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/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>
|
|
@ -1,122 +0,0 @@
|
|||
<?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 synthesizeDrop as specified
|
||||
*/
|
||||
|
||||
-->
|
||||
<window title="Mozilla Bug 462172 extra tests for synthesizeDrop"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="setTimeout(test,0)">
|
||||
<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 synthesizeDrop**/
|
||||
|
||||
var gSetDropEffect = true;
|
||||
var gData;
|
||||
var gEnter = false;
|
||||
var gOver = false;
|
||||
var drag1 = [[
|
||||
{ type : "text/plain",
|
||||
data : "This is a test" }
|
||||
]];
|
||||
|
||||
function doOnDrop(aEvent)
|
||||
{
|
||||
gData = aEvent.dataTransfer.getData(drag1[0][0].type);
|
||||
aEvent.preventDefault(); // cancels event and keeps dropEffect
|
||||
// as was before event.
|
||||
}
|
||||
|
||||
function doOnDragEnter(aEvent)
|
||||
{
|
||||
gEnter = true;
|
||||
aEvent.dataTransfer.effectAllowed = "all";
|
||||
aEvent.preventDefault(); // sets target this element
|
||||
}
|
||||
|
||||
function doOnDragOver(aEvent)
|
||||
{
|
||||
gOver = true;
|
||||
if (gSetDropEffect)
|
||||
aEvent.dataTransfer.dropEffect = "copy";
|
||||
aEvent.preventDefault();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function test() {
|
||||
|
||||
var result;
|
||||
// Now we can run our tests
|
||||
result = synthesizeDrop($("drag1"), $("drag1"), drag1, null, window);
|
||||
ok(gEnter, "Fired dragenter");
|
||||
ok(gOver, "Fired dragover");
|
||||
is(result, "copy", "copy is dropEffect");
|
||||
is(gData, drag1[0][0].data, "Received valid drop data");
|
||||
|
||||
gSetDropEffect = false;
|
||||
result = synthesizeDrop($("drag1"), $("drag1"), drag1, "link", window);
|
||||
is(result, "link", "link is dropEffect");
|
||||
|
||||
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" ondragover ="doOnDragOver(event);"
|
||||
ondragenter ="doOnDragEnter(event);"
|
||||
ondragleave ="doOnDragLeave(event);"
|
||||
ondrop ="doOnDrop(event);">
|
||||
Need some depth and height to drag here
|
||||
</div>
|
||||
</body>
|
||||
</window>
|
|
@ -54,8 +54,12 @@ include $(topsrcdir)/config/rules.mk
|
|||
|
||||
_TEST_FILES = \
|
||||
test_sanity.html \
|
||||
test_sanityEventUtils.html \
|
||||
test_sanityException.html \
|
||||
test_sanityException2.html \
|
||||
test_sanityPluginUtils.html \
|
||||
test_sanitySimpletest.html \
|
||||
test_sanityWindowSnapshot.html \
|
||||
test_SpecialPowersExtension.html \
|
||||
test_SpecialPowersExtension2.html \
|
||||
file_SpecialPowersFrame1.html \
|
||||
|
|
|
@ -5,6 +5,14 @@
|
|||
* sendChar
|
||||
* sendString
|
||||
* sendKey
|
||||
* synthesizeMouse
|
||||
* synthesizeMouseAtCenter
|
||||
* synthesizeMouseScroll
|
||||
* synthesizeKey
|
||||
* synthesizeMouseExpectEvent
|
||||
* synthesizeKeyExpectEvent
|
||||
*
|
||||
* When adding methods to this file, please add a performance test for it.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -541,11 +549,6 @@ function _getDOMWindowUtils(aWindow)
|
|||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
}
|
||||
|
||||
/*
|
||||
* synthesizeComposition, synthesizeText and synthesizeQuerySelectedText
|
||||
* are only used by layout/base/tests/test_reftests_with_caret.html.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Synthesize a composition event.
|
||||
*
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<head>
|
||||
<title>Test for SpecialPowers extension</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body onload="starttest();">
|
||||
|
@ -31,8 +30,10 @@ function dispatchTestEvent() {
|
|||
|
||||
dump("\nSPECIALPTEST:::Test script loaded " + (new Date).getTime() + "\n");
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var startTime = new Date();
|
||||
function starttest(){
|
||||
dump("\nSPECIALPTEST:::Test script running after load " + (new Date).getTime() + "\n");
|
||||
|
||||
/** Test for SpecialPowers extension **/
|
||||
is(SpecialPowers.sanityCheck(), "foo", "check to see whether the Special Powers extension is installed.");
|
||||
|
||||
|
@ -75,9 +76,17 @@ function starttest(){
|
|||
is(SpecialPowers.DOMWindowUtils.getClassName(window), "Proxy");
|
||||
is(SpecialPowers.DOMWindowUtils.docCharsetIsForced, false);
|
||||
|
||||
//Run the createSystemXHR method
|
||||
var xhr = SpecialPowers.createSystemXHR();
|
||||
ok(xhr, "createSystemXHR should not return null");
|
||||
is(xhr.readyState, XMLHttpRequest.UNSENT, "createSystemXHR should create an unsent XMLHttpRequest object");
|
||||
|
||||
//try to run garbage collection
|
||||
SpecialPowers.gc();
|
||||
|
||||
SimpleTest.info("\nProfile::SpecialPowersRunTime: " + (new Date() - startTime) + "\n");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
//starttest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<head>
|
||||
<title>Test for SpecialPowers extension</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -0,0 +1,167 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Profiling test suite for EventUtils</title>
|
||||
<script type="text/javascript">
|
||||
var start = new Date();
|
||||
</script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript">
|
||||
var loadTime = new Date();
|
||||
</script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body onload="starttest()">
|
||||
<input type="radio" id="radioTarget1" name="group">Radio Target 1</input>
|
||||
<input id="textBoxA">
|
||||
<input id="textBoxB">
|
||||
<input id="testMouseEvent" type="button" value="click">
|
||||
<input id="testKeyEvent" >
|
||||
<input id="testStrEvent" >
|
||||
<div id="scrollB" style="width: 190px;height: 250px;overflow:auto">
|
||||
<p>blah blah blah blah</p>
|
||||
<p>blah blah blah blah</p>
|
||||
<p>blah blah blah blah</p>
|
||||
<p>blah blah blah blah</p>
|
||||
<p>blah blah blah blah</p>
|
||||
<p>blah blah blah blah</p>
|
||||
<p>blah blah blah blah</p>
|
||||
<p>blah blah blah blah</p>
|
||||
</div>
|
||||
<script class="testbody" type="text/javascript">
|
||||
SimpleTest.info("\nProfile::EventUtilsLoadTime: " + (loadTime - start) + "\n");
|
||||
function starttest() {
|
||||
SimpleTest.waitForFocus(
|
||||
function () {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var startTime = new Date();
|
||||
var check = false;
|
||||
|
||||
/* test send* functions */
|
||||
$("testMouseEvent").addEventListener("click", function() { check=true; }, false);
|
||||
sendMouseEvent({type:'click'}, "testMouseEvent");
|
||||
is(check, true, 'sendMouseEvent should dispatch click event');
|
||||
|
||||
check = false;
|
||||
$("testKeyEvent").addEventListener("keypress", function() { check = true; }, false);
|
||||
$("testKeyEvent").focus();
|
||||
sendChar("x", "testKeyEvent");
|
||||
is($("testKeyEvent").value, "x", "sendChar should work");
|
||||
is(check, true, "sendChar should dispatch keyPress");
|
||||
$("testKeyEvent").value = "";
|
||||
|
||||
sendString("string", "testStrEvent");
|
||||
is($("testStrEvent").value, "string", "sendString should work");
|
||||
$("testStrEvent").value = "";
|
||||
|
||||
check = false;
|
||||
sendKey("DOWN", "testKeyEvent");
|
||||
is(check, true, "sendKey should dispatch keyPress");
|
||||
|
||||
/* test synthesizeMouse* */
|
||||
//focus trick enables us to run this in iframes
|
||||
$("radioTarget1").addEventListener('focus', function (aEvent) {
|
||||
$("radioTarget1").removeEventListener('focus', arguments.callee, false);
|
||||
synthesizeMouse($("radioTarget1"), 1, 1, {});
|
||||
is($("radioTarget1").checked, true, "synthesizeMouse should work")
|
||||
$("radioTarget1").checked = false;
|
||||
disableNonTestMouseEvents(true);
|
||||
synthesizeMouse($("radioTarget1"), 1, 1, {});
|
||||
is($("radioTarget1").checked, true, "synthesizeMouse should still work with non-test mouse events disabled");
|
||||
$("radioTarget1").checked = false;
|
||||
disableNonTestMouseEvents(false);
|
||||
});
|
||||
$("radioTarget1").focus();
|
||||
|
||||
//focus trick enables us to run this in iframes
|
||||
$("textBoxA").addEventListener("focus", function (aEvent) {
|
||||
$("textBoxA").removeEventListener("focus", arguments.callee, false);
|
||||
check = false;
|
||||
$("textBoxA").addEventListener("click", function() { check = true; }, false);
|
||||
synthesizeMouseAtCenter($("textBoxA"), {});
|
||||
is(check, true, 'synthesizeMouse should dispatch mouse event');
|
||||
|
||||
check = false;
|
||||
synthesizeMouseExpectEvent($("textBoxA"), 1, 1, {}, $("textBoxA"), "click", "synthesizeMouseExpectEvent should fire click event");
|
||||
is(check, true, 'synthesizeMouse should dispatch mouse event');
|
||||
});
|
||||
$("textBoxA").focus();
|
||||
|
||||
/**
|
||||
* TODO: testing synthesizeMouseScroll requires a setTimeout
|
||||
* since there is delay between the scroll event and a check, so for now just test
|
||||
* that we can successfully call it to avoid having setTimeout vary the runtime metric.
|
||||
* Testing of this method is currently done here:
|
||||
* toolkit/content/tests/chrome/test_mousescroll.xul
|
||||
*/
|
||||
synthesizeMouseScroll($("scrollB"), 5, 5, {'delta': 10, 'type': "DOMMouseScroll"});
|
||||
|
||||
/* test synthesizeKey* */
|
||||
check = false;
|
||||
$("testKeyEvent").addEventListener("keypress", function() { check = true; }, false);
|
||||
$("testKeyEvent").focus();
|
||||
synthesizeKey("a", {});
|
||||
is($("testKeyEvent").value, "a", "synthesizeKey should work");
|
||||
is(check, true, "synthesizeKey should dispatch keyPress");
|
||||
$("testKeyEvent").value = "";
|
||||
|
||||
check = false;
|
||||
synthesizeKeyExpectEvent("a", {}, $("testKeyEvent"), "keypress");
|
||||
is($("testKeyEvent").value, "a", "synthesizeKey should work");
|
||||
is(check, true, "synthesizeKey should dispatch keyPress");
|
||||
$("testKeyEvent").value = "";
|
||||
|
||||
/* test synthesizeComposition */
|
||||
check = false;
|
||||
window.addEventListener("compositionstart", function() { check = true; }, false);
|
||||
synthesizeComposition(true);
|
||||
is(check, true, 'synthesizeComposition(true) should dispatch compositionstart');
|
||||
|
||||
check = false;
|
||||
window.addEventListener("compositionend", function() { check = true; }, false);
|
||||
synthesizeComposition();
|
||||
is(check, true, 'synthesizeComposition() should dispatch compositionend');
|
||||
check = false;
|
||||
|
||||
$("textBoxB").focus();
|
||||
const nsIDOMWindowUtils = Components.interfaces.nsIDOMWindowUtils;
|
||||
synthesizeText(
|
||||
{ "composition":
|
||||
{ "string": "a",
|
||||
"clauses":
|
||||
[
|
||||
{ "length": 1, "attr": nsIDOMWindowUtils.COMPOSITION_ATTR_RAWINPUT }
|
||||
]
|
||||
},
|
||||
"caret": { "start": 1, "length": 0 }
|
||||
}
|
||||
);
|
||||
is(check, false, "synthesizeText shouldn't start or end composition");
|
||||
is($("textBoxB").value, "a", "synthesizeText should send text");
|
||||
var querySelectedText = synthesizeQuerySelectedText();
|
||||
ok(querySelectedText, "query selected text event result is null");
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); //get permission to check members of querySelectedText
|
||||
ok(querySelectedText.succeeded, "query selected text event failed");
|
||||
is(querySelectedText.offset, 1,
|
||||
"query selected text event returns wrong offset");
|
||||
is(querySelectedText.text, "",
|
||||
"query selected text event returns wrong selected text");
|
||||
$("textBoxB").value = "";
|
||||
|
||||
querySelectedText = synthesizeQuerySelectedText();
|
||||
ok(querySelectedText, "query selected text event result is null");
|
||||
ok(querySelectedText.succeeded, "query selected text event failed");
|
||||
is(querySelectedText.offset, 0,
|
||||
"query selected text event returns wrong offset");
|
||||
is(querySelectedText.text, "",
|
||||
"query selected text event returns wrong selected text");
|
||||
var endTime = new Date();
|
||||
SimpleTest.info("\nProfile::EventUtilsRunTime: " + (endTime-startTime) + "\n");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
);
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Profiling test suite for PluginUtils</title>
|
||||
<script type="text/javascript">
|
||||
var start = new Date();
|
||||
</script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/PluginUtils.js"></script>
|
||||
<script type="text/javascript">
|
||||
var loadTime = new Date();
|
||||
</script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body onload="starttest()">
|
||||
<!-- load the test plugin defined at $(DIST)/bin/plugins/Test.plugin/ -->
|
||||
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
|
||||
<script class="testbody" type="text/javascript">
|
||||
SimpleTest.info("\nProfile::PluginUtilsLoadTime: " + (loadTime - start) + "\n");
|
||||
function starttest() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var startTime = new Date();
|
||||
//increase the runtime of the test so it is detectible, otherwise we get 0-1ms
|
||||
runtimes = 100;
|
||||
function runTest(plugin) {
|
||||
is(plugin.version, "1.0.0.0", "Make sure version is correct");
|
||||
is(plugin.name, "Test Plug-in");
|
||||
};
|
||||
while (runtimes > 0) {
|
||||
ok(PluginUtils.withTestPlugin(runTest), "Test plugin should be found");
|
||||
--runtimes;
|
||||
}
|
||||
var endTime = new Date();
|
||||
SimpleTest.info("\nProfile::PluginUtilsRunTime: " + (endTime-startTime) + "\n");
|
||||
SimpleTest.finish();
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,97 @@
|
|||
<!--This test should be updated each time new functionality is added to SimpleTest-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Profiling test suite for SimpleTest</title>
|
||||
<script type="text/javascript">
|
||||
var start = new Date();
|
||||
</script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript">
|
||||
var loadTime = new Date();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<input id="textB"/>
|
||||
<script class="testbody" type="text/javascript">
|
||||
SimpleTest.info("Profile::SimpleTestLoadTime: " + (loadTime - start));
|
||||
var startTime = new Date();
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function starttest() {
|
||||
SimpleTest.waitForFocus(
|
||||
function() {
|
||||
//test log
|
||||
SimpleTest.info("Logging some info")
|
||||
|
||||
//basic usage
|
||||
ok(true, "test ok", "This should be true");
|
||||
is(0, 0, "is() test failed");
|
||||
isnot(0, 1, "isnot() test failed");
|
||||
|
||||
//todo tests
|
||||
todo(false, "test todo", "todo() test should not pass");
|
||||
todo_is(false, true, "test todo_is");
|
||||
todo_isnot(true, true, "test todo_isnot");
|
||||
|
||||
//misc
|
||||
is(typeof(SimpleTest.testPluginIsOOP()), "boolean", 'testPluginIsOOP should be bool');
|
||||
SimpleTest.requestLongerTimeout(1);
|
||||
|
||||
//note: this test may alter runtimes as it waits
|
||||
var check = false;
|
||||
$('textB').focus();
|
||||
SimpleTest.waitForClipboard("a",
|
||||
function () {
|
||||
Components.classes["@mozilla.org/widget/clipboardhelper;1"]
|
||||
.getService(Components.interfaces.nsIClipboardHelper)
|
||||
.copyString("a");
|
||||
},
|
||||
function () {
|
||||
check = true;
|
||||
},
|
||||
function () {
|
||||
check = false;
|
||||
}
|
||||
);
|
||||
is(check, true, "waitForClipboard should work");
|
||||
|
||||
//use helper functions
|
||||
var div1 = createEl('div', {'id': 'somediv', 'display': 'block'}, "I am a div");
|
||||
document.body.appendChild(div1);
|
||||
var divObj = this.getElement('somediv');
|
||||
is(divObj, div1, 'createEl did not create element as expected');
|
||||
is($('somediv'), divObj, '$ helper did not get element as expected');
|
||||
is(computedStyle(divObj, 'display'), 'block', 'computedStyle did not get right display value');
|
||||
document.body.removeChild(div1);
|
||||
|
||||
//use waitForFocus
|
||||
//note: this also adds a short wait period
|
||||
SimpleTest.executeSoon(
|
||||
function () {
|
||||
//finish() calls a slew of SimpleTest functions
|
||||
SimpleTest.finish();
|
||||
//call this after finish so we can make sure it works and doesn't hang our process
|
||||
SimpleTest.expectUncaughtException();
|
||||
throw "i am an uncaught exception"
|
||||
/**
|
||||
* Actually testing a crash of a child process ended up with wildly variable runtimes,
|
||||
* on the scale of >1 second, so just make sure we can safely call the method
|
||||
*/
|
||||
SimpleTest.expectChildProcessCrash();
|
||||
var endTime = new Date();
|
||||
SimpleTest.info("Profile::SimpleTestRunTime: " + (endTime-startTime));
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
//use addLoadEvent
|
||||
addLoadEvent(
|
||||
function() {
|
||||
starttest();
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Profiling test suite for WindowSnapshot</title>
|
||||
<script type="text/javascript">
|
||||
var start = new Date();
|
||||
</script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||
<script type="text/javascript">
|
||||
var loadTime = new Date();
|
||||
</script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body onload="starttest()">
|
||||
<script class="testbody" type="text/javascript">
|
||||
SimpleTest.info("\nProfile::WindowSnapshotLoadTime: " + (loadTime - start) + "\n");
|
||||
function starttest() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var startTime = new Date();
|
||||
var snap = snapshotWindow(window, false);
|
||||
var snap2 = snapshotWindow(window, false);
|
||||
is(compareSnapshots(snap, snap2, true)[0], true, "this should be true");
|
||||
var div1 = createEl('div', {'id': 'somediv', 'display': 'block'}, "I am a div");
|
||||
document.body.appendChild(div1);
|
||||
snap2 = snapshotWindow(window, false);
|
||||
is(compareSnapshots(snap, snap2, true)[0], false, "this should be false");
|
||||
document.body.removeChild(div1);
|
||||
var endTime = new Date();
|
||||
SimpleTest.info("\nProfile::WindowSnapshotRunTime: " + (endTime-startTime) + "\n");
|
||||
SimpleTest.finish();
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче