See https://bugzilla.mozilla.org/show_bug.cgi?id=1735738 for reference.
const images = node.getElementsByTagName("img");
  const data = await inlineImages(images);
  const loadedPromises = [];
  for (let i = 0, ii = data.length; i < ii; i++) {
    loadedPromises.push(
      new Promise(function (resolveImage, rejectImage) {
        images[i].onload = resolveImage;
        images[i].onerror = function (e) {
          if (silentErrors) {
            resolveImage();
          } else {
            rejectImage(new Error("Error loading image " + e));
          }
        };
        images[i].src = data[i];
      })
    );
  }
  await Promise.all(loadedPromises);
}
/**
 * @class
 */
var rasterizeTextLayer = (function rasterizeTextLayerClosure() {
  const styles = {