chore: disable the remote module in devtools / chrome extension background scripts (#16866)
* cache isRemoteModuleEnabled * chore: disable the remote module in devtools / chrome extension background scripts
This commit is contained in:
parent
a3cdf46fb6
commit
d8ba1278d1
6 changed files with 20 additions and 17 deletions
|
@ -368,17 +368,6 @@ const addReturnValueToEvent = (event) => {
|
|||
})
|
||||
}
|
||||
|
||||
const safeProtocols = new Set([
|
||||
'chrome-devtools:',
|
||||
'chrome-extension:'
|
||||
])
|
||||
|
||||
const isWebContentsTrusted = function (contents) {
|
||||
const pageURL = contents._getURL()
|
||||
const { protocol } = url.parse(pageURL)
|
||||
return safeProtocols.has(protocol)
|
||||
}
|
||||
|
||||
// Add JavaScript wrappers for WebContents class.
|
||||
WebContents.prototype._init = function () {
|
||||
// The navigation controller.
|
||||
|
@ -436,9 +425,7 @@ WebContents.prototype._init = function () {
|
|||
|
||||
for (const eventName of forwardedEvents) {
|
||||
this.on(eventName, (event, ...args) => {
|
||||
if (!isWebContentsTrusted(event.sender)) {
|
||||
app.emit(eventName, event, this, ...args)
|
||||
}
|
||||
app.emit(eventName, event, this, ...args)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue