Skip to content

Commit

Permalink
fix: throw Error in webworker
Browse files Browse the repository at this point in the history
  • Loading branch information
hughfenghen committed Jun 2, 2024
1 parent 5053d8d commit 225a2a2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/tmpfile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test('delMarkFiles', async () => {
const f = tmpfile();
await write(f, 'mark');
expect(await f.exists()).toBe(true);
window.dispatchEvent(new Event('unload'));
self.dispatchEvent(new Event('unload'));
expect(
localStorage.getItem('OPFS_TOOLS_EXPIRES_TMP_FILES')?.includes(f.name)
).toBe(true);
Expand Down
2 changes: 1 addition & 1 deletion src/tmpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function delMarkFiles() {

if (!bindedUnloadEvt) {
bindedUnloadEvt = true;
window.addEventListener('unload', () => {
self.addEventListener('unload', () => {
if (currentPageTMPFiles.length === 0) return;
localStorage.setItem(
opfsToolsExpires,
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
test: {
browser: {
enabled: true,
name: 'edge', // browser name is required
name: 'chrome', // browser name is required
headless: true,
},
},
Expand Down

0 comments on commit 225a2a2

Please sign in to comment.