Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Commit

Permalink
Fixed JS execution bug that messes with require.js.
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf committed Jun 5, 2012
1 parent 4dc88f5 commit 9be9f79
Show file tree
Hide file tree
Showing 5 changed files with 2,034 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,8 @@ Fixed `a.href` to not break when missing `href` attribute.

Note that `browser.text` no longer preserves white space.

Fixed JS execution bug that messes with require.js.


## Version 1.2.0 2012-05-28

Expand Down
2 changes: 2 additions & 0 deletions lib/zombie/scripts.coffee
Expand Up @@ -46,6 +46,8 @@ addInlineScriptSupport = (document)->
document.addEventListener "DOMNodeInserted", (event)->
node = event.target # Node being inserted
return unless node.tagName == "SCRIPT"
# Let JSDOM deal with script tags with src attribute
return if node.src
# Process scripts in order.
HTML.resourceLoader.enqueue(node, ->
code = node.text
Expand Down
3 changes: 3 additions & 0 deletions test/helpers/brains.coffee
Expand Up @@ -25,6 +25,9 @@ brains.get "/jquery-:version.js", (req, res)->
version = req.params.version
File.readFile "#{__dirname}/../scripts/jquery-#{version}.js", (err, data)->
res.send data
brains.get "/scripts/*", (req, res)->
File.readFile "#{__dirname}/../scripts/#{req.params}", (err, data)->
res.send data


active = false
Expand Down
39 changes: 39 additions & 0 deletions test/requirejs_test.coffee
@@ -0,0 +1,39 @@
{ assert, brains, Browser } = require("./helpers")


describe "require.js", ->

before (done)->
brains.get "/requirejs", (req, res)->
res.send """
<html>
<head>
<script data-main="/requirejs/index" src="/scripts/require-js-2.0.1.js"></script>
</head>
<body>
</body>
</html>
"""
brains.get "/requirejs/index.js", (req, res)->
res.send """
require(["dependency"], function(dependency) {
dependency()
})
"""
brains.get "/requirejs/dependency.js", (req, res)->
res.send """
define(function() {
return function() {
document.title = "Dependency loaded";
}
})
"""
brains.ready done

before (done)->
@browser = new Browser()
@browser.visit "http://localhost:3003/requirejs", done

it "should load dependencies", ->
assert.equal @browser.document.title, "Dependency loaded"

0 comments on commit 9be9f79

Please sign in to comment.