Modified: trunk/JSTests/ChangeLog (204662 => 204663)
--- trunk/JSTests/ChangeLog 2016-08-19 22:44:08 UTC (rev 204662)
+++ trunk/JSTests/ChangeLog 2016-08-19 22:49:26 UTC (rev 204663)
@@ -1,3 +1,25 @@
+2016-08-19 Joseph Pecoraro <[email protected]>
+
+ Make custom Error properties (line, column, sourceURL) configurable and writable
+ https://bugs.webkit.org/show_bug.cgi?id=160984
+ <rdar://problem/27905979>
+
+ Reviewed by Saam Barati.
+
+ * stress/native-error-properties.js: Added.
+ (assert):
+ (shouldNotThrow):
+
+ (checkEmptyErrorPropertiesDescriptors):
+ (checkNonEmptyErrorPropertiesDescriptors):
+ The spec only describes the "message" property, so
+ ensure it has the right descriptor attributes.
+
+ (checkErrorPropertiesWritable):
+ Ensure common error property names are writable.
+ In strict mode this would have thrown an exception
+ if they were readonly.
+
2016-08-18 Mark Lam <[email protected]>
ScopedArguments is using the wrong owner object for a write barrier.
Added: trunk/JSTests/stress/native-error-properties.js (0 => 204663)
--- trunk/JSTests/stress/native-error-properties.js (rev 0)
+++ trunk/JSTests/stress/native-error-properties.js 2016-08-19 22:49:26 UTC (rev 204663)
@@ -0,0 +1,79 @@
+"use strict";
+
+function assert(b) {
+ if (!b)
+ throw new Error("Bad assertion");
+}
+
+function shouldNotThrow(expr) {
+ let testFunc = new Function(expr);
+ let error;
+ try {
+ testFunc();
+ } catch (e) {
+ error = e;
+ }
+ assert(!error);
+}
+
+function checkEmptyErrorPropertiesDescriptors(error) {
+ let descriptor = Object.getOwnPropertyDescriptor(error, "message");
+ assert(descriptor === undefined);
+}
+
+function checkNonEmptyErrorPropertiesDescriptors(error) {
+ let descriptor = Object.getOwnPropertyDescriptor(error, "message");
+ assert(descriptor.configurable);
+ assert(!descriptor.enumerable);
+ assert(descriptor.writable);
+}
+
+function checkErrorPropertiesWritable(error) {
+ let properties = ["name", "message", "line", "lineNumber", "column", "columnNumber", "sourceURL", "stack"];
+ for (let p of properties) {
+ assert(error[p] !== 999);
+ error[p] = 999;
+ assert(error[p] === 999);
+ }
+}
+
+// User created error instances.
+let errorConstructors = [Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError];
+for (let constructor of errorConstructors) {
+ shouldNotThrow(`checkErrorPropertiesWritable(new ${constructor.name})`);
+ shouldNotThrow(`checkEmptyErrorPropertiesDescriptors(new ${constructor.name})`);
+ shouldNotThrow(`checkNonEmptyErrorPropertiesDescriptors(new ${constructor.name}('message'))`);
+}
+
+// Engine created error instances.
+var globalError = null;
+
+try {
+ eval("{");
+} catch (e) {
+ globalError = e;
+ assert(e.name === "SyntaxError");
+ assert(e.message.length);
+ shouldNotThrow("checkNonEmptyErrorPropertiesDescriptors(globalError)");
+ shouldNotThrow("checkErrorPropertiesWritable(globalError)");
+}
+
+try {
+ a.b.c;
+} catch (e) {
+ globalError = e;
+ assert(e.name === "ReferenceError");
+ assert(e.message.length);
+ shouldNotThrow("checkNonEmptyErrorPropertiesDescriptors(globalError)");
+ shouldNotThrow("checkErrorPropertiesWritable(globalError)");
+}
+
+try {
+ undefined.x;
+} catch (e) {
+ globalError = e;
+ assert(e.name === "TypeError");
+ assert(e.message.length);
+ shouldNotThrow("checkNonEmptyErrorPropertiesDescriptors(globalError)");
+ shouldNotThrow("checkErrorPropertiesWritable(globalError)");
+}
Modified: trunk/Source/_javascript_Core/ChangeLog (204662 => 204663)
--- trunk/Source/_javascript_Core/ChangeLog 2016-08-19 22:44:08 UTC (rev 204662)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-08-19 22:49:26 UTC (rev 204663)
@@ -1,5 +1,17 @@
2016-08-19 Joseph Pecoraro <[email protected]>
+ Make custom Error properties (line, column, sourceURL) configurable and writable
+ https://bugs.webkit.org/show_bug.cgi?id=160984
+ <rdar://problem/27905979>
+
+ Reviewed by Saam Barati.
+
+ * runtime/Error.cpp:
+ (JSC::addErrorInfoAndGetBytecodeOffset):
+ (JSC::addErrorInfo):
+
+2016-08-19 Joseph Pecoraro <[email protected]>
+
Remove empty files and empty namespace blocks
https://bugs.webkit.org/show_bug.cgi?id=160990
Modified: trunk/Source/_javascript_Core/runtime/Error.cpp (204662 => 204663)
--- trunk/Source/_javascript_Core/runtime/Error.cpp 2016-08-19 22:44:08 UTC (rev 204662)
+++ trunk/Source/_javascript_Core/runtime/Error.cpp 2016-08-19 22:49:26 UTC (rev 204663)
@@ -159,12 +159,12 @@
unsigned line;
unsigned column;
firstNonNativeFrame->computeLineAndColumn(line, column);
- obj->putDirect(vm, vm.propertyNames->line, jsNumber(line), ReadOnly | DontDelete);
- obj->putDirect(vm, vm.propertyNames->column, jsNumber(column), ReadOnly | DontDelete);
+ obj->putDirect(vm, vm.propertyNames->line, jsNumber(line));
+ obj->putDirect(vm, vm.propertyNames->column, jsNumber(column));
String frameSourceURL = firstNonNativeFrame->sourceURL();
if (!frameSourceURL.isEmpty())
- obj->putDirect(vm, vm.propertyNames->sourceURL, jsString(&vm, frameSourceURL), ReadOnly | DontDelete);
+ obj->putDirect(vm, vm.propertyNames->sourceURL, jsString(&vm, frameSourceURL));
obj->putDirect(vm, vm.propertyNames->stack, Interpreter::stackTraceAsString(vm, stackTrace), DontEnum);
@@ -185,9 +185,9 @@
const String& sourceURL = source.provider()->url();
if (line != -1)
- error->putDirect(*vm, Identifier::fromString(vm, linePropertyName), jsNumber(line), ReadOnly | DontDelete);
+ error->putDirect(*vm, Identifier::fromString(vm, linePropertyName), jsNumber(line));
if (!sourceURL.isNull())
- error->putDirect(*vm, Identifier::fromString(vm, sourceURLPropertyName), jsString(vm, sourceURL), ReadOnly | DontDelete);
+ error->putDirect(*vm, Identifier::fromString(vm, sourceURLPropertyName), jsString(vm, sourceURL));
return error;
}