| Index: src/messages.js
|
| ===================================================================
|
| --- src/messages.js (revision 6298)
|
| +++ src/messages.js (working copy)
|
| @@ -97,6 +97,12 @@
|
| var constructorName = constructor.name;
|
| if (!constructorName) return ToString(obj);
|
| return "#<" + GetInstanceName(constructorName) + ">";
|
| + } else if (obj instanceof $Error) {
|
| + // When formatting internally created error messages, do not
|
| + // invoke overwritten error toString methods but explicitly use
|
| + // the error to string method. This is to avoid leaking error
|
| + // objects between script tags in a browser setting.
|
| + return %_CallFunction(obj, errorToString);
|
| } else {
|
| return ToString(obj);
|
| }
|
| @@ -943,7 +949,12 @@
|
| }
|
| %FunctionSetInstanceClassName(f, 'Error');
|
| %SetProperty(f.prototype, 'constructor', f, DONT_ENUM);
|
| - f.prototype.name = name;
|
| + // The name property on the prototype of error objects is not
|
| + // specified as being read-one and dont-delete. However, allowing
|
| + // overwriting allows leaks of error objects between script blocks
|
| + // in the same context in a browser setting. Therefore we fix the
|
| + // name.
|
| + %SetProperty(f.prototype, "name", name, READ_ONLY | DONT_DELETE);
|
| %SetCode(f, function(m) {
|
| if (%_IsConstructCall()) {
|
| // Define all the expected properties directly on the error
|
| @@ -995,14 +1006,15 @@
|
| // Setup extra properties of the Error.prototype object.
|
| $Error.prototype.message = '';
|
|
|
| -%SetProperty($Error.prototype, 'toString', function toString() {
|
| +function errorToString() {
|
| var type = this.type;
|
| if (type && !this.hasOwnProperty("message")) {
|
| return this.name + ": " + FormatMessage({ type: type, args: this.arguments });
|
| }
|
| var message = this.hasOwnProperty("message") ? (": " + this.message) : "";
|
| return this.name + message;
|
| -}, DONT_ENUM);
|
| +}
|
| +%SetProperty($Error.prototype, 'toString', errorToString, DONT_ENUM);
|
|
|
|
|
| // Boilerplate for exceptions for stack overflows. Used from
|
|
|