Commit 50d391cf authored by weinig@apple.com's avatar weinig@apple.com

about:blank fake responses don't get serialized when sent the UIProcess

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

Source/WebCore: 

Reviewed by Adam Roben

Test: AboutBlankLoad

* platform/network/cf/ResourceResponse.h:
* platform/network/cf/ResourceResponseCFNet.cpp:
(WebCore::ResourceResponse::cfURLResponse):
Create a CFURLResponseRef if one does not exist yet as we do for
NSURLResponses on the mac.

Tools: 

Reviewed by Adam Roben.

* TestWebKitAPI/Tests/WebKit2/AboutBlankLoad.cpp: Added.
(TestWebKitAPI::decidePolicyForResponse):
(TestWebKitAPI::TEST):
Add test that loads of about:blank have a response with a MIMEType of text/html.

* TestWebKitAPI/PlatformUtilities.h:
* TestWebKitAPI/mac/PlatformUtilitiesMac.mm:
(TestWebKitAPI::Util::MIMETypeForWKURLResponse):
* TestWebKitAPI/win/PlatformUtilitiesWin.cpp:
(TestWebKitAPI::Util::MIMETypeForWKURLResponse):
Add helper to get the MIMEType from a WKURLResponse.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/win/TestWebKitAPI.vcproj:
Add new files.



git-svn-id: svn://svn.chromium.org/blink/trunk@81116 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c89313f3
2011-03-14 Sam Weinig <sam@webkit.org>
Reviewed by Adam Roben
about:blank fake responses don't get serialized when sent the UIProcess
<rdar://problem/9108119>
https://bugs.webkit.org/show_bug.cgi?id=56357
Test: AboutBlankLoad
* platform/network/cf/ResourceResponse.h:
* platform/network/cf/ResourceResponseCFNet.cpp:
(WebCore::ResourceResponse::cfURLResponse):
Create a CFURLResponseRef if one does not exist yet as we do for
NSURLResponses on the mac.
2011-03-14 Alexis Menard <alexis.menard@openbossa.org>
Reviewed by Kenneth Rohde Christiansen.
......
......@@ -98,9 +98,9 @@ private:
static bool platformCompare(const ResourceResponse& a, const ResourceResponse& b);
#if USE(CFNETWORK)
RetainPtr<CFURLResponseRef> m_cfResponse;
mutable RetainPtr<CFURLResponseRef> m_cfResponse;
#else
RetainPtr<NSURLResponse> m_nsResponse;
mutable RetainPtr<NSURLResponse> m_nsResponse;
#endif
bool m_isUpToDate;
};
......
......@@ -43,7 +43,14 @@ using namespace std;
namespace WebCore {
CFURLResponseRef ResourceResponse::cfURLResponse() const
{
{
if (!m_cfResponse && !m_isNull) {
RetainPtr<CFURLRef> url(AdoptCF, m_url.createCFURL());
RetainPtr<CFStringRef> mimeType(AdoptCF, m_mimeType.createCFString());
RetainPtr<CFStringRef> textEncodingName(AdoptCF, m_textEncodingName.createCFString());
m_cfResponse.adoptCF(CFURLResponseCreate(0, url.get(), mimeType.get(), m_expectedContentLength, textEncodingName.get(), kCFURLCacheStorageAllowed));
}
return m_cfResponse.get();
}
......
2011-03-14 Sam Weinig <sam@webkit.org>
Reviewed by Adam Roben.
about:blank fake responses don't get serialized when sent the UIProcess
<rdar://problem/9108119>
https://bugs.webkit.org/show_bug.cgi?id=56357
* TestWebKitAPI/Tests/WebKit2/AboutBlankLoad.cpp: Added.
(TestWebKitAPI::decidePolicyForResponse):
(TestWebKitAPI::TEST):
Add test that loads of about:blank have a response with a MIMEType of text/html.
* TestWebKitAPI/PlatformUtilities.h:
* TestWebKitAPI/mac/PlatformUtilitiesMac.mm:
(TestWebKitAPI::Util::MIMETypeForWKURLResponse):
* TestWebKitAPI/win/PlatformUtilitiesWin.cpp:
(TestWebKitAPI::Util::MIMETypeForWKURLResponse):
Add helper to get the MIMEType from a WKURLResponse.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/win/TestWebKitAPI.vcproj:
Add new files.
2011-03-14 Jarkko Sakkinen <jarkko.j.sakkinen@gmail.com>
Reviewed by Kenneth Rohde Christiansen.
......
......@@ -3,6 +3,6 @@
ProjectType="Visual C++"
Version="8.00"
Name="TestWebKitAPIDebug"
InheritedPropertySheets="$(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\common.vsprops;$(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\debug.vsprops;..\Configurations\TestWebKitAPICommon.vsprops;..\Configurations\TestWebKitAPICoreFoundation.vsprops"
InheritedPropertySheets="$(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\common.vsprops;$(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\debug.vsprops;.\TestWebKitAPICommon.vsprops;.\TestWebKitAPICoreFoundation.vsprops;.\TestWebKitAPICFNetwork.vsprops"
>
</VisualStudioPropertySheet>
......@@ -3,6 +3,6 @@
ProjectType="Visual C++"
Version="8.00"
Name="TestWebKitAPIDebugAll"
InheritedPropertySheets="$(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\common.vsprops;$(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\debug.vsprops;$(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\debug_all.vsprops;..\Configurations\TestWebKitAPICommon.vsprops;..\Configurations\TestWebKitAPICoreFoundation.vsprops"
InheritedPropertySheets="$(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\common.vsprops;$(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\debug.vsprops;$(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\debug_all.vsprops;.\TestWebKitAPICommon.vsprops;.\TestWebKitAPICoreFoundation.vsprops;.\TestWebKitAPICFNetwork.vsprops"
>
</VisualStudioPropertySheet>
......@@ -3,6 +3,6 @@
ProjectType="Visual C++"
Version="8.00"
Name="TestWebKitAPIRelease"
InheritedPropertySheets="$(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\common.vsprops;$(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\release.vsprops;..\Configurations\TestWebKitAPICommon.vsprops;..\Configurations\TestWebKitAPICoreFoundation.vsprops"
InheritedPropertySheets="$(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\common.vsprops;$(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\release.vsprops;.\TestWebKitAPICommon.vsprops;.\TestWebKitAPICoreFoundation.vsprops;.\TestWebKitAPICFNetwork.vsprops"
>
</VisualStudioPropertySheet>
......@@ -43,6 +43,7 @@ WKContextRef createContextForInjectedBundleTest(const std::string&, WKTypeRef us
WKStringRef createInjectedBundlePath();
WKURLRef createURLForResource(const char* resource, const char* extension);
WKURLRef URLForNonExistentResource();
WKRetainPtr<WKStringRef> MIMETypeForWKURLResponse(WKURLResponseRef);
bool isKeyDown(WKNativeEventPtr);
......
......@@ -18,6 +18,7 @@
BC131885117114B600B69727 /* PlatformUtilitiesMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC131884117114B600B69727 /* PlatformUtilitiesMac.mm */; };
BC131A9B1171316900B69727 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC131A9A1171316900B69727 /* main.mm */; };
BC131AA9117131FC00B69727 /* TestsController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC131AA8117131FC00B69727 /* TestsController.cpp */; };
BC246D8E132F115A00B56D7C /* AboutBlankLoad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC246D8C132F115A00B56D7C /* AboutBlankLoad.cpp */; };
BC246D9A132F1FE100B56D7C /* CanHandleRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC246D98132F1FE100B56D7C /* CanHandleRequest.cpp */; };
BC246D9C132F1FF000B56D7C /* CanHandleRequest_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC246D97132F1FE100B56D7C /* CanHandleRequest_Bundle.cpp */; };
BC2D004912A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC2D004812A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp */; };
......@@ -113,6 +114,7 @@
BC131A9A1171316900B69727 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; };
BC131A9E1171317C00B69727 /* TestWebKitAPIPrefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestWebKitAPIPrefix.h; sourceTree = "<group>"; };
BC131AA8117131FC00B69727 /* TestsController.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; path = TestsController.cpp; sourceTree = "<group>"; };
BC246D8C132F115A00B56D7C /* AboutBlankLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AboutBlankLoad.cpp; sourceTree = "<group>"; };
BC246D97132F1FE100B56D7C /* CanHandleRequest_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanHandleRequest_Bundle.cpp; sourceTree = "<group>"; };
BC246D98132F1FE100B56D7C /* CanHandleRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanHandleRequest.cpp; sourceTree = "<group>"; };
BC2D004812A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageLoadDidChangeLocationWithinPageForFrame.cpp; sourceTree = "<group>"; };
......@@ -263,6 +265,7 @@
isa = PBXGroup;
children = (
BC90977B125571AE00083756 /* Resources */,
BC246D8C132F115A00B56D7C /* AboutBlankLoad.cpp */,
BC246D97132F1FE100B56D7C /* CanHandleRequest_Bundle.cpp */,
BC246D98132F1FE100B56D7C /* CanHandleRequest.cpp */,
BCB6803F126FBFE100642A61 /* DocumentStartUserScriptAlertCrash.cpp */,
......@@ -439,6 +442,7 @@
4BFDFFA9131477770061F24B /* HitTestResultNodeHandle.cpp in Sources */,
C0BD669D131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp in Sources */,
F6C59E38132AC5E000176C09 /* SendingMessagesToTheWebProcessBeforeItIsValid.cpp in Sources */,
BC246D8E132F115A00B56D7C /* AboutBlankLoad.cpp in Sources */,
BC246D9A132F1FE100B56D7C /* CanHandleRequest.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 "PlatformUtilities.h"
#include "PlatformWebView.h"
#include <WebKit2/WebKit2.h>
namespace TestWebKitAPI {
static bool done;
static void decidePolicyForResponse(WKPageRef, WKFrameRef, WKURLResponseRef response, WKURLRequestRef, WKFramePolicyListenerRef listener, WKTypeRef, const void*)
{
TEST_ASSERT(WKStringIsEqualToUTF8CString(Util::MIMETypeForWKURLResponse(response).get(), "text/html"));
WKFramePolicyListenerUse(listener);
done = true;
}
TEST(WebKit2, AboutBlankLoad)
{
WKRetainPtr<WKContextRef> context = Util::adoptWK(WKContextCreate());
PlatformWebView webView(context.get());
WKPagePolicyClient policyClient;
memset(&policyClient, 0, sizeof(policyClient));
policyClient.decidePolicyForResponse = decidePolicyForResponse;
WKPageSetPagePolicyClient(webView.page(), &policyClient);
WKPageLoadURL(webView.page(), Util::adoptWK(WKURLCreateWithUTF8CString("about:blank")).get());
Util::run(&done);
}
} // namespace TestWebKitAPI
......@@ -28,7 +28,9 @@
#include <WebKit2/WKRetainPtr.h>
#include <WebKit2/WKStringCF.h>
#include <WebKit2/WKURLCF.h>
#include <WebKit2/WKURLResponseNS.h>
#include <WebKit2/WebKit2.h>
#include <wtf/RetainPtr.h>
namespace TestWebKitAPI {
namespace Util {
......@@ -62,6 +64,12 @@ WKURLRef URLForNonExistentResource()
return WKURLCreateWithCFURL((CFURLRef)nsURL);
}
WKRetainPtr<WKStringRef> MIMETypeForWKURLResponse(WKURLResponseRef wkResponse)
{
RetainPtr<NSURLResponse> response(AdoptNS, WKURLResponseCopyNSURLResponse(wkResponse));
return adoptWK(WKStringCreateWithCFString((CFStringRef)[response.get() MIMEType]));
}
bool isKeyDown(WKNativeEventPtr event)
{
return [event type] == NSKeyDown;
......
......@@ -29,6 +29,10 @@
#include <WebKit2/WKURLCF.h>
#include <wtf/RetainPtr.h>
#if USE(CFNETWORK)
#include <WebKit2/WKURLResponseCF.h>
#endif
namespace TestWebKitAPI {
namespace Util {
......@@ -81,6 +85,16 @@ WKURLRef URLForNonExistentResource()
return WKURLCreateWithUTF8CString("file:///does-not-exist.html");
}
WKRetainPtr<WKStringRef> MIMETypeForWKURLResponse(WKURLResponseRef wkResponse)
{
#if USE(CFNETWORK)
RetainPtr<CFURLResponseRef> response(AdoptCF, WKURLResponseCopyCFURLResponse(0, wkResponse));
return adoptWK(WKStringCreateWithCFString(CFURLResponseGetMIMEType(response.get())));
#else
return 0;
#endif
}
bool isKeyDown(WKNativeEventPtr event)
{
return event->message == WM_KEYDOWN;
......
......@@ -411,6 +411,10 @@
<Filter
Name="WebKit2"
>
<File
RelativePath="..\Tests\WebKit2\AboutBlankLoad.cpp"
>
</File>
<File
RelativePath="..\Tests\WebKit2\CanHandleRequest.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