(expression: string, sourceUrl?: string)
| 170 | } |
| 171 | |
| 172 | async evaluate(expression: string, sourceUrl?: string): Promise<Cdp.Runtime.EvaluateResult> { |
| 173 | ++this._evaluateCounter; |
| 174 | this.log(`Evaluating#${this._evaluateCounter}: ${expression}`); |
| 175 | if (sourceUrl === undefined) sourceUrl = `//# sourceURL=eval${this._evaluateCounter}.js`; |
| 176 | else if (sourceUrl) sourceUrl = `//# sourceURL=${this.completeUrl(sourceUrl)}`; |
| 177 | return this._cdp!.Runtime.evaluate({ expression: expression + `\n${sourceUrl}` }).then( |
| 178 | result => { |
| 179 | if (!result) { |
| 180 | this.log(expression, 'Error evaluating'); |
| 181 | debugger; |
| 182 | throw new Error('Error evaluating "' + expression + '"'); |
| 183 | } else if (result.exceptionDetails) { |
| 184 | this.log(result.exceptionDetails, 'Error evaluating'); |
| 185 | debugger; |
| 186 | throw new Error('Error evaluating "' + expression + '"'); |
| 187 | } |
| 188 | return result; |
| 189 | }, |
| 190 | ); |
| 191 | } |
| 192 | |
| 193 | async addScriptTag(relativePath: string): Promise<void> { |
| 194 | await this._cdp!.Runtime.evaluate({ |
nothing calls this directly
no test coverage detected