content/html/document/test/test_bug255820.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/html/document/test/test_bug255820.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,123 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=255820
     1.8 +-->
     1.9 +<head>
    1.10 +  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    1.11 +  <title>Test for Bug 255820</title>
    1.12 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=255820">Mozilla Bug 255820</a>
    1.17 +<p id="display">
    1.18 +  <iframe id="f1"></iframe>
    1.19 +  <iframe id="f2"></iframe>
    1.20 +  <iframe id="f3"></iframe>
    1.21 +</p>
    1.22 +<div id="content" style="display: none">
    1.23 +  
    1.24 +</div>
    1.25 +<pre id="test">
    1.26 +<script class="testbody" type="text/javascript">
    1.27 +
    1.28 +/** Test for Bug 255820 **/
    1.29 +SimpleTest.waitForExplicitFinish();
    1.30 +
    1.31 +is(document.characterSet, "UTF-8",
    1.32 +   "Unexpected character set for our document");
    1.33 +
    1.34 +var testsLeft = 4;
    1.35 +
    1.36 +function testFinished() {
    1.37 +  --testsLeft;
    1.38 +  if (testsLeft == 0) {
    1.39 +    SimpleTest.finish();
    1.40 +  }
    1.41 +}
    1.42 +
    1.43 +function charsetTestFinished(id, doc, charsetTarget) {
    1.44 +  is(doc.characterSet, charsetTarget, "Unexpected charset for subframe " + id);
    1.45 +  testFinished();
    1.46 +}
    1.47 +
    1.48 +function f2Continue() {
    1.49 +//   Commented out pending discussion at the WHATWG
    1.50 +//   $("f2").
    1.51 +//     setAttribute("onload",
    1.52 +//                  "charsetTestFinished('f2 reloaded', this.contentDocument, 'us-ascii');");
    1.53 +  $("f2").
    1.54 +    setAttribute("onload",
    1.55 +                 "testFinished();");
    1.56 +  $("f2").contentWindow.location.reload();
    1.57 +}
    1.58 +
    1.59 +function f3Continue() {
    1.60 +  var doc = $("f3").contentDocument;
    1.61 +  is(doc.defaultView.getComputedStyle(doc.body, "").color, "rgb(0, 180, 0)",
    1.62 +     "Wrong color before reload");
    1.63 +  $("f3").
    1.64 +    setAttribute("onload",
    1.65 +                 'var doc = this.contentDocument; ' + 
    1.66 +                 'is(doc.defaultView.getComputedStyle(doc.body, "").color, ' +
    1.67 +                 '   "rgb(0, 180, 0)",' +
    1.68 +                 '   "Wrong color after reload");' +
    1.69 +                 "charsetTestFinished('f1', this.contentDocument, 'UTF-8')");
    1.70 +  $("f3").contentWindow.location.reload();
    1.71 +}
    1.72 +
    1.73 +function runTest() {
    1.74 +  var doc = $("f1").contentDocument;
    1.75 +  is(doc.characterSet, "UTF-8",
    1.76 +     "Unexpected initial character set for first frame");
    1.77 +  doc.open();
    1.78 +  doc.write('<html></html>');
    1.79 +  doc.close();
    1.80 +  is(doc.characterSet, "UTF-8",
    1.81 +     "Unexpected character set for first frame after write");
    1.82 +  $("f1").
    1.83 +    setAttribute("onload",
    1.84 +                 "charsetTestFinished('f1', this.contentDocument, 'UTF-8')");
    1.85 +  $("f1").contentWindow.location.reload();
    1.86 +
    1.87 +  doc = $("f2").contentDocument;
    1.88 +  is(doc.characterSet, "UTF-8",
    1.89 +     "Unexpected initial character set for second frame");
    1.90 +  doc.open();
    1.91 +  var str = '<html><head>';
    1.92 +  str += '<script src="data:application/javascript,"><'+'/script>';
    1.93 +  str += '<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">';
    1.94 +  str += '</head><body>';
    1.95 +  str += '</body></html>';
    1.96 +  doc.write(str);
    1.97 +  doc.close();
    1.98 +  is(doc.characterSet, "UTF-8",
    1.99 +     "Unexpected character set for second frame after write");
   1.100 +  $("f2").
   1.101 +    setAttribute("onload",
   1.102 +      "charsetTestFinished('f2', this.contentDocument, 'UTF-8');" +
   1.103 +      "f2Continue()");
   1.104 +
   1.105 +  doc = $("f3").contentDocument;
   1.106 +  is(doc.characterSet, "UTF-8",
   1.107 +     "Unexpected initial character set for first frame");
   1.108 +  doc.open();
   1.109 +  var str = '<html><head>';
   1.110 +  str += '<style>body { color: rgb(255, 0, 0) }</style>';
   1.111 +  str += '<link type="text/css" rel="stylesheet" href="data:text/css, body { color: rgb(0, 180, 0) }">';
   1.112 +  str += '</head><body>';
   1.113 +  str += '</body></html>';
   1.114 +  doc.write(str);
   1.115 +  doc.close();
   1.116 +  is(doc.characterSet, "UTF-8",
   1.117 +     "Unexpected character set for first frame after write");
   1.118 +  $("f3").setAttribute("onload", "f3Continue()");
   1.119 +}
   1.120 +
   1.121 +addLoadEvent(runTest);
   1.122 +</script>
   1.123 +</pre>
   1.124 +</body>
   1.125 +</html>
   1.126 +

mercurial