Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,10 @@ func (b *Browser) PageFromTarget(targetID proto.TargetTargetID) (*Page, error) {
return page, nil
}

flatten := true
session, err := proto.TargetAttachToTarget{
TargetID: targetID,
Flatten: true, // if it's not set no response will return
Flatten: &flatten, // if it's not set no response will return
}.Call(b)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion browser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,9 @@ func TestStreamReader(t *testing.T) {
g.Err(err)

g.mc.stub(1, proto.IORead{}, func(_ StubSend) (gson.JSON, error) {
base64Encoded := true
return gson.New(proto.IOReadResult{
Base64Encoded: true,
Base64Encoded: &base64Encoded,
Data: "@",
}), nil
})
Expand Down
3 changes: 2 additions & 1 deletion examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ func Example_page_screenshot() {
page.MustScreenshot("my.png")

// customization version
fromSurface := true
img, _ := page.Screenshot(true, &proto.PageCaptureScreenshot{
Format: proto.PageCaptureScreenshotFormatJpeg,
Quality: gson.Int(90),
Expand All @@ -246,7 +247,7 @@ func Example_page_screenshot() {
Height: 200,
Scale: 1,
},
FromSurface: true,
FromSurface: &fromSurface,
})
_ = utils.OutputFile("my.jpg", img)
}
Expand Down
3 changes: 2 additions & 1 deletion hijack.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,9 @@ func (ctx *HijackResponse) Fail(reason proto.NetworkErrorReason) *HijackResponse
// Ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication
func (b *Browser) HandleAuth(username, password string) func() error {
enable := b.DisableDomain("", &proto.FetchEnable{})
handleAuthRequests := true
disable := b.EnableDomain("", &proto.FetchEnable{
HandleAuthRequests: true,
HandleAuthRequests: &handleAuthRequests,
})

paused := &proto.FetchRequestPaused{}
Expand Down
5 changes: 3 additions & 2 deletions lib/examples/compare-chromedp/cookie/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ func main() {

page := rod.New().MustConnect().MustPage()

httpOnly := true
page.MustSetCookies(&proto.NetworkCookieParam{
Name: "cookie1",
Value: "value1",
Domain: "127.0.0.1",
HTTPOnly: true,
HTTPOnly: &httpOnly,
Expires: expr,
}, &proto.NetworkCookieParam{
Name: "cookie2",
Value: "value2",
Domain: "127.0.0.1",
HTTPOnly: true,
HTTPOnly: &httpOnly,
Expires: expr,
})

Expand Down
4 changes: 2 additions & 2 deletions lib/proto/a_patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ func CookiesToParams(cookies []*NetworkCookie) []*NetworkCookieParam {
Value: c.Value,
Domain: c.Domain,
Path: c.Path,
Secure: c.Secure,
HTTPOnly: c.HTTPOnly,
Secure: &c.Secure,
HTTPOnly: &c.HTTPOnly,
SameSite: c.SameSite,
Expires: c.Expires,
Priority: c.Priority,
Expand Down
6 changes: 3 additions & 3 deletions lib/proto/accessibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ type AccessibilityAXValueSource struct {
AttributeValue *AccessibilityAXValue `json:"attributeValue,omitempty"`

// Superseded (optional) Whether this source is superseded by a higher priority source.
Superseded bool `json:"superseded,omitempty"`
Superseded *bool `json:"superseded,omitempty"`

// NativeSource (optional) The native markup source for this value, e.g. a `<label>` element.
NativeSource AccessibilityAXValueNativeSourceType `json:"nativeSource,omitempty"`
Expand All @@ -153,7 +153,7 @@ type AccessibilityAXValueSource struct {
NativeSourceValue *AccessibilityAXValue `json:"nativeSourceValue,omitempty"`

// Invalid (optional) Whether the value for this property is invalid.
Invalid bool `json:"invalid,omitempty"`
Invalid *bool `json:"invalid,omitempty"`

// InvalidReason (optional) Reason for the value being invalid, if it is.
InvalidReason string `json:"invalidReason,omitempty"`
Expand Down Expand Up @@ -402,7 +402,7 @@ type AccessibilityGetPartialAXTree struct {
ObjectID RuntimeRemoteObjectID `json:"objectId,omitempty"`

// FetchRelatives (optional) Whether to fetch this node's ancestors, siblings and children. Defaults to true.
FetchRelatives bool `json:"fetchRelatives,omitempty"`
FetchRelatives *bool `json:"fetchRelatives,omitempty"`
}

// ProtoReq name.
Expand Down
14 changes: 7 additions & 7 deletions lib/proto/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,20 @@ type BrowserPermissionDescriptor struct {
Name string `json:"name"`

// Sysex (optional) For "midi" permission, may also specify sysex control.
Sysex bool `json:"sysex,omitempty"`
Sysex *bool `json:"sysex,omitempty"`

// UserVisibleOnly (optional) For "push" permission, may specify userVisibleOnly.
// Note that userVisibleOnly = true is the only currently supported type.
UserVisibleOnly bool `json:"userVisibleOnly,omitempty"`
UserVisibleOnly *bool `json:"userVisibleOnly,omitempty"`

// AllowWithoutSanitization (optional) For "clipboard" permission, may specify allowWithoutSanitization.
AllowWithoutSanitization bool `json:"allowWithoutSanitization,omitempty"`
AllowWithoutSanitization *bool `json:"allowWithoutSanitization,omitempty"`

// AllowWithoutGesture (optional) For "fullscreen" permission, must specify allowWithoutGesture:true.
AllowWithoutGesture bool `json:"allowWithoutGesture,omitempty"`
AllowWithoutGesture *bool `json:"allowWithoutGesture,omitempty"`

// PanTiltZoom (optional) For "camera" permission, may specify panTiltZoom.
PanTiltZoom bool `json:"panTiltZoom,omitempty"`
PanTiltZoom *bool `json:"panTiltZoom,omitempty"`
}

// BrowserBrowserCommandID (experimental) Browser command ids used by executeBrowserCommand.
Expand Down Expand Up @@ -426,7 +426,7 @@ type BrowserGetHistograms struct {
Query string `json:"query,omitempty"`

// Delta (optional) If true, retrieve delta since last delta call.
Delta bool `json:"delta,omitempty"`
Delta *bool `json:"delta,omitempty"`
}

// ProtoReq name.
Expand All @@ -450,7 +450,7 @@ type BrowserGetHistogram struct {
Name string `json:"name"`

// Delta (optional) If true, retrieve delta since last delta call.
Delta bool `json:"delta,omitempty"`
Delta *bool `json:"delta,omitempty"`
}

// ProtoReq name.
Expand Down
14 changes: 7 additions & 7 deletions lib/proto/css.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ type CSSCSSStyleSheetHeader struct {
Disabled bool `json:"disabled"`

// HasSourceURL (optional) Whether the sourceURL field value comes from the sourceURL comment.
HasSourceURL bool `json:"hasSourceURL,omitempty"`
HasSourceURL *bool `json:"hasSourceURL,omitempty"`

// IsInline Whether this stylesheet is created for STYLE tag by parser. This flag is not set for
// document.written STYLE tags.
Expand Down Expand Up @@ -169,7 +169,7 @@ type CSSCSSStyleSheetHeader struct {
EndColumn float64 `json:"endColumn"`

// LoadingFailed (experimental) (optional) If the style sheet was loaded from a network resource, this indicates when the resource failed to load
LoadingFailed bool `json:"loadingFailed,omitempty"`
LoadingFailed *bool `json:"loadingFailed,omitempty"`
}

// CSSCSSRule CSS rule representation.
Expand Down Expand Up @@ -278,7 +278,7 @@ type CSSShorthandEntry struct {
Value string `json:"value"`

// Important (optional) Whether the property has "!important" annotation (implies `false` if absent).
Important bool `json:"important,omitempty"`
Important *bool `json:"important,omitempty"`
}

// CSSCSSComputedStyleProperty ...
Expand Down Expand Up @@ -318,19 +318,19 @@ type CSSCSSProperty struct {
Value string `json:"value"`

// Important (optional) Whether the property has "!important" annotation (implies `false` if absent).
Important bool `json:"important,omitempty"`
Important *bool `json:"important,omitempty"`

// Implicit (optional) Whether the property is implicit (implies `false` if absent).
Implicit bool `json:"implicit,omitempty"`
Implicit *bool `json:"implicit,omitempty"`

// Text (optional) The full property text as specified in the style.
Text string `json:"text,omitempty"`

// ParsedOk (optional) Whether the property is understood by the browser (implies `true` if absent).
ParsedOk bool `json:"parsedOk,omitempty"`
ParsedOk *bool `json:"parsedOk,omitempty"`

// Disabled (optional) Whether the property is disabled by the user (present for source-based properties only).
Disabled bool `json:"disabled,omitempty"`
Disabled *bool `json:"disabled,omitempty"`

// Range (optional) The entire property range in the enclosing style declaration (if available).
Range *CSSSourceRange `json:"range,omitempty"`
Expand Down
38 changes: 19 additions & 19 deletions lib/proto/debugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type DebuggerCallFrame struct {
// can be restarted or not. Note that a `true` value here does not
// guarantee that Debugger#restartFrame with this CallFrameId will be
// successful, but it is very likely.
CanBeRestarted bool `json:"canBeRestarted,omitempty"`
CanBeRestarted *bool `json:"canBeRestarted,omitempty"`
}

// DebuggerScopeType enum.
Expand Down Expand Up @@ -304,20 +304,20 @@ type DebuggerEvaluateOnCallFrame struct {

// IncludeCommandLineAPI (optional) Specifies whether command line API should be available to the evaluated expression, defaults
// to false.
IncludeCommandLineAPI bool `json:"includeCommandLineAPI,omitempty"`
IncludeCommandLineAPI *bool `json:"includeCommandLineAPI,omitempty"`

// Silent (optional) In silent mode exceptions thrown during evaluation are not reported and do not pause
// execution. Overrides `setPauseOnException` state.
Silent bool `json:"silent,omitempty"`
Silent *bool `json:"silent,omitempty"`

// ReturnByValue (optional) Whether the result is expected to be a JSON object that should be sent by value.
ReturnByValue bool `json:"returnByValue,omitempty"`
ReturnByValue *bool `json:"returnByValue,omitempty"`

// GeneratePreview (experimental) (optional) Whether preview should be generated for the result.
GeneratePreview bool `json:"generatePreview,omitempty"`
GeneratePreview *bool `json:"generatePreview,omitempty"`

// ThrowOnSideEffect (optional) Whether to throw an exception if side effect cannot be ruled out during evaluation.
ThrowOnSideEffect bool `json:"throwOnSideEffect,omitempty"`
ThrowOnSideEffect *bool `json:"throwOnSideEffect,omitempty"`

// Timeout (experimental) (optional) Terminate execution after timing out (number of milliseconds).
Timeout RuntimeTimeDelta `json:"timeout,omitempty"`
Expand Down Expand Up @@ -352,7 +352,7 @@ type DebuggerGetPossibleBreakpoints struct {
End *DebuggerLocation `json:"end,omitempty"`

// RestrictToFunction (optional) Only consider locations which are in the same (non-nested) function as start.
RestrictToFunction bool `json:"restrictToFunction,omitempty"`
RestrictToFunction *bool `json:"restrictToFunction,omitempty"`
}

// ProtoReq name.
Expand Down Expand Up @@ -591,7 +591,7 @@ type DebuggerResume struct {
// JavaScript (i.e. via evaluation) until execution of the paused code
// is actually resumed, at which point termination is triggered.
// If execution is currently not paused, this parameter has no effect.
TerminateOnResume bool `json:"terminateOnResume,omitempty"`
TerminateOnResume *bool `json:"terminateOnResume,omitempty"`
}

// ProtoReq name.
Expand All @@ -611,10 +611,10 @@ type DebuggerSearchInContent struct {
Query string `json:"query"`

// CaseSensitive (optional) If true, search is case sensitive.
CaseSensitive bool `json:"caseSensitive,omitempty"`
CaseSensitive *bool `json:"caseSensitive,omitempty"`

// IsRegex (optional) If true, treats string parameter as regex.
IsRegex bool `json:"isRegex,omitempty"`
IsRegex *bool `json:"isRegex,omitempty"`
}

// ProtoReq name.
Expand Down Expand Up @@ -894,11 +894,11 @@ type DebuggerSetScriptSource struct {

// DryRun (optional) If true the change will not actually be applied. Dry run may be used to get result
// description without actually modifying the code.
DryRun bool `json:"dryRun,omitempty"`
DryRun *bool `json:"dryRun,omitempty"`

// AllowTopFrameEditing (experimental) (optional) If true, then `scriptSource` is allowed to change the function on top of the stack
// as long as the top-most stack frame is the only activation of that function.
AllowTopFrameEditing bool `json:"allowTopFrameEditing,omitempty"`
AllowTopFrameEditing *bool `json:"allowTopFrameEditing,omitempty"`
}

// ProtoReq name.
Expand Down Expand Up @@ -936,7 +936,7 @@ type DebuggerSetScriptSourceResult struct {
CallFrames []*DebuggerCallFrame `json:"callFrames,omitempty"`

// StackChanged (deprecated) (optional) Whether current call stack was modified after applying the changes.
StackChanged bool `json:"stackChanged,omitempty"`
StackChanged *bool `json:"stackChanged,omitempty"`

// AsyncStackTrace (deprecated) (optional) Async stack trace, if any.
AsyncStackTrace *RuntimeStackTrace `json:"asyncStackTrace,omitempty"`
Expand Down Expand Up @@ -996,7 +996,7 @@ func (m DebuggerSetVariableValue) Call(c Client) error {
type DebuggerStepInto struct {
// BreakOnAsyncCall (experimental) (optional) Debugger will pause on the execution of the first async task which was scheduled
// before next pause.
BreakOnAsyncCall bool `json:"breakOnAsyncCall,omitempty"`
BreakOnAsyncCall *bool `json:"breakOnAsyncCall,omitempty"`

// SkipList (experimental) (optional) The skipList specifies location ranges that should be skipped on step into.
SkipList []*DebuggerLocationRange `json:"skipList,omitempty"`
Expand Down Expand Up @@ -1163,10 +1163,10 @@ type DebuggerScriptFailedToParse struct {
SourceMapURL string `json:"sourceMapURL,omitempty"`

// HasSourceURL (optional) True, if this script has sourceURL.
HasSourceURL bool `json:"hasSourceURL,omitempty"`
HasSourceURL *bool `json:"hasSourceURL,omitempty"`

// IsModule (optional) True, if this script is ES6 module.
IsModule bool `json:"isModule,omitempty"`
IsModule *bool `json:"isModule,omitempty"`

// Length (optional) This script length.
Length *int `json:"length,omitempty"`
Expand Down Expand Up @@ -1220,16 +1220,16 @@ type DebuggerScriptParsed struct {
ExecutionContextAuxData map[string]gson.JSON `json:"executionContextAuxData,omitempty"`

// IsLiveEdit (experimental) (optional) True, if this script is generated as a result of the live edit operation.
IsLiveEdit bool `json:"isLiveEdit,omitempty"`
IsLiveEdit *bool `json:"isLiveEdit,omitempty"`

// SourceMapURL (optional) URL of source map associated with script (if any).
SourceMapURL string `json:"sourceMapURL,omitempty"`

// HasSourceURL (optional) True, if this script has sourceURL.
HasSourceURL bool `json:"hasSourceURL,omitempty"`
HasSourceURL *bool `json:"hasSourceURL,omitempty"`

// IsModule (optional) True, if this script is ES6 module.
IsModule bool `json:"isModule,omitempty"`
IsModule *bool `json:"isModule,omitempty"`

// Length (optional) This script length.
Length *int `json:"length,omitempty"`
Expand Down
6 changes: 3 additions & 3 deletions lib/proto/dom.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ type DOMNode struct {
DistributedNodes []*DOMBackendNode `json:"distributedNodes,omitempty"`

// IsSVG (optional) Whether the node is SVG.
IsSVG bool `json:"isSVG,omitempty"`
IsSVG *bool `json:"isSVG,omitempty"`

// CompatibilityMode (optional) ...
CompatibilityMode DOMCompatibilityMode `json:"compatibilityMode,omitempty"`
Expand Down Expand Up @@ -730,7 +730,7 @@ type DOMGetNodeForLocation struct {
IncludeUserAgentShadowDOM bool `json:"includeUserAgentShadowDOM,omitempty"`

// IgnorePointerEventsNone (optional) Whether to ignore pointer-events: none on elements and hit test them.
IgnorePointerEventsNone bool `json:"ignorePointerEventsNone,omitempty"`
IgnorePointerEventsNone *bool `json:"ignorePointerEventsNone,omitempty"`
}

// ProtoReq name.
Expand Down Expand Up @@ -909,7 +909,7 @@ type DOMPerformSearch struct {
Query string `json:"query"`

// IncludeUserAgentShadowDOM (optional) True to search in user agent shadow DOM.
IncludeUserAgentShadowDOM bool `json:"includeUserAgentShadowDOM,omitempty"`
IncludeUserAgentShadowDOM *bool `json:"includeUserAgentShadowDOM,omitempty"`
}

// ProtoReq name.
Expand Down
Loading