-
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.
- Loading branch information
1 parent
ccf9122
commit a490844
Showing
8 changed files
with
188 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<!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>ResizeObserver</title> | ||
|
||
<script> | ||
partytown = { | ||
debug: true, | ||
logCalls: true, | ||
logGetters: true, | ||
logSetters: true, | ||
logImageRequests: true, | ||
logSendBeaconRequests: true, | ||
logStackTraces: false, | ||
logScriptExecution: true, | ||
}; | ||
</script> | ||
<script src="/~partytown/debug/partytown-snippet.js"></script> | ||
|
||
<link | ||
rel="icon" | ||
id="favicon" | ||
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🎉</text></svg>" | ||
/> | ||
<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 code, | ||
li button { | ||
white-space: nowrap; | ||
flex: 1; | ||
margin: 0 5px; | ||
} | ||
li button { | ||
font-size: 12px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>ResizeObserver</h1> | ||
|
||
<ul> | ||
<li> | ||
<button id="buttonObserve">observe</button> | ||
<button id="buttonIncrease">+</button> | ||
<button id="buttonDecrease">-</button> | ||
|
||
<script type="text/partytown"> | ||
(function () { | ||
let step = 0; | ||
function nextStep() { | ||
step++; | ||
const elm = document.getElementById('testResizeObserver'); | ||
elm.classList.add('step' + step); | ||
const testStep = document.getElementById('testStep'); | ||
testStep.textContent = 'step' + step; | ||
} | ||
|
||
const targetNode = document.getElementById('target'); | ||
|
||
const resizeObserver = new ResizeObserver((entries) => { | ||
for (let entry of entries) { | ||
entry.target.textContent = 'Height: ' + entry.contentRect.height + 'px'; | ||
} | ||
}); | ||
|
||
const buttonObserve = document.getElementById('buttonObserve'); | ||
buttonObserve.addEventListener('click', () => { | ||
const elm = document.getElementById('testResizeObserver'); | ||
if (buttonObserve.textContent === 'observe') { | ||
resizeObserver.observe(elm); | ||
buttonObserve.textContent = 'disconnect'; | ||
} else { | ||
resizeObserver.disconnect(); | ||
buttonObserve.textContent = 'observe'; | ||
} | ||
nextStep(); | ||
}); | ||
|
||
const buttonIncrease = document.getElementById('buttonIncrease'); | ||
buttonIncrease.addEventListener('click', () => { | ||
const elm = document.getElementById('testResizeObserver'); | ||
elm.style.height = parseInt(elm.style.height.replace('px', ''), 10) + 10 + 'px'; | ||
nextStep(); | ||
}); | ||
|
||
const buttonDecrease = document.getElementById('buttonDecrease'); | ||
buttonDecrease.addEventListener('click', () => { | ||
const elm = document.getElementById('testResizeObserver'); | ||
elm.style.height = parseInt(elm.style.height.replace('px', ''), 10) - 10 + 'px'; | ||
nextStep(); | ||
}); | ||
|
||
document.body.className = 'completed' | ||
})(); | ||
</script> | ||
</li> | ||
</ul> | ||
|
||
<div | ||
id="testResizeObserver" | ||
style="height: 40px; text-align: center; border: 1px solid blue; background-color: #eee" | ||
></div> | ||
|
||
<div id="testStep"></div> | ||
|
||
<p><a href="/">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,36 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('resize-observer', async ({ page }) => { | ||
await page.goto('/platform/resize-observer/'); | ||
|
||
await page.waitForSelector('.completed'); | ||
|
||
const buttonObserve = page.locator('#buttonObserve'); | ||
const buttonIncrease = page.locator('#buttonIncrease'); | ||
const buttonDecrease = page.locator('#buttonDecrease'); | ||
|
||
const testResizeObserver = page.locator('#testResizeObserver'); | ||
|
||
await buttonIncrease.click(); | ||
await page.waitForSelector('.step1'); | ||
await expect(testResizeObserver).toHaveText(''); | ||
|
||
await buttonObserve.click(); | ||
await page.waitForSelector('.step2'); | ||
await expect(testResizeObserver).toHaveText('Height: 50px'); | ||
|
||
await buttonIncrease.click(); | ||
await page.waitForSelector('.step3'); | ||
await expect(testResizeObserver).toHaveText('Height: 60px'); | ||
|
||
await buttonDecrease.click(); | ||
await page.waitForSelector('.step4'); | ||
await expect(testResizeObserver).toHaveText('Height: 50px'); | ||
|
||
await buttonObserve.click(); | ||
await page.waitForSelector('.step5'); | ||
|
||
await buttonDecrease.click(); | ||
await page.waitForSelector('.step6'); | ||
await expect(testResizeObserver).toHaveText('Height: 50px'); | ||
}); |
a490844
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: