feat: support minimum_chrome_version
manifest key (#39256)
feat: support minimum_chrome_version extension key
This commit is contained in:
parent
e6931a788f
commit
f8b05bc127
6 changed files with 43 additions and 0 deletions
|
@ -174,6 +174,7 @@ template("electron_paks") {
|
||||||
}
|
}
|
||||||
|
|
||||||
source_patterns = [
|
source_patterns = [
|
||||||
|
"${root_gen_dir}/chrome/chromium_strings_",
|
||||||
"${root_gen_dir}/chrome/locale_settings_",
|
"${root_gen_dir}/chrome/locale_settings_",
|
||||||
"${root_gen_dir}/chrome/platform_locale_settings_",
|
"${root_gen_dir}/chrome/platform_locale_settings_",
|
||||||
"${root_gen_dir}/chrome/generated_resources_",
|
"${root_gen_dir}/chrome/generated_resources_",
|
||||||
|
@ -189,6 +190,7 @@ template("electron_paks") {
|
||||||
"${root_gen_dir}/ui/strings/ui_strings_",
|
"${root_gen_dir}/ui/strings/ui_strings_",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
|
"//chrome/app:chromium_strings",
|
||||||
"//chrome/app:generated_resources",
|
"//chrome/app:generated_resources",
|
||||||
"//chrome/app/resources:locale_settings",
|
"//chrome/app/resources:locale_settings",
|
||||||
"//chrome/app/resources:platform_locale_settings",
|
"//chrome/app/resources:platform_locale_settings",
|
||||||
|
|
|
@ -14,5 +14,9 @@
|
||||||
"devtools_page": {
|
"devtools_page": {
|
||||||
"channel": "stable",
|
"channel": "stable",
|
||||||
"extension_types": ["extension"]
|
"extension_types": ["extension"]
|
||||||
|
},
|
||||||
|
"minimum_chrome_version": {
|
||||||
|
"channel": "stable",
|
||||||
|
"extension_types": ["extension"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "base/containers/span.h"
|
#include "base/containers/span.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "chrome/common/extensions/chrome_manifest_url_handlers.h"
|
#include "chrome/common/extensions/chrome_manifest_url_handlers.h"
|
||||||
|
#include "chrome/common/extensions/manifest_handlers/minimum_chrome_version_checker.h"
|
||||||
#include "electron/buildflags/buildflags.h"
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "electron/shell/common/extensions/api/generated_schemas.h"
|
#include "electron/shell/common/extensions/api/generated_schemas.h"
|
||||||
#include "extensions/common/alias.h"
|
#include "extensions/common/alias.h"
|
||||||
|
@ -99,6 +100,8 @@ void ElectronExtensionsAPIProvider::RegisterManifestHandlers() {
|
||||||
extensions::ManifestHandlerRegistry::Get();
|
extensions::ManifestHandlerRegistry::Get();
|
||||||
registry->RegisterHandler(
|
registry->RegisterHandler(
|
||||||
std::make_unique<extensions::DevToolsPageHandler>());
|
std::make_unique<extensions::DevToolsPageHandler>());
|
||||||
|
registry->RegisterHandler(
|
||||||
|
std::make_unique<extensions::MinimumChromeVersionChecker>());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace electron
|
} // namespace electron
|
||||||
|
|
|
@ -69,6 +69,25 @@ describe('chrome extensions', () => {
|
||||||
`)).to.eventually.have.property('id');
|
`)).to.eventually.have.property('id');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('supports minimum_chrome_version manifest key', async () => {
|
||||||
|
const customSession = session.fromPartition(`persist:${require('uuid').v4()}`);
|
||||||
|
const w = new BrowserWindow({
|
||||||
|
show: false,
|
||||||
|
webPreferences: {
|
||||||
|
session: customSession,
|
||||||
|
sandbox: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await w.loadURL('about:blank');
|
||||||
|
|
||||||
|
const extPath = path.join(fixtures, 'extensions', 'chrome-too-low-version');
|
||||||
|
const load = customSession.loadExtension(extPath);
|
||||||
|
await expect(load).to.eventually.be.rejectedWith(
|
||||||
|
`Loading extension at ${extPath} failed with: This extension requires Chromium version 999 or greater.`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('can open WebSQLDatabase in a background page', async () => {
|
it('can open WebSQLDatabase in a background page', async () => {
|
||||||
const customSession = session.fromPartition(`persist:${require('uuid').v4()}`);
|
const customSession = session.fromPartition(`persist:${require('uuid').v4()}`);
|
||||||
const w = new BrowserWindow({ show: false, webPreferences: { session: customSession, sandbox: true } });
|
const w = new BrowserWindow({ show: false, webPreferences: { session: customSession, sandbox: true } });
|
||||||
|
|
1
spec/fixtures/extensions/chrome-too-low-version/main.js
vendored
Normal file
1
spec/fixtures/extensions/chrome-too-low-version/main.js
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
document.documentElement.style.backgroundColor = 'blue';
|
14
spec/fixtures/extensions/chrome-too-low-version/manifest.json
vendored
Normal file
14
spec/fixtures/extensions/chrome-too-low-version/manifest.json
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"name": "chrome-too-low-version",
|
||||||
|
"version": "1.0",
|
||||||
|
"minimum_chrome_version": "999",
|
||||||
|
"content_scripts": [
|
||||||
|
{
|
||||||
|
"matches": ["<all_urls>"],
|
||||||
|
"js": ["main.js"],
|
||||||
|
"run_at": "document_start"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"permissions": ["storage"],
|
||||||
|
"manifest_version": 3
|
||||||
|
}
|
Loading…
Reference in a new issue