forked from karma-runner/karma-phantomjs-launcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
capture.template.js
41 lines (33 loc) · 1.01 KB
/
capture.template.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(function (phantom) {
var page = require('webpage').create();
<% if (exitOnResourceError) { %>
page.onResourceError = function() {
phantom.exit(1)
}
<% } %>
<% _.forOwn(pageOptions, function(value, key) { %>
page.<%= key %> = <%= value %>
<% }) %>
<% _.forOwn(pageSettingsOptions, function(value, key) { %>
page.settings.<%= key %> = <%= value %>
<% }) %>
page.onConsoleMessage = function () {
console.log.apply(console, arguments)
}
<% if (debug) { %>
function debugPage() {
console.log('Launch the debugger page at http://localhost:9000/webkit/inspector/inspector.html?page=2')
var debuggerWait = 15000
console.log('Waiting ' + (debuggerWait / 1000) + ' seconds for debugger page to launch...')
var launchPage = function () {
console.log('Launching page <%= url %>...')
page.open('<%= url %>')
}
setTimeout(launchPage, 15000)
}
debugPage()
<% } else { %>
page.open('<%= url %>')
page.onCallback = <%= callback %>
<% } %>
}(phantom))