|
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 type="text/javascript" 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 = 4; |
|
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 f2Continue() { |
|
46 // Commented out pending discussion at the WHATWG |
|
47 // $("f2"). |
|
48 // setAttribute("onload", |
|
49 // "charsetTestFinished('f2 reloaded', this.contentDocument, 'us-ascii');"); |
|
50 $("f2"). |
|
51 setAttribute("onload", |
|
52 "testFinished();"); |
|
53 $("f2").contentWindow.location.reload(); |
|
54 } |
|
55 |
|
56 function f3Continue() { |
|
57 var doc = $("f3").contentDocument; |
|
58 is(doc.defaultView.getComputedStyle(doc.body, "").color, "rgb(0, 180, 0)", |
|
59 "Wrong color before reload"); |
|
60 $("f3"). |
|
61 setAttribute("onload", |
|
62 'var doc = this.contentDocument; ' + |
|
63 'is(doc.defaultView.getComputedStyle(doc.body, "").color, ' + |
|
64 ' "rgb(0, 180, 0)",' + |
|
65 ' "Wrong color after reload");' + |
|
66 "charsetTestFinished('f1', this.contentDocument, 'UTF-8')"); |
|
67 $("f3").contentWindow.location.reload(); |
|
68 } |
|
69 |
|
70 function runTest() { |
|
71 var doc = $("f1").contentDocument; |
|
72 is(doc.characterSet, "UTF-8", |
|
73 "Unexpected initial character set for first frame"); |
|
74 doc.open(); |
|
75 doc.write('<html></html>'); |
|
76 doc.close(); |
|
77 is(doc.characterSet, "UTF-8", |
|
78 "Unexpected character set for first frame after write"); |
|
79 $("f1"). |
|
80 setAttribute("onload", |
|
81 "charsetTestFinished('f1', this.contentDocument, 'UTF-8')"); |
|
82 $("f1").contentWindow.location.reload(); |
|
83 |
|
84 doc = $("f2").contentDocument; |
|
85 is(doc.characterSet, "UTF-8", |
|
86 "Unexpected initial character set for second frame"); |
|
87 doc.open(); |
|
88 var str = '<html><head>'; |
|
89 str += '<script src="data:application/javascript,"><'+'/script>'; |
|
90 str += '<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">'; |
|
91 str += '</head><body>'; |
|
92 str += '</body></html>'; |
|
93 doc.write(str); |
|
94 doc.close(); |
|
95 is(doc.characterSet, "UTF-8", |
|
96 "Unexpected character set for second frame after write"); |
|
97 $("f2"). |
|
98 setAttribute("onload", |
|
99 "charsetTestFinished('f2', this.contentDocument, 'UTF-8');" + |
|
100 "f2Continue()"); |
|
101 |
|
102 doc = $("f3").contentDocument; |
|
103 is(doc.characterSet, "UTF-8", |
|
104 "Unexpected initial character set for first frame"); |
|
105 doc.open(); |
|
106 var str = '<html><head>'; |
|
107 str += '<style>body { color: rgb(255, 0, 0) }</style>'; |
|
108 str += '<link type="text/css" rel="stylesheet" href="data:text/css, body { color: rgb(0, 180, 0) }">'; |
|
109 str += '</head><body>'; |
|
110 str += '</body></html>'; |
|
111 doc.write(str); |
|
112 doc.close(); |
|
113 is(doc.characterSet, "UTF-8", |
|
114 "Unexpected character set for first frame after write"); |
|
115 $("f3").setAttribute("onload", "f3Continue()"); |
|
116 } |
|
117 |
|
118 addLoadEvent(runTest); |
|
119 </script> |
|
120 </pre> |
|
121 </body> |
|
122 </html> |
|
123 |