Skip to content

Commit eb3f378

Browse files
committed
Improve types and hash consistency
1 parent 0515131 commit eb3f378

File tree

14 files changed

+166
-73
lines changed

14 files changed

+166
-73
lines changed

rb/lib/selenium/webdriver/bidi/network.rb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,41 +55,41 @@ def remove_intercept(intercept)
5555
def continue_with_auth(request_id, username, password)
5656
@bidi.send_cmd(
5757
'network.continueWithAuth',
58-
'request' => request_id,
59-
'action' => 'provideCredentials',
60-
'credentials' => {
61-
'type' => 'password',
62-
'username' => username,
63-
'password' => password
58+
request: request_id,
59+
action: 'provideCredentials',
60+
credentials: {
61+
type: 'password',
62+
username: username,
63+
password: password
6464
}
6565
)
6666
end
6767

6868
def continue_without_auth(request_id)
6969
@bidi.send_cmd(
7070
'network.continueWithAuth',
71-
'request' => request_id,
72-
'action' => 'default'
71+
request: request_id,
72+
action: 'default'
7373
)
7474
end
7575

7676
def cancel_auth(request_id)
7777
@bidi.send_cmd(
7878
'network.continueWithAuth',
79-
'request' => request_id,
80-
'action' => 'cancel'
79+
request: request_id,
80+
action: 'cancel'
8181
)
8282
end
8383

8484
def continue_request(**args)
8585
@bidi.send_cmd(
8686
'network.continueRequest',
8787
request: args[:id],
88-
'body' => args[:body],
89-
'cookies' => args[:cookies],
90-
'headers' => args[:headers],
91-
'method' => args[:method],
92-
'url' => args[:url]
88+
body: args[:body],
89+
cookies: args[:cookies],
90+
headers: args[:headers],
91+
method: args[:method],
92+
url: args[:url]
9393
)
9494
end
9595

@@ -104,11 +104,11 @@ def continue_response(**args)
104104
@bidi.send_cmd(
105105
'network.continueResponse',
106106
request: args[:id],
107-
'cookies' => args[:cookies],
108-
'credentials' => args[:credentials],
109-
'headers' => args[:headers],
110-
'reasonPhrase' => args[:reason],
111-
'statusCode' => args[:status]
107+
cookies: args[:cookies],
108+
credentials: args[:credentials],
109+
headers: args[:headers],
110+
reasonPhrase: args[:reason],
111+
statusCode: args[:status]
112112
)
113113
end
114114

rb/lib/selenium/webdriver/bidi/network/cookies.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,32 @@ class BiDi
2323
module Cookies
2424
def add_cookie(name, value)
2525
cookies.push(
26-
'name' => name,
27-
'value' => {
28-
'type' => 'string',
29-
'value' => value
26+
name: name,
27+
value: {
28+
type: 'string',
29+
value: value
3030
}
3131
)
3232
end
3333

3434
def remove_cookie(name)
35-
cookies.delete_if { |cookie| cookie['name'] == name }
35+
cookies.delete_if { |cookie| cookie[:name] == name }
3636
end
3737

3838
def set_cookie_header(**args)
3939
cookies.push(
40-
'name' => args[:name],
41-
'value' => {
42-
'type' => 'string',
43-
'value' => 'input'
40+
name: args[:name],
41+
value: {
42+
type: 'string',
43+
value: 'input'
4444
},
45-
'domain' => args[:domain],
46-
'httpOnly' => args[:http_only],
47-
'expiry' => args[:expiry],
48-
'maxAge' => args[:max_age],
49-
'path' => args[:path],
50-
'sameSite' => args[:same_site],
51-
'secure' => args[:secure]
45+
domain: args[:domain],
46+
httpOnly: args[:http_only],
47+
expiry: args[:expiry],
48+
maxAge: args[:max_age],
49+
path: args[:path],
50+
sameSite: args[:same_site],
51+
secure: args[:secure]
5252
)
5353
end
5454
end

rb/lib/selenium/webdriver/bidi/network/headers.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ class BiDi
2323
module Headers
2424
def add_header(name, value)
2525
headers.push(
26-
'name' => name,
27-
'value' => {
28-
'type' => 'string',
29-
'value' => value
26+
name: name,
27+
value: {
28+
type: 'string',
29+
value: value
3030
}
3131
)
3232
end
3333

3434
def remove_header(name)
35-
headers.delete_if { |header| header['name'] == name }
35+
headers.delete_if { |header| header[:name] == name }
3636
end
3737
end
3838
end # BiDi

rb/lib/selenium/webdriver/bidi/network/intercepted_request.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def fail
4949

5050
def body=(value)
5151
@body = {
52-
'type' => 'string',
53-
'value' => value.to_json
52+
type: 'string',
53+
value: value.to_json
5454
}
5555
end
5656
end

rb/lib/selenium/webdriver/bidi/network/intercepted_response.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def continue
4444

4545
def add_credentials(username, password)
4646
@credentials = {
47-
'type' => 'password',
48-
'username' => username,
49-
'password' => password
47+
type: 'password',
48+
username: username,
49+
password: password
5050
}
5151
end
5252
end

rb/sig/lib/selenium/webdriver/bidi/network.rbs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ module Selenium
1010

1111
def initialize: (BiDi bidi) -> void
1212

13-
def add_intercept: (?phases: Array[String], ?contexts: BrowsingContext?, ?url_patterns: untyped?) -> Hash[String, String]
13+
def add_intercept: (?phases: Array[String], ?contexts: BrowsingContext?, ?url_patterns: String | Array[String]?) -> Hash[String, String]
1414

15-
def cancel_auth: -> untyped
15+
def cancel_auth: -> Hash[nil, nil]
1616

17-
def continue_request: -> untyped
17+
def continue_request: -> Hash[nil, nil]
1818

19-
def continue_response: -> untyped
19+
def continue_response: -> Hash[nil, nil]
2020

21-
def continue_without_auth: -> untyped
21+
def continue_without_auth: -> Hash[nil, nil]
2222

23-
def fail_request: -> untyped
23+
def fail_request: -> Hash[nil, nil]
2424

25-
def remove_intercept: (String intercept) -> untyped
25+
def remove_intercept: (String intercept) -> Hash[nil, nil]
2626

27-
def continue_with_auth: (String request_id, String username, String password) -> untyped
27+
def continue_with_auth: (String request_id, String username, String password) -> Hash[nil, nil]
2828

29-
def on: (Symbol event) { (?) -> untyped } -> untyped
29+
def on: (Symbol event) { (?) -> untyped } -> Hash[nil, nil]
3030
end
3131
end
3232
end

rb/sig/lib/selenium/webdriver/bidi/network/cookies.rbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ module Selenium
22
module WebDriver
33
class BiDi
44
module Cookies
5-
def add_cookie: (untyped name, untyped value) -> untyped
5+
def add_cookie: (String name, String value) -> Array[Hash[Symbol, String]]
66

7-
def remove_cookie: (untyped name) -> untyped
7+
def remove_cookie: (String name) -> Array[Hash[Symbol, String]]
88

9-
def set_cookie_header: (**untyped args) -> untyped
9+
def set_cookie_header: (**Hash[Symbol, String | bool | Numeric] args) -> Array[Hash[Symbol, String | bool | Numeric]]
1010
end
1111
end
1212
end

rb/sig/lib/selenium/webdriver/bidi/network/headers.rbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ module Selenium
22
module WebDriver
33
class BiDi
44
module Headers
5-
def add_header: (untyped name, untyped value) -> untyped
5+
def add_header: (String name, String value) -> Array[Hash[Symbol, String]]
66

7-
def remove_header: (untyped name) -> untyped
7+
def remove_header: (String name) -> Array[Hash[Symbol, String]]
88
end
99
end
1010
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module Selenium
2+
module WebDriver
3+
class BiDi
4+
class InterceptedItem
5+
@network: untyped
6+
7+
@request: untyped
8+
9+
@id: untyped
10+
11+
attr_reader network: untyped
12+
13+
attr_reader request: untyped
14+
15+
def initialize: (untyped network, untyped request) -> void
16+
17+
def id: () -> untyped
18+
end
19+
end
20+
end
21+
end
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module Selenium
2+
module WebDriver
3+
class BiDi
4+
class InterceptedRequest < InterceptedItem
5+
@body: untyped
6+
7+
@cookies: untyped
8+
9+
@headers: untyped
10+
11+
@method: untyped
12+
13+
@url: untyped
14+
15+
include Cookies
16+
17+
include Headers
18+
19+
attr_accessor cookies: untyped
20+
21+
attr_accessor headers: untyped
22+
23+
attr_accessor method: untyped
24+
25+
attr_accessor url: untyped
26+
27+
attr_reader body: untyped
28+
29+
def initialize: (untyped network, untyped request) -> void
30+
31+
def continue: () -> untyped
32+
33+
def fail: () -> untyped
34+
35+
def body=: (untyped value) -> untyped
36+
end
37+
end
38+
end
39+
end

0 commit comments

Comments
 (0)