2009-12-04 Kent Hansen <kent.hansen@nokia.com>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Dec 2009 01:21:45 +0000 (01:21 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Dec 2009 01:21:45 +0000 (01:21 +0000)
        Reviewed by Darin Adler.

        JavaScript delete operator should return false for string properties
        https://bugs.webkit.org/show_bug.cgi?id=32012

        * runtime/StringObject.cpp:
        (JSC::StringObject::deleteProperty):
2009-12-04  Kent Hansen  <kent.hansen@nokia.com>

        Reviewed by Darin Adler.

        Add test for JavaScript string property deletion
        https://bugs.webkit.org/show_bug.cgi?id=32012

        * fast/js/script-tests/string-property-deletion.js: Added.
        * fast/js/string-property-deletion-expected.txt: Added.
        * fast/js/string-property-deletion.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51724 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/runtime/StringObject.cpp
LayoutTests/ChangeLog
LayoutTests/fast/js/script-tests/string-property-deletion.js [new file with mode: 0644]
LayoutTests/fast/js/string-property-deletion-expected.txt [new file with mode: 0644]
LayoutTests/fast/js/string-property-deletion.html [new file with mode: 0644]

index 146709d08850b4710465c96cee8f828c7a852749..295eef3d3c911bab802833c7094c650fda813605 100644 (file)
@@ -1,3 +1,13 @@
+2009-12-04  Kent Hansen  <kent.hansen@nokia.com>
+
+        Reviewed by Darin Adler.
+
+        JavaScript delete operator should return false for string properties
+        https://bugs.webkit.org/show_bug.cgi?id=32012
+
+        * runtime/StringObject.cpp:
+        (JSC::StringObject::deleteProperty):
+
 2009-12-03  Drew Wilson  <atwilson@chromium.org>
 
         Rolled back r51633 because it causes a perf regression in Chromium.
 2009-12-03  Drew Wilson  <atwilson@chromium.org>
 
         Rolled back r51633 because it causes a perf regression in Chromium.
index 9455c364f8d6a37f78c457397523770772a32bb8..f23a20d76af2e7725d9da4ccb2e694b1761c2f20 100644 (file)
@@ -79,6 +79,10 @@ bool StringObject::deleteProperty(ExecState* exec, const Identifier& propertyNam
 {
     if (propertyName == exec->propertyNames().length)
         return false;
 {
     if (propertyName == exec->propertyNames().length)
         return false;
+    bool isStrictUInt32;
+    unsigned i = propertyName.toStrictUInt32(&isStrictUInt32);
+    if (isStrictUInt32 && internalValue()->canGetIndex(i))
+        return false;
     return JSObject::deleteProperty(exec, propertyName);
 }
 
     return JSObject::deleteProperty(exec, propertyName);
 }
 
index 55c6326630abb7ebca5fed737089bc9cf62bbddb..80a53c491c71b0f2e6a3bba66f071657887c064b 100644 (file)
@@ -1,3 +1,14 @@
+2009-12-04  Kent Hansen  <kent.hansen@nokia.com>
+
+        Reviewed by Darin Adler.
+
+        Add test for JavaScript string property deletion
+        https://bugs.webkit.org/show_bug.cgi?id=32012
+
+        * fast/js/script-tests/string-property-deletion.js: Added.
+        * fast/js/string-property-deletion-expected.txt: Added.
+        * fast/js/string-property-deletion.html: Added.
+
 2009-12-04  Yuzo Fujishima  <yuzo@google.com>
 
         Reviewed by Alexey Proskuryakov.
 2009-12-04  Yuzo Fujishima  <yuzo@google.com>
 
         Reviewed by Alexey Proskuryakov.
diff --git a/LayoutTests/fast/js/script-tests/string-property-deletion.js b/LayoutTests/fast/js/script-tests/string-property-deletion.js
new file mode 100644 (file)
index 0000000..98cecda
--- /dev/null
@@ -0,0 +1,19 @@
+description("This page tests deletion of properties on a string object.");
+
+var str = "abc";
+shouldBe('str.length', '3');
+shouldBe('delete str.length', 'false');
+shouldBe('delete str[0]', 'false');
+shouldBe('delete str[1]', 'false');
+shouldBe('delete str[2]', 'false');
+shouldBe('delete str[3]', 'true');
+shouldBe('delete str[-1]', 'true');
+shouldBe('delete str[4294967294]', 'true');
+shouldBe('delete str[4294967295]', 'true');
+shouldBe('delete str[4294967296]', 'true');
+shouldBe('delete str[0.0]', 'false');
+shouldBe('delete str[0.1]', 'true');
+shouldBe('delete str[\'0.0\']', 'true');
+shouldBe('delete str.foo', 'true');
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/js/string-property-deletion-expected.txt b/LayoutTests/fast/js/string-property-deletion-expected.txt
new file mode 100644 (file)
index 0000000..995d4f6
--- /dev/null
@@ -0,0 +1,23 @@
+This page tests deletion of properties on a string object.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS str.length is 3
+PASS delete str.length is false
+PASS delete str[0] is false
+PASS delete str[1] is false
+PASS delete str[2] is false
+PASS delete str[3] is true
+PASS delete str[-1] is true
+PASS delete str[4294967294] is true
+PASS delete str[4294967295] is true
+PASS delete str[4294967296] is true
+PASS delete str[0.0] is false
+PASS delete str[0.1] is true
+PASS delete str['0.0'] is true
+PASS delete str.foo is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/js/string-property-deletion.html b/LayoutTests/fast/js/string-property-deletion.html
new file mode 100644 (file)
index 0000000..b57d35c
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="resources/js-test-style.css">
+<script src="resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/string-property-deletion.js"></script>
+<script src="resources/js-test-post.js"></script>
+</body>
+</html>