(script)
| 1592 | } |
| 1593 | |
| 1594 | async pinScript(script) { |
| 1595 | let pinnedScript = new PinnedScript(script) |
| 1596 | let connection |
| 1597 | if (Object.is(this._cdpConnection, undefined)) { |
| 1598 | connection = await this.createCDPConnection('page') |
| 1599 | } else { |
| 1600 | connection = this._cdpConnection |
| 1601 | } |
| 1602 | |
| 1603 | await connection.send('Page.enable', {}) |
| 1604 | |
| 1605 | await connection.send('Runtime.evaluate', { |
| 1606 | expression: pinnedScript.creationScript(), |
| 1607 | }) |
| 1608 | |
| 1609 | let result = await connection.send('Page.addScriptToEvaluateOnNewDocument', { |
| 1610 | source: pinnedScript.creationScript(), |
| 1611 | }) |
| 1612 | |
| 1613 | pinnedScript.scriptId = result['result']['identifier'] |
| 1614 | |
| 1615 | this.pinnedScripts_[pinnedScript.handle] = pinnedScript |
| 1616 | |
| 1617 | return pinnedScript |
| 1618 | } |
| 1619 | |
| 1620 | async unpinScript(script) { |
| 1621 | if (script && !(script instanceof PinnedScript)) { |
no test coverage detected