Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge r186049 - Crash: com.apple.WebKit.WebContent at com.apple.WebCo…
…re: WebCore::CachedFrameBase::restore + 333 https://bugs.webkit.org/show_bug.cgi?id=146388 <rdar://problem/21567343> Reviewed by Darin Adler. Source/WebCore: Pages that are currently loading are not supposed to go into the PageCache. However, PageCache::canCache() only checks if the FrameLoader's documentLoader is loading. If the subframe is in provisional load stage, we would fail to detect that the frame is actually loading because the FrameLoader active documentLoader would be the provisional documentLoader, not the regular documentLoader. Therefore, the page would get added to the PageCache and the frame would keep loading while in the PageCache. On http://www.audiusa.com/models, this is what was happening. It was crashing because the subframe would finish loading while in the PageCache, in which case we would fire the 'load' event and the content 'load' event handler would then proceed to remove the iframe. Upon restoring the PageCache entry, we would run into trouble as we would have a CachedFrame whose Frame has been removed. The solution proposed is to prevent page-caching if a subframe is in provisional load stage. Test: http/tests/navigation/page-cache-iframe-provisional-load.html * history/PageCache.cpp: (WebCore::logCanCacheFrameDecision): (WebCore::PageCache::canCachePageContainingThisFrame): * page/DiagnosticLoggingKeys.cpp: (WebCore::DiagnosticLoggingKeys::provisionalLoadKey): * page/DiagnosticLoggingKeys.h: LayoutTests: Add layout test to cover the case where a subframe is currently in provisional load stage when checking if the page if page-cacheable. The test also removes the iframe once loaded in order to cause a crash if the frame were to finish loading while in the page cache. * http/tests/navigation/page-cache-iframe-provisional-load-expected.txt: Added. * http/tests/navigation/page-cache-iframe-provisional-load.html: Added. * http/tests/navigation/resources/page-cache-helper-slow.html: Added.
- Loading branch information
1 parent
c55739b
commit e2cf598
Showing
8 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
LayoutTests/http/tests/navigation/page-cache-iframe-provisional-load-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
A frame in provisional load stage should prevent page caching. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
pageshow - not from cache | ||
PASS Page was not restored from PageCache | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
56 changes: 56 additions & 0 deletions
56
LayoutTests/http/tests/navigation/page-cache-iframe-provisional-load.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="/resources/js-test-pre.js"></script> | ||
<script> | ||
description("A frame in provisional load stage should prevent page caching."); | ||
window.jsTestIsAsync = true; | ||
|
||
if (window.testRunner) | ||
testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1); | ||
|
||
window.addEventListener("pageshow", function(event) { | ||
debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache"); | ||
|
||
if (!window.sessionStorage.page_cache_provisional_load_test_started) | ||
return; | ||
|
||
delete window.sessionStorage.page_cache_provisional_load_test_started; | ||
|
||
if (event.persisted) | ||
testFailed("Page was restored from PageCache"); | ||
else | ||
testPassed("Page was not restored from PageCache"); | ||
|
||
finishJSTest(); | ||
}, false); | ||
|
||
window.addEventListener("pagehide", function(event) { | ||
debug("pagehide"); | ||
}, false); | ||
|
||
function loadSubframeAndNavigateAway() | ||
{ | ||
// Force a back navigation back to this page. | ||
window.sessionStorage.page_cache_provisional_load_test_started = true; | ||
window.location.href = "resources/page-cache-helper-slow.html"; | ||
|
||
var testFrame = document.getElementById("testFrame"); | ||
testFrame.src = "http://127.0.0.1:8000/navigation/resources/slow-resource.pl?delay=100"; | ||
|
||
// If the page goes into the page cache and the frame keeps loading while in the cache, | ||
// the following will cause crashes. | ||
testFrame.onload = function() { document.getElementById("testFrame").remove(); }; | ||
} | ||
|
||
window.addEventListener('load', function() { | ||
setTimeout(function() { | ||
loadSubframeAndNavigateAway(); | ||
}, 0); | ||
}, false); | ||
|
||
</script> | ||
<iframe id="testFrame" src="about:blank"></iframe> | ||
<script src="/resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
9 changes: 9 additions & 0 deletions
9
LayoutTests/http/tests/navigation/resources/page-cache-helper-slow.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
This page should go back. If a test outputs the contents of this | ||
page, then the test page failed to enter the page cache. | ||
<script> | ||
window.addEventListener("load", function() { | ||
setTimeout(function() { | ||
history.back(); | ||
}, 500); | ||
}, false); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters