fix: disable nodeIntegrationInWorker for certain Worker types (#35919)

fix: disable nodeIntegrationInWorker for certain Worker types
This commit is contained in:
Shelley Vohr
2022-10-12 07:36:24 -07:00
committed by GitHub
parent 1328d8d670
commit 7ce94eb0b4
6 changed files with 51 additions and 34 deletions

View File

View File

@@ -0,0 +1,6 @@
self.clients.matchAll({ includeUncontrolled: true }).then((clients) => {
if (!clients?.length) return;
const msg = [typeof process, typeof setImmediate, typeof global, typeof Buffer].join(' ');
clients[0].postMessage(msg);
});

View File

@@ -1,12 +0,0 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
const {ipcRenderer} = require('electron')
// Pass a random parameter to create independent worker.
let worker = new SharedWorker(`../workers/shared_worker_node.js?a={Math.random()}`)
worker.port.onmessage = function (event) {
ipcRenderer.send('worker-result', event.data)
}
</script>
</body>
</html>