mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-09 21:00:42 +02:00
Automatic update from web-platform-tests [IndexedDB] Fix crash when storing native file system handles using inline keys. IndexedDB assumes it can non-destructively deserialize a SerializedScriptValue, however our implementation for deserializing native file system handles actually modified the SSV in a way that violated that assumption. This fixes this by cloning the handles in the SSV rather than consuming them. Bug: 1058419 Change-Id: I11ddfef757849941cc26e920eadb9022f7e138a4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088218 Reviewed-by: Daniel Murphy <dmurph@chromium.org> Reviewed-by: Joshua Bell <jsbell@chromium.org> Reviewed-by: Kenichi Ishibashi <bashi@chromium.org> Commit-Queue: Marijn Kruisselbrink <mek@chromium.org> Cr-Commit-Position: refs/heads/master@{#747062} -- wpt-commits: 51b8e0940e87eda1f843a48d847d653b9a22c8c4 wpt-pr: 22091
126 lines
4.6 KiB
JavaScript
126 lines
4.6 KiB
JavaScript
'use strict';
|
|
|
|
directory_test(async (t, root_dir) => {
|
|
const handles = await create_file_system_handles(t, root_dir);
|
|
|
|
const db = await createDatabase(t, db => {
|
|
const store = db.createObjectStore('store');
|
|
});
|
|
t.add_cleanup(() => deleteAllDatabases(t));
|
|
|
|
const value = handles;
|
|
|
|
const tx = db.transaction('store', 'readwrite');
|
|
const store = tx.objectStore('store');
|
|
await promiseForRequest(t, store.put(value, 'key'));
|
|
const result = await promiseForRequest(t, store.get('key'));
|
|
|
|
await promiseForTransaction(t, tx);
|
|
|
|
assert_true(Array.isArray(result), 'Result should be an array');
|
|
assert_equals(result.length, value.length);
|
|
await assert_equals_cloned_handles(result, value);
|
|
}, 'Store handle in IndexedDB and read from pending transaction.');
|
|
|
|
directory_test(async (t, root_dir) => {
|
|
const handles = await create_file_system_handles(t, root_dir);
|
|
|
|
const db = await createDatabase(t, db => {
|
|
const store = db.createObjectStore('store');
|
|
});
|
|
t.add_cleanup(() => deleteAllDatabases(t));
|
|
|
|
const value = handles;
|
|
|
|
let tx = db.transaction('store', 'readwrite');
|
|
let store = tx.objectStore('store');
|
|
await promiseForRequest(t, store.put(value, 'key'));
|
|
await promiseForTransaction(t, tx);
|
|
|
|
tx = db.transaction('store', 'readonly');
|
|
store = tx.objectStore('store');
|
|
const result = await promiseForRequest(t, store.get('key'));
|
|
await promiseForTransaction(t, tx);
|
|
|
|
assert_true(Array.isArray(result), 'Result should be an array');
|
|
assert_equals(result.length, value.length);
|
|
await assert_equals_cloned_handles(result, value);
|
|
}, 'Store handle in IndexedDB and read from new transaction.');
|
|
|
|
directory_test(async (t, root_dir) => {
|
|
const handles = await create_file_system_handles(t, root_dir);
|
|
|
|
const db = await createDatabase(t, db => {
|
|
const store = db.createObjectStore('store');
|
|
});
|
|
t.add_cleanup(() => deleteAllDatabases(t));
|
|
|
|
const value = {handles, blob: new Blob(["foobar"])};
|
|
|
|
let tx = db.transaction('store', 'readwrite');
|
|
let store = tx.objectStore('store');
|
|
await promiseForRequest(t, store.put(value, 'key'));
|
|
await promiseForTransaction(t, tx);
|
|
|
|
tx = db.transaction('store', 'readonly');
|
|
store = tx.objectStore('store');
|
|
const result = await promiseForRequest(t, store.get('key'));
|
|
await promiseForTransaction(t, tx);
|
|
|
|
assert_true(Array.isArray(result.handles), 'Result should be an array');
|
|
assert_equals(result.handles.length, value.handles.length);
|
|
await assert_equals_cloned_handles(result.handles, value.handles);
|
|
|
|
assert_equals(await result.blob.text(), await value.blob.text());
|
|
}, 'Store handles and blobs in IndexedDB.');
|
|
|
|
directory_test(async (t, root_dir) => {
|
|
const handles = await create_file_system_handles(t, root_dir);
|
|
|
|
const db = await createDatabase(t, db => {
|
|
const store = db.createObjectStore('store');
|
|
});
|
|
t.add_cleanup(() => deleteAllDatabases(t));
|
|
|
|
const value = handles;
|
|
|
|
let tx = db.transaction('store', 'readwrite');
|
|
let store = tx.objectStore('store');
|
|
await promiseForRequest(t, store.put(value, 'key'));
|
|
await promiseForTransaction(t, tx);
|
|
|
|
tx = db.transaction('store', 'readonly');
|
|
store = tx.objectStore('store');
|
|
let cursor_request = store.openCursor();
|
|
await requestWatcher(t, cursor_request).wait_for('success');
|
|
const result = cursor_request.result.value;
|
|
await promiseForTransaction(t, tx);
|
|
|
|
assert_true(Array.isArray(result), 'Result should be an array');
|
|
assert_equals(result.length, value.length);
|
|
await assert_equals_cloned_handles(result, value);
|
|
}, 'Store handle in IndexedDB and read using a cursor.');
|
|
|
|
directory_test(async (t, root_dir) => {
|
|
const handles = await create_file_system_handles(t, root_dir);
|
|
|
|
const db = await createDatabase(t, db => {
|
|
const store = db.createObjectStore('store', {keyPath: 'key'});
|
|
});
|
|
t.add_cleanup(() => deleteAllDatabases(t));
|
|
|
|
const value = handles;
|
|
let tx = db.transaction('store', 'readwrite');
|
|
let store = tx.objectStore('store');
|
|
await promiseForRequest(t, store.put({key: 'key', value}));
|
|
await promiseForTransaction(t, tx);
|
|
|
|
tx = db.transaction('store', 'readonly');
|
|
store = tx.objectStore('store');
|
|
const result = await promiseForRequest(t, store.get('key'));
|
|
await promiseForTransaction(t, tx);
|
|
|
|
assert_true(Array.isArray(result.value), 'Result should be an array');
|
|
assert_equals(result.value.length, value.length);
|
|
await assert_equals_cloned_handles(result.value, value);
|
|
}, 'Store handle in IndexedDB using inline keys.');
|