<!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>[191850] 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/191850">191850</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2015-10-31 21:34:49 -0700 (Sat, 31 Oct 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>IDB: Date objects don't work as keys or values.
https://bugs.webkit.org/show_bug.cgi?id=150743
Reviewed by Darin Adler.
Source/WebCore:
Test: storage/indexeddb/modern/date-basic.html
The combination of the autogenerated bindings with Deprecated::ScriptValue was
losing the fidelity of "Date" objects being Dates, and not just normal Objects.
This was breaking their usage as IDBKeys.
Custom binding + reworking the IDBObjectStore IDLs to use JSValue instead of ScriptValue
fixes this handily.
* Modules/indexeddb/IDBObjectStore.h:
* Modules/indexeddb/IDBObjectStore.idl:
* Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
(WebCore::IDBClient::IDBObjectStore::add):
(WebCore::IDBClient::IDBObjectStore::put):
(WebCore::IDBClient::IDBObjectStore::putOrAdd):
* Modules/indexeddb/client/IDBObjectStoreImpl.h:
* Modules/indexeddb/legacy/LegacyObjectStore.cpp:
(WebCore::LegacyObjectStore::add):
(WebCore::LegacyObjectStore::put):
* Modules/indexeddb/legacy/LegacyObjectStore.h:
* bindings/js/IDBBindingUtilities.cpp:
(WebCore::internalCreateIDBKeyFromScriptValueAndKeyPath):
(WebCore::maybeCreateIDBKeyFromScriptValueAndKeyPath):
(WebCore::canInjectIDBKeyIntoScriptValue):
(WebCore::scriptValueToIDBKey):
* bindings/js/IDBBindingUtilities.h:
* bindings/js/JSIDBObjectStoreCustom.cpp:
(WebCore::putOrAdd):
(WebCore::JSIDBObjectStore::putRecord):
(WebCore::JSIDBObjectStore::add):
LayoutTests:
* storage/indexeddb/modern/date-basic-expected.txt: Added.
* storage/indexeddb/modern/date-basic.html: Added.
* storage/indexeddb/modern/get-keyrange-expected.txt:
* storage/indexeddb/modern/get-keyrange.html:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsstorageindexeddbmoderngetkeyrangeexpectedtxt">trunk/LayoutTests/storage/indexeddb/modern/get-keyrange-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstorageindexeddbmoderngetkeyrangehtml">trunk/LayoutTests/storage/indexeddb/modern/get-keyrange.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBObjectStoreh">trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBObjectStoreidl">trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBObjectStoreImplcpp">trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBObjectStoreImplh">trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddblegacyLegacyObjectStorecpp">trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyObjectStore.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddblegacyLegacyObjectStoreh">trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyObjectStore.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsIDBBindingUtilitiescpp">trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsIDBBindingUtilitiesh">trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSIDBObjectStoreCustomcpp">trunk/Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsstorageindexeddbmoderndatebasicexpectedtxt">trunk/LayoutTests/storage/indexeddb/modern/date-basic-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstorageindexeddbmoderndatebasichtml">trunk/LayoutTests/storage/indexeddb/modern/date-basic.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (191849 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-11-01 02:29:47 UTC (rev 191849)
+++ trunk/LayoutTests/ChangeLog        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -1,5 +1,17 @@
</span><span class="cx"> 2015-10-31 Brady Eidson <beidson@apple.com>
</span><span class="cx">
</span><ins>+ IDB: Date objects don't work as keys or values.
+ https://bugs.webkit.org/show_bug.cgi?id=150743
+
+ Reviewed by Darin Adler.
+
+ * storage/indexeddb/modern/date-basic-expected.txt: Added.
+ * storage/indexeddb/modern/date-basic.html: Added.
+ * storage/indexeddb/modern/get-keyrange-expected.txt:
+ * storage/indexeddb/modern/get-keyrange.html:
+
+2015-10-31 Brady Eidson <beidson@apple.com>
+
</ins><span class="cx"> storage/indexeddb/modern/idbdatabase-deleteobjectstore-failures.html is flaky.
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=150735
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmoderndatebasicexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/indexeddb/modern/date-basic-expected.txt (0 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/date-basic-expected.txt         (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/date-basic-expected.txt        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+ALERT: Initial upgrade needed: Old version - 0 New version - 1
+ALERT: Initial upgrade versionchange transaction complete
+ALERT: Success getting key 'Fri Nov 04 1955 17:00:00 GMT-0700 (PDT)' of type object, result is 'Flux capacitor' of type string
+ALERT: Key is a Date object, btw
+ALERT: Success getting key 'Sat Nov 12 1955 10:00:00 GMT-0800 (PST)' of type object, result is 'Fish under the sea' of type string
+ALERT: Key is a Date object, btw
+ALERT: Success getting key 'Wed Oct 21 2015 09:00:00 GMT-0700 (PDT)' of type object, result is 'Hoverboards' of type string
+ALERT: Key is a Date object, btw
+ALERT: Success getting key 'a' of type string, result is 'Fri Nov 04 1955 17:00:00 GMT-0700 (PDT)' of type object
+ALERT: Result is a Date object, btw
+ALERT: Success getting key 'b' of type string, result is 'Sat Nov 12 1955 10:00:00 GMT-0800 (PST)' of type object
+ALERT: Result is a Date object, btw
+ALERT: Success getting key 'c' of type string, result is 'Wed Oct 21 2015 09:00:00 GMT-0700 (PDT)' of type object
+ALERT: Result is a Date object, btw
+ALERT: readonly transaction complete
+ALERT: Done
+This tests using Date objects as keys and values.
</ins></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmoderndatebasichtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/indexeddb/modern/date-basic.html (0 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/date-basic.html         (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/date-basic.html        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -0,0 +1,100 @@
</span><ins>+This tests using Date objects as keys and values.
+<script>
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+function done()
+{
+ alert("Done");
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+var createRequest = window.indexedDB.open("DateBasicDatabase", 1);
+var database;
+
+var date1 = new Date("1955-11-05T00:00:00");
+var date2 = new Date("1955-11-12T18:00:00");
+var date3 = new Date("2015-10-21T16:00:00");
+
+createRequest.onupgradeneeded = function(event) {
+ alert("Initial upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
+
+ var versionTransaction = createRequest.transaction;
+ database = event.target.result;
+ var objectStore = database.createObjectStore("TestObjectStore");
+
+ objectStore.put("Flux capacitor", date1);
+ objectStore.put("Fish under the sea", date2);
+ objectStore.put("Hoverboards", date3);
+
+ objectStore.put(date1, "a");
+ objectStore.put(date2, "b");
+ objectStore.put(date3, "c");
+
+ versionTransaction.onabort = function(event) {
+ alert("Initial upgrade versionchange transaction unexpected aborted");
+ done();
+ }
+
+ versionTransaction.oncomplete = function(event) {
+ alert("Initial upgrade versionchange transaction complete");
+ continueTest1();
+ }
+
+ versionTransaction.onerror = function(event) {
+ alert("Initial upgrade versionchange transaction unexpected error" + event);
+ done();
+ }
+}
+
+var objectStore;
+
+function testGet(key) {
+ var request = objectStore.get(key);
+ request.onsuccess = function()
+ {
+ alert("Success getting key '" + key + "' of type " + typeof(key) + ", result is '" + request.result + "' of type " + typeof(request.result));
+ if (key instanceof Date)
+ alert("Key is a Date object, btw");
+ if (request.result instanceof Date)
+ alert("Result is a Date object, btw");
+ }
+ request.onerror = function()
+ {
+ alert("Expected error getting key '" + key + "'");
+ }
+}
+
+function continueTest1()
+{
+ var transaction = database.transaction("TestObjectStore", "readonly");
+ objectStore = transaction.objectStore("TestObjectStore");
+
+ testGet(date1);
+ testGet(date2);
+ testGet(date3);
+ testGet("a");
+ testGet("b");
+ testGet("c");
+
+ transaction.onabort = function(event) {
+ alert("readonly transaction unexpected abort" + event);
+ done();
+ }
+
+ transaction.oncomplete = function(event) {
+ alert("readonly transaction complete");
+ done();
+ }
+
+ transaction.onerror = function(event) {
+ alert("readonly transaction unexpected error" + event);
+ done();
+ }
+}
+
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmoderngetkeyrangeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/storage/indexeddb/modern/get-keyrange-expected.txt (191849 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/get-keyrange-expected.txt        2015-11-01 02:29:47 UTC (rev 191849)
+++ trunk/LayoutTests/storage/indexeddb/modern/get-keyrange-expected.txt        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -77,11 +77,11 @@
</span><span class="cx"> ALERT: Success getting keyRange [Infinity (Closed), a (Closed)]
</span><span class="cx"> ALERT: Result is PosInf
</span><span class="cx"> ALERT: Success getting keyRange [Infinity (Open), a (Closed)]
</span><del>-ALERT: Result is A
</del><ins>+ALERT: Result is Flux capacitor
</ins><span class="cx"> ALERT: Success getting keyRange [Infinity (Closed), a (Open)]
</span><span class="cx"> ALERT: Result is PosInf
</span><span class="cx"> ALERT: Success getting keyRange [Infinity (Open), a (Open)]
</span><del>-ALERT: Result is A
</del><ins>+ALERT: Result is Flux capacitor
</ins><span class="cx"> ALERT: Success getting keyRange [AS (Closed), a (Closed)]
</span><span class="cx"> ALERT: Result is AS
</span><span class="cx"> ALERT: Success getting keyRange [AS (Open), a (Closed)]
</span><span class="lines">@@ -93,11 +93,35 @@
</span><span class="cx"> ALERT: Success getting keyRange [Infinity (Closed), (Closed)]
</span><span class="cx"> ALERT: Result is PosInf
</span><span class="cx"> ALERT: Success getting keyRange [Infinity (Open), (Closed)]
</span><del>-ALERT: Result is A
</del><ins>+ALERT: Result is Flux capacitor
</ins><span class="cx"> ALERT: Success getting keyRange [Infinity (Closed), (Open)]
</span><span class="cx"> ALERT: Result is PosInf
</span><span class="cx"> ALERT: Success getting keyRange [Infinity (Open), (Open)]
</span><del>-ALERT: Result is A
</del><ins>+ALERT: Result is Flux capacitor
+ALERT: Success getting keyRange [Infinity (Closed), a (Closed)]
+ALERT: Result is PosInf
+ALERT: Success getting keyRange [Infinity (Open), a (Closed)]
+ALERT: Result is Flux capacitor
+ALERT: Success getting keyRange [Infinity (Closed), a (Open)]
+ALERT: Result is PosInf
+ALERT: Success getting keyRange [Infinity (Open), a (Open)]
+ALERT: Result is Flux capacitor
+ALERT: Success getting keyRange [Infinity (Closed), a (Closed)]
+ALERT: Result is PosInf
+ALERT: Success getting keyRange [Infinity (Open), a (Closed)]
+ALERT: Result is Flux capacitor
+ALERT: Success getting keyRange [Infinity (Closed), a (Open)]
+ALERT: Result is PosInf
+ALERT: Success getting keyRange [Infinity (Open), a (Open)]
+ALERT: Result is Flux capacitor
+ALERT: Success getting keyRange [Fri Nov 04 1955 17:00:00 GMT-0700 (PDT) (Closed), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Closed)]
+ALERT: Result is Flux capacitor
+ALERT: Success getting keyRange [Fri Nov 04 1955 17:00:00 GMT-0700 (PDT) (Open), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Closed)]
+ALERT: Result is Fish under the sea
+ALERT: Success getting keyRange [Fri Nov 04 1955 17:00:00 GMT-0700 (PDT) (Closed), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Open)]
+ALERT: Result is Flux capacitor
+ALERT: Success getting keyRange [Fri Nov 04 1955 17:00:00 GMT-0700 (PDT) (Open), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Open)]
+ALERT: Result is Fish under the sea
</ins><span class="cx"> ALERT: readonly transaction complete
</span><span class="cx"> ALERT: Done
</span><span class="cx"> This test exercises IDBObjectStore.get() with an IDBKeyRange as the parameter.
</span></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmoderngetkeyrangehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/storage/indexeddb/modern/get-keyrange.html (191849 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/get-keyrange.html        2015-11-01 02:29:47 UTC (rev 191849)
+++ trunk/LayoutTests/storage/indexeddb/modern/get-keyrange.html        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -16,12 +16,21 @@
</span><span class="cx"> var createRequest = window.indexedDB.open("GetKeyRangeDatabase", 1);
</span><span class="cx"> var database;
</span><span class="cx">
</span><ins>+var date1 = new Date("1955-11-05T00:00:00");
+var date2 = new Date("1955-11-12T18:00:00");
+var date3 = new Date("2015-10-21T16:00:00");
+
</ins><span class="cx"> createRequest.onupgradeneeded = function(event) {
</span><span class="cx"> alert("Initial upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
</span><span class="cx">
</span><span class="cx"> var versionTransaction = createRequest.transaction;
</span><span class="cx"> database = event.target.result;
</span><span class="cx"> var objectStore = database.createObjectStore("TestObjectStore");
</span><ins>+
+ objectStore.put("Flux capacitor", date1);
+ objectStore.put("Fish under the sea", date2);
+ objectStore.put("Hoverboards", date3);
+
</ins><span class="cx"> for (var i = 0; i < 100; ++i)
</span><span class="cx"> objectStore.put("\"" + i + "\"", i);
</span><span class="cx">
</span><span class="lines">@@ -127,6 +136,21 @@
</span><span class="cx"> testGet(IDBKeyRange.bound(Infinity, [], true));
</span><span class="cx"> testGet(IDBKeyRange.bound(Infinity, [], false, true));
</span><span class="cx"> testGet(IDBKeyRange.bound(Infinity, [], true, true));
</span><ins>+
+ testGet(IDBKeyRange.bound(Infinity, "a"));
+ testGet(IDBKeyRange.bound(Infinity, "a", true));
+ testGet(IDBKeyRange.bound(Infinity, "a", false, true));
+ testGet(IDBKeyRange.bound(Infinity, "a", true, true));
+
+ testGet(IDBKeyRange.bound(Infinity, "a"));
+ testGet(IDBKeyRange.bound(Infinity, "a", true));
+ testGet(IDBKeyRange.bound(Infinity, "a", false, true));
+ testGet(IDBKeyRange.bound(Infinity, "a", true, true));
+
+ testGet(IDBKeyRange.bound(date1, date3));
+ testGet(IDBKeyRange.bound(date1, date3, true));
+ testGet(IDBKeyRange.bound(date1, date3, false, true));
+ testGet(IDBKeyRange.bound(date1, date3, true, true));
</ins><span class="cx">
</span><span class="cx"> transaction.onabort = function(event) {
</span><span class="cx"> alert("readonly transaction unexpected abort" + event);
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (191849 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-11-01 02:29:47 UTC (rev 191849)
+++ trunk/Source/WebCore/ChangeLog        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -1,3 +1,46 @@
</span><ins>+2015-10-31 Brady Eidson <beidson@apple.com>
+
+ IDB: Date objects don't work as keys or values.
+ https://bugs.webkit.org/show_bug.cgi?id=150743
+
+ Reviewed by Darin Adler.
+
+ Test: storage/indexeddb/modern/date-basic.html
+
+ The combination of the autogenerated bindings with Deprecated::ScriptValue was
+ losing the fidelity of "Date" objects being Dates, and not just normal Objects.
+
+ This was breaking their usage as IDBKeys.
+
+ Custom binding + reworking the IDBObjectStore IDLs to use JSValue instead of ScriptValue
+ fixes this handily.
+
+ * Modules/indexeddb/IDBObjectStore.h:
+ * Modules/indexeddb/IDBObjectStore.idl:
+
+ * Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
+ (WebCore::IDBClient::IDBObjectStore::add):
+ (WebCore::IDBClient::IDBObjectStore::put):
+ (WebCore::IDBClient::IDBObjectStore::putOrAdd):
+ * Modules/indexeddb/client/IDBObjectStoreImpl.h:
+
+ * Modules/indexeddb/legacy/LegacyObjectStore.cpp:
+ (WebCore::LegacyObjectStore::add):
+ (WebCore::LegacyObjectStore::put):
+ * Modules/indexeddb/legacy/LegacyObjectStore.h:
+
+ * bindings/js/IDBBindingUtilities.cpp:
+ (WebCore::internalCreateIDBKeyFromScriptValueAndKeyPath):
+ (WebCore::maybeCreateIDBKeyFromScriptValueAndKeyPath):
+ (WebCore::canInjectIDBKeyIntoScriptValue):
+ (WebCore::scriptValueToIDBKey):
+ * bindings/js/IDBBindingUtilities.h:
+
+ * bindings/js/JSIDBObjectStoreCustom.cpp:
+ (WebCore::putOrAdd):
+ (WebCore::JSIDBObjectStore::putRecord):
+ (WebCore::JSIDBObjectStore::add):
+
</ins><span class="cx"> 2015-10-31 Andreas Kling <akling@apple.com>
</span><span class="cx">
</span><span class="cx"> Add a debug overlay with information about web process resource usage.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBObjectStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h (191849 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h        2015-11-01 02:29:47 UTC (rev 191849)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="cx"> class ExecState;
</span><ins>+class JSValue;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -66,8 +67,8 @@
</span><span class="cx"> virtual RefPtr<IDBTransaction> transaction() = 0;
</span><span class="cx"> virtual bool autoIncrement() const = 0;
</span><span class="cx">
</span><del>- virtual RefPtr<IDBRequest> add(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&) = 0;
- virtual RefPtr<IDBRequest> put(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&) = 0;
</del><ins>+ virtual RefPtr<IDBRequest> add(JSC::ExecState&, JSC::JSValue, ExceptionCode&) = 0;
+ virtual RefPtr<IDBRequest> put(JSC::ExecState&, JSC::JSValue, ExceptionCode&) = 0;
</ins><span class="cx"> virtual RefPtr<IDBRequest> openCursor(ScriptExecutionContext*, ExceptionCode&) = 0;
</span><span class="cx"> virtual RefPtr<IDBRequest> openCursor(ScriptExecutionContext*, IDBKeyRange*, ExceptionCode&) = 0;
</span><span class="cx"> virtual RefPtr<IDBRequest> openCursor(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) = 0;
</span><span class="lines">@@ -76,8 +77,8 @@
</span><span class="cx">
</span><span class="cx"> virtual RefPtr<IDBRequest> get(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) = 0;
</span><span class="cx"> virtual RefPtr<IDBRequest> get(ScriptExecutionContext*, IDBKeyRange*, ExceptionCode&) = 0;
</span><del>- virtual RefPtr<IDBRequest> add(JSC::ExecState&, Deprecated::ScriptValue&, const Deprecated::ScriptValue& key, ExceptionCode&) = 0;
- virtual RefPtr<IDBRequest> put(JSC::ExecState&, Deprecated::ScriptValue&, const Deprecated::ScriptValue& key, ExceptionCode&) = 0;
</del><ins>+ virtual RefPtr<IDBRequest> add(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCode&) = 0;
+ virtual RefPtr<IDBRequest> put(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCode&) = 0;
</ins><span class="cx"> virtual RefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, IDBKeyRange*, ExceptionCode&) = 0;
</span><span class="cx"> virtual RefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) = 0;
</span><span class="cx"> virtual RefPtr<IDBRequest> clear(ScriptExecutionContext*, ExceptionCode&) = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBObjectStoreidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl (191849 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl        2015-11-01 02:29:47 UTC (rev 191849)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -34,8 +34,8 @@
</span><span class="cx"> readonly attribute IDBTransaction transaction;
</span><span class="cx"> readonly attribute boolean autoIncrement;
</span><span class="cx">
</span><del>- [CallWith=ScriptState, RaisesException] IDBRequest put(any value, optional any key);
- [CallWith=ScriptState, RaisesException] IDBRequest add(any value, optional any key);
</del><ins>+ [CallWith=ScriptExecutionContext, Custom, ImplementedAs=putFunction, RaisesException] IDBRequest put(any value, optional any key);
+ [CallWith=ScriptExecutionContext, Custom, RaisesException] IDBRequest add(any value, optional any key);
</ins><span class="cx"> [CallWith=ScriptExecutionContext, ImplementedAs=deleteFunction, RaisesException] IDBRequest delete(IDBKeyRange? keyRange);
</span><span class="cx"> [CallWith=ScriptExecutionContext, ImplementedAs=deleteFunction, RaisesException] IDBRequest delete(any key);
</span><span class="cx"> [CallWith=ScriptExecutionContext, RaisesException] IDBRequest get(IDBKeyRange? key);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBObjectStoreImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp (191849 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp        2015-11-01 02:29:47 UTC (rev 191849)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -87,16 +87,6 @@
</span><span class="cx"> return m_info.autoIncrement();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<WebCore::IDBRequest> IDBObjectStore::add(JSC::ExecState& state, Deprecated::ScriptValue& value, ExceptionCode& ec)
-{
- return putOrAdd(state, value, nullptr, IndexedDB::ObjectStoreOverwriteMode::NoOverwrite, ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::put(JSC::ExecState& state, Deprecated::ScriptValue& value, ExceptionCode& ec)
-{
- return putOrAdd(state, value, nullptr, IndexedDB::ObjectStoreOverwriteMode::Overwrite, ec);
-}
-
</del><span class="cx"> RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext*, ExceptionCode&)
</span><span class="cx"> {
</span><span class="cx"> RELEASE_ASSERT_NOT_REACHED();
</span><span class="lines">@@ -183,20 +173,30 @@
</span><span class="cx"> return WTF::move(request);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<WebCore::IDBRequest> IDBObjectStore::add(JSC::ExecState& execState, Deprecated::ScriptValue& value, const Deprecated::ScriptValue& key, ExceptionCode& ec)
</del><ins>+RefPtr<WebCore::IDBRequest> IDBObjectStore::add(JSC::ExecState& state, JSC::JSValue value, ExceptionCode& ec)
</ins><span class="cx"> {
</span><ins>+ return putOrAdd(state, value, nullptr, IndexedDB::ObjectStoreOverwriteMode::NoOverwrite, ec);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::add(JSC::ExecState& execState, JSC::JSValue value, JSC::JSValue key, ExceptionCode& ec)
+{
</ins><span class="cx"> auto idbKey = scriptValueToIDBKey(execState, key);
</span><span class="cx"> return putOrAdd(execState, value, idbKey, IndexedDB::ObjectStoreOverwriteMode::NoOverwrite, ec);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<WebCore::IDBRequest> IDBObjectStore::put(JSC::ExecState& execState, Deprecated::ScriptValue& value, const Deprecated::ScriptValue& key, ExceptionCode& ec)
</del><ins>+RefPtr<WebCore::IDBRequest> IDBObjectStore::put(JSC::ExecState& execState, JSC::JSValue value, JSC::JSValue key, ExceptionCode& ec)
</ins><span class="cx"> {
</span><span class="cx"> auto idbKey = scriptValueToIDBKey(execState, key);
</span><span class="cx"> return putOrAdd(execState, value, idbKey, IndexedDB::ObjectStoreOverwriteMode::Overwrite, ec);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<WebCore::IDBRequest> IDBObjectStore::putOrAdd(JSC::ExecState& state, Deprecated::ScriptValue& value, RefPtr<IDBKey> key, IndexedDB::ObjectStoreOverwriteMode overwriteMode, ExceptionCode& ec)
</del><ins>+RefPtr<WebCore::IDBRequest> IDBObjectStore::put(JSC::ExecState& state, JSC::JSValue value, ExceptionCode& ec)
</ins><span class="cx"> {
</span><ins>+ return putOrAdd(state, value, nullptr, IndexedDB::ObjectStoreOverwriteMode::Overwrite, ec);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::putOrAdd(JSC::ExecState& state, JSC::JSValue value, RefPtr<IDBKey> key, IndexedDB::ObjectStoreOverwriteMode overwriteMode, ExceptionCode& ec)
+{
</ins><span class="cx"> LOG(IndexedDB, "IDBObjectStore::putOrAdd");
</span><span class="cx">
</span><span class="cx"> if (m_transaction->isReadOnly()) {
</span><span class="lines">@@ -214,7 +214,7 @@
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(&state, value.jsValue(), nullptr, nullptr);
</del><ins>+ RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(&state, value, nullptr, nullptr);
</ins><span class="cx"> if (state.hadException()) {
</span><span class="cx"> ec = DATA_CLONE_ERR;
</span><span class="cx"> return nullptr;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBObjectStoreImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h (191849 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h        2015-11-01 02:29:47 UTC (rev 191849)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -54,8 +54,8 @@
</span><span class="cx"> virtual RefPtr<WebCore::IDBTransaction> transaction() override final;
</span><span class="cx"> virtual bool autoIncrement() const override final;
</span><span class="cx">
</span><del>- virtual RefPtr<WebCore::IDBRequest> add(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&) override final;
- virtual RefPtr<WebCore::IDBRequest> put(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&) override final;
</del><ins>+ virtual RefPtr<WebCore::IDBRequest> add(JSC::ExecState&, JSC::JSValue, ExceptionCode&) override final;
+ virtual RefPtr<WebCore::IDBRequest> put(JSC::ExecState&, JSC::JSValue, ExceptionCode&) override final;
</ins><span class="cx"> virtual RefPtr<WebCore::IDBRequest> openCursor(ScriptExecutionContext*, ExceptionCode&) override final;
</span><span class="cx"> virtual RefPtr<WebCore::IDBRequest> openCursor(ScriptExecutionContext*, IDBKeyRange*, ExceptionCode&) override final;
</span><span class="cx"> virtual RefPtr<WebCore::IDBRequest> openCursor(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) override final;
</span><span class="lines">@@ -63,8 +63,8 @@
</span><span class="cx"> virtual RefPtr<WebCore::IDBRequest> openCursor(ScriptExecutionContext*, const Deprecated::ScriptValue& key, const String& direction, ExceptionCode&) override final;
</span><span class="cx"> virtual RefPtr<WebCore::IDBRequest> get(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) override final;
</span><span class="cx"> virtual RefPtr<WebCore::IDBRequest> get(ScriptExecutionContext*, IDBKeyRange*, ExceptionCode&) override final;
</span><del>- virtual RefPtr<WebCore::IDBRequest> add(JSC::ExecState&, Deprecated::ScriptValue&, const Deprecated::ScriptValue& key, ExceptionCode&) override final;
- virtual RefPtr<WebCore::IDBRequest> put(JSC::ExecState&, Deprecated::ScriptValue&, const Deprecated::ScriptValue& key, ExceptionCode&) override final;
</del><ins>+ virtual RefPtr<WebCore::IDBRequest> add(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCode&) override final;
+ virtual RefPtr<WebCore::IDBRequest> put(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCode&) override final;
</ins><span class="cx"> virtual RefPtr<WebCore::IDBRequest> deleteFunction(ScriptExecutionContext*, IDBKeyRange*, ExceptionCode&) override final;
</span><span class="cx"> virtual RefPtr<WebCore::IDBRequest> deleteFunction(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) override final;
</span><span class="cx"> virtual RefPtr<WebCore::IDBRequest> clear(ScriptExecutionContext*, ExceptionCode&) override final;
</span><span class="lines">@@ -82,7 +82,7 @@
</span><span class="cx"> private:
</span><span class="cx"> IDBObjectStore(const IDBObjectStoreInfo&, IDBTransaction&);
</span><span class="cx">
</span><del>- RefPtr<WebCore::IDBRequest> putOrAdd(JSC::ExecState&, Deprecated::ScriptValue&, RefPtr<IDBKey>, IndexedDB::ObjectStoreOverwriteMode, ExceptionCode&);
</del><ins>+ RefPtr<WebCore::IDBRequest> putOrAdd(JSC::ExecState&, JSC::JSValue, RefPtr<IDBKey>, IndexedDB::ObjectStoreOverwriteMode, ExceptionCode&);
</ins><span class="cx">
</span><span class="cx"> IDBObjectStoreInfo m_info;
</span><span class="cx"> Ref<IDBTransaction> m_transaction;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddblegacyLegacyObjectStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyObjectStore.cpp (191849 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyObjectStore.cpp        2015-11-01 02:29:47 UTC (rev 191849)
+++ trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyObjectStore.cpp        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -96,28 +96,33 @@
</span><span class="cx"> return get(context, keyRange.get(), ec);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<IDBRequest> LegacyObjectStore::add(JSC::ExecState& state, Deprecated::ScriptValue& value, const Deprecated::ScriptValue& key, ExceptionCode& ec)
</del><ins>+RefPtr<IDBRequest> LegacyObjectStore::add(JSC::ExecState& state, JSC::JSValue value, JSC::JSValue key, ExceptionCode& ec)
</ins><span class="cx"> {
</span><span class="cx"> LOG(StorageAPI, "LegacyObjectStore::add");
</span><del>- return put(IDBDatabaseBackend::AddOnly, LegacyAny::create(this), state, value, key, ec);
</del><ins>+ auto deprecatedValue = Deprecated::ScriptValue(state.vm(), value);
+ auto dKey = Deprecated::ScriptValue(state.vm(), key);
+ return put(IDBDatabaseBackend::AddOnly, LegacyAny::create(this), state, deprecatedValue, dKey, ec);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<IDBRequest> LegacyObjectStore::add(JSC::ExecState& state, Deprecated::ScriptValue& value, ExceptionCode& ec)
</del><ins>+RefPtr<IDBRequest> LegacyObjectStore::add(JSC::ExecState& state, JSC::JSValue value, ExceptionCode& ec)
</ins><span class="cx"> {
</span><span class="cx"> LOG(StorageAPI, "LegacyObjectStore::add");
</span><del>- return put(IDBDatabaseBackend::AddOnly, LegacyAny::create(this), state, value, static_cast<IDBKey*>(nullptr), ec);
</del><ins>+ auto deprecatedValue = Deprecated::ScriptValue(state.vm(), value);
+ return put(IDBDatabaseBackend::AddOnly, LegacyAny::create(this), state, deprecatedValue, static_cast<IDBKey*>(nullptr), ec);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<IDBRequest> LegacyObjectStore::put(JSC::ExecState& state, Deprecated::ScriptValue& value, const Deprecated::ScriptValue& key, ExceptionCode& ec)
</del><ins>+RefPtr<IDBRequest> LegacyObjectStore::put(JSC::ExecState& state, JSC::JSValue value, JSC::JSValue key, ExceptionCode& ec)
</ins><span class="cx"> {
</span><span class="cx"> LOG(StorageAPI, "LegacyObjectStore::put");
</span><del>- return put(IDBDatabaseBackend::AddOrUpdate, LegacyAny::create(this), state, value, key, ec);
</del><ins>+ auto deprecatedValue = Deprecated::ScriptValue(state.vm(), value);
+ return put(IDBDatabaseBackend::AddOrUpdate, LegacyAny::create(this), state, deprecatedValue, Deprecated::ScriptValue(state.vm(), key), ec);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<IDBRequest> LegacyObjectStore::put(JSC::ExecState& state, Deprecated::ScriptValue& value, ExceptionCode& ec)
</del><ins>+RefPtr<IDBRequest> LegacyObjectStore::put(JSC::ExecState& state, JSC::JSValue value, ExceptionCode& ec)
</ins><span class="cx"> {
</span><span class="cx"> LOG(StorageAPI, "LegacyObjectStore::put");
</span><del>- return put(IDBDatabaseBackend::AddOrUpdate, LegacyAny::create(this), state, value, static_cast<IDBKey*>(nullptr), ec);
</del><ins>+ auto deprecatedValue = Deprecated::ScriptValue(state.vm(), value);
+ return put(IDBDatabaseBackend::AddOrUpdate, LegacyAny::create(this), state, deprecatedValue, static_cast<IDBKey*>(nullptr), ec);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RefPtr<IDBRequest> LegacyObjectStore::put(IDBDatabaseBackend::PutMode putMode, RefPtr<LegacyAny> source, JSC::ExecState& state, Deprecated::ScriptValue& value, const Deprecated::ScriptValue& keyValue, ExceptionCode& ec)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddblegacyLegacyObjectStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyObjectStore.h (191849 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyObjectStore.h        2015-11-01 02:29:47 UTC (rev 191849)
+++ trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyObjectStore.h        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -67,8 +67,8 @@
</span><span class="cx"> RefPtr<IDBTransaction> transaction() { return m_transaction; }
</span><span class="cx"> bool autoIncrement() const { return m_metadata.autoIncrement; }
</span><span class="cx">
</span><del>- RefPtr<IDBRequest> add(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&);
- RefPtr<IDBRequest> put(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&);
</del><ins>+ RefPtr<IDBRequest> add(JSC::ExecState&, JSC::JSValue, ExceptionCode&);
+ RefPtr<IDBRequest> put(JSC::ExecState&, JSC::JSValue, ExceptionCode&);
</ins><span class="cx"> RefPtr<IDBRequest> openCursor(ScriptExecutionContext*, ExceptionCode&);
</span><span class="cx"> RefPtr<IDBRequest> openCursor(ScriptExecutionContext*, IDBKeyRange*, ExceptionCode&);
</span><span class="cx"> RefPtr<IDBRequest> openCursor(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&);
</span><span class="lines">@@ -78,8 +78,8 @@
</span><span class="cx">
</span><span class="cx"> RefPtr<IDBRequest> get(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&);
</span><span class="cx"> RefPtr<IDBRequest> get(ScriptExecutionContext*, IDBKeyRange*, ExceptionCode&);
</span><del>- RefPtr<IDBRequest> add(JSC::ExecState&, Deprecated::ScriptValue&, const Deprecated::ScriptValue& key, ExceptionCode&);
- RefPtr<IDBRequest> put(JSC::ExecState&, Deprecated::ScriptValue&, const Deprecated::ScriptValue& key, ExceptionCode&);
</del><ins>+ RefPtr<IDBRequest> add(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCode&);
+ RefPtr<IDBRequest> put(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCode&);
</ins><span class="cx"> RefPtr<IDBRequest> put(IDBDatabaseBackend::PutMode, RefPtr<LegacyAny>, JSC::ExecState&, Deprecated::ScriptValue&, RefPtr<IDBKey>, ExceptionCode&);
</span><span class="cx"> RefPtr<IDBRequest> put(IDBDatabaseBackend::PutMode, RefPtr<LegacyAny> source, JSC::ExecState&, Deprecated::ScriptValue&, const Deprecated::ScriptValue& key, ExceptionCode&);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsIDBBindingUtilitiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp (191849 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp        2015-11-01 02:29:47 UTC (rev 191849)
+++ trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -185,14 +185,14 @@
</span><span class="cx"> return currentValue;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static RefPtr<IDBKey> internalCreateIDBKeyFromScriptValueAndKeyPath(ExecState* exec, const Deprecated::ScriptValue& value, const String& keyPath)
</del><ins>+static RefPtr<IDBKey> internalCreateIDBKeyFromScriptValueAndKeyPath(ExecState* exec, const JSC::JSValue& value, const String& keyPath)
</ins><span class="cx"> {
</span><span class="cx"> Vector<String> keyPathElements;
</span><span class="cx"> IDBKeyPathParseError error;
</span><span class="cx"> IDBParseKeyPath(keyPath, keyPathElements, error);
</span><span class="cx"> ASSERT(error == IDBKeyPathParseError::None);
</span><span class="cx">
</span><del>- JSValue jsValue = value.jsValue();
</del><ins>+ JSValue jsValue = value;
</ins><span class="cx"> jsValue = getNthValueOnKeyPath(exec, jsValue, keyPathElements, keyPathElements.size());
</span><span class="cx"> if (jsValue.isUndefined())
</span><span class="cx"> return nullptr;
</span><span class="lines">@@ -302,8 +302,29 @@
</span><span class="cx"> return internalCreateIDBKeyFromScriptValueAndKeyPath(&exec, value, keyPath.string());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool canInjectIDBKeyIntoScriptValue(DOMRequestState* requestState, const Deprecated::ScriptValue& scriptValue, const IDBKeyPath& keyPath)
</del><ins>+RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(ExecState& exec, const JSC::JSValue& value, const IDBKeyPath& keyPath)
</ins><span class="cx"> {
</span><ins>+ ASSERT(!keyPath.isNull());
+
+ if (keyPath.type() == IndexedDB::KeyPathType::Array) {
+ const Vector<String>& array = keyPath.array();
+ Vector<RefPtr<IDBKey>> result;
+ result.reserveInitialCapacity(array.size());
+ for (auto& string : array) {
+ RefPtr<IDBKey> key = internalCreateIDBKeyFromScriptValueAndKeyPath(&exec, value, string);
+ if (!key)
+ return nullptr;
+ result.uncheckedAppend(WTF::move(key));
+ }
+ return IDBKey::createArray(WTF::move(result));
+ }
+
+ ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
+ return internalCreateIDBKeyFromScriptValueAndKeyPath(&exec, value, keyPath.string());
+}
+
+bool canInjectIDBKeyIntoScriptValue(DOMRequestState* requestState, const JSC::JSValue& scriptValue, const IDBKeyPath& keyPath)
+{
</ins><span class="cx"> LOG(StorageAPI, "canInjectIDBKeyIntoScriptValue");
</span><span class="cx">
</span><span class="cx"> JSC::ExecState* exec = requestState->exec();
</span><span class="lines">@@ -313,7 +334,7 @@
</span><span class="cx"> return canInjectIDBKeyIntoScriptValue(*exec, scriptValue, keyPath);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool canInjectIDBKeyIntoScriptValue(JSC::ExecState& execState, const Deprecated::ScriptValue& scriptValue, const IDBKeyPath& keyPath)
</del><ins>+bool canInjectIDBKeyIntoScriptValue(JSC::ExecState& execState, const JSC::JSValue& scriptValue, const IDBKeyPath& keyPath)
</ins><span class="cx"> {
</span><span class="cx"> LOG(StorageAPI, "canInjectIDBKeyIntoScriptValue");
</span><span class="cx">
</span><span class="lines">@@ -326,7 +347,7 @@
</span><span class="cx"> if (!keyPathElements.size())
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- return canInjectNthValueOnKeyPath(&execState, scriptValue.jsValue(), keyPathElements, keyPathElements.size() - 1);
</del><ins>+ return canInjectNthValueOnKeyPath(&execState, scriptValue, keyPathElements, keyPathElements.size() - 1);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Deprecated::ScriptValue deserializeIDBValue(DOMRequestState* requestState, PassRefPtr<SerializedScriptValue> prpValue)
</span><span class="lines">@@ -402,15 +423,15 @@
</span><span class="cx"> return Deprecated::ScriptValue(exec->vm(), idbKeyToJSValue(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), key.get()));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<IDBKey> scriptValueToIDBKey(DOMRequestState* requestState, const Deprecated::ScriptValue& scriptValue)
</del><ins>+RefPtr<IDBKey> scriptValueToIDBKey(DOMRequestState* requestState, const JSC::JSValue& scriptValue)
</ins><span class="cx"> {
</span><span class="cx"> ExecState* exec = requestState->exec();
</span><del>- return createIDBKeyFromValue(exec, scriptValue.jsValue());
</del><ins>+ return createIDBKeyFromValue(exec, scriptValue);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<IDBKey> scriptValueToIDBKey(ExecState& exec, const Deprecated::ScriptValue& scriptValue)
</del><ins>+RefPtr<IDBKey> scriptValueToIDBKey(ExecState& exec, const JSC::JSValue& scriptValue)
</ins><span class="cx"> {
</span><del>- return createIDBKeyFromValue(&exec, scriptValue.jsValue());
</del><ins>+ return createIDBKeyFromValue(&exec, scriptValue);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void generateIndexKeysForValue(ExecState* exec, const IDBIndexMetadata& indexMetadata, const Deprecated::ScriptValue& objectValue, Vector<IDBKeyData>& indexKeys)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsIDBBindingUtilitiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h (191849 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h        2015-11-01 02:29:47 UTC (rev 191849)
+++ trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -49,17 +49,18 @@
</span><span class="cx">
</span><span class="cx"> RefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(JSC::ExecState*, const Deprecated::ScriptValue&, const IDBKeyPath&);
</span><span class="cx"> RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(JSC::ExecState&, const Deprecated::ScriptValue&, const IDBKeyPath&);
</span><ins>+RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(JSC::ExecState&, const JSC::JSValue&, const IDBKeyPath&);
</ins><span class="cx">
</span><del>-bool canInjectIDBKeyIntoScriptValue(DOMRequestState*, const Deprecated::ScriptValue&, const IDBKeyPath&);
-bool canInjectIDBKeyIntoScriptValue(JSC::ExecState&, const Deprecated::ScriptValue&, const IDBKeyPath&);
</del><ins>+bool canInjectIDBKeyIntoScriptValue(DOMRequestState*, const JSC::JSValue&, const IDBKeyPath&);
+bool canInjectIDBKeyIntoScriptValue(JSC::ExecState&, const JSC::JSValue&, const IDBKeyPath&);
</ins><span class="cx">
</span><span class="cx"> Deprecated::ScriptValue deserializeIDBValue(DOMRequestState*, PassRefPtr<SerializedScriptValue>);
</span><span class="cx"> Deprecated::ScriptValue deserializeIDBValueData(ScriptExecutionContext&, const ThreadSafeDataBuffer& valueData);
</span><span class="cx"> Deprecated::ScriptValue deserializeIDBValueBuffer(DOMRequestState*, PassRefPtr<SharedBuffer>, bool keyIsDefined);
</span><span class="cx"> WEBCORE_EXPORT Deprecated::ScriptValue deserializeIDBValueBuffer(JSC::ExecState*, const Vector<uint8_t>&, bool keyIsDefined);
</span><span class="cx"> Deprecated::ScriptValue idbKeyToScriptValue(DOMRequestState*, PassRefPtr<IDBKey>);
</span><del>-RefPtr<IDBKey> scriptValueToIDBKey(DOMRequestState*, const Deprecated::ScriptValue&);
-RefPtr<IDBKey> scriptValueToIDBKey(JSC::ExecState&, const Deprecated::ScriptValue&);
</del><ins>+RefPtr<IDBKey> scriptValueToIDBKey(DOMRequestState*, const JSC::JSValue&);
+RefPtr<IDBKey> scriptValueToIDBKey(JSC::ExecState&, const JSC::JSValue&);
</ins><span class="cx"> WEBCORE_EXPORT void generateIndexKeysForValue(JSC::ExecState*, const IDBIndexMetadata&, const Deprecated::ScriptValue& objectValue, Vector<IDBKeyData>& indexKeys);
</span><span class="cx">
</span><span class="cx"> Deprecated::ScriptValue idbKeyDataToScriptValue(ScriptExecutionContext*, const IDBKeyData&);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSIDBObjectStoreCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp (191849 => 191850)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp        2015-11-01 02:29:47 UTC (rev 191849)
+++ trunk/Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp        2015-11-01 04:34:49 UTC (rev 191850)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include "IDBObjectStore.h"
</span><span class="cx"> #include "JSDOMBinding.h"
</span><span class="cx"> #include "JSIDBIndex.h"
</span><ins>+#include "JSIDBRequest.h"
</ins><span class="cx"> #include <runtime/Error.h>
</span><span class="cx"> #include <runtime/JSString.h>
</span><span class="cx">
</span><span class="lines">@@ -43,6 +44,55 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+static JSValue putOrAdd(JSC::ExecState& state, bool overwrite)
+{
+ JSValue thisValue = state.thisValue();
+ JSIDBObjectStore* castedThis = jsDynamicCast<JSIDBObjectStore*>(thisValue);
+ if (UNLIKELY(!castedThis))
+ return JSValue::decode(throwThisTypeError(state, "IDBObjectStore", "put"));
+
+ ASSERT_GC_OBJECT_INHERITS(castedThis, JSIDBObjectStore::info());
+ auto& impl = castedThis->impl();
+
+ size_t argsCount = state.argumentCount();
+ if (UNLIKELY(argsCount < 1))
+ return JSValue::decode(throwVMError(&state, createNotEnoughArgumentsError(&state)));
+
+ ExceptionCode ec = 0;
+ auto value = state.uncheckedArgument(0);
+
+ if (argsCount == 1) {
+ JSValue result;
+ if (overwrite)
+ result = toJS(&state, castedThis->globalObject(), impl.put(state, value, ec).get());
+ else
+ result = toJS(&state, castedThis->globalObject(), impl.add(state, value, ec).get());
+
+ setDOMException(&state, ec);
+ return result;
+ }
+
+ auto key = state.uncheckedArgument(1);
+ JSValue result;
+ if (overwrite)
+ result = toJS(&state, castedThis->globalObject(), impl.put(state, value, key, ec).get());
+ else
+ result = toJS(&state, castedThis->globalObject(), impl.add(state, value, key, ec).get());
+
+ setDOMException(&state, ec);
+ return result;
+}
+
+JSValue JSIDBObjectStore::putFunction(JSC::ExecState& state)
+{
+ return putOrAdd(state, true);
+}
+
+JSValue JSIDBObjectStore::add(JSC::ExecState& state)
+{
+ return putOrAdd(state, false);
+}
+
</ins><span class="cx"> JSValue JSIDBObjectStore::createIndex(ExecState& state)
</span><span class="cx"> {
</span><span class="cx"> ScriptExecutionContext* context = jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())->scriptExecutionContext();
</span></span></pre>
</div>
</div>
</body>
</html>