Created
June 12, 2012 17:40
-
-
Save nym/2918959 to your computer and use it in GitHub Desktop.
Script tag not loading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsdom = require('jsdom'); | |
jsdom.defaultDocumentFeatures = { | |
FetchExternalResources : ['script'], | |
ProcessExternalResources : ['script'], | |
MutationEvents : '2.0', | |
QuerySelector : false | |
}; | |
var htmlDoc = '<html lang="en-US">' + | |
'head>' + | |
'<title>Test document</title>' + | |
'<script>' + | |
'var testVar = "foo";' + | |
'</script>' + | |
'<script src=\'http://code.jquery.com/jquery-latest.js\'></script>' + | |
'<script>' + | |
'</script>' + | |
'</head>' + | |
'<body id="mainPage">' + | |
'<script type="text/javascript">document.body.innerHTML = "WOO";</script></body>' + | |
'</html>'; | |
var document = jsdom.jsdom(htmlDoc); | |
var window = document.createWindow(); | |
var elementsArray = window.document.getElementsByTagName('script'); | |
console.log("Elements Arr:", elementsArray.length); | |
console.log("Window.testVar:", window.testVar); | |
console.log("Window.testVar:", document.body.innerHTML); | |
window.addEventListener('load', function () { | |
console.log("Jquery:", typeof window.$ == 'function'); | |
window.close(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment