gecko/testing/mochitest/tests/Harness_sanity/test_sanityEventUtils.html
Joel Maher a46890e4bd Bug 971025 - move testing/mochitest/test/test_* to testing/mochitest/test/Harness_sanity. r=ted
--HG--
rename : testing/mochitest/tests/SpecialPowersLoadChromeScript.js => testing/mochitest/tests/Harness_sanity/SpecialPowersLoadChromeScript.js
rename : testing/mochitest/tests/file_SpecialPowersFrame1.html => testing/mochitest/tests/Harness_sanity/file_SpecialPowersFrame1.html
rename : testing/mochitest/tests/test_SimpleTestGetTestFileURL.html => testing/mochitest/tests/Harness_sanity/test_SimpleTestGetTestFileURL.html
rename : testing/mochitest/tests/test_SpecialPowersExtension.html => testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html
rename : testing/mochitest/tests/test_SpecialPowersExtension2.html => testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension2.html
rename : testing/mochitest/tests/test_SpecialPowersLoadChromeScript.html => testing/mochitest/tests/Harness_sanity/test_SpecialPowersLoadChromeScript.html
rename : testing/mochitest/tests/test_SpecialPowersPushPermissions.html => testing/mochitest/tests/Harness_sanity/test_SpecialPowersPushPermissions.html
rename : testing/mochitest/tests/test_SpecialPowersPushPrefEnv.html => testing/mochitest/tests/Harness_sanity/test_SpecialPowersPushPrefEnv.html
rename : testing/mochitest/tests/test_bug362788.xhtml => testing/mochitest/tests/Harness_sanity/test_bug362788.xhtml
rename : testing/mochitest/tests/test_bug816847.html => testing/mochitest/tests/Harness_sanity/test_bug816847.html
rename : testing/mochitest/tests/test_sanity.html => testing/mochitest/tests/Harness_sanity/test_sanity.html
rename : testing/mochitest/tests/test_sanityEventUtils.html => testing/mochitest/tests/Harness_sanity/test_sanityEventUtils.html
rename : testing/mochitest/tests/test_sanityException.html => testing/mochitest/tests/Harness_sanity/test_sanityException.html
rename : testing/mochitest/tests/test_sanityException2.html => testing/mochitest/tests/Harness_sanity/test_sanityException2.html
rename : testing/mochitest/tests/test_sanitySimpletest.html => testing/mochitest/tests/Harness_sanity/test_sanitySimpletest.html
rename : testing/mochitest/tests/test_sanityWindowSnapshot.html => testing/mochitest/tests/Harness_sanity/test_sanityWindowSnapshot.html
rename : testing/mochitest/tests/test_sanity_cleanup.html => testing/mochitest/tests/Harness_sanity/test_sanity_cleanup.html
rename : testing/mochitest/tests/test_sanity_cleanup2.html => testing/mochitest/tests/Harness_sanity/test_sanity_cleanup2.html
2014-03-05 10:32:02 -05:00

186 lines
7.2 KiB
HTML

<!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">
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");
is($("testKeyEvent").value, "x", "sendChar should work");
is(check, true, "sendChar should dispatch keyPress");
$("testKeyEvent").value = "";
$("testStrEvent").focus();
sendString("string");
is($("testStrEvent").value, "string", "sendString should work");
$("testStrEvent").value = "";
check = false;
$("testKeyEvent").focus();
sendKey("DOWN");
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 synthesizeWheel 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
*/
synthesizeWheel($("scrollB"), 5, 5, {'deltaY': 10.0, deltaMode: WheelEvent.DOM_DELTA_LINE});
/* 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 */
$("textBoxB").focus();
check = false;
window.addEventListener("compositionstart", function() { check = true; }, false);
synthesizeComposition({ type: "compositionstart" });
is(check, true, 'synthesizeComposition() should dispatch compositionstart');
check = false;
window.addEventListener("compositionupdate", function() { check = true; }, false);
synthesizeComposition({ type: "compositionupdate", data: "a" });
is(check, true, 'synthesizeComposition() should dispatch compositionupdate');
check = false;
window.addEventListener("text", function() { check = true; }, false);
synthesizeText(
{ "composition":
{ "string": "a",
"clauses":
[
{ "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
]
},
"caret": { "start": 1, "length": 0 }
}
);
is(check, true, "synthesizeText should dispatch text event");
synthesizeText(
{ "composition":
{ "string": "a",
"clauses":
[
{ "length": 0, "attr": 0 }
]
},
"caret": { "start": 1, "length": 0 }
}
);
check = false;
window.addEventListener("compositionend", function() { check = true; }, false);
synthesizeComposition({ type: "compositionend", data: "a" });
is(check, true, 'synthesizeComposition() should dispatch compositionend');
var querySelectedText = synthesizeQuerySelectedText();
ok(querySelectedText, "query selected text event result is null");
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();
info("\nProfile::EventUtilsRunTime: " + (endTime-startTime) + "\n");
SimpleTest.finish();
}
);
};
</script>
</body>
</html>