Title: [250436] trunk
Revision
250436
Author
[email protected]
Date
2019-09-27 11:32:47 -0700 (Fri, 27 Sep 2019)

Log Message

Non-standard Error properties should not be enumerable
https://bugs.webkit.org/show_bug.cgi?id=198975

Patch by Alexey Shvayka <[email protected]> on 2019-09-27
Reviewed by Ross Kirsling.

JSTests:

* ChakraCore/test/Error/NativeErrors_v4.baseline-jsc: Adjust expectations.
* microbenchmarks/let-for-in.js: Adjust test.
* test262/expectations.yaml: Mark 6 test cases as passing.

Source/_javascript_Core:

Define non-standard Error properties "line", "column", and "sourceURL" as non-enumerable to match other engines.

* runtime/ErrorInstance.cpp:
(JSC::ErrorInstance::materializeErrorInfoIfNeeded):

LayoutTests:

* inspector/debugger/resources/exception.js: Introduce `stringifyError` helper.
* inspector/debugger/setPauseOnExceptions-all.html:
* inspector/debugger/setPauseOnExceptions-none.html:
* inspector/debugger/setPauseOnExceptions-uncaught.html:
* js/exception-properties-expected.txt:
* js/script-tests/exception-properties.js:

Modified Paths

Diff

Modified: trunk/JSTests/ChakraCore/test/Error/NativeErrors_v4.baseline-jsc (250435 => 250436)


--- trunk/JSTests/ChakraCore/test/Error/NativeErrors_v4.baseline-jsc	2019-09-27 18:28:29 UTC (rev 250435)
+++ trunk/JSTests/ChakraCore/test/Error/NativeErrors_v4.baseline-jsc	2019-09-27 18:32:47 UTC (rev 250436)
@@ -1,7 +1,5 @@
 EvalError
-column         = (number)  14
 description    = (undefined)undefined
-line           = (number)  1
 number         = (undefined)undefined
 stack          = (string)  eval code
 eval@[native code]
@@ -10,9 +8,7 @@
 toString()     = EvalError
 
 RangeError('This is a range error')
-column         = (number)  15
 description    = (undefined)undefined
-line           = (number)  1
 number         = (undefined)undefined
 stack          = (string)  eval code
 eval@[native code]
@@ -21,9 +17,7 @@
 toString()     = RangeError: This is a range error
 
 ReferenceError
-column         = (number)  19
 description    = (undefined)undefined
-line           = (number)  1
 number         = (undefined)undefined
 stack          = (string)  eval code
 eval@[native code]
@@ -32,9 +26,7 @@
 toString()     = ReferenceError
 
 SyntaxError
-column         = (number)  16
 description    = (undefined)undefined
-line           = (number)  1
 number         = (undefined)undefined
 stack          = (string)  eval code
 eval@[native code]
@@ -43,9 +35,7 @@
 toString()     = SyntaxError
 
 TypeError('This is a type error')
-column         = (number)  14
 description    = (undefined)undefined
-line           = (number)  1
 number         = (undefined)undefined
 stack          = (string)  eval code
 eval@[native code]
@@ -54,9 +44,7 @@
 toString()     = TypeError: This is a type error
 
 URIError
-column         = (number)  13
 description    = (undefined)undefined
-line           = (number)  1
 number         = (undefined)undefined
 stack          = (string)  eval code
 eval@[native code]

Modified: trunk/JSTests/ChangeLog (250435 => 250436)


--- trunk/JSTests/ChangeLog	2019-09-27 18:28:29 UTC (rev 250435)
+++ trunk/JSTests/ChangeLog	2019-09-27 18:32:47 UTC (rev 250436)
@@ -1,3 +1,14 @@
+2019-09-27  Alexey Shvayka  <[email protected]>
+
+        Non-standard Error properties should not be enumerable
+        https://bugs.webkit.org/show_bug.cgi?id=198975
+
+        Reviewed by Ross Kirsling.
+
+        * ChakraCore/test/Error/NativeErrors_v4.baseline-jsc: Adjust expectations.
+        * microbenchmarks/let-for-in.js: Adjust test.
+        * test262/expectations.yaml: Mark 6 test cases as passing.
+
 2019-09-26  Yusuke Suzuki  <[email protected]>
 
         [JSC] DFG recursive-tail-call optimization should not emit jump to call-frame with varargs

Modified: trunk/JSTests/microbenchmarks/let-for-in.js (250435 => 250436)


--- trunk/JSTests/microbenchmarks/let-for-in.js	2019-09-27 18:28:29 UTC (rev 250435)
+++ trunk/JSTests/microbenchmarks/let-for-in.js	2019-09-27 18:32:47 UTC (rev 250436)
@@ -8,8 +8,14 @@
 }
 noInline(foo);
 
+function Bar() {
+    this.line = 1;
+    this.column = 2;
+    this.stack = "str";
+}
+
 var total = 0;
 for (let j = 0; j < 100000; ++j)
-    total += foo(new Error);
+    total += foo(new Bar);
 if (total != 300000)
     throw new Error("Bad result: " + total);

Modified: trunk/JSTests/test262/expectations.yaml (250435 => 250436)


--- trunk/JSTests/test262/expectations.yaml	2019-09-27 18:28:29 UTC (rev 250435)
+++ trunk/JSTests/test262/expectations.yaml	2019-09-27 18:32:47 UTC (rev 250436)
@@ -1212,15 +1212,6 @@
 test/built-ins/Number/proto-from-ctor-realm.js:
   default: 'Test262Error: Expected SameValue(«0», «0») to be true'
   strict mode: 'Test262Error: Expected SameValue(«0», «0») to be true'
-test/built-ins/Object/defineProperties/15.2.3.7-2-15.js:
-  default: 'TypeError: Property description must be an object.'
-  strict mode: 'TypeError: Property description must be an object.'
-test/built-ins/Object/defineProperties/15.2.3.7-5-a-16.js:
-  default: 'TypeError: Property description must be an object.'
-  strict mode: 'TypeError: Property description must be an object.'
-test/built-ins/Object/defineProperties/15.2.3.7-5-b-248.js:
-  default: 'TypeError: Property description must be an object.'
-  strict mode: 'TypeError: Property description must be an object.'
 test/built-ins/Object/internals/DefineOwnProperty/consistent-value-function-arguments.js:
   default: 'Test262Error: Expected SameValue(«null», «[object Arguments]») to be true'
 test/built-ins/Object/internals/DefineOwnProperty/consistent-value-function-caller.js:

Modified: trunk/LayoutTests/ChangeLog (250435 => 250436)


--- trunk/LayoutTests/ChangeLog	2019-09-27 18:28:29 UTC (rev 250435)
+++ trunk/LayoutTests/ChangeLog	2019-09-27 18:32:47 UTC (rev 250436)
@@ -1,3 +1,17 @@
+2019-09-27  Alexey Shvayka  <[email protected]>
+
+        Non-standard Error properties should not be enumerable
+        https://bugs.webkit.org/show_bug.cgi?id=198975
+
+        Reviewed by Ross Kirsling.
+
+        * inspector/debugger/resources/exception.js: Introduce `stringifyError` helper.
+        * inspector/debugger/setPauseOnExceptions-all.html:
+        * inspector/debugger/setPauseOnExceptions-none.html:
+        * inspector/debugger/setPauseOnExceptions-uncaught.html:
+        * js/exception-properties-expected.txt:
+        * js/script-tests/exception-properties.js:
+
 2019-09-27  Said Abou-Hallawa  <[email protected]>
 
         [iOS]: When inserting a photo and then inserting auto-corrected text, the photo is removed

Modified: trunk/LayoutTests/inspector/debugger/resources/exception.js (250435 => 250436)


--- trunk/LayoutTests/inspector/debugger/resources/exception.js	2019-09-27 18:28:29 UTC (rev 250435)
+++ trunk/LayoutTests/inspector/debugger/resources/exception.js	2019-09-27 18:32:47 UTC (rev 250436)
@@ -35,11 +35,23 @@
         try {
             func.apply(this, Array.prototype.slice.call(arguments, 2));
         } catch (e) {
-            console.log("catchNested caught exception: " + JSON.stringify(e));
+            console.log(`catchNested caught exception: ${stringifyError(e)}`);
         }
     }
 }
 
+function stringifyError(err)
+{
+    if (typeof err === "string")
+        return JSON.stringify(err);
+
+    return JSON.stringify({
+        line: err.line,
+        column: err.column,
+        sourceURL: err.sourceURL,
+    });
+}
+
 function noException()
 {
     return "no exception";

Modified: trunk/LayoutTests/inspector/debugger/setPauseOnExceptions-all.html (250435 => 250436)


--- trunk/LayoutTests/inspector/debugger/setPauseOnExceptions-all.html	2019-09-27 18:28:29 UTC (rev 250435)
+++ trunk/LayoutTests/inspector/debugger/setPauseOnExceptions-all.html	2019-09-27 18:32:47 UTC (rev 250436)
@@ -15,7 +15,7 @@
 
     var currentCaughtExceptionStatement = 0;
     var statementsWithCaughtExceptions = [
-        "try{ ({}).a.b.c.d } catch (e) { console.log('caught inline: ' + JSON.stringify(e)); }",
+        "try{ ({}).a.b.c.d } catch (e) { console.log(`caught inline: ${stringifyError(e)}`); }",
         "catchNested(exceptionBasic, 1);",
         "catchNested(exceptionDOM, 2);",
         "catchNested(exceptionInHostFunction, 3);",

Modified: trunk/LayoutTests/inspector/debugger/setPauseOnExceptions-none.html (250435 => 250436)


--- trunk/LayoutTests/inspector/debugger/setPauseOnExceptions-none.html	2019-09-27 18:28:29 UTC (rev 250435)
+++ trunk/LayoutTests/inspector/debugger/setPauseOnExceptions-none.html	2019-09-27 18:32:47 UTC (rev 250436)
@@ -13,7 +13,7 @@
         InspectorProtocol.sendCommand("Runtime.evaluate", {_expression_: "setTimeout(function() { 1+1; }, 0);"});
         InspectorProtocol.sendCommand("Runtime.evaluate", {_expression_: "setTimeout(function() { noException(); }, 0);"});
         InspectorProtocol.sendCommand("Runtime.evaluate", {_expression_: "setTimeout(function() { catchNested(noException, 7); }, 0);"});
-        InspectorProtocol.sendCommand("Runtime.evaluate", {_expression_: "setTimeout(function() { try{ ({}).a.b.c.d } catch (e) { console.log('caught inline: ' + JSON.stringify(e)); } }, 0);"});
+        InspectorProtocol.sendCommand("Runtime.evaluate", {_expression_: "setTimeout(function() { try{ ({}).a.b.c.d } catch (e) { console.log(`caught inline: ${stringifyError(e)}`); } }, 0);"});
         InspectorProtocol.sendCommand("Runtime.evaluate", {_expression_: "setTimeout(function() { catchNested(exceptionBasic, 1); }, 0);"});
         InspectorProtocol.sendCommand("Runtime.evaluate", {_expression_: "setTimeout(function() { catchNested(exceptionDOM, 2); }, 0);"});
         InspectorProtocol.sendCommand("Runtime.evaluate", {_expression_: "setTimeout(function() { catchNested(exceptionInHostFunction, 3); }, 0);"});

Modified: trunk/LayoutTests/inspector/debugger/setPauseOnExceptions-uncaught.html (250435 => 250436)


--- trunk/LayoutTests/inspector/debugger/setPauseOnExceptions-uncaught.html	2019-09-27 18:28:29 UTC (rev 250435)
+++ trunk/LayoutTests/inspector/debugger/setPauseOnExceptions-uncaught.html	2019-09-27 18:32:47 UTC (rev 250436)
@@ -14,7 +14,7 @@
     ];
 
     var statementsWithCaughtExceptions = [
-        "try{ ({}).a.b.c.d } catch (e) { console.log('caught inline: ' + JSON.stringify(e)); }",
+        "try{ ({}).a.b.c.d } catch (e) { console.log(`caught inline: ${stringifyError(e)}`); }",
         "catchNested(exceptionBasic, 1);",
         "catchNested(exceptionDOM, 2);",
         "catchNested(exceptionInHostFunction, 3);",

Modified: trunk/LayoutTests/js/exception-properties-expected.txt (250435 => 250436)


--- trunk/LayoutTests/js/exception-properties-expected.txt	2019-09-27 18:28:29 UTC (rev 250435)
+++ trunk/LayoutTests/js/exception-properties-expected.txt	2019-09-27 18:32:47 UTC (rev 250436)
@@ -3,8 +3,10 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS enumerableProperties(error).sort() is ["column", "line", "sourceURL"]
-PASS enumerableProperties(nativeError).sort() is ["column", "line", "sourceURL"]
+PASS Object.keys(error).sort() is []
+PASS Object.keys(nativeError).sort() is []
+PASS Object.getOwnPropertyNames(error).sort() is ["column", "line", "message", "sourceURL", "stack"]
+PASS Object.getOwnPropertyNames(nativeError).sort() is ["column", "line", "message", "sourceURL", "stack"]
 PASS Object.getPrototypeOf(nativeError).name is "RangeError"
 PASS Object.getPrototypeOf(nativeError).message is ""
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/js/script-tests/exception-properties.js (250435 => 250436)


--- trunk/LayoutTests/js/script-tests/exception-properties.js	2019-09-27 18:28:29 UTC (rev 250435)
+++ trunk/LayoutTests/js/script-tests/exception-properties.js	2019-09-27 18:32:47 UTC (rev 250436)
@@ -1,13 +1,5 @@
 description("Test for correct properties on Error objects.");
 
-function enumerableProperties(object)
-{
-    var result = [];
-    for (var i in object)
-        result.push(i);
-    return result;
-}
-
 try {
     // generate a RangeError.
     [].length = -1;
@@ -15,9 +7,12 @@
     var nativeError = rangeError;
     var error = new Error("message");
 
-    shouldBe('enumerableProperties(error).sort()', '["column", "line", "sourceURL"]');
-    shouldBe('enumerableProperties(nativeError).sort()', '["column", "line", "sourceURL"]');
+    shouldBe('Object.keys(error).sort()', '[]');
+    shouldBe('Object.keys(nativeError).sort()', '[]');
 
+    shouldBe('Object.getOwnPropertyNames(error).sort()', '["column", "line", "message", "sourceURL", "stack"]');
+    shouldBe('Object.getOwnPropertyNames(nativeError).sort()', '["column", "line", "message", "sourceURL", "stack"]');
+
     shouldBe('Object.getPrototypeOf(nativeError).name', '"RangeError"');
     shouldBe('Object.getPrototypeOf(nativeError).message', '""');
 }

Modified: trunk/Source/_javascript_Core/ChangeLog (250435 => 250436)


--- trunk/Source/_javascript_Core/ChangeLog	2019-09-27 18:28:29 UTC (rev 250435)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-09-27 18:32:47 UTC (rev 250436)
@@ -1,3 +1,15 @@
+2019-09-27  Alexey Shvayka  <[email protected]>
+
+        Non-standard Error properties should not be enumerable
+        https://bugs.webkit.org/show_bug.cgi?id=198975
+
+        Reviewed by Ross Kirsling.
+
+        Define non-standard Error properties "line", "column", and "sourceURL" as non-enumerable to match other engines.
+
+        * runtime/ErrorInstance.cpp:
+        (JSC::ErrorInstance::materializeErrorInfoIfNeeded):
+
 2019-09-26  Yusuke Suzuki  <[email protected]>
 
         [JSC] DFG recursive-tail-call optimization should not emit jump to call-frame with varargs

Modified: trunk/Source/_javascript_Core/runtime/ErrorInstance.cpp (250435 => 250436)


--- trunk/Source/_javascript_Core/runtime/ErrorInstance.cpp	2019-09-27 18:28:29 UTC (rev 250435)
+++ trunk/Source/_javascript_Core/runtime/ErrorInstance.cpp	2019-09-27 18:32:47 UTC (rev 250436)
@@ -238,12 +238,14 @@
     computeErrorInfo(vm);
 
     if (!m_stackString.isNull()) {
-        putDirect(vm, vm.propertyNames->line, jsNumber(m_line));
-        putDirect(vm, vm.propertyNames->column, jsNumber(m_column));
+        auto attributes = static_cast<unsigned>(PropertyAttribute::DontEnum);
+
+        putDirect(vm, vm.propertyNames->line, jsNumber(m_line), attributes);
+        putDirect(vm, vm.propertyNames->column, jsNumber(m_column), attributes);
         if (!m_sourceURL.isEmpty())
-            putDirect(vm, vm.propertyNames->sourceURL, jsString(vm, WTFMove(m_sourceURL)));
+            putDirect(vm, vm.propertyNames->sourceURL, jsString(vm, WTFMove(m_sourceURL)), attributes);
 
-        putDirect(vm, vm.propertyNames->stack, jsString(vm, WTFMove(m_stackString)), static_cast<unsigned>(PropertyAttribute::DontEnum));
+        putDirect(vm, vm.propertyNames->stack, jsString(vm, WTFMove(m_stackString)), attributes);
     }
 
     m_errorInfoMaterialized = true;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to