Add an IDB leak test.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jun 2016 21:01:55 +0000 (21:01 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jun 2016 21:01:55 +0000 (21:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158632

Reviewed by Alex Christensen.

* storage/indexeddb/modern/leak-1-expected.txt: Added.
* storage/indexeddb/modern/leak-1.html: Added.
* storage/indexeddb/modern/resources/leak-1.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201940 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/modern/leak-1-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/leak-1.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/resources/leak-1.js [new file with mode: 0644]

index d220084..b3ad2ff 100644 (file)
@@ -1,3 +1,14 @@
+2016-06-10  Brady Eidson  <beidson@apple.com>
+
+        Add an IDB leak test.
+        https://bugs.webkit.org/show_bug.cgi?id=158632
+
+        Reviewed by Alex Christensen.
+
+        * storage/indexeddb/modern/leak-1-expected.txt: Added.
+        * storage/indexeddb/modern/leak-1.html: Added.
+        * storage/indexeddb/modern/resources/leak-1.js: Added.
+
 2016-06-10  Carlos Alberto Lopez Perez  <clopez@igalia.com>
 
         [GTK] Unreviewed gardening.
diff --git a/LayoutTests/storage/indexeddb/modern/leak-1-expected.txt b/LayoutTests/storage/indexeddb/modern/leak-1-expected.txt
new file mode 100644 (file)
index 0000000..d86c9f1
--- /dev/null
@@ -0,0 +1,18 @@
+This tests that certain IDB object relationships don't cause leaks.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
+Initial upgrade needed: Old version - 0 New version - 1
+Issuing a simple request to the object store
+Observing GC on the transaction and request. 
+PASS txObserver.wasCollected is true
+PASS reqObserver.wasCollected is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/storage/indexeddb/modern/leak-1.html b/LayoutTests/storage/indexeddb/modern/leak-1.html
new file mode 100644 (file)
index 0000000..e2a55bd
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<head>
+<script src="../../../resources/js-test.js"></script>
+<script src="../resources/shared.js"></script>
+</head>
+<body>
+
+<script src="resources/leak-1.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/storage/indexeddb/modern/resources/leak-1.js b/LayoutTests/storage/indexeddb/modern/resources/leak-1.js
new file mode 100644 (file)
index 0000000..16638d1
--- /dev/null
@@ -0,0 +1,66 @@
+description("This tests that certain IDB object relationships don't cause leaks.");
+
+indexedDBTest(prepareDatabase);
+
+function log(message)
+{
+    debug(message);
+}
+
+var testGenerator;
+function next()
+{
+    testGenerator.next();
+}
+
+function asyncNext()
+{
+    setTimeout("testGenerator.next();", 0);
+}
+
+var db;
+
+function prepareDatabase(event)
+{
+    debug("Initial upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
+
+    db = event.target.result;
+    db.createObjectStore("foo");
+    event.target.onsuccess = function() {
+        testGenerator = testSteps();
+        testGenerator.next();
+    };
+}
+
+function* testSteps()
+{
+    log("Issuing a simple request to the object store");
+    
+    tx = db.transaction("foo");
+    tx.oncomplete = next;
+    req = tx.objectStore("foo").get("foo");
+    req.onsuccess = next;
+    
+    yield; // For the request success.
+    yield; // For the transaction's completion.
+    
+    log("Observing GC on the transaction and request. ");
+    
+    txObserver = internals.observeGC(tx);
+    reqObserver = internals.observeGC(req);
+    
+    tx = null;
+    req = null;
+    
+    // Make sure we are no longer handling any IDB events.
+    asyncNext();
+    yield;
+    
+    gc();
+    
+    shouldBeTrue("txObserver.wasCollected");
+    shouldBeTrue("reqObserver.wasCollected");
+
+    finishJSTest();
+ }
\ No newline at end of file