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

Unified Diff: third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp

Issue 1913983002: Use document referrer policy when preloading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test expectation Created 4 years, 8 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 | « third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp
index a87f84e3f445462ac6625674ab18ffed7d8fd5cc..a31ec683dcca085ec93a6ef21b5f0014cfe7d443 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp
@@ -123,13 +123,14 @@ protected:
return data;
}
- void runSetUp(ViewportState viewportState, PreloadState preloadState = PreloadEnabled)
+ void runSetUp(ViewportState viewportState, PreloadState preloadState = PreloadEnabled, ReferrerPolicy documentReferrerPolicy = ReferrerPolicyDefault)
{
HTMLParserOptions options(&m_dummyPageHolder->document());
KURL documentURL(ParsedURLString, "http://whatever.test/");
m_dummyPageHolder->document().settings()->setViewportEnabled(viewportState == ViewportEnabled);
m_dummyPageHolder->document().settings()->setViewportMetaEnabled(viewportState == ViewportEnabled);
m_dummyPageHolder->document().settings()->setDoHtmlPreloadScanning(preloadState == PreloadEnabled);
+ m_dummyPageHolder->document().setReferrerPolicy(documentReferrerPolicy);
m_scanner = HTMLPreloadScanner::create(options, documentURL, CachedDocumentParameters::create(&m_dummyPageHolder->document()), createMediaValuesData());
}
@@ -362,6 +363,28 @@ TEST_F(HTMLPreloadScannerTest, testReferrerPolicy)
test(testCase);
}
+// Tests that a document-level referrer policy (e.g. one set by HTTP
+// header) is applied for preload requests.
+TEST_F(HTMLPreloadScannerTest, testReferrerPolicyOnDocument)
+{
+ runSetUp(ViewportEnabled, PreloadEnabled, ReferrerPolicyOrigin);
+ ReferrerPolicyTestCase testCases[] = {
+ { "http://example.test", "<img src='blah.gif'/>", "blah.gif", "http://example.test/", Resource::Image, 0, ReferrerPolicyOrigin },
+ { "http://example.test", "<style>@import url('blah.css');</style>", "blah.css", "http://example.test/", Resource::CSSStyleSheet, 0, ReferrerPolicyOrigin },
+ // Tests that a meta-delivered referrer policy with an
+ // unrecognized policy value does not override the document's
+ // referrer policy.
+ { "http://example.test", "<meta name='referrer' content='not-a-valid-policy'><img src='bla.gif'/>", "bla.gif", "http://example.test/", Resource::Image, 0, ReferrerPolicyOrigin },
+ // Tests that a meta-delivered referrer policy with a
+ // valid policy value does override the document's
+ // referrer policy.
+ { "http://example.test", "<meta name='referrer' content='unsafe-url'><img src='bla.gif'/>", "bla.gif", "http://example.test/", Resource::Image, 0, ReferrerPolicyAlways },
+ };
+
+ for (const auto& testCase : testCases)
+ test(testCase);
+}
+
TEST_F(HTMLPreloadScannerTest, testLinkRelPreload)
{
TestCase testCases[] = {
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698