1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_bug401662.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=401662 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 401662</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=401662">Mozilla Bug 401662</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"> 1.18 + <iframe id="testframe" 1.19 + src="data:text/html,<html><body>foo<style>bar</style></body></html>"> 1.20 + </iframe> 1.21 +</div> 1.22 +<pre id="test"> 1.23 +<script class="testbody" type="text/javascript"> 1.24 + 1.25 +/** Test for Bug 401662 - don't serialize style elements in body into 1.26 + plaintext**/ 1.27 +SimpleTest.waitForExplicitFinish(); 1.28 + 1.29 +window.onload = function() { 1.30 + const Cc = SpecialPowers.Cc; 1.31 + const Ci = SpecialPowers.Ci; 1.32 + 1.33 + var encoder = Cc["@mozilla.org/layout/documentEncoder;1?type=text/html"] 1.34 + .createInstance(Ci.nsIDocumentEncoder); 1.35 + 1.36 + var doc = $("testframe").contentDocument; 1.37 + 1.38 + encoder.init(doc, "text/plain", encoder.OutputBodyOnly); 1.39 + encoder.setCharset("UTF-8"); 1.40 + 1.41 + var out = encoder.encodeToString(); 1.42 + 1.43 + is(out, "foo", "style content serialized in plaintext?"); 1.44 + 1.45 + SimpleTest.finish(); 1.46 +} 1.47 +</script> 1.48 +</pre> 1.49 +</body> 1.50 +</html> 1.51 +