1616# KIND, either express or implied.  See the License for the 
1717# specific language governing permissions and limitations 
1818# under the License. 
19+ require_relative  'network/url_pattern' 
1920
2021module  Selenium 
2122  module  WebDriver 
@@ -39,8 +40,12 @@ def initialize(bidi)
3940          @bidi  =  bidi 
4041        end 
4142
42-         def  add_intercept ( phases : [ ] ,  contexts : nil ,  url_patterns : nil ) 
43-           @bidi . send_cmd ( 'network.addIntercept' ,  phases : phases ,  contexts : contexts ,  urlPatterns : url_patterns ) 
43+         def  add_intercept ( phases : [ ] ,  contexts : nil ,  url_patterns : nil ,  pattern_type : :string ) 
44+           url_patterns  =  url_patterns  && pattern_type  ? UrlPattern . format_pattern ( url_patterns ,  pattern_type )  : nil 
45+           @bidi . send_cmd ( 'network.addIntercept' , 
46+                          phases : phases , 
47+                          contexts : contexts , 
48+                          urlPatterns : url_patterns ) 
4449        end 
4550
4651        def  remove_intercept ( intercept ) 
@@ -50,31 +55,67 @@ def remove_intercept(intercept)
5055        def  continue_with_auth ( request_id ,  username ,  password ) 
5156          @bidi . send_cmd ( 
5257            'network.continueWithAuth' , 
53-             ' request'   =>  request_id , 
54-             ' action'   =>  'provideCredentials' , 
55-             ' credentials'   =>  { 
56-               ' type'   =>  'password' , 
57-               ' username'   =>  username , 
58-               ' password'   =>  password 
58+             request :  request_id , 
59+             action :  'provideCredentials' , 
60+             credentials :  { 
61+               type :  'password' , 
62+               username :  username , 
63+               password :  password 
5964            } 
6065          ) 
6166        end 
6267
63-         def  continue_with_request ( ** args ) 
68+         def  continue_without_auth ( request_id ) 
6469          @bidi . send_cmd ( 
65-             'network.continueWithRequest' , 
66-             request : args [ :request_id ] , 
67-             'body'  =>  args [ :body ] , 
68-             'cookies'  =>  args [ :cookies ] , 
69-             'headers'  =>  args [ :headers ] , 
70-             'method'  =>  args [ :method ] , 
71-             'url'  =>  args [ :url ] 
70+             'network.continueWithAuth' , 
71+             request : request_id , 
72+             action : 'default' 
73+           ) 
74+         end 
75+ 
76+         def  cancel_auth ( request_id ) 
77+           @bidi . send_cmd ( 
78+             'network.continueWithAuth' , 
79+             request : request_id , 
80+             action : 'cancel' 
81+           ) 
82+         end 
83+ 
84+         def  continue_request ( **args ) 
85+           @bidi . send_cmd ( 
86+             'network.continueRequest' , 
87+             request : args [ :id ] , 
88+             body : args [ :body ] , 
89+             cookies : args [ :cookies ] , 
90+             headers : args [ :headers ] , 
91+             method : args [ :method ] , 
92+             url : args [ :url ] 
93+           ) 
94+         end 
95+ 
96+         def  fail_request ( request_id ) 
97+           @bidi . send_cmd ( 
98+             'network.failRequest' , 
99+             request : request_id 
100+           ) 
101+         end 
102+ 
103+         def  continue_response ( **args ) 
104+           @bidi . send_cmd ( 
105+             'network.continueResponse' , 
106+             request : args [ :id ] , 
107+             cookies : args [ :cookies ] , 
108+             credentials : args [ :credentials ] , 
109+             headers : args [ :headers ] , 
110+             reasonPhrase : args [ :reason ] , 
111+             statusCode : args [ :status ] 
72112          ) 
73113        end 
74114
75115        def  on ( event ,  &) 
76116          event  =  EVENTS [ event ]  if  event . is_a? ( Symbol ) 
77117          @bidi . add_callback ( event ,  &) 
118+           @bidi . session . subscribe ( event ) 
78119        end 
79120      end  # Network 
80121    end  # BiDi 
0 commit comments