Skip to content

Commit

Permalink
test: getComputedStyle(elm).getPropertyValue()
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Jan 15, 2022
1 parent a782be3 commit c02a2ed
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
31 changes: 29 additions & 2 deletions tests/platform/window/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,21 @@ <h1>Window</h1>
<script type="text/partytown">
(function () {
const elm = document.getElementById('testGetComputedStyle');
const style = getComputedStyle(elm);
elm.textContent = style.color;
const style1 = getComputedStyle(elm);
const style2 = getComputedStyle(elm);
elm.textContent = style1.color + ' ' + (JSON.stringify(style1) === JSON.stringify(style2));
})();
</script>
</li>

<li>
<strong>getComputedStyle().getPropertyValue('color')</strong>
<code id="testGetComputedStyleGetPropertyValue" style="color: limegreen"></code>
<script type="text/partytown">
(function () {
const elm = document.getElementById('testGetComputedStyleGetPropertyValue');
const cs = getComputedStyle(elm);
elm.textContent = cs.getPropertyValue('color');
})();
</script>
</li>
Expand Down Expand Up @@ -671,6 +684,20 @@ <h1>Window</h1>
</script>
</li>

<li>
<strong>MediaSource.isTypeSupported()</strong>
<code id="testIsTypeSupported"></code>
<script type="text/partytown">
(function () {
const elm = document.getElementById('testIsTypeSupported');
const isTypeSupported = MediaSource.isTypeSupported(
'video/mp4; codecs="avc1.42E01E, mp4a.40.2"'
);
elm.textContent = String(isTypeSupported);
})();
</script>
</li>

<script type="text/partytown">
(function () {
document.body.classList.add('completed');
Expand Down
11 changes: 10 additions & 1 deletion tests/platform/window/window.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ test('window', async ({ page }) => {
await expect(testNameEquals).toHaveText('true');

const testComputedStyle = page.locator('#testGetComputedStyle');
await expect(testComputedStyle).toHaveText('rgb(128, 0, 128)');
await expect(testComputedStyle).toHaveText('rgb(128, 0, 128) true');

const testGetComputedStyleGetPropertyValue = page.locator(
'#testGetComputedStyleGetPropertyValue'
);
await expect(testGetComputedStyleGetPropertyValue).toHaveText('rgb(50, 205, 50)');

await page.waitForSelector('.testRaf');

Expand Down Expand Up @@ -132,4 +137,8 @@ test('window', async ({ page }) => {

const testTrustedTypes = page.locator('#testTrustedTypes');
await expect(testTrustedTypes).toHaveText('true');

// TODO: test in CI
// const testIsTypeSupported = page.locator('#testIsTypeSupported');
// await expect(testIsTypeSupported).toHaveText('true');
});

0 comments on commit c02a2ed

Please sign in to comment.