tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug255820.html (2778B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=255820
      5 -->
      6 <head>
      7  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      8  <title>Test for Bug 255820</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>        
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     11 </head>
     12 <body>
     13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=255820">Mozilla Bug 255820</a>
     14 <p id="display">
     15  <iframe id="f1"></iframe>
     16  <iframe id="f2"></iframe>
     17  <iframe id="f3"></iframe>
     18 </p>
     19 <div id="content" style="display: none">
     20  
     21 </div>
     22 <pre id="test">
     23 <script class="testbody" type="text/javascript">
     24 
     25 /** Test for Bug 255820 */
     26 SimpleTest.waitForExplicitFinish();
     27 
     28 is(document.characterSet, "UTF-8",
     29   "Unexpected character set for our document");
     30 
     31 var testsLeft = 3;
     32 
     33 function testFinished() {
     34  --testsLeft;
     35  if (testsLeft == 0) {
     36    SimpleTest.finish();
     37  }
     38 }
     39 
     40 function charsetTestFinished(id, doc, charsetTarget) {
     41  is(doc.characterSet, charsetTarget, "Unexpected charset for subframe " + id);
     42  testFinished();
     43 }
     44 
     45 function f3Continue() {
     46  var doc = $("f3").contentDocument;
     47  is(doc.defaultView.getComputedStyle(doc.body).color, "rgb(0, 180, 0)",
     48     "Wrong color");
     49  charsetTestFinished('f3', doc, "UTF-8");
     50 }
     51 
     52 function runTest() {
     53  var doc = $("f1").contentDocument;
     54  is(doc.characterSet, "UTF-8",
     55     "Unexpected initial character set for first frame");
     56  doc.open();
     57  doc.write('<html></html>');
     58  doc.close();
     59  charsetTestFinished("f1", doc, "UTF-8");
     60 
     61  doc = $("f2").contentDocument;
     62  is(doc.characterSet, "UTF-8",
     63     "Unexpected initial character set for second frame");
     64  doc.open();
     65  var str = '<html><head>';
     66  str += '<script src="data:application/javascript,"><'+'/script>';
     67  str += '<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">';
     68  str += '</head><body>';
     69  str += '</body></html>';
     70  doc.write(str);
     71  doc.close();
     72  is(doc.characterSet, "UTF-8",
     73     "Unexpected character set for second frame after write");
     74  $("f2").
     75    setAttribute("onload",
     76      "charsetTestFinished('f2', this.contentDocument, 'UTF-8');");
     77 
     78  doc = $("f3").contentDocument;
     79  is(doc.characterSet, "UTF-8",
     80     "Unexpected initial character set for third frame");
     81  doc.open();
     82  var str = '<html><head>';
     83  str += '<style>body { color: rgb(255, 0, 0) }</style>';
     84  str += '<link type="text/css" rel="stylesheet" href="data:text/css, body { color: rgb(0, 180, 0) }">';
     85  str += '</head><body>';
     86  str += '</body></html>';
     87  doc.write(str);
     88  doc.close();
     89  is(doc.characterSet, "UTF-8",
     90     "Unexpected character set for third frame after write");
     91  $("f3").setAttribute("onload", "f3Continue()");
     92 }
     93 
     94 addLoadEvent(runTest);
     95 </script>
     96 </pre>
     97 </body>
     98 </html>