Skip to content

Commit

Permalink
[Closes assaf#137] Implemented window.resizeBy/resizeTo.
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf committed May 28, 2012
1 parent 2251e7b commit b574601
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Allow `browser.select` to use the option text.

`JSON.parse` now respects `Array.prototype`.

Implemented `window.resizeBy` and `window.resizeTo`.


## Version 1.1.7 2012-05-27

Expand Down
6 changes: 6 additions & 0 deletions lib/zombie/windows.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ class Windows
return img
window.console = new Console(@_browser.silent)

window.resizeTo = (width, height)->
window.outerWidth = window.innerWidth = width
window.outerHeight = window.innerHeight = height
window.resizeBy = (width, height)->
window.resizeTo window.outerWidth + width, window.outerHeight + height

# Help iframes talking with each other
window.postMessage = (data, targetOrigin)=>
document = window.document
Expand Down
10 changes: 10 additions & 0 deletions test/window_test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,13 @@ describe "Window", ->
it "should fire when document is done loading", ->
assert.equal browser.text("body"), "1 clicks here"


describe "resize", ->
it "should change window dimensions", ->
browser = new Browser()
assert.equal browser.window.innerWidth, 1024
assert.equal browser.window.innerHeight, 768
browser.window.resizeBy(-224, -168)
assert.equal browser.window.innerWidth, 800
assert.equal browser.window.innerHeight, 600

0 comments on commit b574601

Please sign in to comment.