NodeList has issues with Symbol and empty string
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Apr 2015 23:22:39 +0000 (23:22 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Apr 2015 23:22:39 +0000 (23:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144310

Reviewed by Darin Adler.

Source/JavaScriptCore:

* runtime/PropertyName.h:
(JSC::PropertyName::isSymbol):
Helper to check if the PropertyName is a string or symbol property.

Source/WebCore:

Tests: fast/dom/StyleSheet/stylesheet-symbol-names.html
       fast/dom/dataset-name-getter-symbols.html
       fast/dom/named-items-with-empty-name.html
       fast/dom/named-items-with-symbol-name.html
       storage/domstorage/localstorage/named-items.html

Test different bindings objects with custom named setter
and getter handlers. Ensure that they handle Symbol properties
gracefully. Often times avoiding the string path.

* dom/StaticNodeList.cpp:
(WebCore::StaticNodeList::namedItem):
(WebCore::StaticElementList::namedItem):
Better handle the empty string. It should not match an item.

* bindings/js/JSDOMBinding.h:
(WebCore::propertyNameToString):
In cases where we would use this, we should have handled
Symbol properties.

(WebCore::propertyNameToAtomicString):
For Symbols, use the unique string. This should result
in no matches for a Symbol property.

* bindings/js/JSDOMStringMapCustom.cpp:
(WebCore::JSDOMStringMap::getOwnPropertySlotDelegate):
(WebCore::JSDOMStringMap::deleteProperty):
(WebCore::JSDOMStringMap::putDelegate):
* bindings/js/JSStorageCustom.cpp:
(WebCore::JSStorage::canGetItemsForName):
(WebCore::JSStorage::nameGetter):
(WebCore::JSStorage::deleteProperty):
(WebCore::JSStorage::putDelegate):
* bindings/js/JSStyleSheetListCustom.cpp:
(WebCore::JSStyleSheetList::canGetItemsForName):
Treat Symbol properties as private properties. They just
go directly through to the Object, and avoid the string
getter/setter property path.

LayoutTests:

* fast/dom/StyleSheet/stylesheet-symbol-names-expected.txt: Added.
* fast/dom/StyleSheet/stylesheet-symbol-names.html: Added.
* fast/dom/dataset-name-getter-symbols-expected.txt: Added.
* fast/dom/dataset-name-getter-symbols.html: Added.
* fast/dom/named-items-with-empty-name-expected.txt: Added.
* fast/dom/named-items-with-empty-name.html: Added.
* fast/dom/named-items-with-symbol-name-expected.txt: Added.
* fast/dom/named-items-with-symbol-name.html: Added.
* storage/domstorage/localstorage/named-items-expected.txt: Added.
* storage/domstorage/localstorage/named-items.html: Added.

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

19 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/StyleSheet/stylesheet-symbol-names-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/StyleSheet/stylesheet-symbol-names.html [new file with mode: 0644]
LayoutTests/fast/dom/dataset-name-getter-symbols-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/dataset-name-getter-symbols.html [new file with mode: 0644]
LayoutTests/fast/dom/named-items-with-empty-name-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/named-items-with-empty-name.html [new file with mode: 0644]
LayoutTests/fast/dom/named-items-with-symbol-name-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/named-items-with-symbol-name.html [new file with mode: 0644]
LayoutTests/storage/domstorage/localstorage/named-items-expected.txt [new file with mode: 0644]
LayoutTests/storage/domstorage/localstorage/named-items.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/PropertyName.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp
Source/WebCore/bindings/js/JSStorageCustom.cpp
Source/WebCore/bindings/js/JSStyleSheetListCustom.cpp
Source/WebCore/dom/StaticNodeList.cpp

index fc4b589..23b40f8 100644 (file)
@@ -1,3 +1,21 @@
+2015-04-29  Joseph Pecoraro  <pecoraro@apple.com>
+
+        NodeList has issues with Symbol and empty string
+        https://bugs.webkit.org/show_bug.cgi?id=144310
+
+        Reviewed by Darin Adler.
+
+        * fast/dom/StyleSheet/stylesheet-symbol-names-expected.txt: Added.
+        * fast/dom/StyleSheet/stylesheet-symbol-names.html: Added.
+        * fast/dom/dataset-name-getter-symbols-expected.txt: Added.
+        * fast/dom/dataset-name-getter-symbols.html: Added.
+        * fast/dom/named-items-with-empty-name-expected.txt: Added.
+        * fast/dom/named-items-with-empty-name.html: Added.
+        * fast/dom/named-items-with-symbol-name-expected.txt: Added.
+        * fast/dom/named-items-with-symbol-name.html: Added.
+        * storage/domstorage/localstorage/named-items-expected.txt: Added.
+        * storage/domstorage/localstorage/named-items.html: Added.
+
 2015-04-29  Simon Fraser  <simon.fraser@apple.com>
 
         Allow testing of plug-ins that handle wheel events.
diff --git a/LayoutTests/fast/dom/StyleSheet/stylesheet-symbol-names-expected.txt b/LayoutTests/fast/dom/StyleSheet/stylesheet-symbol-names-expected.txt
new file mode 100644 (file)
index 0000000..5616524
--- /dev/null
@@ -0,0 +1,16 @@
+This tests document.styelSheets with Symbol property names.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.styleSheets.length is 3
+PASS document.styleSheets[''] is undefined
+PASS document.styleSheets['test'] is styleElement2.sheet
+PASS document.styleSheets[Symbol()] is undefined
+PASS delete document.styleSheets['test'] did not throw exception.
+PASS delete document.styleSheets[Symbol()] did not throw exception.
+PASS document.styleSheets.length is 3
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/StyleSheet/stylesheet-symbol-names.html b/LayoutTests/fast/dom/StyleSheet/stylesheet-symbol-names.html
new file mode 100644 (file)
index 0000000..52ba768
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("This tests document.styelSheets with Symbol property names.");
+
+styleElement1 = document.createElement("style");
+styleElement1.setAttribute("id", "");
+document.head.appendChild(styleElement1);
+
+styleElement2 = document.createElement("style");
+styleElement2.setAttribute("id", "test");
+document.head.appendChild(styleElement2);
+
+shouldBe("document.styleSheets.length", "3");
+shouldBe("document.styleSheets['']", "undefined");
+shouldBe("document.styleSheets['test']", "styleElement2.sheet");
+shouldBe("document.styleSheets[Symbol()]", "undefined");
+shouldNotThrow("delete document.styleSheets['test']");
+shouldNotThrow("delete document.styleSheets[Symbol()]");
+shouldBe("document.styleSheets.length", "3");
+
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/dataset-name-getter-symbols-expected.txt b/LayoutTests/fast/dom/dataset-name-getter-symbols-expected.txt
new file mode 100644 (file)
index 0000000..b112e3e
--- /dev/null
@@ -0,0 +1,22 @@
+Test the name getters on DOMStringMap (dataset).
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.body.dataset.webkitRocks === 'yes' is true
+PASS Object.keys(document.body.dataset).length === 1 is true
+PASS document.body.dataset[''] = 'test' did not throw exception.
+PASS document.body.dataset[''] === 'test' is true
+PASS document.body.dataset[Symbol()] === undefined is true
+PASS Object.keys(document.body.dataset).length === 2 is true
+PASS document.body.dataset[knownSymbol] === undefined is true
+PASS Object.keys(document.body.dataset).length === 2 is true
+PASS document.body.dataset[knownSymbol] = 'symbol property' did not throw exception.
+PASS document.body.dataset[knownSymbol] === 'symbol property' is true
+PASS delete document.body.dataset[knownSymbol] is true
+PASS document.body.dataset[knownSymbol] === undefined is true
+PASS Object.keys(document.body.dataset).length === 2 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/dataset-name-getter-symbols.html b/LayoutTests/fast/dom/dataset-name-getter-symbols.html
new file mode 100644 (file)
index 0000000..0d220a2
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body data-webkit-rocks=yes>
+<script>
+description('Test the name getters on DOMStringMap (dataset).');
+
+knownSymbol = Symbol();
+
+shouldBeTrue("document.body.dataset.webkitRocks === 'yes'");
+shouldBeTrue("Object.keys(document.body.dataset).length === 1");
+
+shouldNotThrow("document.body.dataset[''] = 'test'");
+shouldBeTrue("document.body.dataset[''] === 'test'");
+shouldBeTrue("document.body.dataset[Symbol()] === undefined");
+shouldBeTrue("Object.keys(document.body.dataset).length === 2");
+
+shouldBeTrue("document.body.dataset[knownSymbol] === undefined");
+shouldBeTrue("Object.keys(document.body.dataset).length === 2");
+shouldNotThrow("document.body.dataset[knownSymbol] = 'symbol property'");
+shouldBeTrue("document.body.dataset[knownSymbol] === 'symbol property'");
+shouldBeTrue("delete document.body.dataset[knownSymbol]");
+shouldBeTrue("document.body.dataset[knownSymbol] === undefined");
+shouldBeTrue("Object.keys(document.body.dataset).length === 2");
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/named-items-with-empty-name-expected.txt b/LayoutTests/fast/dom/named-items-with-empty-name-expected.txt
new file mode 100644 (file)
index 0000000..f702be3
--- /dev/null
@@ -0,0 +1,10 @@
+This tests empty strings do not return a value in collections or named items cases.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.querySelectorAll('div')[''] === undefined is true
+PASS document.getElementsByTagName('div')[''] === undefined is true
+PASS document.body.children[''] === undefined is true
+PASS document.all[''] === undefined is true
+
diff --git a/LayoutTests/fast/dom/named-items-with-empty-name.html b/LayoutTests/fast/dom/named-items-with-empty-name.html
new file mode 100644 (file)
index 0000000..e17490f
--- /dev/null
@@ -0,0 +1,20 @@
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<div id=""></div>
+    
+<script>
+description('This tests empty strings do not return a value in collections or named items cases.');
+
+shouldBeTrue("document.querySelectorAll('div')[''] === undefined");
+shouldBeTrue("document.getElementsByTagName('div')[''] === undefined");
+shouldBeTrue("document.body.children[''] === undefined");
+shouldBeTrue("document.all[''] === undefined");
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/named-items-with-symbol-name-expected.txt b/LayoutTests/fast/dom/named-items-with-symbol-name-expected.txt
new file mode 100644 (file)
index 0000000..17295b8
--- /dev/null
@@ -0,0 +1,42 @@
+This tests Symbol property names with a number of named items collections.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+[object NodeList]
+PASS querySelectorAllList.length === 4 is true
+PASS querySelectorAllList[Symbol()] === undefined is true
+PASS querySelectorAllList[Symbol('div')] === undefined is true
+PASS querySelectorAllList['Symbol(div)'] instanceof HTMLDivElement is true
+
+[object NodeList]
+PASS getElementsByTagNameList.length === 4 is true
+PASS getElementsByTagNameList[Symbol()] === undefined is true
+PASS getElementsByTagNameList[Symbol('div')] === undefined is true
+PASS getElementsByTagNameList['Symbol(div)'] instanceof HTMLDivElement is true
+
+[object Window]
+PASS window[Symbol()] === undefined is true
+PASS window[Symbol('div')] === undefined is true
+PASS window['Symbol(div)'] instanceof HTMLDivElement is true
+
+[object HTMLCollection]
+PASS document.images.length === 3 is true
+PASS document.images[Symbol()] === undefined is true
+PASS document.images[Symbol('img')] === undefined is true
+PASS document.images['Symbol(img)'] instanceof HTMLImageElement is true
+
+[object HTMLAllCollection]
+PASS document.all.length > 10 is true
+PASS document.all[Symbol()] === undefined is true
+PASS document.all[Symbol('div')] === undefined is true
+PASS document.all['Symbol(div)'] instanceof HTMLDivElement is true
+
+[object HTMLCollection]
+PASS document.forms[Symbol()] === undefined is true
+
+[object HTMLFormElement]
+PASS document.forms[0][Symbol()] === undefined is true
+PASS document.forms[0][Symbol('input')] === undefined is true
+PASS document.forms[0]['Symbol(input)'] instanceof HTMLInputElement is true
+
diff --git a/LayoutTests/fast/dom/named-items-with-symbol-name.html b/LayoutTests/fast/dom/named-items-with-symbol-name.html
new file mode 100644 (file)
index 0000000..7210103
--- /dev/null
@@ -0,0 +1,59 @@
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<div style="display:none">
+    <div>text1</div><div id='Symbol(div)'>text2</div>
+    <img><img id="img"><img id="Symbol(img)">
+    <form><input><input name="input"><input name="Symbol(input)"></form>
+</div>
+    
+<script>
+description('This tests Symbol property names with a number of named items collections.');
+
+var querySelectorAllList = document.querySelectorAll('div');
+debug(String(querySelectorAllList));
+shouldBeTrue("querySelectorAllList.length === 4");
+shouldBeTrue("querySelectorAllList[Symbol()] === undefined");
+shouldBeTrue("querySelectorAllList[Symbol('div')] === undefined");
+shouldBeTrue("querySelectorAllList['Symbol(div)'] instanceof HTMLDivElement");
+
+var getElementsByTagNameList = document.getElementsByTagName('div');
+debug("\n" + String(getElementsByTagNameList));
+shouldBeTrue("getElementsByTagNameList.length === 4");
+shouldBeTrue("getElementsByTagNameList[Symbol()] === undefined");
+shouldBeTrue("getElementsByTagNameList[Symbol('div')] === undefined");
+shouldBeTrue("getElementsByTagNameList['Symbol(div)'] instanceof HTMLDivElement");
+
+debug("\n" + String(window));
+shouldBeTrue("window[Symbol()] === undefined");
+shouldBeTrue("window[Symbol('div')] === undefined");
+shouldBeTrue("window['Symbol(div)'] instanceof HTMLDivElement");
+
+debug("\n" + String(document.images));
+shouldBeTrue("document.images.length === 3");
+shouldBeTrue("document.images[Symbol()] === undefined");
+shouldBeTrue("document.images[Symbol('img')] === undefined");
+shouldBeTrue("document.images['Symbol(img)'] instanceof HTMLImageElement");
+
+debug("\n" + String(document.all));
+shouldBeTrue("document.all.length > 10");
+shouldBeTrue("document.all[Symbol()] === undefined");
+shouldBeTrue("document.all[Symbol('div')] === undefined");
+shouldBeTrue("document.all['Symbol(div)'] instanceof HTMLDivElement");
+
+debug("\n" + String(document.forms));
+shouldBeTrue("document.forms[Symbol()] === undefined");
+
+debug("\n" + String(document.forms[0]));
+shouldBeTrue("document.forms[0][Symbol()] === undefined");
+shouldBeTrue("document.forms[0][Symbol('input')] === undefined");
+shouldBeTrue("document.forms[0]['Symbol(input)'] instanceof HTMLInputElement");
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/storage/domstorage/localstorage/named-items-expected.txt b/LayoutTests/storage/domstorage/localstorage/named-items-expected.txt
new file mode 100644 (file)
index 0000000..c071f44
--- /dev/null
@@ -0,0 +1,28 @@
+Tests storage with named item access and Symbol properties.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS localStorage.length === 0 is true
+PASS localStorage[Symbol()] === undefined is true
+PASS localStorage.length === 0 is true
+PASS localStorage[knownSymbol] === 2 is true
+PASS delete localStorage[knownSymbol] did not throw exception.
+PASS localStorage.length === 0 is true
+PASS localStorage[knownSymbol] === undefined is true
+PASS localStorage.length === 1 is true
+PASS localStorage['Symbol()'] === '3' is true
+PASS localStorage.key(0) === 'Symbol()' is true
+PASS localStorage[''] === undefined is true
+PASS localStorage[''] === '4' is true
+PASS localStorage.length === 2 is true
+PASS delete localStorage['Symbol()'] did not throw exception.
+PASS localStorage.length === 1 is true
+PASS localStorage['Symbol()'] === undefined is true
+PASS delete localStorage[''] did not throw exception.
+PASS localStorage.length === 0 is true
+PASS localStorage[''] === undefined is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/storage/domstorage/localstorage/named-items.html b/LayoutTests/storage/domstorage/localstorage/named-items.html
new file mode 100644 (file)
index 0000000..70c7f28
--- /dev/null
@@ -0,0 +1,43 @@
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Tests storage with named item access and Symbol properties.");
+
+knownSymbol = Symbol();
+localStorage.clear();
+
+localStorage[Symbol()] = 1;
+shouldBeTrue("localStorage.length === 0");
+shouldBeTrue("localStorage[Symbol()] === undefined");
+
+localStorage[knownSymbol] = 2;
+shouldBeTrue("localStorage.length === 0");
+shouldBeTrue("localStorage[knownSymbol] === 2"); // number
+shouldNotThrow("delete localStorage[knownSymbol]");
+shouldBeTrue("localStorage.length === 0");
+shouldBeTrue("localStorage[knownSymbol] === undefined");
+
+localStorage["Symbol()"] = 3;
+shouldBeTrue("localStorage.length === 1");
+shouldBeTrue("localStorage['Symbol()'] === '3'"); // string
+shouldBeTrue("localStorage.key(0) === 'Symbol()'");
+
+shouldBeTrue("localStorage[''] === undefined");
+localStorage[''] = 4;
+shouldBeTrue("localStorage[''] === '4'"); // string
+shouldBeTrue("localStorage.length === 2");
+
+shouldNotThrow("delete localStorage['Symbol()']");
+shouldBeTrue("localStorage.length === 1");
+shouldBeTrue("localStorage['Symbol()'] === undefined"); // string
+
+shouldNotThrow("delete localStorage['']");
+shouldBeTrue("localStorage.length === 0");
+shouldBeTrue("localStorage[''] === undefined"); // string
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
index c1750c2..17f2080 100644 (file)
@@ -1,3 +1,14 @@
+2015-04-29  Joseph Pecoraro  <pecoraro@apple.com>
+
+        NodeList has issues with Symbol and empty string
+        https://bugs.webkit.org/show_bug.cgi?id=144310
+
+        Reviewed by Darin Adler.
+
+        * runtime/PropertyName.h:
+        (JSC::PropertyName::isSymbol):
+        Helper to check if the PropertyName is a string or symbol property.
+
 2015-04-29  Alex Christensen  <achristensen@webkit.org>
 
         Fix non-cygwin incremental builds on Windows.
index 7424229..4f2ca87 100644 (file)
@@ -52,6 +52,11 @@ public:
         ASSERT(m_impl->isSymbol());
     }
 
+    bool isSymbol()
+    {
+        return m_impl && m_impl->isSymbol();
+    }
+
     AtomicStringImpl* uid() const
     {
         return m_impl;
index 8092430..7b5a81d 100644 (file)
@@ -1,3 +1,49 @@
+2015-04-29  Joseph Pecoraro  <pecoraro@apple.com>
+
+        NodeList has issues with Symbol and empty string
+        https://bugs.webkit.org/show_bug.cgi?id=144310
+
+        Reviewed by Darin Adler.
+
+        Tests: fast/dom/StyleSheet/stylesheet-symbol-names.html
+               fast/dom/dataset-name-getter-symbols.html
+               fast/dom/named-items-with-empty-name.html
+               fast/dom/named-items-with-symbol-name.html
+               storage/domstorage/localstorage/named-items.html
+
+        Test different bindings objects with custom named setter
+        and getter handlers. Ensure that they handle Symbol properties
+        gracefully. Often times avoiding the string path.
+
+        * dom/StaticNodeList.cpp:
+        (WebCore::StaticNodeList::namedItem):
+        (WebCore::StaticElementList::namedItem):
+        Better handle the empty string. It should not match an item.
+
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::propertyNameToString):
+        In cases where we would use this, we should have handled
+        Symbol properties.
+
+        (WebCore::propertyNameToAtomicString):
+        For Symbols, use the unique string. This should result
+        in no matches for a Symbol property.
+
+        * bindings/js/JSDOMStringMapCustom.cpp:
+        (WebCore::JSDOMStringMap::getOwnPropertySlotDelegate):
+        (WebCore::JSDOMStringMap::deleteProperty):
+        (WebCore::JSDOMStringMap::putDelegate):
+        * bindings/js/JSStorageCustom.cpp:
+        (WebCore::JSStorage::canGetItemsForName):
+        (WebCore::JSStorage::nameGetter):
+        (WebCore::JSStorage::deleteProperty):
+        (WebCore::JSStorage::putDelegate):
+        * bindings/js/JSStyleSheetListCustom.cpp:
+        (WebCore::JSStyleSheetList::canGetItemsForName):
+        Treat Symbol properties as private properties. They just
+        go directly through to the Object, and avoid the string
+        getter/setter property path.
+
 2015-04-29  Eric Carlson  <eric.carlson@apple.com>
 
         [Mac] Register with device picker whenever a page has <video>
index 1e0c8fd..c7f71ba 100644 (file)
@@ -567,12 +567,13 @@ JSC::EncodedJSValue objectToStringFunctionGetter(JSC::ExecState*, JSC::JSObject*
 
 inline String propertyNameToString(JSC::PropertyName propertyName)
 {
-    return propertyName.publicName();
+    ASSERT(!propertyName.isSymbol());
+    return propertyName.uid() ? propertyName.uid() : propertyName.publicName();
 }
 
 inline AtomicString propertyNameToAtomicString(JSC::PropertyName propertyName)
 {
-    return AtomicString(propertyName.publicName());
+    return AtomicString(propertyName.uid() ? propertyName.uid() : propertyName.publicName());
 }
 
 template<typename DOMClass> inline const JSC::HashTableValue* getStaticValueSlotEntryWithoutCaching(JSC::ExecState* exec, JSC::PropertyName propertyName)
index 52598ce..88dc56d 100644 (file)
@@ -37,6 +37,8 @@ namespace WebCore {
 
 bool JSDOMStringMap::getOwnPropertySlotDelegate(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
 {
+    if (propertyName.isSymbol())
+        return false;
     bool nameIsValid;
     const AtomicString& item = impl().item(propertyNameToString(propertyName), nameIsValid);
     if (nameIsValid) {
@@ -58,9 +60,11 @@ void JSDOMStringMap::getOwnPropertyNames(JSObject* object, ExecState* exec, Prop
     Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
 }
 
-bool JSDOMStringMap::deleteProperty(JSCell* cell, ExecState*, PropertyName propertyName)
+bool JSDOMStringMap::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
 {
     JSDOMStringMap* thisObject = jsCast<JSDOMStringMap*>(cell);
+    if (propertyName.isSymbol())
+        return Base::deleteProperty(thisObject, exec, propertyName);
     return thisObject->m_impl->deleteItem(propertyNameToString(propertyName));
 }
 
@@ -71,9 +75,13 @@ bool JSDOMStringMap::deletePropertyByIndex(JSCell* cell, ExecState* exec, unsign
 
 bool JSDOMStringMap::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot&)
 {
+    if (propertyName.isSymbol())
+        return false;
+
     String stringValue = value.toString(exec)->value(exec);
     if (exec->hadException())
         return false;
+
     ExceptionCode ec = 0;
     impl().setItem(propertyNameToString(propertyName), stringValue, ec);
     setDOMException(exec, ec);
index d64603e..e651340 100644 (file)
@@ -37,6 +37,9 @@ namespace WebCore {
 
 bool JSStorage::canGetItemsForName(ExecState* exec, Storage* impl, PropertyName propertyName)
 {
+    if (propertyName.isSymbol())
+        return false;
+
     ExceptionCode ec = 0;
     bool result = impl->contains(propertyNameToString(propertyName), ec);
     setDOMException(exec, ec);
@@ -51,6 +54,9 @@ EncodedJSValue JSStorage::nameGetter(ExecState* exec, JSObject* slotBase, Encode
     if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot))
         return JSValue::encode(slot.getValue(exec, propertyName));
 
+    if (propertyName.isSymbol())
+        return false;
+
     ExceptionCode ec = 0;
     JSValue result = jsStringOrNull(exec, thisObject->impl().getItem(propertyNameToString(propertyName), ec));
     setDOMException(exec, ec);
@@ -65,11 +71,14 @@ bool JSStorage::deleteProperty(JSCell* cell, ExecState* exec, PropertyName prope
     // the native property slots manually.
     PropertySlot slot(thisObject);
     if (getStaticValueSlot<JSStorage, Base>(exec, *s_info.staticPropHashTable, thisObject, propertyName, slot))
-        return false;
-        
+        return Base::deleteProperty(thisObject, exec, propertyName);
+
     JSValue prototype = thisObject->prototype();
     if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot))
-        return false;
+        return Base::deleteProperty(thisObject, exec, propertyName);
+
+    if (propertyName.isSymbol())
+        return Base::deleteProperty(thisObject, exec, propertyName);
 
     ExceptionCode ec = 0;
     thisObject->m_impl->removeItem(propertyNameToString(propertyName), ec);
@@ -113,10 +122,13 @@ bool JSStorage::putDelegate(ExecState* exec, PropertyName propertyName, JSValue
     if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot))
         return false;
 
+    if (propertyName.isSymbol())
+        return false;
+
     String stringValue = value.toString(exec)->value(exec);
     if (exec->hadException())
         return true;
-    
+
     ExceptionCode ec = 0;
     impl().setItem(propertyNameToString(propertyName), stringValue, ec);
     setDOMException(exec, ec);
index c5eda33..8d9b94a 100644 (file)
@@ -37,6 +37,8 @@ namespace WebCore {
 
 bool JSStyleSheetList::canGetItemsForName(ExecState*, StyleSheetList* styleSheetList, PropertyName propertyName)
 {
+    if (propertyName.isSymbol())
+        return false;
     return styleSheetList->getNamedItem(propertyNameToString(propertyName));
 }
 
index dd70ee9..5f0233b 100644 (file)
@@ -45,6 +45,8 @@ Node* StaticNodeList::item(unsigned index) const
 
 Node* StaticNodeList::namedItem(const AtomicString& elementId) const
 {
+    if (elementId.isEmpty())
+        return nullptr;
     for (unsigned i = 0, length = m_nodes.size(); i < length; ++i) {
         Node& node = const_cast<Node&>(m_nodes[i].get());
         if (is<Element>(node) && downcast<Element>(node).getIdAttribute() == elementId)
@@ -67,6 +69,8 @@ Node* StaticElementList::item(unsigned index) const
 
 Node* StaticElementList::namedItem(const AtomicString& elementId) const
 {
+    if (elementId.isEmpty())
+        return nullptr;
     for (unsigned i = 0, length = m_elements.size(); i < length; ++i) {
         Element& element = const_cast<Element&>(m_elements[i].get());
         if (element.getIdAttribute() == elementId)