(input)
| 81 | } |
| 82 | |
| 83 | function buildWindow(input) { |
| 84 | const localStorage = makeStorage(); |
| 85 | const sessionStorage = makeStorage(); |
| 86 | const entryUrl = input.entryUrl || 'https://www.bigmodel.cn/glm-coding'; |
| 87 | const url = new URL(entryUrl); |
| 88 | |
| 89 | const document = makeNoopProxy({ |
| 90 | cookie: input.cookieHeader || '', |
| 91 | referrer: entryUrl, |
| 92 | URL: entryUrl, |
| 93 | charset: 'UTF-8', |
| 94 | hidden: false, |
| 95 | visibilityState: 'visible', |
| 96 | documentElement: createElementStub({ clientWidth: 1920, clientHeight: 1080 }), |
| 97 | body: createElementStub({ clientWidth: 1920, clientHeight: 1080 }), |
| 98 | createElement(tag) { |
| 99 | const normalized = String(tag).toLowerCase(); |
| 100 | if (normalized === 'canvas') { |
| 101 | return createElementStub({ |
| 102 | getContext() { |
| 103 | return makeNoopProxy({ |
| 104 | fillRect() {}, |
| 105 | clearRect() {}, |
| 106 | getImageData() { |
| 107 | return { data: new Uint8ClampedArray(4) }; |
| 108 | }, |
| 109 | putImageData() {}, |
| 110 | createImageData() { |
| 111 | return []; |
| 112 | }, |
| 113 | setTransform() {}, |
| 114 | drawImage() {}, |
| 115 | save() {}, |
| 116 | fillText() {}, |
| 117 | restore() {}, |
| 118 | beginPath() {}, |
| 119 | moveTo() {}, |
| 120 | lineTo() {}, |
| 121 | closePath() {}, |
| 122 | stroke() {}, |
| 123 | translate() {}, |
| 124 | scale() {}, |
| 125 | rotate() {}, |
| 126 | arc() {}, |
| 127 | fill() {}, |
| 128 | measureText(text) { |
| 129 | return { width: String(text).length * 8 }; |
| 130 | }, |
| 131 | transform() {}, |
| 132 | rect() {}, |
| 133 | clip() {}, |
| 134 | }); |
| 135 | }, |
| 136 | toDataURL() { |
| 137 | return 'data:image/png;base64,AAAA'; |
| 138 | }, |
| 139 | width: 300, |
| 140 | height: 150, |
no test coverage detected