Emmanuel Arias Soto | 9e15965 | 2025-05-16 07:53:55 | [diff] [blame] | 1 | // Copyright 2025 The Chromium Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "content/browser/renderer_host/debug_urls.h" |
| 6 | |
| 7 | #include "testing/gtest/include/gtest/gtest.h" |
| 8 | #include "third_party/blink/public/common/chrome_debug_urls.h" |
| 9 | #include "url/gurl.h" |
| 10 | |
| 11 | namespace content { |
| 12 | |
| 13 | using DebugUrlsUnitTest = testing::Test; |
| 14 | |
| 15 | TEST_F(DebugUrlsUnitTest, IsDebugURL_NonDebugUrlsReturnFalse) { |
| 16 | EXPECT_FALSE(IsDebugURL(GURL("invalid"))); |
| 17 | EXPECT_FALSE(IsDebugURL(GURL("https://example.com"))); |
| 18 | EXPECT_FALSE(IsDebugURL(GURL("http://example.com"))); |
| 19 | EXPECT_FALSE(IsDebugURL(GURL("chrome://version"))); |
| 20 | } |
| 21 | |
| 22 | TEST_F(DebugUrlsUnitTest, IsDebugURL_AsanUrlsReturnTrue) { |
| 23 | EXPECT_TRUE(IsDebugURL(GURL("chrome://crash/browser-heap-overflow"))); |
| 24 | EXPECT_TRUE(IsDebugURL(GURL("chrome://crash/browser-heap-overflow"))); |
| 25 | EXPECT_TRUE(IsDebugURL(GURL("chrome://crash/browser-use-after-free"))); |
| 26 | |
| 27 | #if BUILDFLAG(IS_WIN) |
| 28 | EXPECT_TRUE(IsDebugURL(GURL("chrome://crash/browser-corrupt-heap-block"))); |
| 29 | EXPECT_TRUE(IsDebugURL(GURL("chrome://crash/browser-corrupt-heap"))); |
| 30 | #endif |
| 31 | } |
| 32 | |
| 33 | TEST_F(DebugUrlsUnitTest, IsDebugURL_DebugUrlsReturnTrue) { |
| 34 | EXPECT_TRUE(IsDebugURL(GURL(blink::kChromeUIBrowserCrashURL))); |
| 35 | EXPECT_TRUE(IsDebugURL(GURL(blink::kChromeUIBrowserDcheckURL))); |
| 36 | #if BUILDFLAG(IS_WIN) |
| 37 | EXPECT_TRUE(IsDebugURL(GURL(blink::kChromeUIBrowserHeapCorruptionURL))); |
| 38 | #endif |
| 39 | EXPECT_TRUE(IsDebugURL(GURL(blink::kChromeUIBrowserUIHang))); |
| 40 | EXPECT_TRUE(IsDebugURL(GURL(blink::kChromeUIDelayedBrowserUIHang))); |
| 41 | EXPECT_TRUE(IsDebugURL(GURL(blink::kChromeUIGpuCleanURL))); |
| 42 | EXPECT_TRUE(IsDebugURL(GURL(blink::kChromeUIGpuCrashURL))); |
| 43 | #if BUILDFLAG(IS_ANDROID) |
| 44 | EXPECT_TRUE(IsDebugURL(GURL(blink::kChromeUIGpuJavaCrashURL))); |
| 45 | #endif |
| 46 | EXPECT_TRUE(IsDebugURL(GURL(blink::kChromeUIGpuHangURL))); |
| 47 | EXPECT_TRUE(IsDebugURL(GURL(blink::kChromeUIMemoryPressureCriticalURL))); |
| 48 | EXPECT_TRUE(IsDebugURL(GURL(blink::kChromeUIMemoryPressureModerateURL))); |
| 49 | } |
| 50 | |
| 51 | } // namespace content |