fix: add prefer-blob-reading-methods rule (#5118)

This commit is contained in:
LongYinan
2023-11-29 04:44:10 +00:00
parent cb2c659f52
commit eadf8a085b
2 changed files with 5 additions and 12 deletions

View File

@@ -368,18 +368,10 @@ test('can sync svg between different browsers', async ({ page, browser }) => {
expect(src).not.toBeNull();
// fetch the src resource in the browser
const svg2 = await page2.evaluate(async src => {
async function blobToString(blob: Blob) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsText(blob);
});
}
const blob = fetch(src!).then(res => res.blob());
return blobToString(await blob);
const svg2 = await page2.evaluate(src => {
return fetch(src!)
.then(res => res.blob())
.then(blob => blob.text());
}, src);
// turn the blob into string and check if it contains the svg