webkit_remote_unstable 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +8 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +59 -0
- data/LICENSE.txt +20 -0
- data/README.md +65 -0
- data/Rakefile +38 -0
- data/VERSION +1 -0
- data/lib/webkit_remote_unstable.rb +6 -0
- data/lib/webkit_remote_unstable/css.rb +65 -0
- data/lib/webkit_remote_unstable/css_events.rb +22 -0
- data/lib/webkit_remote_unstable/page.rb +63 -0
- data/test/fixtures/config.ru +25 -0
- data/test/fixtures/html/css.html +32 -0
- data/test/fixtures/html/page.html +9 -0
- data/test/helper.rb +50 -0
- data/test/webkit_remote_unstable/css_test.rb +65 -0
- data/test/webkit_remote_unstable/page_test.rb +35 -0
- metadata +260 -0
data/.travis.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.3
|
4
|
+
before_install:
|
5
|
+
- "sudo sh -c \"echo \\\"deb https://dl.google.com/linux/deb/ stable main\\\" >> /etc/apt/sources.list\""
|
6
|
+
- "sudo wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -"
|
7
|
+
- "sudo apt-get -qq update"
|
8
|
+
- "sudo apt-get -qq install google-chrome-stable"
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
gem 'webkit_remote', '>= 0.4.1'
|
3
|
+
|
4
|
+
group :development do
|
5
|
+
gem 'bundler', '>= 1.2.1'
|
6
|
+
gem 'debugger', '>= 1.2.1'
|
7
|
+
gem 'jeweler', '>= 1.8.4'
|
8
|
+
gem 'minitest', '>= 4.1.0'
|
9
|
+
gem 'puma', '>= 1.6.3'
|
10
|
+
gem 'rack', '>= 1.4.1'
|
11
|
+
gem 'rack-contrib', '>= 1.1.0'
|
12
|
+
gem 'rdoc', '>= 3.12'
|
13
|
+
gem 'ruby-prof', '>= 0.11.2'
|
14
|
+
gem 'simplecov', '>= 0.7.1'
|
15
|
+
gem 'yard', '>= 0.8.3'
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
columnize (0.3.6)
|
5
|
+
debugger (1.2.1)
|
6
|
+
columnize (>= 0.3.1)
|
7
|
+
debugger-linecache (~> 1.1.1)
|
8
|
+
debugger-ruby_core_source (~> 1.1.4)
|
9
|
+
debugger-linecache (1.1.2)
|
10
|
+
debugger-ruby_core_source (>= 1.1.1)
|
11
|
+
debugger-ruby_core_source (1.1.4)
|
12
|
+
eventmachine (1.0.0)
|
13
|
+
faye-websocket (0.4.6)
|
14
|
+
eventmachine (>= 0.12.0)
|
15
|
+
git (1.2.5)
|
16
|
+
jeweler (1.8.4)
|
17
|
+
bundler (~> 1.0)
|
18
|
+
git (>= 1.2.5)
|
19
|
+
rake
|
20
|
+
rdoc
|
21
|
+
json (1.7.5)
|
22
|
+
minitest (4.2.0)
|
23
|
+
multi_json (1.3.7)
|
24
|
+
posix-spawn (0.3.6)
|
25
|
+
puma (1.6.3)
|
26
|
+
rack (~> 1.2)
|
27
|
+
rack (1.4.1)
|
28
|
+
rack-contrib (1.1.0)
|
29
|
+
rack (>= 0.9.1)
|
30
|
+
rake (10.0.1)
|
31
|
+
rdoc (3.12)
|
32
|
+
json (~> 1.4)
|
33
|
+
ruby-prof (0.11.2)
|
34
|
+
simplecov (0.7.1)
|
35
|
+
multi_json (~> 1.0)
|
36
|
+
simplecov-html (~> 0.7.1)
|
37
|
+
simplecov-html (0.7.1)
|
38
|
+
webkit_remote (0.4.1)
|
39
|
+
eventmachine (>= 1.0.0)
|
40
|
+
faye-websocket (>= 0.4.6)
|
41
|
+
posix-spawn (>= 0.3.6)
|
42
|
+
yard (0.8.3)
|
43
|
+
|
44
|
+
PLATFORMS
|
45
|
+
ruby
|
46
|
+
|
47
|
+
DEPENDENCIES
|
48
|
+
bundler (>= 1.2.1)
|
49
|
+
debugger (>= 1.2.1)
|
50
|
+
jeweler (>= 1.8.4)
|
51
|
+
minitest (>= 4.1.0)
|
52
|
+
puma (>= 1.6.3)
|
53
|
+
rack (>= 1.4.1)
|
54
|
+
rack-contrib (>= 1.1.0)
|
55
|
+
rdoc (>= 3.12)
|
56
|
+
ruby-prof (>= 0.11.2)
|
57
|
+
simplecov (>= 0.7.1)
|
58
|
+
webkit_remote (>= 0.4.1)
|
59
|
+
yard (>= 0.8.3)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Victor Costan
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# webkit_remote_unstable
|
2
|
+
|
3
|
+
[webkit_remote](https://github.com/pwnall/webkit_remote) is a Ruby gem for
|
4
|
+
driving [Google Chrome](https://www.google.com/chrome/) and possibly other
|
5
|
+
WebKit-based browsers via the
|
6
|
+
[WebKit remote debugging protocol](https://www.webkit.org/blog/1875/announcing-remote-debugging-protocol-v1-0/).
|
7
|
+
|
8
|
+
This gem adds support for some of the unstable features in the WebKit remote
|
9
|
+
debugging protocol. To see all the unstable protocol features, search for
|
10
|
+
`"hidden": true` in the
|
11
|
+
[protocol schema](http://trac.webkit.org/browser/trunk/Source/WebCore/inspector/Inspector.json).
|
12
|
+
|
13
|
+
|
14
|
+
## Features
|
15
|
+
|
16
|
+
This gem currently implements the following unstable features in the WebKit
|
17
|
+
remote debugging protocol.
|
18
|
+
|
19
|
+
* Overriding device attributes
|
20
|
+
* CSS computed styles
|
21
|
+
|
22
|
+
|
23
|
+
## Requirements
|
24
|
+
|
25
|
+
The requirements for [webkit_remote](https://github.com/pwnall/webkit_remote)
|
26
|
+
apply, namely you need a Google Chrome installation, and you can use
|
27
|
+
[Xvfb](http://en.wikipedia.org/wiki/Xvfb) for headless testing.
|
28
|
+
|
29
|
+
## Installation
|
30
|
+
|
31
|
+
Use RubyGems to install `webkit_remote_unstable` instead of `webkit_remote`,
|
32
|
+
and enjoy living on the bleeding edge.
|
33
|
+
|
34
|
+
```bash
|
35
|
+
gem install webkit_remote_unstable
|
36
|
+
```
|
37
|
+
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
See the project's
|
42
|
+
[YARD documentation](http://rdoc.info/github/pwnall/webkit_remote_unstable/master/)
|
43
|
+
and
|
44
|
+
[test cases](https://github.com/pwnall/webkit_remote_unstable/tree/master/test/webkit_remote_unstable)
|
45
|
+
for usage examples.
|
46
|
+
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
Please contribute support for stable features to
|
51
|
+
[webkit_remote](https:://github.com/pwnall/webkit_remote) and support for
|
52
|
+
unstable features at
|
53
|
+
[webkit_remote_unstable](https:://github.com/pwnall/webkit_remote_unstable).
|
54
|
+
|
55
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
56
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
57
|
+
* Fork the project.
|
58
|
+
* Start a feature/bugfix branch.
|
59
|
+
* Commit and push until you are happy with your contribution.
|
60
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
61
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
62
|
+
|
63
|
+
## Copyright
|
64
|
+
|
65
|
+
Copyright (c) 2012 Victor Costan. See LICENSE.txt for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "webkit_remote_unstable"
|
18
|
+
gem.homepage = "http://github.com/pwnall/webkit_remote_unstable"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Unstable features for the webkit_remote Webkit remote debugging client}
|
21
|
+
gem.description = %Q{Launches Google Chrome instances and controls them via the Remote Debugging server}
|
22
|
+
gem.email = "victor@costan.us"
|
23
|
+
gem.authors = ["Victor Costan"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/*_test.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
36
|
+
|
37
|
+
require 'yard'
|
38
|
+
YARD::Rake::YardocTask.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module WebkitRemote
|
2
|
+
|
3
|
+
class Client
|
4
|
+
|
5
|
+
# API for the unstable CSS domain.
|
6
|
+
module Css
|
7
|
+
# Enables or disables the generation of events in the CSS domain.
|
8
|
+
#
|
9
|
+
# @param [Boolean] new_css_events if true, the browser debugger will
|
10
|
+
# generate CSS.* events
|
11
|
+
def css_events=(new_css_events)
|
12
|
+
new_css_events = !!new_css_events
|
13
|
+
if new_css_events != css_events
|
14
|
+
@rpc.call(new_css_events ? 'CSS.enable' : 'CSS.disable')
|
15
|
+
@css_events = new_css_events
|
16
|
+
end
|
17
|
+
new_css_events
|
18
|
+
end
|
19
|
+
|
20
|
+
# Cleans up all the CSS-related state.
|
21
|
+
#
|
22
|
+
# @return [WebkitRemote::Client] self
|
23
|
+
def clear_css
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Boolean] true if the debugger generates css.* events
|
28
|
+
attr_reader :css_events
|
29
|
+
|
30
|
+
# @private Called by the Client constructor to set up css data.
|
31
|
+
def initialize_css
|
32
|
+
@css_events = false
|
33
|
+
end
|
34
|
+
end # module WebkitRemote::Client::Css
|
35
|
+
|
36
|
+
initializer :initialize_css
|
37
|
+
clearer :clear_css
|
38
|
+
include WebkitRemote::Client::Css
|
39
|
+
|
40
|
+
class DomNode
|
41
|
+
# @return [Hash<Symbol, String>] computed CSS attributes for this node
|
42
|
+
def computed_style
|
43
|
+
@computed_style ||= computed_style!
|
44
|
+
end
|
45
|
+
|
46
|
+
# Gets the node's computed CSS attributes, bypassing the node cache.
|
47
|
+
#
|
48
|
+
# @return [Hash<Symbol, String>] computed CSS attributes for this node
|
49
|
+
def computed_style!
|
50
|
+
result = @client.rpc.call 'CSS.getComputedStyleForNode', nodeId: @remote_id
|
51
|
+
@computed_style = Hash[result['computedStyle'].map { |property|
|
52
|
+
[property['name'].gsub('-', '_').to_sym, property['value']]
|
53
|
+
}]
|
54
|
+
end
|
55
|
+
|
56
|
+
# @private Called by the DomNode constructor
|
57
|
+
def initialize_css
|
58
|
+
@computed_style = nil
|
59
|
+
end
|
60
|
+
initializer :initialize_css
|
61
|
+
end # namespace WebkitRemote::Client::DomNode
|
62
|
+
|
63
|
+
end # namespace WebkitRemote::Client
|
64
|
+
|
65
|
+
end # namespace WebkitRemote
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module WebkitRemote
|
2
|
+
|
3
|
+
class Event
|
4
|
+
|
5
|
+
# Emitted when the result of CSS media queries changes.
|
6
|
+
class MediaQueryResultChanged < WebkitRemote::Event
|
7
|
+
register 'CSS.mediaQueryResultChanged'
|
8
|
+
|
9
|
+
# @private Use Event#for instead of calling this constructor directly.
|
10
|
+
def initialize(rpc_event, client)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
# @private Use Event#can_receive instead of calling this directly.
|
15
|
+
def self.can_reach?(client)
|
16
|
+
client.css_events
|
17
|
+
end
|
18
|
+
end # class WebkitRemote::Event::MediaQueryResultChanged
|
19
|
+
|
20
|
+
end # namespace WebkitRemote::Event
|
21
|
+
|
22
|
+
end # namepspace WebkitRemote
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module WebkitRemote
|
2
|
+
|
3
|
+
class Client
|
4
|
+
|
5
|
+
# Unstable API for the Page domain.
|
6
|
+
module Page
|
7
|
+
# Checks if the debugger can override the browser's device metrics.
|
8
|
+
#
|
9
|
+
# @return [Boolean] true if WebkitRemote::Client::Page#device_metrics= can be
|
10
|
+
# successfully called
|
11
|
+
def can_set_device_metrics?
|
12
|
+
response = @rpc.call 'Page.canOverrideDeviceMetrics'
|
13
|
+
!!response['result']
|
14
|
+
end
|
15
|
+
|
16
|
+
# Overrides the values of device screen dimensions.
|
17
|
+
#
|
18
|
+
# This changes the properties of window.screen and the results of CSS media
|
19
|
+
# queries involving "device-width" and "device-height".
|
20
|
+
#
|
21
|
+
# @param [Hash<Symbol, Object>] new_device_metrics overridden attributes
|
22
|
+
# @option new_device_metrics [Integer] width override for window.screen.width
|
23
|
+
# and window.innerWidth
|
24
|
+
# @option new_device_metrics [Integer] height override for
|
25
|
+
# window.screen.height and window.innerHeight
|
26
|
+
# @option new_device_metrics [Number] font_scale override for the font scale
|
27
|
+
# factor value
|
28
|
+
# @option new_device_metrics [Boolean] fit_window true if views that exceed
|
29
|
+
# the browser window area should be scaled to fit
|
30
|
+
#
|
31
|
+
# @return [Hash<Symbol, Object>] new_device_metrics
|
32
|
+
def device_metrics=(new_device_metrics)
|
33
|
+
new_device_metrics = {
|
34
|
+
width: new_device_metrics[:width] || nil,
|
35
|
+
height: new_device_metrics[:height] || nil,
|
36
|
+
font_scale: new_device_metrics[:font_scale] || nil,
|
37
|
+
fit_window: new_device_metrics[:fit_window] || false,
|
38
|
+
}.freeze
|
39
|
+
@rpc.call 'Page.setDeviceMetricsOverride',
|
40
|
+
width: new_device_metrics[:width] || 0,
|
41
|
+
height: new_device_metrics[:height] || 0,
|
42
|
+
fontScaleFactor: new_device_metrics[:font_scale] || 1,
|
43
|
+
fitWindow: new_device_metrics[:fit_window] || false
|
44
|
+
@device_metrics = new_device_metrics
|
45
|
+
new_device_metrics
|
46
|
+
end
|
47
|
+
|
48
|
+
# @private Called by the Client constructor to set up unsupported Page data.
|
49
|
+
def initialize_page_unstable
|
50
|
+
@device_metrics = {}
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [Hash<Symbol, Object>] overridden device metrics; see
|
54
|
+
# WebkitRemote::Client::Page#device_metrics= for details
|
55
|
+
attr_reader :device_metrics
|
56
|
+
end # module WebkitRemote::Client::Page
|
57
|
+
|
58
|
+
initializer :initialize_page_unstable
|
59
|
+
|
60
|
+
end # namespace WebkitRemote::Client
|
61
|
+
|
62
|
+
end # namespace WebkitRemote
|
63
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.setup :default, :development
|
3
|
+
|
4
|
+
require 'json'
|
5
|
+
require 'rack/contrib'
|
6
|
+
|
7
|
+
# Compression for Network domain testing.
|
8
|
+
use Rack::Deflater
|
9
|
+
|
10
|
+
# Custom header for Network domain testing.
|
11
|
+
use Rack::ResponseHeaders do |headers|
|
12
|
+
headers['X-Unit-Test'] = 'webkit-remote'
|
13
|
+
end
|
14
|
+
|
15
|
+
# Cache headers for Network domain testing.
|
16
|
+
use Rack::StaticCache, urls: ['/html', '/js', '/png'], root: 'test/fixtures',
|
17
|
+
versioning: false, duration: 24 * 60 * 60
|
18
|
+
app = lambda do |env|
|
19
|
+
[
|
20
|
+
200,
|
21
|
+
{'Content-Type' => 'application/json'},
|
22
|
+
[JSON.dump(env)]
|
23
|
+
]
|
24
|
+
end
|
25
|
+
run app
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>WebkitRemote CSS test</title>
|
5
|
+
<style type="text/css">
|
6
|
+
html, body {
|
7
|
+
font-size: 12px;
|
8
|
+
width: 100%;
|
9
|
+
height: 100%;
|
10
|
+
margin: 0;
|
11
|
+
padding: 0;
|
12
|
+
}
|
13
|
+
h1 {
|
14
|
+
font-size: 2em;
|
15
|
+
line-height: 1.2;
|
16
|
+
width: 50%;
|
17
|
+
height: 50%;
|
18
|
+
margin: 0 auto;
|
19
|
+
}
|
20
|
+
@media screen and (max-width: 300px) {
|
21
|
+
h1 {
|
22
|
+
color: red;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
</style>
|
26
|
+
</head>
|
27
|
+
<body>
|
28
|
+
<h1>Page title</h1>
|
29
|
+
<p>Page loaded</p>
|
30
|
+
</body>
|
31
|
+
</html>
|
32
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'minitest/unit'
|
11
|
+
require 'minitest/spec'
|
12
|
+
|
13
|
+
require 'simplecov'
|
14
|
+
SimpleCov.start
|
15
|
+
|
16
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
17
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
18
|
+
require 'webkit_remote_unstable'
|
19
|
+
|
20
|
+
require 'debugger'
|
21
|
+
require 'pp'
|
22
|
+
require 'thread'
|
23
|
+
Thread.abort_on_exception = true
|
24
|
+
|
25
|
+
# Launch a dev server and wait until it starts.
|
26
|
+
pid = Process.spawn 'bundle exec puma --port 9969 --quiet --threads 1:1 ' +
|
27
|
+
'test/fixtures/config.ru', :in => '/dev/null', :out => '/dev/null'
|
28
|
+
Process.detach pid
|
29
|
+
at_exit { Process.kill 'TERM', pid }
|
30
|
+
loop do
|
31
|
+
begin
|
32
|
+
response = Net::HTTP.get_response URI.parse('http://localhost:9969')
|
33
|
+
break if response.kind_of?(Net::HTTPSuccess)
|
34
|
+
rescue SystemCallError
|
35
|
+
sleep 0.1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class MiniTest::Unit::TestCase
|
40
|
+
# URL for a file in the test/fixtures directory.
|
41
|
+
def fixture_url(name, type = :html)
|
42
|
+
"http://localhost:9969/#{type}/#{name}.#{type}"
|
43
|
+
end
|
44
|
+
# Path to a file in the test/fixtures directory.
|
45
|
+
def fixture_path(name, type = :html)
|
46
|
+
File.join File.dirname(__FILE__), "fixtures/#{type}/#{name}.#{type}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
MiniTest::Unit.autorun
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.expand_path('../helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe WebkitRemote::Client::Css do
|
4
|
+
before :all do
|
5
|
+
@client = WebkitRemote.local port: 9669
|
6
|
+
@client.page_events = true
|
7
|
+
@client.navigate_to fixture_url(:css)
|
8
|
+
@client.wait_for type: WebkitRemote::Event::PageLoaded
|
9
|
+
end
|
10
|
+
after :all do
|
11
|
+
@client.close
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'without css events enabled' do
|
15
|
+
before :each do
|
16
|
+
@client.css_events = false
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'cannot wait for CSS events' do
|
20
|
+
lambda {
|
21
|
+
@client.wait_for type: WebkitRemote::Event::MediaQueryResultChanged
|
22
|
+
}.must_raise ArgumentError
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'DomNode#computed_style' do
|
26
|
+
before :each do
|
27
|
+
@node = @client.dom_root.query_selector 'h1'
|
28
|
+
@style = @node.computed_style
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'gives computed values' do
|
32
|
+
@style[:font_size].must_equal '24px'
|
33
|
+
@style[:line_height].must_equal '28px'
|
34
|
+
@style[:color].must_equal 'rgb(255, 0, 0)'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'with CSS events enabled' do
|
40
|
+
before :each do
|
41
|
+
@client.css_events = true
|
42
|
+
@client.device_metrics = { width: 512, height: 480, fit_window: false }
|
43
|
+
@events = @client.wait_for(
|
44
|
+
type: WebkitRemote::Event::MediaQueryResultChanged)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'receives MediaQueryResultChanged events' do
|
48
|
+
@events.last.must_be_kind_of WebkitRemote::Event::MediaQueryResultChanged
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'DomNode#computed_style' do
|
52
|
+
before :each do
|
53
|
+
@node = @client.dom_root.query_selector 'h1'
|
54
|
+
@style = @node.computed_style
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'gives computed values' do
|
58
|
+
@style[:color].must_equal 'rgb(0, 0, 0)'
|
59
|
+
@style[:width].must_equal '256px'
|
60
|
+
@style[:height].must_equal '240px'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path('../helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe WebkitRemote::Client::Page do
|
4
|
+
before :all do
|
5
|
+
@client = WebkitRemote.local port: 9669
|
6
|
+
@client.page_events = true
|
7
|
+
@client.navigate_to fixture_url(:page)
|
8
|
+
@client.wait_for type: WebkitRemote::Event::PageLoaded
|
9
|
+
end
|
10
|
+
after :all do
|
11
|
+
@client.close
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'can_set_device_metrics?' do
|
15
|
+
it 'returns true in Chrome' do
|
16
|
+
@client.can_set_device_metrics?.must_equal true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'device_metrics=' do
|
21
|
+
before :each do
|
22
|
+
@client.device_metrics = { width: 512, height: 480, fit_window: true }
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'changes window.innerWidth and window.innerHeight' do
|
26
|
+
@client.remote_eval('window.innerWidth').must_be_close_to 512, 1
|
27
|
+
@client.remote_eval('window.innerHeight').must_be_close_to 480, 1
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'changes window.screen.width and window.screen.height' do
|
31
|
+
@client.remote_eval('window.screen.width').must_be_close_to 512, 1
|
32
|
+
@client.remote_eval('window.screen.height').must_be_close_to 480, 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,260 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: webkit_remote_unstable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Victor Costan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: webkit_remote
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.4.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.4.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.2.1
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.2.1
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: debugger
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.2.1
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.2.1
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: jeweler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.8.4
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.8.4
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: minitest
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 4.1.0
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 4.1.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: puma
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.6.3
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.6.3
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rack
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.4.1
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 1.4.1
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rack-contrib
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 1.1.0
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 1.1.0
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: rdoc
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '3.12'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '3.12'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: ruby-prof
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 0.11.2
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.11.2
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: simplecov
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: 0.7.1
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: 0.7.1
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: yard
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ! '>='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: 0.8.3
|
198
|
+
type: :development
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ! '>='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: 0.8.3
|
206
|
+
description: Launches Google Chrome instances and controls them via the Remote Debugging
|
207
|
+
server
|
208
|
+
email: victor@costan.us
|
209
|
+
executables: []
|
210
|
+
extensions: []
|
211
|
+
extra_rdoc_files:
|
212
|
+
- LICENSE.txt
|
213
|
+
- README.md
|
214
|
+
files:
|
215
|
+
- .travis.yml
|
216
|
+
- Gemfile
|
217
|
+
- Gemfile.lock
|
218
|
+
- LICENSE.txt
|
219
|
+
- README.md
|
220
|
+
- Rakefile
|
221
|
+
- VERSION
|
222
|
+
- lib/webkit_remote_unstable.rb
|
223
|
+
- lib/webkit_remote_unstable/css.rb
|
224
|
+
- lib/webkit_remote_unstable/css_events.rb
|
225
|
+
- lib/webkit_remote_unstable/page.rb
|
226
|
+
- test/fixtures/config.ru
|
227
|
+
- test/fixtures/html/css.html
|
228
|
+
- test/fixtures/html/page.html
|
229
|
+
- test/helper.rb
|
230
|
+
- test/webkit_remote_unstable/css_test.rb
|
231
|
+
- test/webkit_remote_unstable/page_test.rb
|
232
|
+
homepage: http://github.com/pwnall/webkit_remote_unstable
|
233
|
+
licenses:
|
234
|
+
- MIT
|
235
|
+
post_install_message:
|
236
|
+
rdoc_options: []
|
237
|
+
require_paths:
|
238
|
+
- lib
|
239
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
240
|
+
none: false
|
241
|
+
requirements:
|
242
|
+
- - ! '>='
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: '0'
|
245
|
+
segments:
|
246
|
+
- 0
|
247
|
+
hash: -4351478666109423187
|
248
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
249
|
+
none: false
|
250
|
+
requirements:
|
251
|
+
- - ! '>='
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
version: '0'
|
254
|
+
requirements: []
|
255
|
+
rubyforge_project:
|
256
|
+
rubygems_version: 1.8.24
|
257
|
+
signing_key:
|
258
|
+
specification_version: 3
|
259
|
+
summary: Unstable features for the webkit_remote Webkit remote debugging client
|
260
|
+
test_files: []
|