Skip to content

Commit

Permalink
enabled window.Image to accept height and width attributes [assaf#35]
Browse files Browse the repository at this point in the history
  • Loading branch information
boblail committed Feb 26, 2011
1 parent 22bffc3 commit 144aa40
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 4 additions & 3 deletions spec/script-spec.coffee
Expand Up @@ -207,9 +207,10 @@ vows.describe("Scripts").addBatch(
"should evaluate in context and return value": (title)-> assert.equal title, "The Living"

"new Image":
topic: ->
browser = new zombie.Browser()
"should construct an img tag": (browser)-> assert.equal domToHtml(browser.evaluate("new Image")), "<img>\r\n"
zombie.wants "http://localhost:3003/script/living"
"should construct an img tag": (browser)-> assert.equal domToHtml(browser.evaluate("new Image")), "<img>\r\n"
"should construct an img tag with width and height": (browser)->
assert.equal domToHtml(browser.evaluate("new Image(1, 1)")), "<img width=\"1\" height=\"1\">\r\n"

###
"SSL":
Expand Down
7 changes: 6 additions & 1 deletion src/zombie/browser.coffee
Expand Up @@ -127,7 +127,12 @@ class Browser extends require("events").EventEmitter
ws.extend newWindow
newWindow.screen = new Screen()
newWindow.JSON = JSON
newWindow.Image = core.HTMLImageElement
newWindow.Image = (width, height)->
img = new core.HTMLImageElement(newWindow.document)
img.width = width
img.height = height
img

# Default onerror handler.
newWindow.onerror = (event)=> @emit "error", event.error || new Error("Error loading script")

Expand Down

0 comments on commit 144aa40

Please sign in to comment.