<!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>[210918] 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/210918">210918</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2017-01-19 00:21:37 -0800 (Thu, 19 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>[WebIDL] Records should preserve javascript object order
https://bugs.webkit.org/show_bug.cgi?id=167189
Patch by Sam Weinig <sam@webkit.org> on 2017-01-18
Reviewed by Alex Christensen.
Source/WebCore:
Instead of modeling IDL records as HashMaps, use a Vector
of KeyValuePairs, to all preserving the iteration order.
* Modules/webdatabase/SQLResultSetRowList.cpp:
(WebCore::SQLResultSetRowList::item):
* Modules/webdatabase/SQLResultSetRowList.h:
Return a Vector rather than a HashMap.
* bindings/IDLTypes.h:
Change underlying type to be a Vector<KeyValuePair<K, V>>.
* bindings/js/JSDOMConvert.h:
Update conversion for new implementation type. For conversion
to JSValue, allow any type that can has an iterator of keyValuePairs.
* testing/TypeConversions.h:
(WebCore::TypeConversions::testLongRecord):
(WebCore::TypeConversions::setTestLongRecord):
(WebCore::TypeConversions::testNodeRecord):
(WebCore::TypeConversions::setTestNodeRecord):
(WebCore::TypeConversions::testSequenceRecord):
(WebCore::TypeConversions::setTestSequenceRecord):
* testing/TypeConversions.idl:
Update test IDL to use functions, since the spec mandates that
records can't be used with attributes.
LayoutTests:
* js/dom/webidl-type-mapping-expected.txt:
* js/dom/webidl-type-mapping.html:
Update test to reflect changes to TypeConversions.idl</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsdomwebidltypemappingexpectedtxt">trunk/LayoutTests/js/dom/webidl-type-mapping-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsdomwebidltypemappinghtml">trunk/LayoutTests/js/dom/webidl-type-mapping.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModuleswebdatabaseSQLResultSetRowListcpp">trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebdatabaseSQLResultSetRowListh">trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.h</a></li>
<li><a href="#trunkSourceWebCorebindingsIDLTypesh">trunk/Source/WebCore/bindings/IDLTypes.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMConverth">trunk/Source/WebCore/bindings/js/JSDOMConvert.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCoretestingTypeConversionsh">trunk/Source/WebCore/testing/TypeConversions.h</a></li>
<li><a href="#trunkSourceWebCoretestingTypeConversionsidl">trunk/Source/WebCore/testing/TypeConversions.idl</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (210917 => 210918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/LayoutTests/ChangeLog        2017-01-19 08:21:37 UTC (rev 210918)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-01-18 Sam Weinig <sam@webkit.org>
+
+ [WebIDL] Records should preserve javascript object order
+ https://bugs.webkit.org/show_bug.cgi?id=167189
+
+ Reviewed by Alex Christensen.
+
+ * js/dom/webidl-type-mapping-expected.txt:
+ * js/dom/webidl-type-mapping.html:
+ Update test to reflect changes to TypeConversions.idl
+
</ins><span class="cx"> 2017-01-18 Yoav Weiss <yoav@yoav.ws>
</span><span class="cx">
</span><span class="cx"> Add Link header support for preload.
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomwebidltypemappingexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/webidl-type-mapping-expected.txt (210917 => 210918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/webidl-type-mapping-expected.txt        2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/LayoutTests/js/dom/webidl-type-mapping-expected.txt        2017-01-19 08:21:37 UTC (rev 210918)
</span><span class="lines">@@ -1127,69 +1127,69 @@
</span><span class="cx"> PASS converter.typeConversionsDictionaryUnionType is 'dictionary'
</span><span class="cx">
</span><span class="cx"> Testing record conversion
</span><del>-converter.testLongRecord = { key: 1, key2: 2 }
-PASS converter.testLongRecord is an instance of Object
-PASS converter.testLongRecord.hasOwnProperty('key') is true
-PASS 'key' in converter.testLongRecord is true
-PASS converter.testLongRecord['key'] is 1
-PASS converter.testLongRecord.hasOwnProperty('key2') is true
-PASS 'key2' in converter.testLongRecord is true
-PASS converter.testLongRecord['key2'] is 2
-converter.testLongRecord = undefined
-PASS converter.testLongRecord is an instance of Object
-converter.testLongRecord = null
-PASS converter.testLongRecord is an instance of Object
-PASS converter.testLongRecord = 1 threw exception TypeError: Type error.
-PASS converter.testLongRecord = { key: { valueOf:function() { throw new Error(); } } } threw exception Error.
-var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { enumerable: false, value: 1 }); converter.testLongRecord = o;
-PASS converter.testLongRecord.hasOwnProperty('key') is false
-PASS converter.testLongRecord.hasOwnProperty('otherKey') is true
-PASS converter.testLongRecord['otherKey'] is 2
-var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { return 1; }, enumerable: true }); converter.testLongRecord = o;
-PASS converter.testLongRecord.hasOwnProperty('key') is true
-PASS converter.testLongRecord['key'] is 1
-PASS converter.testLongRecord.hasOwnProperty('otherKey') is true
-PASS converter.testLongRecord['otherKey'] is 2
-PASS var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { throw new Error();; }, enumerable: true }); converter.testLongRecord = o; threw exception Error.
-converter.testNodeRecord = { key: document, key2: document.documentElement }
-PASS converter.testNodeRecord.hasOwnProperty('key') is true
-PASS 'key' in converter.testNodeRecord is true
-PASS converter.testNodeRecord['key'] is document
-PASS converter.testNodeRecord.hasOwnProperty('key2') is true
-PASS 'key2' in converter.testNodeRecord is true
-PASS converter.testNodeRecord['key2'] is document.documentElement
-PASS converter.testNodeRecord = { key: 'hello' } threw exception TypeError: Type error.
-converter.testLongRecord = {'í ': 1 }
-PASS converter.testLongRecord['í '] is 1
-converter.testNodeRecord = {'í ': document }
-PASS converter.testNodeRecord['�'] is document
-converter.testLongRecord = {'í°': 1 }
-PASS converter.testLongRecord['í°'] is 1
-converter.testNodeRecord = {'í°': document }
-PASS converter.testNodeRecord['�'] is document
-converter.testLongRecord = {'í ': 1 }
-PASS converter.testLongRecord['í \0'] is 1
-converter.testNodeRecord = {'í ': document }
-PASS converter.testNodeRecord['�\0'] is document
-converter.testLongRecord = {'í°': 1 }
-PASS converter.testLongRecord['í°\0'] is 1
-converter.testNodeRecord = {'í°': document }
-PASS converter.testNodeRecord['�\0'] is document
-converter.testLongRecord = {'í°í ': 1 }
-PASS converter.testLongRecord['í°í '] is 1
-converter.testNodeRecord = {'í°í ': document }
-PASS converter.testNodeRecord['��'] is document
-converter.testLongRecord = {'ð': 1 }
-PASS converter.testLongRecord['ð'] is 1
-converter.testNodeRecord = {'ð': document }
-PASS converter.testNodeRecord['ð'] is document
-converter.testSequenceRecord = { key: ['value', 'other value'] }
-PASS converter.testSequenceRecord.hasOwnProperty('key') is true
-PASS 'key' in converter.testSequenceRecord is true
-PASS converter.testSequenceRecord['key'] is ['value', 'other value']
-PASS converter.testSequenceRecord = { 'Ä': ['value'] } threw exception TypeError: Type error.
-converter.testSequenceRecord = { 'ÿ': ['value'] }
-PASS converter.testSequenceRecord['ÿ'] is ['value']
</del><ins>+converter.setTestLongRecord({ key: 1, key2: 2 })
+PASS converter.testLongRecord() is an instance of Object
+PASS converter.testLongRecord().hasOwnProperty('key') is true
+PASS 'key' in converter.testLongRecord() is true
+PASS converter.testLongRecord()['key'] is 1
+PASS converter.testLongRecord().hasOwnProperty('key2') is true
+PASS 'key2' in converter.testLongRecord() is true
+PASS converter.testLongRecord()['key2'] is 2
+converter.setTestLongRecord(undefined)
+PASS converter.testLongRecord() is an instance of Object
+converter.setTestLongRecord(null)
+PASS converter.testLongRecord() is an instance of Object
+PASS converter.setTestLongRecord(1) threw exception TypeError: Type error.
+PASS converter.setTestLongRecord({ key: { valueOf:function() { throw new Error(); } } }) threw exception Error.
+var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { enumerable: false, value: 1 }); converter.setTestLongRecord(o);
+PASS converter.testLongRecord().hasOwnProperty('key') is false
+PASS converter.testLongRecord().hasOwnProperty('otherKey') is true
+PASS converter.testLongRecord()['otherKey'] is 2
+var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { return 1; }, enumerable: true }); converter.setTestLongRecord(o);
+PASS converter.testLongRecord().hasOwnProperty('key') is true
+PASS converter.testLongRecord()['key'] is 1
+PASS converter.testLongRecord().hasOwnProperty('otherKey') is true
+PASS converter.testLongRecord()['otherKey'] is 2
+PASS var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { throw new Error(); }, enumerable: true }); converter.setTestLongRecord(o); threw exception Error.
+converter.setTestNodeRecord({ key: document, key2: document.documentElement })
+PASS converter.testNodeRecord().hasOwnProperty('key') is true
+PASS 'key' in converter.testNodeRecord() is true
+PASS converter.testNodeRecord()['key'] is document
+PASS converter.testNodeRecord().hasOwnProperty('key2') is true
+PASS 'key2' in converter.testNodeRecord() is true
+PASS converter.testNodeRecord()['key2'] is document.documentElement
+PASS converter.setTestNodeRecord({ key: 'hello' }) threw exception TypeError: Type error.
+converter.setTestLongRecord({'í ': 1 })
+PASS converter.testLongRecord()['í '] is 1
+converter.setTestNodeRecord({'í ': document })
+PASS converter.testNodeRecord()['�'] is document
+converter.setTestLongRecord({'í°': 1 })
+PASS converter.testLongRecord()['í°'] is 1
+converter.setTestNodeRecord({'í°': document })
+PASS converter.testNodeRecord()['�'] is document
+converter.setTestLongRecord({'í ': 1 })
+PASS converter.testLongRecord()['í \0'] is 1
+converter.setTestNodeRecord({'í ': document })
+PASS converter.testNodeRecord()['�\0'] is document
+converter.setTestLongRecord({'í°': 1 })
+PASS converter.testLongRecord()['í°\0'] is 1
+converter.setTestNodeRecord({'í°': document })
+PASS converter.testNodeRecord()['�\0'] is document
+converter.setTestLongRecord({'í°í ': 1 })
+PASS converter.testLongRecord()['í°í '] is 1
+converter.setTestNodeRecord({'í°í ': document })
+PASS converter.testNodeRecord()['��'] is document
+converter.setTestLongRecord({'ð': 1 })
+PASS converter.testLongRecord()['ð'] is 1
+converter.setTestNodeRecord({'ð': document })
+PASS converter.testNodeRecord()['ð'] is document
+converter.setTestSequenceRecord({ key: ['value', 'other value'] })
+PASS converter.testSequenceRecord().hasOwnProperty('key') is true
+PASS 'key' in converter.testSequenceRecord() is true
+PASS converter.testSequenceRecord()['key'] is ['value', 'other value']
+PASS converter.setTestSequenceRecord({ 'Ä': ['value'] }) threw exception TypeError: Type error.
+converter.setTestSequenceRecord({ 'ÿ': ['value'] })
+PASS converter.testSequenceRecord()['ÿ'] is ['value']
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx">
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomwebidltypemappinghtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/webidl-type-mapping.html (210917 => 210918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/webidl-type-mapping.html        2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/LayoutTests/js/dom/webidl-type-mapping.html        2017-01-19 08:21:37 UTC (rev 210918)
</span><span class="lines">@@ -659,39 +659,39 @@
</span><span class="cx"> // testNodeRecord is a record<USVString, Node> attribute
</span><span class="cx"> // testSequenceRecord is a record<ByteString, sequence<DOMString>> attribute
</span><span class="cx">
</span><del>-evalAndLog("converter.testLongRecord = { key: 1, key2: 2 }");
-shouldBeType("converter.testLongRecord", "Object");
-shouldBeTrue("converter.testLongRecord.hasOwnProperty('key')");
-shouldBeTrue("'key' in converter.testLongRecord");
-shouldBe("converter.testLongRecord['key']", "1");
-shouldBeTrue("converter.testLongRecord.hasOwnProperty('key2')");
-shouldBeTrue("'key2' in converter.testLongRecord");
-shouldBe("converter.testLongRecord['key2']", "2");
-evalAndLog("converter.testLongRecord = undefined");
-shouldBeType("converter.testLongRecord", "Object");
-evalAndLog("converter.testLongRecord = null");
-shouldBeType("converter.testLongRecord", "Object");
-shouldThrow("converter.testLongRecord = 1");
-shouldThrow("converter.testLongRecord = { key: { valueOf:function() { throw new Error(); } } }");
-evalAndLog("var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { enumerable: false, value: 1 }); converter.testLongRecord = o;");
-shouldBeFalse("converter.testLongRecord.hasOwnProperty('key')");
-shouldBeTrue("converter.testLongRecord.hasOwnProperty('otherKey')");
-shouldBe("converter.testLongRecord['otherKey']", "2");
-evalAndLog("var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { return 1; }, enumerable: true }); converter.testLongRecord = o;");
-shouldBeTrue("converter.testLongRecord.hasOwnProperty('key')");
-shouldBe("converter.testLongRecord['key']", "1");
-shouldBeTrue("converter.testLongRecord.hasOwnProperty('otherKey')");
-shouldBe("converter.testLongRecord['otherKey']", "2");
-shouldThrow("var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { throw new Error();; }, enumerable: true }); converter.testLongRecord = o;");
</del><ins>+evalAndLog("converter.setTestLongRecord({ key: 1, key2: 2 })");
+shouldBeType("converter.testLongRecord()", "Object");
+shouldBeTrue("converter.testLongRecord().hasOwnProperty('key')");
+shouldBeTrue("'key' in converter.testLongRecord()");
+shouldBe("converter.testLongRecord()['key']", "1");
+shouldBeTrue("converter.testLongRecord().hasOwnProperty('key2')");
+shouldBeTrue("'key2' in converter.testLongRecord()");
+shouldBe("converter.testLongRecord()['key2']", "2");
+evalAndLog("converter.setTestLongRecord(undefined)");
+shouldBeType("converter.testLongRecord()", "Object");
+evalAndLog("converter.setTestLongRecord(null)");
+shouldBeType("converter.testLongRecord()", "Object");
+shouldThrow("converter.setTestLongRecord(1)");
+shouldThrow("converter.setTestLongRecord({ key: { valueOf:function() { throw new Error(); } } })");
+evalAndLog("var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { enumerable: false, value: 1 }); converter.setTestLongRecord(o);");
+shouldBeFalse("converter.testLongRecord().hasOwnProperty('key')");
+shouldBeTrue("converter.testLongRecord().hasOwnProperty('otherKey')");
+shouldBe("converter.testLongRecord()['otherKey']", "2");
+evalAndLog("var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { return 1; }, enumerable: true }); converter.setTestLongRecord(o);");
+shouldBeTrue("converter.testLongRecord().hasOwnProperty('key')");
+shouldBe("converter.testLongRecord()['key']", "1");
+shouldBeTrue("converter.testLongRecord().hasOwnProperty('otherKey')");
+shouldBe("converter.testLongRecord()['otherKey']", "2");
+shouldThrow("var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { throw new Error(); }, enumerable: true }); converter.setTestLongRecord(o);");
</ins><span class="cx">
</span><del>-evalAndLog("converter.testNodeRecord = { key: document, key2: document.documentElement }");
-shouldBeTrue("converter.testNodeRecord.hasOwnProperty('key')");
-shouldBeTrue("'key' in converter.testNodeRecord");
-shouldBe("converter.testNodeRecord['key']", "document");
-shouldBeTrue("converter.testNodeRecord.hasOwnProperty('key2')");
-shouldBeTrue("'key2' in converter.testNodeRecord");
-shouldBe("converter.testNodeRecord['key2']", "document.documentElement");
-shouldThrow("converter.testNodeRecord = { key: 'hello' }");
</del><ins>+evalAndLog("converter.setTestNodeRecord({ key: document, key2: document.documentElement })");
+shouldBeTrue("converter.testNodeRecord().hasOwnProperty('key')");
+shouldBeTrue("'key' in converter.testNodeRecord()");
+shouldBe("converter.testNodeRecord()['key']", "document");
+shouldBeTrue("converter.testNodeRecord().hasOwnProperty('key2')");
+shouldBeTrue("'key2' in converter.testNodeRecord()");
+shouldBe("converter.testNodeRecord()['key2']", "document.documentElement");
+shouldThrow("converter.setTestNodeRecord({ key: 'hello' })");
</ins><span class="cx">
</span><span class="cx"> [{input: "\uD800", expected: "\uFFFD"},
</span><span class="cx"> {input: "\uDC00", expected: "\uFFFD"},
</span><span class="lines">@@ -700,19 +700,19 @@
</span><span class="cx"> {input: "\uDC00\uD800", expected: "\uFFFD\uFFFD"},
</span><span class="cx"> {input: "\uD834\uDD1E", expected: "\uD834\uDD1E"},
</span><span class="cx"> ].forEach(function(test) {
</span><del>- evalAndLog("converter.testLongRecord = {'" + test.input + "': 1 }");
- shouldBe("converter.testLongRecord['" + test.input + "']", "1");
- evalAndLog("converter.testNodeRecord = {'" + test.input + "': document }");
- shouldBe("converter.testNodeRecord['" + test.expected + "']", "document");
</del><ins>+ evalAndLog("converter.setTestLongRecord({'" + test.input + "': 1 })");
+ shouldBe("converter.testLongRecord()['" + test.input + "']", "1");
+ evalAndLog("converter.setTestNodeRecord({'" + test.input + "': document })");
+ shouldBe("converter.testNodeRecord()['" + test.expected + "']", "document");
</ins><span class="cx"> });
</span><span class="cx">
</span><del>-evalAndLog("converter.testSequenceRecord = { key: ['value', 'other value'] }");
-shouldBeTrue("converter.testSequenceRecord.hasOwnProperty('key')");
-shouldBeTrue("'key' in converter.testSequenceRecord");
-shouldBe("converter.testSequenceRecord['key']", "['value', 'other value']");
-shouldThrow("converter.testSequenceRecord = { '\u0100': ['value'] }");
-evalAndLog("converter.testSequenceRecord = { '\u00FF': ['value'] }");
-shouldBe("converter.testSequenceRecord['\u00FF']", "['value']");
</del><ins>+evalAndLog("converter.setTestSequenceRecord({ key: ['value', 'other value'] })");
+shouldBeTrue("converter.testSequenceRecord().hasOwnProperty('key')");
+shouldBeTrue("'key' in converter.testSequenceRecord()");
+shouldBe("converter.testSequenceRecord()['key']", "['value', 'other value']");
+shouldThrow("converter.setTestSequenceRecord({ '\u0100': ['value'] })");
+evalAndLog("converter.setTestSequenceRecord({ '\u00FF': ['value'] })");
+shouldBe("converter.testSequenceRecord()['\u00FF']", "['value']");
</ins><span class="cx">
</span><span class="cx"> </script>
</span><span class="cx"> <script src="../../resources/js-test-post.js"></script>
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210917 => 210918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/ChangeLog        2017-01-19 08:21:37 UTC (rev 210918)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2017-01-18 Sam Weinig <sam@webkit.org>
+
+ [WebIDL] Records should preserve javascript object order
+ https://bugs.webkit.org/show_bug.cgi?id=167189
+
+ Reviewed by Alex Christensen.
+
+ Instead of modeling IDL records as HashMaps, use a Vector
+ of KeyValuePairs, to all preserving the iteration order.
+
+ * Modules/webdatabase/SQLResultSetRowList.cpp:
+ (WebCore::SQLResultSetRowList::item):
+ * Modules/webdatabase/SQLResultSetRowList.h:
+ Return a Vector rather than a HashMap.
+
+ * bindings/IDLTypes.h:
+ Change underlying type to be a Vector<KeyValuePair<K, V>>.
+
+ * bindings/js/JSDOMConvert.h:
+ Update conversion for new implementation type. For conversion
+ to JSValue, allow any type that can has an iterator of keyValuePairs.
+
+ * testing/TypeConversions.h:
+ (WebCore::TypeConversions::testLongRecord):
+ (WebCore::TypeConversions::setTestLongRecord):
+ (WebCore::TypeConversions::testNodeRecord):
+ (WebCore::TypeConversions::setTestNodeRecord):
+ (WebCore::TypeConversions::testSequenceRecord):
+ (WebCore::TypeConversions::setTestSequenceRecord):
+ * testing/TypeConversions.idl:
+ Update test IDL to use functions, since the spec mandates that
+ records can't be used with attributes.
+
</ins><span class="cx"> 2017-01-18 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Implement URLSearchParams's sort()
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebdatabaseSQLResultSetRowListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.cpp (210917 => 210918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.cpp        2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.cpp        2017-01-19 08:21:37 UTC (rev 210918)
</span><span class="lines">@@ -43,17 +43,17 @@
</span><span class="cx"> return m_result.size() / m_columns.size();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-ExceptionOr<HashMap<String, SQLValue>> SQLResultSetRowList::item(unsigned index) const
</del><ins>+ExceptionOr<Vector<WTF::KeyValuePair<String, SQLValue>>> SQLResultSetRowList::item(unsigned index) const
</ins><span class="cx"> {
</span><span class="cx"> if (index >= length())
</span><span class="cx"> return Exception { INDEX_SIZE_ERR };
</span><span class="cx">
</span><del>- HashMap<String, SQLValue> result;
</del><ins>+ Vector<WTF::KeyValuePair<String, SQLValue>> result;
</ins><span class="cx">
</span><span class="cx"> unsigned numberOfColumns = m_columns.size();
</span><span class="cx"> unsigned valuesIndex = index * numberOfColumns;
</span><span class="cx"> for (unsigned i = 0; i < numberOfColumns; i++)
</span><del>- result.set(m_columns[i], m_result[valuesIndex + i]);
</del><ins>+ result.append({ m_columns[i], m_result[valuesIndex + i] });
</ins><span class="cx">
</span><span class="cx"> return WTFMove(result);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebdatabaseSQLResultSetRowListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.h (210917 => 210918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.h        2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.h        2017-01-19 08:21:37 UTC (rev 210918)
</span><span class="lines">@@ -30,8 +30,7 @@
</span><span class="cx">
</span><span class="cx"> #include "ExceptionOr.h"
</span><span class="cx"> #include "SQLValue.h"
</span><del>-#include <wtf/HashMap.h>
-#include <wtf/text/StringHash.h>
</del><ins>+#include <wtf/HashTraits.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -46,7 +45,7 @@
</span><span class="cx"> void addResult(const SQLValue& result) { m_result.append(result); }
</span><span class="cx">
</span><span class="cx"> unsigned length() const;
</span><del>- ExceptionOr<HashMap<String, SQLValue>> item(unsigned index) const;
</del><ins>+ ExceptionOr<Vector<WTF::KeyValuePair<String, SQLValue>>> item(unsigned index) const;
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> SQLResultSetRowList() { }
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsIDLTypesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/IDLTypes.h (210917 => 210918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/IDLTypes.h        2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/bindings/IDLTypes.h        2017-01-19 08:21:37 UTC (rev 210918)
</span><span class="lines">@@ -156,11 +156,11 @@
</span><span class="cx"> using ParameterType = const Vector<typename T::ImplementationType>&;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-template<typename K, typename V> struct IDLRecord : IDLType<HashMap<typename K::ImplementationType, typename V::ImplementationType>> {
</del><ins>+template<typename K, typename V> struct IDLRecord : IDLType<Vector<WTF::KeyValuePair<typename K::ImplementationType, typename V::ImplementationType>>> {
</ins><span class="cx"> using KeyType = K;
</span><span class="cx"> using ValueType = V;
</span><span class="cx">
</span><del>- using ParameterType = const HashMap<typename K::ImplementationType, typename V::ImplementationType>&;
</del><ins>+ using ParameterType = const Vector<WTF::KeyValuePair<typename K::ImplementationType, typename V::ImplementationType>>&;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> template<typename T> struct IDLPromise : IDLType<DOMPromise<T>> {
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMConverth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMConvert.h (210917 => 210918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMConvert.h        2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvert.h        2017-01-19 08:21:37 UTC (rev 210918)
</span><span class="lines">@@ -1271,8 +1271,10 @@
</span><span class="cx">
</span><span class="cx"> // 4. If typedKey is already a key in result, set its value to typedValue.
</span><span class="cx"> // Note: This can happen when O is a proxy object.
</span><ins>+ // FIXME: Handle this case.
+
</ins><span class="cx"> // 5. Otherwise, append to result a mapping (typedKey, typedValue).
</span><del>- result.set(typedKey, typedValue);
</del><ins>+ result.append({ typedKey, typedValue });
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1285,8 +1287,8 @@
</span><span class="cx"> static constexpr bool needsState = true;
</span><span class="cx"> static constexpr bool needsGlobalObject = true;
</span><span class="cx">
</span><del>- template<typename ValueType>
- static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const HashMap<String, ValueType>& map)
</del><ins>+ template<typename MapType>
+ static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const MapType& map)
</ins><span class="cx"> {
</span><span class="cx"> auto& vm = state.vm();
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (210917 => 210918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2017-01-19 08:21:37 UTC (rev 210918)
</span><span class="lines">@@ -297,7 +297,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if ($codeGenerator->IsRecordType($type)) {
</span><del>- AddToIncludes("<wtf/HashMap.h>", $includesRef, $conditional);
</del><ins>+ AddToIncludes("<wtf/Vector.h>", $includesRef, $conditional);
</ins><span class="cx"> AddToIncludesForIDLType(@{$type->subtypes}[0], $includesRef, $conditional);
</span><span class="cx"> AddToIncludesForIDLType(@{$type->subtypes}[1], $includesRef, $conditional);
</span><span class="cx"> return;
</span><span class="lines">@@ -5327,7 +5327,7 @@
</span><span class="cx"> return GetEnumerationClassName($type, $interface) if $codeGenerator->IsEnumType($type);
</span><span class="cx"> return GetDictionaryClassName($type, $interface) if $codeGenerator->IsDictionaryType($type);
</span><span class="cx"> return "Vector<" . GetNativeInnerType(@{$type->subtypes}[0], $interface) . ">" if $codeGenerator->IsSequenceOrFrozenArrayType($type);
</span><del>- return "HashMap<" . GetNativeInnerType(@{$type->subtypes}[0], $interface) . ", " . GetNativeInnerType(@{$type->subtypes}[1], $interface) . ">" if $codeGenerator->IsRecordType($type);
</del><ins>+ return "Vector<WTF::KeyValuePair<" . GetNativeInnerType(@{$type->subtypes}[0], $interface) . ", " . GetNativeInnerType(@{$type->subtypes}[1], $interface) . ">>" if $codeGenerator->IsRecordType($type);
</ins><span class="cx">
</span><span class="cx"> return "RefPtr<${typeName}>" if $codeGenerator->IsTypedArrayType($type) and $typeName ne "ArrayBuffer";
</span><span class="cx"> return "${typeName}*";
</span><span class="lines">@@ -5344,7 +5344,7 @@
</span><span class="cx"> return GetEnumerationClassName($innerType, $interface) if $codeGenerator->IsEnumType($innerType);
</span><span class="cx"> return GetDictionaryClassName($innerType, $interface) if $codeGenerator->IsDictionaryType($innerType);
</span><span class="cx"> return "Vector<" . GetNativeInnerType(@{$innerType->subtypes}[0], $interface) . ">" if $codeGenerator->IsSequenceOrFrozenArrayType($innerType);
</span><del>- return "HashMap<" . GetNativeInnerType(@{$innerType->subtypes}[0], $interface) . ", " . GetNativeInnerType(@{$innerType->subtypes}[1], $interface) . ">" if $codeGenerator->IsRecordType($innerType);
</del><ins>+ return "Vector<WTF::KeyValuePair<" . GetNativeInnerType(@{$innerType->subtypes}[0], $interface) . ", " . GetNativeInnerType(@{$innerType->subtypes}[1], $interface) . ">>" if $codeGenerator->IsRecordType($innerType);
</ins><span class="cx"> return "RefPtr<$innerTypeName>";
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoretestingTypeConversionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/TypeConversions.h (210917 => 210918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/TypeConversions.h        2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/testing/TypeConversions.h        2017-01-19 08:21:37 UTC (rev 210918)
</span><span class="lines">@@ -102,12 +102,12 @@
</span><span class="cx"> const String& testByteString() const { return m_byteString; }
</span><span class="cx"> void setTestByteString(const String& byteString) { m_byteString = byteString; }
</span><span class="cx">
</span><del>- const HashMap<String, int>& testLongRecord() const { return m_longRecord; }
- void setTestLongRecord(const HashMap<String, int>& value) { m_longRecord = value; }
- const HashMap<String, RefPtr<Node>>& testNodeRecord() const { return m_nodeRecord; }
- void setTestNodeRecord(const HashMap<String, RefPtr<Node>>& value) { m_nodeRecord = value; }
- const HashMap<String, Vector<String>>& testSequenceRecord() const { return m_sequenceRecord; }
- void setTestSequenceRecord(const HashMap<String, Vector<String>>& value) { m_sequenceRecord = value; }
</del><ins>+ const Vector<WTF::KeyValuePair<String, int>>& testLongRecord() const { return m_longRecord; }
+ void setTestLongRecord(const Vector<WTF::KeyValuePair<String, int>>& value) { m_longRecord = value; }
+ const Vector<WTF::KeyValuePair<String, RefPtr<Node>>>& testNodeRecord() const { return m_nodeRecord; }
+ void setTestNodeRecord(const Vector<WTF::KeyValuePair<String, RefPtr<Node>>>& value) { m_nodeRecord = value; }
+ const Vector<WTF::KeyValuePair<String, Vector<String>>>& testSequenceRecord() const { return m_sequenceRecord; }
+ void setTestSequenceRecord(const Vector<WTF::KeyValuePair<String, Vector<String>>>& value) { m_sequenceRecord = value; }
</ins><span class="cx">
</span><span class="cx"> using TestUnion = Variant<String, int, bool, RefPtr<Node>, Vector<int>>;
</span><span class="cx"> const TestUnion& testUnion() const { return m_union; }
</span><span class="lines">@@ -150,9 +150,9 @@
</span><span class="cx"> String m_string;
</span><span class="cx"> String m_usvstring;
</span><span class="cx"> String m_byteString;
</span><del>- HashMap<String, int> m_longRecord;
- HashMap<String, RefPtr<Node>> m_nodeRecord;
- HashMap<String, Vector<String>> m_sequenceRecord;
</del><ins>+ Vector<WTF::KeyValuePair<String, int>> m_longRecord;
+ Vector<WTF::KeyValuePair<String, RefPtr<Node>>> m_nodeRecord;
+ Vector<WTF::KeyValuePair<String, Vector<String>>> m_sequenceRecord;
</ins><span class="cx"> TestUnion m_union;
</span><span class="cx">
</span><span class="cx"> int m_typeConversionsDictionaryLongValue { 0 };
</span></span></pre></div>
<a id="trunkSourceWebCoretestingTypeConversionsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/TypeConversions.idl (210917 => 210918)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/TypeConversions.idl        2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/testing/TypeConversions.idl        2017-01-19 08:21:37 UTC (rev 210918)
</span><span class="lines">@@ -54,10 +54,15 @@
</span><span class="cx"> attribute ByteString testByteString;
</span><span class="cx"> attribute USVString testUSVString;
</span><span class="cx">
</span><del>- attribute record<DOMString, long> testLongRecord;
- attribute record<USVString, Node> testNodeRecord;
- attribute record<ByteString, sequence<DOMString>> testSequenceRecord;
</del><ins>+ void setTestLongRecord(record<DOMString, long> record);
+ record<DOMString, long> testLongRecord();
</ins><span class="cx">
</span><ins>+ void setTestNodeRecord(record<USVString, Node> record);
+ record<USVString, Node> testNodeRecord();
+
+ void setTestSequenceRecord(record<ByteString, sequence<DOMString>> record);
+ record<ByteString, sequence<DOMString>> testSequenceRecord();
+
</ins><span class="cx"> attribute (DOMString or long or boolean or Node or sequence<long>) testUnion;
</span><span class="cx">
</span><span class="cx"> void setTypeConversionsDictionary(TypeConversionsDictionary d);
</span></span></pre>
</div>
</div>
</body>
</html>