idbfactory-origin-isolation.html (1568B)
1 <!DOCTYPE html> 2 <title>Databases on different origins use separate locking</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/common/get-host-info.sub.js"></script> 6 <script src="resources/support.js"></script> 7 <script src="resources/support-promises.js"></script> 8 <script> 9 10 var host_info = get_host_info(); 11 12 promise_test(async testCase => { 13 await deleteAllDatabases(testCase); 14 15 // Create an iframe to open and hold a database on a different origin. 16 var iframe = document.createElement('iframe'); 17 var newLocation = window.location.href.replace('www', 'www2'); 18 19 const keepalive_watcher = new EventWatcher(testCase, window, 'message'); 20 iframe.src = host_info.HTTP_REMOTE_ORIGIN + 21 '/IndexedDB/resources/idbfactory-origin-isolation-iframe.html'; 22 document.body.appendChild(iframe); 23 24 // Wait until the iframe starts its transaction. 25 var event = await keepalive_watcher.wait_for('message'); 26 assert_equals("keep_alive_started", event.data); 27 28 // Create our own database with the same name, and perform a simple get. 29 const db = await createNamedDatabase( 30 testCase, 'db-isolation-test', database => { 31 database.createObjectStore('s'); 32 }); 33 const tx = db.transaction('s', 'readonly'); 34 var request = tx.objectStore('s').get(0); 35 request.onsuccess = testCase.step_func_done(); 36 request.onerror = testCase.unreached_func("There should be no errors."); 37 }, "Test to make sure that origins have separate locking schemes"); 38 39 </script> 40 41 <div id="log"></div>