<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[183589] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/183589">183589</a></dd>
<dt>Author</dt> <dd>joepeck@webkit.org</dd>
<dt>Date</dt> <dd>2015-04-29 16:22:39 -0700 (Wed, 29 Apr 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>NodeList has issues with Symbol and empty string
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.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimePropertyNameh">trunk/Source/JavaScriptCore/runtime/PropertyName.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMBindingh">trunk/Source/WebCore/bindings/js/JSDOMBinding.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMStringMapCustomcpp">trunk/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSStorageCustomcpp">trunk/Source/WebCore/bindings/js/JSStorageCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSStyleSheetListCustomcpp">trunk/Source/WebCore/bindings/js/JSStyleSheetListCustom.cpp</a></li>
<li><a href="#trunkSourceWebCoredomStaticNodeListcpp">trunk/Source/WebCore/dom/StaticNodeList.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomStyleSheetstylesheetsymbolnamesexpectedtxt">trunk/LayoutTests/fast/dom/StyleSheet/stylesheet-symbol-names-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomStyleSheetstylesheetsymbolnameshtml">trunk/LayoutTests/fast/dom/StyleSheet/stylesheet-symbol-names.html</a></li>
<li><a href="#trunkLayoutTestsfastdomdatasetnamegettersymbolsexpectedtxt">trunk/LayoutTests/fast/dom/dataset-name-getter-symbols-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomdatasetnamegettersymbolshtml">trunk/LayoutTests/fast/dom/dataset-name-getter-symbols.html</a></li>
<li><a href="#trunkLayoutTestsfastdomnameditemswithemptynameexpectedtxt">trunk/LayoutTests/fast/dom/named-items-with-empty-name-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomnameditemswithemptynamehtml">trunk/LayoutTests/fast/dom/named-items-with-empty-name.html</a></li>
<li><a href="#trunkLayoutTestsfastdomnameditemswithsymbolnameexpectedtxt">trunk/LayoutTests/fast/dom/named-items-with-symbol-name-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomnameditemswithsymbolnamehtml">trunk/LayoutTests/fast/dom/named-items-with-symbol-name.html</a></li>
<li><a href="#trunkLayoutTestsstoragedomstoragelocalstoragenameditemsexpectedtxt">trunk/LayoutTests/storage/domstorage/localstorage/named-items-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstoragedomstoragelocalstoragenameditemshtml">trunk/LayoutTests/storage/domstorage/localstorage/named-items.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (183588 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-04-29 23:19:00 UTC (rev 183588)
+++ trunk/LayoutTests/ChangeLog        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+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.
+
</ins><span class="cx"> 2015-04-29 Simon Fraser <simon.fraser@apple.com>
</span><span class="cx">
</span><span class="cx"> Allow testing of plug-ins that handle wheel events.
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomStyleSheetstylesheetsymbolnamesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/StyleSheet/stylesheet-symbol-names-expected.txt (0 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/StyleSheet/stylesheet-symbol-names-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/dom/StyleSheet/stylesheet-symbol-names-expected.txt        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomStyleSheetstylesheetsymbolnameshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/StyleSheet/stylesheet-symbol-names.html (0 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/StyleSheet/stylesheet-symbol-names.html         (rev 0)
+++ trunk/LayoutTests/fast/dom/StyleSheet/stylesheet-symbol-names.html        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+<!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>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomdatasetnamegettersymbolsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/dataset-name-getter-symbols-expected.txt (0 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/dataset-name-getter-symbols-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/dom/dataset-name-getter-symbols-expected.txt        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomdatasetnamegettersymbolshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/dataset-name-getter-symbols.html (0 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/dataset-name-getter-symbols.html         (rev 0)
+++ trunk/LayoutTests/fast/dom/dataset-name-getter-symbols.html        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+<!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>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomnameditemswithemptynameexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/named-items-with-empty-name-expected.txt (0 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/named-items-with-empty-name-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/dom/named-items-with-empty-name-expected.txt        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomnameditemswithemptynamehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/named-items-with-empty-name.html (0 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/named-items-with-empty-name.html         (rev 0)
+++ trunk/LayoutTests/fast/dom/named-items-with-empty-name.html        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+<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>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomnameditemswithsymbolnameexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/named-items-with-symbol-name-expected.txt (0 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/named-items-with-symbol-name-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/dom/named-items-with-symbol-name-expected.txt        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomnameditemswithsymbolnamehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/named-items-with-symbol-name.html (0 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/named-items-with-symbol-name.html         (rev 0)
+++ trunk/LayoutTests/fast/dom/named-items-with-symbol-name.html        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+<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>
</ins></span></pre></div>
<a id="trunkLayoutTestsstoragedomstoragelocalstoragenameditemsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/domstorage/localstorage/named-items-expected.txt (0 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/domstorage/localstorage/named-items-expected.txt         (rev 0)
+++ trunk/LayoutTests/storage/domstorage/localstorage/named-items-expected.txt        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -0,0 +1,28 @@
</span><ins>+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestsstoragedomstoragelocalstoragenameditemshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/domstorage/localstorage/named-items.html (0 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/domstorage/localstorage/named-items.html         (rev 0)
+++ trunk/LayoutTests/storage/domstorage/localstorage/named-items.html        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+<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>
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (183588 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-04-29 23:19:00 UTC (rev 183588)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+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.
+
</ins><span class="cx"> 2015-04-29 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Fix non-cygwin incremental builds on Windows.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimePropertyNameh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/PropertyName.h (183588 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/PropertyName.h        2015-04-29 23:19:00 UTC (rev 183588)
+++ trunk/Source/JavaScriptCore/runtime/PropertyName.h        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -52,6 +52,11 @@
</span><span class="cx"> ASSERT(m_impl->isSymbol());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ bool isSymbol()
+ {
+ return m_impl && m_impl->isSymbol();
+ }
+
</ins><span class="cx"> AtomicStringImpl* uid() const
</span><span class="cx"> {
</span><span class="cx"> return m_impl;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (183588 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-04-29 23:19:00 UTC (rev 183588)
+++ trunk/Source/WebCore/ChangeLog        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -1,3 +1,49 @@
</span><ins>+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.
+
</ins><span class="cx"> 2015-04-29 Eric Carlson <eric.carlson@apple.com>
</span><span class="cx">
</span><span class="cx"> [Mac] Register with device picker whenever a page has <video>
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMBindingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (183588 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2015-04-29 23:19:00 UTC (rev 183588)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -567,12 +567,13 @@
</span><span class="cx">
</span><span class="cx"> inline String propertyNameToString(JSC::PropertyName propertyName)
</span><span class="cx"> {
</span><del>- return propertyName.publicName();
</del><ins>+ ASSERT(!propertyName.isSymbol());
+ return propertyName.uid() ? propertyName.uid() : propertyName.publicName();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> inline AtomicString propertyNameToAtomicString(JSC::PropertyName propertyName)
</span><span class="cx"> {
</span><del>- return AtomicString(propertyName.publicName());
</del><ins>+ return AtomicString(propertyName.uid() ? propertyName.uid() : propertyName.publicName());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template<typename DOMClass> inline const JSC::HashTableValue* getStaticValueSlotEntryWithoutCaching(JSC::ExecState* exec, JSC::PropertyName propertyName)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMStringMapCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp (183588 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp        2015-04-29 23:19:00 UTC (rev 183588)
+++ trunk/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -37,6 +37,8 @@
</span><span class="cx">
</span><span class="cx"> bool JSDOMStringMap::getOwnPropertySlotDelegate(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
</span><span class="cx"> {
</span><ins>+ if (propertyName.isSymbol())
+ return false;
</ins><span class="cx"> bool nameIsValid;
</span><span class="cx"> const AtomicString& item = impl().item(propertyNameToString(propertyName), nameIsValid);
</span><span class="cx"> if (nameIsValid) {
</span><span class="lines">@@ -58,9 +60,11 @@
</span><span class="cx"> Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool JSDOMStringMap::deleteProperty(JSCell* cell, ExecState*, PropertyName propertyName)
</del><ins>+bool JSDOMStringMap::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
</ins><span class="cx"> {
</span><span class="cx"> JSDOMStringMap* thisObject = jsCast<JSDOMStringMap*>(cell);
</span><ins>+ if (propertyName.isSymbol())
+ return Base::deleteProperty(thisObject, exec, propertyName);
</ins><span class="cx"> return thisObject->m_impl->deleteItem(propertyNameToString(propertyName));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -71,9 +75,13 @@
</span><span class="cx">
</span><span class="cx"> bool JSDOMStringMap::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot&)
</span><span class="cx"> {
</span><ins>+ if (propertyName.isSymbol())
+ return false;
+
</ins><span class="cx"> String stringValue = value.toString(exec)->value(exec);
</span><span class="cx"> if (exec->hadException())
</span><span class="cx"> return false;
</span><ins>+
</ins><span class="cx"> ExceptionCode ec = 0;
</span><span class="cx"> impl().setItem(propertyNameToString(propertyName), stringValue, ec);
</span><span class="cx"> setDOMException(exec, ec);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSStorageCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSStorageCustom.cpp (183588 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSStorageCustom.cpp        2015-04-29 23:19:00 UTC (rev 183588)
+++ trunk/Source/WebCore/bindings/js/JSStorageCustom.cpp        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -37,6 +37,9 @@
</span><span class="cx">
</span><span class="cx"> bool JSStorage::canGetItemsForName(ExecState* exec, Storage* impl, PropertyName propertyName)
</span><span class="cx"> {
</span><ins>+ if (propertyName.isSymbol())
+ return false;
+
</ins><span class="cx"> ExceptionCode ec = 0;
</span><span class="cx"> bool result = impl->contains(propertyNameToString(propertyName), ec);
</span><span class="cx"> setDOMException(exec, ec);
</span><span class="lines">@@ -51,6 +54,9 @@
</span><span class="cx"> if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot))
</span><span class="cx"> return JSValue::encode(slot.getValue(exec, propertyName));
</span><span class="cx">
</span><ins>+ if (propertyName.isSymbol())
+ return false;
+
</ins><span class="cx"> ExceptionCode ec = 0;
</span><span class="cx"> JSValue result = jsStringOrNull(exec, thisObject->impl().getItem(propertyNameToString(propertyName), ec));
</span><span class="cx"> setDOMException(exec, ec);
</span><span class="lines">@@ -65,12 +71,15 @@
</span><span class="cx"> // the native property slots manually.
</span><span class="cx"> PropertySlot slot(thisObject);
</span><span class="cx"> if (getStaticValueSlot<JSStorage, Base>(exec, *s_info.staticPropHashTable, thisObject, propertyName, slot))
</span><del>- return false;
-
</del><ins>+ return Base::deleteProperty(thisObject, exec, propertyName);
+
</ins><span class="cx"> JSValue prototype = thisObject->prototype();
</span><span class="cx"> if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot))
</span><del>- return false;
</del><ins>+ return Base::deleteProperty(thisObject, exec, propertyName);
</ins><span class="cx">
</span><ins>+ if (propertyName.isSymbol())
+ return Base::deleteProperty(thisObject, exec, propertyName);
+
</ins><span class="cx"> ExceptionCode ec = 0;
</span><span class="cx"> thisObject->m_impl->removeItem(propertyNameToString(propertyName), ec);
</span><span class="cx"> setDOMException(exec, ec);
</span><span class="lines">@@ -113,10 +122,13 @@
</span><span class="cx"> if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot))
</span><span class="cx"> return false;
</span><span class="cx">
</span><ins>+ if (propertyName.isSymbol())
+ return false;
+
</ins><span class="cx"> String stringValue = value.toString(exec)->value(exec);
</span><span class="cx"> if (exec->hadException())
</span><span class="cx"> return true;
</span><del>-
</del><ins>+
</ins><span class="cx"> ExceptionCode ec = 0;
</span><span class="cx"> impl().setItem(propertyNameToString(propertyName), stringValue, ec);
</span><span class="cx"> setDOMException(exec, ec);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSStyleSheetListCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSStyleSheetListCustom.cpp (183588 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSStyleSheetListCustom.cpp        2015-04-29 23:19:00 UTC (rev 183588)
+++ trunk/Source/WebCore/bindings/js/JSStyleSheetListCustom.cpp        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -37,6 +37,8 @@
</span><span class="cx">
</span><span class="cx"> bool JSStyleSheetList::canGetItemsForName(ExecState*, StyleSheetList* styleSheetList, PropertyName propertyName)
</span><span class="cx"> {
</span><ins>+ if (propertyName.isSymbol())
+ return false;
</ins><span class="cx"> return styleSheetList->getNamedItem(propertyNameToString(propertyName));
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoredomStaticNodeListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/StaticNodeList.cpp (183588 => 183589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/StaticNodeList.cpp        2015-04-29 23:19:00 UTC (rev 183588)
+++ trunk/Source/WebCore/dom/StaticNodeList.cpp        2015-04-29 23:22:39 UTC (rev 183589)
</span><span class="lines">@@ -45,6 +45,8 @@
</span><span class="cx">
</span><span class="cx"> Node* StaticNodeList::namedItem(const AtomicString& elementId) const
</span><span class="cx"> {
</span><ins>+ if (elementId.isEmpty())
+ return nullptr;
</ins><span class="cx"> for (unsigned i = 0, length = m_nodes.size(); i < length; ++i) {
</span><span class="cx"> Node& node = const_cast<Node&>(m_nodes[i].get());
</span><span class="cx"> if (is<Element>(node) && downcast<Element>(node).getIdAttribute() == elementId)
</span><span class="lines">@@ -67,6 +69,8 @@
</span><span class="cx">
</span><span class="cx"> Node* StaticElementList::namedItem(const AtomicString& elementId) const
</span><span class="cx"> {
</span><ins>+ if (elementId.isEmpty())
+ return nullptr;
</ins><span class="cx"> for (unsigned i = 0, length = m_elements.size(); i < length; ++i) {
</span><span class="cx"> Element& element = const_cast<Element&>(m_elements[i].get());
</span><span class="cx"> if (element.getIdAttribute() == elementId)
</span></span></pre>
</div>
</div>
</body>
</html>