Skip to content

Commit 577e831

Browse files
committed
minor tweaks
1 parent 4da618f commit 577e831

4 files changed

Lines changed: 46 additions & 10 deletions

File tree

‎v4-cokapi/backends/javascript/jslogger.js‎

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,39 @@ function listener(event, execState, eventData, data) {
643643
}
644644
}
645645

646+
647+
// for testing
648+
function simpleListener(event, execState, eventData, data) {
649+
var stepType, i, n;
650+
var ii, jj, sc, scopeType, scopeObj;
651+
var f;
652+
653+
// TODO: catch CompileError and maybe other events too
654+
if (event !== debug.DebugEvent.Break && event !== debug.DebugEvent.Exception) {
655+
return;
656+
}
657+
658+
var isException = (event === debug.DebugEvent.Exception);
659+
660+
var script = eventData.func().script().name();
661+
var line = eventData.sourceLine() + 1;
662+
var col = eventData.sourceColumn();
663+
assert(line >= 2);
664+
line -= 2; // to account for wrapUserscript() adding extra lines
665+
666+
log(script, line, col, isException);
667+
668+
// if what we're currently executing isn't inside of userscript.js,
669+
// then PUNT, since we're probably in the first line of console.log()
670+
// or some other utility function
671+
if (script !== 'userscript.js') {
672+
execState.prepareStep(debug.StepAction.StepOut);
673+
} else {
674+
execState.prepareStep(debug.StepAction.StepIn);
675+
}
676+
}
677+
678+
646679
assert(argv._.length <= 1);
647680
var cod;
648681
if (argv._.length === 1) {
@@ -667,14 +700,17 @@ try {
667700
}
668701
catch (e) {
669702
// for some reason, the node debugger doesn't allow us to keep going
670-
// after an uncaught exception to, say, execute 'finally' clauses. so
671-
// let's just issue this warning by hijacking the last entry.
703+
// after an uncaught exception to, say, execute 'finally' clauses.
672704
if (curTrace.length > 0) {
705+
// do a NOP for now ... it's weird to issue an uncaught_exception since
706+
// that's usually reserved for syntax errors
707+
/*
673708
var lastEntry = curTrace[curTrace.length - 1];
674-
lastEntry.event = 'uncaught_exception';
709+
lastEntry.event = 'exception';
675710
lastEntry.exception_msg = String(e);
676711
lastEntry.exception_msg += "\n(Uncaught Exception: execution ended due to current limits of\nthis visualizer. 'finally' blocks and other code might not be run.)";
677712
lastEntry.line = 0;
713+
*/
678714
} else {
679715
// likely a compile error since nothing executed yet; trace is empty
680716

‎v4-cokapi/backends/javascript/tests/exception.golden‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -846,14 +846,13 @@
846846
encoded_locals: { n: 0, x: [ 'JS_SPECIAL_VAL', 'undefined' ] } } ],
847847
globals: { f: [ 'REF', 1 ] },
848848
ordered_globals: [ 'f' ],
849-
line: 0,
849+
line: 18,
850850
col: 8,
851-
event: 'uncaught_exception',
851+
event: 'step_line',
852852
heap:
853853
{ '1':
854854
[ 'JS_FUNCTION',
855855
'f',
856856
'function f(n) {\n try {\n if (n == 0) {\n throw new Error(\'DivByZero\');\n }\n else {\n var x = 10 / n;\n console.log("x is " + x);\n f(n-1);\n console.log("survived!");\n }\n }\n finally {\n console.log("Bye from f where n = " + n);\n }\n}',
857857
null,
858-
null ] },
859-
exception_msg: 'Error: DivByZero\n(Uncaught Exception: execution ended due to current limits of\nthis visualizer. \'finally\' blocks and other code might not be run.)' } ] }
858+
null ] } } ] }

‎v4-cokapi/backends/javascript/tests/strict-runtime-error.golden‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
col: 2,
1919
event: 'step_line',
2020
heap: {} },
21-
{ exception_msg: 'ReferenceError: y is not defined\n(Uncaught Exception: execution ended due to current limits of\nthis visualizer. \'finally\' blocks and other code might not be run.)',
21+
{ exception_msg: 'ReferenceError: y is not defined',
2222
stdout: '',
2323
func_name: '',
2424
stack_to_render: [],
2525
globals: { x: 5 },
2626
ordered_globals: [ 'x' ],
27-
line: 0,
27+
line: 2,
2828
col: 2,
29-
event: 'uncaught_exception',
29+
event: 'exception',
3030
heap: {} } ] }

‎v4-cokapi/frontends/js/opt-frontend-common.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ function initAceEditor(height) {
7070
initDeltaObj();
7171
pyInputAceEditor.on('change', function(e) {
7272
$.doTimeout('pyInputAceEditorChange', 1000, snapshotCodeDiff); // debounce
73+
clearFrontendError();
7374
});
7475

7576
// don't do real-time syntax checks:

0 commit comments

Comments
 (0)