-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: service worker communicates with the latest client only (#573)
- Loading branch information
Showing
9 changed files
with
126 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="description" content="Partytown Test Page" /> | ||
<title>Form</title> | ||
<style> | ||
body { | ||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, | ||
Apple Color Emoji, Segoe UI Emoji; | ||
font-size: 12px; | ||
} | ||
h1 { | ||
margin: 0 0 15px 0; | ||
} | ||
ul { | ||
list-style-type: none; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
a { | ||
display: block; | ||
padding: 16px 8px; | ||
} | ||
a:link, | ||
a:visited { | ||
text-decoration: none; | ||
color: blue; | ||
} | ||
a:hover { | ||
background-color: #eee; | ||
} | ||
li { | ||
display: flex; | ||
margin: 15px 0; | ||
} | ||
li strong, | ||
li code, | ||
li button { | ||
white-space: nowrap; | ||
flex: 1; | ||
margin: 0 5px; | ||
} | ||
</style> | ||
<script> | ||
partytown = { | ||
logCalls: true, | ||
logGetters: true, | ||
logSetters: true, | ||
logStackTraces: false, | ||
logScriptExecution: true, | ||
}; | ||
</script> | ||
<script src="/~partytown/debug/partytown.js"></script> | ||
</head> | ||
<body> | ||
<h1>Multiple Tabs</h1> | ||
<p> | ||
<span>Opened Tabs:</span> | ||
<span id="testNewTabs">0</span> | ||
</p> | ||
<a href="#" target="_blank" id="openNewTab">Open New Tab</a> | ||
<script type="text/partytown"> | ||
let tabsNumber = 0; | ||
document.getElementById('openNewTab').addEventListener('click', () => { | ||
tabsNumber++; | ||
document.getElementById('testNewTabs').textContent = tabsNumber; | ||
}); | ||
</script> | ||
|
||
<script type="text/partytown"> | ||
(function () { | ||
document.body.classList.add('completed'); | ||
})(); | ||
</script> | ||
<hr /> | ||
<p><a href="/tests/">All Tests</a></p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('multiple tabs', async ({ page, context }) => { | ||
await page.goto('/tests/platform/multiple-tabs/'); | ||
|
||
await page.waitForSelector('.completed'); | ||
|
||
const testNewTabs = page.locator('#testNewTabs'); | ||
await expect(testNewTabs).toHaveText('0'); | ||
|
||
const linkNewTab = page.locator('#openNewTab'); | ||
const newPagePromise = context.waitForEvent('page'); | ||
await linkNewTab.click(); | ||
const newPage = await newPagePromise; | ||
await newPage.waitForSelector('.completed'); | ||
await expect(testNewTabs).toHaveText('1'); | ||
|
||
const newPagePromise2 = context.waitForEvent('page'); | ||
await linkNewTab.click(); | ||
const newPage2 = await newPagePromise2; | ||
await newPage2.waitForSelector('.completed'); | ||
await expect(testNewTabs).toHaveText('2'); | ||
}); |