Skip to content

Commit

Permalink
use typed method names
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Sep 13, 2020
1 parent cb25fa4 commit 1db9370
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions states.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ func (b *Browser) set(sessionID proto.TargetSessionID, methodName string, params

key := ""
switch methodName {
case "Target.setDiscoverTargets": // only Target domain is special
case (proto.TargetSetDiscoverTargets{}).MethodName(): // only Target domain is special
method := &proto.TargetSetDiscoverTargets{}
utils.E(json.Unmarshal(params, method))
if !method.Discover {
key = "Target.setDiscoverTargets"
key = (proto.TargetSetDiscoverTargets{}).MethodName()
}
case "Emulation.clearDeviceMetricsOverride":
key = "Emulation.setDeviceMetricsOverride"
case "Emulation.clearGeolocationOverride":
key = "Emulation.setGeolocationOverride"
case (proto.EmulationClearDeviceMetricsOverride{}).MethodName():
key = (proto.EmulationSetDeviceMetricsOverride{}).MethodName()
case (proto.EmulationClearGeolocationOverride{}).MethodName():
key = (proto.EmulationSetGeolocationOverride{}).MethodName()
default:
domain, name := proto.ParseMethodName(methodName)
if name == "disable" {
Expand Down Expand Up @@ -67,7 +67,7 @@ func (b *Browser) EnableDomain(sessionID proto.TargetSessionID, method proto.Pay

return func() {
if !enabled {
if method.MethodName() == "Target.setDiscoverTargets" { // only Target domain is special
if method.MethodName() == (proto.TargetSetDiscoverTargets{}).MethodName() { // only Target domain is special
_ = proto.TargetSetDiscoverTargets{Discover: false}.Call(b)
return
}
Expand All @@ -84,7 +84,7 @@ func (b *Browser) DisableDomain(sessionID proto.TargetSessionID, method proto.Pa
domain, _ := proto.ParseMethodName(method.MethodName())

if enabled {
if method.MethodName() == "Target.setDiscoverTargets" { // only Target domain is special
if method.MethodName() == (proto.TargetSetDiscoverTargets{}).MethodName() { // only Target domain is special
_ = proto.TargetSetDiscoverTargets{Discover: false}.Call(b)
} else {
_, _ = b.Call(b.ctx, string(sessionID), domain+".disable", nil)
Expand Down

0 comments on commit 1db9370

Please sign in to comment.