File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -75,8 +75,11 @@ def frames_subscribe
75
75
frame_id = params . dig ( "context" , "auxData" , "frameId" )
76
76
77
77
unless @main_frame . id
78
- @main_frame . id = frame_id
79
- @frames [ frame_id ] = @main_frame
78
+ root_frame = command ( 'Page.getFrameTree' ) . dig ( 'frameTree' , 'frame' , 'id' )
79
+ if frame_id == root_frame
80
+ @main_frame . id = frame_id
81
+ @frames [ frame_id ] = @main_frame
82
+ end
80
83
end
81
84
82
85
frame = @frames [ frame_id ] || Frame . new ( frame_id , self )
Original file line number Diff line number Diff line change @@ -27,6 +27,14 @@ module Ferrum
27
27
expect ( frame . url ) . to end_with ( "/ferrum/get_cookie" )
28
28
end
29
29
30
+ it 'finds main frame properly' do
31
+ browser . goto ( "/ferrum/popup_frames" )
32
+ browser . at_xpath ( "//a[text()='pop up']" ) . click
33
+ expect ( browser . pages . size ) . to eq ( 2 )
34
+ opened_page = browser . pages . last
35
+ expect ( opened_page . main_frame . url ) . to end_with ( "/frames" )
36
+ end
37
+
30
38
it "waits for the frame to load" do
31
39
browser . go_to
32
40
browser . execute <<-JS
Original file line number Diff line number Diff line change
1
+ < a href ="frames " target ="_blank "> pop up</ a >
You can’t perform that action at this time.
0 commit comments