• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1description('Test of normalize on an XML document with CDATA.');
2
3var parser = new DOMParser();
4var serializer = new XMLSerializer();
5
6var xmlChunk = parser.parseFromString(
7    '<foo>' +
8    'This is some text before the CDATA' +
9    '<![CDATA[This is some <bold>markup</bold> inside of a CDATA]]>' +
10    'This is some text after the CDATA' +
11    '</foo>',
12    'application/xml');
13
14debug('Before normalize');
15shouldBe('serializer.serializeToString(xmlChunk)', '"<foo>This is some text before the CDATA<![CDATA[This is some <bold>markup</bold> inside of a CDATA]]>This is some text after the CDATA</foo>"');
16shouldBe('xmlChunk.documentElement.childNodes.length', '3');
17xmlChunk.documentElement.normalize();
18debug('After normalize');
19shouldBe('serializer.serializeToString(xmlChunk)', '"<foo>This is some text before the CDATA<![CDATA[This is some <bold>markup</bold> inside of a CDATA]]>This is some text after the CDATA</foo>"');
20shouldBe('xmlChunk.documentElement.childNodes.length', '3');
21
22var successfullyParsed = true;
23