Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Unified Diff: third_party/WebKit/Source/core/loader/PingLoaderTest.cpp

Issue 2982523002: Set "ping" requests priority as lowest (Closed)
Patch Set: fix Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/loader/PingLoaderTest.cpp
diff --git a/third_party/WebKit/Source/core/loader/PingLoaderTest.cpp b/third_party/WebKit/Source/core/loader/PingLoaderTest.cpp
index ced63815971338b845e762307bb722f9787b0829..e1c904da525989111e731353137548d878ff4c68 100644
--- a/third_party/WebKit/Source/core/loader/PingLoaderTest.cpp
+++ b/third_party/WebKit/Source/core/loader/PingLoaderTest.cpp
@@ -23,7 +23,7 @@ namespace {
class PingLocalFrameClient : public EmptyLocalFrameClient {
public:
void DispatchWillSendRequest(ResourceRequest& request) override {
- if (request.HttpContentType() == "text/ping")
+ if (request.GetKeepalive())
ping_request_ = request;
}
@@ -71,7 +71,7 @@ class PingLoaderTest : public ::testing::Test {
return ping_request;
}
- private:
+ protected:
Persistent<PingLocalFrameClient> client_;
std::unique_ptr<DummyPageHolder> page_holder_;
};
@@ -103,6 +103,52 @@ TEST_F(PingLoaderTest, NonHTTPPingTarget) {
ASSERT_TRUE(ping_request.IsNull());
}
+TEST_F(PingLoaderTest, LoadImagePriority) {
+ SetDocumentURL(KURL(kParsedURLString, "http://localhost/foo.html"));
+
+ KURL ping_url(kParsedURLString, "https://localhost/bar.html");
+ URLTestHelpers::RegisterMockedURLLoad(
+ ping_url, testing::CoreTestDataPath("bar.html"), "text/html");
+ PingLoader::LoadImage(&page_holder_->GetFrame(), ping_url);
+ Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests();
+ const ResourceRequest& request = client_->PingRequest();
+ ASSERT_FALSE(request.IsNull());
+ ASSERT_EQ(request.Url(), ping_url);
+ EXPECT_EQ(kResourceLoadPriorityVeryLow, request.Priority());
+}
+
+TEST_F(PingLoaderTest, LinkAuditPingPriority) {
+ KURL destination_url(kParsedURLString, "http://navigation.destination");
+ SetDocumentURL(KURL(kParsedURLString, "http://localhost/foo.html"));
+
+ KURL ping_url(kParsedURLString, "https://localhost/bar.html");
+ URLTestHelpers::RegisterMockedURLLoad(
+ ping_url, testing::CoreTestDataPath("bar.html"), "text/html");
+ PingLoader::SendLinkAuditPing(&page_holder_->GetFrame(), ping_url,
+ destination_url);
+ Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests();
+ const ResourceRequest& request = client_->PingRequest();
+ ASSERT_FALSE(request.IsNull());
+ ASSERT_EQ(request.Url(), ping_url);
+ EXPECT_EQ(kResourceLoadPriorityVeryLow, request.Priority());
+}
+
+TEST_F(PingLoaderTest, BeaconPriority) {
+ SetDocumentURL(KURL(kParsedURLString, "https://localhost/foo.html"));
+
+ KURL ping_url(kParsedURLString, "https://localhost/bar.html");
+ URLTestHelpers::RegisterMockedURLLoad(
+ ping_url, testing::CoreTestDataPath("bar.html"), "text/html");
+ size_t size = 0;
+ PingLoader::SendBeacon(&page_holder_->GetFrame(), 123, ping_url, "hello",
+ size);
+ Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests();
+ const ResourceRequest& request = client_->PingRequest();
+ ASSERT_FALSE(request.IsNull());
+ ASSERT_EQ(request.Url(), ping_url);
+ EXPECT_EQ(kResourceLoadPriorityVeryLow, request.Priority());
+}
+
} // namespace
} // namespace blink
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698