2011-12-30 15:47:08 +00:00
|
|
|
(function() {
|
|
|
|
var puts;
|
2012-01-10 22:14:37 +00:00
|
|
|
|
2011-10-25 19:41:22 +00:00
|
|
|
if (window.JHW) {
|
|
|
|
window.console = {
|
|
|
|
log: function(data) {
|
|
|
|
var dump, useJsDump;
|
|
|
|
if (typeof jQuery !== 'undefined' && data instanceof jQuery) {
|
2011-11-18 12:51:54 +00:00
|
|
|
return JHW.log(style_html($("<div />").append(data.clone()).html(), {
|
2011-10-25 19:41:22 +00:00
|
|
|
indent_size: 2
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
useJsDump = true;
|
|
|
|
try {
|
|
|
|
if (typeof data.toJSON === 'function') {
|
|
|
|
JHW.log("JSON: " + (JSON.stringify(data, null, 2)));
|
|
|
|
useJsDump = false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
2011-10-25 15:25:02 +00:00
|
|
|
|
2011-10-25 19:41:22 +00:00
|
|
|
}
|
|
|
|
if (useJsDump) {
|
|
|
|
dump = jsDump.doParse(data);
|
|
|
|
if (dump.indexOf("\n") === -1) {
|
|
|
|
return JHW.log(dump);
|
|
|
|
} else {
|
|
|
|
return JHW.log("jsDump: " + dump);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
pp: function(data) {
|
|
|
|
return JHW.log(jasmine ? jasmine.pp(data) : console.log(data));
|
|
|
|
},
|
|
|
|
peek: function(data) {
|
|
|
|
console.log(data);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
};
|
2011-12-30 15:47:08 +00:00
|
|
|
puts = function(message) {
|
|
|
|
return JHW.print('stdout', message + "\n");
|
|
|
|
};
|
2011-10-25 19:41:22 +00:00
|
|
|
window.onbeforeunload = function(e) {
|
2011-11-05 18:19:41 +00:00
|
|
|
e = e || window.event;
|
2011-10-26 02:22:29 +00:00
|
|
|
JHW.hasError();
|
2011-12-30 15:47:08 +00:00
|
|
|
puts("The code tried to leave the test page. Check for unhandled form submits and link clicks.");
|
2012-01-10 22:14:37 +00:00
|
|
|
if (e) e.returnValue = 'string';
|
2011-11-05 18:19:41 +00:00
|
|
|
return 'string';
|
2011-10-25 19:41:22 +00:00
|
|
|
};
|
|
|
|
JHW._hasErrors = false;
|
|
|
|
JHW._handleError = function(message, lineNumber, sourceURL) {
|
2011-12-29 23:37:23 +00:00
|
|
|
JHW.print('stderr', message + "\n");
|
2011-10-25 19:41:22 +00:00
|
|
|
JHW._hasErrors = true;
|
|
|
|
return false;
|
|
|
|
};
|
2012-01-09 16:09:34 +00:00
|
|
|
window.confirm = function() {
|
|
|
|
puts("" + ("[confirm]".foreground('red')) + " You should mock window.confirm. Returning true.");
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
window.prompt = function() {
|
|
|
|
puts("" + ("[prompt]".foreground('red')) + " You should mock window.prompt. Returning true.");
|
2011-12-30 15:47:08 +00:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
window.alert = function(message) {
|
|
|
|
return puts("[alert] ".foreground('red') + message);
|
|
|
|
};
|
2011-10-26 02:22:29 +00:00
|
|
|
JHW._setColors = function(useColors) {
|
|
|
|
return Intense.useColors = useColors;
|
2011-10-25 19:41:22 +00:00
|
|
|
};
|
2011-10-26 02:22:29 +00:00
|
|
|
JHW._usedConsole = false;
|
2011-10-25 19:41:22 +00:00
|
|
|
JHW.log = function(msg) {
|
2011-12-29 23:37:23 +00:00
|
|
|
var reporter, _i, _len, _ref;
|
2011-10-26 02:22:29 +00:00
|
|
|
JHW.hasUsedConsole();
|
2011-12-29 23:37:23 +00:00
|
|
|
_ref = jasmine.getEnv().reporter.subReporters_;
|
|
|
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
|
|
reporter = _ref[_i];
|
2012-01-10 22:14:37 +00:00
|
|
|
if (reporter.consoleLogUsed != null) reporter.consoleLogUsed(msg);
|
2011-12-29 23:37:23 +00:00
|
|
|
}
|
2011-10-26 02:22:29 +00:00
|
|
|
JHW._usedConsole = true;
|
2011-12-30 15:47:08 +00:00
|
|
|
return puts(msg);
|
2011-10-25 19:41:22 +00:00
|
|
|
};
|
|
|
|
}
|
2012-01-10 22:14:37 +00:00
|
|
|
|
2011-10-26 12:45:23 +00:00
|
|
|
window.CoffeeScriptToFilename = {};
|
2012-01-10 22:14:37 +00:00
|
|
|
|
2011-10-26 12:55:44 +00:00
|
|
|
window.CSTF = window.CoffeeScriptToFilename;
|
2012-01-10 22:14:37 +00:00
|
|
|
|
2011-12-30 15:47:08 +00:00
|
|
|
}).call(this);
|