Title: [262872] trunk
Revision
262872
Author
[email protected]
Date
2020-06-10 16:15:43 -0700 (Wed, 10 Jun 2020)

Log Message

[JSC] JSCallbackObject::deleteProperty should redirect to Parent::deletePropertyByIndex if propertyName is index
https://bugs.webkit.org/show_bug.cgi?id=213041
<rdar://problem/64204300>

Reviewed by Darin Adler.

Source/_javascript_Core:

We have an infinite recursion here.

-> JSCallbackObject::deletePropertyByIndex
    -> JSCell::deleteProperty
        -> JSCallbackObject::deleteProperty
            -> JSObject::deleteProperty
                -> JSCallbackObject::deletePropertyByIndex

When propertyName in JSCallbackObject::deleteProperty is an index, we should go to JSObject::deletePropertyByIndex instead of JSObject::deleteProperty.

* API/JSCallbackObjectFunctions.h:
(JSC::JSCallbackObject<Parent>::deleteProperty):

LayoutTests:

* js/dom/callbackobject-delete-should-not-infinite-recursion-expected.txt: Added.
* js/dom/callbackobject-delete-should-not-infinite-recursion.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (262871 => 262872)


--- trunk/LayoutTests/ChangeLog	2020-06-10 23:14:18 UTC (rev 262871)
+++ trunk/LayoutTests/ChangeLog	2020-06-10 23:15:43 UTC (rev 262872)
@@ -1,3 +1,14 @@
+2020-06-10  Yusuke Suzuki  <[email protected]>
+
+        [JSC] JSCallbackObject::deleteProperty should redirect to Parent::deletePropertyByIndex if propertyName is index
+        https://bugs.webkit.org/show_bug.cgi?id=213041
+        <rdar://problem/64204300>
+
+        Reviewed by Darin Adler.
+
+        * js/dom/callbackobject-delete-should-not-infinite-recursion-expected.txt: Added.
+        * js/dom/callbackobject-delete-should-not-infinite-recursion.html: Added.
+
 2020-06-10  Zalan Bujtas  <[email protected]>
 
         [ Mac ] mathml/scripts-removeChild.html is flaky failing.

Added: trunk/LayoutTests/js/dom/callbackobject-delete-should-not-infinite-recursion-expected.txt (0 => 262872)


--- trunk/LayoutTests/js/dom/callbackobject-delete-should-not-infinite-recursion-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/dom/callbackobject-delete-should-not-infinite-recursion-expected.txt	2020-06-10 23:15:43 UTC (rev 262872)
@@ -0,0 +1,3 @@
+
+PASS JSCallbackObject::deleteProperty should not cause infinite recursion 
+

Added: trunk/LayoutTests/js/dom/callbackobject-delete-should-not-infinite-recursion.html (0 => 262872)


--- trunk/LayoutTests/js/dom/callbackobject-delete-should-not-infinite-recursion.html	                        (rev 0)
+++ trunk/LayoutTests/js/dom/callbackobject-delete-should-not-infinite-recursion.html	2020-06-10 23:15:43 UTC (rev 262872)
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <script src=""
+    <script src=""
+</head>
+<body>
+<script>
+test(() => {
+    delete testRunner[0];
+}, "JSCallbackObject::deleteProperty should not cause infinite recursion");
+</script>
+</body>

Modified: trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h (262871 => 262872)


--- trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h	2020-06-10 23:14:18 UTC (rev 262871)
+++ trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h	2020-06-10 23:15:43 UTC (rev 262872)
@@ -418,6 +418,9 @@
         }
     }
 
+    static_assert(std::is_final_v<JSCallbackObject<Parent>>, "Ensure no derived classes have custom deletePropertyByIndex implementation");
+    if (Optional<uint32_t> index = parseIndex(propertyName))
+        return Parent::deletePropertyByIndex(thisObject, globalObject, index.value());
     return Parent::deleteProperty(thisObject, globalObject, propertyName, slot);
 }
 

Modified: trunk/Source/_javascript_Core/ChangeLog (262871 => 262872)


--- trunk/Source/_javascript_Core/ChangeLog	2020-06-10 23:14:18 UTC (rev 262871)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-06-10 23:15:43 UTC (rev 262872)
@@ -1,3 +1,24 @@
+2020-06-10  Yusuke Suzuki  <[email protected]>
+
+        [JSC] JSCallbackObject::deleteProperty should redirect to Parent::deletePropertyByIndex if propertyName is index
+        https://bugs.webkit.org/show_bug.cgi?id=213041
+        <rdar://problem/64204300>
+
+        Reviewed by Darin Adler.
+
+        We have an infinite recursion here.
+
+        -> JSCallbackObject::deletePropertyByIndex
+            -> JSCell::deleteProperty
+                -> JSCallbackObject::deleteProperty
+                    -> JSObject::deleteProperty
+                        -> JSCallbackObject::deletePropertyByIndex
+
+        When propertyName in JSCallbackObject::deleteProperty is an index, we should go to JSObject::deletePropertyByIndex instead of JSObject::deleteProperty.
+
+        * API/JSCallbackObjectFunctions.h:
+        (JSC::JSCallbackObject<Parent>::deleteProperty):
+
 2020-06-09  Mark Lam  <[email protected]>
 
         Stringifier::appendStringifiedValue() should not assume it is always safe to recurse.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to