fix: pass startPage url correctly to extensions (#21711)
* fix: pass startPage url correctly to extensions * check for devtools_page first
This commit is contained in:
parent
80a037db86
commit
83c19faf61
1 changed files with 17 additions and 9 deletions
|
@ -57,18 +57,25 @@ const getManifestFromPath = function (srcDirectory) {
|
||||||
if (!manifestNameMap[manifest.name]) {
|
if (!manifestNameMap[manifest.name]) {
|
||||||
const extensionId = generateExtensionIdFromName(manifest.name)
|
const extensionId = generateExtensionIdFromName(manifest.name)
|
||||||
manifestMap[extensionId] = manifestNameMap[manifest.name] = manifest
|
manifestMap[extensionId] = manifestNameMap[manifest.name] = manifest
|
||||||
|
|
||||||
|
let extensionURL = url.format({
|
||||||
|
protocol: 'chrome-extension',
|
||||||
|
slashes: true,
|
||||||
|
hostname: extensionId,
|
||||||
|
pathname: manifest.devtools_page
|
||||||
|
})
|
||||||
|
|
||||||
|
// Chromium requires that startPage matches '([^:]+:\/\/[^/]*)\/'
|
||||||
|
// We also can't use the file:// protocol here since that would make Chromium
|
||||||
|
// treat all extension resources as being relative to root which we don't want.
|
||||||
|
if (!manifest.devtools_page) extensionURL += '/'
|
||||||
|
|
||||||
Object.assign(manifest, {
|
Object.assign(manifest, {
|
||||||
srcDirectory: srcDirectory,
|
srcDirectory: srcDirectory,
|
||||||
extensionId: extensionId,
|
extensionId: extensionId,
|
||||||
// We can not use 'file://' directly because all resources in the extension
|
startPage: extensionURL
|
||||||
// will be treated as relative to the root in Chrome.
|
|
||||||
startPage: url.format({
|
|
||||||
protocol: 'chrome-extension',
|
|
||||||
slashes: true,
|
|
||||||
hostname: extensionId,
|
|
||||||
pathname: manifest.devtools_page
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return manifest
|
return manifest
|
||||||
} else if (manifest && manifest.name) {
|
} else if (manifest && manifest.name) {
|
||||||
console.warn(`Attempted to load extension "${manifest.name}" that has already been loaded.`)
|
console.warn(`Attempted to load extension "${manifest.name}" that has already been loaded.`)
|
||||||
|
@ -389,7 +396,8 @@ const loadDevToolsExtensions = function (win, manifests) {
|
||||||
})
|
})
|
||||||
|
|
||||||
extensionInfoArray.forEach((extensionInfo) => {
|
extensionInfoArray.forEach((extensionInfo) => {
|
||||||
win.devToolsWebContents.executeJavaScript(`Extensions.extensionServer._addExtension(${JSON.stringify(extensionInfo)})`)
|
const info = JSON.stringify(extensionInfo)
|
||||||
|
win.devToolsWebContents.executeJavaScript(`Extensions.extensionServer._addExtension(${info})`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue