Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / phantomjs / lib / phantom / examples / injectme.coffee
1 # Use 'page.injectJs()' to load the script itself in the Page context
2
3 if phantom?
4   page = require('webpage').create()
5
6   # Route "console.log()" calls from within the Page context to the main
7   # Phantom context (i.e. current "this")
8   page.onConsoleMessage = (msg) -> console.log(msg)
9
10   page.onAlert = (msg) -> console.log(msg)
11
12   console.log "* Script running in the Phantom context."
13   console.log "* Script will 'inject' itself in a page..."
14   page.open "about:blank", (status) ->
15     if status is "success"
16       if page.injectJs("injectme.coffee")
17         console.log "... done injecting itself!"
18       else
19         console.log "... fail! Check the $PWD?!"
20     phantom.exit()
21 else
22   alert "* Script running in the Page context."
23