Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(685)

Side by Side Diff: LayoutTests/fast/events/resources/onerror-test.js

Issue 19962008: Rewrite the 'window.onerror' tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: *facepalm* Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/fast/events/resources/window-onerror.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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) {
11 window.onerror = function (message, url, line, column) {
12 debug("window.onerror: \"" + message + "\" at " + stripURL(url) + " (Lin e: " + line + ", Column: " + column + ")");
13
14 if (callback)
15 callback(++errorsSeen);
16 if (returnValue)
17 debug("Returning 'true': the error should not be reported in the con sole as an unhandled exception.");
18 else
19 debug("Returning 'false': the error should be reported in the consol e as an unhandled exception.");
20 return returnValue;
21 };
22 }
23
24 function dumpErrorEventAndAllowDefault(callback) {
25 window.addEventListener('error', function (e) {
26 dumpErrorEvent(e)
27 debug("Not calling e.preventDefault(): the error should be reported in t he console as an unhandled exception.");
28 if (callback)
29 callback(++errorsSeen);
30 });
31 }
32
33 function dumpErrorEventAndPreventDefault(callback) {
34 window.addEventListener('error', function (e) {
35 dumpErrorEvent(e);
36 debug("Calling e.preventDefault(): the error should not be reported in t he 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) {
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 }
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/events/resources/window-onerror.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698