Skip to content

Commit 5672000

Browse files
committed
Regenerate code & fix 1 failing test
1 parent 7abf594 commit 5672000

11 files changed

Lines changed: 702 additions & 18 deletions

cdp/background_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ServiceName(enum.Enum):
2727
BACKGROUND_SYNC = "backgroundSync"
2828
PUSH_MESSAGING = "pushMessaging"
2929
NOTIFICATIONS = "notifications"
30+
PAYMENT_HANDLER = "paymentHandler"
3031

3132
def to_json(self) -> str:
3233
return self.value

cdp/browser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ class PermissionType(enum.Enum):
109109
SENSORS = "sensors"
110110
VIDEO_CAPTURE = "videoCapture"
111111
IDLE_DETECTION = "idleDetection"
112+
WAKE_LOCK_SCREEN = "wakeLockScreen"
113+
WAKE_LOCK_SYSTEM = "wakeLockSystem"
112114

113115
def to_json(self) -> str:
114116
return self.value

cdp/dom_snapshot.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,13 +642,28 @@ class LayoutTreeSnapshot:
642642
#: Stacking context information.
643643
stacking_contexts: 'RareBooleanData'
644644

645+
#: The offset rect of nodes. Only available when includeDOMRects is set to true
646+
offset_rects: typing.Optional[typing.List['Rectangle']] = None
647+
648+
#: The scroll rect of nodes. Only available when includeDOMRects is set to true
649+
scroll_rects: typing.Optional[typing.List['Rectangle']] = None
650+
651+
#: The client rect of nodes. Only available when includeDOMRects is set to true
652+
client_rects: typing.Optional[typing.List['Rectangle']] = None
653+
645654
def to_json(self) -> T_JSON_DICT:
646655
json: T_JSON_DICT = dict()
647656
json['nodeIndex'] = [i for i in self.node_index]
648657
json['styles'] = [i.to_json() for i in self.styles]
649658
json['bounds'] = [i.to_json() for i in self.bounds]
650659
json['text'] = [i.to_json() for i in self.text]
651660
json['stackingContexts'] = self.stacking_contexts.to_json()
661+
if self.offset_rects is not None:
662+
json['offsetRects'] = [i.to_json() for i in self.offset_rects]
663+
if self.scroll_rects is not None:
664+
json['scrollRects'] = [i.to_json() for i in self.scroll_rects]
665+
if self.client_rects is not None:
666+
json['clientRects'] = [i.to_json() for i in self.client_rects]
652667
return json
653668

654669
@classmethod
@@ -659,6 +674,9 @@ def from_json(cls, json: T_JSON_DICT) -> 'LayoutTreeSnapshot':
659674
bounds=[Rectangle.from_json(i) for i in json['bounds']],
660675
text=[StringIndex.from_json(i) for i in json['text']],
661676
stacking_contexts=RareBooleanData.from_json(json['stackingContexts']),
677+
offset_rects=[Rectangle.from_json(i) for i in json['offsetRects']] if 'offsetRects' in json else None,
678+
scroll_rects=[Rectangle.from_json(i) for i in json['scrollRects']] if 'scrollRects' in json else None,
679+
client_rects=[Rectangle.from_json(i) for i in json['clientRects']] if 'clientRects' in json else None,
662680
)
663681

664682

@@ -762,7 +780,8 @@ def get_snapshot(
762780

763781

764782
def capture_snapshot(
765-
computed_styles: typing.List[str]
783+
computed_styles: typing.List[str],
784+
include_dom_rects: typing.Optional[bool] = None
766785
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[typing.List['DocumentSnapshot'], typing.List[str]]]:
767786
'''
768787
Returns a document snapshot, including the full DOM tree of the root node (including iframes,
@@ -771,12 +790,15 @@ def capture_snapshot(
771790
flattened.
772791
773792
:param computed_styles: Whitelist of computed styles to return.
793+
:param include_dom_rects: Whether to include DOM rectangles (offsetRects, clientRects, scrollRects) into the snapshot
774794
:returns: a tuple with the following items:
775795
0. documents: The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
776796
1. strings: Shared string table that all string properties refer to with indexes.
777797
'''
778798
params: T_JSON_DICT = dict()
779799
params['computedStyles'] = [i for i in computed_styles]
800+
if include_dom_rects is not None:
801+
params['includeDOMRects'] = include_dom_rects
780802
cmd_dict: T_JSON_DICT = {
781803
'method': 'DOMSnapshot.captureSnapshot',
782804
'params': params,

cdp/network.py

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,114 @@ def from_json(cls, json: T_JSON_DICT) -> 'Cookie':
931931
)
932932

933933

934+
class SetCookieBlockedReason(enum.Enum):
935+
'''
936+
Types of reasons why a cookie may not be stored from a response.
937+
'''
938+
SECURE_ONLY = "SecureOnly"
939+
SAME_SITE_STRICT = "SameSiteStrict"
940+
SAME_SITE_LAX = "SameSiteLax"
941+
SAME_SITE_EXTENDED = "SameSiteExtended"
942+
SAME_SITE_UNSPECIFIED_TREATED_AS_LAX = "SameSiteUnspecifiedTreatedAsLax"
943+
SAME_SITE_NONE_INSECURE = "SameSiteNoneInsecure"
944+
USER_PREFERENCES = "UserPreferences"
945+
SYNTAX_ERROR = "SyntaxError"
946+
SCHEME_NOT_SUPPORTED = "SchemeNotSupported"
947+
OVERWRITE_SECURE = "OverwriteSecure"
948+
INVALID_DOMAIN = "InvalidDomain"
949+
INVALID_PREFIX = "InvalidPrefix"
950+
UNKNOWN_ERROR = "UnknownError"
951+
952+
def to_json(self) -> str:
953+
return self.value
954+
955+
@classmethod
956+
def from_json(cls, json: str) -> 'SetCookieBlockedReason':
957+
return cls(json)
958+
959+
960+
class CookieBlockedReason(enum.Enum):
961+
'''
962+
Types of reasons why a cookie may not be sent with a request.
963+
'''
964+
SECURE_ONLY = "SecureOnly"
965+
NOT_ON_PATH = "NotOnPath"
966+
DOMAIN_MISMATCH = "DomainMismatch"
967+
SAME_SITE_STRICT = "SameSiteStrict"
968+
SAME_SITE_LAX = "SameSiteLax"
969+
SAME_SITE_EXTENDED = "SameSiteExtended"
970+
SAME_SITE_UNSPECIFIED_TREATED_AS_LAX = "SameSiteUnspecifiedTreatedAsLax"
971+
SAME_SITE_NONE_INSECURE = "SameSiteNoneInsecure"
972+
USER_PREFERENCES = "UserPreferences"
973+
UNKNOWN_ERROR = "UnknownError"
974+
975+
def to_json(self) -> str:
976+
return self.value
977+
978+
@classmethod
979+
def from_json(cls, json: str) -> 'CookieBlockedReason':
980+
return cls(json)
981+
982+
983+
@dataclass
984+
class BlockedSetCookieWithReason:
985+
'''
986+
A cookie which was not stored from a response with the corresponding reason.
987+
'''
988+
#: The reason this cookie was blocked.
989+
blocked_reason: 'SetCookieBlockedReason'
990+
991+
#: The string representing this individual cookie as it would appear in the header.
992+
#: This is not the entire "cookie" or "set-cookie" header which could have multiple cookies.
993+
cookie_line: str
994+
995+
#: The cookie object which represents the cookie which was not stored. It is optional because
996+
#: sometimes complete cookie information is not available, such as in the case of parsing
997+
#: errors.
998+
cookie: typing.Optional['Cookie'] = None
999+
1000+
def to_json(self) -> T_JSON_DICT:
1001+
json: T_JSON_DICT = dict()
1002+
json['blockedReason'] = self.blocked_reason.to_json()
1003+
json['cookieLine'] = self.cookie_line
1004+
if self.cookie is not None:
1005+
json['cookie'] = self.cookie.to_json()
1006+
return json
1007+
1008+
@classmethod
1009+
def from_json(cls, json: T_JSON_DICT) -> 'BlockedSetCookieWithReason':
1010+
return cls(
1011+
blocked_reason=SetCookieBlockedReason.from_json(json['blockedReason']),
1012+
cookie_line=str(json['cookieLine']),
1013+
cookie=Cookie.from_json(json['cookie']) if 'cookie' in json else None,
1014+
)
1015+
1016+
1017+
@dataclass
1018+
class BlockedCookieWithReason:
1019+
'''
1020+
A cookie with was not sent with a request with the corresponding reason.
1021+
'''
1022+
#: The reason the cookie was blocked.
1023+
blocked_reason: 'CookieBlockedReason'
1024+
1025+
#: The cookie object representing the cookie which was not sent.
1026+
cookie: 'Cookie'
1027+
1028+
def to_json(self) -> T_JSON_DICT:
1029+
json: T_JSON_DICT = dict()
1030+
json['blockedReason'] = self.blocked_reason.to_json()
1031+
json['cookie'] = self.cookie.to_json()
1032+
return json
1033+
1034+
@classmethod
1035+
def from_json(cls, json: T_JSON_DICT) -> 'BlockedCookieWithReason':
1036+
return cls(
1037+
blocked_reason=CookieBlockedReason.from_json(json['blockedReason']),
1038+
cookie=Cookie.from_json(json['cookie']),
1039+
)
1040+
1041+
9341042
@dataclass
9351043
class CookieParam:
9361044
'''
@@ -1203,12 +1311,16 @@ class SignedExchangeHeader:
12031311
#: Signed exchange response signature.
12041312
signatures: typing.List['SignedExchangeSignature']
12051313

1314+
#: Signed exchange header integrity hash in the form of "sha256-<base64-hash-value>".
1315+
header_integrity: str
1316+
12061317
def to_json(self) -> T_JSON_DICT:
12071318
json: T_JSON_DICT = dict()
12081319
json['requestUrl'] = self.request_url
12091320
json['responseCode'] = self.response_code
12101321
json['responseHeaders'] = self.response_headers.to_json()
12111322
json['signatures'] = [i.to_json() for i in self.signatures]
1323+
json['headerIntegrity'] = self.header_integrity
12121324
return json
12131325

12141326
@classmethod
@@ -1218,6 +1330,7 @@ def from_json(cls, json: T_JSON_DICT) -> 'SignedExchangeHeader':
12181330
response_code=int(json['responseCode']),
12191331
response_headers=Headers.from_json(json['responseHeaders']),
12201332
signatures=[SignedExchangeSignature.from_json(i) for i in json['signatures']],
1333+
header_integrity=str(json['headerIntegrity']),
12211334
)
12221335

12231336

@@ -1384,6 +1497,7 @@ def continue_intercepted_request(
13841497
modifications, or blocks it, or completes it with the provided response bytes. If a network
13851498
fetch occurs as a result which encounters a redirect an additional Network.requestIntercepted
13861499
event will be sent with the same InterceptionId.
1500+
Deprecated, use Fetch.continueRequest, Fetch.fulfillRequest and Fetch.failRequest instead.
13871501
13881502
:param interception_id:
13891503
:param error_reason: If set this causes the request to fail with the given reason. Passing ``Aborted`` for requests
@@ -1872,6 +1986,7 @@ def set_request_interception(
18721986
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
18731987
'''
18741988
Sets the requests to intercept that match the provided patterns and optionally resource types.
1989+
Deprecated, please use Fetch.enable instead.
18751990
18761991
:param patterns: Requests matching any of these patterns will be forwarded and wait for the corresponding
18771992
continueInterceptedRequest call.
@@ -2026,6 +2141,7 @@ class RequestIntercepted:
20262141
'''
20272142
Details of an intercepted HTTP request, which must be either allowed, blocked, modified or
20282143
mocked.
2144+
Deprecated, use Fetch.requestPaused instead.
20292145
'''
20302146
#: Each request the page makes will have a unique id, however if any redirects are encountered
20312147
#: while processing that fetch, they will be reported with the same id as the original fetch.
@@ -2363,3 +2479,59 @@ def from_json(cls, json: T_JSON_DICT) -> 'WebSocketWillSendHandshakeRequest':
23632479
wall_time=TimeSinceEpoch.from_json(json['wallTime']),
23642480
request=WebSocketRequest.from_json(json['request'])
23652481
)
2482+
2483+
2484+
@event_class('Network.requestWillBeSentExtraInfo')
2485+
@dataclass
2486+
class RequestWillBeSentExtraInfo:
2487+
'''
2488+
Fired when additional information about a requestWillBeSent event is available from the
2489+
network stack. Not every requestWillBeSent event will have an additional
2490+
requestWillBeSentExtraInfo fired for it, and there is no guarantee whether requestWillBeSent
2491+
or requestWillBeSentExtraInfo will be fired first for the same request.
2492+
'''
2493+
#: Request identifier. Used to match this information to an existing requestWillBeSent event.
2494+
request_id: 'RequestId'
2495+
#: A list of cookies which will not be sent with this request along with corresponding reasons
2496+
#: for blocking.
2497+
blocked_cookies: typing.List['BlockedCookieWithReason']
2498+
#: Raw request headers as they will be sent over the wire.
2499+
headers: 'Headers'
2500+
2501+
@classmethod
2502+
def from_json(cls, json: T_JSON_DICT) -> 'RequestWillBeSentExtraInfo':
2503+
return cls(
2504+
request_id=RequestId.from_json(json['requestId']),
2505+
blocked_cookies=[BlockedCookieWithReason.from_json(i) for i in json['blockedCookies']],
2506+
headers=Headers.from_json(json['headers'])
2507+
)
2508+
2509+
2510+
@event_class('Network.responseReceivedExtraInfo')
2511+
@dataclass
2512+
class ResponseReceivedExtraInfo:
2513+
'''
2514+
Fired when additional information about a responseReceived event is available from the network
2515+
stack. Not every responseReceived event will have an additional responseReceivedExtraInfo for
2516+
it, and responseReceivedExtraInfo may be fired before or after responseReceived.
2517+
'''
2518+
#: Request identifier. Used to match this information to another responseReceived event.
2519+
request_id: 'RequestId'
2520+
#: A list of cookies which were not stored from the response along with the corresponding
2521+
#: reasons for blocking. The cookies here may not be valid due to syntax errors, which
2522+
#: are represented by the invalid cookie line string instead of a proper cookie.
2523+
blocked_cookies: typing.List['BlockedSetCookieWithReason']
2524+
#: Raw response headers as they were received over the wire.
2525+
headers: 'Headers'
2526+
#: Raw response header text as it was received over the wire. The raw text may not always be
2527+
#: available, such as in the case of HTTP/2 or QUIC.
2528+
headers_text: typing.Optional[str]
2529+
2530+
@classmethod
2531+
def from_json(cls, json: T_JSON_DICT) -> 'ResponseReceivedExtraInfo':
2532+
return cls(
2533+
request_id=RequestId.from_json(json['requestId']),
2534+
blocked_cookies=[BlockedSetCookieWithReason.from_json(i) for i in json['blockedCookies']],
2535+
headers=Headers.from_json(json['headers']),
2536+
headers_text=str(json['headersText']) if 'headersText' in json else None
2537+
)

cdp/overlay.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,23 @@ def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
142142

143143
def get_highlight_object_for_test(
144144
node_id: 'dom.NodeId',
145-
include_distance: typing.Optional[bool] = None
145+
include_distance: typing.Optional[bool] = None,
146+
include_style: typing.Optional[bool] = None
146147
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,dict]:
147148
'''
148149
For testing.
149150
150151
:param node_id: Id of the node to get highlight object for.
151152
:param include_distance: Whether to include distance info.
153+
:param include_style: Whether to include style info.
152154
:returns: Highlight data for the node.
153155
'''
154156
params: T_JSON_DICT = dict()
155157
params['nodeId'] = node_id.to_json()
156158
if include_distance is not None:
157159
params['includeDistance'] = include_distance
160+
if include_style is not None:
161+
params['includeStyle'] = include_style
158162
cmd_dict: T_JSON_DICT = {
159163
'method': 'Overlay.getHighlightObjectForTest',
160164
'params': params,
@@ -398,6 +402,23 @@ def set_show_paint_rects(
398402
json = yield cmd_dict
399403

400404

405+
def set_show_layout_shift_regions(
406+
result: bool
407+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
408+
'''
409+
Requests that backend shows layout shift regions
410+
411+
:param result: True for showing layout shift regions
412+
'''
413+
params: T_JSON_DICT = dict()
414+
params['result'] = result
415+
cmd_dict: T_JSON_DICT = {
416+
'method': 'Overlay.setShowLayoutShiftRegions',
417+
'params': params,
418+
}
419+
json = yield cmd_dict
420+
421+
401422
def set_show_scroll_bottleneck_rects(
402423
show: bool
403424
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:

0 commit comments

Comments
 (0)