Skip to content

Commit

Permalink
[headless] Added default window sizes tests
Browse files Browse the repository at this point in the history
Web Platform Tests have a problem with window.outerWidth/Height
being zero when running against headless shell,
see https://crbug.com/339909604.

This CL adds a test to verify this problem.

Bug: 347324963
Change-Id: Ieea73021002d56ff08fcff79aa7ba6d07cd1b95b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5633124
Reviewed-by: Andrey Kosyakov <[email protected]>
Commit-Queue: Peter Kvitek <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1315493}
  • Loading branch information
Peter Kvitek authored and Chromium LUCI CQ committed Jun 14, 2024
1 parent c6190b6 commit e9d89f8
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions headless/test/headless_browser_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -345,22 +345,28 @@ IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, DefaultSizes) {
HeadlessBrowser::Options::Builder builder;
const HeadlessBrowser::Options kDefaultOptions = builder.Build();

const int expected_width = kDefaultOptions.window_size.width();
const int expected_height = kDefaultOptions.window_size.height();

// The screen size on macOS appears to be set to the actual desktop size, not
// the headless default window size as it is on other platforms. See
// https://crbug.com/347324963
#if !BUILDFLAG(IS_MAC)
// On Mac headless does not override the screen dimensions, so they are
// left with the actual screen values.
EXPECT_THAT(
EvaluateScript(web_contents, "screen.width"),
DictHasValue("result.result.value", kDefaultOptions.window_size.width()));
EXPECT_THAT(EvaluateScript(web_contents, "screen.width"),
DictHasValue("result.result.value", expected_width));
EXPECT_THAT(EvaluateScript(web_contents, "screen.height"),
DictHasValue("result.result.value",
kDefaultOptions.window_size.height()));
#endif // !BUILDFLAG(IS_MAC)
EXPECT_THAT(
EvaluateScript(web_contents, "window.innerWidth"),
DictHasValue("result.result.value", kDefaultOptions.window_size.width()));
DictHasValue("result.result.value", expected_height));
#endif

EXPECT_THAT(EvaluateScript(web_contents, "window.outerWidth"),
DictHasValue("result.result.value", expected_width));
EXPECT_THAT(EvaluateScript(web_contents, "window.outerHeight"),
DictHasValue("result.result.value", expected_height));

EXPECT_THAT(EvaluateScript(web_contents, "window.innerWidth"),
DictHasValue("result.result.value", expected_width));
EXPECT_THAT(EvaluateScript(web_contents, "window.innerHeight"),
DictHasValue("result.result.value",
kDefaultOptions.window_size.height()));
DictHasValue("result.result.value", expected_height));
}

// TODO(skyostil): This test currently relies on being able to run a shell
Expand Down

0 comments on commit e9d89f8

Please sign in to comment.