Changeset 207388 in webkit
- Timestamp:
- Oct 16, 2016 1:35:18 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207386 r207388 1 2016-10-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Document request not updated after willSendRequest is called for a redirect 4 https://bugs.webkit.org/show_bug.cgi?id=163436 5 6 Reviewed by Michael Catanzaro. 7 8 The first willSendRequest happens before DocumentLoader::startLoadingMainResource(), that calls setRequest, but 9 the second one happens after DocumentLoader::redirectReceived() and then the request is never updated again. 10 11 Covered by GTK+ unit tests. 12 13 * loader/DocumentLoader.cpp: 14 (WebCore::DocumentLoader::willContinueMainResourceLoadAfterRedirect): Set the new request. 15 * loader/DocumentLoader.h: 16 * loader/SubresourceLoader.cpp: 17 (WebCore::SubresourceLoader::willSendRequestInternal): Notify the document loader when loading the main resource 18 and called for a redirection. 19 1 20 2016-10-15 Said Abou-Hallawa <sabouhallawa@apple.com> 2 21 -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r207325 r207388 1630 1630 } 1631 1631 1632 void DocumentLoader::willContinueMainResourceLoadAfterRedirect(const ResourceRequest& newRequest) 1633 { 1634 setRequest(newRequest); 1635 } 1636 1632 1637 void DocumentLoader::clearMainResource() 1633 1638 { -
trunk/Source/WebCore/loader/DocumentLoader.h
r207151 r207388 214 214 void startLoadingMainResource(); 215 215 WEBCORE_EXPORT void cancelMainResourceLoad(const ResourceError&); 216 216 void willContinueMainResourceLoadAfterRedirect(const ResourceRequest&); 217 217 218 // Support iconDatabase in synchronous mode. 218 219 void iconLoadDecisionAvailable(); -
trunk/Source/WebCore/loader/SubresourceLoader.cpp
r206869 r207388 230 230 231 231 ResourceLoader::willSendRequestInternal(newRequest, redirectResponse); 232 if (newRequest.isNull()) 232 if (newRequest.isNull()) { 233 233 cancel(); 234 return; 235 } 236 237 if (m_resource->type() == CachedResource::MainResource && !redirectResponse.isNull()) 238 m_documentLoader->willContinueMainResourceLoadAfterRedirect(newRequest); 234 239 } 235 240 -
trunk/Tools/ChangeLog
r207385 r207388 1 2016-10-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Document request not updated after willSendRequest is called for a redirect 4 https://bugs.webkit.org/show_bug.cgi?id=163436 5 6 Reviewed by Michael Catanzaro. 7 8 Update /webkit2/WebKitWebView/active-uri test to check the active URI also when modified by 9 WebKitPage::send-request signal in a web extension. 10 11 * TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp: 12 (testWebViewActiveURI): 13 (serverCallback): 14 * TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp: 15 (sendRequestCallback): 16 * TestWebKitAPI/gtk/WebKit2Gtk/LoadTrackingTest.cpp: 17 (loadChangedCallback): 18 1 19 2016-10-15 Dan Bernstein <mitz@apple.com> 2 20 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp
r194480 r207388 28 28 #include <gtk/gtk.h> 29 29 #include <libsoup/soup.h> 30 #include <wtf/Vector.h> 30 31 #include <wtf/text/CString.h> 31 32 … … 210 211 static void uriChanged(GObject*, GParamSpec*, ViewURITrackingTest* test) 211 212 { 212 g_assert_cmpstr(test->m_ activeURI.data(), !=, webkit_web_view_get_uri(test->m_webView));213 test->m_ activeURI = webkit_web_view_get_uri(test->m_webView);213 g_assert_cmpstr(test->m_currentURI.data(), !=, webkit_web_view_get_uri(test->m_webView)); 214 test->m_currentURI = webkit_web_view_get_uri(test->m_webView); 214 215 } 215 216 216 217 ViewURITrackingTest() 217 : m_activeURI(webkit_web_view_get_uri(m_webView)) 218 { 219 g_assert(m_activeURI.isNull()); 218 : m_currentURI(webkit_web_view_get_uri(m_webView)) 219 { 220 g_assert(m_currentURI.isNull()); 221 m_currentURIList.grow(m_currentURIList.capacity()); 220 222 g_signal_connect(m_webView, "notify::uri", G_CALLBACK(uriChanged), this); 221 223 } 222 224 225 enum State { Provisional, ProvisionalAfterRedirect, Commited, Finished }; 226 227 void loadURI(const char* uri) 228 { 229 reset(); 230 LoadTrackingTest::loadURI(uri); 231 } 232 223 233 void provisionalLoadStarted() 224 234 { 225 checkActiveURI("/redirect");235 m_currentURIList[Provisional] = m_currentURI; 226 236 } 227 237 228 238 void provisionalLoadReceivedServerRedirect() 229 239 { 230 checkActiveURI("/normal");240 m_currentURIList[ProvisionalAfterRedirect] = m_currentURI; 231 241 } 232 242 233 243 void loadCommitted() 234 244 { 235 checkActiveURI("/normal");245 m_currentURIList[Commited] = m_currentURI; 236 246 } 237 247 238 248 void loadFinished() 239 249 { 240 checkActiveURI("/normal");250 m_currentURIList[Finished] = m_currentURI; 241 251 LoadTrackingTest::loadFinished(); 242 252 } 243 253 244 CString m_activeURI; 254 void checkURIAtState(State state, const char* path) 255 { 256 if (path) 257 ASSERT_CMP_CSTRING(m_currentURIList[state], ==, kServer->getURIForPath(path)); 258 else 259 g_assert(m_currentURIList[state].isNull()); 260 } 245 261 246 262 private: 247 void checkActiveURI(const char* uri) 248 { 249 ASSERT_CMP_CSTRING(m_activeURI, ==, kServer->getURIForPath(uri)); 250 } 263 void reset() 264 { 265 m_currentURI = CString(); 266 m_currentURIList.clear(); 267 m_currentURIList.grow(m_currentURIList.capacity()); 268 } 269 270 CString m_currentURI; 271 Vector<CString, 4> m_currentURIList; 251 272 }; 252 273 253 274 static void testWebViewActiveURI(ViewURITrackingTest* test, gconstpointer) 254 275 { 276 // Normal load, the URL doesn't change. 277 test->loadURI(kServer->getURIForPath("/normal1").data()); 278 test->waitUntilLoadFinished(); 279 test->checkURIAtState(ViewURITrackingTest::State::Provisional, "/normal1"); 280 test->checkURIAtState(ViewURITrackingTest::State::ProvisionalAfterRedirect, nullptr); 281 test->checkURIAtState(ViewURITrackingTest::State::Commited, "/normal1"); 282 test->checkURIAtState(ViewURITrackingTest::State::Finished, "/normal1"); 283 284 // Redirect, the URL changes after the redirect. 255 285 test->loadURI(kServer->getURIForPath("/redirect").data()); 256 286 test->waitUntilLoadFinished(); 287 test->checkURIAtState(ViewURITrackingTest::State::Provisional, "/redirect"); 288 test->checkURIAtState(ViewURITrackingTest::State::ProvisionalAfterRedirect, "/normal"); 289 test->checkURIAtState(ViewURITrackingTest::State::Commited, "/normal"); 290 test->checkURIAtState(ViewURITrackingTest::State::Finished, "/normal"); 291 292 // Normal load, URL changed by WebKitPage::send-request. 293 test->loadURI(kServer->getURIForPath("/normal-change-request").data()); 294 test->waitUntilLoadFinished(); 295 test->checkURIAtState(ViewURITrackingTest::State::Provisional, "/normal-change-request"); 296 test->checkURIAtState(ViewURITrackingTest::State::ProvisionalAfterRedirect, nullptr); 297 test->checkURIAtState(ViewURITrackingTest::State::Commited, "/request-changed"); 298 test->checkURIAtState(ViewURITrackingTest::State::Finished, "/request-changed"); 299 300 // Redirect, URL changed by WebKitPage::send-request. 301 test->loadURI(kServer->getURIForPath("/redirect-to-change-request").data()); 302 test->waitUntilLoadFinished(); 303 test->checkURIAtState(ViewURITrackingTest::State::Provisional, "/redirect-to-change-request"); 304 test->checkURIAtState(ViewURITrackingTest::State::ProvisionalAfterRedirect, "/normal-change-request"); 305 test->checkURIAtState(ViewURITrackingTest::State::Commited, "/request-changed-on-redirect"); 306 test->checkURIAtState(ViewURITrackingTest::State::Finished, "/request-changed-on-redirect"); 257 307 } 258 308 … … 485 535 soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY); 486 536 soup_message_headers_append(message->response_headers, "Location", "/normal"); 537 } else if (g_str_equal(path, "/redirect-to-change-request")) { 538 soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY); 539 soup_message_headers_append(message->response_headers, "Location", "/normal-change-request"); 487 540 } else if (g_str_equal(path, "/cancelled")) { 488 541 soup_message_headers_set_encoding(message->response_headers, SOUP_ENCODING_CHUNKED); -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp
r205540 r207388 155 155 g_assert(headers); 156 156 soup_message_headers_append(headers, "DNT", "1"); 157 } else if (g_str_has_suffix(requestURI, "/normal-change-request")) { 158 GUniquePtr<char> prefix(g_strndup(requestURI, strlen(requestURI) - strlen("/normal-change-request"))); 159 GUniquePtr<char> newURI(g_strdup_printf("%s/request-changed%s", prefix.get(), redirectResponse ? "-on-redirect" : "")); 160 webkit_uri_request_set_uri(request, newURI.get()); 157 161 } else if (g_str_has_suffix(requestURI, "/http-get-method")) { 158 162 g_assert_cmpstr(webkit_uri_request_get_http_method(request), ==, "GET"); -
trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/LoadTrackingTest.cpp
r193815 r207388 40 40 case WEBKIT_LOAD_COMMITTED: { 41 41 g_assert(webkit_web_view_is_loading(webView)); 42 g_assert_cmpstr(test->m_activeURI.data(), ==, webkit_web_view_get_uri(webView));42 test->m_activeURI = webkit_web_view_get_uri(webView); 43 43 44 44 // Check that on committed we always have a main resource with a response.
Note: See TracChangeset
for help on using the changeset viewer.