зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1533998 [wpt PR 15691] - [IndexedDB] Fixed DisjointRangeLockManager usage in IndexedDB, a=testonly
Automatic update from web-platform-tests [IndexedDB] Fixed DisjointRangeLockManager usage in IndexedDB IndexedDBFactoryImpl isn't scoped per origin and so can be used by multiple origins. The original code assumed that it was scoped per origin, so when in actuality it was used by multiple origins, when a single origin requested a lock this could interrupt other origins in certain cases. https://docs.google.com/document/d/1jX6OOQJ0aLrWAeqYLtARXPFawUlJPbHNIKAK-0vmFHU/edit#heading=h.6cqn78xajqmp R=cmp@chromium.org Bug: 934790 Change-Id: I10f3e7c1b43ad7310d8824648575d940568b534d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1487369 Commit-Queue: Daniel Murphy <dmurph@chromium.org> Reviewed-by: Chase Phillips <cmp@chromium.org> Cr-Commit-Position: refs/heads/master@{#638260} -- wpt-commits: b7ffa083a7bdef805e08c36a757f4f97fd50eff9 wpt-pr: 15691
This commit is contained in:
Родитель
0072b89466
Коммит
5a21162335
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Databases on different origins use separate locking</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<script src="support.js"></script>
|
||||
<script src="support-promises.js"></script>
|
||||
<script>
|
||||
|
||||
var host_info = get_host_info();
|
||||
|
||||
promise_test(async testCase => {
|
||||
await deleteAllDatabases(testCase);
|
||||
|
||||
// Create an iframe to open and hold a database on a different origin.
|
||||
var iframe = document.createElement('iframe');
|
||||
var newLocation = window.location.href.replace('www', 'www2');
|
||||
|
||||
const keepalive_watcher = new EventWatcher(testCase, window, 'message');
|
||||
iframe.src = host_info.HTTP_REMOTE_ORIGIN +
|
||||
'/IndexedDB/resources/idbfactory-origin-isolation-iframe.html';
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
// Wait until the iframe starts its transaction.
|
||||
var event = await keepalive_watcher.wait_for('message');
|
||||
assert_equals("keep_alive_started", event.data);
|
||||
|
||||
// Create our own database with the same name, and perform a simple get.
|
||||
const db = await createNamedDatabase(
|
||||
testCase, 'db-isolation-test', database => {
|
||||
database.createObjectStore('s');
|
||||
});
|
||||
const tx = db.transaction('s');
|
||||
var request = tx.objectStore('s').get(0);
|
||||
request.onsuccess = testCase.step_func_done();
|
||||
request.onerror = testCase.unreached_func("There should be no errors.");
|
||||
}, "Test to make sure that origins have separate locking schemes");
|
||||
|
||||
</script>
|
||||
|
||||
<div id="log"></div>
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<title>This iframe keeps a transaction on a database alive indefinitely to test</title>
|
||||
<script>
|
||||
|
||||
// Keeps the passed transaction alive indefinitely (by making requests
|
||||
// against the named store). Returns a function that asserts that the
|
||||
// transaction has not already completed and then ends the request loop so that
|
||||
// the transaction may autocommit and complete.
|
||||
function keep_alive(tx, store_name) {
|
||||
let completed = false;
|
||||
tx.addEventListener('complete', () => { completed = true; });
|
||||
|
||||
let keepSpinning = true;
|
||||
|
||||
function spin() {
|
||||
if (!keepSpinning)
|
||||
return;
|
||||
tx.objectStore(store_name).get(0).onsuccess = spin;
|
||||
}
|
||||
spin();
|
||||
|
||||
return () => {
|
||||
assert_false(completed, 'Transaction completed while kept alive');
|
||||
keepSpinning = false;
|
||||
};
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const dbs_to_delete = await indexedDB.databases();
|
||||
for (const db_info of dbs_to_delete) {
|
||||
let request = indexedDB.deleteDatabase(db_info.name);
|
||||
await new Promise((resolve, reject) => {
|
||||
request.onsuccess = resolve;
|
||||
request.onerror = reject;
|
||||
});
|
||||
}
|
||||
|
||||
var openRequest = indexedDB.open('db-isolation-test');
|
||||
openRequest.onupgradeneeded = () => {
|
||||
openRequest.result.createObjectStore('s');
|
||||
};
|
||||
openRequest.onsuccess = () => {
|
||||
var tx = openRequest.result.transaction('s');
|
||||
keep_alive(tx, 's');
|
||||
window.parent.postMessage("keep_alive_started", "*");
|
||||
};
|
||||
}
|
||||
|
||||
run();
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче