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

Freetype crash regression test (uplift to 1.51.x) #18373

Merged
merged 1 commit into from
May 8, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions renderer/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ source_set("browser_tests") {
sources = [
"digital_goods_api_browsertest.cc",
"file_system_access_browsertest.cc",
"font_browsertest.cc",
"js_ethereum_provider_browsertest.cc",
"navigator_connection_attribute_browsertest.cc",
"serial_api_browsertest.cc",
Expand Down
45 changes: 45 additions & 0 deletions renderer/test/font_browsertest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* Copyright (c) 2023 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */

#include "base/path_service.h"
#include "brave/components/constants/brave_paths.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/test/browser_test.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/gurl.h"

class FontBrowserTest : public InProcessBrowserTest {
public:
FontBrowserTest() : https_server_(net::EmbeddedTestServer::TYPE_HTTPS) {
brave::RegisterPathProvider();
base::FilePath test_data_dir;
base::PathService::Get(brave::DIR_TEST_DATA, &test_data_dir);
https_server_.SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_.ServeFilesFromDirectory(test_data_dir);
}

~FontBrowserTest() override = default;

void SetUpOnMainThread() override {
InProcessBrowserTest::SetUpOnMainThread();

EXPECT_TRUE(https_server_.Start());
// Map all hosts to localhost.
host_resolver()->AddRule("*", "127.0.0.1");
}

protected:
net::EmbeddedTestServer https_server_;
};

IN_PROC_BROWSER_TEST_F(FontBrowserTest, FreetypeRegression) {
// Loading this page on 1.50.121 on Linux crashed the tab.
// See https://github.com/brave/brave-browser/issues/29893
// and https://bugs.chromium.org/p/chromium/issues/detail?id=1434194
const GURL url = https_server_.GetURL("/freetype-crash.html");
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
}
Binary file added test/data/NotoSans-VF.ttf
Binary file not shown.
22 changes: 22 additions & 0 deletions test/data/freetype-crash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang=en>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
/* Triggering version of Google Noto Sans VF */
@font-face {
font-family: Noto Crash;
src: url(NotoSans-VF.ttf)
}
select {
font-family: Noto Crash;
}
</style>
</head>
<body>
<select>
<!-- In this environment the tab crashed with the Noto variable font. -->
<option>crash me</option>
</select>
</body>
</html>