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

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameFetchContextTest.cpp

Issue 1783653002: save-data header value gets appended on page refreshes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed japhet comments Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015, Google Inc. All rights reserved. 2 * Copyright (c) 2015, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 EXPECT_EQ(ResourceLoadPriorityVeryLow, childFetchContext->modifyPriorityForE xperiments(ResourceLoadPriorityMedium, Resource::Script, request, ResourcePriori ty::NotVisible)); 550 EXPECT_EQ(ResourceLoadPriorityVeryLow, childFetchContext->modifyPriorityForE xperiments(ResourceLoadPriorityMedium, Resource::Script, request, ResourcePriori ty::NotVisible));
551 } 551 }
552 552
553 TEST_F(FrameFetchContextTest, EnableDataSaver) 553 TEST_F(FrameFetchContextTest, EnableDataSaver)
554 { 554 {
555 Settings* settings = document->frame()->settings(); 555 Settings* settings = document->frame()->settings();
556 settings->setDataSaverEnabled(true); 556 settings->setDataSaverEnabled(true);
557 ResourceRequest resourceRequest("http://www.example.com"); 557 ResourceRequest resourceRequest("http://www.example.com");
558 fetchContext->addAdditionalRequestHeaders(resourceRequest, FetchMainResource ); 558 fetchContext->addAdditionalRequestHeaders(resourceRequest, FetchMainResource );
559 EXPECT_STREQ("on", resourceRequest.httpHeaderField("Save-Data").utf8().data( )); 559 EXPECT_STREQ("on", resourceRequest.httpHeaderField("Save-Data").utf8().data( ));
560
561 // Subsequent call to addAdditionalRequestHeaders should not append to the
562 // save-data header.
563 fetchContext->addAdditionalRequestHeaders(resourceRequest, FetchMainResource );
564 EXPECT_STREQ("on", resourceRequest.httpHeaderField("Save-Data").utf8().data( ));
560 } 565 }
561 566
562 TEST_F(FrameFetchContextTest, DisabledDataSaver) 567 TEST_F(FrameFetchContextTest, DisabledDataSaver)
563 { 568 {
564 ResourceRequest resourceRequest("http://www.example.com"); 569 ResourceRequest resourceRequest("http://www.example.com");
565 fetchContext->addAdditionalRequestHeaders(resourceRequest, FetchMainResource ); 570 fetchContext->addAdditionalRequestHeaders(resourceRequest, FetchMainResource );
566 EXPECT_STREQ("", resourceRequest.httpHeaderField("Save-Data").utf8().data()) ; 571 EXPECT_STREQ("", resourceRequest.httpHeaderField("Save-Data").utf8().data()) ;
567 } 572 }
568 573
569 // Tests that when a resource with certificate errors is loaded from the 574 // Tests that when a resource with certificate errors is loaded from the
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource ); 722 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource );
718 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation); 723 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation);
719 724
720 ResourceRequest subRequest(test.url); 725 ResourceRequest subRequest(test.url);
721 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); 726 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource);
722 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation); 727 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation);
723 } 728 }
724 } 729 }
725 730
726 } // namespace blink 731 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698