File tree 1 file changed +42
-1
lines changed
1 file changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -685,6 +685,28 @@ def puts result
685
685
end
686
686
687
687
class Session
688
+ # FIXME: unify this method with ThreadClient#propertyDescriptor.
689
+ def get_type obj
690
+ case obj
691
+ when Array
692
+ [ 'object' , 'array' ]
693
+ when Hash
694
+ [ 'object' , 'map' ]
695
+ when String
696
+ [ 'string' ]
697
+ when TrueClass , FalseClass
698
+ [ 'boolean' ]
699
+ when Symbol
700
+ [ 'symbol' ]
701
+ when Integer , Float
702
+ [ 'number' ]
703
+ when Exception
704
+ [ 'object' , 'error' ]
705
+ else
706
+ [ 'object' ]
707
+ end
708
+ end
709
+
688
710
def fail_response req , **result
689
711
@ui . respond_fail req , **result
690
712
return :retry
@@ -716,9 +738,28 @@ def process_protocol_request req
716
738
frame_id = ref [ 1 ]
717
739
fid = @frame_map [ frame_id ]
718
740
request_tc [ :cdp , :scope , req , fid ]
741
+ when 'global'
742
+ vars = global_variables . sort . map do |name |
743
+ gv = eval ( name . to_s )
744
+ prop = {
745
+ name : name ,
746
+ value : {
747
+ description : gv . inspect
748
+ } ,
749
+ configurable : true ,
750
+ enumerable : true
751
+ }
752
+ type , subtype = get_type ( gv )
753
+ prop [ :value ] [ :type ] = type
754
+ prop [ :value ] [ :subtype ] = subtype if subtype
755
+ prop
756
+ end
757
+
758
+ @ui . respond req , result : vars
759
+ return :retry
719
760
when 'properties'
720
761
request_tc [ :cdp , :properties , req , oid ]
721
- when 'script' , 'global'
762
+ when 'script'
722
763
# TODO: Support script and global types
723
764
@ui . respond req , result : [ ]
724
765
return :retry
You can’t perform that action at this time.
0 commit comments