Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore(ff): remove some dead code (#6423)
Pavel Feldman765d74987f69
diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBERindex 971be60f4e..b0ad0dfbc1 100644--- a/browser_patches/firefox/BUILD_NUMBER+++ b/browser_patches/firefox/BUILD_NUMBER@@ -1,2 +1,2 @@-1252-Changed: [email protected] Tue 04 May 2021 02:47:58 AM PDT+1253+Changed: [email protected] Wed 05 May 2021 01:22:39 PM PDTdiff --git a/browser_patches/firefox/juggler/TargetRegistry.js b/browser_patches/firefox/juggler/TargetRegistry.jsindex 0e646c83f2..09f05bc0a9 100644--- a/browser_patches/firefox/juggler/TargetRegistry.js+++ b/browser_patches/firefox/juggler/TargetRegistry.js@@ -488,7 +488,7 @@ class PageTarget {return await this._channel.connect('').send('hasFailedToOverrideTimezone').catch(e => true);}- async _startVideoRecording({width, height, scale, dir}) {+ async _startVideoRecording({width, height, dir}) {// On Mac the window may not yet be visible when TargetCreated and its// NSWindow.windowNumber may be -1, so we wait until the window is known// to be initialized and visible.@@ -496,16 +496,13 @@ class PageTarget {const file = OS.Path.join(dir, helper.generateId() + '.webm');if (width < 10 || width > 10000 || height < 10 || height > 10000)throw new Error("Invalid size");- if (scale && (scale <= 0 || scale > 1))- throw new Error("Unsupported scale");const screencast = Cc['@mozilla.org/juggler/screencast;1'].getService(Ci.nsIScreencastService);const docShell = this._gBrowser.ownerGlobal.docShell;// Exclude address bar and navigation control from the video.const rect = this.linkedBrowser().getBoundingClientRect();const devicePixelRatio = this._window.devicePixelRatio;- const viewport = this._viewportSize || this._browserContext.defaultViewportSize || {width: 0, height: 0};- const videoSessionId = screencast.startVideoRecording(docShell, file, width, height, viewport.width, viewport.height, scale || 0, devicePixelRatio * rect.top);+ const videoSessionId = screencast.startVideoRecording(docShell, file, width, height, devicePixelRatio * rect.top);this._screencastInfo = { videoSessionId, file };this.emit(PageTarget.Events.ScreencastStarted);}diff --git a/browser_patches/firefox/juggler/protocol/PageHandler.js b/browser_patches/firefox/juggler/protocol/PageHandler.jsindex b5b52d106d..3989d54b1f 100644--- a/browser_patches/firefox/juggler/protocol/PageHandler.js+++ b/browser_patches/firefox/juggler/protocol/PageHandler.js@@ -379,10 +379,6 @@ class PageHandler {throw new Error('ERROR: cannot find worker with id ' + workerId);return await worker.sendMessage(JSON.parse(message));}-- async ['Page.stopVideoRecording']() {- await this._pageTarget.stopVideoRecording();- }}var EXPORTED_SYMBOLS = ['PageHandler'];diff --git a/browser_patches/firefox/juggler/protocol/Protocol.js b/browser_patches/firefox/juggler/protocol/Protocol.jsindex c9693b162b..ba7fa099e2 100644--- a/browser_patches/firefox/juggler/protocol/Protocol.js+++ b/browser_patches/firefox/juggler/protocol/Protocol.js@@ -426,7 +426,6 @@ const Browser = {dir: t.String,width: t.Number,height: t.Number,- scale: t.Optional(t.Number),},},},@@ -896,16 +895,6 @@ const Page = {message: t.String,},},- 'startVideoRecording': {- params: {- file: t.String,- width: t.Number,- height: t.Number,- scale: t.Optional(t.Number),- },- },- 'stopVideoRecording': {- },},};diff --git a/browser_patches/firefox/juggler/screencast/ScreencastEncoder.cpp b/browser_patches/firefox/juggler/screencast/ScreencastEncoder.cppindex d0352f1cfa..981bbc9915 100644--- a/browser_patches/firefox/juggler/screencast/ScreencastEncoder.cpp+++ b/browser_patches/firefox/juggler/screencast/ScreencastEncoder.cpp@@ -110,9 +110,8 @@ void createImage(unsigned int width, unsigned int height,class ScreencastEncoder::VPXFrame {public:- VPXFrame(rtc::scoped_refptr<webrtc::VideoFrameBuffer>&& buffer, Maybe<double> scale, const gfx::IntMargin& margin)+ VPXFrame(rtc::scoped_refptr<webrtc::VideoFrameBuffer>&& buffer, const gfx::IntMargin& margin): m_frameBuffer(std::move(buffer))- , m_scale(scale), m_margin(margin){ }@@ -137,8 +136,8 @@ public:double src_width = src->width() - m_margin.LeftRight();double src_height = src->height() - m_margin.top;- if (m_scale || (src_width > image->w || src_height > image->h)) {- double scale = m_scale ? m_scale.value() : std::min(image->w / src_width, image->h / src_height);+ if (src_width > image->w || src_height > image->h) {+ double scale = std::min(image->w / src_width, image->h / src_height);double dst_width = src_width * scale;if (dst_width > image->w) {src_width *= image->w / dst_width;@@ -174,7 +173,6 @@ public:private:rtc::scoped_refptr<webrtc::VideoFrameBuffer> m_frameBuffer;- Maybe<double> m_scale;gfx::IntMargin m_margin;TimeDuration m_duration;};@@ -276,9 +274,8 @@ private:std::unique_ptr<vpx_image_t> m_image;};-ScreencastEncoder::ScreencastEncoder(std::unique_ptr<VPXCodec>&& vpxCodec, Maybe<double> scale, const gfx::IntMargin& margin)+ScreencastEncoder::ScreencastEncoder(std::unique_ptr<VPXCodec>&& vpxCodec, const gfx::IntMargin& margin): m_vpxCodec(std::move(vpxCodec))- , m_scale(scale), m_margin(margin){}@@ -287,7 +284,7 @@ ScreencastEncoder::~ScreencastEncoder(){}-RefPtr<ScreencastEncoder> ScreencastEncoder::create(nsCString& errorString, const nsCString& filePath, int width, int height, Maybe<double> scale, const gfx::IntMargin& margin)+RefPtr<ScreencastEncoder> ScreencastEncoder::create(nsCString& errorString, const nsCString& filePath, int width, int height, const gfx::IntMargin& margin){vpx_codec_iface_t* codec_interface = vpx_codec_vp8_cx();if (!codec_interface) {@@ -328,7 +325,7 @@ RefPtr<ScreencastEncoder> ScreencastEncoder::create(nsCString& errorString, consstd::unique_ptr<VPXCodec> vpxCodec(new VPXCodec(codec, cfg, file));// fprintf(stderr, "ScreencastEncoder initialized with: %s\n", vpx_codec_iface_name(codec_interface));- return new ScreencastEncoder(std::move(vpxCodec), scale, margin);+ return new ScreencastEncoder(std::move(vpxCodec), margin);}void ScreencastEncoder::flushLastFrame()@@ -350,7 +347,7 @@ void ScreencastEncoder::encodeFrame(const webrtc::VideoFrame& videoFrame)// fprintf(stderr, "ScreencastEncoder::encodeFrame\n");flushLastFrame();- m_lastFrame = std::make_unique<VPXFrame>(videoFrame.video_frame_buffer(), m_scale, m_margin);+ m_lastFrame = std::make_unique<VPXFrame>(videoFrame.video_frame_buffer(), m_margin);}void ScreencastEncoder::finish(std::function<void()>&& callback)diff --git a/browser_patches/firefox/juggler/screencast/ScreencastEncoder.h b/browser_patches/firefox/juggler/screencast/ScreencastEncoder.hindex b6827800bc..bfc9b69e76 100644--- a/browser_patches/firefox/juggler/screencast/ScreencastEncoder.h+++ b/browser_patches/firefox/juggler/screencast/ScreencastEncoder.h@@ -23,10 +23,10 @@ class ScreencastEncoder {public:static constexpr int fps = 25;- static RefPtr<ScreencastEncoder> create(nsCString& errorString, const nsCString& filePath, int width, int height, Maybe<double> scale, const gfx::IntMargin& margin);+ static RefPtr<ScreencastEncoder> create(nsCString& errorString, const nsCString& filePath, int width, int height, const gfx::IntMargin& margin);class VPXCodec;- ScreencastEncoder(std::unique_ptr<VPXCodec>&&, Maybe<double> scale, const gfx::IntMargin& margin);+ ScreencastEncoder(std::unique_ptr<VPXCodec>&&, const gfx::IntMargin& margin);void encodeFrame(const webrtc::VideoFrame& videoFrame);@@ -38,7 +38,6 @@ private:void flushLastFrame();std::unique_ptr<VPXCodec> m_vpxCodec;- Maybe<double> m_scale;gfx::IntMargin m_margin;TimeStamp m_lastFrameTimestamp;class VPXFrame;diff --git a/browser_patches/firefox/juggler/screencast/nsIScreencastService.idl b/browser_patches/firefox/juggler/screencast/nsIScreencastService.idlindex b7edfe3c1a..d39760371f 100644--- a/browser_patches/firefox/juggler/screencast/nsIScreencastService.idl+++ b/browser_patches/firefox/juggler/screencast/nsIScreencastService.idl@@ -12,7 +12,7 @@ interface nsIDocShell;[scriptable, uuid(d8c4d9e0-9462-445e-9e43-68d3872ad1de)]interface nsIScreencastService : nsISupports{- AString startVideoRecording(in nsIDocShell docShell, in ACString fileName, in uint32_t width, in uint32_t height, in uint32_t viewportWidth, in uint32_t viewportHeight, in double scale, in int32_t offset_top);+ AString startVideoRecording(in nsIDocShell docShell, in ACString fileName, in uint32_t width, in uint32_t height, in int32_t offset_top);/*** Will emit 'juggler-screencast-stopped' when the video file is saved.diff --git a/browser_patches/firefox/juggler/screencast/nsScreencastService.cpp b/browser_patches/firefox/juggler/screencast/nsScreencastService.cppindex cbebd9fbc1..d91f31c2c9 100644--- a/browser_patches/firefox/juggler/screencast/nsScreencastService.cpp+++ b/browser_patches/firefox/juggler/screencast/nsScreencastService.cpp@@ -140,7 +140,7 @@ nsScreencastService::nsScreencastService() = default;nsScreencastService::~nsScreencastService() {}-nsresult nsScreencastService::StartVideoRecording(nsIDocShell* aDocShell, const nsACString& aFileName, uint32_t width, uint32_t height, uint32_t viewportWidth, uint32_t viewportHeight, double scale, int32_t offsetTop, nsAString& sessionId) {+nsresult nsScreencastService::StartVideoRecording(nsIDocShell* aDocShell, const nsACString& aFileName, uint32_t width, uint32_t height, int32_t offsetTop, nsAString& sessionId) {MOZ_RELEASE_ASSERT(NS_IsMainThread(), "Screencast service must be started on the Main thread.");PresShell* presShell = aDocShell->GetPresShell();@@ -158,23 +158,16 @@ nsresult nsScreencastService::StartVideoRecording(nsIDocShell* aDocShell, constif (!capturer)return NS_ERROR_FAILURE;- nsCString error;- Maybe<double> maybeScale;- if (scale)- maybeScale = Some(scale);-gfx::IntMargin margin;auto bounds = widget->GetScreenBounds().ToUnknownRect();auto clientBounds = widget->GetClientBounds().ToUnknownRect();- // The browser window has a minimum size, so it might be larger than the viewport size.- clientBounds.width = std::min((int)viewportWidth, clientBounds.width);- clientBounds.height = std::min((int)viewportHeight, clientBounds.height);// Crop the image to exclude frame (if any).margin = bounds - clientBounds;// Crop the image to exclude controls.margin.top += offsetTop;- RefPtr<ScreencastEncoder> encoder = ScreencastEncoder::create(error, PromiseFlatCString(aFileName), width, height, maybeScale, margin);+ nsCString error;+ RefPtr<ScreencastEncoder> encoder = ScreencastEncoder::create(error, PromiseFlatCString(aFileName), width, height, margin);if (!encoder) {fprintf(stderr, "Failed to create ScreencastEncoder: %s\n", error.get());return NS_ERROR_FAILURE;