Skip to content

Commit

Permalink
Integrated loc.replace issues noted at http://code.google.com/p/respo…
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Stankus Jr committed May 18, 2008
1 parent 8ed4e51 commit 939e6ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/parent_selector_assertion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module SelectorAssertions
def assert_select_parent(*args, &block)
wrapper_re_str = Regexp.escape("with(window.parent) { setTimeout(function() { window.eval('") +
"(.*)" +
Regexp.escape("'); loc.replace('about:blank'); }, 1) }")
Regexp.escape("'); window.loc && loc.replace('about:blank'); }, 1) }")
match = @response.body.match(Regexp.new(wrapper_re_str))

if match
Expand Down Expand Up @@ -64,7 +64,7 @@ module SelectorAssertions
def assert_select_parent(*args, &block)
wrapper_re_str = Regexp.escape("with(window.parent) { setTimeout(function() { window.eval('") +
"(.*)" +
Regexp.escape("'); loc.replace('about:blank'); }, 1) }")
Regexp.escape("'); window.loc && loc.replace('about:blank'); }, 1) }")
match = @response.body.match(Regexp.new(wrapper_re_str))

if match
Expand Down Expand Up @@ -112,7 +112,7 @@ module SelectorAssertions
def assert_select_parent(*args, &block)
wrapper_re_str = Regexp.escape("with(window.parent) { setTimeout(function() { window.eval('") +
"(.*)" +
Regexp.escape("'); loc.replace('about:blank'); }, 1) }")
Regexp.escape("'); window.loc && loc.replace('about:blank'); }, 1) }")
match = @response.body.match(Regexp.new(wrapper_re_str))

if match
Expand Down
2 changes: 1 addition & 1 deletion lib/responds_to_parent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def responds_to_parent(&block)
# window.eval - legal eval for Opera
render :text => "<html><body><script type='text/javascript' charset='utf-8'>
var loc = document.location;
with(window.parent) { setTimeout(function() { window.eval('#{script}'); loc.replace('about:blank'); }, 1) }
with(window.parent) { setTimeout(function() { window.eval('#{script}'); window.loc && loc.replace('about:blank'); }, 1) }
</script></body></html>"
end
end
Expand Down

0 comments on commit 939e6ba

Please sign in to comment.