Title: [258707] trunk/LayoutTests
Revision
258707
Author
[email protected]
Date
2020-03-19 10:23:58 -0700 (Thu, 19 Mar 2020)

Log Message

Flaky Test: storage/indexeddb/cursor-leak.html and storage/indexeddb/cursor-leak-private.html
https://bugs.webkit.org/show_bug.cgi?id=209256
<rdar://problem/60097171>

Reviewed by Geoffrey Garen.

gc() does not guarantee all objects to be collected due to our conservative GC. To make the test more stable, we
now test if there is at lease one object is collected, which is enough to show cursor does not hold strong
reference to script value properties.

* storage/indexeddb/cursor-leak-expected.txt:
* storage/indexeddb/cursor-leak-private-expected.txt:
* storage/indexeddb/resources/cursor-leak.js:
(onOpen.tx.oncomplete):
(onOpen.cursorRequest.onsuccess): Deleted.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (258706 => 258707)


--- trunk/LayoutTests/ChangeLog	2020-03-19 17:14:23 UTC (rev 258706)
+++ trunk/LayoutTests/ChangeLog	2020-03-19 17:23:58 UTC (rev 258707)
@@ -1,3 +1,21 @@
+2020-03-19  Sihui Liu  <[email protected]>
+
+        Flaky Test: storage/indexeddb/cursor-leak.html and storage/indexeddb/cursor-leak-private.html
+        https://bugs.webkit.org/show_bug.cgi?id=209256
+        <rdar://problem/60097171>
+
+        Reviewed by Geoffrey Garen.
+
+        gc() does not guarantee all objects to be collected due to our conservative GC. To make the test more stable, we
+        now test if there is at lease one object is collected, which is enough to show cursor does not hold strong 
+        reference to script value properties.
+
+        * storage/indexeddb/cursor-leak-expected.txt:
+        * storage/indexeddb/cursor-leak-private-expected.txt:
+        * storage/indexeddb/resources/cursor-leak.js:
+        (onOpen.tx.oncomplete):
+        (onOpen.cursorRequest.onsuccess): Deleted.
+
 2020-03-19  Jason Lawrence  <[email protected]>
 
         [ iOS wk2 and Mac wk2 ] imported/w3c/web-platform-tests/fetch/stale-while-revalidate/frame-removal.html is flaky failing.

Modified: trunk/LayoutTests/storage/indexeddb/cursor-leak-expected.txt (258706 => 258707)


--- trunk/LayoutTests/storage/indexeddb/cursor-leak-expected.txt	2020-03-19 17:14:23 UTC (rev 258706)
+++ trunk/LayoutTests/storage/indexeddb/cursor-leak-expected.txt	2020-03-19 17:23:58 UTC (rev 258707)
@@ -7,7 +7,8 @@
 
 indexedDB.deleteDatabase(dbname)
 indexedDB.open(dbname)
-PASS cursorObserver.wasCollected is true
+PASS cursorObservers.length is 10000
+PASS anyCollected is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/storage/indexeddb/cursor-leak-private-expected.txt (258706 => 258707)


--- trunk/LayoutTests/storage/indexeddb/cursor-leak-private-expected.txt	2020-03-19 17:14:23 UTC (rev 258706)
+++ trunk/LayoutTests/storage/indexeddb/cursor-leak-private-expected.txt	2020-03-19 17:23:58 UTC (rev 258707)
@@ -7,7 +7,8 @@
 
 indexedDB.deleteDatabase(dbname)
 indexedDB.open(dbname)
-PASS cursorObserver.wasCollected is true
+PASS cursorObservers.length is 10000
+PASS anyCollected is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/storage/indexeddb/resources/cursor-leak.js (258706 => 258707)


--- trunk/LayoutTests/storage/indexeddb/resources/cursor-leak.js	2020-03-19 17:14:23 UTC (rev 258706)
+++ trunk/LayoutTests/storage/indexeddb/resources/cursor-leak.js	2020-03-19 17:23:58 UTC (rev 258707)
@@ -3,7 +3,7 @@
     importScripts('shared.js');
 }
 
-description("Verify that that cursors weakly hold script value properties");
+description('Verify that that cursors weakly hold script value properties');
 
 if (window.internals) {
     indexedDBTest(prepareDatabase, onOpen);
@@ -24,30 +24,32 @@
     // evalAndLog() is not used as that generates new DOM nodes.
 
     db = evt.target.result;
-    tx = db.transaction('store');
+    tx = db.transaction('store', 'readonly');
     store = tx.objectStore('store');
-    cursorRequest = store.openCursor();
-    cursorRequest._onsuccess_ = function() {
-        cursor = cursorRequest.result;
-    };
+    cursorObservers = [];
+    for (let i = 0; i < 10000; ++i) {
+        store.openCursor()._onsuccess_ = (event) => {
+            cursor = event.target.result
+            cursor.key.cursor = cursor;
+            cursor.primaryKey.cursor = cursor;
+            cursor.value.cursor = cursor;
+            cursorObservers.push(internals.observeGC(cursor));
+            cursor = null;
+        };
+    }
     tx._oncomplete_ = function() {
         db.close();
+        shouldBe('cursorObservers.length', '10000');
 
-        // Try and induce a leak by a reference cycle from DOM to V8 and back.
-        // If the v8 value of cursor.key (etc) is only held by the cursor's
-        // V8 wrapper then there will be no leak.
-        cursor.key.cursor = cursor;
-        cursor.primaryKey.cursor = cursor;
-        cursor.value.cursor = cursor;
+        gc();
 
-        cursorObserver = internals.observeGC(cursor);
+        anyCollected = false;
+        for (let observer of cursorObservers) {
+            if (observer.wasCollected)
+                anyCollected = true;
+        }
 
-        cursorRequest = null;
-        cursor = null;
-
-        gc();
-
-        shouldBeTrue("cursorObserver.wasCollected");
+        shouldBeTrue('anyCollected');
         finishJSTest();
     };
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to