mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
ci: Improve CI pipeline (#1790)
This commit is contained in:
@ -0,0 +1,2 @@
|
||||
[Safari]/tests/reftests/acid2.html
|
||||
[Safari]/tests/reftests/background/encoded.html
|
||||
|
@ -75,7 +75,7 @@ const assertPath = (result, expected, desc) => {
|
||||
.filter(test => {
|
||||
return (
|
||||
!Array.isArray(reftests.ignoredTests[test]) ||
|
||||
reftests.ignoredTests[test].indexOf(query.browser) === -1
|
||||
reftests.ignoredTests[test].indexOf(platform.name) === -1
|
||||
);
|
||||
})
|
||||
.forEach(url => {
|
||||
@ -342,79 +342,37 @@ const assertPath = (result, expected, desc) => {
|
||||
}
|
||||
|
||||
if (window.__karma__) {
|
||||
const MAX_CHUNK_SIZE = 75000;
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr =
|
||||
'withCredentials' in new XMLHttpRequest()
|
||||
? new XMLHttpRequest()
|
||||
: new XDomainRequest();
|
||||
|
||||
const sendScreenshot = (tries, body, server) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr =
|
||||
'withCredentials' in new XMLHttpRequest()
|
||||
? new XMLHttpRequest()
|
||||
: new XDomainRequest();
|
||||
|
||||
xhr.onload = () => {
|
||||
if (
|
||||
typeof xhr.status !== 'number' ||
|
||||
xhr.status === 200
|
||||
) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(
|
||||
`Failed to send screenshot with status ${xhr.status}`
|
||||
);
|
||||
}
|
||||
};
|
||||
xhr.onerror = reject;
|
||||
|
||||
xhr.open('POST', server, true);
|
||||
xhr.send(body);
|
||||
}).catch(e => {
|
||||
if (tries > 0) {
|
||||
// Older edge browsers and some safari browsers have issues sending large xhr through saucetunnel
|
||||
const data = canvas.toDataURL();
|
||||
const totalCount = Math.ceil(
|
||||
data.length / MAX_CHUNK_SIZE
|
||||
);
|
||||
return Promise.all(
|
||||
Array.apply(
|
||||
null,
|
||||
Array(totalCount)
|
||||
).map((x, part) =>
|
||||
sendScreenshot(
|
||||
0,
|
||||
JSON.stringify({
|
||||
screenshot: data.substr(
|
||||
part * MAX_CHUNK_SIZE,
|
||||
MAX_CHUNK_SIZE
|
||||
),
|
||||
part,
|
||||
totalCount,
|
||||
test: url,
|
||||
platform: {
|
||||
name: platform.name,
|
||||
version: platform.version
|
||||
}
|
||||
}),
|
||||
'http://localhost:8000/screenshot/chunk'
|
||||
)
|
||||
)
|
||||
xhr.onload = () => {
|
||||
if (
|
||||
typeof xhr.status !== 'number' ||
|
||||
xhr.status === 200
|
||||
) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(
|
||||
`Failed to send screenshot with status ${xhr.status}`
|
||||
);
|
||||
}
|
||||
};
|
||||
xhr.onerror = reject;
|
||||
|
||||
return Promise.reject(e);
|
||||
});
|
||||
};
|
||||
return sendScreenshot(
|
||||
1,
|
||||
JSON.stringify({
|
||||
xhr.open('POST', 'http://localhost:8000/screenshot', true);
|
||||
xhr.send(JSON.stringify({
|
||||
screenshot: canvas.toDataURL(),
|
||||
test: url,
|
||||
platform: {
|
||||
name: platform.name,
|
||||
version: platform.version
|
||||
}
|
||||
}),
|
||||
'http://localhost:8000/screenshot'
|
||||
);
|
||||
}));
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user