Update web-platform-tests to revision b7a8b84debb42268ea95a45bdad8f727d1facdf7

This commit is contained in:
WPT Sync Bot 2019-03-21 21:40:20 -04:00
parent ba929208e4
commit 953dbda9a6
215 changed files with 6409 additions and 1644 deletions

View file

@ -0,0 +1,40 @@
// META: script=support.js
function cursorRequestTest({ useIndex, useKeyCursor }) {
indexeddb_test(
(t, db) => {
const objStore = db.createObjectStore("my_objectstore");
objStore.add("data", 1);
objStore.createIndex("my_index", "");
},
(t, db) => {
const tx = db.transaction("my_objectstore");
let source = tx.objectStore("my_objectstore");
if (useIndex) source = source.index('my_index');
const req = useKeyCursor ? source.openKeyCursor() : source.openCursor();
let cursor;
req.onsuccess = t.step_func(() => {
cursor = req.result;
assert_equals(cursor.request, req, 'cursor.request');
assert_readonly(cursor, 'request');
});
req.transaction.oncomplete = t.step_func(() => {
setTimeout(t.step_func(() => {
assert_equals(cursor.request, req, 'cursor.request after transaction complete');
t.done();
}), 0);
});
req.transaction.onerror = t.unreached_func('Transaction error');
},
`cursor.request from ${useIndex ? 'IDBIndex' : 'IDBObjectStore'}.${useKeyCursor ? 'openKeyCursor' : 'openCursor'}`
);
}
for (const useIndex of [false, true]) {
for (const useKeyCursor of [false, true]) {
cursorRequestTest({ useIndex, useKeyCursor });
}
}

View file

@ -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>

View file

@ -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>