|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=401662 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 401662</title> |
|
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
10 </head> |
|
11 <body> |
|
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=401662">Mozilla Bug 401662</a> |
|
13 <p id="display"></p> |
|
14 <div id="content" style="display: none"> |
|
15 <iframe id="testframe" |
|
16 src="data:text/html,<html><body>foo<style>bar</style></body></html>"> |
|
17 </iframe> |
|
18 </div> |
|
19 <pre id="test"> |
|
20 <script class="testbody" type="text/javascript"> |
|
21 |
|
22 /** Test for Bug 401662 - don't serialize style elements in body into |
|
23 plaintext**/ |
|
24 SimpleTest.waitForExplicitFinish(); |
|
25 |
|
26 window.onload = function() { |
|
27 const Cc = SpecialPowers.Cc; |
|
28 const Ci = SpecialPowers.Ci; |
|
29 |
|
30 var encoder = Cc["@mozilla.org/layout/documentEncoder;1?type=text/html"] |
|
31 .createInstance(Ci.nsIDocumentEncoder); |
|
32 |
|
33 var doc = $("testframe").contentDocument; |
|
34 |
|
35 encoder.init(doc, "text/plain", encoder.OutputBodyOnly); |
|
36 encoder.setCharset("UTF-8"); |
|
37 |
|
38 var out = encoder.encodeToString(); |
|
39 |
|
40 is(out, "foo", "style content serialized in plaintext?"); |
|
41 |
|
42 SimpleTest.finish(); |
|
43 } |
|
44 </script> |
|
45 </pre> |
|
46 </body> |
|
47 </html> |
|
48 |