Index: third_party/WebKit/LayoutTests/storage/websql/database-removed-context-crash.html |
diff --git a/third_party/WebKit/LayoutTests/storage/websql/database-removed-context-crash.html b/third_party/WebKit/LayoutTests/storage/websql/database-removed-context-crash.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0f2b7c494f8cfea49ebe694ea436b2a666ba7a60 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/storage/websql/database-removed-context-crash.html |
@@ -0,0 +1,50 @@ |
+<!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> |