| <!DOCTYPE html> |
| <title>Database from removed execution context</title> |
| <script> |
| if (window.testRunner) { |
| testRunner.dumpAsText(); |
| testRunner.waitUntilDone(); |
| } |
| |
| var script = ` |
| var db = openDatabase('' + Date.now() + Math.random(), '1', 'db', 1024); |
| frameElement.remove(); |
| `; |
| |
| var cases = [ |
| 'db.transaction(() => {});', |
| 'db.readTransaction(() => {});', |
| 'db.changeVersion(1, 2);' |
| ]; |
| |
| window.addEventListener('DOMContentLoaded', e => { |
| function nextCase() { |
| if (!cases.length) { |
| if (window.testRunner) |
| testRunner.notifyDone(); |
| return; |
| } |
| |
| var srcdoc = '<script>' + script + cases.shift() + '<\/script>'; |
| var iframe = document.createElement('iframe'); |
| document.body.appendChild(iframe); |
| iframe.srcdoc = srcdoc; |
| waitUntil(() => iframe.parentNode === null, nextCase); |
| } |
| |
| nextCase(); |
| }); |
| |
| // Poll (10ms) until testFunc returns true, then execute callback(). |
| function waitUntil(testFunc, callback) { |
| setTimeout(() => { |
| if (testFunc()) |
| callback(); |
| else |
| waitUntil(testFunc, callback); |
| }, 10); |
| } |
| </script> |
| <body> |
| If it doesn't crash, this test has passed. |
| </body> |