diff --git a/CHANGELOG.md b/CHANGELOG.md index e0d207aa..d56d6344 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ### diff --git a/lib/capybara/poltergeist/client/agent.coffee b/lib/capybara/poltergeist/client/agent.coffee index 50313080..df0fa48d 100644 --- a/lib/capybara/poltergeist/client/agent.coffee +++ b/lib/capybara/poltergeist/client/agent.coffee @@ -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]) diff --git a/lib/capybara/poltergeist/client/compiled/agent.js b/lib/capybara/poltergeist/client/compiled/agent.js index bcbf8494..0d7036ea 100644 --- a/lib/capybara/poltergeist/client/compiled/agent.js +++ b/lib/capybara/poltergeist/client/compiled/agent.js @@ -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 }; }; diff --git a/spec/integration/driver_spec.rb b/spec/integration/driver_spec.rb index bc21dc29..4f60bd55 100644 --- a/spec/integration/driver_spec.rb +++ b/spec/integration/driver_spec.rb @@ -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') diff --git a/spec/support/views/fixed_positioning.erb b/spec/support/views/fixed_positioning.erb new file mode 100644 index 00000000..11f0c5f6 --- /dev/null +++ b/spec/support/views/fixed_positioning.erb @@ -0,0 +1,6 @@ + + +
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+
+