webkit_remote 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  require File.expand_path('../../helper.rb', File.dirname(__FILE__))
2
2
 
3
- describe WebkitRemote::Client::RemoteObjectGroup do
3
+ describe WebkitRemote::Client::JsObjectGroup do
4
4
  before :each do
5
5
  @client = WebkitRemote.local port: 9669
6
6
  @client.page_events = true
@@ -1,6 +1,6 @@
1
1
  require File.expand_path('../../helper.rb', File.dirname(__FILE__))
2
2
 
3
- describe WebkitRemote::Client::RemoteObject do
3
+ describe WebkitRemote::Client::JsObject do
4
4
  before :each do
5
5
  @client = WebkitRemote.local port: 9669
6
6
  @client.page_events = true
@@ -18,50 +18,57 @@ describe WebkitRemote::Client::RemoteObject do
18
18
  end
19
19
 
20
20
  it 'enumerates the properties correctly' do
21
- @object.properties[:answer].name.must_equal :answer
22
- @object.properties[:test].name.must_equal :test
23
- @object.properties[:other].must_equal nil
21
+ @object.properties['answer'].name.must_equal 'answer'
22
+ @object.properties['test'].name.must_equal 'test'
23
+ @object.properties['other'].must_equal nil
24
24
  end
25
25
 
26
26
  it 'gets the correct values' do
27
- @object.properties[:answer].value.must_equal 42
28
- @object.properties[:test].value.must_equal true
27
+ @object.properties['answer'].value.must_equal 42
28
+ @object.properties['test'].value.must_equal true
29
29
  end
30
30
 
31
31
  it 'sets owner correctly' do
32
- @object.properties[:answer].owner.must_equal @object
32
+ @object.properties['answer'].owner.must_equal @object
33
33
  end
34
34
 
35
35
  it 'does not have extra properties' do
36
36
  @object.properties.select { |name, property| property.enumerable? }.
37
- keys.sort.must_equal [:answer, :test]
37
+ keys.sort.must_equal ['answer', 'test']
38
38
  end
39
39
 
40
40
  it 'recognizes writable properties' do
41
- @object.properties[:answer].writable?.must_equal true
42
- @object.properties[:constructor].writable?.must_equal false
41
+ @object.properties['answer'].writable?.must_equal true
42
+ @object.properties['constructor'].writable?.must_equal false
43
43
  end
44
44
 
45
45
  it 'recognizes configurable properties' do
46
- @object.properties[:answer].configurable?.must_equal true
47
- @object.properties[:constructor].configurable?.must_equal false
46
+ @object.properties['answer'].configurable?.must_equal true
47
+ @object.properties['constructor'].configurable?.must_equal false
48
48
  end
49
49
 
50
50
  it 'recognizes enumerable properties' do
51
- @object.properties[:answer].enumerable?.must_equal true
52
- @object.properties[:constructor].enumerable?.must_equal false
51
+ @object.properties['answer'].enumerable?.must_equal true
52
+ @object.properties['constructor'].enumerable?.must_equal false
53
53
  end
54
54
 
55
55
  describe 'after property update' do
56
56
  before do
57
- @object.properties[:DONE]
57
+ @object.properties['DONE']
58
58
  @client.remote_eval 'window.t.test = "updated"'
59
59
  end
60
60
  it 'does not automatically refresh' do
61
- @object.properties[:test].value.must_equal true
61
+ @object.properties['test'].value.must_equal true
62
62
  end
63
63
  it 'refreshes when properties! is called' do
64
- @object.properties![:test].value.must_equal 'updated'
64
+ @object.properties!['test'].value.must_equal 'updated'
65
+ end
66
+ end
67
+
68
+ describe 'inspect' do
69
+ it 'contains the property name and its enumerable status' do
70
+ @object.properties['test'].inspect.must_match(
71
+ /<WebkitRemote::Client::JsProperty:.*\s+name="test"\s+configurable=.+\s+enumerable=.+>/)
65
72
  end
66
73
  end
67
74
  end
@@ -72,9 +79,9 @@ describe WebkitRemote::Client::RemoteObject do
72
79
  end
73
80
 
74
81
  it 'recognizes configurable, non-writable, enumerable properties' do
75
- @object.properties[:DONE].configurable?.must_equal true
76
- @object.properties[:DONE].writable?.must_equal false
77
- @object.properties[:DONE].enumerable?.must_equal true
82
+ @object.properties['DONE'].configurable?.must_equal true
83
+ @object.properties['DONE'].writable?.must_equal false
84
+ @object.properties['DONE'].enumerable?.must_equal true
78
85
  end
79
86
  end
80
87
  end
@@ -120,7 +127,7 @@ describe WebkitRemote::Client::RemoteObject do
120
127
  @arg1, @arg2
121
128
  end
122
129
  it 'passes the objects and returns an object correctly' do
123
- @result.must_be_kind_of WebkitRemote::Client::RemoteObject
130
+ @result.must_be_kind_of WebkitRemote::Client::JsObject
124
131
  @result.js_class_name.must_equal 'TestClass'
125
132
  @result.bound_call('TestClass.prototype.toString').
126
133
  must_equal 'hello ruby, rbx and jruby'
@@ -94,8 +94,8 @@ describe WebkitRemote::Client::Runtime do
94
94
  group = @client.object_group('yes')
95
95
  group.release_all if group
96
96
  end
97
- it 'returns an RemoteObject instance' do
98
- @object.must_be_kind_of WebkitRemote::Client::RemoteObject
97
+ it 'returns an JsObject instance' do
98
+ @object.must_be_kind_of WebkitRemote::Client::JsObject
99
99
  end
100
100
  it 'sets the object properties correctly' do
101
101
  @object.js_class_name.must_equal 'TestClass'
@@ -116,8 +116,8 @@ describe WebkitRemote::Client::Runtime do
116
116
  group = @client.object_group('yes')
117
117
  group.release_all if group
118
118
  end
119
- it 'returns an RemoteObject instance' do
120
- @object.must_be_kind_of WebkitRemote::Client::RemoteObject
119
+ it 'returns an JsObject instance' do
120
+ @object.must_be_kind_of WebkitRemote::Client::JsObject
121
121
  end
122
122
  it 'sets the object properties correctly' do
123
123
  @object.js_class_name.must_equal 'Object'
@@ -139,8 +139,8 @@ describe WebkitRemote::Client::Runtime do
139
139
  group.release_all if group
140
140
  end
141
141
 
142
- it 'returns a RemoteObject instance' do
143
- @function.must_be_kind_of WebkitRemote::Client::RemoteObject
142
+ it 'returns a JsObject instance' do
143
+ @function.must_be_kind_of WebkitRemote::Client::JsObject
144
144
  end
145
145
 
146
146
  it 'sets the object properties correctly' do
@@ -2,7 +2,7 @@ require File.expand_path('../helper.rb', File.dirname(__FILE__))
2
2
 
3
3
  describe WebkitRemote::Client do
4
4
  before :each do
5
- @process = WebkitRemote::Process.new port: 9669
5
+ @process = WebkitRemote::Process.new port: 9669, xvfb: true
6
6
  @process.start
7
7
  @browser = WebkitRemote::Browser.new process: @process, stop_process: true
8
8
  tab = @browser.tabs.first
@@ -1,51 +1,103 @@
1
1
  require File.expand_path('../helper.rb', File.dirname(__FILE__))
2
2
 
3
3
  describe WebkitRemote::Process do
4
- before :each do
5
- @process = WebkitRemote::Process.new port: 9669
6
- end
7
- after :each do
8
- @process.stop if @process
9
- end
10
-
11
- describe '#running' do
12
- it 'returns false before #start is called' do
13
- @process.running?.must_equal false
14
- end
15
- end
16
-
17
- describe '#start' do
4
+ describe 'on Xvfb' do
18
5
  before :each do
19
- @browser = @process.start
6
+ @process = WebkitRemote::Process.new port: 9669, xvfb: true
20
7
  end
21
8
  after :each do
22
- @browser.close if @browser
23
9
  @process.stop if @process
24
10
  end
25
11
 
26
- it 'makes running? return true' do
27
- @process.running?.must_equal true
12
+ describe '#running' do
13
+ it 'returns false before #start is called' do
14
+ @process.running?.must_equal false
15
+ end
16
+ end
17
+
18
+ describe '#start' do
19
+ before :each do
20
+ @browser = @process.start
21
+ end
22
+ after :each do
23
+ @browser.close if @browser
24
+ @process.stop if @process
25
+ end
26
+
27
+ it 'makes running? return true' do
28
+ @process.running?.must_equal true
29
+ end
30
+
31
+ it 'returns a Browser instance that does not auto-stop the process' do
32
+ @browser.must_be_kind_of WebkitRemote::Browser
33
+ @browser.closed?.must_equal false
34
+ @browser.stop_process?.must_equal false
35
+ end
36
+
37
+ describe '#stop' do
38
+ before :each do
39
+ @process.stop
40
+ end
41
+
42
+ it 'makes running? return false' do
43
+ @process.running?.must_equal false
44
+ end
45
+
46
+ it 'kills the http server that responds to /json' do
47
+ begin
48
+ @browser.tabs
49
+ fail 'browser process not killed'
50
+ rescue EOFError
51
+ pass
52
+ rescue Errno::ECONNRESET
53
+ pass
54
+ end
55
+ end
56
+ end
28
57
  end
58
+ end
29
59
 
30
- it 'returns a Browser instance that does not auto-stop the process' do
31
- @browser.must_be_kind_of WebkitRemote::Browser
32
- @browser.closed?.must_equal false
33
- @browser.stop_process?.must_equal false
60
+ describe 'on real X desktop' do
61
+ before :each do
62
+ unless ENV['DISPLAY'] and /\:\d+/ =~ ENV['DISPLAY']
63
+ skip 'No real X desktop configured'
64
+ end
65
+ @process = WebkitRemote::Process.new port: 9669
66
+ end
67
+ after :each do
68
+ @process.stop if @process
34
69
  end
35
70
 
36
- describe '#stop' do
71
+ describe '#start' do
37
72
  before :each do
38
- @process.stop
73
+ @browser = @process.start
74
+ end
75
+ after :each do
76
+ @browser.close if @browser
77
+ @process.stop if @process
39
78
  end
40
79
 
41
- it 'makes running? return false' do
42
- @process.running?.must_equal false
80
+ it 'returns a Browser instance that does not auto-stop the process' do
81
+ @browser.must_be_kind_of WebkitRemote::Browser
82
+ @browser.closed?.must_equal false
83
+ @browser.stop_process?.must_equal false
43
84
  end
44
85
 
45
- it 'kills the http server that responds to /json' do
46
- lambda {
47
- @browser.tabs
48
- }.must_raise EOFError
86
+ describe '#stop' do
87
+ before :each do
88
+ @process.stop
89
+ end
90
+
91
+ it 'kills the http server that responds to /json' do
92
+ begin
93
+ @browser.tabs
94
+ fail 'browser process not killed'
95
+ rescue EOFError
96
+ pass
97
+ rescue Errno::ECONNRESET
98
+ pass
99
+ end
100
+ end
49
101
  end
50
102
  end
51
103
  end
@@ -2,7 +2,7 @@ require File.expand_path('../helper.rb', File.dirname(__FILE__))
2
2
 
3
3
  describe WebkitRemote::Rpc do
4
4
  before :each do
5
- @process = WebkitRemote::Process.new port: 9669
5
+ @process = WebkitRemote::Process.new port: 9669, xvfb: true
6
6
  @process.start
7
7
  @browser = WebkitRemote::Browser.new process: @process, stop_process: true
8
8
  tab = @browser.tabs.first
@@ -3,7 +3,7 @@ require File.expand_path('helper.rb', File.dirname(__FILE__))
3
3
  describe WebkitRemote do
4
4
  describe 'local' do
5
5
  before do
6
- @client = WebkitRemote.local port: 9669
6
+ @client = WebkitRemote.local port: 9669, xvfb: true
7
7
  end
8
8
  after do
9
9
  @client.close
@@ -29,7 +29,7 @@ describe WebkitRemote do
29
29
 
30
30
  describe 'remote' do
31
31
  before do
32
- @process = WebkitRemote::Process.new port: 9669
32
+ @process = WebkitRemote::Process.new port: 9669, xvfb: true
33
33
  browser = @process.start
34
34
  browser.close
35
35
  @client = WebkitRemote.remote host: 'localhost', port: 9669
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "webkit_remote"
8
- s.version = "0.3.2"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Victor Costan"]
12
- s.date = "2012-11-10"
12
+ s.date = "2012-11-16"
13
13
  s.description = "Launches Google Chrome instances and controls them via the Remote Debugging server"
14
14
  s.email = "victor@costan.us"
15
15
  s.extra_rdoc_files = [
@@ -30,6 +30,8 @@ Gem::Specification.new do |s|
30
30
  "lib/webkit_remote/client.rb",
31
31
  "lib/webkit_remote/client/console.rb",
32
32
  "lib/webkit_remote/client/console_events.rb",
33
+ "lib/webkit_remote/client/dom.rb",
34
+ "lib/webkit_remote/client/dom_events.rb",
33
35
  "lib/webkit_remote/client/network.rb",
34
36
  "lib/webkit_remote/client/network_events.rb",
35
37
  "lib/webkit_remote/client/page.rb",
@@ -41,6 +43,7 @@ Gem::Specification.new do |s|
41
43
  "lib/webkit_remote/top_level.rb",
42
44
  "test/fixtures/config.ru",
43
45
  "test/fixtures/html/console.html",
46
+ "test/fixtures/html/dom.html",
44
47
  "test/fixtures/html/load.html",
45
48
  "test/fixtures/html/network.html",
46
49
  "test/fixtures/html/runtime.html",
@@ -49,10 +52,11 @@ Gem::Specification.new do |s|
49
52
  "test/helper.rb",
50
53
  "test/webkit_remote/browser_test.rb",
51
54
  "test/webkit_remote/client/console_test.rb",
55
+ "test/webkit_remote/client/dom_test.rb",
56
+ "test/webkit_remote/client/js_object_group_test.rb",
57
+ "test/webkit_remote/client/js_object_test.rb",
52
58
  "test/webkit_remote/client/network_test.rb",
53
59
  "test/webkit_remote/client/page_test.rb",
54
- "test/webkit_remote/client/remote_object_group_test.rb",
55
- "test/webkit_remote/client/remote_object_test.rb",
56
60
  "test/webkit_remote/client/runtime_test.rb",
57
61
  "test/webkit_remote/client_test.rb",
58
62
  "test/webkit_remote/event_test.rb",
@@ -75,6 +79,7 @@ Gem::Specification.new do |s|
75
79
  s.add_runtime_dependency(%q<faye-websocket>, [">= 0.4.6"])
76
80
  s.add_runtime_dependency(%q<posix-spawn>, [">= 0.3.6"])
77
81
  s.add_development_dependency(%q<bundler>, [">= 1.2.1"])
82
+ s.add_development_dependency(%q<debugger>, [">= 1.2.1"])
78
83
  s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
79
84
  s.add_development_dependency(%q<minitest>, [">= 4.1.0"])
80
85
  s.add_development_dependency(%q<puma>, [">= 1.6.3"])
@@ -89,6 +94,7 @@ Gem::Specification.new do |s|
89
94
  s.add_dependency(%q<faye-websocket>, [">= 0.4.6"])
90
95
  s.add_dependency(%q<posix-spawn>, [">= 0.3.6"])
91
96
  s.add_dependency(%q<bundler>, [">= 1.2.1"])
97
+ s.add_dependency(%q<debugger>, [">= 1.2.1"])
92
98
  s.add_dependency(%q<jeweler>, [">= 1.8.4"])
93
99
  s.add_dependency(%q<minitest>, [">= 4.1.0"])
94
100
  s.add_dependency(%q<puma>, [">= 1.6.3"])
@@ -104,6 +110,7 @@ Gem::Specification.new do |s|
104
110
  s.add_dependency(%q<faye-websocket>, [">= 0.4.6"])
105
111
  s.add_dependency(%q<posix-spawn>, [">= 0.3.6"])
106
112
  s.add_dependency(%q<bundler>, [">= 1.2.1"])
113
+ s.add_dependency(%q<debugger>, [">= 1.2.1"])
107
114
  s.add_dependency(%q<jeweler>, [">= 1.8.4"])
108
115
  s.add_dependency(%q<minitest>, [">= 4.1.0"])
109
116
  s.add_dependency(%q<puma>, [">= 1.6.3"])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webkit_remote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-10 00:00:00.000000000 Z
12
+ date: 2012-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: 1.2.1
78
+ - !ruby/object:Gem::Dependency
79
+ name: debugger
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: 1.2.1
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: 1.2.1
78
94
  - !ruby/object:Gem::Dependency
79
95
  name: jeweler
80
96
  requirement: !ruby/object:Gem::Requirement
@@ -241,6 +257,8 @@ files:
241
257
  - lib/webkit_remote/client.rb
242
258
  - lib/webkit_remote/client/console.rb
243
259
  - lib/webkit_remote/client/console_events.rb
260
+ - lib/webkit_remote/client/dom.rb
261
+ - lib/webkit_remote/client/dom_events.rb
244
262
  - lib/webkit_remote/client/network.rb
245
263
  - lib/webkit_remote/client/network_events.rb
246
264
  - lib/webkit_remote/client/page.rb
@@ -252,6 +270,7 @@ files:
252
270
  - lib/webkit_remote/top_level.rb
253
271
  - test/fixtures/config.ru
254
272
  - test/fixtures/html/console.html
273
+ - test/fixtures/html/dom.html
255
274
  - test/fixtures/html/load.html
256
275
  - test/fixtures/html/network.html
257
276
  - test/fixtures/html/runtime.html
@@ -260,10 +279,11 @@ files:
260
279
  - test/helper.rb
261
280
  - test/webkit_remote/browser_test.rb
262
281
  - test/webkit_remote/client/console_test.rb
282
+ - test/webkit_remote/client/dom_test.rb
283
+ - test/webkit_remote/client/js_object_group_test.rb
284
+ - test/webkit_remote/client/js_object_test.rb
263
285
  - test/webkit_remote/client/network_test.rb
264
286
  - test/webkit_remote/client/page_test.rb
265
- - test/webkit_remote/client/remote_object_group_test.rb
266
- - test/webkit_remote/client/remote_object_test.rb
267
287
  - test/webkit_remote/client/runtime_test.rb
268
288
  - test/webkit_remote/client_test.rb
269
289
  - test/webkit_remote/event_test.rb
@@ -286,7 +306,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
286
306
  version: '0'
287
307
  segments:
288
308
  - 0
289
- hash: 3000124756786155400
309
+ hash: 4292049841560848513
290
310
  required_rubygems_version: !ruby/object:Gem::Requirement
291
311
  none: false
292
312
  requirements: