4
4
5
5
module Ferrum
6
6
class Contexts
7
+ ALLOWED_TARGET_TYPES = %w[ page iframe ] . freeze
8
+
7
9
include Enumerable
8
10
9
11
attr_reader :contexts
@@ -71,7 +73,7 @@ def size
71
73
def subscribe
72
74
@client . on ( "Target.attachedToTarget" ) do |params |
73
75
info , session_id = params . values_at ( "targetInfo" , "sessionId" )
74
- next unless %w[ page iframe ] . include? ( info [ "type" ] )
76
+ next unless ALLOWED_TARGET_TYPES . include? ( info [ "type" ] )
75
77
76
78
context_id = info [ "browserContextId" ]
77
79
@contexts [ context_id ] &.add_target ( session_id : session_id , params : info )
@@ -82,7 +84,7 @@ def subscribe
82
84
83
85
@client . on ( "Target.targetCreated" ) do |params |
84
86
info = params [ "targetInfo" ]
85
- next unless %w[ page iframe ] . include? ( info [ "type" ] )
87
+ next unless ALLOWED_TARGET_TYPES . include? ( info [ "type" ] )
86
88
87
89
context_id = info [ "browserContextId" ]
88
90
@@ -96,7 +98,7 @@ def subscribe
96
98
97
99
@client . on ( "Target.targetInfoChanged" ) do |params |
98
100
info = params [ "targetInfo" ]
99
- next unless %w[ page iframe ] . include? ( info [ "type" ] )
101
+ next unless ALLOWED_TARGET_TYPES . include? ( info [ "type" ] )
100
102
101
103
context_id , target_id = info . values_at ( "browserContextId" , "targetId" )
102
104
@contexts [ context_id ] &.update_target ( target_id , info )
0 commit comments