Skip to content

Commit

Permalink
Add setOfflineMode() to puppet context (#5)
Browse files Browse the repository at this point in the history
* Add `setOfflineMode()` to puppet context

* Document `puppet.setOfflineMode()`
  • Loading branch information
andywer authored Dec 6, 2018
1 parent 577fe97 commit bdc85fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ Causes the script to end. The `puppet-run` process will exit with the exit code

The exit code defaults to zero.

#### `puppet.setOfflineMode(takeOffline: boolean = true)`

Puts the browser in offline mode and closes all active connections if called with `true` or no arguments. Call it with `false` to bring the browser back online.


## Test framework support

Expand Down
7 changes: 5 additions & 2 deletions src/host-bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ export async function injectPuppetContext (page: Page, contextConfig: PuppetCont
window.puppet = {
argv: ${JSON.stringify(contextConfig.argv)},
plugins: ${JSON.stringify(contextConfig.plugins)},
exit: (exitCode = 0) => {
console.log(${JSON.stringify(magicLogMessageMarker)}, "exit", exitCode);
exit (exitCode = 0) {
console.log(${JSON.stringify(magicLogMessageMarker)}, "exit", exitCode)
},
setOfflineMode (offline = true) {
return window.setPuppetOfflineMode(offline)
}
};
`
Expand Down

0 comments on commit bdc85fd

Please sign in to comment.