mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
fix: handle unhandled promise rejections (#2568)
This commit is contained in:

committed by
GitHub

parent
382853cb33
commit
4555940d0b
@ -2,10 +2,21 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>iframe test</title>
|
||||
<script>
|
||||
h2cOptions = {useCORS: true, proxy: null};
|
||||
</script>
|
||||
<script type="text/javascript" src="../test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div style="background: cornflowerblue; padding: 20px; width: 200px;">Parent document content</div>
|
||||
<iframe src="/tests/assets/iframe/frame1.html" width="500" height="500"></iframe>
|
||||
<iframe
|
||||
title="Github"
|
||||
src="https://ghbtns.com/github-btn.html?user=niklasvh&repo=html2canvas&type=star&count=true&size=large"
|
||||
frameBorder="0"
|
||||
scrolling="0"
|
||||
width="160px"
|
||||
height="30px"
|
||||
></iframe>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -24,6 +24,10 @@ var REFTEST = window.location.search.indexOf('reftest') !== -1;
|
||||
])
|
||||
.forEach(appendScript);
|
||||
|
||||
window.addEventListener("unhandledrejection", function(event) {
|
||||
console.info('UNHANDLED PROMISE REJECTION:', event);
|
||||
});
|
||||
|
||||
window.onload = function() {
|
||||
(function($) {
|
||||
$.fn.html2canvas = function(options) {
|
||||
|
@ -86,6 +86,11 @@ testList
|
||||
throw new Error('Window not found for iframe');
|
||||
}
|
||||
|
||||
contentWindow.addEventListener('unhandledrejection', (event) => {
|
||||
console.error(event.reason);
|
||||
throw new Error(`unhandledrejection: ${JSON.stringify(event.reason)}`);
|
||||
});
|
||||
|
||||
const canvas: HTMLCanvasElement = await contentWindow
|
||||
// @ts-ignore
|
||||
.html2canvas(contentWindow.forceElement || contentWindow.document.documentElement, {
|
||||
|
Reference in New Issue
Block a user