puppeteer-ruby 0.35.1 → 0.37.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +71 -45
  3. data/README.md +69 -0
  4. data/docs/api_coverage.md +55 -45
  5. data/lib/puppeteer/browser.rb +2 -8
  6. data/lib/puppeteer/browser_context.rb +1 -0
  7. data/lib/puppeteer/browser_runner.rb +1 -1
  8. data/lib/puppeteer/concurrent_ruby_utils.rb +2 -2
  9. data/lib/puppeteer/coverage.rb +11 -2
  10. data/lib/puppeteer/define_async_method.rb +1 -1
  11. data/lib/puppeteer/devices.rb +132 -0
  12. data/lib/puppeteer/dom_world.rb +10 -9
  13. data/lib/puppeteer/element_handle/offset.rb +28 -0
  14. data/lib/puppeteer/element_handle/point.rb +11 -0
  15. data/lib/puppeteer/element_handle.rb +68 -7
  16. data/lib/puppeteer/frame.rb +4 -3
  17. data/lib/puppeteer/frame_manager.rb +2 -2
  18. data/lib/puppeteer/{request.rb → http_request.rb} +150 -21
  19. data/lib/puppeteer/{response.rb → http_response.rb} +2 -2
  20. data/lib/puppeteer/js_coverage.rb +28 -7
  21. data/lib/puppeteer/launcher/launch_options.rb +3 -3
  22. data/lib/puppeteer/lifecycle_watcher.rb +2 -2
  23. data/lib/puppeteer/mouse.rb +54 -1
  24. data/lib/puppeteer/network_condition.rb +12 -0
  25. data/lib/puppeteer/network_conditions.rb +24 -0
  26. data/lib/puppeteer/network_manager.rb +64 -18
  27. data/lib/puppeteer/page/metrics.rb +49 -0
  28. data/lib/puppeteer/page/screenshot_options.rb +3 -1
  29. data/lib/puppeteer/page.rb +166 -134
  30. data/lib/puppeteer/puppeteer.rb +5 -0
  31. data/lib/puppeteer/timeout_helper.rb +22 -0
  32. data/lib/puppeteer/tracing.rb +6 -1
  33. data/lib/puppeteer/version.rb +1 -1
  34. data/lib/puppeteer/wait_task.rb +1 -1
  35. data/lib/puppeteer/web_socket.rb +1 -0
  36. data/lib/puppeteer.rb +17 -14
  37. data/puppeteer-ruby.gemspec +1 -1
  38. metadata +11 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6261fae36fcaf6fad5ebcc8a6721496ea1ba7e76cdc770885f1b9cb6c49582b
4
- data.tar.gz: cd7c4dbc2370568973c4319158e8c0d2f79248f83a7d7fd0a1f00d8c9f38ffa8
3
+ metadata.gz: a83ed41b8bd2c8068dc4a1738fa16abe80e88e59fb21c4768994ae640bb5b567
4
+ data.tar.gz: 6e67fb0d381644bb376d09d01213320170aa5f9ec429694c9b98888bd2006722
5
5
  SHA512:
6
- metadata.gz: 0cb8cb7bebc28260088f3f558225c83f8e15bfbe539c0eabbca2fdcf324e941d3c4f61ebd08b57600bf3a366219bcb2f9c0930e250f796caca367601baab9daf
7
- data.tar.gz: e3532e2a9b2da82d819b6946a7c4b2b870312dfb359739b997a7f2c72bc13772998a89453a3e244e64d0db0a6c9f6f70b95d86ba2d02c1b7d8cd5411a67c482f
6
+ metadata.gz: b229ccf33f63425298aa0d70051d6d6a1d61d9509bf6030499521b11494fb7b9ece03fa63ab5c31be6b0a552f28b5d7b571b6c930027445cee60bbcadaada24c
7
+ data.tar.gz: 6f35fb3ea22f4cd557e062576fdb95939f16e62c611f09469bf8d7647f72ff380000e1b94ac8e1412b03f9107124a5ce21914c4e2b839e893ecd275ed73b9ef3
data/CHANGELOG.md CHANGED
@@ -1,42 +1,69 @@
1
- ### master [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.35.1...master)]
1
+ ### master [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.37.2...master)]
2
2
 
3
- * xxx
3
+ - xxx
4
+
5
+ ### 0.37.2 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.37.1...0.37.2)]
6
+
7
+ Bugfix:
8
+
9
+ - `timeout: 0` did set the timeout value to zero. Now it disables the timeout as expected.
10
+
11
+ ### 0.37.1 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.37.0...0.37.1)]
12
+
13
+ Bugfix:
14
+
15
+ - Fix handle_SIGINT, handle_SIGTERM, handle_SIGHUP options to work with `false` value specified.
16
+
17
+ ### 0.37.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.36.0...0.37.0)]
18
+
19
+ New features:
20
+
21
+ - Some features introduced in Puppeteer 10.4
22
+
23
+ ### 0.36.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.35.1...0.36.0)]
24
+
25
+ New features:
26
+
27
+ - Drag and Drop feature introduced in Puppeteer 10.1
28
+ - `Page#emulateNetworkConditions`, `Page#emulateCPUThrottling`
29
+ - `Page#exposeFunction`
30
+ - Metrics
4
31
 
5
32
  ### 0.35.1 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.35.0...0.35.1)]
6
33
 
7
34
  New features:
8
35
 
9
- * Allow Rails users to use this library without `require 'puppeteer'`.
36
+ - Allow Rails users to use this library without `require 'puppeteer'`.
10
37
 
11
38
  ### 0.35.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.3...0.35.0)]
12
39
 
13
40
  New features:
14
41
 
15
- * Add `channel` parameter for Puppeteer.launch. Now `channel: chrome` or `channel: chrome-canary` (chrome-beta, chrome-dev is also available) automatically detects the executablePath of Google Chrome. Windows/macOS users can also use `channel: msedge`.
42
+ - Add `channel` parameter for Puppeteer.launch. Now `channel: chrome` or `channel: chrome-canary` (chrome-beta, chrome-dev is also available) automatically detects the executablePath of Google Chrome. Windows/macOS users can also use `channel: msedge`.
16
43
 
17
44
  ### 0.34.3 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.2...0.34.3)]
18
45
 
19
46
  Bugfix:
20
47
 
21
- * Fix wait_for_xxx's timeout error type.
48
+ - Fix wait_for_xxx's timeout error type.
22
49
 
23
50
  ### 0.34.2 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.1...0.34.2)]
24
51
 
25
52
  New features:
26
53
 
27
- * Add `Page#bring_to_front`.
54
+ - Add `Page#bring_to_front`.
28
55
 
29
56
  ### 0.34.1 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.0...0.34.1)]
30
57
 
31
58
  Bugfix:
32
59
 
33
- * Fix `Page#pdf` to work without `path` parameter.
60
+ - Fix `Page#pdf` to work without `path` parameter.
34
61
 
35
62
  ### 0.34.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.33.0...0.34.0)]
36
63
 
37
64
  New features:
38
65
 
39
- * Sync API with block
66
+ - Sync API with block
40
67
 
41
68
  ### 0.33.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.32.4...0.33.0)]
42
69
 
@@ -44,170 +71,169 @@ NOTE: Requires Ruby version >= 2.6 explicitly since this version.
44
71
 
45
72
  Bugfix:
46
73
 
47
- * Fix PDF options to work correctly on decimal numbers specified.
74
+ - Fix PDF options to work correctly on decimal numbers specified.
48
75
 
49
76
  ### 0.32.4 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.32.3...0.32.4)]
50
77
 
51
78
  Bugfix:
52
79
 
53
- * Fix `#type_text` to input '<' correctly.
80
+ - Fix `#type_text` to input '<' correctly.
54
81
 
55
82
  ### 0.32.3 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.32.2...0.32.3)]
56
83
 
57
84
  Bugfix:
58
85
 
59
- * Fix puppeteer-ruby to work on Rails in development mode.
60
-
86
+ - Fix puppeteer-ruby to work on Rails in development mode.
61
87
 
62
88
  ### 0.32.2 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.32.1...0.32.2)]
63
89
 
64
90
  Bugfix:
65
91
 
66
- * Fix full_page option in screenshot.
92
+ - Fix full_page option in screenshot.
67
93
 
68
94
  ### 0.32.1 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.32.0...0.32.1)]
69
95
 
70
96
  Bugfix:
71
97
 
72
- * Fix WebSocket to work with `wss://...` endpoint (ex. browserless.io)
98
+ - Fix WebSocket to work with `wss://...` endpoint (ex. browserless.io)
73
99
 
74
100
  ### 0.32.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.6...0.32.0)]
75
101
 
76
102
  New features:
77
103
 
78
- * Tracing
79
- * JS/CSS coverages
104
+ - Tracing
105
+ - JS/CSS coverages
80
106
 
81
107
  Improvement:
82
108
 
83
- * Increase stability [#92](https://github.com/YusukeIwaki/puppeteer-ruby/pull/92)
109
+ - Increase stability [#92](https://github.com/YusukeIwaki/puppeteer-ruby/pull/92)
84
110
 
85
111
  ### 0.31.6 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.5...0.31.6)]
86
112
 
87
113
  Improvement:
88
114
 
89
- * Increase stability [#87](https://github.com/YusukeIwaki/puppeteer-ruby/pull/87)
115
+ - Increase stability [#87](https://github.com/YusukeIwaki/puppeteer-ruby/pull/87)
90
116
 
91
117
  ### 0.31.5 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.4...0.31.5)]
92
118
 
93
119
  Bugfix:
94
120
 
95
- * Fix file uploading to work without crash.
121
+ - Fix file uploading to work without crash.
96
122
 
97
123
  ### 0.31.4 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.3...0.31.4)]
98
124
 
99
125
  Bugfix:
100
126
 
101
- * Fix PDF options (format, margin, omit_background) to work.
127
+ - Fix PDF options (format, margin, omit_background) to work.
102
128
 
103
129
  ### 0.31.3 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.1...0.31.3)]
104
130
 
105
131
  Bugfix:
106
132
 
107
- * Fix `wait_for_selector` to work. *It is strongly recommended to update for 0.29.0-0.31.x users.*
133
+ - Fix `wait_for_selector` to work. _It is strongly recommended to update for 0.29.0-0.31.x users._
108
134
 
109
135
  ### 0.31.1 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.0...0.31.1)]
110
136
 
111
137
  Bugfix:
112
138
 
113
- * Fix `Page#pdf` to work on Windows.
139
+ - Fix `Page#pdf` to work on Windows.
114
140
 
115
141
  ### 0.31.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.30.0...0.31.0)]
116
142
 
117
143
  New features:
118
144
 
119
- * Now puppeteer-ruby is compatible with Windows
145
+ - Now puppeteer-ruby is compatible with Windows
120
146
 
121
147
  Bugfix:
122
148
 
123
- * Fix `Page#add_script_tag` and `Page#add_style_tag` to work
149
+ - Fix `Page#add_script_tag` and `Page#add_style_tag` to work
124
150
 
125
151
  ### 0.30.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.29.0...0.30.0)]
126
152
 
127
153
  New features:
128
154
 
129
- * S, SS, Seval, SSeval is renamed to query_selector, query_selector_all, eval_on_selector, eval_on_selector_all
155
+ - S, SS, Seval, SSeval is renamed to query_selector, query_selector_all, eval_on_selector, eval_on_selector_all
130
156
 
131
157
  ### 0.29.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.28.1...0.29.0)]
132
158
 
133
159
  New features:
134
160
 
135
- * Add `AriaQueryHandler`. Now we can use "aria/...." for selectors.
161
+ - Add `AriaQueryHandler`. Now we can use "aria/...." for selectors.
136
162
 
137
163
  ### 0.28.1 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.27...0.28.1)]
138
164
 
139
165
  New features:
140
166
 
141
- * Add `Page#emulate_idle_state`
142
- * Change versioning rule.
167
+ - Add `Page#emulate_idle_state`
168
+ - Change versioning rule.
143
169
 
144
170
  ### 0.0.27 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.26...0.0.27)]
145
171
 
146
172
  New features:
147
173
 
148
- * Now puppeteer-ruby is Ruby 3.0 compatible!
174
+ - Now puppeteer-ruby is Ruby 3.0 compatible!
149
175
 
150
176
  ### 0.0.26 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.25...0.0.26)]
151
177
 
152
178
  Bugfix:
153
179
 
154
- * Fix `Page#screenshot` working correctly with `quality` parameter.
180
+ - Fix `Page#screenshot` working correctly with `quality` parameter.
155
181
 
156
182
  ### 0.0.25 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.23...0.0.25)]
157
183
 
158
184
  New feature:
159
185
 
160
- * **Cookie** feature: `Page#set_cookie`, `Page#cookies`
186
+ - **Cookie** feature: `Page#set_cookie`, `Page#cookies`
161
187
 
162
188
  ### 0.0.23 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.22...0.0.23)]
163
189
 
164
190
  New feature:
165
191
 
166
- * **GeoLocation** feature
167
- * grant/clear permission
192
+ - **GeoLocation** feature
193
+ - grant/clear permission
168
194
 
169
195
  Bugfix/Improvement:
170
196
 
171
- * Refactoring for events ([#31](https://github.com/YusukeIwaki/puppeteer-ruby/pull/31))
172
- * Improve SEND/RECV handling in CDPSession ([#34](https://github.com/YusukeIwaki/puppeteer-ruby/pull/34))
197
+ - Refactoring for events ([#31](https://github.com/YusukeIwaki/puppeteer-ruby/pull/31))
198
+ - Improve SEND/RECV handling in CDPSession ([#34](https://github.com/YusukeIwaki/puppeteer-ruby/pull/34))
173
199
 
174
200
  ### 0.0.22 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.21...0.0.22)]
175
201
 
176
202
  Bugfix
177
203
 
178
- * Make `Puppeteer#default_args` to work
179
- * Respect Firefox launch options
180
- * Respect `default_viewport: nil`
204
+ - Make `Puppeteer#default_args` to work
205
+ - Respect Firefox launch options
206
+ - Respect `default_viewport: nil`
181
207
 
182
208
  ### 0.0.21 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.20...0.0.21)]
183
209
 
184
210
  Bugfix/Improvement:
185
211
 
186
- * Update DeviceDescriptors (list of emulatable devices)
187
- * Fix bug on inputing "(" ([#25](https://github.com/YusukeIwaki/puppeteer-ruby/pull/25))
212
+ - Update DeviceDescriptors (list of emulatable devices)
213
+ - Fix bug on inputing "(" ([#25](https://github.com/YusukeIwaki/puppeteer-ruby/pull/25))
188
214
 
189
215
  ### 0.0.20 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.19...0.0.20)]
190
216
 
191
217
  New feature
192
218
 
193
- * Dialog-handling feature
219
+ - Dialog-handling feature
194
220
 
195
221
  ### 0.0.19 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.18...0.0.19)]
196
222
 
197
223
  New feature
198
224
 
199
- * **Firefox support**
225
+ - **Firefox support**
200
226
 
201
227
  Bugfix/Improvement
202
228
 
203
- * Allow `Page#keyboard` with block ([#18](https://github.com/YusukeIwaki/puppeteer-ruby/pull/18))
229
+ - Allow `Page#keyboard` with block ([#18](https://github.com/YusukeIwaki/puppeteer-ruby/pull/18))
204
230
 
205
231
  ### 0.0.18 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.17...0.0.18)]
206
232
 
207
233
  New feature
208
234
 
209
- * **Firefox support**
235
+ - **Firefox support**
210
236
 
211
237
  Bugfix/Improvement
212
238
 
213
- * Allow `Page#keyboard` with block ([#18](https://github.com/YusukeIwaki/puppeteer-ruby/pull/18))
239
+ - Allow `Page#keyboard` with block ([#18](https://github.com/YusukeIwaki/puppeteer-ruby/pull/18))
data/README.md CHANGED
@@ -156,6 +156,75 @@ RSpec.describe 'hotel.testplanisphere.dev', type: :feature do
156
156
 
157
157
  The detailed step of configuration can be found [here](https://github.com/YusukeIwaki/puppeteer-ruby-example/tree/master/_with_capybara-rspec).
158
158
 
159
+ ## :bulb: Use Puppeteer methods simply without Capybara::DSL
160
+
161
+ We can also use puppeteer-ruby as it is without Capybara DSL. When you want to just test a Rails application simply with Puppeteer, refer this section.
162
+
163
+ Also, if you have trouble with handling flaky/unstable testcases in existing feature/system specs, consider replacing Capybara::DSL with raw puppeteer-ruby codes like `page.wait_for_selector(...)` or `page.wait_for_navigation { ... }`.
164
+
165
+ Capybara prepares test server even when Capybara DSL is not used.
166
+
167
+ Sample configuration is shown below. You can use it by putting the file at `spec/support/puppeteer_ruby.rb` or another location where RSpec loads on initialization.
168
+
169
+ ```ruby
170
+ RSpec.configure do |config|
171
+ require 'capybara'
172
+
173
+ # This driver only requests Capybara to launch test server.
174
+ # Remark that no Capybara::DSL is available with this driver.
175
+ class CapybaraNullDriver < Capybara::Driver::Base
176
+ def needs_server?
177
+ true
178
+ end
179
+ end
180
+
181
+ Capybara.register_driver(:null) { CapybaraNullDriver.new }
182
+
183
+ config.around(driver: :null) do |example|
184
+ Capybara.current_driver = :null
185
+
186
+ # Rails server is launched here,
187
+ # (at the first time of accessing Capybara.current_session.server)
188
+ @base_url = Capybara.current_session.server.base_url
189
+
190
+ require 'puppeteer'
191
+ launch_options = {
192
+ # Use launch options as you like.
193
+ channel: :chrome,
194
+ headless: false,
195
+ }
196
+ Puppeteer.launch(**launch_options) do |browser|
197
+ @puppeteer_page = browser.new_page
198
+ example.run
199
+ end
200
+
201
+ Capybara.reset_sessions!
202
+ Capybara.use_default_driver
203
+ end
204
+ end
205
+ ```
206
+
207
+ Now, we can work with integration test using `Puppeteer::Page` in puppeteer-ruby.
208
+
209
+ ```ruby
210
+ RSpec.describe 'Sample integration tests', driver: :null do
211
+ let(:page) { @puppeteer_page }
212
+ let(:base_url) { @base_url }
213
+
214
+ it 'should work with Puppeteer' do
215
+ # null driver only launches server, and Capybara::DSL is unavailable.
216
+ expect { visit '/' }.to raise_error(/NotImplementedError/)
217
+
218
+ page.goto("#{base_url}/")
219
+
220
+ # Automation with Puppeteer
221
+ h1_text = page.eval_on_selector('h1', '(el) => el.textContent')
222
+ expect(h1_text).to eq('It works!')
223
+ end
224
+ end
225
+ ```
226
+
227
+
159
228
  ## API
160
229
 
161
230
  https://yusukeiwaki.github.io/puppeteer-ruby-docs/
data/docs/api_coverage.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # API coverages
2
- - Puppeteer version: v10.1.0
3
- - puppeteer-ruby version: 0.35.1
2
+ - Puppeteer version: v11.0.0
3
+ - puppeteer-ruby version: 0.37.2
4
4
 
5
5
  ## Puppeteer
6
6
 
@@ -13,7 +13,7 @@
13
13
  * ~~errors~~
14
14
  * executablePath => `#executable_path`
15
15
  * launch
16
- * ~~networkConditions~~
16
+ * networkConditions => `#network_conditions`
17
17
  * product
18
18
  * ~~registerCustomQueryHandler~~
19
19
  * ~~unregisterCustomQueryHandler~~
@@ -81,17 +81,17 @@
81
81
  * createPDFStream => `#create_pdf_stream`
82
82
  * deleteCookie => `#delete_cookie`
83
83
  * emulate
84
- * ~~emulateCPUThrottling~~
84
+ * emulateCPUThrottling => `#emulate_cpu_throttling`
85
85
  * emulateIdleState => `#emulate_idle_state`
86
86
  * emulateMediaFeatures => `#emulate_media_features`
87
87
  * emulateMediaType => `#emulate_media_type`
88
- * ~~emulateNetworkConditions~~
88
+ * emulateNetworkConditions => `#emulate_network_conditions`
89
89
  * emulateTimezone => `#emulate_timezone`
90
90
  * emulateVisionDeficiency => `#emulate_vision_deficiency`
91
91
  * evaluate
92
92
  * evaluateHandle => `#evaluate_handle`
93
93
  * evaluateOnNewDocument => `#evaluate_on_new_document`
94
- * ~~exposeFunction~~
94
+ * exposeFunction => `#expose_function`
95
95
  * focus
96
96
  * frames
97
97
  * goBack => `#go_back`
@@ -99,11 +99,11 @@
99
99
  * goto
100
100
  * hover
101
101
  * isClosed => `#closed?`
102
- * ~~isDragInterceptionEnabled~~
102
+ * isDragInterceptionEnabled => `#drag_interception_enabled?`
103
103
  * isJavaScriptEnabled => `#javascript_enabled?`
104
104
  * keyboard
105
105
  * mainFrame => `#main_frame`
106
- * ~~metrics~~
106
+ * metrics
107
107
  * mouse
108
108
  * pdf
109
109
  * queryObjects => `#query_objects`
@@ -134,8 +134,10 @@
134
134
  * viewport
135
135
  * ~~waitFor~~
136
136
  * waitForFileChooser => `#wait_for_file_chooser`
137
+ * ~~waitForFrame~~
137
138
  * waitForFunction => `#wait_for_function`
138
139
  * waitForNavigation => `#wait_for_navigation`
140
+ * ~~waitForNetworkIdle~~
139
141
  * waitForRequest => `#wait_for_request`
140
142
  * waitForResponse => `#wait_for_response`
141
143
  * waitForSelector => `#wait_for_selector`
@@ -166,11 +168,11 @@
166
168
 
167
169
  * click
168
170
  * down
169
- * ~~drag~~
170
- * ~~dragAndDrop~~
171
- * ~~dragEnter~~
172
- * ~~dragOver~~
173
- * ~~drop~~
171
+ * drag
172
+ * dragAndDrop => `#drag_and_drop`
173
+ * dragEnter => `#drag_enter`
174
+ * dragOver => `#drag_over`
175
+ * drop
174
176
  * move
175
177
  * up
176
178
  * wheel
@@ -225,6 +227,7 @@
225
227
  * goto
226
228
  * hover
227
229
  * isDetached => `#detached?`
230
+ * ~~isOOPFrame~~
228
231
  * name
229
232
  * parentFrame => `#parent_frame`
230
233
  * select
@@ -272,11 +275,11 @@
272
275
  * clickablePoint => `#clickable_point`
273
276
  * contentFrame => `#content_frame`
274
277
  * dispose
275
- * ~~drag~~
276
- * ~~dragAndDrop~~
277
- * ~~dragEnter~~
278
- * ~~dragOver~~
279
- * ~~drop~~
278
+ * drag
279
+ * dragAndDrop => `#drag_and_drop`
280
+ * dragEnter => `#drag_enter`
281
+ * dragOver => `#drag_over`
282
+ * drop
280
283
  * evaluate
281
284
  * evaluateHandle => `#evaluate_handle`
282
285
  * executionContext => `#execution_context`
@@ -294,38 +297,44 @@
294
297
  * type => `#type_text`
295
298
  * uploadFile => `#upload_file`
296
299
 
297
- ## ~~HTTPRequest~~
298
-
299
- * ~~abort~~
300
- * ~~continue~~
301
- * ~~failure~~
302
- * ~~frame~~
303
- * ~~headers~~
304
- * ~~isNavigationRequest~~
305
- * ~~method~~
306
- * ~~postData~~
307
- * ~~redirectChain~~
308
- * ~~resourceType~~
309
- * ~~respond~~
310
- * ~~response~~
311
- * ~~url~~
300
+ ## HTTPRequest
301
+
302
+ * abort
303
+ * abortErrorReason => `#abort_error_reason`
304
+ * continue
305
+ * continueRequestOverrides => `#continue_request_overrides`
306
+ * enqueueInterceptAction => `#enqueue_intercept_action`
307
+ * failure
308
+ * finalizeInterceptions => `#finalize_interceptions`
309
+ * frame
310
+ * headers
311
+ * ~~initiator~~
312
+ * isNavigationRequest => `#navigation_request?`
313
+ * method
314
+ * postData => `#post_data`
315
+ * redirectChain => `#redirect_chain`
316
+ * resourceType => `#resource_type`
317
+ * respond
318
+ * response
319
+ * responseForRequest => `#response_for_request`
320
+ * url
312
321
 
313
- ## ~~HTTPResponse~~
322
+ ## HTTPResponse
314
323
 
315
- * ~~buffer~~
316
- * ~~frame~~
324
+ * buffer
325
+ * frame
317
326
  * ~~fromCache~~
318
327
  * ~~fromServiceWorker~~
319
- * ~~headers~~
320
- * ~~json~~
328
+ * headers
329
+ * json
321
330
  * ~~ok~~
322
- * ~~remoteAddress~~
323
- * ~~request~~
324
- * ~~securityDetails~~
325
- * ~~status~~
326
- * ~~statusText~~
327
- * ~~text~~
328
- * ~~url~~
331
+ * remoteAddress => `#remote_address`
332
+ * request
333
+ * securityDetails => `#security_details`
334
+ * status
335
+ * statusText => `#status_text`
336
+ * text
337
+ * url
329
338
 
330
339
  ## ~~SecurityDetails~~
331
340
 
@@ -351,6 +360,7 @@
351
360
 
352
361
  * connection
353
362
  * detach
363
+ * ~~id~~
354
364
  * send
355
365
 
356
366
  ## Coverage
@@ -223,7 +223,7 @@ class Puppeteer::Browser
223
223
  # @param predicate [Proc(Puppeteer::Target -> Boolean)]
224
224
  # @return [Puppeteer::Target]
225
225
  def wait_for_target(predicate:, timeout: nil)
226
- timeout_in_sec = (timeout || 30000).to_i / 1000.0
226
+ timeout_helper = Puppeteer::TimeoutHelper.new('target', timeout_ms: timeout, default_timeout_ms: 30000)
227
227
  existing_target = targets.find { |target| predicate.call(target) }
228
228
  return existing_target if existing_target
229
229
 
@@ -241,15 +241,9 @@ class Puppeteer::Browser
241
241
  end
242
242
 
243
243
  begin
244
- if timeout_in_sec > 0
245
- Timeout.timeout(timeout_in_sec) do
246
- target_promise.value!
247
- end
248
- else
244
+ timeout_helper.with_timeout do
249
245
  target_promise.value!
250
246
  end
251
- rescue Timeout::Error
252
- raise Puppeteer::TimeoutError.new("waiting for target failed: timeout #{timeout}ms exceeded")
253
247
  ensure
254
248
  remove_event_listener(*event_listening_ids)
255
249
  end
@@ -74,6 +74,7 @@ class Puppeteer::BrowserContext
74
74
  'clipboard-read' => 'clipboardReadWrite',
75
75
  'clipboard-write' => 'clipboardReadWrite',
76
76
  'payment-handler' => 'paymentHandler',
77
+ 'persistent-storage' => 'durableStorage',
77
78
  'idle-detection' => 'idleDetection',
78
79
  # chrome-specific permissions we have.
79
80
  'midi-sysex' => 'midiSysex',
@@ -94,7 +94,7 @@ class Puppeteer::BrowserRunner
94
94
  FileUtils.rm_rf(@temp_directory)
95
95
  end
96
96
  }
97
- trap(:EXIT) do
97
+ at_exit do
98
98
  kill
99
99
  end
100
100
 
@@ -3,11 +3,11 @@ module Puppeteer::ConcurrentRubyUtils
3
3
  module ConcurrentPromisesFutureExtension
4
4
  # Extension for describing 2 concurrent tasks smartly.
5
5
  #
6
- # page.async_for_navigation.with_waiting_for_complete do
6
+ # page.async_wait_for_navigation.with_waiting_for_complete do
7
7
  # page.click('#submit')
8
8
  # end
9
9
  def with_waiting_for_complete(&block)
10
- async_block_call = Concurrent::Promises.future do
10
+ async_block_call = Concurrent::Promises.delay do
11
11
  block.call
12
12
  rescue => err
13
13
  Logger.new($stderr).warn(err)
@@ -5,10 +5,14 @@ class Puppeteer::Coverage
5
5
  @css = Puppeteer::CSSCoverage.new(client)
6
6
  end
7
7
 
8
- def start_js_coverage(reset_on_navigation: nil, report_anonymous_scripts: nil)
8
+ def start_js_coverage(
9
+ reset_on_navigation: nil,
10
+ report_anonymous_scripts: nil,
11
+ include_raw_script_coverage: nil)
9
12
  @js.start(
10
13
  reset_on_navigation: reset_on_navigation,
11
14
  report_anonymous_scripts: report_anonymous_scripts,
15
+ include_raw_script_coverage: include_raw_script_coverage,
12
16
  )
13
17
  end
14
18
 
@@ -16,7 +20,11 @@ class Puppeteer::Coverage
16
20
  @js.stop
17
21
  end
18
22
 
19
- def js_coverage(reset_on_navigation: nil, report_anonymous_scripts: nil, &block)
23
+ def js_coverage(
24
+ reset_on_navigation: nil,
25
+ report_anonymous_scripts: nil,
26
+ include_raw_script_coverage: nil,
27
+ &block)
20
28
  unless block
21
29
  raise ArgumentError.new('Block must be given')
22
30
  end
@@ -24,6 +32,7 @@ class Puppeteer::Coverage
24
32
  start_js_coverage(
25
33
  reset_on_navigation: reset_on_navigation,
26
34
  report_anonymous_scripts: report_anonymous_scripts,
35
+ include_raw_script_coverage: include_raw_script_coverage,
27
36
  )
28
37
  block.call
29
38
  stop_js_coverage
@@ -40,7 +40,7 @@ module Puppeteer::DefineAsyncMethod
40
40
  end
41
41
  end
42
42
 
43
- async_block_call = Concurrent::Promises.future do
43
+ async_block_call = Concurrent::Promises.delay do
44
44
  block.call
45
45
  rescue => err
46
46
  Logger.new($stderr).warn(err)