Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix broken screen farbling regression test #17341

Merged
merged 1 commit into from
Feb 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions browser/farbling/brave_screen_farbling_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class BraveScreenFarblingBrowserTest : public InProcessBrowserTest {

gfx::Rect SetBounds(const gfx::Rect& bounds) {
browser()->window()->SetBounds(bounds);
content::RunAllPendingInMessageLoop();
return browser()->window()->GetBounds();
}

Expand Down Expand Up @@ -273,20 +274,17 @@ class BraveScreenFarblingBrowserTest : public InProcessBrowserTest {

void FarbleScreenPopupPosition(int j) {
gfx::Rect parent_bounds;
// Make sure parent_bounds dimensions aren't unexpectedly large.
do {
parent_bounds = SetBounds(kTestWindowBounds[j]);
} while (parent_bounds.width() > 600 || parent_bounds.height() > 600);
parent_bounds = SetBounds(kTestWindowBounds[j]);
for (bool allow_fingerprinting : {false, true}) {
SetFingerprintingSetting(allow_fingerprinting);
NavigateToURLUntilLoadStop(parent_url());
for (bool test_iframe : {false, true}) {
const char* script =
"open('/simple.html', '', `"
"left=10,"
"top=10,"
"width=${outerWidth + 200},"
"height=${outerHeight + 200}"
"left=30,"
"top=30,"
"width=${outerWidth + 20},"
"height=${outerHeight + 20}"
"`);";
Browser* popup = OpenPopup(script, test_iframe);
auto* popup_contents = popup->tab_strip_model()->GetActiveWebContents();
Expand All @@ -310,19 +308,19 @@ class BraveScreenFarblingBrowserTest : public InProcessBrowserTest {
popup->window()->GetNativeWindow());

auto bounds_before = popup->window()->GetBounds();
auto waiter2 = WidgetBoundsChangeWaiter(widget, 10);
auto waiter1 = WidgetBoundsChangeWaiter(widget, 10);
ASSERT_TRUE(ExecJs(popup_contents,
"resizeTo(outerWidth - 13, outerHeight - 14)"));
waiter2.Wait();
waiter1.Wait();
auto bounds_after = popup->window()->GetBounds();
EXPECT_EQ(-13, bounds_after.width() - bounds_before.width());
EXPECT_EQ(-14, bounds_after.height() - bounds_before.height());

bounds_before = popup->window()->GetBounds();
auto waiter = WidgetBoundsChangeWaiter(widget, 10);
auto waiter2 = WidgetBoundsChangeWaiter(widget, 10);
ASSERT_TRUE(
ExecJs(popup_contents, "moveTo(screenX + 11, screenY + 12)"));
waiter.Wait();
waiter2.Wait();
bounds_after = popup->window()->GetBounds();
EXPECT_EQ(11, bounds_after.x() - bounds_before.x());
EXPECT_EQ(12, bounds_after.y() - bounds_before.y());
Expand Down