xml-parse-serialize-roundtrip.html (1766B)
1 <!DOCTYPE html> 2 <link rel=author href="mailto:jarhar@chromium.org"> 3 <link rel=help href="https://issues.chromium.org/issues/327273585"> 4 <link rel=help href="https://issues.chromium.org/issues/41101979"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 8 <script> 9 function runTest(xmlString, testName) { 10 test(() => { 11 const xmlDoc = (new DOMParser()).parseFromString(xmlString, 'text/xml'); 12 const result = (new XMLSerializer()).serializeToString(xmlDoc); 13 assert_equals(result, xmlString); 14 }, `DOMParser and XMLSerializer should round trip with CDATA sections: ${testName}`); 15 } 16 17 runTest( 18 `<root><![CDATA[ 19 12345678901234567890123456789012345678901234567890123456789012345678901234567890 20 12345678901234567890123456789012345678901234567890123456789012345678901234567890 21 12345678901234567890123456789012345678901234567890123456789012345678901234567890 22 12345678901234567890123456789012345678901234567890123456789012345678901234567890 23 12345678901234567890123456789012345678901234567890123456789012345678901234567890 24 12345678901234567890123456789012345678901234567890123456789012345678901234567890 25 12345678901234567890123456789012345678901234567890123456789012345678901234567890 26 12345678901234567890123456789012345678901234567890123456789012345678901234567890 27 12345678901234567890123456789012345678901234567890123456789012345678901234567890 28 12345678901234567890123456789012345678901234567890123456789012345678901234567890 29 12345678901234567890123456789012345678901234567890123456789012345678901234567890 30 ]]></root>`, 31 'large CDATA'); 32 33 runTest( 34 '<root><htmlDefn><![CDATA[<div><![CDATA[ Just Rubbish Data $#$^#^$ ]]]]><![CDATA[></div><div></div>]]></htmlDefn></root>', 35 'multiple CDATAs'); 36 </script>