Unreviewed changes
4 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: chrome/browser/extensions/extension_user_script_loader_unittest.cc
Insertions: 8, Deletions: 8.
@@ -343,7 +343,6 @@
}
TEST_F(ExtensionUserScriptLoaderTest, ComponentExtensionContentScriptIsLoaded) {
- // Define mock manager
class MockResourceManager : public ComponentExtensionResourceManager {
public:
bool IsComponentExtensionResource(const base::FilePath& extension_path,
@@ -362,10 +361,9 @@
}
};
- // Define test client
- class MyTestClient : public TestExtensionsBrowserClient {
+ class TestClient : public TestExtensionsBrowserClient {
public:
- MyTestClient() = default;
+ TestClient() = default;
const ComponentExtensionResourceManager*
GetComponentExtensionResourceManager() override {
return &mock_manager_;
@@ -380,9 +378,10 @@
MockResourceManager mock_manager_;
};
- MyTestClient client;
+ TestClient client;
client.set_extension_system_factory(
ChromeExtensionSystemFactory::GetInstance());
+ ExtensionsBrowserClient* old_client = ExtensionsBrowserClient::Get();
ExtensionsBrowserClient::Set(&client);
base::FilePath resources_dir;
@@ -405,8 +404,9 @@
base::BindRepeating(&TestExtensionSystem::Build));
profile_builder.AddTestingFactory(
ExtensionPrefValueMapFactory::GetInstance(),
- base::BindRepeating([](content::BrowserContext* context) {
- return std::unique_ptr<KeyedService>(new ExtensionPrefValueMap());
+ base::BindRepeating([](content::BrowserContext* context)
+ -> std::unique_ptr<KeyedService> {
+ return std::make_unique<ExtensionPrefValueMap>();
}));
std::unique_ptr<TestingProfile> profile = profile_builder.Build();
@@ -427,7 +427,7 @@
histogram_tester.ExpectTotalCount(
"Extensions.ContentScripts.DynamicContentScriptsLengthPerLoad", 1);
- ExtensionsBrowserClient::Set(nullptr);
+ ExtensionsBrowserClient::Set(old_client);
}
TEST_F(ExtensionUserScriptLoaderTest, RecordScriptLengthUmas) {
```
Change information
Commit message:
extensions: Port ComponentExtensionContentScriptIsLoaded to Desktop Android
- This CL enables and fixes the ComponentExtensionContentScriptIsLoaded
unit test for Desktop Android by addressing initialization crashes and
missing resource dependencies.
- Fixed SIGSEGV crashes by using TestingProfile::Builder to inject test
factories and overriding context resolution in the test client
preventing null derefs during profile setup.
- Fixed assertion failures caused by missing PDF assets on Android by
mocking ComponentExtensionResourceManager to return a standard,
cross-platform resource ID (IDR_EXTENSION_DEFAULT_ICON).
Change-Id: I217b0de84133ad8b69fd217c7ed2e0fb4fa2bbb1
Cr-Commit-Position: refs/heads/main@{#1609365}
Files:
- M chrome/browser/extensions/extension_user_script_loader_unittest.cc
Change size: M
Delta: 1 file changed, 63 insertions(+), 7 deletions(-)
Branch: refs/heads/main
Submit Requirements:
Code-Review: +1 by James Cook