WebKit Bugzilla
Attachment 361751 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-20190211182236.patch (text/plain), 9.08 KB, created by
Sihui Liu
on 2019-02-11 18:22:37 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Sihui Liu
Created:
2019-02-11 18:22:37 PST
Size:
9.08 KB
patch
obsolete
>Subversion Revision: 241287 >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 790c5526c86d1a25c675e97cd34d8a431fe7642e..12961ae2e342e0046cae41bbc92eadfcc18df5bc 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,20 @@ >+2019-02-11 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!). >+ >+ * 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/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