Commit cb06ffab authored by yangguo@chromium.org's avatar yangguo@chromium.org

Correctly check for native error objects.

BUG=2138
TEST=

Review URL: https://chromiumcodereview.appspot.com/10392158

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11589 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3d45e98b
......@@ -61,18 +61,21 @@ function FormatString(format, message) {
// To check if something is a native error we need to check the
// concrete native error types. It is not enough to check "obj
// instanceof $Error" because user code can replace
// NativeError.prototype.__proto__. User code cannot replace
// NativeError.prototype though and therefore this is a safe test.
// concrete native error types. It is not sufficient to use instanceof
// since it possible to create an object that has Error.prototype on
// its prototype chain. This is the case for DOMException for example.
function IsNativeErrorObject(obj) {
return (obj instanceof $Error) ||
(obj instanceof $EvalError) ||
(obj instanceof $RangeError) ||
(obj instanceof $ReferenceError) ||
(obj instanceof $SyntaxError) ||
(obj instanceof $TypeError) ||
(obj instanceof $URIError);
switch (%_ClassOf(obj)) {
case 'Error':
case 'EvalError':
case 'RangeError':
case 'ReferenceError':
case 'SyntaxError':
case 'TypeError':
case 'URIError':
return true;
}
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment