(script)
| 1547 | } |
| 1548 | |
| 1549 | async pinScript(script) { |
| 1550 | let pinnedScript = new PinnedScript(script) |
| 1551 | let connection |
| 1552 | if (Object.is(this._cdpConnection, undefined)) { |
| 1553 | connection = await this.createCDPConnection('page') |
| 1554 | } else { |
| 1555 | connection = this._cdpConnection |
| 1556 | } |
| 1557 | |
| 1558 | await connection.send('Page.enable', {}) |
| 1559 | |
| 1560 | await connection.send('Runtime.evaluate', { |
| 1561 | expression: pinnedScript.creationScript(), |
| 1562 | }) |
| 1563 | |
| 1564 | let result = await connection.send('Page.addScriptToEvaluateOnNewDocument', { |
| 1565 | source: pinnedScript.creationScript(), |
| 1566 | }) |
| 1567 | |
| 1568 | pinnedScript.scriptId = result['result']['identifier'] |
| 1569 | |
| 1570 | this.pinnedScripts_[pinnedScript.handle] = pinnedScript |
| 1571 | |
| 1572 | return pinnedScript |
| 1573 | } |
| 1574 | |
| 1575 | async unpinScript(script) { |
| 1576 | if (script && !(script instanceof PinnedScript)) { |
no test coverage detected