Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use http location for jQuery #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/screencap/raster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion screencap.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 7 additions & 7 deletions spec/fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
end