Skip to content

Commit

Permalink
Change-Id: Ib186eed471374bdc492c351c32563ad5d234be00
Browse files Browse the repository at this point in the history
  • Loading branch information
jindw committed Jun 10, 2012
1 parent b6fd947 commit f98cfea
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xmldom",
"version": "0.1.9",
"version": "0.1.10",
"description": "A W3C Standard based DOMParser and XMLSerializer (DOM Level2 CORE). ",
"keywords": [
"javascript",
Expand Down
16 changes: 15 additions & 1 deletion test/html/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ wows.describe('html normalizer').addBatch({
console.assert(dom == '<div>\u00a0\u00a9&amp;nbsp&amp;copy</div>',dom+'')


var dom = new DOMParser().parseFromString('<html xmlns:x="1"><body/></html>','text/html');
console.assert(dom == '<html xmlns:x="1"><body></body></html>',dom+'')
},
'attr': function () {
var dom = new DOMParser().parseFromString('<div test="alert(\'<br/>\')"/>','text/html');
var dom = new DOMParser().parseFromString('<html test="a<b && a>b && \'&amp;&&\'"/>','text/html');
console.assert(dom == '<html test="a&lt;b &amp;&amp; a>b &amp;&amp; \'&amp;&amp;&amp;\'"></html>',dom+'')

var dom = new DOMParser().parseFromString('<div test="alert(\'<br/>\')"/>','text/html');
console.assert(dom == '<div test="alert(\'&lt;br/>\')"></div>',dom+'')
var dom = new DOMParser().parseFromString('<div test="a<b&&a< c && a>d"></div>','text/html');
console.assert(dom == '<div test="a&lt;b&amp;&amp;a&lt; c &amp;&amp; a>d"></div>',dom+'')
Expand Down Expand Up @@ -55,11 +60,20 @@ wows.describe('html normalizer').addBatch({
'script': function () {
var dom = new DOMParser().parseFromString('<script>alert(a<b&&c?"<br>":">>");</script>','text/html');
console.assert(dom == '<script>alert(a<b&&c?"<br>":">>");</script>',dom+'')

var dom = new DOMParser().parseFromString('<script>alert(a<b&&c?"<br>":">>");</script>','text/xml');
console.assert(dom == '<script>alert(a&lt;b&amp;&amp;c?"<br/>":">>");</script>',dom+'')

var dom = new DOMParser().parseFromString('<script>alert(a<b&&c?"<br/>":">>");</script>','text/html');
console.assert(dom == '<script>alert(a<b&&c?"<br/>":">>");</script>',dom+'')

},
'textarea': function () {
var dom = new DOMParser().parseFromString('<textarea>alert(a<b&&c?"<br>":">>");</textarea>','text/html');
console.assert(dom == '<textarea>alert(a&lt;b&amp;&amp;c?"&lt;br>":">>");</textarea>',dom+'')


var dom = new DOMParser().parseFromString('<textarea>alert(a<b&&c?"<br>":">>");</textarea>','text/xml');
console.assert(dom == '<textarea>alert(a&lt;b&amp;&amp;c?"<br/>":">>");</textarea>',dom+'')
}
}).run();
26 changes: 0 additions & 26 deletions test/html/parse.js

This file was deleted.

3 changes: 2 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ function check(data,doc){
DOMParser.prototype.parseFromString = function(data,mimeType){
var doc = oldParser.apply(this,arguments);
if(!/\/x?html?\b/.test(mimeType)){
try{
check(data,doc);
}catch(e){console.dir(e)}
}
return doc;
}
Expand All @@ -42,6 +44,5 @@ require('./dom');
require('./parse-element');
require('./node');
require('./namespace');
require('./html/parse');
require('./html/normalize');
//require('./big-file-performance');

0 comments on commit f98cfea

Please sign in to comment.