Skip to content

Instantly share code, notes, and snippets.

@merryprankster
Created January 12, 2011 08:55
Show Gist options
  • Save merryprankster/775898 to your computer and use it in GitHub Desktop.
Save merryprankster/775898 to your computer and use it in GitHub Desktop.
A simple server which outputs HTML containing script-tag having structure similar to Wicket's IHeaderResponse.renderOnLoadJavascript().
//
// CLIENT
//
var zombie = require("zombie");
zombie.visit("http://localhost:8080", function(err, browser) { });
//
// EXAMPLE SERVER
//
var http = require("http");
http.createServer(function(res, res) {
res.writeHead(200, {"Content-Type":"text/html"});
res.end("<!DOCTYPE html> \
<html> \
<head> \
<title>Test</title> \
<script type=\"text/javascript\" ><!--/*--><![CDATA[/*><!--*/ alert(\"Wicket stuff would be here\"); /*-->]]>*/</script> \
</head> \
<body> \
</body> \
</html>");
}).listen(8080,"127.0.0.1");
@merryprankster
Copy link
Author

Run server, run client, client barfs:

..

 threw error 

{ message: [Getter/Setter]
, stack: [Getter/Setter]
, type: 'unexpected_token'
, arguments: [ '<' ]
}

..

@aredridel
Copy link

Just so you know, using javascript comments instead of # would be awesome for running this out of a clone of the gist.

@merryprankster
Copy link
Author

Thanks for the tip!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment