aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dom_tests/test_runner.coffee
blob: 9ed3cd3bddb83cd8e5d5fd67673d5991abf87551 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Tests.outputMethod = (args...) ->
  newOutput = args.join "\n"
  # escape html
  newOutput = newOutput.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
  # highlight the source of the error
  newOutput = newOutput.replace /\/([^:/]+):([0-9]+):([0-9]+)/, "/<span class='errorPosition'>$1:$2</span>:$3"
  document.getElementById("output-div").innerHTML += "<div class='output-section'>" + newOutput + "</div>"
  console.log.apply console, args

# PhantomJS will call the tests manually
unless navigator.userAgent == 'phantom'
  # ensure the extension has time to load before commencing the tests
  document.addEventListener "DOMContentLoaded", ->
    setTimeout Tests.run, 200