testing/mochitest/tests/Harness_sanity/test_sanity.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/testing/mochitest/tests/Harness_sanity/test_sanity.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test for mochitest harness sanity</title>
     1.8 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    1.10 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.11 +</head>
    1.12 +<body>
    1.13 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
    1.14 +<p id="display">
    1.15 +  <input id="testKeyEvent1" onkeypress="press1 = true">
    1.16 +  <input id="testKeyEvent2" onkeydown="return false;" onkeypress="press2 = true">
    1.17 +  <input id="testKeyEvent3" onkeypress="press3 = true">
    1.18 +  <input id="testKeyEvent4" onkeydown="return false;" onkeypress="press4 = true">
    1.19 +</p
    1.20 +<div id="content" style="display: none">
    1.21 +  
    1.22 +</div>
    1.23 +<pre id="test">
    1.24 +<script class="testbody" type="text/javascript">
    1.25 +
    1.26 +/** Test for sanity  **/
    1.27 +ok(true, "true must be ok");
    1.28 +is(1, true, "1 must be true");
    1.29 +isnot(1, false, "1 must not be false");
    1.30 +is(0, false, "0 must be false");
    1.31 +isnot(0, true, "0 must not be true");
    1.32 +is("", 0, "Empty string must be 0");
    1.33 +is("1", 1, "Numeric string must be equal the number");
    1.34 +isnot("", null, "Empty string must not be null");
    1.35 +
    1.36 +var press1 = false;
    1.37 +$("testKeyEvent1").focus();
    1.38 +synthesizeKey("x", {});
    1.39 +is($("testKeyEvent1").value, "x", "synthesizeKey should work");
    1.40 +is(press1, true, "synthesizeKey should dispatch keyPress");
    1.41 +
    1.42 +var press2 = false;
    1.43 +$("testKeyEvent2").focus();
    1.44 +synthesizeKey("x", {});
    1.45 +is($("testKeyEvent2").value, "", "synthesizeKey should respect keydown preventDefault");
    1.46 +is(press2, false, "synthesizeKey should not dispatch keyPress with default prevented");
    1.47 +
    1.48 +var press3 = false;
    1.49 +$("testKeyEvent3").focus();
    1.50 +sendChar("x")
    1.51 +is($("testKeyEvent3").value, "x", "sendChar should work");
    1.52 +is(press3, true, "sendChar should dispatch keyPress");
    1.53 +
    1.54 +var press4 = false;
    1.55 +$("testKeyEvent4").focus();
    1.56 +sendChar("x")
    1.57 +is($("testKeyEvent4").value, "", "sendChar should respect keydown preventDefault");
    1.58 +is(press4, false, "sendChar should not dispatch keyPress with default prevented");
    1.59 +
    1.60 +
    1.61 +</script>
    1.62 +</pre>
    1.63 +</body>
    1.64 +</html>
    1.65 +

mercurial