Bug 1371010 - Test to make sure that serializeToString does not percent-encode href attributes. r?jgraham
MozReview-Commit-ID: 2gGhaEXIltr
--- a/testing/web-platform/tests/domparsing/xml-serialization.xhtml
+++ b/testing/web-platform/tests/domparsing/xml-serialization.xhtml
@@ -63,16 +63,28 @@ test(function() {
}, "DocumentType: 'QUOTATION MARK' (U+0022)");
test(function() {
var dt = document.implementation.createDocumentType("html", '"\'', '\'"');
assert_equals(serialize(dt), '<!DOCTYPE html PUBLIC ""\'" "\'"">');
}, "DocumentType: 'APOSTROPHE' (U+0027) and 'QUOTATION MARK' (U+0022)");
test(function() {
+ var el = document.createElement("a");
+ el.setAttribute("href", "\u3042\u3044\u3046 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
+ assert_equals(serialize(el), "<a xmlns=\"http://www.w3.org/1999/xhtml\" href=\"\u3042\u3044\u3046 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\"></a>");
+}, "Element: href attributes are not percent-encoded");
+
+test(function() {
+ var el = document.createElement("a");
+ el.setAttribute("href", "?\u3042\u3044\u3046 !\"$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
+ assert_equals(serialize(el), "<a xmlns=\"http://www.w3.org/1999/xhtml\" href=\"?\u3042\u3044\u3046 !"$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\"></a>");
+}, "Element: query parts in href attributes are not percent-encoded");
+
+test(function() {
var pi = document.createProcessingInstruction("a", "");
assert_equals(serialize(pi), "<?a ?>");
}, "ProcessingInstruction: empty data");
test(function() {
var pi = document.createProcessingInstruction("a", "b");
assert_equals(serialize(pi), "<?a b?>");
}, "ProcessingInstruction: non-empty data");