<!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>[172707] 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/172707">172707</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-08-18 10:08:22 -0700 (Mon, 18 Aug 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Completed iterator can be revived by adding more than one new entry to the target object
https://bugs.webkit.org/show_bug.cgi?id=129993

Patch by Diego Pino Garcia &lt;dpino@igalia.com&gt; on 2014-08-18
Reviewed by Oliver Hunt.

Source/JavaScriptCore:

When iterator reaches end, finish iterator.

* runtime/JSMapIterator.h:
(JSC::JSMapIterator::finish):
* runtime/JSSetIterator.h:
(JSC::JSSetIterator::finish):
* runtime/MapData.h:
(JSC::MapData::const_iterator::finish): set index of iterator to max
Int32.
* runtime/MapIteratorPrototype.cpp:
(JSC::MapIteratorPrototypeFuncNext):
* runtime/SetIteratorPrototype.cpp:
(JSC::SetIteratorPrototypeFuncNext):

LayoutTests:

Test a Map or Set iterator should remain dead after using it.

* js/basic-map-expected.txt:
* js/basic-set-expected.txt:
* js/script-tests/basic-map.js:
(set var):
(set map):
* js/script-tests/basic-set.js:
(keys.set keys):
(set add.set add):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsbasicmapexpectedtxt">trunk/LayoutTests/js/basic-map-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsbasicsetexpectedtxt">trunk/LayoutTests/js/basic-set-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsbasicmapjs">trunk/LayoutTests/js/script-tests/basic-map.js</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsbasicsetjs">trunk/LayoutTests/js/script-tests/basic-set.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSMapIteratorh">trunk/Source/JavaScriptCore/runtime/JSMapIterator.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSSetIteratorh">trunk/Source/JavaScriptCore/runtime/JSSetIterator.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeMapDatah">trunk/Source/JavaScriptCore/runtime/MapData.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeMapIteratorPrototypecpp">trunk/Source/JavaScriptCore/runtime/MapIteratorPrototype.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeSetIteratorPrototypecpp">trunk/Source/JavaScriptCore/runtime/SetIteratorPrototype.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (172706 => 172707)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-08-18 17:02:13 UTC (rev 172706)
+++ trunk/LayoutTests/ChangeLog        2014-08-18 17:08:22 UTC (rev 172707)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2014-08-18  Diego Pino Garcia  &lt;dpino@igalia.com&gt;
+
+        Completed iterator can be revived by adding more than one new entry to the target object
+        https://bugs.webkit.org/show_bug.cgi?id=129993
+
+        Reviewed by Oliver Hunt.
+
+        Test a Map or Set iterator should remain dead after using it.
+
+        * js/basic-map-expected.txt:
+        * js/basic-set-expected.txt: 
+        * js/script-tests/basic-map.js: 
+        (set var):
+        (set map):
+        * js/script-tests/basic-set.js:
+        (keys.set keys):
+        (set add.set add):
+
</ins><span class="cx"> 2014-08-18  Renata Hodovan  &lt;rhodovan.u-szeged@partner.samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix keyTimes list length of from/to/by animations.
</span></span></pre></div>
<a id="trunkLayoutTestsjsbasicmapexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/basic-map-expected.txt (172706 => 172707)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/basic-map-expected.txt        2014-08-18 17:02:13 UTC (rev 172706)
+++ trunk/LayoutTests/js/basic-map-expected.txt        2014-08-18 17:08:22 UTC (rev 172707)
</span><span class="lines">@@ -222,6 +222,10 @@
</span><span class="cx"> PASS value is 14
</span><span class="cx"> PASS i is 5
</span><span class="cx"> PASS map.size is 4
</span><ins>+A dead iterator should remain dead
+PASS count is 0
+PASS count is 3
+PASS count is 3
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsjsbasicsetexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/basic-set-expected.txt (172706 => 172707)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/basic-set-expected.txt        2014-08-18 17:02:13 UTC (rev 172706)
+++ trunk/LayoutTests/js/basic-set-expected.txt        2014-08-18 17:08:22 UTC (rev 172707)
</span><span class="lines">@@ -193,6 +193,10 @@
</span><span class="cx"> PASS key is 7
</span><span class="cx"> PASS i is 5
</span><span class="cx"> PASS set.size is 4
</span><ins>+A dead iterator should remain dead
+PASS count is 0
+PASS count is 3
+PASS count is 3
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsbasicmapjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/basic-map.js (172706 => 172707)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/basic-map.js        2014-08-18 17:02:13 UTC (rev 172706)
+++ trunk/LayoutTests/js/script-tests/basic-map.js        2014-08-18 17:08:22 UTC (rev 172707)
</span><span class="lines">@@ -246,3 +246,35 @@
</span><span class="cx"> shouldBe(&quot;i&quot;, &quot;5&quot;)
</span><span class="cx"> shouldBe(&quot;map.size&quot;, &quot;4&quot;);
</span><span class="cx"> 
</span><ins>+debug(&quot;A dead iterator should remain dead&quot;)
+
+var map = new Map;
+map.set(1, &quot;foo&quot;);
+var keys = map.keys()
+// Iterator reaches end and becomes dead.
+for (key of keys) {
+    // Do nothing
+}
+map.set(2, &quot;bar&quot;)
+map.set(3, &quot;wibble&quot;)
+
+// Iterator 'keys' remains dead.
+var count = 0;
+for (key of keys) {
+    count++;
+}
+shouldBe(&quot;count&quot;, &quot;0&quot;);
+
+// New assignment creates a new iterator.
+keys = map.keys();
+for (key of keys) {
+    count++;
+}
+shouldBe(&quot;count&quot;, &quot;3&quot;);
+
+// Iterating through map.keys()
+count = 0;
+for (key of map.keys()) {
+    count++;
+}
+shouldBe(&quot;count&quot;, &quot;3&quot;);
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsbasicsetjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/basic-set.js (172706 => 172707)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/basic-set.js        2014-08-18 17:02:13 UTC (rev 172706)
+++ trunk/LayoutTests/js/script-tests/basic-set.js        2014-08-18 17:08:22 UTC (rev 172707)
</span><span class="lines">@@ -205,3 +205,36 @@
</span><span class="cx"> }
</span><span class="cx"> shouldBe(&quot;i&quot;, &quot;5&quot;)
</span><span class="cx"> shouldBe(&quot;set.size&quot;, &quot;4&quot;);
</span><ins>+
+debug(&quot;A dead iterator should remain dead&quot;)
+
+var set = new Set;
+set.add(&quot;foo&quot;);
+var keys = set.keys()
+// Iterator reaches end and becomes dead.
+for (key of keys) {
+    // Do nothing
+}
+set.add(&quot;bar&quot;)
+set.add(&quot;wibble&quot;)
+
+// Iterator 'keys' remains dead.
+var count = 0;
+for (key of keys) {
+    count++;
+}
+shouldBe(&quot;count&quot;, &quot;0&quot;);
+
+// New assignment creates a new iterator.
+keys = set.keys();
+for (key of keys) {
+    count++;
+}
+shouldBe(&quot;count&quot;, &quot;3&quot;);
+
+// Iterating through set.keys()
+count = 0;
+for (key of set.keys()) {
+    count++;
+}
+shouldBe(&quot;count&quot;, &quot;3&quot;);
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (172706 => 172707)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-08-18 17:02:13 UTC (rev 172706)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-08-18 17:08:22 UTC (rev 172707)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2014-08-18  Diego Pino Garcia  &lt;dpino@igalia.com&gt;
+
+        Completed iterator can be revived by adding more than one new entry to the target object
+        https://bugs.webkit.org/show_bug.cgi?id=129993
+
+        Reviewed by Oliver Hunt.
+
+        When iterator reaches end, finish iterator.
+
+        * runtime/JSMapIterator.h:
+        (JSC::JSMapIterator::finish):
+        * runtime/JSSetIterator.h:
+        (JSC::JSSetIterator::finish):
+        * runtime/MapData.h:
+        (JSC::MapData::const_iterator::finish): set index of iterator to max
+        Int32.
+        * runtime/MapIteratorPrototype.cpp:
+        (JSC::MapIteratorPrototypeFuncNext):
+        * runtime/SetIteratorPrototype.cpp:
+        (JSC::SetIteratorPrototypeFuncNext):
+
</ins><span class="cx"> 2014-08-15  Brian J. Burg  &lt;burg@cs.washington.edu&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: rewrite CodeGeneratorInspector to be modular and testable
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSMapIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSMapIterator.h (172706 => 172707)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSMapIterator.h        2014-08-18 17:02:13 UTC (rev 172706)
+++ trunk/Source/JavaScriptCore/runtime/JSMapIterator.h        2014-08-18 17:08:22 UTC (rev 172707)
</span><span class="lines">@@ -70,6 +70,11 @@
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    void finish()
+    {
+        m_iterator.finish();
+    }
+
</ins><span class="cx"> private:
</span><span class="cx">     JSMapIterator(VM&amp; vm, Structure* structure, JSMap* iteratedObject, MapIterationKind kind)
</span><span class="cx">         : Base(vm, structure)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSSetIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSSetIterator.h (172706 => 172707)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSSetIterator.h        2014-08-18 17:02:13 UTC (rev 172706)
+++ trunk/Source/JavaScriptCore/runtime/JSSetIterator.h        2014-08-18 17:08:22 UTC (rev 172707)
</span><span class="lines">@@ -68,6 +68,11 @@
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    void finish()
+    {
+        m_iterator.finish();
+    }
+
</ins><span class="cx"> private:
</span><span class="cx">     JSSetIterator(VM&amp; vm, Structure* structure, JSSet* iteratedObject, SetIterationKind kind)
</span><span class="cx">         : Base(vm, structure)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeMapDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/MapData.h (172706 => 172707)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/MapData.h        2014-08-18 17:02:13 UTC (rev 172706)
+++ trunk/Source/JavaScriptCore/runtime/MapData.h        2014-08-18 17:08:22 UTC (rev 172707)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx">         static const_iterator end(const MapData*);
</span><span class="cx">         bool operator!=(const const_iterator&amp; other);
</span><span class="cx">         bool operator==(const const_iterator&amp; other);
</span><ins>+        void finish() { m_index = std::numeric_limits&lt;int32_t&gt;::max(); }
</ins><span class="cx"> 
</span><span class="cx">         bool ensureSlot();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeMapIteratorPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/MapIteratorPrototype.cpp (172706 => 172707)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/MapIteratorPrototype.cpp        2014-08-18 17:02:13 UTC (rev 172706)
+++ trunk/Source/JavaScriptCore/runtime/MapIteratorPrototype.cpp        2014-08-18 17:08:22 UTC (rev 172707)
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx">     JSValue result;
</span><span class="cx">     if (iterator-&gt;next(callFrame, result))
</span><span class="cx">         return JSValue::encode(result);
</span><ins>+    iterator-&gt;finish();
</ins><span class="cx">     return JSValue::encode(callFrame-&gt;vm().iterationTerminator.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeSetIteratorPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/SetIteratorPrototype.cpp (172706 => 172707)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/SetIteratorPrototype.cpp        2014-08-18 17:02:13 UTC (rev 172706)
+++ trunk/Source/JavaScriptCore/runtime/SetIteratorPrototype.cpp        2014-08-18 17:08:22 UTC (rev 172707)
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (iterator-&gt;next(callFrame, result))
</span><span class="cx">         return JSValue::encode(result);
</span><del>-
</del><ins>+    iterator-&gt;finish();
</ins><span class="cx">     return JSValue::encode(callFrame-&gt;vm().iterationTerminator.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>