Skip to content
Permalink
Browse files
IDBTransaction / IDBObjectStore should not prevent a page from enteri…
…ng the back / forward cache

https://bugs.webkit.org/show_bug.cgi?id=202291
<rdar://problem/55760106>

Reviewed by Geoffrey Garen.

Source/WebCore:

IDBObjectStore does not fire any events and should therefore not cause any problem while in PageCache.
IDBTransaction can only fire abort/complete/error events, all of which are being enqueued to the
DocumentEventQueue. The DocumentEventQueue subclasses SuspendableTimer which will correctly suspend
while the document is in page cache. IDBTransaction will therefore not cause events to fire (and JS
to run) while in page cache.

Test: storage/indexeddb/IDBTransaction-page-cache.html

* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::canSuspendForDocumentSuspension const):
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::canSuspendForDocumentSuspension const):

LayoutTests:

Add layout test coverage.

* storage/indexeddb/IDBTransaction-page-cache.html: Added.


Canonical link: https://commits.webkit.org/215910@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250531 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Sep 30, 2019
1 parent 7f28018 commit 77c9b2cc1987bd16f04616df9e0cf71a78180a6e
Showing 8 changed files with 100 additions and 9 deletions.
@@ -1,3 +1,15 @@
2019-09-30 Chris Dumez <cdumez@apple.com>

IDBTransaction / IDBObjectStore should not prevent a page from entering the back / forward cache
https://bugs.webkit.org/show_bug.cgi?id=202291
<rdar://problem/55760106>

Reviewed by Geoffrey Garen.

Add layout test coverage.

* storage/indexeddb/IDBTransaction-page-cache.html: Added.

2019-09-30 Chris Dumez <cdumez@apple.com>

Pages with Web Workers cannot enter the back / forward cache
@@ -1,10 +1,12 @@
Tests that a page with an open IndexedDB database does not go into the page cache.
Tests that a page with an open IndexedDB database goes into the page cache.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


pageshow - not from cache
PASS Page was not restored from page cache
pagehide - entering cache
pageshow - from cache
PASS Page did enter and was restored from the page cache
PASS successfullyParsed is true

TEST COMPLETE
@@ -4,7 +4,7 @@
<body>
<script src="../../resources/js-test-pre.js"></script>
<script>
description('Tests that a page with an open IndexedDB database does not go into the page cache.');
description('Tests that a page with an open IndexedDB database goes into the page cache.');
window.jsTestIsAsync = true;

window.addEventListener("pageshow", function(event) {
@@ -15,16 +15,16 @@
delete window.sessionStorage.page_cache_open_indexeddb_test_started;

if (event.persisted)
testFailed("Page did enter and was restored from the page cache");
testPassed("Page did enter and was restored from the page cache");
else
testPassed("Page was not restored from page cache");
testFailed("Page was not restored from page cache");
finishJSTest();
}, false);

window.addEventListener("pagehide", function(event) {
debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
if (event.persisted) {
testFailed("Page entered the page cache.");
if (!event.persisted) {
testFailed("Page failed to enter the page cache.");
finishJSTest();
}
}, false);
@@ -0,0 +1,13 @@
Tests that an IDBRequest does not prevent page caching.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


pageshow - not from page cache
pagehide - entering page cache
pageshow - from page cache
PASS Page entered page cache
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,43 @@
<!-- webkit-test-runner [ enablePageCache=true ] -->
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<script>
description("Tests that an IDBRequest does not prevent page caching.");
jsTestIsAsync = true;

window.addEventListener("pageshow", function(event) {
debug("pageshow - " + (event.persisted ? "" : "not ") + "from page cache");
if (event.persisted) {
testPassed("Page entered page cache");
finishJSTest();
}
});

window.addEventListener("pagehide", function(event) {
debug("pagehide - " + (event.persisted ? "" : "not ") + "entering page cache");
if (!event.persisted) {
testFailed("Page failed to enter page cache");
finishJSTest();
}
});

onload = () => {
setTimeout(() => {
request = indexedDB.open("MyTestDatabase");
request.onerror = function(event) {
testFailed("Failed to open the database");
finishJSTest();
}
request.onupgradeneeded = function(event) {
var db = event.target.result;
objectStore = db.createObjectStore("customers", { keyPath: "ssn" });
transaction = objectStore.transaction;

window.location = "../../fast/history/resources/page-cache-helper.html";
};
}, 0);
};
</script>
</html>
@@ -1,3 +1,24 @@
2019-09-30 Chris Dumez <cdumez@apple.com>

IDBTransaction / IDBObjectStore should not prevent a page from entering the back / forward cache
https://bugs.webkit.org/show_bug.cgi?id=202291
<rdar://problem/55760106>

Reviewed by Geoffrey Garen.

IDBObjectStore does not fire any events and should therefore not cause any problem while in PageCache.
IDBTransaction can only fire abort/complete/error events, all of which are being enqueued to the
DocumentEventQueue. The DocumentEventQueue subclasses SuspendableTimer which will correctly suspend
while the document is in page cache. IDBTransaction will therefore not cause events to fire (and JS
to run) while in page cache.

Test: storage/indexeddb/IDBTransaction-page-cache.html

* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::canSuspendForDocumentSuspension const):
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::canSuspendForDocumentSuspension const):

2019-09-30 Chris Dumez <cdumez@apple.com>

Refine restrictions for X-Temp-Tablet HTTP header experiment
@@ -77,7 +77,7 @@ const char* IDBObjectStore::activeDOMObjectName() const

bool IDBObjectStore::canSuspendForDocumentSuspension() const
{
return false;
return true;
}

bool IDBObjectStore::hasPendingActivity() const
@@ -326,7 +326,7 @@ const char* IDBTransaction::activeDOMObjectName() const
bool IDBTransaction::canSuspendForDocumentSuspension() const
{
ASSERT(&m_database->originThread() == &Thread::current());
return false;
return true;
}

bool IDBTransaction::hasPendingActivity() const

0 comments on commit 77c9b2c

Please sign in to comment.