Commit ad9b09c1 authored by jberlin@webkit.org's avatar jberlin@webkit.org

Crash calling WebContext::clearResourceCaches(InMemoryResourceCachesOnly) before the Web

Process has finished launching.
https://bugs.webkit.org/show_bug.cgi?id=56208

Reviewed by Adam Roben.

Source/WebKit2: 

Only send the message if the Web Process is valid.

* UIProcess/WebContext.cpp:
(WebKit::WebContext::clearResourceCaches):

Tools: 

* TestWebKitAPI/Tests/WebKit2/SendingMessagesToTheWebProcessBeforeItIsValid.cpp: Added.
(TestWebKitAPI::TEST):
Test that calling WKContextClearResourceCaches works with both options when called before
the Web Process is valid.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
Add the new test.
* TestWebKitAPI/win/TestWebKitAPI.vcproj:
Ditto.



git-svn-id: svn://svn.chromium.org/blink/trunk@80884 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0d9d2dc5
2011-03-11 Jessie Berlin <jberlin@apple.com>
Reviewed by Adam Roben.
Crash calling WebContext::clearResourceCaches(InMemoryResourceCachesOnly) before the Web
Process has finished launching.
https://bugs.webkit.org/show_bug.cgi?id=56208
Only send the message if the Web Process is valid.
* UIProcess/WebContext.cpp:
(WebKit::WebContext::clearResourceCaches):
2011-03-11 Anders Carlsson <andersca@apple.com>
Reviewed by Dan Bernstein.
......
......@@ -655,15 +655,18 @@ CoreIPC::SyncReplyMode WebContext::didReceiveSyncMessage(CoreIPC::Connection* co
void WebContext::clearResourceCaches(ResourceCachesToClear cachesToClear)
{
if (!hasValidProcess() && cachesToClear == AllResourceCaches) {
if (hasValidProcess()) {
m_process->send(Messages::WebProcess::ClearResourceCaches(cachesToClear), 0);
return;
}
if (cachesToClear == InMemoryResourceCachesOnly)
return;
// FIXME <rdar://problem/8727879>: Setting this flag ensures that the next time a WebProcess is created, this request to
// clear the resource cache will be respected. But if the user quits the application before another WebProcess is created,
// their request will be ignored.
m_clearResourceCachesForNewWebProcess = true;
return;
}
m_process->send(Messages::WebProcess::ClearResourceCaches(cachesToClear), 0);
}
void WebContext::clearApplicationCache()
......
2011-03-11 Jessie Berlin <jberlin@apple.com>
Reviewed by Adam Roben.
Crash calling WebContext::clearResourceCaches(InMemoryResourceCachesOnly) before the Web
Process has finished launching.
https://bugs.webkit.org/show_bug.cgi?id=56208
* TestWebKitAPI/Tests/WebKit2/SendingMessagesToTheWebProcessBeforeItIsValid.cpp: Added.
(TestWebKitAPI::TEST):
Test that calling WKContextClearResourceCaches works with both options when called before
the Web Process is valid.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
Add the new test.
* TestWebKitAPI/win/TestWebKitAPI.vcproj:
Ditto.
2011-03-11 Adam Roben <aroben@apple.com>
Make it possible to view all leaks from a build at once in Leaks Viewer
......
......@@ -54,6 +54,7 @@
C0ADBE9612FCA79B00D2C129 /* simple-form.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C0ADBE8412FCA6B600D2C129 /* simple-form.html */; };
C0BD669D131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0BD669C131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp */; };
C0BD669F131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */; };
F6C59E38132AC5E000176C09 /* SendingMessagesToTheWebProcessBeforeItIsValid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6C59E37132AC5DF00176C09 /* SendingMessagesToTheWebProcessBeforeItIsValid.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
......@@ -153,6 +154,7 @@
C0ADBE8412FCA6B600D2C129 /* simple-form.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "simple-form.html"; sourceTree = "<group>"; };
C0BD669C131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResponsivenessTimerDoesntFireEarly.cpp; sourceTree = "<group>"; };
C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResponsivenessTimerDoesntFireEarly_Bundle.cpp; sourceTree = "<group>"; };
F6C59E37132AC5DF00176C09 /* SendingMessagesToTheWebProcessBeforeItIsValid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SendingMessagesToTheWebProcessBeforeItIsValid.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -275,6 +277,7 @@
C0BD669C131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp */,
C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */,
C0ADBE8212FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp */,
F6C59E37132AC5DF00176C09 /* SendingMessagesToTheWebProcessBeforeItIsValid.cpp */,
C02B77F1126612140026BF0F /* SpacebarScrolling.cpp */,
BC7B619A1299FE9E00D174A4 /* WKPreferences.cpp */,
BC90995D12567BC100083756 /* WKString.cpp */,
......@@ -429,6 +432,7 @@
1ADBEFAE130C689C00D61D19 /* ForceRepaint.cpp in Sources */,
4BFDFFA9131477770061F24B /* HitTestResultNodeHandle.cpp in Sources */,
C0BD669D131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp in Sources */,
F6C59E38132AC5E000176C09 /* SendingMessagesToTheWebProcessBeforeItIsValid.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "Test.h"
#include <WebKit2/WKRetainPtr.h>
#include <WebKit2/WKContext.h>
namespace TestWebKitAPI {
TEST(WebKit2, SendingMessagesToTheWebProcessBeforeItIsValid)
{
WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
// Neither of these calls should cause a crash.
WKContextClearResourceCaches(context.get(), kWKAllResourceCaches);
WKContextClearResourceCaches(context.get(), kWKInMemoryResourceCachesOnly);
}
} // namespace TestWebKitAPI
......@@ -495,6 +495,10 @@
RelativePath="..\Tests\WebKit2\spacebar-scrolling.html"
>
</File>
<File
RelativePath="..\Tests\WebKit2\SendingMessagesToTheWebProcessBeforeItIsValid.cpp"
>
</File>
<File
RelativePath="..\Tests\WebKit2\SpacebarScrolling.cpp"
>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment