Commit d9d4246f authored by dcheng@chromium.org's avatar dcheng@chromium.org

Revert "IndexedDB: Ensure transactions created in microtasks are deactivated"

This timed out on the waterfall and is failing on unrelated tryjobs runs
as well.

TBR=jsbell@chromium.org
BUG=380910

Review URL: https://codereview.chromium.org/316383002

git-svn-id: svn://svn.chromium.org/blink/trunk@175615 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0ebfe771
This is a testharness.js-based test.
PASS Transactions created in microtasks are deactivated when control returns to the event loop
PASS Transactions created in microtasks remain active in subsequent microtasks
PASS Within request event dispatch, transactions remain active across microtasks
Harness: the test ran to completion.
<!DOCTYPE html>
<title>IndexedDB: Verify transaction activation behavior around microtasks</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
function idb_test(description, onUpgrade, onOpen) {
var t = async_test(description);
t.step(function() {
var dbName = 'db' + location.pathname + '-' + description;
var deleteRequest = indexedDB.deleteDatabase(dbName);
deleteRequest.onerror = t.unreached_func('deleteDatabase should not fail');
deleteRequest.onsuccess = t.step_func(function(e) {
var openRequest = indexedDB.open(dbName);
openRequest.onerror = t.unreached_func('open should not fail');
openRequest.onupgradeneeded = t.step_func(function(e) {
onUpgrade(t, openRequest.result);
});
openRequest.onsuccess = t.step_func(function(e) {
onOpen(t, openRequest.result);
});
});
});
}
function isTransactionActive(tx, storeName) {
try {
tx.objectStore(storeName).get(0);
return true;
} catch (ex) {
assert_equals(ex.name, 'TransactionInactiveError',
'Failure should be due to inactive transaction');
return false;
}
}
idb_test(
'Transactions created in microtasks are deactivated when control returns to the event loop',
function(t, db) {
db.createObjectStore('store');
},
function(t, db) {
Promise.resolve().then(t.step_func(function() {
var tx = db.transaction('store');
var request = tx.objectStore('store').get(0);
request.onerror = t.unreached_func('request should not fail');
request.onsuccess = t.step_func(function() {
assert_true(isTransactionActive(tx, 'store'),
'Transaction should be active during event dispatch');
setTimeout(function() {
assert_false(isTransactionActive(tx, 'store'),
'Transaction should be inactive once control returns to event loop');
t.done();
}, 0);
});
}));
}
);
idb_test(
'Transactions created in microtasks remain active in subsequent microtasks',
function(t, db) {
db.createObjectStore('store');
},
function(t, db) {
var tx;
Promise.resolve().then(function() {
tx = db.transaction('store');
assert_true(isTransactionActive(tx, 'store'),
'Transaction should be active when created');
}).then(t.step_func(function() {
assert_true(isTransactionActive(tx, 'store'),
'Transaction should be active until control returns to event loop');
setTimeout(function() {
assert_false(isTransactionActive(tx, 'store'),
'Transaction should be inactive once control returns to event loop');
t.done();
}, 0);
}));
}
);
idb_test(
'Within request event dispatch, transactions remain active across microtasks',
function(t, db) {
db.createObjectStore('store');
},
function(t, db) {
var tx = db.transaction('store');
var request = tx.objectStore('store').get(0);
request.onerror = t.unreached_func('request should not fail');
request.onsuccess = t.step_func(function() {
assert_true(isTransactionActive(tx, 'store'),
'Transaction should be active during event dispatch');
Promise.resolve().then(t.step_func(function() {
assert_true(isTransactionActive(tx, 'store'),
'Microtasks are run as part of event dispatch, so transaction should still be active');
setTimeout(function() {
assert_false(isTransactionActive(tx, 'store'),
'Transaction should be inactive once control returns to the event loop');
t.done();
}, 0);
}));
});
}
);
</script>
...@@ -38,11 +38,13 @@ namespace WebCore { ...@@ -38,11 +38,13 @@ namespace WebCore {
void V8RecursionScope::didLeaveScriptContext() void V8RecursionScope::didLeaveScriptContext()
{ {
Microtask::performCheckpoint(); // FIXME: Instrument any work that takes place when script exits to c++ (e.g. Mutation Observers).
// Indexed DB requires that transactions are created with an internal |active| flag // Indexed DB requires that transactions are created with an internal |active| flag
// set to true, but the flag becomes false when control returns to the event loop. // set to true, but the flag becomes false when control returns to the event loop.
IDBPendingTransactionMonitor::from(m_executionContext).deactivateNewTransactions(); IDBPendingTransactionMonitor::from(m_executionContext).deactivateNewTransactions();
Microtask::performCheckpoint();
} }
} // namespace WebCore } // namespace WebCore
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment