fix: crash on WebWorkerObserver
script execution (#37050)
fix: crash on WebWorkerObserver script execution
This commit is contained in:
parent
ce35bda805
commit
23739c644b
6 changed files with 109 additions and 16 deletions
22
spec/fixtures/crash-cases/worker-multiple-destroy/index.html
vendored
Normal file
22
spec/fixtures/crash-cases/worker-multiple-destroy/index.html
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<html>
|
||||
|
||||
<body>
|
||||
<style>
|
||||
textarea {
|
||||
background-image: url(checkerboard);
|
||||
background-image: paint(checkerboard);
|
||||
}
|
||||
|
||||
@supports (background: paint(id)) {
|
||||
background-image: paint(checkerboard);
|
||||
}
|
||||
</style>
|
||||
<textarea></textarea>
|
||||
<script>
|
||||
const addPaintWorklet = async () => {
|
||||
await CSS.paintWorklet.addModule('worklet.js');
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
38
spec/fixtures/crash-cases/worker-multiple-destroy/index.js
vendored
Normal file
38
spec/fixtures/crash-cases/worker-multiple-destroy/index.js
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
const { app, BrowserWindow } = require('electron');
|
||||
|
||||
async function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
webPreferences: {
|
||||
nodeIntegrationInWorker: true
|
||||
}
|
||||
});
|
||||
|
||||
let loads = 1;
|
||||
mainWindow.webContents.on('did-finish-load', async () => {
|
||||
if (loads === 2) {
|
||||
process.exit(0);
|
||||
} else {
|
||||
loads++;
|
||||
await mainWindow.webContents.executeJavaScript('addPaintWorklet()');
|
||||
await mainWindow.webContents.executeJavaScript('location.reload()');
|
||||
}
|
||||
});
|
||||
|
||||
mainWindow.webContents.on('render-process-gone', () => {
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
await mainWindow.loadFile('index.html');
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||
});
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') app.quit();
|
||||
});
|
18
spec/fixtures/crash-cases/worker-multiple-destroy/worklet.js
vendored
Normal file
18
spec/fixtures/crash-cases/worker-multiple-destroy/worklet.js
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
class CheckerboardPainter {
|
||||
paint (ctx, geom, properties) {
|
||||
const colors = ['red', 'green', 'blue'];
|
||||
const size = 32;
|
||||
for (let y = 0; y < (geom.height / size); y++) {
|
||||
for (let x = 0; x < (geom.width / size); x++) {
|
||||
const color = colors[(x + y) % colors.length];
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = color;
|
||||
ctx.rect(x * size, y * size, size, size);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
registerPaint('checkerboard', CheckerboardPainter);
|
Loading…
Add table
Add a link
Reference in a new issue