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): screencast for Mac headful (#2985)

Yury Semikhatsky89ccf99b9088
diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBER
index 243bc3c3a5..aaea94d989 100644
--- a/browser_patches/firefox/BUILD_NUMBER
+++ b/browser_patches/firefox/BUILD_NUMBER
@@ -1,2 +1,2 @@
-1129
-Changed: [email protected] Wed Jul 15 23:55:13 GMTST 2020
+1130
+Changed: [email protected] Thu Jul 16 15:31:21 PDT 2020
diff --git a/browser_patches/firefox/juggler/protocol/PageHandler.js b/browser_patches/firefox/juggler/protocol/PageHandler.js
index 96e6ad06ac..0ca7fa6f11 100644
--- a/browser_patches/firefox/juggler/protocol/PageHandler.js
+++ b/browser_patches/firefox/juggler/protocol/PageHandler.js
@@ -296,7 +296,8 @@ class PageHandler {
const docShell = this._pageTarget._gBrowser.ownerGlobal.docShell;
// Exclude address bar and navigation control from the video.
const rect = this._pageTarget.linkedBrowser().getBoundingClientRect();
- this._videoSessionId = screencast.startVideoRecording(docShell, file, width, height, scale || 0, rect.top);
+ const devicePixelRatio = this._pageTarget._window.devicePixelRatio;
+ this._videoSessionId = screencast.startVideoRecording(docShell, file, width, height, scale || 0, devicePixelRatio * rect.top);
}
stopVideoRecording() {
diff --git a/browser_patches/firefox/juggler/screencast/nsScreencastService.cpp b/browser_patches/firefox/juggler/screencast/nsScreencastService.cpp
index 94afa75997..eb3b9d0153 100644
--- a/browser_patches/firefox/juggler/screencast/nsScreencastService.cpp
+++ b/browser_patches/firefox/juggler/screencast/nsScreencastService.cpp
@@ -37,30 +37,14 @@ rtc::scoped_refptr<webrtc::VideoCaptureModule> CreateWindowCapturer(nsIWidget* w
HeadlessWidget* headlessWidget = static_cast<HeadlessWidget*>(widget);
return HeadlessWindowCapturer::Create(headlessWidget);
}
-#ifdef MOZ_WIDGET_GTK
- mozilla::widget::CompositorWidgetInitData initData;
- widget->GetCompositorWidgetInitData(&initData);
- const mozilla::widget::GtkCompositorWidgetInitData& gtkInitData = initData.get_GtkCompositorWidgetInitData();
- nsCString windowId;
-# ifdef MOZ_X11
- windowId.AppendPrintf("%lu", gtkInitData.XWindow());
- return webrtc::DesktopCaptureImpl::Create(sessionId, windowId.get(), webrtc::CaptureDeviceType::Window);
-# else
- // TODO: support in wayland
- fprintf(stderr, "Video capture for Wayland is not implemented\n");
- return nullptr;
-# endif
-#elif defined(_WIN32)
- mozilla::widget::CompositorWidgetInitData initData;
- widget->GetCompositorWidgetInitData(&initData);
- const mozilla::widget::WinCompositorWidgetInitData& winInitData = initData.get_WinCompositorWidgetInitData();
+ uintptr_t rawWindowId = reinterpret_cast<uintptr_t>(widget->GetNativeData(NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID));
+ if (!rawWindowId) {
+ fprintf(stderr, "Failed to get native window id\n");
+ return nullptr;
+ }
nsCString windowId;
- windowId.AppendPrintf("%lu", winInitData.hWnd());
+ windowId.AppendPrintf("%" PRIuPTR, rawWindowId);
return webrtc::DesktopCaptureImpl::Create(sessionId, windowId.get(), webrtc::CaptureDeviceType::Window);
-#else
- fprintf(stderr, "Video capture is not implemented on this platform\n");
- return nullptr;
-#endif
}
}