Skip to content

Commit f850784

Browse files
Pending API request URL no set when loading Data, Alternate HTML or plain text
https://bugs.webkit.org/show_bug.cgi?id=136916 Reviewed by Darin Adler. Source/WebKit2: Set pending API request URL for all load methods in WebPageProxy. This ensures that right after calling those methods, the active URL is the requested one and that PageLoadState::isLoading() returns true. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::loadAlternateHTMLString): (WebKit::WebPageProxy::loadPlainTextString): (WebKit::WebPageProxy::loadWebArchiveData): Tools: Add new test to check that active URL is the requested one right after calling WKPage load methods. * TestWebKitAPI/PlatformEfl.cmake: * TestWebKitAPI/PlatformGTK.cmake: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit2/PendingAPIRequestURL.cpp: Added. (TestWebKitAPI::TEST): * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp: (WebViewTest::loadPlainText): Remove FIXME. (WebViewTest::loadBytes): Ditto. (WebViewTest::loadAlternateHTML): Ditto. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@199663 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 2a31459 commit f850784

File tree

8 files changed

+155
-14
lines changed

8 files changed

+155
-14
lines changed

Source/WebKit2/ChangeLog

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
2016-04-18 Carlos Garcia Campos <[email protected]>
2+
3+
Pending API request URL no set when loading Data, Alternate HTML or plain text
4+
https://bugs.webkit.org/show_bug.cgi?id=136916
5+
6+
Reviewed by Darin Adler.
7+
8+
Set pending API request URL for all load methods in
9+
WebPageProxy. This ensures that right after calling those methods,
10+
the active URL is the requested one and that
11+
PageLoadState::isLoading() returns true.
12+
13+
* UIProcess/WebPageProxy.cpp:
14+
(WebKit::WebPageProxy::loadAlternateHTMLString):
15+
(WebKit::WebPageProxy::loadPlainTextString):
16+
(WebKit::WebPageProxy::loadWebArchiveData):
17+
118
2016-04-18 Commit Queue <[email protected]>
219

320
Unreviewed, rolling out r199660.

Source/WebKit2/UIProcess/WebPageProxy.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ RefPtr<API::Navigation> WebPageProxy::loadData(API::Data* data, const String& MI
971971

972972
auto transaction = m_pageLoadState.transaction();
973973

974-
m_pageLoadState.setPendingAPIRequestURL(transaction, !baseURL.isEmpty() ? baseURL : ASCIILiteral("about:blank"));
974+
m_pageLoadState.setPendingAPIRequestURL(transaction, !baseURL.isEmpty() ? baseURL : blankURL().string());
975975

976976
if (!isValid())
977977
reattachToWebProcess();
@@ -993,7 +993,7 @@ RefPtr<API::Navigation> WebPageProxy::loadHTMLString(const String& htmlString, c
993993

994994
auto transaction = m_pageLoadState.transaction();
995995

996-
m_pageLoadState.setPendingAPIRequestURL(transaction, !baseURL.isEmpty() ? baseURL : ASCIILiteral("about:blank"));
996+
m_pageLoadState.setPendingAPIRequestURL(transaction, !baseURL.isEmpty() ? baseURL : blankURL().string());
997997

998998
if (!isValid())
999999
reattachToWebProcess();
@@ -1021,6 +1021,7 @@ void WebPageProxy::loadAlternateHTMLString(const String& htmlString, const Strin
10211021

10221022
auto transaction = m_pageLoadState.transaction();
10231023

1024+
m_pageLoadState.setPendingAPIRequestURL(transaction, unreachableURL);
10241025
m_pageLoadState.setUnreachableURL(transaction, unreachableURL);
10251026

10261027
if (m_mainFrame)
@@ -1040,6 +1041,9 @@ void WebPageProxy::loadPlainTextString(const String& string, API::Object* userDa
10401041
if (!isValid())
10411042
reattachToWebProcess();
10421043

1044+
auto transaction = m_pageLoadState.transaction();
1045+
m_pageLoadState.setPendingAPIRequestURL(transaction, blankURL().string());
1046+
10431047
m_process->send(Messages::WebPage::LoadPlainTextString(string, UserData(process().transformObjectsToHandles(userData).get())), m_pageID);
10441048
m_process->responsivenessTimer().start();
10451049
}
@@ -1052,6 +1056,9 @@ void WebPageProxy::loadWebArchiveData(API::Data* webArchiveData, API::Object* us
10521056
if (!isValid())
10531057
reattachToWebProcess();
10541058

1059+
auto transaction = m_pageLoadState.transaction();
1060+
m_pageLoadState.setPendingAPIRequestURL(transaction, blankURL().string());
1061+
10551062
m_process->send(Messages::WebPage::LoadWebArchiveData(webArchiveData->dataReference(), UserData(process().transformObjectsToHandles(userData).get())), m_pageID);
10561063
m_process->responsivenessTimer().start();
10571064
}

Tools/ChangeLog

+20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
2016-04-18 Carlos Garcia Campos <[email protected]>
2+
3+
Pending API request URL no set when loading Data, Alternate HTML or plain text
4+
https://bugs.webkit.org/show_bug.cgi?id=136916
5+
6+
Reviewed by Darin Adler.
7+
8+
Add new test to check that active URL is the requested one right
9+
after calling WKPage load methods.
10+
11+
* TestWebKitAPI/PlatformEfl.cmake:
12+
* TestWebKitAPI/PlatformGTK.cmake:
13+
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
14+
* TestWebKitAPI/Tests/WebKit2/PendingAPIRequestURL.cpp: Added.
15+
(TestWebKitAPI::TEST):
16+
* TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp:
17+
(WebViewTest::loadPlainText): Remove FIXME.
18+
(WebViewTest::loadBytes): Ditto.
19+
(WebViewTest::loadAlternateHTML): Ditto.
20+
121
2016-04-18 Commit Queue <[email protected]>
222

323
Unreviewed, rolling out r199660.

Tools/TestWebKitAPI/PlatformEfl.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ set(test_webkit2_api_BINARIES
9494
PageLoadBasic
9595
PageLoadDidChangeLocationWithinPageForFrame
9696
ParentFrame
97+
PendingAPIRequestURL
9798
PreventEmptyUserAgent
9899
PrivateBrowsingPushStateNoHistoryCallback
99100
ResponsivenessTimerDoesntFireEarly

Tools/TestWebKitAPI/PlatformGTK.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ add_executable(TestWebKit2
9898
${TESTWEBKITAPI_DIR}/Tests/WebKit2/PageLoadBasic.cpp
9999
${TESTWEBKITAPI_DIR}/Tests/WebKit2/PageLoadDidChangeLocationWithinPageForFrame.cpp
100100
${TESTWEBKITAPI_DIR}/Tests/WebKit2/ParentFrame.cpp
101+
${TESTWEBKITAPI_DIR}/Tests/WebKit2/PendingAPIRequestURL.cpp
101102
${TESTWEBKITAPI_DIR}/Tests/WebKit2/PreventEmptyUserAgent.cpp
102103
${TESTWEBKITAPI_DIR}/Tests/WebKit2/PrivateBrowsingPushStateNoHistoryCallback.cpp
103104
${TESTWEBKITAPI_DIR}/Tests/WebKit2/ReloadPageAfterCrash.cpp

Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
0766DD201A5AD5200023E3BB /* PendingAPIRequestURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0766DD1F1A5AD5200023E3BB /* PendingAPIRequestURL.cpp */; };
1011
0F139E771A423A5B00F590F5 /* WeakObjCPtr.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F139E751A423A5300F590F5 /* WeakObjCPtr.mm */; };
1112
0F139E781A423A6B00F590F5 /* PlatformUtilitiesCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */; };
1213
0F139E791A42457000F590F5 /* PlatformUtilitiesCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */; };
@@ -506,6 +507,7 @@
506507
/* Begin PBXFileReference section */
507508
00BC16851680FE810065F1E5 /* PublicSuffix.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PublicSuffix.mm; sourceTree = "<group>"; };
508509
00CD9F6215BE312C002DA2CE /* BackForwardList.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BackForwardList.mm; sourceTree = "<group>"; };
510+
0766DD1F1A5AD5200023E3BB /* PendingAPIRequestURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PendingAPIRequestURL.cpp; sourceTree = "<group>"; };
509511
0BCD833414857CE400EA2003 /* HashMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HashMap.cpp; sourceTree = "<group>"; };
510512
0BCD85691485C98B00EA2003 /* TemporaryChange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TemporaryChange.cpp; sourceTree = "<group>"; };
511513
0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PlatformUtilitiesCocoa.mm; path = cocoa/PlatformUtilitiesCocoa.mm; sourceTree = "<group>"; };
@@ -1199,6 +1201,7 @@
11991201
BC9096411255616000083756 /* WebKit2 */ = {
12001202
isa = PBXGroup;
12011203
children = (
1204+
0766DD1F1A5AD5200023E3BB /* PendingAPIRequestURL.cpp */,
12021205
0F139E741A423A4600F590F5 /* cocoa */,
12031206
C0C5D3BB14598B6F00A802A6 /* mac */,
12041207
BC90977B125571AE00083756 /* Resources */,
@@ -1952,6 +1955,7 @@
19521955
isa = PBXSourcesBuildPhase;
19531956
buildActionMask = 2147483647;
19541957
files = (
1958+
0766DD201A5AD5200023E3BB /* PendingAPIRequestURL.cpp in Sources */,
19551959
2D9A53AF1B31FA8D0074D5AA /* ShrinkToFit.mm in Sources */,
19561960
51B454EC1B4E236B0085EAA6 /* WebViewCloseInsideDidFinishLoadForFrame.mm in Sources */,
19571961
57901FAD1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm in Sources */,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* Copyright (C) 2014 Igalia S.L.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "config.h"
27+
28+
#if WK_HAVE_C_SPI
29+
30+
#include "PlatformUtilities.h"
31+
#include "PlatformWebView.h"
32+
#include "Test.h"
33+
#include <WebKit/WKRetainPtr.h>
34+
35+
namespace TestWebKitAPI {
36+
37+
TEST(WebKit2, PendingAPIRequestURL)
38+
{
39+
WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
40+
PlatformWebView webView(context.get());
41+
42+
WKRetainPtr<WKURLRef> activeURL = adoptWK(WKPageCopyActiveURL(webView.page()));
43+
EXPECT_NULL(activeURL.get());
44+
45+
WKRetainPtr<WKURLRef> url = adoptWK(Util::createURLForResource("simple", "html"));
46+
WKPageLoadURL(webView.page(), url.get());
47+
activeURL = adoptWK(WKPageCopyActiveURL(webView.page()));
48+
ASSERT_NOT_NULL(activeURL.get());
49+
EXPECT_TRUE(WKURLIsEqual(activeURL.get(), url.get()));
50+
WKPageStopLoading(webView.page());
51+
52+
WKRetainPtr<WKStringRef> htmlString = Util::toWK("<body>Hello, World</body>");
53+
WKRetainPtr<WKURLRef> blankURL = adoptWK(WKURLCreateWithUTF8CString("about:blank"));
54+
WKPageLoadHTMLString(webView.page(), htmlString.get(), nullptr);
55+
activeURL = adoptWK(WKPageCopyActiveURL(webView.page()));
56+
ASSERT_NOT_NULL(activeURL.get());
57+
EXPECT_TRUE(WKURLIsEqual(activeURL.get(), blankURL.get()));
58+
WKPageStopLoading(webView.page());
59+
60+
url = adoptWK(WKURLCreateWithUTF8CString("http://www.webkit.org"));
61+
WKPageLoadHTMLString(webView.page(), htmlString.get(), url.get());
62+
activeURL = adoptWK(WKPageCopyActiveURL(webView.page()));
63+
ASSERT_NOT_NULL(activeURL.get());
64+
EXPECT_TRUE(WKURLIsEqual(activeURL.get(), url.get()));
65+
WKPageStopLoading(webView.page());
66+
67+
WKRetainPtr<WKDataRef> data = adoptWK(WKDataCreate(nullptr, 0));
68+
WKPageLoadData(webView.page(), data.get(), nullptr, nullptr, nullptr);
69+
activeURL = adoptWK(WKPageCopyActiveURL(webView.page()));
70+
ASSERT_NOT_NULL(activeURL.get());
71+
EXPECT_TRUE(WKURLIsEqual(activeURL.get(), blankURL.get()));
72+
WKPageStopLoading(webView.page());
73+
74+
WKPageLoadData(webView.page(), data.get(), nullptr, nullptr, url.get());
75+
activeURL = adoptWK(WKPageCopyActiveURL(webView.page()));
76+
ASSERT_NOT_NULL(activeURL.get());
77+
EXPECT_TRUE(WKURLIsEqual(activeURL.get(), url.get()));
78+
WKPageStopLoading(webView.page());
79+
80+
WKPageLoadAlternateHTMLString(webView.page(), htmlString.get(), nullptr, url.get());
81+
activeURL = adoptWK(WKPageCopyActiveURL(webView.page()));
82+
ASSERT_NOT_NULL(activeURL.get());
83+
EXPECT_TRUE(WKURLIsEqual(activeURL.get(), url.get()));
84+
WKPageStopLoading(webView.page());
85+
86+
WKRetainPtr<WKStringRef> plainTextString = Util::toWK("Hello, World");
87+
WKPageLoadPlainTextString(webView.page(), plainTextString.get());
88+
activeURL = adoptWK(WKPageCopyActiveURL(webView.page()));
89+
ASSERT_NOT_NULL(activeURL.get());
90+
EXPECT_TRUE(WKURLIsEqual(activeURL.get(), blankURL.get()));
91+
WKPageStopLoading(webView.page());
92+
93+
url = adoptWK(WKURLCreateWithUTF8CString("file:///tmp/index.html"));
94+
WKPageLoadFile(webView.page(), url.get(), nullptr);
95+
activeURL = adoptWK(WKPageCopyActiveURL(webView.page()));
96+
ASSERT_NOT_NULL(activeURL.get());
97+
EXPECT_TRUE(WKURLIsEqual(activeURL.get(), url.get()));
98+
WKPageStopLoading(webView.page());
99+
}
100+
101+
} // namespace TestWebKitAPI
102+
103+
#endif

Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,8 @@ void WebViewTest::loadPlainText(const char* plainText)
8282
{
8383
m_activeURI = "about:blank";
8484
webkit_web_view_load_plain_text(m_webView, plainText);
85-
#if 0
86-
// FIXME: Pending API request URL no set when loading plain text.
87-
// See https://bugs.webkit.org/show_bug.cgi?id=136916.
8885
g_assert(webkit_web_view_is_loading(m_webView));
8986
g_assert_cmpstr(webkit_web_view_get_uri(m_webView), ==, m_activeURI.data());
90-
#endif
9187
}
9288

9389
void WebViewTest::loadBytes(GBytes* bytes, const char* mimeType, const char* encoding, const char* baseURI)
@@ -97,12 +93,8 @@ void WebViewTest::loadBytes(GBytes* bytes, const char* mimeType, const char* enc
9793
else
9894
m_activeURI = baseURI;
9995
webkit_web_view_load_bytes(m_webView, bytes, mimeType, encoding, baseURI);
100-
#if 0
101-
// FIXME: Pending API request URL no set when loading data.
102-
// See https://bugs.webkit.org/show_bug.cgi?id=136916.
10396
g_assert(webkit_web_view_is_loading(m_webView));
10497
g_assert_cmpstr(webkit_web_view_get_uri(m_webView), ==, m_activeURI.data());
105-
#endif
10698
}
10799

108100
void WebViewTest::loadRequest(WebKitURIRequest* request)
@@ -117,11 +109,7 @@ void WebViewTest::loadAlternateHTML(const char* html, const char* contentURI, co
117109
{
118110
m_activeURI = contentURI;
119111
webkit_web_view_load_alternate_html(m_webView, html, contentURI, baseURI);
120-
#if 0
121-
// FIXME: Pending API request URL no set when loading Alternate HTML.
122-
// See https://bugs.webkit.org/show_bug.cgi?id=136916.
123112
g_assert(webkit_web_view_is_loading(m_webView));
124-
#endif
125113
g_assert_cmpstr(webkit_web_view_get_uri(m_webView), ==, m_activeURI.data());
126114
}
127115

0 commit comments

Comments
 (0)