Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 function stripURL(url) { | |
| 2 return url ? url.match( /[^\/]+\/?$/ )[0] : url; | |
| 3 } | |
| 4 | |
| 5 function throwException(message) { | |
| 6 throw new Error(message ? message : "An exception"); | |
| 7 } | |
| 8 | |
| 9 var errorsSeen = 0; | |
| 10 function DumpOnErrorArgumentValuesAndReturn(returnValue, callback) { | |
|
do-not-use
2013/07/24 13:18:01
nit: function usually start with a lowercase in Bl
Mike West
2013/07/24 15:28:32
Done.
| |
| 11 window.onerror = function (message, url, line, column) { | |
| 12 debug("window.onerror: \"" + message + "\" at " + stripURL(url) + " (" + line + ", " + column + ")"); | |
|
do-not-use
2013/07/24 13:18:01
nit: I find the output in expected results not ver
Mike West
2013/07/24 15:28:32
Done.
| |
| 13 | |
| 14 if (callback) | |
| 15 callback(++errorsSeen); | |
| 16 if (returnValue) | |
| 17 debug("- Returning 'true': the error should not be reported in the c onsole as an unhandled exception."); | |
|
do-not-use
2013/07/24 13:18:01
I think we can remove the "- " prefix, I don't fin
Mike West
2013/07/24 15:28:32
Done.
| |
| 18 else | |
| 19 debug("- Returning 'false': the error should be reported in the cons ole as an unhandled exception."); | |
| 20 return returnValue; | |
| 21 }; | |
| 22 } | |
| 23 | |
| 24 function DumpErrorEventAndAllowDefault(callback) { | |
|
do-not-use
2013/07/24 13:18:01
Ditto.
Mike West
2013/07/24 15:28:32
Done.
| |
| 25 window.addEventListener('error', function (e) { | |
| 26 DumpErrorEvent(e) | |
| 27 debug("- Not calling e.preventDefault(): the error should be reported in the console as an unhandled exception."); | |
| 28 if (callback) | |
| 29 callback(++errorsSeen); | |
| 30 }); | |
| 31 } | |
| 32 | |
| 33 function DumpErrorEventAndPreventDefault(callback) { | |
|
do-not-use
2013/07/24 13:18:01
ditto.
Mike West
2013/07/24 15:28:32
Done.
| |
| 34 window.addEventListener('error', function (e) { | |
| 35 DumpErrorEvent(e); | |
| 36 debug("- Calling e.preventDefault(): the error should not be reported in the console as an unhandled exception."); | |
| 37 e.preventDefault(); | |
| 38 if (callback) | |
| 39 callback(++errorsSeen); | |
| 40 }); | |
| 41 } | |
| 42 | |
| 43 var eventPassedToTheErrorListener = null; | |
| 44 var eventCurrentTarget = null; | |
| 45 function DumpErrorEvent(e) { | |
|
do-not-use
2013/07/24 13:18:01
Ditto.
Mike West
2013/07/24 15:28:32
Done.
| |
| 46 debug("Handling '" + e.type + "' event (phase " + e.eventPhase + "): \"" + e .message + "\" at " + stripURL(e.filename) + ":" + e.lineno); | |
| 47 | |
| 48 eventPassedToTheErrorListener = e; | |
| 49 eventCurrentTarget = e.currentTarget; | |
| 50 shouldBe('eventPassedToTheErrorListener', 'window.event'); | |
| 51 shouldBe('eventCurrentTarget', 'window'); | |
| 52 eventPassedToTheErrorListener = null; | |
| 53 eventCurrentTarget = null; | |
| 54 } | |
| OLD | NEW |