Skip to content

Commit

Permalink
Merge pull request teampoltergeist#452 from kevinmcconnell/render-ful…
Browse files Browse the repository at this point in the history
…l-with-no-document-height

Render full window size if document has no height
  • Loading branch information
thedelchop committed Apr 29, 2014
2 parents 1f0c785 + 8e90854 commit 876a77c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
(Pedro Carriço and Erik Ostrom) [Issue #432]
* Raise exception on PhantomJS "status: fail" result (i.e DNS issue) instead
of returning minimal HTML body (Dean Holdren) [Issue #473]
* Render full window size when document has no height (Kevin McConnell)

### 1.5.0 ###

Expand Down
4 changes: 2 additions & 2 deletions lib/capybara/poltergeist/client/agent.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class PoltergeistAgent
@elements.length - 1

documentSize: ->
height: document.documentElement.scrollHeight,
width: document.documentElement.scrollWidth
height: document.documentElement.scrollHeight || document.documentElement.clientHeight,
width: document.documentElement.scrollWidth || document.documentElement.clientWidth

get: (id) ->
@nodes[id] or= new PoltergeistAgent.Node(this, @elements[id])
Expand Down
4 changes: 2 additions & 2 deletions lib/capybara/poltergeist/client/compiled/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ PoltergeistAgent = (function() {

PoltergeistAgent.prototype.documentSize = function() {
return {
height: document.documentElement.scrollHeight,
width: document.documentElement.scrollWidth
height: document.documentElement.scrollHeight || document.documentElement.clientHeight,
width: document.documentElement.scrollWidth || document.documentElement.clientWidth
};
};

Expand Down
11 changes: 11 additions & 0 deletions spec/integration/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ def session_url(path)
end
end

it 'supports rendering the entire window when documentElement has no height' do
@session.visit('/poltergeist/fixed_positioning')

create_screenshot file, full: true
File.open(file, 'rb') do |f|
expect(ImageSize.new(f.read).size).to eq(
@driver.evaluate_script('[window.innerWidth, window.innerHeight]')
)
end
end

it 'supports rendering just the selected element' do
@session.visit('/poltergeist/long_page')

Expand Down
6 changes: 6 additions & 0 deletions spec/support/views/fixed_positioning.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<body style="margin: 0; padding: 0;">
<div style="position: fixed">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</body>

0 comments on commit 876a77c

Please sign in to comment.