forked from llimllib/chrome-control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DOMDebugger.py
123 lines (82 loc) · 3.87 KB
/
DOMDebugger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from enum import Enum
from typing import Any, List
from base import ChromeCommand
import Runtime
DOMBreakpointType = Enum("DOMBreakpointType", "subtree-modified attribute-modified node-removed")
DOMBreakpointType.__doc__ = "DOM breakpoint type."
class EventListener:
"""Object event listener."""
def __init__(self, type: str, useCapture: bool, passive: bool, once: bool, scriptId: "Runtime.ScriptId", lineNumber: int, columnNumber: int, handler: "Runtime.RemoteObject"=None, originalHandler: "Runtime.RemoteObject"=None, removeFunction: "Runtime.RemoteObject"=None):
# <code>EventListener</code>'s type.
self.type = type
# <code>EventListener</code>'s useCapture.
self.useCapture = useCapture
# <code>EventListener</code>'s passive flag.
self.passive = passive
# <code>EventListener</code>'s once flag.
self.once = once
# Script id of the handler code.
self.scriptId = scriptId
# Line number in the script (0-based).
self.lineNumber = lineNumber
# Column number in the script (0-based).
self.columnNumber = columnNumber
# Event handler function value.
self.handler = handler
# Event original handler function value.
self.originalHandler = originalHandler
# Event listener remove function.
self.removeFunction = removeFunction
class setDOMBreakpoint(ChromeCommand):
"""Sets breakpoint on particular operation with DOM."""
def __init__(self, nodeId: "DOM.NodeId", type: "DOMBreakpointType"):
# Identifier of the node to set breakpoint on.
self.nodeId = nodeId
# Type of the operation to stop upon.
self.type = type
class removeDOMBreakpoint(ChromeCommand):
"""Removes DOM breakpoint that was set using <code>setDOMBreakpoint</code>."""
def __init__(self, nodeId: "DOM.NodeId", type: "DOMBreakpointType"):
# Identifier of the node to remove breakpoint from.
self.nodeId = nodeId
# Type of the breakpoint to remove.
self.type = type
class setEventListenerBreakpoint(ChromeCommand):
"""Sets breakpoint on particular DOM event."""
def __init__(self, eventName: str, targetName: str=None):
# DOM Event name to stop on (any DOM event will do).
self.eventName = eventName
# EventTarget interface name to stop on. If equal to <code>"*"</code> or not provided, will stop on any EventTarget.
self.targetName = targetName
class removeEventListenerBreakpoint(ChromeCommand):
"""Removes breakpoint on particular DOM event."""
def __init__(self, eventName: str, targetName: str=None):
# Event name.
self.eventName = eventName
# EventTarget interface name.
self.targetName = targetName
class setInstrumentationBreakpoint(ChromeCommand):
"""Sets breakpoint on particular native event."""
def __init__(self, eventName: str):
# Instrumentation name to stop on.
self.eventName = eventName
class removeInstrumentationBreakpoint(ChromeCommand):
"""Removes breakpoint on particular native event."""
def __init__(self, eventName: str):
# Instrumentation name to stop on.
self.eventName = eventName
class setXHRBreakpoint(ChromeCommand):
"""Sets breakpoint on XMLHttpRequest."""
def __init__(self, url: str):
# Resource URL substring. All XHRs having this substring in the URL will get stopped upon.
self.url = url
class removeXHRBreakpoint(ChromeCommand):
"""Removes breakpoint from XMLHttpRequest."""
def __init__(self, url: str):
# Resource URL substring.
self.url = url
class getEventListeners(ChromeCommand):
"""Returns event listeners of the given object."""
def __init__(self, objectId: "Runtime.RemoteObjectId"):
# Identifier of the object to return listeners for.
self.objectId = objectId