See https://bugzilla.mozilla.org/show_bug.cgi?id=1735738 for reference.
while (styleSheet.cssRules.length > 0) {
          styleSheet.deleteRule(0);
        }
        styleSheet.ownerNode.remove();
      }
      const body = document.body;
      while (body.lastChild !== this.end) {
        body.removeChild(body.lastChild);
      }
      const destroyedPromises = [];
      
      for (let i = 0; i < this.manifest.length; i++) {
        if (this.manifest[i].pdfDoc) {
          destroyedPromises.push(this.manifest[i].pdfDoc.destroy());
          delete this.manifest[i].pdfDoc;
        }
      }
      return Promise.all(destroyedPromises);
    },
    _exceptionToString: function Driver_exceptionToString(e) {
      if (typeof e !== "object") {
        return String(e);
      }
      if (!("message" in e)) {
        return JSON.stringify(e);
      }
      return e.message + ("stack" in e ? " at " + e.stack.split("\n")[0] : "");
    },
    _getLastPageNumber: function Driver_getLastPageNumber(task) {
      if (!task.pdfDoc) {