Skip to content

Commit

Permalink
update img tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Sep 17, 2021
1 parent 4d2c855 commit 0d8afe5
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 56 deletions.
48 changes: 24 additions & 24 deletions tests/image/image.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ import { test, expect } from '@playwright/test';
test('image', async ({ page }) => {
await page.goto('/image/');

await page.waitForSelector('.test0');
const test0 = page.locator('#test0');
await expect(test0).toHaveText('load');
await page.waitForSelector('.testImageOnLoad');
const testImageOnLoad = page.locator('#testImageOnLoad');
await expect(testImageOnLoad).toHaveText('load');

await page.waitForSelector('.test1');
const test1 = page.locator('#test1');
await expect(test1).toHaveText('error');
await page.waitForSelector('.testImageOnError');
const testImageOnError = page.locator('#testImageOnError');
await expect(testImageOnError).toHaveText('error');

await page.waitForSelector('.test2');
const test2 = page.locator('#test2');
await expect(test2).toHaveText('load');
await page.waitForSelector('.testImageListenerLoad');
const testImageListenerLoad = page.locator('#testImageListenerLoad');
await expect(testImageListenerLoad).toHaveText('load');

await page.waitForSelector('.test3');
const test3 = page.locator('#test3');
await expect(test3).toHaveText('error');
await page.waitForSelector('.testImageListenerError');
const testImageListenerError = page.locator('#testImageListenerError');
await expect(testImageListenerError).toHaveText('error');

await page.waitForSelector('.test4');
const test4 = page.locator('#test4');
await expect(test4).toHaveText('load');
await page.waitForSelector('.testImgOnLoad');
const testImgOnLoad = page.locator('#testImgOnLoad');
await expect(testImgOnLoad).toHaveText('load');

await page.waitForSelector('.test5');
const test5 = page.locator('#test5');
await expect(test5).toHaveText('error');
await page.waitForSelector('.testImgOnError');
const testImgOnError = page.locator('#testImgOnError');
await expect(testImgOnError).toHaveText('error');

await page.waitForSelector('.test6');
const test6 = page.locator('#test6');
await expect(test6).toHaveText('load');
await page.waitForSelector('.testImgListenerLoad');
const testImgListenerLoad = page.locator('#testImgListenerLoad');
await expect(testImgListenerLoad).toHaveText('load');

await page.waitForSelector('.test7');
const test7 = page.locator('#test7');
await expect(test7).toHaveText('error');
await page.waitForSelector('.testImgListenerError');
const testImgListenerError = page.locator('#testImgListenerError');
await expect(testImgListenerError).toHaveText('error');
});
64 changes: 32 additions & 32 deletions tests/image/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,121 +54,121 @@ <h1>Image</h1>
<ul>
<li>
<strong>Image() onload</strong>
<code id="test0"></code>
<code id="testImageOnLoad"></code>
<script type="text/partytown">
(function () {
const image = new Image();
image.onload = function (ev) {
const elm = document.getElementById('test0');
const elm = document.getElementById('testImageOnLoad');
elm.textContent = ev.type;
elm.className = 'test0';
elm.className = 'testImageOnLoad';
};
image.src = 'dot.gif?test=0';
image.src = 'dot.gif?testImageOnLoad';
})();
</script>
</li>
<li>
<strong>Image() onerror</strong>
<code id="test1"></code>
<code id="testImageOnError"></code>
<script type="text/partytown">
(function () {
const image = new Image();
image.onerror = function (ev) {
const elm = document.getElementById('test1');
const elm = document.getElementById('testImageOnError');
elm.textContent = ev.type;
elm.className = 'test1';
elm.className = 'testImageOnError';
};
image.src = '404.gif?test=1';
image.src = '404.gif?testImageOnError';
})();
</script>
</li>
<li>
<strong>Image() addEventListener('load')</strong>
<code id="test2"></code>
<code id="testImageListenerLoad"></code>
<script type="text/partytown">
(function () {
const image = new Image();
image.addEventListener('load', function (ev) {
const elm = document.getElementById('test2');
const elm = document.getElementById('testImageListenerLoad');
elm.textContent = ev.type;
elm.className = 'test2';
elm.className = 'testImageListenerLoad';
});
image.src = 'dot.gif?test=2';
image.src = 'dot.gif?testImageListenerLoad';
})();
</script>
</li>
<li>
<strong>Image() addEventListener('error')</strong>
<code id="test3"></code>
<code id="testImageListenerError"></code>
<script type="text/partytown">
(function () {
const image = new Image();
image.addEventListener('error', function (ev) {
const elm = document.getElementById('test3');
const elm = document.getElementById('testImageListenerError');
elm.textContent = ev.type;
elm.className = 'test3';
elm.className = 'testImageListenerError';
});
image.src = '404.gif?test=3';
image.src = '404.gif?testImageListenerError';
})();
</script>
</li>
<li>
<strong>&lt;img&gt; onload</strong>
<code id="test4"></code>
<code id="testImgOnLoad"></code>
<script type="text/partytown">
(function () {
const image = document.createElement('img');
image.onload = function (ev) {
const elm = document.getElementById('test4');
const elm = document.getElementById('testImgOnLoad');
elm.textContent = ev.type;
elm.className = 'test4';
elm.className = 'testImgOnLoad';
};
image.src = 'dot.gif?test=4';
image.src = 'dot.gif?testImgOnLoad';
})();
</script>
</li>
<li>
<strong>&lt;img&gt; onerror</strong>
<code id="test5"></code>
<code id="testImgOnError"></code>
<script type="text/partytown">
(function () {
const image = document.createElement('img');
image.onerror = function (ev) {
const elm = document.getElementById('test5');
const elm = document.getElementById('testImgOnError');
elm.textContent = ev.type;
elm.className = 'test5';
elm.className = 'testImgOnError';
};
image.src = '404.gif?test=5';
image.src = '404.gif?testImgOnError';
})();
</script>
</li>
<li>
<strong>&lt;img&gt; addEventListener('load')</strong>
<code id="test6"></code>
<code id="testImgListenerLoad"></code>
<script type="text/partytown">
(function () {
const image = new Image();
image.addEventListener('load', function (ev) {
const elm = document.getElementById('test6');
const elm = document.getElementById('testImgListenerLoad');
elm.textContent = ev.type;
elm.className = 'test6';
elm.className = 'testImgListenerLoad';
});
image.src = 'dot.gif?test=6';
image.src = 'dot.gif?testImgListenerLoad';
})();
</script>
</li>
<li>
<strong>&lt;img&gt; addEventListener('error')</strong>
<code id="test7"></code>
<code id="testImgListenerError"></code>
<script type="text/partytown">
(function () {
const image = new Image();
image.addEventListener('error', function (ev) {
const elm = document.getElementById('test7');
const elm = document.getElementById('testImgListenerError');
elm.textContent = ev.type;
elm.className = 'test7';
elm.className = 'testImgListenerError';
});
image.src = '404.gif?test=7';
image.src = '404.gif?testImgListenerError';
})();
</script>
</li>
Expand Down

1 comment on commit 0d8afe5

@vercel
Copy link

@vercel vercel bot commented on 0d8afe5 Sep 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.