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

Unified Diff: test/mjsunit/stack-traces.js

Issue 160263: Merge r2541 and r2542 to branches/1.2. (Closed) Base URL: http://v8.googlecode.com/svn/branches/1.2/
Patch Set: Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/version.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/stack-traces.js
===================================================================
--- test/mjsunit/stack-traces.js (revision 2544)
+++ test/mjsunit/stack-traces.js (working copy)
@@ -84,9 +84,26 @@
(function () { FAIL }).call([1, 2, 3]);
}
+function CustomError(message, stripPoint) {
+ this.message = message;
+ Error.captureStackTrace(this, stripPoint);
+}
+
+CustomError.prototype.toString = function () {
+ return "CustomError: " + this.message;
+};
+
+function testDefaultCustomError() {
+ throw new CustomError("hep-hey", undefined);
+}
+
+function testStrippedCustomError() {
+ throw new CustomError("hep-hey", CustomError);
+}
+
// Utility function for testing that the expected strings occur
// in the stack trace produced when running the given function.
-function testTrace(fun, expected) {
+function testTrace(fun, expected, unexpected) {
var threw = false;
try {
fun();
@@ -94,6 +111,11 @@
for (var i = 0; i < expected.length; i++) {
assertTrue(e.stack.indexOf(expected[i]) != -1);
}
+ if (unexpected) {
+ for (var i = 0; i < unexpected.length; i++) {
+ assertEquals(e.stack.indexOf(unexpected[i]), -1);
+ }
+ }
threw = true;
}
assertTrue(threw);
@@ -165,6 +187,10 @@
testTrace(testConstructor, ["new Plonk"]);
testTrace(testRenamedMethod, ["Wookie.a$b$c$d [as d]"]);
testTrace(testAnonymousMethod, ["Array.<anonymous>"]);
+testTrace(testDefaultCustomError, ["hep-hey", "new CustomError"],
+ ["collectStackTrace"]);
+testTrace(testStrippedCustomError, ["hep-hey"], ["new CustomError",
+ "collectStackTrace"]);
testCallerCensorship();
testUnintendedCallerCensorship();
« no previous file with comments | « src/version.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698