|
5 | 5 |
|
6 | 6 | #include <algorithm>
|
7 | 7 |
|
| 8 | +#include "base/files/file_path.h" |
8 | 9 | #include "base/path_service.h"
|
9 | 10 | #include "base/run_loop.h"
|
10 | 11 | #include "base/test/scoped_feature_list.h"
|
11 | 12 | #include "brave/browser/brave_content_browser_client.h"
|
12 | 13 | #include "brave/components/brave_shields/browser/brave_shields_util.h"
|
13 | 14 | #include "brave/components/constants/brave_paths.h"
|
14 | 15 | #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
|
15 |
| -#include "chrome/browser/extensions/extension_browsertest.h" |
| 16 | +#include "chrome/browser/extensions/chrome_test_extension_loader.h" |
16 | 17 | #include "chrome/browser/profiles/profile.h"
|
17 | 18 | #include "chrome/browser/ui/browser_window.h"
|
18 | 19 | #include "chrome/common/chrome_content_client.h"
|
| 20 | +#include "chrome/common/chrome_paths.h" |
| 21 | +#include "chrome/test/base/in_process_browser_test.h" |
19 | 22 | #include "chrome/test/base/ui_test_utils.h"
|
20 | 23 | #include "content/public/test/browser_test.h"
|
21 | 24 | #include "net/dns/mock_host_resolver.h"
|
@@ -62,6 +65,14 @@ class BraveScreenFarblingBrowserTest : public InProcessBrowserTest {
|
62 | 65 | content_client_.reset();
|
63 | 66 | }
|
64 | 67 |
|
| 68 | + std::string LoadExtension(const base::FilePath& path) { |
| 69 | + extensions::ChromeTestExtensionLoader loader(browser()->profile()); |
| 70 | + scoped_refptr<const extensions::Extension> extension = |
| 71 | + loader.LoadExtension(path); |
| 72 | + EXPECT_TRUE(extension); |
| 73 | + return extension->id(); |
| 74 | + } |
| 75 | + |
65 | 76 | HostContentSettingsMap* ContentSettings() {
|
66 | 77 | return HostContentSettingsMapFactory::GetForProfile(browser()->profile());
|
67 | 78 | }
|
@@ -99,13 +110,13 @@ class BraveScreenFarblingBrowserTest : public InProcessBrowserTest {
|
99 | 110 | return browser()->window()->GetBounds();
|
100 | 111 | }
|
101 | 112 |
|
102 |
| - void FarbleScreenSize() { |
| 113 | + void FarbleScreenSize(const GURL& url, bool content_scheme) { |
103 | 114 | for (int j = 0; j < static_cast<int>(std::size(kTestWindowBounds)); ++j) {
|
104 | 115 | SetBounds(kTestWindowBounds[j]);
|
105 | 116 | for (bool allow_fingerprinting : {false, true}) {
|
106 | 117 | SetFingerprintingSetting(allow_fingerprinting);
|
107 |
| - NavigateToURLUntilLoadStop(FarblingUrl()); |
108 |
| - if (!allow_fingerprinting && !IsFlagDisabled()) { |
| 118 | + NavigateToURLUntilLoadStop(url); |
| 119 | + if (!allow_fingerprinting && !IsFlagDisabled() && content_scheme) { |
109 | 120 | EXPECT_GE(
|
110 | 121 | 8, EvalJs(Contents(), "window.outerWidth - window.innerWidth"));
|
111 | 122 | EXPECT_GE(
|
@@ -274,12 +285,12 @@ class BraveScreenFarblingBrowserTest_DisableFlag
|
274 | 285 |
|
275 | 286 | IN_PROC_BROWSER_TEST_F(BraveScreenFarblingBrowserTest_EnableFlag,
|
276 | 287 | FarbleScreenSize_EnableFlag) {
|
277 |
| - FarbleScreenSize(); |
| 288 | + FarbleScreenSize(FarblingUrl(), true); |
278 | 289 | }
|
279 | 290 |
|
280 | 291 | IN_PROC_BROWSER_TEST_F(BraveScreenFarblingBrowserTest_DisableFlag,
|
281 | 292 | FarbleScreenSize_DisableFlag) {
|
282 |
| - FarbleScreenSize(); |
| 293 | + FarbleScreenSize(FarblingUrl(), true); |
283 | 294 | }
|
284 | 295 |
|
285 | 296 | IN_PROC_BROWSER_TEST_F(BraveScreenFarblingBrowserTest_EnableFlag,
|
@@ -345,3 +356,25 @@ IN_PROC_BROWSER_TEST_F(BraveScreenFarblingBrowserTest_DisableFlag,
|
345 | 356 | FarbleScreenPopupPosition_DisableFlag_3) {
|
346 | 357 | FarbleScreenPopupPosition(3);
|
347 | 358 | }
|
| 359 | + |
| 360 | +IN_PROC_BROWSER_TEST_F(BraveScreenFarblingBrowserTest_EnableFlag, |
| 361 | + FarbleScreenSize_Schemes) { |
| 362 | + // chrome: URI (don't farble) |
| 363 | + FarbleScreenSize(GURL("chrome:version"), false); |
| 364 | + |
| 365 | + // chrome-extension: URI (don't farble) |
| 366 | + base::FilePath test_data_dir; |
| 367 | + base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); |
| 368 | + std::string extension_id = |
| 369 | + LoadExtension(test_data_dir.AppendASCII("extensions") |
| 370 | + .AppendASCII("ui") |
| 371 | + .AppendASCII("browser_action_popup")); |
| 372 | + base::RunLoop().RunUntilIdle(); // Ensure the extension is fully loaded. |
| 373 | + const GURL extension_url("chrome-extension://" + extension_id + |
| 374 | + "/popup.html"); |
| 375 | + FarbleScreenSize(extension_url, false); |
| 376 | + |
| 377 | + // devtools: URI (don't farble) |
| 378 | + const GURL devtools_url("devtools://devtools/bundled/devtools_app.html"); |
| 379 | + FarbleScreenSize(devtools_url, false); |
| 380 | +} |
0 commit comments