puppeteer-ruby 0.40.6 → 0.42.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51b26b6b3710f06e7a7cfb7e9f5730bbb9517396fd30a7f271161820bb6902c6
4
- data.tar.gz: 528fd6520a029cf9d85424a105cf19a156f428435dc795a8b8753c8cbfa442db
3
+ metadata.gz: 6b06e1f5f867ef4e7d648e93becc953f660bb707b29019ffe6e93f8e9f02acc4
4
+ data.tar.gz: ff082c6ba661e0f2d8b0d8bc0f92f5aeecf036f9edcd7bb6f8937db4fd019947
5
5
  SHA512:
6
- metadata.gz: ad616ae1574e76f71cb7e7cb1dae5cba4ae4ad65865ab6a5e6cb92c6033b9ce654de2b364b5d5351e69302f88fc48231c2a9bd97765af9ed827862e762f9d748
7
- data.tar.gz: 9a194d8df09c6c6eda97ef095d67dafd693b7ff386e612d926925bdbcf41b3b2a21c06862eff90525e39f85c7d8a5ded419bb8c4b4a3ecb33413c7ccdf47215e
6
+ metadata.gz: 19b67fb8ef13bac90538e8755905749427a7131bba5088c16f512b51d72833d80ee296ea7537b5122bb531a28d3c95c7924cd199dc6343ab17a1b3d2c391af9b
7
+ data.tar.gz: c65cb7780075ddea13c60b6c668b8a9a6d53627a8dbfa263f08694777ff10f1a3f3a98eeb2596a6497e0274a3a6d6aafc24a215ee6873c07485dc400444c0c17
data/CHANGELOG.md CHANGED
@@ -1,7 +1,19 @@
1
- ### main [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.40.6...main)]
1
+ ### main [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.42.0...main)]
2
2
 
3
3
  - xxx
4
4
 
5
+ ### 0.42.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.41.0...0.42.0)]
6
+
7
+ - Port Puppeteer v15.3-v15.5 features, including `Frame#page`
8
+
9
+ ### 0.41.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.40.7...0.41.0)]
10
+
11
+ - Port Puppeteer v14.0-v15.2 features, including `ElementHandle#wait_for_xpath`
12
+
13
+ ### 0.40.7 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.40.6...0.40.7)]
14
+
15
+ - Port Puppeteer v13.6-v13.7 features.
16
+
5
17
  ### 0.40.6 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.40.5...0.40.6)]
6
18
 
7
19
  - Port Puppeteer v13.1-v13.5 features mainly for request interception.
data/README.md CHANGED
@@ -229,6 +229,13 @@ end
229
229
 
230
230
  https://yusukeiwaki.github.io/puppeteer-ruby-docs/
231
231
 
232
+ ## Limitations
233
+
234
+ ### Not compatible with Firefox >= v97.0
235
+
236
+ :sos: Help and contribution wanted! :sos:
237
+ https://github.com/YusukeIwaki/puppeteer-ruby/issues/220
238
+
232
239
  ## Contributing
233
240
 
234
241
  Bug reports and pull requests are welcome on GitHub at https://github.com/YusukeIwaki/puppeteer-ruby.
data/docs/api_coverage.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # API coverages
2
- - Puppeteer version: v13.5.2
3
- - puppeteer-ruby version: 0.40.6
2
+ - Puppeteer version: v15.5.0
3
+ - puppeteer-ruby version: 0.42.0
4
4
 
5
5
  ## Puppeteer
6
6
 
@@ -14,20 +14,12 @@
14
14
  * executablePath => `#executable_path`
15
15
  * launch
16
16
  * networkConditions => `#network_conditions`
17
- * product
18
17
  * ~~registerCustomQueryHandler~~
19
18
  * ~~unregisterCustomQueryHandler~~
20
19
 
21
- ## ~~BrowserFetcher~~
20
+ ## ~~Accessibility~~
22
21
 
23
- * ~~canDownload~~
24
- * ~~download~~
25
- * ~~host~~
26
- * ~~localRevisions~~
27
- * ~~platform~~
28
- * ~~product~~
29
- * ~~remove~~
30
- * ~~revisionInfo~~
22
+ * ~~snapshot~~
31
23
 
32
24
  ## Browser
33
25
 
@@ -59,138 +51,55 @@
59
51
  * targets
60
52
  * waitForTarget => `#wait_for_target`
61
53
 
62
- ## Page
63
-
64
- * $ => `#query_selector`
65
- * $$ => `#query_selector_all`
66
- * $$eval => `#eval_on_selector_all`
67
- * $eval => `#eval_on_selector`
68
- * $x => `#Sx`
69
- * accessibility
70
- * addScriptTag => `#add_script_tag`
71
- * addStyleTag => `#add_style_tag`
72
- * authenticate
73
- * bringToFront => `#bring_to_front`
74
- * browser
75
- * browserContext => `#browser_context`
76
- * click
77
- * close
78
- * content
79
- * cookies
80
- * coverage
81
- * createPDFStream => `#create_pdf_stream`
82
- * deleteCookie => `#delete_cookie`
83
- * emulate
84
- * emulateCPUThrottling => `#emulate_cpu_throttling`
85
- * emulateIdleState => `#emulate_idle_state`
86
- * emulateMediaFeatures => `#emulate_media_features`
87
- * emulateMediaType => `#emulate_media_type`
88
- * emulateNetworkConditions => `#emulate_network_conditions`
89
- * emulateTimezone => `#emulate_timezone`
90
- * emulateVisionDeficiency => `#emulate_vision_deficiency`
91
- * evaluate
92
- * evaluateHandle => `#evaluate_handle`
93
- * evaluateOnNewDocument => `#evaluate_on_new_document`
94
- * exposeFunction => `#expose_function`
95
- * focus
96
- * frames
97
- * goBack => `#go_back`
98
- * goForward => `#go_forward`
99
- * goto
100
- * hover
101
- * isClosed => `#closed?`
102
- * isDragInterceptionEnabled => `#drag_interception_enabled?`
103
- * isJavaScriptEnabled => `#javascript_enabled?`
104
- * keyboard
105
- * mainFrame => `#main_frame`
106
- * metrics
107
- * mouse
108
- * pdf
109
- * queryObjects => `#query_objects`
110
- * reload
111
- * screenshot
112
- * select
113
- * setBypassCSP => `#bypass_csp=`
114
- * setCacheEnabled => `#cache_enabled=`
115
- * setContent => `#content=`
116
- * setCookie => `#set_cookie`
117
- * setDefaultNavigationTimeout => `#default_navigation_timeout=`
118
- * setDefaultTimeout => `#default_timeout=`
119
- * ~~setDragInterception~~
120
- * setExtraHTTPHeaders => `#extra_http_headers=`
121
- * setGeolocation => `#geolocation=`
122
- * setJavaScriptEnabled => `#javascript_enabled=`
123
- * setOfflineMode => `#offline_mode=`
124
- * setRequestInterception => `#request_interception=`
125
- * setUserAgent => `#user_agent=`
126
- * setViewport => `#viewport=`
127
- * tap
128
- * target
129
- * title
130
- * ~~touchscreen~~
131
- * tracing
132
- * type => `#type_text`
133
- * url
134
- * viewport
135
- * ~~waitFor~~
136
- * waitForFileChooser => `#wait_for_file_chooser`
137
- * waitForFrame => `#wait_for_frame`
138
- * waitForFunction => `#wait_for_function`
139
- * waitForNavigation => `#wait_for_navigation`
140
- * ~~waitForNetworkIdle~~
141
- * waitForRequest => `#wait_for_request`
142
- * waitForResponse => `#wait_for_response`
143
- * waitForSelector => `#wait_for_selector`
144
- * waitForTimeout => `#wait_for_timeout`
145
- * waitForXPath => `#wait_for_xpath`
146
- * workers
147
-
148
- ## ~~WebWorker~~
54
+ ## ~~BrowserFetcher~~
149
55
 
150
- * ~~evaluate~~
151
- * ~~evaluateHandle~~
152
- * ~~executionContext~~
153
- * ~~url~~
56
+ * ~~canDownload~~
57
+ * ~~download~~
58
+ * ~~host~~
59
+ * ~~localRevisions~~
60
+ * ~~platform~~
61
+ * ~~product~~
62
+ * ~~remove~~
63
+ * ~~revisionInfo~~
154
64
 
155
- ## ~~Accessibility~~
65
+ ## CDPSession
156
66
 
157
- * ~~snapshot~~
67
+ * connection
68
+ * detach
69
+ * id
70
+ * send
158
71
 
159
- ## Keyboard
72
+ ## Connection
160
73
 
161
- * down
162
- * press
163
- * sendCharacter => `#send_character`
164
- * type => `#type_text`
165
- * up
74
+ * createSession => `#create_session`
75
+ * dispose
76
+ * ~~fromSession~~
77
+ * send
78
+ * session
79
+ * url
166
80
 
167
- ## Mouse
81
+ ## ConsoleMessage
168
82
 
169
- * click
170
- * down
171
- * drag
172
- * dragAndDrop => `#drag_and_drop`
173
- * dragEnter => `#drag_enter`
174
- * dragOver => `#drag_over`
175
- * drop
176
- * move
177
- * up
178
- * wheel
83
+ * args
84
+ * location
85
+ * stackTrace => `#stack_trace`
86
+ * text
87
+ * ~~type~~
179
88
 
180
- ## ~~Touchscreen~~
89
+ ## Coverage
181
90
 
182
- * ~~tap~~
91
+ * startCSSCoverage => `#start_css_coverage`
92
+ * startJSCoverage => `#start_js_coverage`
93
+ * stopCSSCoverage => `#stop_css_coverage`
94
+ * stopJSCoverage => `#stop_js_coverage`
183
95
 
184
- ## Tracing
96
+ ## CSSCoverage
185
97
 
186
98
  * start
187
99
  * stop
188
100
 
189
- ## FileChooser
101
+ ## ~~CustomError~~
190
102
 
191
- * accept
192
- * cancel
193
- * isMultiple => `#multiple?`
194
103
 
195
104
  ## Dialog
196
105
 
@@ -200,49 +109,47 @@
200
109
  * message
201
110
  * type
202
111
 
203
- ## ConsoleMessage
204
-
205
- * args
206
- * location
207
- * stackTrace => `#stack_trace`
208
- * text
209
- * ~~type~~
210
-
211
- ## Frame
112
+ ## ElementHandle
212
113
 
213
114
  * $ => `#query_selector`
214
115
  * $$ => `#query_selector_all`
215
116
  * $$eval => `#eval_on_selector_all`
216
117
  * $eval => `#eval_on_selector`
217
118
  * $x => `#Sx`
218
- * addScriptTag => `#add_script_tag`
219
- * addStyleTag => `#add_style_tag`
220
- * childFrames => `#child_frames`
119
+ * asElement => `#as_element`
120
+ * boundingBox => `#bounding_box`
121
+ * boxModel => `#box_model`
221
122
  * click
222
- * content
223
- * evaluate
224
- * evaluateHandle => `#evaluate_handle`
225
- * executionContext => `#execution_context`
123
+ * clickablePoint => `#clickable_point`
124
+ * contentFrame => `#content_frame`
125
+ * drag
126
+ * dragAndDrop => `#drag_and_drop`
127
+ * dragEnter => `#drag_enter`
128
+ * dragOver => `#drag_over`
129
+ * drop
226
130
  * focus
227
- * goto
228
131
  * hover
229
- * isDetached => `#detached?`
230
- * isOOPFrame => `#oop_frame?`
231
- * name
232
- * parentFrame => `#parent_frame`
132
+ * isIntersectingViewport => `#intersecting_viewport?`
133
+ * press
134
+ * screenshot
233
135
  * select
234
- * setContent => `#set_content`
235
136
  * tap
236
- * title
237
137
  * type => `#type_text`
238
- * url
239
- * ~~waitFor~~
240
- * waitForFunction => `#wait_for_function`
241
- * waitForNavigation => `#wait_for_navigation`
138
+ * uploadFile => `#upload_file`
242
139
  * waitForSelector => `#wait_for_selector`
243
- * waitForTimeout => `#wait_for_timeout`
244
140
  * waitForXPath => `#wait_for_xpath`
245
141
 
142
+ ## ~~EventEmitter~~
143
+
144
+ * ~~addListener~~
145
+ * ~~emit~~
146
+ * ~~listenerCount~~
147
+ * ~~off~~
148
+ * ~~on~~
149
+ * ~~once~~
150
+ * ~~removeAllListeners~~
151
+ * ~~removeListener~~
152
+
246
153
  ## ExecutionContext
247
154
 
248
155
  * evaluate
@@ -250,53 +157,46 @@
250
157
  * frame
251
158
  * ~~queryObjects~~
252
159
 
253
- ## JSHandle
160
+ ## FileChooser
254
161
 
255
- * asElement => `#as_element`
256
- * dispose
257
- * evaluate
258
- * evaluateHandle => `#evaluate_handle`
259
- * executionContext => `#execution_context`
260
- * getProperties => `#properties`
261
- * getProperty => `#[]`
262
- * jsonValue => `#json_value`
162
+ * accept
163
+ * cancel
164
+ * isMultiple => `#multiple?`
263
165
 
264
- ## ElementHandle
166
+ ## Frame
265
167
 
266
168
  * $ => `#query_selector`
267
169
  * $$ => `#query_selector_all`
268
170
  * $$eval => `#eval_on_selector_all`
269
171
  * $eval => `#eval_on_selector`
270
172
  * $x => `#Sx`
271
- * asElement => `#as_element`
272
- * boundingBox => `#bounding_box`
273
- * boxModel => `#box_model`
173
+ * addScriptTag => `#add_script_tag`
174
+ * addStyleTag => `#add_style_tag`
175
+ * childFrames => `#child_frames`
274
176
  * click
275
- * clickablePoint => `#clickable_point`
276
- * contentFrame => `#content_frame`
277
- * dispose
278
- * drag
279
- * dragAndDrop => `#drag_and_drop`
280
- * dragEnter => `#drag_enter`
281
- * dragOver => `#drag_over`
282
- * drop
177
+ * content
283
178
  * evaluate
284
179
  * evaluateHandle => `#evaluate_handle`
285
180
  * executionContext => `#execution_context`
286
181
  * focus
287
- * getProperties => `#properties`
288
- * getProperty => `#[]`
182
+ * goto
289
183
  * hover
290
- * isIntersectingViewport => `#intersecting_viewport?`
291
- * jsonValue => `#json_value`
292
- * press
293
- * screenshot
184
+ * isDetached => `#detached?`
185
+ * isOOPFrame => `#oop_frame?`
186
+ * name
187
+ * page
188
+ * parentFrame => `#parent_frame`
294
189
  * select
190
+ * setContent => `#set_content`
295
191
  * tap
296
- * ~~toString~~
192
+ * title
297
193
  * type => `#type_text`
298
- * uploadFile => `#upload_file`
194
+ * url
195
+ * waitForFunction => `#wait_for_function`
196
+ * waitForNavigation => `#wait_for_navigation`
299
197
  * waitForSelector => `#wait_for_selector`
198
+ * waitForTimeout => `#wait_for_timeout`
199
+ * waitForXPath => `#wait_for_xpath`
300
200
 
301
201
  ## HTTPRequest
302
202
 
@@ -340,6 +240,131 @@
340
240
  * ~~timing~~
341
241
  * url
342
242
 
243
+ ## JSCoverage
244
+
245
+ * start
246
+ * stop
247
+
248
+ ## JSHandle
249
+
250
+ * asElement => `#as_element`
251
+ * dispose
252
+ * evaluate
253
+ * evaluateHandle => `#evaluate_handle`
254
+ * executionContext => `#execution_context`
255
+ * getProperties => `#properties`
256
+ * getProperty => `#[]`
257
+ * getProperty => `#[]`
258
+ * jsonValue => `#json_value`
259
+ * remoteObject => `#remote_object`
260
+ * ~~toString~~
261
+
262
+ ## Keyboard
263
+
264
+ * down
265
+ * press
266
+ * sendCharacter => `#send_character`
267
+ * type => `#type_text`
268
+ * up
269
+
270
+ ## Mouse
271
+
272
+ * click
273
+ * down
274
+ * drag
275
+ * dragAndDrop => `#drag_and_drop`
276
+ * dragEnter => `#drag_enter`
277
+ * dragOver => `#drag_over`
278
+ * drop
279
+ * move
280
+ * up
281
+ * wheel
282
+
283
+ ## Page
284
+
285
+ * $ => `#query_selector`
286
+ * $$ => `#query_selector_all`
287
+ * $$eval => `#eval_on_selector_all`
288
+ * $eval => `#eval_on_selector`
289
+ * $x => `#Sx`
290
+ * addScriptTag => `#add_script_tag`
291
+ * addStyleTag => `#add_style_tag`
292
+ * authenticate
293
+ * bringToFront => `#bring_to_front`
294
+ * browser
295
+ * browserContext => `#browser_context`
296
+ * click
297
+ * close
298
+ * content
299
+ * cookies
300
+ * createPDFStream => `#create_pdf_stream`
301
+ * deleteCookie => `#delete_cookie`
302
+ * emulate
303
+ * emulateCPUThrottling => `#emulate_cpu_throttling`
304
+ * emulateIdleState => `#emulate_idle_state`
305
+ * emulateMediaFeatures => `#emulate_media_features`
306
+ * emulateMediaType => `#emulate_media_type`
307
+ * emulateNetworkConditions => `#emulate_network_conditions`
308
+ * emulateTimezone => `#emulate_timezone`
309
+ * emulateVisionDeficiency => `#emulate_vision_deficiency`
310
+ * evaluate
311
+ * evaluateHandle => `#evaluate_handle`
312
+ * evaluateOnNewDocument => `#evaluate_on_new_document`
313
+ * exposeFunction => `#expose_function`
314
+ * focus
315
+ * frames
316
+ * goBack => `#go_back`
317
+ * goForward => `#go_forward`
318
+ * goto
319
+ * hover
320
+ * isClosed => `#closed?`
321
+ * isDragInterceptionEnabled => `#drag_interception_enabled?`
322
+ * isJavaScriptEnabled => `#javascript_enabled?`
323
+ * mainFrame => `#main_frame`
324
+ * metrics
325
+ * ~~off~~
326
+ * on
327
+ * once
328
+ * pdf
329
+ * queryObjects => `#query_objects`
330
+ * reload
331
+ * screenshot
332
+ * select
333
+ * setBypassCSP => `#bypass_csp=`
334
+ * setCacheEnabled => `#cache_enabled=`
335
+ * setContent => `#content=`
336
+ * setCookie => `#set_cookie`
337
+ * setDefaultNavigationTimeout => `#default_navigation_timeout=`
338
+ * setDefaultTimeout => `#default_timeout=`
339
+ * ~~setDragInterception~~
340
+ * setExtraHTTPHeaders => `#extra_http_headers=`
341
+ * setGeolocation => `#geolocation=`
342
+ * setJavaScriptEnabled => `#javascript_enabled=`
343
+ * setOfflineMode => `#offline_mode=`
344
+ * setRequestInterception => `#request_interception=`
345
+ * setUserAgent => `#user_agent=`
346
+ * setViewport => `#viewport=`
347
+ * tap
348
+ * target
349
+ * title
350
+ * type => `#type_text`
351
+ * url
352
+ * viewport
353
+ * waitForFileChooser => `#wait_for_file_chooser`
354
+ * waitForFrame => `#wait_for_frame`
355
+ * waitForFunction => `#wait_for_function`
356
+ * waitForNavigation => `#wait_for_navigation`
357
+ * ~~waitForNetworkIdle~~
358
+ * waitForRequest => `#wait_for_request`
359
+ * waitForResponse => `#wait_for_response`
360
+ * waitForSelector => `#wait_for_selector`
361
+ * waitForTimeout => `#wait_for_timeout`
362
+ * waitForXPath => `#wait_for_xpath`
363
+ * workers
364
+
365
+ ## ~~ProtocolError~~
366
+
367
+
343
368
  ## ~~SecurityDetails~~
344
369
 
345
370
  * ~~issuer~~
@@ -360,30 +385,21 @@
360
385
  * url
361
386
  * ~~worker~~
362
387
 
363
- ## CDPSession
388
+ ## TimeoutError
364
389
 
365
- * connection
366
- * detach
367
- * id
368
- * send
369
390
 
370
- ## Coverage
391
+ ## ~~Touchscreen~~
371
392
 
372
- * startCSSCoverage => `#start_css_coverage`
373
- * startJSCoverage => `#start_js_coverage`
374
- * stopCSSCoverage => `#stop_css_coverage`
375
- * stopJSCoverage => `#stop_js_coverage`
393
+ * ~~tap~~
376
394
 
377
- ## TimeoutError
395
+ ## Tracing
378
396
 
397
+ * start
398
+ * stop
379
399
 
380
- ## ~~EventEmitter~~
400
+ ## ~~WebWorker~~
381
401
 
382
- * ~~addListener~~
383
- * ~~emit~~
384
- * ~~listenerCount~~
385
- * ~~off~~
386
- * ~~on~~
387
- * ~~once~~
388
- * ~~removeAllListeners~~
389
- * ~~removeListener~~
402
+ * ~~evaluate~~
403
+ * ~~evaluateHandle~~
404
+ * ~~executionContext~~
405
+ * ~~url~~
@@ -13,7 +13,14 @@ class Puppeteer::Browser
13
13
  # @param {?Puppeteer.Viewport} defaultViewport
14
14
  # @param process [Puppeteer::BrowserRunner::BrowserProcess|NilClass]
15
15
  # @param {function()=} closeCallback
16
- def self.create(connection:, context_ids:, ignore_https_errors:, default_viewport:, process:, close_callback:)
16
+ def self.create(connection:,
17
+ context_ids:,
18
+ ignore_https_errors:,
19
+ default_viewport:,
20
+ process:,
21
+ close_callback:,
22
+ target_filter_callback:,
23
+ is_page_target_callback:)
17
24
  browser = Puppeteer::Browser.new(
18
25
  connection: connection,
19
26
  context_ids: context_ids,
@@ -21,6 +28,8 @@ class Puppeteer::Browser
21
28
  default_viewport: default_viewport,
22
29
  process: process,
23
30
  close_callback: close_callback,
31
+ target_filter_callback: target_filter_callback,
32
+ is_page_target_callback: is_page_target_callback,
24
33
  )
25
34
  connection.send_message('Target.setDiscoverTargets', discover: true)
26
35
  browser
@@ -32,12 +41,21 @@ class Puppeteer::Browser
32
41
  # @param {?Puppeteer.Viewport} defaultViewport
33
42
  # @param {?Puppeteer.ChildProcess} process
34
43
  # @param {(function():Promise)=} closeCallback
35
- def initialize(connection:, context_ids:, ignore_https_errors:, default_viewport:, process:, close_callback:)
44
+ def initialize(connection:,
45
+ context_ids:,
46
+ ignore_https_errors:,
47
+ default_viewport:,
48
+ process:,
49
+ close_callback:,
50
+ target_filter_callback:,
51
+ is_page_target_callback:)
36
52
  @ignore_https_errors = ignore_https_errors
37
53
  @default_viewport = default_viewport
38
54
  @process = process
39
55
  @connection = connection
40
56
  @close_callback = close_callback
57
+ @target_filter_callback = target_filter_callback || method(:default_target_filter_callback)
58
+ @is_page_target_callback = is_page_target_callback || method(:default_is_page_target_callback)
41
59
 
42
60
  @default_context = Puppeteer::BrowserContext.new(@connection, self, nil)
43
61
  @contexts = {}
@@ -54,6 +72,16 @@ class Puppeteer::Browser
54
72
  @connection.on_event('Target.targetInfoChanged', &method(:handle_target_info_changed))
55
73
  end
56
74
 
75
+ private def default_target_filter_callback(target_info)
76
+ true
77
+ end
78
+
79
+ private def default_is_page_target_callback(target_info)
80
+ ['page', 'background_page', 'webview'].include?(target_info.type)
81
+ end
82
+
83
+ attr_reader :is_page_target_callback
84
+
57
85
  # @param event_name [Symbol] either of :disconnected, :targetcreated, :targetchanged, :targetdestroyed
58
86
  def on(event_name, &block)
59
87
  unless BrowserEmittedEvents.values.include?(event_name.to_s)
@@ -119,12 +147,16 @@ class Puppeteer::Browser
119
147
  if @targets[target_info.target_id]
120
148
  raise TargetAlreadyExistError.new
121
149
  end
150
+
151
+ return unless @target_filter_callback.call(target_info)
152
+
122
153
  target = Puppeteer::Target.new(
123
154
  target_info: target_info,
124
155
  browser_context: context,
125
156
  session_factory: -> { @connection.create_session(target_info) },
126
157
  ignore_https_errors: @ignore_https_errors,
127
158
  default_viewport: @default_viewport,
159
+ is_page_target_callback: @is_page_target_callback,
128
160
  )
129
161
  @targets[target_info.target_id] = target
130
162
  if_present(@wait_for_creating_targets.delete(target_info.target_id)) do |promise|
@@ -50,7 +50,9 @@ class Puppeteer::BrowserContext
50
50
 
51
51
  # @return {!Promise<!Array<!Puppeteer.Page>>}
52
52
  def pages
53
- targets.select { |target| target.type == 'page' }.map(&:page).reject { |page| !page }
53
+ targets.select { |target|
54
+ target.type == 'page' || (target.type == 'other' && @browser.is_page_target_callback&.call(target.target_info))
55
+ }.map(&:page).reject { |page| !page }
54
56
  end
55
57
 
56
58
  def incognito?
@@ -128,7 +128,7 @@ class Puppeteer::BrowserRunner
128
128
  def close
129
129
  return if @closed
130
130
 
131
- if @using_temp_user_data_dir && !@for_firefox
131
+ if @using_temp_user_data_dir
132
132
  kill
133
133
  elsif @connection
134
134
  begin
@@ -191,6 +191,7 @@ class Puppeteer::Connection
191
191
  'Network.responseReceived',
192
192
  'Network.responseReceivedExtraInfo',
193
193
  'Page.lifecycleEvent',
194
+ 'Target.receivedMessageFromTarget', # only Firefox
194
195
  ]
195
196
 
196
197
  def handle_message(message)