tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit cce0baff53452f64206424f9533fff2acc03fa24
parent 001d694b28865a9e454c1725724aee0e3d8340f1
Author: Michael Froman <mfroman@mozilla.com>
Date:   Wed,  8 Oct 2025 18:43:11 -0500

Bug 1993083 - Vendor libwebrtc from 8fc86b7e46

Upstream commit: https://webrtc.googlesource.com/src/+/8fc86b7e46d81b128c79be1bc9743495b64e68d0
    Add tests for FullScreenDetector for WgcCapturer

    Bug: chromium:409473386
    Change-Id: Id096ec907f86faea34e05bcbc819eab3d79e2516
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/398940
    Commit-Queue: Palak Agarwal <agpalak@google.com>
    Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#45075}

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/modules/desktop_capture/win/wgc_capturer_win_unittest.cc | 188+++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------
2 files changed, 128 insertions(+), 64 deletions(-)

diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor @@ -1,4 +1,4 @@ # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-08T23:41:18.001214+00:00. +libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-08T23:43:01.892200+00:00. # base of lastest vendoring -e972e87576 +8fc86b7e46 diff --git a/third_party/libwebrtc/modules/desktop_capture/win/wgc_capturer_win_unittest.cc b/third_party/libwebrtc/modules/desktop_capture/win/wgc_capturer_win_unittest.cc @@ -440,68 +440,6 @@ TEST_F(WgcCapturerWindowTest, FocusOnWindow) { DestroyTestWindow(window_info_); } -TEST_F(WgcCapturerWindowTest, FullScreenWindowDetector) { - capturer_ = WgcCapturerWin::CreateRawWindowCapturer( - DesktopCaptureOptions::CreateDefault()); - - WindowInfo editor_info = CreateTestWindow( - L"My - Title - PowerPoint", /*height=*/240, /*width=*/320, - /*extended_styles=*/0, /*window_class=*/L"PPTFrameClass"); - WindowInfo slide_show_info = CreateTestWindow( - L"PowerPoint Slide Show - [My - Title]", /*height=*/240, /*width=*/320, - /*extended_styles=*/0, /*window_class=*/L"screenClass"); - - auto* wgc_capturer = static_cast<WgcCapturerWin*>(capturer_.get()); - wgc_capturer->SetUpFullScreenDetectorForTest( - /*use_heuristic=*/true, - reinterpret_cast<DesktopCapturer::SourceId>(editor_info.hwnd)); - - EXPECT_TRUE(capturer_->SelectSource( - reinterpret_cast<DesktopCapturer::SourceId>(editor_info.hwnd))); - capturer_->Start(this); - DoCapture(); - - EXPECT_FALSE(wgc_capturer->IsSourceBeingCaptured( - reinterpret_cast<DesktopCapturer::SourceId>(editor_info.hwnd))); - EXPECT_TRUE(wgc_capturer->IsSourceBeingCaptured( - reinterpret_cast<DesktopCapturer::SourceId>(slide_show_info.hwnd))); - EXPECT_EQ(metrics::NumEvents(kCaptureFullscreenDetectorHistogram, true), 1); - - DestroyTestWindow(editor_info); - DestroyTestWindow(slide_show_info); -} - -TEST_F(WgcCapturerWindowTest, FullScreenWindowDetectorDoesNotWorkByDefault) { - capturer_ = WgcCapturerWin::CreateRawWindowCapturer( - DesktopCaptureOptions::CreateDefault()); - - WindowInfo editor_info = CreateTestWindow( - L"My - Title - PowerPoint", /*height=*/240, /*width=*/320, - /*extended_styles=*/0, /*window_class=*/L"PPTFrameClass"); - WindowInfo slide_show_info = CreateTestWindow( - L"PowerPoint Slide Show - [My - Title]", /*height=*/240, /*width=*/320, - /*extended_styles=*/0, /*window_class=*/L"screenClass"); - - auto* wgc_capturer = static_cast<WgcCapturerWin*>(capturer_.get()); - // The default behavior on WGC capturer of `use_heuristic` is false. - wgc_capturer->SetUpFullScreenDetectorForTest( - /*use_heuristic=*/false, - reinterpret_cast<DesktopCapturer::SourceId>(editor_info.hwnd)); - - EXPECT_TRUE(capturer_->SelectSource( - reinterpret_cast<DesktopCapturer::SourceId>(editor_info.hwnd))); - capturer_->Start(this); - DoCapture(); - - EXPECT_TRUE(wgc_capturer->IsSourceBeingCaptured( - reinterpret_cast<DesktopCapturer::SourceId>(editor_info.hwnd))); - EXPECT_FALSE(wgc_capturer->IsSourceBeingCaptured( - reinterpret_cast<DesktopCapturer::SourceId>(slide_show_info.hwnd))); - EXPECT_EQ(metrics::NumEvents(kCaptureFullscreenDetectorHistogram, true), 0); - - DestroyTestWindow(editor_info); - DestroyTestWindow(slide_show_info); -} TEST_F(WgcCapturerWindowTest, SelectMinimizedWindow) { SetUpForWindowCapture(); MinimizeTestWindow(reinterpret_cast<HWND>(source_id_)); @@ -635,4 +573,130 @@ TEST_F(WgcCapturerWindowTest, CloseWindowMidCapture) { EXPECT_EQ(result_, DesktopCapturer::Result::ERROR_PERMANENT); } +class WgcCapturerFullScreenDetectorTest : public WgcCapturerWindowTest { + public: + void SetUp() override { + capturer_ = WgcCapturerWin::CreateRawWindowCapturer( + DesktopCaptureOptions::CreateDefault()); + wgc_capturer_ = static_cast<WgcCapturerWin*>(capturer_.get()); + + editor_window_ = CreateEditorWindow(); + CreateSlideShowWindow(); + WgcCapturerWindowTest::SetUp(); + } + + WindowInfo CreateEditorWindow() { + return CreateTestWindow( + L"My - Title - PowerPoint", kMediumWindowHeight, kMediumWindowWidth, + /*extended_styles=*/0, /*window_class=*/L"PPTFrameClass"); + } + + void CreateSlideShowWindow() { + slide_show_window_ = + CreateTestWindow(L"PowerPoint Slide Show - [My - Title]", + kLargeWindowHeight, kLargeWindowWidth, + /*extended_styles=*/0, + /*window_class=*/L"screenClass"); + } + + WgcCapturerWin* wgc_capturer_; + WindowInfo editor_window_; + WindowInfo slide_show_window_; +}; + +TEST_F(WgcCapturerFullScreenDetectorTest, SlideShowNotFoundByDefaultConfig) { + // The default behavior on WGC capturer of `use_heuristic` is false. + wgc_capturer_->SetUpFullScreenDetectorForTest( + /*use_heuristic=*/false, + reinterpret_cast<DesktopCapturer::SourceId>(editor_window_.hwnd)); + + EXPECT_TRUE(wgc_capturer_->SelectSource( + reinterpret_cast<DesktopCapturer::SourceId>(editor_window_.hwnd))); + wgc_capturer_->Start(this); + DoCapture(); + + EXPECT_TRUE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast<DesktopCapturer::SourceId>(editor_window_.hwnd))); + EXPECT_FALSE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast<DesktopCapturer::SourceId>(slide_show_window_.hwnd))); + EXPECT_EQ(metrics::NumEvents(kCaptureFullscreenDetectorHistogram, true), 0); +} + +TEST_F(WgcCapturerFullScreenDetectorTest, CorrectSlideShowFoundForEditor) { + wgc_capturer_->SetUpFullScreenDetectorForTest( + /*use_heuristic=*/true, + reinterpret_cast<DesktopCapturer::SourceId>(editor_window_.hwnd)); + + EXPECT_TRUE(wgc_capturer_->SelectSource( + reinterpret_cast<DesktopCapturer::SourceId>(editor_window_.hwnd))); + wgc_capturer_->Start(this); + DoCapture(); + + EXPECT_FALSE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast<DesktopCapturer::SourceId>(editor_window_.hwnd))); + EXPECT_TRUE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast<DesktopCapturer::SourceId>(slide_show_window_.hwnd))); + + EXPECT_EQ(metrics::NumEvents(kCaptureFullscreenDetectorHistogram, true), 1); +} + +TEST_F(WgcCapturerFullScreenDetectorTest, LoggedOnlyOnce) { + wgc_capturer_->SetUpFullScreenDetectorForTest( + /*use_heuristic=*/true, + reinterpret_cast<DesktopCapturer::SourceId>(editor_window_.hwnd)); + + EXPECT_TRUE(wgc_capturer_->SelectSource( + reinterpret_cast<DesktopCapturer::SourceId>(editor_window_.hwnd))); + wgc_capturer_->Start(this); + DoCapture(); + ValidateFrame(kLargeWindowWidth, kLargeWindowHeight); + DoCapture(); + ValidateFrame(kLargeWindowWidth, kLargeWindowHeight); + + EXPECT_TRUE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast<DesktopCapturer::SourceId>(slide_show_window_.hwnd))); + EXPECT_EQ(metrics::NumEvents(kCaptureFullscreenDetectorHistogram, true), 1); +} + +TEST_F(WgcCapturerFullScreenDetectorTest, + SlideShowNotFoundWithMultipleSameTitleEditors) { + WindowInfo same_title_editor_window = CreateEditorWindow(); + EXPECT_NE(editor_window_.hwnd, same_title_editor_window.hwnd); + wgc_capturer_->SetUpFullScreenDetectorForTest( + /*use_heuristic=*/true, + reinterpret_cast<DesktopCapturer::SourceId>(editor_window_.hwnd)); + + EXPECT_TRUE(wgc_capturer_->SelectSource( + reinterpret_cast<DesktopCapturer::SourceId>(editor_window_.hwnd))); + wgc_capturer_->Start(this); + DoCapture(); + + EXPECT_TRUE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast<DesktopCapturer::SourceId>(editor_window_.hwnd))); + EXPECT_FALSE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast<DesktopCapturer::SourceId>(slide_show_window_.hwnd))); + EXPECT_EQ(metrics::NumEvents(kCaptureFullscreenDetectorHistogram, true), 0); +} + +TEST_F(WgcCapturerFullScreenDetectorTest, + CaptureTiedToSlideShowIfSlideShowIsShared) { + wgc_capturer_->SetUpFullScreenDetectorForTest( + /*use_heuristic=*/true, + reinterpret_cast<DesktopCapturer::SourceId>(editor_window_.hwnd)); + wgc_capturer_->SetUpFullScreenDetectorForTest( + /*use_heuristic=*/true, + reinterpret_cast<DesktopCapturer::SourceId>(slide_show_window_.hwnd)); + + EXPECT_TRUE(wgc_capturer_->SelectSource( + reinterpret_cast<DesktopCapturer::SourceId>(slide_show_window_.hwnd))); + wgc_capturer_->Start(this); + DoCapture(); + + EXPECT_FALSE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast<DesktopCapturer::SourceId>(editor_window_.hwnd))); + EXPECT_TRUE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast<DesktopCapturer::SourceId>(slide_show_window_.hwnd))); + EXPECT_EQ(metrics::NumEvents(kCaptureFullscreenDetectorHistogram, true), 0); +} + } // namespace webrtc