Permalink
Browse files

Merge pull request #57 from djanowski/zombie

---

Simple stub.
  • Loading branch information...
2 parents 6d30813 + 573e1b1 commit 2f636db729a338ef28b3817d5c9121297bbee77d @assaf assaf committed Jan 26, 2011
Showing with 43 additions and 4 deletions.
  1. +26 −1 spec/browser-spec.coffee
  2. +17 −3 src/zombie/browser.coffee
View
@@ -108,6 +108,17 @@ brains.get "/prompt", (req, res)-> res.send """
</script>
"""
+brains.get "/screen", (req, res)-> res.send """
+ <script>
+ var props = [];
+
+ for (key in window.screen) {
+ props.push(key + "=" + window.screen[key]);
+ }
+
+ document.title = props.join(", ");
+ </script>
+ """
vows.describe("Browser").addBatch(
"open page":
@@ -287,5 +298,19 @@ vows.describe("Browser").addBatch(
assert.ok browser.prompted("gender")
assert.ok browser.prompted("location")
assert.ok !browser.prompted("not asked")
-
+
+ "window.screen":
+ zombie.wants "http://localhost:3003/screen"
+ "should have a screen object available": (browser)->
+ assert.match browser.document.title, /width=1280/
+ assert.match browser.document.title, /height=800/
+ assert.match browser.document.title, /left=0/
+ assert.match browser.document.title, /top=0/
+ assert.match browser.document.title, /availLeft=0/
+ assert.match browser.document.title, /availTop=0/
+ assert.match browser.document.title, /availWidth=1280/
+ assert.match browser.document.title, /availHeight=800/
+ assert.match browser.document.title, /colorDepth=24/
+ assert.match browser.document.title, /pixelDepth=24/
+
).export(module)
View
@@ -86,16 +86,14 @@ class Browser extends require("events").EventEmitter
history.extend window
interact.extend window
xhr.extend window
+ window.screen = new Screen()
window.JSON = JSON
# Default onerror handler.
window.onerror = (event)=> @emit "error", event.error || new Error("Error loading script")
# TODO: Fix
window.Image = ->
return window
- # Always start with an open window.
- @open()
-
# Events
@@ -725,6 +723,22 @@ class Browser extends require("events").EventEmitter
else
console.log "No document" unless @document
+ class Screen
+ constructor: ->
+ @width = 1280
+ @height = 800
+ @left = 0
+ @top = 0
+
+ @__defineGetter__ "availLeft", -> 0
+ @__defineGetter__ "availTop", -> 0
+ @__defineGetter__ "availWidth", -> @width
+ @__defineGetter__ "availHeight", -> @height
+ @__defineGetter__ "colorDepth", -> 24
+ @__defineGetter__ "pixelDepth", -> 24
+
+ # Always start with an open window.
+ @open()
exports.Browser = Browser

0 comments on commit 2f636db

Please sign in to comment.