Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

browser(firefox): support start/stop videos for context (#8173)

Dmitry Gozmandba3c5055fe2
diff --git a/browser_patches/firefox-beta/BUILD_NUMBER b/browser_patches/firefox-beta/BUILD_NUMBER
index 483013339a..4b496aa606 100644
--- a/browser_patches/firefox-beta/BUILD_NUMBER
+++ b/browser_patches/firefox-beta/BUILD_NUMBER
@@ -1,2 +1,2 @@
-1276
-Changed: [email protected] Wed 11 Aug 2021 01:41:01 PM PDT
+1277
+Changed: [email protected] Thu Aug 12 16:33:32 PDT 2021
diff --git a/browser_patches/firefox-beta/juggler/TargetRegistry.js b/browser_patches/firefox-beta/juggler/TargetRegistry.js
index 97850f5e86..84228109f4 100644
--- a/browser_patches/firefox-beta/juggler/TargetRegistry.js
+++ b/browser_patches/firefox-beta/juggler/TargetRegistry.js
@@ -917,11 +917,13 @@ class BrowserContext {
async setVideoRecordingOptions(options) {
this.videoRecordingOptions = options;
- if (!options)
- return;
const promises = [];
- for (const page of this.pages)
- promises.push(page._startVideoRecording(options));
+ for (const page of this.pages) {
+ if (options)
+ promises.push(page._startVideoRecording(options));
+ else if (page._videoRecordingInfo)
+ promises.push(page._stopVideoRecording());
+ }
await Promise.all(promises);
}
}
diff --git a/browser_patches/firefox-beta/juggler/protocol/BrowserHandler.js b/browser_patches/firefox-beta/juggler/protocol/BrowserHandler.js
index 74fa09ac54..e24924afdb 100644
--- a/browser_patches/firefox-beta/juggler/protocol/BrowserHandler.js
+++ b/browser_patches/firefox-beta/juggler/protocol/BrowserHandler.js
@@ -213,8 +213,8 @@ class BrowserHandler {
await this._targetRegistry.browserContextForId(browserContextId).setForcedColors(nullToUndefined(forcedColors));
}
- async ['Browser.setVideoRecordingOptions']({browserContextId, dir, width, height, scale}) {
- await this._targetRegistry.browserContextForId(browserContextId).setVideoRecordingOptions({dir, width, height, scale});
+ async ['Browser.setVideoRecordingOptions']({browserContextId, options}) {
+ await this._targetRegistry.browserContextForId(browserContextId).setVideoRecordingOptions(options);
}
async ['Browser.setUserAgentOverride']({browserContextId, userAgent}) {
diff --git a/browser_patches/firefox-beta/juggler/protocol/Protocol.js b/browser_patches/firefox-beta/juggler/protocol/Protocol.js
index 9f35b38433..910678e955 100644
--- a/browser_patches/firefox-beta/juggler/protocol/Protocol.js
+++ b/browser_patches/firefox-beta/juggler/protocol/Protocol.js
@@ -453,9 +453,11 @@ const Browser = {
'setVideoRecordingOptions': {
params: {
browserContextId: t.Optional(t.String),
- dir: t.String,
- width: t.Number,
- height: t.Number,
+ options: t.Optional({
+ dir: t.String,
+ width: t.Number,
+ height: t.Number,
+ }),
},
},
'cancelDownload': {
diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBER
index ac84447749..a766aa883d 100644
--- a/browser_patches/firefox/BUILD_NUMBER
+++ b/browser_patches/firefox/BUILD_NUMBER
@@ -1,2 +1,2 @@
-1282
-Changed: [email protected] Wed 11 Aug 2021 01:40:40 PM PDT
+1283
+Changed: [email protected] Thu Aug 12 16:33:32 PDT 2021
diff --git a/browser_patches/firefox/juggler/TargetRegistry.js b/browser_patches/firefox/juggler/TargetRegistry.js
index 97850f5e86..84228109f4 100644
--- a/browser_patches/firefox/juggler/TargetRegistry.js
+++ b/browser_patches/firefox/juggler/TargetRegistry.js
@@ -917,11 +917,13 @@ class BrowserContext {
async setVideoRecordingOptions(options) {
this.videoRecordingOptions = options;
- if (!options)
- return;
const promises = [];
- for (const page of this.pages)
- promises.push(page._startVideoRecording(options));
+ for (const page of this.pages) {
+ if (options)
+ promises.push(page._startVideoRecording(options));
+ else if (page._videoRecordingInfo)
+ promises.push(page._stopVideoRecording());
+ }
await Promise.all(promises);
}
}
diff --git a/browser_patches/firefox/juggler/protocol/BrowserHandler.js b/browser_patches/firefox/juggler/protocol/BrowserHandler.js
index 74fa09ac54..e24924afdb 100644
--- a/browser_patches/firefox/juggler/protocol/BrowserHandler.js
+++ b/browser_patches/firefox/juggler/protocol/BrowserHandler.js
@@ -213,8 +213,8 @@ class BrowserHandler {
await this._targetRegistry.browserContextForId(browserContextId).setForcedColors(nullToUndefined(forcedColors));
}
- async ['Browser.setVideoRecordingOptions']({browserContextId, dir, width, height, scale}) {
- await this._targetRegistry.browserContextForId(browserContextId).setVideoRecordingOptions({dir, width, height, scale});
+ async ['Browser.setVideoRecordingOptions']({browserContextId, options}) {
+ await this._targetRegistry.browserContextForId(browserContextId).setVideoRecordingOptions(options);
}
async ['Browser.setUserAgentOverride']({browserContextId, userAgent}) {
diff --git a/browser_patches/firefox/juggler/protocol/Protocol.js b/browser_patches/firefox/juggler/protocol/Protocol.js
index 9f35b38433..910678e955 100644
--- a/browser_patches/firefox/juggler/protocol/Protocol.js
+++ b/browser_patches/firefox/juggler/protocol/Protocol.js
@@ -453,9 +453,11 @@ const Browser = {
'setVideoRecordingOptions': {
params: {
browserContextId: t.Optional(t.String),
- dir: t.String,
- width: t.Number,
- height: t.Number,
+ options: t.Optional({
+ dir: t.String,
+ width: t.Number,
+ height: t.Number,
+ }),
},
},
'cancelDownload': {