From 6ba899e52c45c81b6ebd3f2795dae5a27822515b Mon Sep 17 00:00:00 2001 From: Matenia Rossides Date: Tue, 5 Apr 2016 10:49:36 +1000 Subject: [PATCH 1/2] Use http endpoint for jquery as https doesn't run the callback --- lib/screencap/raster.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/screencap/raster.js b/lib/screencap/raster.js index 884abe3..b72ef71 100644 --- a/lib/screencap/raster.js +++ b/lib/screencap/raster.js @@ -102,8 +102,10 @@ function takeScreenshot() { } else { delayScreenshotForResources(); + // https won't run the callbacks, so we're going to use http for now + // until we see whether it's an issue page.includeJs( - "https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js", + "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js", function() { var foundDiv = true; From 1eef6f4159b0a83272e56037c4232c3a6931367b Mon Sep 17 00:00:00 2001 From: Matenia Rossides Date: Sat, 9 Apr 2016 09:35:56 +1000 Subject: [PATCH 2/2] lock phantomjs version + fix specs --- screencap.gemspec | 2 +- spec/fetcher_spec.rb | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/screencap.gemspec b/screencap.gemspec index 39cba0a..cf8c687 100644 --- a/screencap.gemspec +++ b/screencap.gemspec @@ -19,5 +19,5 @@ Gem::Specification.new do |gem| gem.add_development_dependency 'rake' gem.add_development_dependency 'phantomjs.rb' gem.add_development_dependency 'fastimage' - gem.add_runtime_dependency 'phantomjs' + gem.add_runtime_dependency 'phantomjs', '1.9.8.0' end diff --git a/spec/fetcher_spec.rb b/spec/fetcher_spec.rb index 05f8c2c..6d9f7ad 100644 --- a/spec/fetcher_spec.rb +++ b/spec/fetcher_spec.rb @@ -6,28 +6,28 @@ end it 'supports a custom filename' do - screenshot = Screencap::Fetcher.new('http://yahoo.com').fetch(:output => TMP_DIRECTORY + 'custom_filename.png') + screenshot = Screencap::Fetcher.new('http://rubyonrails.org/').fetch(output: TMP_DIRECTORY + 'custom_filename.png') File.exists?(screenshot).should == true end it 'supports a custom width' do - screenshot = Screencap::Fetcher.new('http://google.com').fetch(:output => TMP_DIRECTORY + 'custom_width.jpg', :width => 800) + screenshot = Screencap::Fetcher.new('http://google.com').fetch(output: TMP_DIRECTORY + 'custom_width.jpg', width: 800) FastImage.size(screenshot)[0].should == 800 end it 'supports a custom height' do # note using stackoverflow.com as google.com implements x-frame-options header meaning that it won't load in the object element - screenshot = Screencap::Fetcher.new('http://stackoverflow.com').fetch(:output => TMP_DIRECTORY + 'custom_height.jpg', :height => 600) + screenshot = Screencap::Fetcher.new('http://stackoverflow.com').fetch(output: TMP_DIRECTORY + 'custom_height.jpg', height: 600) FastImage.size(screenshot)[1].should == 600 end it 'captures a given element' do - screenshot = Screencap::Fetcher.new('http://placehold.it').fetch(:output => TMP_DIRECTORY + 'given_element.jpg', :div => 'img.image') - FastImage.size(screenshot)[0].should == 140 + screenshot = Screencap::Fetcher.new('http://placehold.it').fetch(output: TMP_DIRECTORY + 'given_element.jpg', div: '#content-left') + FastImage.size(screenshot)[0].should == 400 end it 'should work when given a query string with ampersand in it' do - screenshot = Screencap::Fetcher.new('http://google.com?1=2&3=4').fetch(:output => TMP_DIRECTORY + 'ampersand.jpg', :width => 800) + screenshot = Screencap::Fetcher.new('http://google.com?1=2&3=4').fetch(output: TMP_DIRECTORY + 'ampersand.jpg', width: 800) FastImage.size(screenshot)[0].should == 800 end -end \ No newline at end of file +end