WebKit Bugzilla
Attachment 361809 Details for
Bug 194527
: Add two regression tests for reference cycle in IndexedDB
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194527-20190212111234.patch (text/plain), 11.19 KB, created by
Sihui Liu
on 2019-02-12 11:12:35 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Sihui Liu
Created:
2019-02-12 11:12:35 PST
Size:
11.19 KB
patch
obsolete
>Subversion Revision: 241287 >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 790c5526c86d1a25c675e97cd34d8a431fe7642e..120a072cb61a315049a2065f0d220e9fe135dcb6 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,25 @@ >+2019-02-12 Sihui Liu <sihui_liu@apple.com> >+ >+ Add two regression tests for reference cycle in IndexedDB >+ https://bugs.webkit.org/show_bug.cgi?id=194527 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * fast/dom/reference-cycle-leaks.html: >+ * platform/win/TestExpectations: >+ The added tests are failing on win bots for unknown reasons, propably related to webkit.org/b/193540. Skip them >+ on win. >+ >+ * storage/indexeddb/resources/result-request-cycle.js: Added. >+ (prepareDatabase): >+ * storage/indexeddb/resources/value-cursor-cycle.js: Added. >+ (prepareDatabase): >+ (onOpen.cursorRequest.onsuccess): >+ * storage/indexeddb/result-request-cycle-expected.txt: Added. >+ * storage/indexeddb/result-request-cycle.html: Added. >+ * storage/indexeddb/value-cursor-cycle-expected.txt: Added. >+ * storage/indexeddb/value-cursor-cycle.html: Added. >+ > 2019-02-11 Shawn Roberts <sroberts@apple.com> > > Updating for all of Mac WK2 for flaky test >diff --git a/LayoutTests/fast/dom/reference-cycle-leaks.html b/LayoutTests/fast/dom/reference-cycle-leaks.html >index f71e0d5f9bba6116a1dc0805ac1d86fe378abc07..38eef046a6e877fbb6997e01b8adcc1eb1b2c282 100644 >--- a/LayoutTests/fast/dom/reference-cycle-leaks.html >+++ b/LayoutTests/fast/dom/reference-cycle-leaks.html >@@ -117,13 +117,10 @@ function createPopStateEventStateCycle() > leakDetectionNode.event = new PopStateEvent("x", { state: leakDetectionNode }); > } > >-function createIDBRequestResultCycle() >-{ >- // FIXME: Need to write this test and reorganize so it can be asynchronous. >- // Get an IDBRequest with a result that is a structured clone (see IDBTransaction::didGetRecordOnServer). >- // Add a property to the result object that references the request. >- // Add another property to the result object that references a leak detection node. >-} >+// FIXME: Need to write this test and reorganize so it can be asynchronous. >+ >+// Reference cycle of IDBRequest and IDBCursor is tested in >+// storage/indexeddb/value-cursor-cycle.html and LayoutTests/storage/indexeddb/result-request-cycle.html. > > // PaymentResponse details reference cycle is tested in > // http/tests/paymentrequest/payment-response-reference-cycle-leak.https.html. >diff --git a/LayoutTests/platform/win/TestExpectations b/LayoutTests/platform/win/TestExpectations >index a918cef89348a9dc7a08671732c187c7c507d658..674c158aa48c48eac56dc56f07328c260a92cad8 100644 >--- a/LayoutTests/platform/win/TestExpectations >+++ b/LayoutTests/platform/win/TestExpectations >@@ -4269,3 +4269,6 @@ webkit.org/b/193540 js/slow-stress/simple-custom-getter.html [ Skip ] > webkit.org/b/193540 performance-api/performance-observer-no-document-leak.html [ Skip ] > > webkit.org/b/194451 accessibility/set-value-not-work-for-disabled-sliders.html [ Failure ] >+ >+storage/indexeddb/result-request-cycle.html [ Skip ] >+storage/indexeddb/value-cursor-cycle.html [ Skip ] >diff --git a/LayoutTests/storage/indexeddb/resources/result-request-cycle.js b/LayoutTests/storage/indexeddb/resources/result-request-cycle.js >new file mode 100644 >index 0000000000000000000000000000000000000000..477548c8f9e671eb8ac238f8f70a58fa30e5e170 >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/resources/result-request-cycle.js >@@ -0,0 +1,56 @@ >+if (this.importScripts) { >+ importScripts('../../../resources/js-test.js'); >+ importScripts('shared.js'); >+} >+ >+description("Verify that IDBRequest is not leaked when there is a reference cycle for result attribute"); >+ >+indexedDBTest(prepareDatabase, onOpen); >+ >+function prepareDatabase(evt) >+{ >+ preamble(evt); >+ evalAndLog("db = event.target.result"); >+ evalAndLog("store = db.createObjectStore('store')"); >+ store.put({ value: 'value1' }, 'key1'); >+ store.put({ value: 'value2' }, 'key2'); >+} >+ >+function onOpen(evt) >+{ >+ preamble(evt); >+ evalAndLog("db = event.target.result"); >+ evalAndLog("tx = db.transaction('store')"); >+ evalAndLog("store = tx.objectStore('store')"); >+ >+ evalAndLog("getRequest = store.get('key1')"); >+ getRequest.onsuccess = (evt) => { >+ preamble(evt); >+ >+ debug("Verify that the request's result can be accessed lazily:"); >+ evalAndLog("gc()"); >+ >+ evalAndLog("result = getRequest.result"); >+ shouldBeEqualToString("result.value", "value1"); >+ evalAndLog("result.source = getRequest"); >+ } >+ >+ evalAndLog("getRequest2 = store.get('key2')"); >+ getRequest2.onsuccess = (evt) => { >+ shouldBeEqualToString("getRequest2.result.value", "value2"); >+ >+ getRequestObervation = internals.observeGC(getRequest); >+ resultObservation = internals.observeGC(result); >+ evalAndLog("getRequest = null"); >+ evalAndLog("gc()"); >+ shouldBeFalse("getRequestObervation.wasCollected"); >+ shouldBeFalse("resultObservation.wasCollected"); >+ >+ evalAndLog("result = null"); >+ evalAndLog("gc()"); >+ shouldBeTrue("getRequestObervation.wasCollected"); >+ shouldBeTrue("resultObservation.wasCollected"); >+ } >+ >+ tx.oncomplete = finishJSTest; >+} >\ No newline at end of file >diff --git a/LayoutTests/storage/indexeddb/resources/value-cursor-cycle.js b/LayoutTests/storage/indexeddb/resources/value-cursor-cycle.js >new file mode 100644 >index 0000000000000000000000000000000000000000..c33fc29163d185b526a752e0142c235907a0a06c >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/resources/value-cursor-cycle.js >@@ -0,0 +1,54 @@ >+if (this.importScripts) { >+ importScripts('../../../resources/js-test.js'); >+ importScripts('shared.js'); >+} >+ >+description("Verify that IDBCursor is not leaked when there is a reference cycle for value attribute"); >+ >+indexedDBTest(prepareDatabase, onOpen); >+ >+function prepareDatabase(evt) >+{ >+ preamble(evt); >+ evalAndLog("db = event.target.result"); >+ evalAndLog("store = db.createObjectStore('store')"); >+ store.put({ name: 'value' }, 'key'); >+} >+ >+function onOpen(evt) >+{ >+ preamble(evt); >+ evalAndLog("db = event.target.result"); >+ evalAndLog("tx = db.transaction('store')"); >+ evalAndLog("store = tx.objectStore('store')"); >+ >+ evalAndLog("cursorRequest = store.openCursor()"); >+ cursorRequest.onsuccess = function openCursorRequestSuccess(evt) { >+ preamble(evt); >+ }; >+ >+ evalAndLog("getRequest = store.get('key')"); >+ getRequest.onsuccess = () => { >+ shouldBeEqualToString("getRequest.result.name", "value"); >+ >+ evalAndLog("cursor = cursorRequest.result"); >+ shouldBeNonNull("cursor"); >+ evalAndLog("value = cursor.value"); >+ shouldBeEqualToString("value.name", "value"); >+ evalAndLog("value.cycle = cursor"); >+ >+ cursorObservation = internals.observeGC(cursor); >+ valueObservation = internals.observeGC(value); >+ evalAndLog("cursor = null"); >+ evalAndLog("cursorRequest = null"); >+ evalAndLog("gc()"); >+ shouldBeFalse("cursorObservation.wasCollected"); >+ >+ evalAndLog("value = null"); >+ evalAndLog("gc()"); >+ shouldBeTrue("cursorObservation.wasCollected"); >+ shouldBeTrue("valueObservation.wasCollected"); >+ } >+ >+ tx.oncomplete = finishJSTest; >+} >\ No newline at end of file >diff --git a/LayoutTests/storage/indexeddb/result-request-cycle-expected.txt b/LayoutTests/storage/indexeddb/result-request-cycle-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..7c91fe2bd8d5cebf8569b7107284e5b9bab737bc >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/result-request-cycle-expected.txt >@@ -0,0 +1,40 @@ >+Verify that IDBRequest is not leaked when there is a reference cycle for result attribute >+ >+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) >+ >+prepareDatabase(): >+db = event.target.result >+store = db.createObjectStore('store') >+ >+onOpen(): >+db = event.target.result >+tx = db.transaction('store') >+store = tx.objectStore('store') >+getRequest = store.get('key1') >+getRequest2 = store.get('key2') >+ >+(): >+Verify that the request's result can be accessed lazily: >+gc() >+result = getRequest.result >+PASS result.value is "value1" >+result.source = getRequest >+PASS getRequest2.result.value is "value2" >+getRequest = null >+gc() >+PASS getRequestObervation.wasCollected is false >+PASS resultObservation.wasCollected is false >+result = null >+gc() >+PASS getRequestObervation.wasCollected is true >+PASS resultObservation.wasCollected is true >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/storage/indexeddb/result-request-cycle.html b/LayoutTests/storage/indexeddb/result-request-cycle.html >new file mode 100644 >index 0000000000000000000000000000000000000000..b2a5e264920e4a1e7523beaefb8f02a7e648cb9e >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/result-request-cycle.html >@@ -0,0 +1,9 @@ >+<html> >+<head> >+<script src="../../resources/js-test.js"></script> >+<script src="resources/shared.js"></script> >+</head> >+<body> >+<script src="resources/result-request-cycle.js"></script> >+</body> >+</html> >diff --git a/LayoutTests/storage/indexeddb/value-cursor-cycle-expected.txt b/LayoutTests/storage/indexeddb/value-cursor-cycle-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..57145c29980567d2accf95babd4f6b32c54bc07c >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/value-cursor-cycle-expected.txt >@@ -0,0 +1,40 @@ >+Verify that IDBCursor is not leaked when there is a reference cycle for value attribute >+ >+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) >+ >+prepareDatabase(): >+db = event.target.result >+store = db.createObjectStore('store') >+ >+onOpen(): >+db = event.target.result >+tx = db.transaction('store') >+store = tx.objectStore('store') >+cursorRequest = store.openCursor() >+getRequest = store.get('key') >+ >+openCursorRequestSuccess(): >+PASS getRequest.result.name is "value" >+cursor = cursorRequest.result >+PASS cursor is non-null. >+value = cursor.value >+PASS value.name is "value" >+value.cycle = cursor >+cursor = null >+cursorRequest = null >+gc() >+PASS cursorObservation.wasCollected is false >+value = null >+gc() >+PASS cursorObservation.wasCollected is true >+PASS valueObservation.wasCollected is true >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/storage/indexeddb/value-cursor-cycle.html b/LayoutTests/storage/indexeddb/value-cursor-cycle.html >new file mode 100644 >index 0000000000000000000000000000000000000000..9c62007296b655d362aefb0ecfd9791226ffb35f >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/value-cursor-cycle.html >@@ -0,0 +1,9 @@ >+<html> >+<head> >+<script src="../../resources/js-test.js"></script> >+<script src="resources/shared.js"></script> >+</head> >+<body> >+<script src="resources/value-cursor-cycle.js"></script> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194527
:
361751
|
361763
|
361809
|
361920