Title: [153679] trunk
Revision
153679
Author
[email protected]
Date
2013-08-02 17:04:41 -0700 (Fri, 02 Aug 2013)

Log Message

Give the error object's stack property accessor attributes.
https://bugs.webkit.org/show_bug.cgi?id=119404

Source/_javascript_Core:

Patch by Chris Curtis <[email protected]> on 2013-08-02
Reviewed by Geoffrey Garen.

Changed the attributes of error object's stack property to allow developers to write
and delete the stack property. This will match the functionality of Chrome. Firefox
allows developers to write the error's stack, but not delete it.

* interpreter/Interpreter.cpp:
(JSC::Interpreter::addStackTraceIfNecessary):
* runtime/ErrorInstance.cpp:
(JSC::ErrorInstance::finishCreation):

LayoutTests:

Patch by Chris Curtis <[email protected]> on 2013-08-02
Reviewed by Geoffrey Garen.

* fast/dom/DOMException/stack-trace-expected.txt:

New tests to show that the error object's stack property is writable and deleteable.
* fast/js/error-object-write-and-detele-for-stack-property-expected.txt: Added.
* fast/js/error-object-write-and-detele-for-stack-property.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (153678 => 153679)


--- trunk/LayoutTests/ChangeLog	2013-08-03 00:01:06 UTC (rev 153678)
+++ trunk/LayoutTests/ChangeLog	2013-08-03 00:04:41 UTC (rev 153679)
@@ -1,3 +1,16 @@
+2013-08-02  Chris Curtis  <[email protected]>
+
+        Give the error object's stack property accessor attributes.
+        https://bugs.webkit.org/show_bug.cgi?id=119404
+
+        Reviewed by Geoffrey Garen.
+
+        * fast/dom/DOMException/stack-trace-expected.txt:
+        
+        New tests to show that the error object's stack property is writable and deleteable.
+        * fast/js/error-object-write-and-detele-for-stack-property-expected.txt: Added.
+        * fast/js/error-object-write-and-detele-for-stack-property.html: Added.
+
 2013-08-02  Roger Fong  <[email protected]>
 
         Unreviewed. Skip failing canvas blending tests on AppleWin port.

Modified: trunk/LayoutTests/fast/dom/DOMException/stack-trace-expected.txt (153678 => 153679)


--- trunk/LayoutTests/fast/dom/DOMException/stack-trace-expected.txt	2013-08-03 00:01:06 UTC (rev 153678)
+++ trunk/LayoutTests/fast/dom/DOMException/stack-trace-expected.txt	2013-08-03 00:04:41 UTC (rev 153679)
@@ -6,7 +6,7 @@
 PASS e.name is "HierarchyRequestError"
 PASS e.message is "HierarchyRequestError: DOM Exception 3"
 PASS e.code is 3
-FAIL e.stack === 42 should be true. Was false.
+PASS e.stack === 42 is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Added: trunk/LayoutTests/fast/js/error-object-write-and-detele-for-stack-property-expected.txt (0 => 153679)


--- trunk/LayoutTests/fast/js/error-object-write-and-detele-for-stack-property-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/js/error-object-write-and-detele-for-stack-property-expected.txt	2013-08-03 00:04:41 UTC (rev 153679)
@@ -0,0 +1,9 @@
+This test verifies that the stack property able to be deleted and written to by the developer.
+
+Creating new Error e
+PASS  typeof(e.stack) == "string" is true
+Deleting the stack property should make it undefined.
+PASS e.stack is undefined.
+Writing to the stack property.
+PASS e.stack == "Brand new stack!" is true
+

Added: trunk/LayoutTests/fast/js/error-object-write-and-detele-for-stack-property.html (0 => 153679)


--- trunk/LayoutTests/fast/js/error-object-write-and-detele-for-stack-property.html	                        (rev 0)
+++ trunk/LayoutTests/fast/js/error-object-write-and-detele-for-stack-property.html	2013-08-03 00:04:41 UTC (rev 153679)
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<head>
+<script src=""
+</head>
+<body>
+    <p>This test verifies that the stack property able to be deleted and written to by the developer.</p>
+
+    <pre id="console"></pre>
+
+
+    <script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    function log(s)
+    {
+        document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
+    }
+
+    var e = new Error("hello");
+    var stack = e.stack; 
+    log("Creating new Error e");
+    shouldBeTrue(' typeof(e.stack) == "string"');
+
+    delete(e.stack);
+    log("Deleting the stack property should make it undefined.")
+    shouldBeUndefined('e.stack');
+
+    log("Writing to the stack property.");    
+    e.stack = "Brand new stack!";
+    shouldBeTrue('e.stack == "Brand new stack!"');    
+
+    successfullyParsed = true;
+    </script>
+</body>
\ No newline at end of file

Modified: trunk/Source/_javascript_Core/ChangeLog (153678 => 153679)


--- trunk/Source/_javascript_Core/ChangeLog	2013-08-03 00:01:06 UTC (rev 153678)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-08-03 00:04:41 UTC (rev 153679)
@@ -1,3 +1,19 @@
+2013-08-02  Chris Curtis  <[email protected]>
+
+        Give the error object's stack property accessor attributes.
+        https://bugs.webkit.org/show_bug.cgi?id=119404
+
+        Reviewed by Geoffrey Garen.
+        
+        Changed the attributes of error object's stack property to allow developers to write
+        and delete the stack property. This will match the functionality of Chrome. Firefox  
+        allows developers to write the error's stack, but not delete it. 
+
+        * interpreter/Interpreter.cpp:
+        (JSC::Interpreter::addStackTraceIfNecessary):
+        * runtime/ErrorInstance.cpp:
+        (JSC::ErrorInstance::finishCreation):
+
 2013-08-02  Oliver Hunt  <[email protected]>
 
         Incorrect type speculation reported by ToPrimitive

Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (153678 => 153679)


--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2013-08-03 00:01:06 UTC (rev 153678)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2013-08-03 00:04:41 UTC (rev 153679)
@@ -583,7 +583,7 @@
     if (asObject(error)->hasProperty(callFrame, vm->propertyNames->stack))
         return;
     
-    asObject(error)->putDirect(*vm, vm->propertyNames->stack, vm->interpreter->stackTraceAsString(vm->topCallFrame, stackTrace), ReadOnly | DontDelete);
+    asObject(error)->putDirect(*vm, vm->propertyNames->stack, vm->interpreter->stackTraceAsString(vm->topCallFrame, stackTrace), None);
 
 }
 

Modified: trunk/Source/_javascript_Core/runtime/ErrorInstance.cpp (153678 => 153679)


--- trunk/Source/_javascript_Core/runtime/ErrorInstance.cpp	2013-08-03 00:01:06 UTC (rev 153678)
+++ trunk/Source/_javascript_Core/runtime/ErrorInstance.cpp	2013-08-03 00:04:41 UTC (rev 153679)
@@ -44,7 +44,7 @@
         putDirect(vm, vm.propertyNames->message, jsString(&vm, message), DontEnum);
     
     if (!stackTrace.isEmpty())
-        putDirect(vm, vm.propertyNames->stack, vm.interpreter->stackTraceAsString(vm.topCallFrame, stackTrace), ReadOnly | DontDelete);
+        putDirect(vm, vm.propertyNames->stack, vm.interpreter->stackTraceAsString(vm.topCallFrame, stackTrace), None);
 }
     
 } // namespace JSC
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to