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

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

Issue 8345039: Make builtin functions be skipped in stack traces. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed review comments. Created 9 years, 2 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/runtime.cc ('k') | test/mjsunit/stack-traces-2.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/stack-traces.js
diff --git a/test/mjsunit/stack-traces.js b/test/mjsunit/stack-traces.js
index 47a5cc594a056575592033b02e05b1ed8eaa2d30..536e71bbb58a33a5ad6e2db9bae34fc9e6034a7f 100644
--- a/test/mjsunit/stack-traces.js
+++ b/test/mjsunit/stack-traces.js
@@ -194,6 +194,46 @@ function testErrorsDuringFormatting() {
}
+// Poisonous object that throws a reference error if attempted converted to
+// a primitive values.
+var thrower = { valueOf: function() { FAIL; },
+ toString: function() { FAIL; } };
+
+// Tests that a native constructor function is included in the
+// stack trace.
+function testTraceNativeConstructor(nativeFunc) {
+ var nativeFuncName = nativeFunc.name;
+ try {
+ new nativeFunc(thrower);
+ assertUnreachable(nativeFuncName);
+ } catch (e) {
+ assertTrue(e.stack.indexOf(nativeFuncName) >= 0, nativeFuncName);
+ }
+}
+
+// Tests that a native conversion function is included in the
+// stack trace.
+function testTraceNativeConversion(nativeFunc) {
+ var nativeFuncName = nativeFunc.name;
+ try {
+ nativeFunc(thrower);
+ assertUnreachable(nativeFuncName);
+ } catch (e) {
+ assertTrue(e.stack.indexOf(nativeFuncName) >= 0, nativeFuncName);
+ }
+}
+
+
+function testOmittedBuiltin(throwing, omitted) {
+ try {
+ throwing();
+ assertUnreachable(omitted);
+ } catch (e) {
+ assertTrue(e.stack.indexOf(omitted) < 0, omitted);
+ }
+}
+
+
testTrace("testArrayNative", testArrayNative, ["Array.map (native)"]);
testTrace("testNested", testNested, ["at one", "at two", "at three"]);
testTrace("testMethodNameInference", testMethodNameInference, ["at Foo.bar"]);
@@ -217,3 +257,21 @@ testTrace("testStrippedCustomError", testStrippedCustomError, ["hep-hey"],
testCallerCensorship();
testUnintendedCallerCensorship();
testErrorsDuringFormatting();
+
+testTraceNativeConversion(String); // Does ToString on argument.
+testTraceNativeConversion(Number); // Does ToNumber on argument.
+testTraceNativeConversion(RegExp); // Does ToString on argument.
+
+testTraceNativeConstructor(String); // Does ToString on argument.
+testTraceNativeConstructor(Number); // Does ToNumber on argument.
+testTraceNativeConstructor(RegExp); // Does ToString on argument.
+testTraceNativeConstructor(Date); // Does ToNumber on argument.
+
+// Omitted because QuickSort has builtins object as receiver, and is non-native
+// builtin.
+testOmittedBuiltin(function(){ [thrower, 2].sort(function (a,b) {
+ (b < a) - (a < b); });
+ }, "QuickSort");
+
+// Omitted because ADD from runtime.js is non-native builtin.
+testOmittedBuiltin(function(){ thrower + 2; }, "ADD");
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/stack-traces-2.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698