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

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

Issue 1800843002: save-data header value gets appended on page refreshes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameFetchContext.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
570 // memory cache, the embedder is notified. 575 // memory cache, the embedder is notified.
571 TEST_F(FrameFetchContextDisplayedCertificateErrorsTest, MemoryCacheCertificateEr ror) 576 TEST_F(FrameFetchContextDisplayedCertificateErrorsTest, MemoryCacheCertificateEr ror)
572 { 577 {
573 ResourceRequest resourceRequest(url); 578 ResourceRequest resourceRequest(url);
574 ResourceResponse response; 579 ResourceResponse response;
575 response.setURL(url); 580 response.setURL(url);
576 response.setSecurityInfo(securityInfo); 581 response.setSecurityInfo(securityInfo);
577 response.setHasMajorCertificateErrors(true); 582 response.setHasMajorCertificateErrors(true);
578 RefPtrWillBeRawPtr<Resource> resource = Resource::create(resourceRequest, Re source::Image); 583 RefPtrWillBeRawPtr<Resource> resource = Resource::create(resourceRequest, Re source::Image);
579 resource->setResponse(response); 584 resource->setResponse(response);
580 fetchContext->dispatchDidLoadResourceFromMemoryCache(resource.get(), WebURLR equest::FrameTypeNone, WebURLRequest::RequestContextImage); 585 fetchContext->dispatchDidLoadResourceFromMemoryCache(resource.get(), WebURLR equest::FrameTypeNone, WebURLRequest::RequestContextImage);
581 } 586 }
582 587
583 } // namespace blink 588 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameFetchContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698