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

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

Issue 1416673008: Converge <link rel=preload> loading logic with preloadScanner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 5 years, 1 month 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/loader/LinkLoader.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/loader/LinkLoaderTest.cpp
diff --git a/third_party/WebKit/Source/core/loader/LinkLoaderTest.cpp b/third_party/WebKit/Source/core/loader/LinkLoaderTest.cpp
index 34b2df1f1a8fab56076da2b30a6ddf8e92bd4fd0..364cc3fd3c4dac0fc429aad833099a72903d1388 100644
--- a/third_party/WebKit/Source/core/loader/LinkLoaderTest.cpp
+++ b/third_party/WebKit/Source/core/loader/LinkLoaderTest.cpp
@@ -8,6 +8,7 @@
#include "core/fetch/ResourceFetcher.h"
#include "core/frame/Settings.h"
#include "core/html/LinkRelAttribute.h"
+#include "core/loader/DocumentLoader.h"
#include "core/loader/LinkLoaderClient.h"
#include "core/loader/NetworkHintsInterface.h"
#include "core/testing/DummyPageHolder.h"
@@ -82,16 +83,16 @@ TEST(LinkLoaderTest, Preload)
const ResourceLoadPriority priority;
const bool shouldLoad;
} cases[] = {
- {"data://example.com/cat.jpg", "image", ResourceLoadPriorityVeryLow, true},
- {"data://example.com/cat.jpg", "script", ResourceLoadPriorityMedium, true},
- {"data://example.com/cat.jpg", "stylesheet", ResourceLoadPriorityHigh, true},
- {"data://example.com/cat.jpg", "blabla", ResourceLoadPriorityUnresolved, true},
- {"data://example.com/cat.jpg", "image", ResourceLoadPriorityUnresolved, false},
+ {"data://example.test/cat.jpg", "image", ResourceLoadPriorityVeryLow, true},
+ {"data://example.test/cat.js", "script", ResourceLoadPriorityMedium, true},
+ {"data://example.test/cat.css", "stylesheet", ResourceLoadPriorityHigh, true},
+ {"data://example.test/cat.blob", "blabla", ResourceLoadPriorityUnresolved, false},
};
// Test the cases with a single header
for (const auto& testCase : cases) {
OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(500, 500));
+ dummyPageHolder->frame().settings()->setScriptEnabled(true);
MockLinkLoaderClient loaderClient(testCase.shouldLoad);
LinkLoader loader(&loaderClient);
KURL hrefURL = KURL(KURL(), testCase.href);
@@ -102,11 +103,18 @@ TEST(LinkLoaderTest, Preload)
hrefURL,
dummyPageHolder->document(),
NetworkHintsMock());
- if (testCase.priority == ResourceLoadPriorityUnresolved) {
- ASSERT(!loader.resource());
- } else {
- ASSERT(loader.resource());
- ASSERT_EQ(testCase.priority, loader.resource()->resourceRequest().priority());
+ ASSERT(dummyPageHolder->document().fetcher());
+ WillBeHeapListHashSet<RawPtrWillBeMember<Resource>>* preloads = dummyPageHolder->document().fetcher()->preloads();
+ if (testCase.shouldLoad)
+ ASSERT_NE(nullptr, preloads);
+ if (preloads) {
+ if (testCase.priority == ResourceLoadPriorityUnresolved) {
+ ASSERT_EQ((unsigned)0, preloads->size());
+ } else {
+ ASSERT_EQ((unsigned)1, preloads->size());
+ if (preloads->size() > 0)
+ ASSERT_EQ(testCase.priority, preloads->begin().get()->get()->resourceRequest().priority());
+ }
}
}
}
« no previous file with comments | « third_party/WebKit/Source/core/loader/LinkLoader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698