Permalink
Browse files

iframe and textarea fix

  • Loading branch information...
1 parent 6cfc5fa commit 294a1ecf5e5f48a7a94f51ea45c37bf04f143473 @dbrans dbrans committed Mar 17, 2013
Showing with 17 additions and 8 deletions.
  1. +3 −5 grunt.js
  2. +1 −1 htmlParser/htmlParser.js
  3. +3 −1 test/helpers.js
  4. +10 −1 test/test.js
View
@@ -95,12 +95,10 @@ module.exports = function(grunt) {
var done = this.async();
var data = grunt.config('generate_expected');
+ var args = [data.phantom, data.index, data.dest];
+ console.log(args);
- grunt.utils.spawn({cmd: 'phantomjs', args: [
- data.phantom,
- data.index,
- data.dest
- ]}, function(error, result) {
+ grunt.utils.spawn({cmd: 'phantomjs', args: args}, function(error, result) {
if(error) {
console.error(result.stderr);
}
View
@@ -58,7 +58,7 @@
var detect = {
comment: /^<!--/,
endTag: /^<\//,
- atomicTag: /^<\s*(script|style|noscript)[\s>]/i,
+ atomicTag: /^<\s*(script|style|noscript|iframe|textarea)[\s>]/i,
startTag: /^</,
chars: /^[^<]/
};
View
@@ -27,7 +27,9 @@ var ignoreScripts = (function() {
var innerHtml = function(el) {
//return el.innerHTML.replace(/(\r\n)?<script[^>]*>[\s\S]*?<\/script>(\r\n)?/ig, '');
- var html = el.innerHTML.replace(/\.js\?0\.\d+/g, '.js');
+ var html = el.innerHTML
+ .replace(/\.js\?0\.\d+/g, '.js')
+ .replace(/(<iframe[^>]*>)[\s\S]*?(<\/iframe>)/ig, '$1$2');
return ignoreScripts ?
// remove all scripts (IE7/8, FF)
// IE7/8 because we pass expected html through the innerHTML of a div, scripts don't appear
View
@@ -360,6 +360,14 @@ $(document).ready(function(){
ctx.write('>there</div>Continue </i>outside<b>please</b>');
});
+ testWrite('iframe with script content', function(ctx) {
+ ctx.writeInline('document.write("<iframe><script><\\/script></iframe>")');
+ });
+
+ testWrite('textarea with script content', function(ctx) {
+ ctx.writeInline('document.write("<textarea><script><\\/script></textarea>")');
+ });
+
test('naked remote write', function() {
var div = document.createElement('div');
div.id = "naked-remote-write";
@@ -433,7 +441,8 @@ $(document).ready(function(){
testError('remote script 404', "<script src='http://cdn.krxd.net/not_found'></script>");
- testError('remote script exception', "<script src='remote/error.js'></script>");
+ // TODO: This doesn't work in phantomJS "generate_expected"
+ //testError('remote script exception', "<script src='remote/error.js'></script>");
}

0 comments on commit 294a1ec

Please sign in to comment.