Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added closed property to window

  • Loading branch information...
commit 186b7081240ae5f4a18739f9689849ec9f223d53 1 parent d46910a
@jeromegn jeromegn authored
Showing with 14 additions and 0 deletions.
  1. +6 −0 lib/zombie/windows.coffee
  2. +8 −0 test/browser_test.coffee
View
6 lib/zombie/windows.coffee
@@ -90,6 +90,9 @@ class Windows
index = @_stack.indexOf(window)
return unless index >= 0
+ # Set `window`'s `closed` property to `true`
+ window.closed = true
+
delete @_named[window.name]
@_stack.splice(index, 1)
# If we closed the currently open window, switch to the previous window.
@@ -142,6 +145,9 @@ class Windows
set: (title)->
@document.title = title
+ # `window`s have a `closed` property defaulting to `false`
+ window.closed = false
+
# javaEnabled, present in browsers, not in spec Used by Google Analytics see
# https://developer.mozilla.org/en/DOM/window.navigator.javaEnabled
Object.defineProperties window.navigator,
View
8 test/browser_test.coffee
@@ -424,6 +424,9 @@ describe "Browser", ->
it "should set window name", ->
assert.equal window.name, "popup"
+ it "should set window closed to false", ->
+ assert.equal window.closed, false
+
it "should load page", ->
assert.equal window.document.querySelector("h1").textContent, "Popup window"
@@ -471,7 +474,9 @@ describe "Browser", ->
describe "and close it", ->
+ closed_window = null
before ->
+ closed_window = browser.window
browser.window.close()
it "should lose that window", ->
@@ -479,6 +484,9 @@ describe "Browser", ->
assert.equal browser.windows.get(0).name, "nodejs"
assert !browser.windows.get(1)
+ it "should set the `closed` property to `true`", ->
+ assert.equal closed_window.closed, true
+
it "should switch to last window", ->
assert.equal browser.window, browser.windows.get(0)
Please sign in to comment.
Something went wrong with that request. Please try again.