spec: add missing checks to "validates process APIs access in sandboxed renderer" (#17129)
This commit is contained in:
parent
67f04c0370
commit
676c02611d
2 changed files with 46 additions and 9 deletions
19
spec/fixtures/module/preload-sandbox.js
vendored
19
spec/fixtures/module/preload-sandbox.js
vendored
|
@ -4,11 +4,30 @@
|
|||
window.ipcRenderer = ipcRenderer
|
||||
window.setImmediate = setImmediate
|
||||
window.require = require
|
||||
|
||||
function invoke (code) {
|
||||
try {
|
||||
return code()
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
if (location.protocol === 'file:') {
|
||||
window.test = 'preload'
|
||||
window.process = process
|
||||
if (process.env.sandboxmain) {
|
||||
window.test = {
|
||||
osSandbox: !process.argv.includes('--no-sandbox'),
|
||||
hasCrash: typeof process.crash === 'function',
|
||||
hasHang: typeof process.hang === 'function',
|
||||
creationTime: invoke(() => process.getCreationTime()),
|
||||
heapStatistics: invoke(() => process.getHeapStatistics()),
|
||||
processMemoryInfo: invoke(() => process.getProcessMemoryInfo()),
|
||||
systemMemoryInfo: invoke(() => process.getSystemMemoryInfo()),
|
||||
systemVersion: invoke(() => process.getSystemVersion()),
|
||||
cpuUsage: invoke(() => process.getCPUUsage()),
|
||||
ioCounters: invoke(() => process.getIOCounters()),
|
||||
env: process.env,
|
||||
execPath: process.execPath,
|
||||
pid: process.pid,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue