From 26d012b3b7e0a557fa40f260871a2c6d9c24b539 Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Tue, 4 Nov 2014 12:32:53 -0800 Subject: [PATCH] Add comment clarifying new hook function, Refined Page Error output. --- IPython/html/tests/util.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/IPython/html/tests/util.js b/IPython/html/tests/util.js index 2125afc4b..9caf2dae2 100644 --- a/IPython/html/tests/util.js +++ b/IPython/html/tests/util.js @@ -22,8 +22,11 @@ casper.open_new_notebook = function () { }); this.waitFor(this.page_loaded); + // Hook the log and error methods of the console, forcing them to + // serialize their arguments before printing. This allows the + // Objects to cross into the phantom/slimer regime for display. this.thenEvaluate(function(){ - var fix_function = function(f, context) { + var serialize_arguments = function(f, context) { return function() { var pretty_arguments = []; for (var i = 0; i < arguments.length; i++) { @@ -37,8 +40,8 @@ casper.open_new_notebook = function () { f.apply(context, pretty_arguments); }; }; - console.log = fix_function(console.log, console); - console.error = fix_function(console.error, console); + console.log = serialize_arguments(console.log, console); + console.error = serialize_arguments(console.error, console); }); // Make sure the kernel has started @@ -675,7 +678,7 @@ casper.print_log = function () { casper.on("page.error", function onError(msg, trace) { // show errors in the browser this.echo("Page Error"); - this.echo(" Message: " + msg); + this.echo(" Message: " + msg.split('\n').join('\n ')); this.echo(" Call stack:"); var local_path = this.get_notebook_server(); for (var i = 0; i < trace.length; i++) {