var wows = require('vows'); var assert = require('assert'); var DOMParser = require('xmldom').DOMParser; var XMLSerializer = require('xmldom').XMLSerializer; var parser = new DOMParser(); // Create a Test Suite wows.describe('html normalizer').addBatch({ 'text & <': function () { var dom = new DOMParser().parseFromString('
&<123&456<789;&&
','text/html'); console.assert(dom == '
&<123&456<789;&&
',dom+'') var dom = new DOMParser().parseFromString('
<123e>&
','text/html'); console.assert(dom == '
<123e>&<a
',dom+'') var dom = new DOMParser().parseFromString('
 © ©
','text/html'); console.assert(dom == '
\u00a0\u00a9&nbsp&copy
',dom+'') var dom = new DOMParser().parseFromString('','text/html'); console.assert(dom == '',dom+'') }, 'attr': function () { var dom = new DOMParser().parseFromString('','text/html'); console.assert(dom == '',dom+'') var dom = new DOMParser().parseFromString('
','text/html'); console.assert(dom == '
',dom+'') var dom = new DOMParser().parseFromString('
','text/html'); console.assert(dom == '
',dom+'') var dom = new DOMParser().parseFromString('
','text/html'); console.assert(dom == '
',dom+'') var dom = new DOMParser().parseFromString('
','text/html'); console.assert(dom == '
',dom+'') }, 'attrQute': function () { var dom = new DOMParser().parseFromString('','text/html'); console.assert(dom == '',dom+'') // var dom = new DOMParser().parseFromString('',dom+'!!') // var dom = new DOMParser().parseFromString('','text/html'); console.assert(dom == '',dom+'') }, "unclosed":function(){ var dom = new DOMParser().parseFromString('

','text/html'); console.assert(dom == '

',dom+'') var dom = new DOMParser().parseFromString('','text/html'); console.assert(dom == '',dom+'') var dom = new DOMParser().parseFromString('','text/html'); console.assert(dom == '',dom+'') var dom = new DOMParser().parseFromString('','text/html'); console.assert(dom == '',dom+'') var dom = new DOMParser().parseFromString('','text/html'); console.assert(dom == '',dom+'') var dom = new DOMParser().parseFromString('

','text/html'); console.assert(dom == '

',dom+'') }, 'script': function () { var dom = new DOMParser().parseFromString('','text/html'); console.assert(dom == '',dom+'') var dom = new DOMParser().parseFromString('','text/xml'); console.assert(dom == '',dom+'') var dom = new DOMParser().parseFromString('','text/html'); console.assert(dom == '',dom+'') }, 'textarea': function () { var dom = new DOMParser().parseFromString('','text/html'); console.assert(dom == '',dom+'') var dom = new DOMParser().parseFromString('','text/xml'); console.assert(dom == '',dom+'') } }).run();