content/html/document/test/test_bug332848.xhtml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/html/document/test/test_bug332848.xhtml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,86 @@
     1.4 +<html xmlns="http://www.w3.org/1999/xhtml">
     1.5 +<!--
     1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=332848
     1.7 +-->
     1.8 +<head>
     1.9 +  <title>Test for Bug 332848</title>
    1.10 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
    1.11 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.12 +</head>
    1.13 +<body>
    1.14 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=332848">Mozilla Bug 332848</a>
    1.15 +<p id="display"></p>
    1.16 +<div id="content" style="display: none">
    1.17 +  
    1.18 +</div>
    1.19 +<pre id="test">
    1.20 +<script class="testbody" type="text/javascript">
    1.21 +<![CDATA[
    1.22 +
    1.23 +/** Test for Bug 332848 **/
    1.24 +
    1.25 +// parseChecker will become true if we keep parsing after calling close().
    1.26 +var parseChecker = false;
    1.27 +
    1.28 +function test() {
    1.29 +  try {
    1.30 +    document.open();
    1.31 +    is(0, 1, "document.open succeeded");
    1.32 +  } catch (e) {
    1.33 +    is (e.name, "InvalidStateError",
    1.34 +        "Wrong exception from document.open");
    1.35 +    is (e.code, DOMException.INVALID_STATE_ERR,
    1.36 +        "Wrong exception from document.open");
    1.37 +  }
    1.38 +
    1.39 +  try {
    1.40 +    document.write("aaa");
    1.41 +    is(0, 1, "document.write succeeded");
    1.42 +  } catch (e) {
    1.43 +    is (e.name, "InvalidStateError",
    1.44 +        "Wrong exception from document.write");
    1.45 +    is (e.code, DOMException.INVALID_STATE_ERR,
    1.46 +        "Wrong exception from document.write");
    1.47 +  }
    1.48 +
    1.49 +  try {
    1.50 +    document.writeln("aaa");
    1.51 +    is(0, 1, "document.write succeeded");
    1.52 +  } catch (e) {
    1.53 +    is (e.name, "InvalidStateError",
    1.54 +        "Wrong exception from document.write");
    1.55 +    is (e.code, DOMException.INVALID_STATE_ERR,
    1.56 +        "Wrong exception from document.write");
    1.57 +  }
    1.58 +
    1.59 +  try {
    1.60 +    document.close();
    1.61 +    is(0, 1, "document.close succeeded");
    1.62 +  } catch (e) {
    1.63 +    is (e.name, "InvalidStateError",
    1.64 +        "Wrong exception from document.close");
    1.65 +    is (e.code, DOMException.INVALID_STATE_ERR,
    1.66 +        "Wrong exception from document.close");
    1.67 +  }
    1.68 +}
    1.69 +
    1.70 +function loadTest() {
    1.71 +  is(parseChecker, true, "Parsing stopped");
    1.72 +  test();
    1.73 +  SimpleTest.finish();
    1.74 +}
    1.75 +
    1.76 +window.onload = loadTest;
    1.77 +
    1.78 +SimpleTest.waitForExplicitFinish();
    1.79 +
    1.80 +test();
    1.81 +]]>
    1.82 +</script>
    1.83 +<script>
    1.84 +    parseChecker = true;
    1.85 +</script>
    1.86 +</pre>
    1.87 +</body>
    1.88 +</html>
    1.89 +

mercurial