summaryrefslogtreecommitdiff
path: root/vendor/github.com/playwright-community/playwright-go/video.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-31 16:09:12 -0600
committermo khan <mo@mokhan.ca>2025-07-31 16:09:12 -0600
commit311603d0c0b04d451e9fb8e5e8335dca8425e2c4 (patch)
treef38db8e10c4b55aef21c96c30fc71278c6e3d5c6 /vendor/github.com/playwright-community/playwright-go/video.go
parentebb003ef2beaeee61104d6b88a342c5c9fa73b51 (diff)
Connect to postgresql
Diffstat (limited to 'vendor/github.com/playwright-community/playwright-go/video.go')
-rw-r--r--vendor/github.com/playwright-community/playwright-go/video.go97
1 files changed, 0 insertions, 97 deletions
diff --git a/vendor/github.com/playwright-community/playwright-go/video.go b/vendor/github.com/playwright-community/playwright-go/video.go
deleted file mode 100644
index a57b61a..0000000
--- a/vendor/github.com/playwright-community/playwright-go/video.go
+++ /dev/null
@@ -1,97 +0,0 @@
-package playwright
-
-import (
- "errors"
- "sync"
-)
-
-type videoImpl struct {
- page *pageImpl
- artifact *artifactImpl
- artifactChan chan *artifactImpl
- done chan struct{}
- closeOnce sync.Once
- isRemote bool
-}
-
-func (v *videoImpl) Path() (string, error) {
- if v.isRemote {
- return "", errors.New("Path is not available when connecting remotely. Use SaveAs() to save a local copy.")
- }
- v.getArtifact()
- if v.artifact == nil {
- return "", errors.New("Page did not produce any video frames")
- }
- return v.artifact.AbsolutePath(), nil
-}
-
-func (v *videoImpl) Delete() error {
- v.getArtifact()
- if v.artifact == nil {
- return nil
- }
- return v.artifact.Delete()
-}
-
-func (v *videoImpl) SaveAs(path string) error {
- if !v.page.IsClosed() {
- return errors.New("Page is not yet closed. Close the page prior to calling SaveAs")
- }
- v.getArtifact()
- if v.artifact == nil {
- return errors.New("Page did not produce any video frames")
- }
- return v.artifact.SaveAs(path)
-}
-
-func (v *videoImpl) artifactReady(artifact *artifactImpl) {
- v.artifactChan <- artifact
-}
-
-func (v *videoImpl) pageClosed(p Page) {
- v.closeOnce.Do(func() {
- close(v.done)
- })
-}
-
-func (v *videoImpl) getArtifact() {
- // prevent channel block if no video will be produced
- if v.page.browserContext.options == nil {
- v.pageClosed(v.page)
- } else {
- option := v.page.browserContext.options
- if option == nil || option.RecordVideo == nil { // no recordVideo option
- v.pageClosed(v.page)
- }
- }
- select {
- case artifact := <-v.artifactChan:
- if artifact != nil {
- v.artifact = artifact
- }
- case <-v.done: // page closed
- select { // make sure get artifact if it's ready before page closed
- case artifact := <-v.artifactChan:
- if artifact != nil {
- v.artifact = artifact
- }
- default:
- }
- }
-}
-
-func newVideo(page *pageImpl) *videoImpl {
- video := &videoImpl{
- page: page,
- artifactChan: make(chan *artifactImpl, 1),
- done: make(chan struct{}, 1),
- isRemote: page.connection.isRemote,
- }
-
- if page.isClosed {
- video.pageClosed(page)
- } else {
- page.OnClose(video.pageClosed)
- }
- return video
-}