Skip to content

Commit 5a4d7c0

Browse files
committed
Updating cdproto
1 parent f6fdfdd commit 5a4d7c0

File tree

4 files changed

+40
-12
lines changed

4 files changed

+40
-12
lines changed

chromedp_test.go

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"os"
1616
"path"
1717
"path/filepath"
18+
"slices"
1819
"strings"
1920
"sync"
2021
"sync/atomic"
@@ -905,7 +906,7 @@ func TestBrowserContext(t *testing.T) {
905906
t.Fatal(err)
906907
}
907908

908-
disposed := !contains(ids, want)
909+
disposed := !slices.Contains(ids, want)
909910

910911
if disposed != tt.wantDisposed {
911912
t.Errorf("browser context disposed = %v, want %v", disposed, tt.wantDisposed)
@@ -1516,7 +1517,7 @@ func TestPDFTemplate(t *testing.T) {
15161517
t.Fatal(err)
15171518
}
15181519

1519-
want := []byte("PDF Template -- about:blank" + "(1 / 1)" + "Hello World!")
1520+
want := []byte("Hello World!PDF Template -- about:blank(1 / 1)")
15201521
l := len(want)
15211522
// try to reuse buf
15221523
if len(buf) >= l {
@@ -1535,11 +1536,39 @@ func TestPDFTemplate(t *testing.T) {
15351536
}
15361537
}
15371538

1538-
func contains(v []cdp.BrowserContextID, id cdp.BrowserContextID) bool {
1539-
for _, i := range v {
1540-
if i == id {
1541-
return true
1542-
}
1539+
// regression test for https://github.com/chromedp/chromedp/issues/1551
1540+
func TestPDFBackground(t *testing.T) {
1541+
t.Parallel()
1542+
1543+
ctx, cancel := testAllocate(t, "")
1544+
defer cancel()
1545+
1546+
var buf []byte
1547+
if err := Run(ctx,
1548+
Navigate("about:blank"),
1549+
ActionFunc(func(ctx context.Context) error {
1550+
frameTree, err := page.GetFrameTree().Do(ctx)
1551+
if err != nil {
1552+
return err
1553+
}
1554+
return page.SetDocumentContent(frameTree.Frame.ID, `
1555+
<html lang="en">
1556+
<head></head>
1557+
<body style="background-color:green">
1558+
<p>Lorem ipsum</p>
1559+
</body>
1560+
</html>
1561+
`).Do(ctx)
1562+
}),
1563+
ActionFunc(func(ctx context.Context) error {
1564+
var err error
1565+
buf, _, err = page.PrintToPDF().Do(ctx)
1566+
return err
1567+
}),
1568+
); err != nil {
1569+
t.Fatal(err)
1570+
}
1571+
if err := os.WriteFile("background.pdf", buf, 0o644); err != nil {
1572+
t.Fatal(err)
15431573
}
1544-
return false
15451574
}

example_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,6 @@ func ExampleEvaluate() {
740740
// Output:
741741
// 3
742742
// encountered an undefined value
743-
// encountered a null value
744743
// <nil>
745744
// [1 2]
746745
// slice is nil: true

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/chromedp/chromedp
33
go 1.23
44

55
require (
6-
github.com/chromedp/cdproto v0.0.0-20250319231242-a755498943c8
6+
github.com/chromedp/cdproto v0.0.0-20250401205909-91afd104e2b8
77
github.com/go-json-experiment/json v0.0.0-20250211171154-1ae217ad3535
88
github.com/gobwas/ws v1.4.0
99
github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/chromedp/cdproto v0.0.0-20250319231242-a755498943c8 h1:AqW2bDQf67Zbq6Tpop/+yJSIknxhiQecO2B8jNYTAPs=
2-
github.com/chromedp/cdproto v0.0.0-20250319231242-a755498943c8/go.mod h1:NItd7aLkcfOA/dcMXvl8p1u+lQqioRMq/SqDp71Pb/k=
1+
github.com/chromedp/cdproto v0.0.0-20250401205909-91afd104e2b8 h1:k5Q26sl2euPK4oyhfIC+84SYKrr+JCRtjYFlDS71s1c=
2+
github.com/chromedp/cdproto v0.0.0-20250401205909-91afd104e2b8/go.mod h1:NItd7aLkcfOA/dcMXvl8p1u+lQqioRMq/SqDp71Pb/k=
33
github.com/chromedp/sysutil v1.1.0 h1:PUFNv5EcprjqXZD9nJb9b/c9ibAbxiYo4exNWZyipwM=
44
github.com/chromedp/sysutil v1.1.0/go.mod h1:WiThHUdltqCNKGc4gaU50XgYjwjYIhKWoHGPTUfWTJ8=
55
github.com/go-json-experiment/json v0.0.0-20250211171154-1ae217ad3535 h1:yE7argOs92u+sSCRgqqe6eF+cDaVhSPlioy1UkA0p/w=

0 commit comments

Comments
 (0)