Skip to content

Commit a1b6055

Browse files
authored
chore: roll to Playwright v1.47.0 (#480)
1 parent 9a40c60 commit a1b6055

31 files changed

+1310
-431
lines changed

.github/workflows/build.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Set up Go 1.x
1414
uses: actions/setup-go@v5
1515
with:
16-
go-version: ^1.19.9
16+
go-version: oldstable
1717
id: go
1818
- name: golangci-lint
1919
uses: golangci/golangci-lint-action@v6
@@ -27,16 +27,17 @@ jobs:
2727
# https://github.com/microsoft/playwright/issues/30705 is fixed.
2828
os: [ubuntu-latest, windows-latest, macos-13]
2929
browser: [chromium, firefox, webkit]
30+
go: ['stable', 'oldstable']
3031
runs-on: ${{ matrix.os }}
31-
name: ${{ matrix.browser }} on ${{ matrix.os }}
32+
name: ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }}
3233
steps:
3334
- uses: actions/checkout@v4
3435
with:
3536
submodules: true
3637
- name: Set up Go
3738
uses: actions/setup-go@v5
3839
with:
39-
go-version: ^1.19.9
40+
go-version: ${{ matrix.go }}
4041
id: go
4142
- name: Cache drivers
4243
uses: actions/cache@v4
@@ -52,7 +53,7 @@ jobs:
5253
~/Library/Caches/ms-playwright
5354
~\AppData\Local\ms-playwright-go
5455
~\AppData\Local\ms-playwright
55-
key: ${{ runner.os }}-go-${{ matrix.browser }}-${{ hashFiles('**/run.go') }}
56+
key: ${{ runner.os }}-go${{ matrix.go }}-${{ matrix.browser }}-${{ hashFiles('**/run.go') }}
5657
- run: |
5758
go install ./...
5859
playwright install --with-deps ${{ matrix.browser }}
@@ -84,7 +85,7 @@ jobs:
8485
- name: Set up Go
8586
uses: actions/setup-go@v5
8687
with:
87-
go-version: ^1.19.9
88+
go-version: oldstable
8889
id: go
8990
- name: Install goveralls
9091
run: go install github.com/mattn/goveralls@latest
@@ -99,7 +100,7 @@ jobs:
99100
- name: Set up Go 1.x
100101
uses: actions/setup-go@v5
101102
with:
102-
go-version: ^1.19.9
103+
go-version: oldstable
103104
id: go
104105
- run: |
105106
go install ./...

.github/workflows/verify_type_generation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Set up Go
1515
uses: actions/setup-go@v5
1616
with:
17-
go-version: ^1.19.9
17+
go-version: oldstable
1818
- name: Install gofumpt
1919
run: go install mvdan.cc/gofumpt@latest
2020
- name: Install Browsers

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
[![PkgGoDev](https://pkg.go.dev/badge/github.com/playwright-community/playwright-go)](https://pkg.go.dev/github.com/playwright-community/playwright-go)
66
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](http://opensource.org/licenses/MIT)
77
[![Go Report Card](https://goreportcard.com/badge/github.com/playwright-community/playwright-go)](https://goreportcard.com/report/github.com/playwright-community/playwright-go) ![Build Status](https://github.com/playwright-community/playwright-go/workflows/Go/badge.svg)
8-
[![Join Slack](https://img.shields.io/badge/join-slack-infomational)](https://aka.ms/playwright-slack) [![Coverage Status](https://coveralls.io/repos/github/playwright-community/playwright-go/badge.svg?branch=main)](https://coveralls.io/github/playwright-community/playwright-go?branch=main) <!-- GEN:chromium-version-badge -->[![Chromium version](https://img.shields.io/badge/chromium-127.0.6533.17-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-127.0-blue.svg?logo=mozilla-firefox)](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> <!-- GEN:webkit-version-badge -->[![WebKit version](https://img.shields.io/badge/webkit-17.4-blue.svg?logo=safari)](https://webkit.org/)<!-- GEN:stop -->
8+
[![Join Slack](https://img.shields.io/badge/join-slack-infomational)](https://aka.ms/playwright-slack) [![Coverage Status](https://coveralls.io/repos/github/playwright-community/playwright-go/badge.svg?branch=main)](https://coveralls.io/github/playwright-community/playwright-go?branch=main) <!-- GEN:chromium-version-badge -->[![Chromium version](https://img.shields.io/badge/chromium-129.0.6668.29-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-130.0-blue.svg?logo=mozilla-firefox)](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> <!-- GEN:webkit-version-badge -->[![WebKit version](https://img.shields.io/badge/webkit-18.0-blue.svg?logo=safari)](https://webkit.org/)<!-- GEN:stop -->
99

1010
[API reference](https://playwright.dev/docs/api/class-playwright) | [Example recipes](https://github.com/playwright-community/playwright-go/tree/main/examples)
1111

1212
Playwright is a Go library to automate [Chromium](https://www.chromium.org/Home), [Firefox](https://www.mozilla.org/en-US/firefox/new/) and [WebKit](https://webkit.org/) with a single API. Playwright is built to enable cross-browser web automation that is **ever-green**, **capable**, **reliable** and **fast**.
1313

1414
| | Linux | macOS | Windows |
1515
| :--- | :---: | :---: | :---: |
16-
| Chromium <!-- GEN:chromium-version -->127.0.6533.17<!-- GEN:stop --> ||||
17-
| WebKit <!-- GEN:webkit-version -->17.4<!-- GEN:stop --> ||||
18-
| Firefox <!-- GEN:firefox-version -->127.0<!-- GEN:stop --> ||||
16+
| Chromium <!-- GEN:chromium-version -->129.0.6668.29<!-- GEN:stop --> ||||
17+
| WebKit <!-- GEN:webkit-version -->18.0<!-- GEN:stop --> ||||
18+
| Firefox <!-- GEN:firefox-version -->130.0<!-- GEN:stop --> ||||
1919

2020
Headless execution is supported for all the browsers on all platforms.
2121

browser.go

+55
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package playwright
22

33
import (
4+
"encoding/base64"
45
"encoding/json"
56
"errors"
67
"fmt"
@@ -46,6 +47,14 @@ func (b *browserImpl) NewContext(options ...BrowserNewContextOptions) (BrowserCo
4647
overrides["extraHTTPHeaders"] = serializeMapToNameAndValue(options[0].ExtraHttpHeaders)
4748
options[0].ExtraHttpHeaders = nil
4849
}
50+
if option.ClientCertificates != nil {
51+
certs, err := transformClientCertificate(option.ClientCertificates)
52+
if err != nil {
53+
return nil, err
54+
}
55+
overrides["clientCertificates"] = certs
56+
options[0].ClientCertificates = nil
57+
}
4958
if option.StorageStatePath != nil {
5059
var storageState *OptionalStorageState
5160
storageString, err := os.ReadFile(*options[0].StorageStatePath)
@@ -217,3 +226,49 @@ func newBrowser(parent *channelOwner, objectType string, guid string, initialize
217226
b.channel.On("close", b.onClose)
218227
return b
219228
}
229+
230+
func transformClientCertificate(clientCertificates []ClientCertificate) ([]map[string]interface{}, error) {
231+
results := make([]map[string]interface{}, 0)
232+
233+
for _, cert := range clientCertificates {
234+
data := map[string]interface{}{
235+
"origin": cert.Origin,
236+
"passphrase": cert.Passphrase,
237+
}
238+
if len(cert.Cert) > 0 {
239+
data["cert"] = base64.StdEncoding.EncodeToString(cert.Cert)
240+
} else if cert.CertPath != nil {
241+
content, err := os.ReadFile(*cert.CertPath)
242+
if err != nil {
243+
return nil, err
244+
}
245+
data["cert"] = base64.StdEncoding.EncodeToString(content)
246+
}
247+
248+
if len(cert.Key) > 0 {
249+
data["key"] = base64.StdEncoding.EncodeToString(cert.Key)
250+
} else if cert.KeyPath != nil {
251+
content, err := os.ReadFile(*cert.KeyPath)
252+
if err != nil {
253+
return nil, err
254+
}
255+
data["key"] = base64.StdEncoding.EncodeToString(content)
256+
}
257+
258+
if len(cert.Pfx) > 0 {
259+
data["pfx"] = base64.StdEncoding.EncodeToString(cert.Pfx)
260+
} else if cert.PfxPath != nil {
261+
content, err := os.ReadFile(*cert.PfxPath)
262+
if err != nil {
263+
return nil, err
264+
}
265+
data["pfx"] = base64.StdEncoding.EncodeToString(content)
266+
}
267+
268+
results = append(results, data)
269+
}
270+
if len(results) == 0 {
271+
return nil, nil
272+
}
273+
return results, nil
274+
}

browser_type.go

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ func (b *browserTypeImpl) LaunchPersistentContext(userDataDir string, options ..
5252
}
5353
options[0].AcceptDownloads = nil
5454
}
55+
if options[0].ClientCertificates != nil {
56+
certs, err := transformClientCertificate(options[0].ClientCertificates)
57+
if err != nil {
58+
return nil, err
59+
}
60+
overrides["clientCertificates"] = certs
61+
options[0].ClientCertificates = nil
62+
}
5563
if options[0].ExtraHttpHeaders != nil {
5664
overrides["extraHTTPHeaders"] = serializeMapToNameAndValue(options[0].ExtraHttpHeaders)
5765
options[0].ExtraHttpHeaders = nil

fetch.go

+11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ type apiRequestImpl struct {
1616
func (r *apiRequestImpl) NewContext(options ...APIRequestNewContextOptions) (APIRequestContext, error) {
1717
overrides := map[string]interface{}{}
1818
if len(options) == 1 {
19+
if options[0].ClientCertificates != nil {
20+
certs, err := transformClientCertificate(options[0].ClientCertificates)
21+
if err != nil {
22+
return nil, err
23+
}
24+
overrides["clientCertificates"] = certs
25+
options[0].ClientCertificates = nil
26+
}
1927
if options[0].ExtraHttpHeaders != nil {
2028
overrides["extraHTTPHeaders"] = serializeMapToNameAndValue(options[0].ExtraHttpHeaders)
2129
options[0].ExtraHttpHeaders = nil
@@ -105,6 +113,9 @@ func (r *apiRequestContextImpl) innerFetch(url string, request Request, options
105113
if options[0].MaxRedirects != nil && *options[0].MaxRedirects < 0 {
106114
return nil, errors.New("maxRedirects must be non-negative")
107115
}
116+
if options[0].MaxRetries != nil && *options[0].MaxRetries < 0 {
117+
return nil, errors.New("maxRetries must be non-negative")
118+
}
108119
// only one of them can be specified
109120
if countNonNil(options[0].Data, options[0].Form, options[0].Multipart) > 1 {
110121
return nil, errors.New("only one of 'data', 'form' or 'multipart' can be specified")

0 commit comments

Comments
 (0)