@@ -15,25 +15,25 @@ import (
1515)
1616
1717func TestTranslateRoutesWrapsAndUnwrapsModCDPProtocolMessagesDeterministically (t * testing.T ) {
18- if routeFor ("Browser.getVersion" , map [string ]string {"Browser.*" : "direct_cdp" , "*.*" : "service_worker" }) != "direct_cdp" {
18+ if RouteFor ("Browser.getVersion" , map [string ]string {"Browser.*" : "direct_cdp" , "*.*" : "service_worker" }) != "direct_cdp" {
1919 t .Fatal ("Browser.getVersion route mismatch" )
2020 }
21- if routeFor ("Target.getTargets" , map [string ]string {"Browser.*" : "direct_cdp" , "*.*" : "service_worker" }) != "service_worker" {
21+ if RouteFor ("Target.getTargets" , map [string ]string {"Browser.*" : "direct_cdp" , "*.*" : "service_worker" }) != "service_worker" {
2222 t .Fatal ("Target.getTargets route mismatch" )
2323 }
24- if routeFor ("Browser.getVersion" , nil ) != "direct_cdp" {
24+ if RouteFor ("Browser.getVersion" , nil ) != "direct_cdp" {
2525 t .Fatal ("Browser.getVersion default route mismatch" )
2626 }
2727
28- direct , err := wrapCommandIfNeeded ("Browser.getVersion" , map [string ]any {}, map [string ]string {"*.*" : "direct_cdp" }, "" )
28+ direct , err := WrapCommandIfNeeded ("Browser.getVersion" , map [string ]any {}, map [string ]string {"*.*" : "direct_cdp" }, "" )
2929 if err != nil {
3030 t .Fatal (err )
3131 }
3232 if direct .Target != "direct_cdp" || len (direct .Steps ) != 1 || direct .Steps [0 ].Method != "Browser.getVersion" {
3333 t .Fatalf ("direct = %#v" , direct )
3434 }
3535
36- wrapped , err := wrapCommandIfNeeded (
36+ wrapped , err := WrapCommandIfNeeded (
3737 "Mod.evaluate" ,
3838 map [string ]any {"expression" : "({ ok: true })" , "params" : map [string ]any {"value" : 1 }},
3939 DefaultClientRoutes (),
@@ -66,15 +66,15 @@ func TestTranslateRoutesWrapsAndUnwrapsModCDPProtocolMessagesDeterministically(t
6666 t .Fatalf ("unwrap = %q" , wrapped .Steps [0 ].Unwrap )
6767 }
6868
69- configured , err := wrapCommandIfNeeded ("Mod.configure" , map [string ]any {"router" : map [string ]any {"router_routes" : map [string ]any {"*.*" : "loopback_cdp" }}}, DefaultClientRoutes (), "session-1" )
69+ configured , err := WrapCommandIfNeeded ("Mod.configure" , map [string ]any {"router" : map [string ]any {"router_routes" : map [string ]any {"*.*" : "loopback_cdp" }}}, DefaultClientRoutes (), "session-1" )
7070 if err != nil {
7171 t .Fatal (err )
7272 }
7373 if configured .Steps [0 ].Unwrap != "runtime_json" {
7474 t .Fatalf ("configure unwrap = %q" , configured .Steps [0 ].Unwrap )
7575 }
7676
77- ping , err := wrapCommandIfNeeded ("Mod.ping" , map [string ]any {}, DefaultClientRoutes (), "" )
77+ ping , err := WrapCommandIfNeeded ("Mod.ping" , map [string ]any {}, DefaultClientRoutes (), "" )
7878 if err != nil {
7979 t .Fatal (err )
8080 }
@@ -87,7 +87,7 @@ func TestTranslateRoutesWrapsAndUnwrapsModCDPProtocolMessagesDeterministically(t
8787 t .Fatalf ("ping params = %#v" , pingPayload )
8888 }
8989
90- custom , err := wrapCommandIfNeeded (
90+ custom , err := WrapCommandIfNeeded (
9191 "Custom.echo" ,
9292 map [string ]any {"secret" : strings .Repeat ("x" , 100 ), "nested" : map [string ]any {"ok" : true }},
9393 DefaultClientRoutes (),
@@ -118,7 +118,7 @@ func TestTranslateRoutesWrapsAndUnwrapsModCDPProtocolMessagesDeterministically(t
118118 t .Fatalf ("session argument = %#v" , customArguments [2 ])
119119 }
120120
121- customWithSession , err := wrapCommandIfNeeded (
121+ customWithSession , err := WrapCommandIfNeeded (
122122 "Custom.echo" ,
123123 map [string ]any {"secret" : "targeted" },
124124 DefaultClientRoutes (),
@@ -132,14 +132,14 @@ func TestTranslateRoutesWrapsAndUnwrapsModCDPProtocolMessagesDeterministically(t
132132 t .Fatalf ("target session argument = %#v" , customWithSessionArguments [2 ])
133133 }
134134
135- unwrapped , err := unwrapResponseIfNeeded (map [string ]any {"result" : map [string ]any {"type" : "object" , "value" : map [string ]any {"ok" : true }}}, "runtime" )
135+ unwrapped , err := UnwrapResponseIfNeeded (map [string ]any {"result" : map [string ]any {"type" : "object" , "value" : map [string ]any {"ok" : true }}}, "runtime" )
136136 if err != nil {
137137 t .Fatal (err )
138138 }
139139 if unwrapped .(map [string ]any )["ok" ] != true {
140140 t .Fatalf ("unwrapped = %#v" , unwrapped )
141141 }
142- raw , err := unwrapResponseIfNeeded (map [string ]any {"product" : "Chrome/1" }, "" )
142+ raw , err := UnwrapResponseIfNeeded (map [string ]any {"product" : "Chrome/1" }, "" )
143143 if err != nil {
144144 t .Fatal (err )
145145 }
@@ -148,7 +148,7 @@ func TestTranslateRoutesWrapsAndUnwrapsModCDPProtocolMessagesDeterministically(t
148148 }
149149
150150 payloadSessionID := "session-2"
151- payload , err := encodeBindingPayload (types.ModCDPBindingPayload {
151+ payload , err := EncodeBindingPayload (types.ModCDPBindingPayload {
152152 Event : "Custom.ready" ,
153153 Data : map [string ]any {"ready" : true },
154154 CDPSessionID : & payloadSessionID ,
@@ -158,14 +158,14 @@ func TestTranslateRoutesWrapsAndUnwrapsModCDPProtocolMessagesDeterministically(t
158158 }
159159 unwrappedEvent , ok := UnwrapEventIfNeeded (
160160 "Runtime.bindingCalled" ,
161- map [string ]any {"name" : customEventBindingName , "payload" : payload },
161+ map [string ]any {"name" : CustomEventBindingName , "payload" : payload },
162162 "session-1" ,
163163 "session-1" ,
164164 )
165165 if ! ok || unwrappedEvent .Event != "Custom.ready" || unwrappedEvent .Data .(map [string ]any )["ready" ] != true || unwrappedEvent .SessionID == nil || * unwrappedEvent .SessionID != "session-2" {
166166 t .Fatalf ("unwrappedEvent=%#v ok=%v" , unwrappedEvent , ok )
167167 }
168- if _ , ok := UnwrapEventIfNeeded ("Runtime.consoleAPICalled" , map [string ]any {"name" : customEventBindingName , "payload" : payload }, "" , "" ); ok {
168+ if _ , ok := UnwrapEventIfNeeded ("Runtime.consoleAPICalled" , map [string ]any {"name" : CustomEventBindingName , "payload" : payload }, "" , "" ); ok {
169169 t .Fatal ("expected console event to ignore binding payload" )
170170 }
171171}
0 commit comments