Skip to content

Commit 294a1ec

Browse files
committed
iframe and textarea fix
1 parent 6cfc5fa commit 294a1ec

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

grunt.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,10 @@ module.exports = function(grunt) {
9595
var done = this.async();
9696

9797
var data = grunt.config('generate_expected');
98+
var args = [data.phantom, data.index, data.dest];
99+
console.log(args);
98100

99-
grunt.utils.spawn({cmd: 'phantomjs', args: [
100-
data.phantom,
101-
data.index,
102-
data.dest
103-
]}, function(error, result) {
101+
grunt.utils.spawn({cmd: 'phantomjs', args: args}, function(error, result) {
104102
if(error) {
105103
console.error(result.stderr);
106104
}

htmlParser/htmlParser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
var detect = {
5959
comment: /^<!--/,
6060
endTag: /^<\//,
61-
atomicTag: /^<\s*(script|style|noscript)[\s>]/i,
61+
atomicTag: /^<\s*(script|style|noscript|iframe|textarea)[\s>]/i,
6262
startTag: /^</,
6363
chars: /^[^<]/
6464
};

test/helpers.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ var ignoreScripts = (function() {
2727

2828
var innerHtml = function(el) {
2929
//return el.innerHTML.replace(/(\r\n)?<script[^>]*>[\s\S]*?<\/script>(\r\n)?/ig, '');
30-
var html = el.innerHTML.replace(/\.js\?0\.\d+/g, '.js');
30+
var html = el.innerHTML
31+
.replace(/\.js\?0\.\d+/g, '.js')
32+
.replace(/(<iframe[^>]*>)[\s\S]*?(<\/iframe>)/ig, '$1$2');
3133
return ignoreScripts ?
3234
// remove all scripts (IE7/8, FF)
3335
// IE7/8 because we pass expected html through the innerHTML of a div, scripts don't appear

test/test.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,14 @@ $(document).ready(function(){
360360
ctx.write('>there</div>Continue </i>outside<b>please</b>');
361361
});
362362

363+
testWrite('iframe with script content', function(ctx) {
364+
ctx.writeInline('document.write("<iframe><script><\\/script></iframe>")');
365+
});
366+
367+
testWrite('textarea with script content', function(ctx) {
368+
ctx.writeInline('document.write("<textarea><script><\\/script></textarea>")');
369+
});
370+
363371
test('naked remote write', function() {
364372
var div = document.createElement('div');
365373
div.id = "naked-remote-write";
@@ -433,7 +441,8 @@ $(document).ready(function(){
433441

434442
testError('remote script 404', "<script src='http://cdn.krxd.net/not_found'></script>");
435443

436-
testError('remote script exception', "<script src='remote/error.js'></script>");
444+
// TODO: This doesn't work in phantomJS "generate_expected"
445+
//testError('remote script exception', "<script src='remote/error.js'></script>");
437446

438447
}
439448

0 commit comments

Comments
 (0)