44
55module Ferrum
66 class Contexts
7+ ALLOWED_TARGET_TYPES = %w[ page iframe ] . freeze
8+
79 include Enumerable
810
911 attr_reader :contexts
@@ -71,7 +73,7 @@ def size
7173 def subscribe
7274 @client . on ( "Target.attachedToTarget" ) do |params |
7375 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" ] )
7577
7678 context_id = info [ "browserContextId" ]
7779 @contexts [ context_id ] &.add_target ( session_id : session_id , params : info )
@@ -82,7 +84,7 @@ def subscribe
8284
8385 @client . on ( "Target.targetCreated" ) do |params |
8486 info = params [ "targetInfo" ]
85- next unless %w[ page iframe ] . include? ( info [ "type" ] )
87+ next unless ALLOWED_TARGET_TYPES . include? ( info [ "type" ] )
8688
8789 context_id = info [ "browserContextId" ]
8890
@@ -96,7 +98,7 @@ def subscribe
9698
9799 @client . on ( "Target.targetInfoChanged" ) do |params |
98100 info = params [ "targetInfo" ]
99- next unless %w[ page iframe ] . include? ( info [ "type" ] )
101+ next unless ALLOWED_TARGET_TYPES . include? ( info [ "type" ] )
100102
101103 context_id , target_id = info . values_at ( "browserContextId" , "targetId" )
102104 @contexts [ context_id ] &.update_target ( target_id , info )
0 commit comments