Skip to content

Commit

Permalink
Merge pull request #18338 from brave/freetype-regression
Browse files Browse the repository at this point in the history
Freetype crash regression test
  • Loading branch information
rillian authored May 4, 2023
2 parents 3f51f04 + a7e8742 commit a441fb7
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
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>

0 comments on commit a441fb7

Please sign in to comment.