| 48 | } |
| 49 | |
| 50 | function execScript(scriptText: string) { |
| 51 | const iframe = document.querySelector("iframe#iframe"); |
| 52 | if (!iframe || !(iframe instanceof HTMLIFrameElement)) { |
| 53 | throw new Error("Can't execute the script because iframe isn't found"); |
| 54 | } |
| 55 | const doc = iframe.contentDocument!; |
| 56 | const script = doc.createElement("script"); |
| 57 | script.innerText = scriptText; |
| 58 | // @ts-expect-error - We're messing with iframes |
| 59 | if (!(doc.body instanceof iframe.contentWindow.HTMLBodyElement)) { |
| 60 | throw new Error( |
| 61 | "Can't execute the script because iframe does not have body", |
| 62 | ); |
| 63 | } |
| 64 | doc.body.append(script); |
| 65 | } |
| 66 | }); |
| 67 | |
| 68 | it("returns false if the given value is not a date object", () => { |