Skip to content

Commit

Permalink
Add windowName option.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvine committed Mar 16, 2012
1 parent df80931 commit cf2a5b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/API.md
Expand Up @@ -41,6 +41,7 @@ You can use the following options:
- `silent` -- If true, supress all `console.log` output from scripts. You can still view it with `window.console.output`.
- `site` -- Base URL for all requests. If set, you can call `visit` with relative URL.
- `waitFor` -- Tells `wait` function how long to wait (in milliseconds) while timers fire. Defaults to 0.5 seconds.
- `windowName` -- Sets the browser's window.name property; useful when an evaluated script tries to detect whether/where the window is embedded as an iframe. Defaults to "nodejs".

Credential options look like this:

Expand Down
6 changes: 5 additions & 1 deletion lib/zombie/browser.coffee
Expand Up @@ -20,7 +20,7 @@ WebSocket = require("./websocket")

HTML = JSDom.dom.level3.html
MOUSE_EVENT_NAMES = ["mousedown", "mousemove", "mouseup"]
BROWSER_OPTIONS = ["credentials", "debug", "htmlParser", "loadCSS", "referer", "runScripts", "silent", "site", "userAgent", "waitFor"]
BROWSER_OPTIONS = ["credentials", "debug", "htmlParser", "loadCSS", "referer", "runScripts", "silent", "site", "userAgent", "waitFor", "windowName"]


PACKAGE = JSON.parse(require("fs").readFileSync(__dirname + "/../../package.json"))
Expand Down Expand Up @@ -94,6 +94,9 @@ class Browser extends EventEmitter
# Tells `wait` and any function that uses `wait` how long to wait for, executing timers. Defaults to 0.5 seconds.
@waitFor = 500

# You can set the browser window.name property
@windowName = "nodejs"

# Sets the browser options.
for name in BROWSER_OPTIONS
value = options[name]
Expand Down Expand Up @@ -171,6 +174,7 @@ class Browser extends EventEmitter
newWindow.navigator.javaEnabled = ->
return false
newWindow.navigator.userAgent = @userAgent
newWindow.name = @windowName

@_cookies.extend newWindow
@_storages.extend newWindow
Expand Down

0 comments on commit cf2a5b8

Please sign in to comment.