Changeset 246770 in webkit


Ignore:
Timestamp:
Jun 24, 2019 4:45:41 PM (5 years ago)
Author:
sihui_liu@apple.com
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):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/storage/indexeddb/key-type-binary-expected.txt

    r208349 r246770  
    99indexedDB.open(dbname)
    1010db.createObjectStore('store');
     11db.createObjectStore('storeWithKeyPath', {keyPath: 'binary'});
    1112
    1213
     
    5455
    5556store.put('value', new DataView(new Uint8Array([1,2,3]).buffer))
     57
     58testBinaryKeys3():
     59trans = db.transaction('storeWithKeyPath', 'readwrite')
     60store = trans.objectStore('storeWithKeyPath')
     61
     62binary = new Uint8ClampedArray([1,2,3])
     63store.put({ binary })
     64request = store.get(binary)
     65PASS binary.constructor === request.result.binary.constructor is true
     66
     67binary = new Uint16Array([1,2,3])
     68store.put({ binary })
     69request = store.get(binary)
     70PASS binary.constructor === request.result.binary.constructor is true
     71
     72binary = new Uint32Array([1,2,3])
     73store.put({ binary })
     74request = store.get(binary)
     75PASS binary.constructor === request.result.binary.constructor is true
     76
     77binary = new Int8Array([1,2,3])
     78store.put({ binary })
     79request = store.get(binary)
     80PASS binary.constructor === request.result.binary.constructor is true
     81
     82binary = new Int16Array([1,2,3])
     83store.put({ binary })
     84request = store.get(binary)
     85PASS binary.constructor === request.result.binary.constructor is true
     86
     87binary = new Int32Array([1,2,3])
     88store.put({ binary })
     89request = store.get(binary)
     90PASS binary.constructor === request.result.binary.constructor is true
     91
     92binary = new Float32Array([1,2,3])
     93store.put({ binary })
     94request = store.get(binary)
     95PASS binary.constructor === request.result.binary.constructor is true
     96
     97binary = new Float64Array([1,2,3])
     98store.put({ binary })
     99request = store.get(binary)
     100PASS binary.constructor === request.result.binary.constructor is true
     101
     102binary = new Uint8Array([1,2,3]).buffer
     103store.put({ binary })
     104request = store.get(binary)
     105PASS binary.constructor === request.result.binary.constructor is true
     106
     107binary = new DataView(new Uint8Array([1,2,3]).buffer)
     108store.put({ binary })
     109request = store.get(binary)
     110PASS binary.constructor === request.result.binary.constructor is true
    56111PASS successfullyParsed is true
    57112
  • trunk/LayoutTests/storage/indexeddb/key-type-binary-private-expected.txt

    r208349 r246770  
    99indexedDB.open(dbname)
    1010db.createObjectStore('store');
     11db.createObjectStore('storeWithKeyPath', {keyPath: 'binary'});
    1112
    1213
     
    5455
    5556store.put('value', new DataView(new Uint8Array([1,2,3]).buffer))
     57
     58testBinaryKeys3():
     59trans = db.transaction('storeWithKeyPath', 'readwrite')
     60store = trans.objectStore('storeWithKeyPath')
     61
     62binary = new Uint8ClampedArray([1,2,3])
     63store.put({ binary })
     64request = store.get(binary)
     65PASS binary.constructor === request.result.binary.constructor is true
     66
     67binary = new Uint16Array([1,2,3])
     68store.put({ binary })
     69request = store.get(binary)
     70PASS binary.constructor === request.result.binary.constructor is true
     71
     72binary = new Uint32Array([1,2,3])
     73store.put({ binary })
     74request = store.get(binary)
     75PASS binary.constructor === request.result.binary.constructor is true
     76
     77binary = new Int8Array([1,2,3])
     78store.put({ binary })
     79request = store.get(binary)
     80PASS binary.constructor === request.result.binary.constructor is true
     81
     82binary = new Int16Array([1,2,3])
     83store.put({ binary })
     84request = store.get(binary)
     85PASS binary.constructor === request.result.binary.constructor is true
     86
     87binary = new Int32Array([1,2,3])
     88store.put({ binary })
     89request = store.get(binary)
     90PASS binary.constructor === request.result.binary.constructor is true
     91
     92binary = new Float32Array([1,2,3])
     93store.put({ binary })
     94request = store.get(binary)
     95PASS binary.constructor === request.result.binary.constructor is true
     96
     97binary = new Float64Array([1,2,3])
     98store.put({ binary })
     99request = store.get(binary)
     100PASS binary.constructor === request.result.binary.constructor is true
     101
     102binary = new Uint8Array([1,2,3]).buffer
     103store.put({ binary })
     104request = store.get(binary)
     105PASS binary.constructor === request.result.binary.constructor is true
     106
     107binary = new DataView(new Uint8Array([1,2,3]).buffer)
     108store.put({ binary })
     109request = store.get(binary)
     110PASS binary.constructor === request.result.binary.constructor is true
    56111PASS successfullyParsed is true
    57112
  • trunk/LayoutTests/storage/indexeddb/resources/key-type-binary.js

    r208349 r246770  
    1212    event.target.transaction.onabort = unexpectedAbortCallback;
    1313    objectStore = evalAndLog("db.createObjectStore('store');");
     14    objectStoreWithKeyPath = evalAndLog("db.createObjectStore('storeWithKeyPath', {keyPath: 'binary'});");
    1415    debug("");
    1516}
     
    4748}
    4849
     50const cases = [
     51    "new Uint8ClampedArray([1,2,3])",
     52    "new Uint16Array([1,2,3])",
     53    "new Uint32Array([1,2,3])",
     54    "new Int8Array([1,2,3])",
     55    "new Int16Array([1,2,3])",
     56    "new Int32Array([1,2,3])",
     57    "new Float32Array([1,2,3])",
     58    "new Float64Array([1,2,3])",
     59    "new Uint8Array([1,2,3]).buffer",
     60    "new DataView(new Uint8Array([1,2,3]).buffer)"
     61];
     62
    4963function testBinaryKeys2()
    5064{
     
    5367    evalAndLog("store = trans.objectStore('store')");
    5468
    55     var cases = [
    56         "new Uint8ClampedArray([1,2,3])",
    57         "new Uint16Array([1,2,3])",
    58         "new Uint32Array([1,2,3])",
    59         "new Int8Array([1,2,3])",
    60         "new Int16Array([1,2,3])",
    61         "new Int32Array([1,2,3])",
    62         "new Float32Array([1,2,3])",
    63         "new Float64Array([1,2,3])",
    64         "new Uint8Array([1,2,3]).buffer",
    65         "new DataView(new Uint8Array([1,2,3]).buffer)"
    66     ];
    67 
    6869    cases.forEach(function(testCase) {
    6970        debug("");
     
    7172    });
    7273
    73     finishJSTest();
     74    trans.oncomplete = testBinaryKeys3;
    7475}
     76
     77function runTest(testNumber) {
     78    debug("");
     79    evalAndLog("binary = " + cases[testNumber]);
     80    evalAndLog("store.put({ binary })");
     81    evalAndLog("request = store.get(binary)");
     82    request.onsuccess = ()=>{
     83        shouldBeTrue("binary.constructor === request.result.binary.constructor");
     84
     85        if (++testNumber == cases.length)
     86            finishJSTest();
     87        else
     88            runTest(testNumber);
     89    }
     90    request.onerror = unexpectedErrorCallback;
     91}
     92
     93function testBinaryKeys3()
     94{
     95    preamble();
     96    evalAndLog("trans = db.transaction('storeWithKeyPath', 'readwrite')");
     97    evalAndLog("store = trans.objectStore('storeWithKeyPath')");
     98
     99    runTest(0);
     100}
  • trunk/Source/WebCore/ChangeLog

    r246768 r246770  
     12019-06-24  Sihui Liu  <sihui_liu@apple.com>
     2
     3        REGRESSION (r244436): IndexedDB Uint8Array returned as ArrayBuffer
     4        https://bugs.webkit.org/show_bug.cgi?id=198738
     5        <rdar://problem/51614053>
     6
     7        Reviewed by Brady Eidson.
     8
     9        In InexedDB, two binary keys are the same as long as their data is the same.
     10
     11        Modified tests: storage/indexeddb/key-type-binary.html
     12                        storage/indexeddb/key-type-binary-private.html
     13
     14        * bindings/js/IDBBindingUtilities.cpp:
     15        (WebCore::injectIDBKeyIntoScriptValue):
     16        * bindings/js/SerializedScriptValue.cpp:
     17        (WebCore::CloneDeserializer::readArrayBufferView):
     18
    1192019-06-24  Sihui Liu  <sihui_liu@apple.com>
    220
  • trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp

    r244436 r246770  
    328328
    329329    // Do not set if object already has the correct property value.
    330     auto jsKey = toJS(exec, *exec.lexicalGlobalObject(), key.get());
    331330    JSValue existingKey;
    332     if (get(exec, parent, keyPathElements.last(), existingKey) && existingKey == jsKey)
     331    if (get(exec, parent, keyPathElements.last(), existingKey) && !key->compare(createIDBKeyFromValue(exec, existingKey)))
    333332        return true;
    334 
    335333    if (!set(exec, parent, keyPathElements.last(), toJS(exec, *exec.lexicalGlobalObject(), key.get())))
    336334        return false;
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp

    r244115 r246770  
    21372137        switch (arrayBufferViewSubtag) {
    21382138        case DataViewTag:
    2139             arrayBufferView = getJSValue(DataView::create(WTFMove(arrayBuffer), byteOffset, length).get());
     2139            arrayBufferView = toJS(m_exec, m_globalObject, DataView::create(WTFMove(arrayBuffer), byteOffset, length).get());
    21402140            return true;
    21412141        case Int8ArrayTag:
Note: See TracChangeset for help on using the changeset viewer.