@@ -40,51 +40,134 @@ func mapBrowserToGoja(vu k6modules.VU) *goja.Object {
40
40
return obj
41
41
}
42
42
43
+ // mapFrame to the JS module.
44
+ //
45
+ //nolint:funlen
46
+ func mapFrame (rt * goja.Runtime , f api.Frame ) mapping {
47
+ maps := mapping {
48
+ "addScriptTag" : f .AddScriptTag ,
49
+ "addStyleTag" : f .AddStyleTag ,
50
+ "check" : f .Check ,
51
+ "childFrames" : func () * goja.Object {
52
+ var (
53
+ mcfs []mapping
54
+ cfs = f .ChildFrames ()
55
+ )
56
+ for _ , fr := range cfs {
57
+ mcfs = append (mcfs , mapFrame (rt , fr ))
58
+ }
59
+ return rt .ToValue (mcfs ).ToObject (rt )
60
+ },
61
+ "click" : f .Click ,
62
+ "content" : f .Content ,
63
+ "dblclick" : f .Dblclick ,
64
+ "dispatchEvent" : f .DispatchEvent ,
65
+ "evaluate" : f .Evaluate ,
66
+ "evaluateHandle" : f .EvaluateHandle ,
67
+ "fill" : f .Fill ,
68
+ "focus" : f .Focus ,
69
+ "frameElement" : f .FrameElement ,
70
+ "getAttribute" : f .GetAttribute ,
71
+ "goto" : f .Goto ,
72
+ "hover" : f .Hover ,
73
+ "innerHTML" : f .InnerHTML ,
74
+ "innerText" : f .InnerText ,
75
+ "inputValue" : f .InputValue ,
76
+ "isChecked" : f .IsChecked ,
77
+ "isDetached" : f .IsDetached ,
78
+ "isDisabled" : f .IsDisabled ,
79
+ "isEditable" : f .IsEditable ,
80
+ "isEnabled" : f .IsEnabled ,
81
+ "isHidden" : f .IsHidden ,
82
+ "isVisible" : f .IsVisible ,
83
+ "iD" : f .ID ,
84
+ "loaderID" : f .LoaderID ,
85
+ "locator" : f .Locator ,
86
+ "name" : f .Name ,
87
+ "page" : func () * goja.Object {
88
+ mp := mapPage (rt , f .Page ())
89
+ return rt .ToValue (mp ).ToObject (rt )
90
+ },
91
+ "parentFrame" : func () * goja.Object {
92
+ mf := mapFrame (rt , f .ParentFrame ())
93
+ return rt .ToValue (mf ).ToObject (rt )
94
+ },
95
+ "press" : f .Press ,
96
+ "selectOption" : f .SelectOption ,
97
+ "setContent" : f .SetContent ,
98
+ "setInputFiles" : f .SetInputFiles ,
99
+ "tap" : f .Tap ,
100
+ "textContent" : f .TextContent ,
101
+ "title" : f .Title ,
102
+ "type" : f .Type ,
103
+ "uncheck" : f .Uncheck ,
104
+ "url" : f .URL ,
105
+ "waitForFunction" : f .WaitForFunction ,
106
+ "waitForLoadState" : f .WaitForLoadState ,
107
+ "waitForNavigation" : f .WaitForNavigation ,
108
+ "waitForSelector" : f .WaitForSelector ,
109
+ "waitForTimeout" : f .WaitForTimeout ,
110
+ }
111
+
112
+ return maps
113
+ }
114
+
43
115
// mapPage to the JS module.
44
116
//
45
117
//nolint:funlen
46
118
func mapPage (rt * goja.Runtime , p api.Page ) mapping {
47
- _ = rt
48
119
maps := mapping {
49
- "addInitScript" : p .AddInitScript ,
50
- "addScriptTag" : p .AddScriptTag ,
51
- "addStyleTag" : p .AddStyleTag ,
52
- "bringToFront" : p .BringToFront ,
53
- "check" : p .Check ,
54
- "click" : p .Click ,
55
- "close" : p .Close ,
56
- "content" : p .Content ,
57
- "context" : p .Context ,
58
- "dblclick" : p .Dblclick ,
59
- "dispatchEvent" : p .DispatchEvent ,
60
- "dragAndDrop" : p .DragAndDrop ,
61
- "emulateMedia" : p .EmulateMedia ,
62
- "emulateVisionDeficiency" : p .EmulateVisionDeficiency ,
63
- "evaluate" : p .Evaluate ,
64
- "evaluateHandle" : p .EvaluateHandle ,
65
- "exposeBinding" : p .ExposeBinding ,
66
- "exposeFunction" : p .ExposeFunction ,
67
- "fill" : p .Fill ,
68
- "focus" : p .Focus ,
69
- "frame" : p .Frame ,
70
- "frames" : p .Frames ,
71
- "getAttribute" : p .GetAttribute ,
72
- "goBack" : p .GoBack ,
73
- "goForward" : p .GoForward ,
74
- "goto" : p .Goto ,
75
- "hover" : p .Hover ,
76
- "innerHTML" : p .InnerHTML ,
77
- "innerText" : p .InnerText ,
78
- "inputValue" : p .InputValue ,
79
- "isChecked" : p .IsChecked ,
80
- "isClosed" : p .IsClosed ,
81
- "isDisabled" : p .IsDisabled ,
82
- "isEditable" : p .IsEditable ,
83
- "isEnabled" : p .IsEnabled ,
84
- "isHidden" : p .IsHidden ,
85
- "isVisible" : p .IsVisible ,
86
- "locator" : p .Locator ,
87
- "mainFrame" : p .MainFrame ,
120
+ "addInitScript" : p .AddInitScript ,
121
+ "addScriptTag" : p .AddScriptTag ,
122
+ "addStyleTag" : p .AddStyleTag ,
123
+ "bringToFront" : p .BringToFront ,
124
+ "check" : p .Check ,
125
+ "click" : p .Click ,
126
+ "close" : p .Close ,
127
+ "content" : p .Content ,
128
+ "context" : p .Context ,
129
+ "dblclick" : p .Dblclick ,
130
+ "dispatchEvent" : p .DispatchEvent ,
131
+ "dragAndDrop" : p .DragAndDrop ,
132
+ "emulateMedia" : p .EmulateMedia ,
133
+ "emulateVisionDeficiency" : p .EmulateVisionDeficiency ,
134
+ "evaluate" : p .Evaluate ,
135
+ "evaluateHandle" : p .EvaluateHandle ,
136
+ "exposeBinding" : p .ExposeBinding ,
137
+ "exposeFunction" : p .ExposeFunction ,
138
+ "fill" : p .Fill ,
139
+ "focus" : p .Focus ,
140
+ "frame" : p .Frame ,
141
+ "frames" : func () * goja.Object {
142
+ var (
143
+ mfrs []mapping
144
+ frs = p .Frames ()
145
+ )
146
+ for _ , fr := range frs {
147
+ mfrs = append (mfrs , mapFrame (rt , fr ))
148
+ }
149
+ return rt .ToValue (mfrs ).ToObject (rt )
150
+ },
151
+ "getAttribute" : p .GetAttribute ,
152
+ "goBack" : p .GoBack ,
153
+ "goForward" : p .GoForward ,
154
+ "goto" : p .Goto ,
155
+ "hover" : p .Hover ,
156
+ "innerHTML" : p .InnerHTML ,
157
+ "innerText" : p .InnerText ,
158
+ "inputValue" : p .InputValue ,
159
+ "isChecked" : p .IsChecked ,
160
+ "isClosed" : p .IsClosed ,
161
+ "isDisabled" : p .IsDisabled ,
162
+ "isEditable" : p .IsEditable ,
163
+ "isEnabled" : p .IsEnabled ,
164
+ "isHidden" : p .IsHidden ,
165
+ "isVisible" : p .IsVisible ,
166
+ "locator" : p .Locator ,
167
+ "mainFrame" : func () * goja.Object {
168
+ mf := mapFrame (rt , p .MainFrame ())
169
+ return rt .ToValue (mf ).ToObject (rt )
170
+ },
88
171
"opener" : p .Opener ,
89
172
"pause" : p .Pause ,
90
173
"pdf" : p .Pdf ,
0 commit comments