Skip to content
Permalink
Browse files
WKURLRefs should be allowed to be null
<rdar://problem/8575621>
https://bugs.webkit.org/show_bug.cgi?id=48535

Reviewed by Anders Carlsson.

WebKit2:

* Shared/API/c/WKSharedAPICast.h:
(WebKit::toURLRef):
(WebKit::toCopiedURLAPI):
Turn a null WTF::String into a null WKURLRef.

WebKitTools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp:
(TestWebKitAPI::didStartProvisionalLoadForFrame):
(TestWebKitAPI::didCommitLoadForFrame):
(TestWebKitAPI::didFinishLoadForFrame):
Test that URLs are null pointers when unset.



Canonical link: https://commits.webkit.org/61309@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70795 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
weinig committed Oct 28, 2010
1 parent f2d9c0b commit c3c2aa86a289afddea6c2bad165eb2e77307b59f
Showing 5 changed files with 50 additions and 9 deletions.
@@ -1,3 +1,16 @@
2010-10-28 Sam Weinig <sam@webkit.org>

Reviewed by Anders Carlsson.

WKURLRefs should be allowed to be null
<rdar://problem/8575621>
https://bugs.webkit.org/show_bug.cgi?id=48535

* Shared/API/c/WKSharedAPICast.h:
(WebKit::toURLRef):
(WebKit::toCopiedURLAPI):
Turn a null WTF::String into a null WKURLRef.

2010-10-28 Sam Weinig <sam@webkit.org>

Reviewed by Anders Carlsson.
@@ -117,23 +117,25 @@ inline ProxyingRefPtr<WebString> toAPI(StringImpl* string)
return ProxyingRefPtr<WebString>(WebString::create(String(impl)));
}

inline ProxyingRefPtr<WebURL> toURLRef(StringImpl* string)
{
StringImpl* impl = string ? string : StringImpl::empty();
return ProxyingRefPtr<WebURL>(WebURL::create(String(impl)));
}

inline WKStringRef toCopiedAPI(const String& string)
{
StringImpl* impl = string.impl() ? string.impl() : StringImpl::empty();
RefPtr<WebString> webString = WebString::create(String(impl));
return toAPI(webString.release().releaseRef());
}

inline ProxyingRefPtr<WebURL> toURLRef(StringImpl* string)
{
if (!string)
ProxyingRefPtr<WebURL>(0);
return ProxyingRefPtr<WebURL>(WebURL::create(String(string)));
}

inline WKURLRef toCopiedURLAPI(const String& string)
{
StringImpl* impl = string.impl() ? string.impl() : StringImpl::empty();
RefPtr<WebURL> webURL = WebURL::create(String(impl));
if (!string)
return 0;
RefPtr<WebURL> webURL = WebURL::create(string);
return toAPI(webURL.release().releaseRef());
}

@@ -1,3 +1,18 @@
2010-10-28 Sam Weinig <sam@webkit.org>

Reviewed by Anders Carlsson.

WKURLRefs should be allowed to be null
<rdar://problem/8575621>
https://bugs.webkit.org/show_bug.cgi?id=48535

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp:
(TestWebKitAPI::didStartProvisionalLoadForFrame):
(TestWebKitAPI::didCommitLoadForFrame):
(TestWebKitAPI::didFinishLoadForFrame):
Test that URLs are null pointers when unset.

2010-10-28 Chris Fleizach <cfleizach@apple.com>

Reviewed by Adele Peterson.
@@ -256,8 +256,8 @@
BC90977B125571AE00083756 /* Resources */ = {
isa = PBXGroup;
children = (
BCBD372E125ABBE600D2C29F /* icon.png */,
1A02C84B125D4A5E00E3F4BD /* find.html */,
BCBD372E125ABBE600D2C29F /* icon.png */,
BC909778125571AB00083756 /* simple.html */,
C02B7882126615410026BF0F /* spacebar-scrolling.html */,
);
@@ -52,8 +52,13 @@ static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WK
State* state = reinterpret_cast<State*>(const_cast<void*>(clientInfo));
TEST_ASSERT(state->didDecidePolicyForNavigationAction);
TEST_ASSERT(!state->didCommitLoadForFrame);

// The commited URL should be null.
TEST_ASSERT(!WKFrameCopyURL(frame));

TEST_ASSERT(!state->didStartProvisionalLoadForFrame);


state->didStartProvisionalLoadForFrame = true;
}

@@ -63,6 +68,9 @@ static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef us
TEST_ASSERT(state->didDecidePolicyForNavigationAction);
TEST_ASSERT(state->didStartProvisionalLoadForFrame);

// The provisional URL should be null.
TEST_ASSERT(!WKFrameCopyProvisionalURL(frame));

state->didCommitLoadForFrame = true;
}

@@ -73,6 +81,9 @@ static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef us
TEST_ASSERT(state->didStartProvisionalLoadForFrame);
TEST_ASSERT(state->didCommitLoadForFrame);

// The provisional URL should be null.
TEST_ASSERT(!WKFrameCopyProvisionalURL(frame));

test1Done = true;
}

0 comments on commit c3c2aa8

Please sign in to comment.