aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket/src/main/webapp/vnfmarket/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'vnfmarket/src/main/webapp/vnfmarket/node_modules/phantomjs/lib/phantom/examples/injectme.coffee')
-rw-r--r--vnfmarket/src/main/webapp/vnfmarket/node_modules/phantomjs/lib/phantom/examples/injectme.coffee23
1 files changed, 23 insertions, 0 deletions
diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/phantomjs/lib/phantom/examples/injectme.coffee b/vnfmarket/src/main/webapp/vnfmarket/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
new file mode 100644
index 00000000..ae4927d5
--- /dev/null
+++ b/vnfmarket/src/main/webapp/vnfmarket/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
@@ -0,0 +1,23 @@
+# Use 'page.injectJs()' to load the script itself in the Page context
+
+if phantom?
+ page = require('webpage').create()
+
+ # Route "console.log()" calls from within the Page context to the main
+ # Phantom context (i.e. current "this")
+ page.onConsoleMessage = (msg) -> console.log(msg)
+
+ page.onAlert = (msg) -> console.log(msg)
+
+ console.log "* Script running in the Phantom context."
+ console.log "* Script will 'inject' itself in a page..."
+ page.open "about:blank", (status) ->
+ if status is "success"
+ if page.injectJs("injectme.coffee")
+ console.log "... done injecting itself!"
+ else
+ console.log "... fail! Check the $PWD?!"
+ phantom.exit()
+else
+ alert "* Script running in the Page context."
+