Title: [246770] trunk
Revision
246770
Author
[email protected]
Date
2019-06-24 16:45:41 -0700 (Mon, 24 Jun 2019)

Log Message

REGRESSION (r244436): IndexedDB Uint8Array returned as ArrayBuffer
https://bugs.webkit.org/show_bug.cgi?id=198738
<rdar://problem/51614053>

Reviewed by Brady Eidson.

In InexedDB, two binary keys are the same as long as their data is the same.

Modified tests: storage/indexeddb/key-type-binary.html
                storage/indexeddb/key-type-binary-private.html

* bindings/js/IDBBindingUtilities.cpp:
(WebCore::injectIDBKeyIntoScriptValue):
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneDeserializer::readArrayBufferView):

Modified Paths

Diff

Modified: trunk/LayoutTests/storage/indexeddb/key-type-binary-expected.txt (246769 => 246770)


--- trunk/LayoutTests/storage/indexeddb/key-type-binary-expected.txt	2019-06-24 23:37:35 UTC (rev 246769)
+++ trunk/LayoutTests/storage/indexeddb/key-type-binary-expected.txt	2019-06-24 23:45:41 UTC (rev 246770)
@@ -8,6 +8,7 @@
 indexedDB.deleteDatabase(dbname)
 indexedDB.open(dbname)
 db.createObjectStore('store');
+db.createObjectStore('storeWithKeyPath', {keyPath: 'binary'});
 
 
 testBinaryKeys1():
@@ -53,6 +54,60 @@
 store.put('value', new Uint8Array([1,2,3]).buffer)
 
 store.put('value', new DataView(new Uint8Array([1,2,3]).buffer))
+
+testBinaryKeys3():
+trans = db.transaction('storeWithKeyPath', 'readwrite')
+store = trans.objectStore('storeWithKeyPath')
+
+binary = new Uint8ClampedArray([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Uint16Array([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Uint32Array([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Int8Array([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Int16Array([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Int32Array([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Float32Array([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Float64Array([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Uint8Array([1,2,3]).buffer
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new DataView(new Uint8Array([1,2,3]).buffer)
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/storage/indexeddb/key-type-binary-private-expected.txt (246769 => 246770)


--- trunk/LayoutTests/storage/indexeddb/key-type-binary-private-expected.txt	2019-06-24 23:37:35 UTC (rev 246769)
+++ trunk/LayoutTests/storage/indexeddb/key-type-binary-private-expected.txt	2019-06-24 23:45:41 UTC (rev 246770)
@@ -8,6 +8,7 @@
 indexedDB.deleteDatabase(dbname)
 indexedDB.open(dbname)
 db.createObjectStore('store');
+db.createObjectStore('storeWithKeyPath', {keyPath: 'binary'});
 
 
 testBinaryKeys1():
@@ -53,6 +54,60 @@
 store.put('value', new Uint8Array([1,2,3]).buffer)
 
 store.put('value', new DataView(new Uint8Array([1,2,3]).buffer))
+
+testBinaryKeys3():
+trans = db.transaction('storeWithKeyPath', 'readwrite')
+store = trans.objectStore('storeWithKeyPath')
+
+binary = new Uint8ClampedArray([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Uint16Array([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Uint32Array([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Int8Array([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Int16Array([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Int32Array([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Float32Array([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Float64Array([1,2,3])
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new Uint8Array([1,2,3]).buffer
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
+
+binary = new DataView(new Uint8Array([1,2,3]).buffer)
+store.put({ binary })
+request = store.get(binary)
+PASS binary.constructor === request.result.binary.constructor is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/storage/indexeddb/resources/key-type-binary.js (246769 => 246770)


--- trunk/LayoutTests/storage/indexeddb/resources/key-type-binary.js	2019-06-24 23:37:35 UTC (rev 246769)
+++ trunk/LayoutTests/storage/indexeddb/resources/key-type-binary.js	2019-06-24 23:45:41 UTC (rev 246770)
@@ -11,6 +11,7 @@
     db = event.target.result;
     event.target.transaction._onabort_ = unexpectedAbortCallback;
     objectStore = evalAndLog("db.createObjectStore('store');");
+    objectStoreWithKeyPath = evalAndLog("db.createObjectStore('storeWithKeyPath', {keyPath: 'binary'});");
     debug("");
 }
 
@@ -46,6 +47,19 @@
     trans._oncomplete_ = testBinaryKeys2;
 }
 
+const cases = [
+    "new Uint8ClampedArray([1,2,3])",
+    "new Uint16Array([1,2,3])",
+    "new Uint32Array([1,2,3])",
+    "new Int8Array([1,2,3])",
+    "new Int16Array([1,2,3])",
+    "new Int32Array([1,2,3])",
+    "new Float32Array([1,2,3])",
+    "new Float64Array([1,2,3])",
+    "new Uint8Array([1,2,3]).buffer",
+    "new DataView(new Uint8Array([1,2,3]).buffer)"
+];
+
 function testBinaryKeys2()
 {
     preamble();
@@ -52,23 +66,35 @@
     evalAndLog("trans = db.transaction('store', 'readwrite')");
     evalAndLog("store = trans.objectStore('store')");
 
-    var cases = [
-        "new Uint8ClampedArray([1,2,3])",
-        "new Uint16Array([1,2,3])",
-        "new Uint32Array([1,2,3])",
-        "new Int8Array([1,2,3])",
-        "new Int16Array([1,2,3])",
-        "new Int32Array([1,2,3])",
-        "new Float32Array([1,2,3])",
-        "new Float64Array([1,2,3])",
-        "new Uint8Array([1,2,3]).buffer",
-        "new DataView(new Uint8Array([1,2,3]).buffer)"
-    ];
-
     cases.forEach(function(testCase) {
         debug("");
         evalAndLog("store.put('value', " + testCase + ")");
     });
 
-    finishJSTest();
+    trans._oncomplete_ = testBinaryKeys3;
 }
+
+function runTest(testNumber) {
+    debug("");
+    evalAndLog("binary = " + cases[testNumber]);
+    evalAndLog("store.put({ binary })");
+    evalAndLog("request = store.get(binary)");
+    request._onsuccess_ = ()=>{
+        shouldBeTrue("binary.constructor === request.result.binary.constructor");
+
+        if (++testNumber == cases.length)
+            finishJSTest();
+        else
+            runTest(testNumber);
+    }
+    request._onerror_ = unexpectedErrorCallback;
+}
+
+function testBinaryKeys3()
+{
+    preamble();
+    evalAndLog("trans = db.transaction('storeWithKeyPath', 'readwrite')");
+    evalAndLog("store = trans.objectStore('storeWithKeyPath')");
+
+    runTest(0);
+}
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (246769 => 246770)


--- trunk/Source/WebCore/ChangeLog	2019-06-24 23:37:35 UTC (rev 246769)
+++ trunk/Source/WebCore/ChangeLog	2019-06-24 23:45:41 UTC (rev 246770)
@@ -1,5 +1,23 @@
 2019-06-24  Sihui Liu  <[email protected]>
 
+        REGRESSION (r244436): IndexedDB Uint8Array returned as ArrayBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=198738
+        <rdar://problem/51614053>
+
+        Reviewed by Brady Eidson.
+
+        In InexedDB, two binary keys are the same as long as their data is the same.
+
+        Modified tests: storage/indexeddb/key-type-binary.html
+                        storage/indexeddb/key-type-binary-private.html
+
+        * bindings/js/IDBBindingUtilities.cpp:
+        (WebCore::injectIDBKeyIntoScriptValue):
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::CloneDeserializer::readArrayBufferView):
+
+2019-06-24  Sihui Liu  <[email protected]>
+
         Remove WebSQL quirk for nytimes.com
         https://bugs.webkit.org/show_bug.cgi?id=199175
 

Modified: trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp (246769 => 246770)


--- trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp	2019-06-24 23:37:35 UTC (rev 246769)
+++ trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp	2019-06-24 23:45:41 UTC (rev 246770)
@@ -327,11 +327,9 @@
         return false;
 
     // Do not set if object already has the correct property value.
-    auto jsKey = toJS(exec, *exec.lexicalGlobalObject(), key.get());
     JSValue existingKey;
-    if (get(exec, parent, keyPathElements.last(), existingKey) && existingKey == jsKey)
+    if (get(exec, parent, keyPathElements.last(), existingKey) && !key->compare(createIDBKeyFromValue(exec, existingKey)))
         return true;
-
     if (!set(exec, parent, keyPathElements.last(), toJS(exec, *exec.lexicalGlobalObject(), key.get())))
         return false;
 

Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (246769 => 246770)


--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2019-06-24 23:37:35 UTC (rev 246769)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2019-06-24 23:45:41 UTC (rev 246770)
@@ -2136,7 +2136,7 @@
         RefPtr<ArrayBuffer> arrayBuffer = toPossiblySharedArrayBuffer(vm, arrayBufferObj);
         switch (arrayBufferViewSubtag) {
         case DataViewTag:
-            arrayBufferView = getJSValue(DataView::create(WTFMove(arrayBuffer), byteOffset, length).get());
+            arrayBufferView = toJS(m_exec, m_globalObject, DataView::create(WTFMove(arrayBuffer), byteOffset, length).get());
             return true;
         case Int8ArrayTag:
             arrayBufferView = toJS(m_exec, m_globalObject, Int8Array::tryCreate(WTFMove(arrayBuffer), byteOffset, length).get());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to