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

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

Issue 1418003006: Simplify starting a navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 int marginWidth() const override { return -1; } 89 int marginWidth() const override { return -1; }
90 int marginHeight() const override { return -1; } 90 int marginHeight() const override { return -1; }
91 }; 91 };
92 92
93 class FrameFetchContextTest : public ::testing::Test { 93 class FrameFetchContextTest : public ::testing::Test {
94 protected: 94 protected:
95 void SetUp() override 95 void SetUp() override
96 { 96 {
97 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500)); 97 dummyPageHolder = DummyPageHolder::create(IntSize(500, 500));
98 dummyPageHolder->page().setDeviceScaleFactor(1.0); 98 dummyPageHolder->page().setDeviceScaleFactor(1.0);
99 documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), Resou rceRequest("http://www.example.com"), SubstituteData());
100 document = toHTMLDocument(&dummyPageHolder->document()); 99 document = toHTMLDocument(&dummyPageHolder->document());
100 documentLoader = document->loader();
101 fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher( )->context()); 101 fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher( )->context());
102 owner = StubFrameOwner::create(); 102 owner = StubFrameOwner::create();
103 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get( )); 103 FrameFetchContext::provideDocumentToContext(*fetchContext, document.get( ));
104 } 104 }
105 105
106 void TearDown() override 106 void TearDown() override
107 { 107 {
108 documentLoader->detachFromFrame();
Nate Chapin 2015/11/04 22:13:09 I'm not sure exactly which change I made caused th
jochen (gone - plz use gerrit) 2015/11/06 05:28:05 well, you're no longer creating documentLoader jus
109 documentLoader.clear(); 108 documentLoader.clear();
110 109
111 if (childFrame) { 110 if (childFrame) {
112 childDocumentLoader->detachFromFrame();
113 childDocumentLoader.clear(); 111 childDocumentLoader.clear();
114 childFrame->detach(FrameDetachType::Remove); 112 childFrame->detach(FrameDetachType::Remove);
115 } 113 }
116 } 114 }
117 115
118 FrameFetchContext* createChildFrame() 116 FrameFetchContext* createChildFrame()
119 { 117 {
120 childClient = StubFrameLoaderClientWithParent::create(document->frame()) ; 118 childClient = StubFrameLoaderClientWithParent::create(document->frame()) ;
121 childFrame = LocalFrame::create(childClient.get(), document->frame()->ho st(), owner.get()); 119 childFrame = LocalFrame::create(childClient.get(), document->frame()->ho st(), owner.get());
122 childFrame->setView(FrameView::create(childFrame.get(), IntSize(500, 500 ))); 120 childFrame->setView(FrameView::create(childFrame.get(), IntSize(500, 500 )));
123 childFrame->init(); 121 childFrame->init();
124 childDocumentLoader = DocumentLoader::create(childFrame.get(), ResourceR equest("http://www.example.com"), SubstituteData());
125 childDocument = childFrame->document(); 122 childDocument = childFrame->document();
123 childDocumentLoader = childDocument->loader();
126 FrameFetchContext* childFetchContext = static_cast<FrameFetchContext*>(& childDocumentLoader->fetcher()->context()); 124 FrameFetchContext* childFetchContext = static_cast<FrameFetchContext*>(& childDocumentLoader->fetcher()->context());
127 FrameFetchContext::provideDocumentToContext(*childFetchContext, childDoc ument.get()); 125 FrameFetchContext::provideDocumentToContext(*childFetchContext, childDoc ument.get());
128 return childFetchContext; 126 return childFetchContext;
129 } 127 }
130 128
131 OwnPtr<DummyPageHolder> dummyPageHolder; 129 OwnPtr<DummyPageHolder> dummyPageHolder;
132 // We don't use the DocumentLoader directly in any tests, but need to keep i t around as long 130 // We don't use the DocumentLoader directly in any tests, but need to keep i t around as long
133 // as the ResourceFetcher and Document live due to indirect usage. 131 // as the ResourceFetcher and Document live due to indirect usage.
134 RefPtrWillBePersistent<DocumentLoader> documentLoader; 132 RefPtrWillBePersistent<DocumentLoader> documentLoader;
135 RefPtrWillBePersistent<Document> document; 133 RefPtrWillBePersistent<Document> document;
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 EXPECT_EQ(ResourceLoadPriorityVeryHigh, childFetchContext->modifyPriorityFor Experiments(ResourceLoadPriorityVeryHigh, Resource::MainResource, request, Resou rcePriority::NotVisible)); 507 EXPECT_EQ(ResourceLoadPriorityVeryHigh, childFetchContext->modifyPriorityFor Experiments(ResourceLoadPriorityVeryHigh, Resource::MainResource, request, Resou rcePriority::NotVisible));
510 EXPECT_EQ(ResourceLoadPriorityMedium, childFetchContext->modifyPriorityForEx periments(ResourceLoadPriorityMedium, Resource::Script, request, ResourcePriorit y::NotVisible)); 508 EXPECT_EQ(ResourceLoadPriorityMedium, childFetchContext->modifyPriorityForEx periments(ResourceLoadPriorityMedium, Resource::Script, request, ResourcePriorit y::NotVisible));
511 509
512 // Low priority iframes enabled, everything should be low priority 510 // Low priority iframes enabled, everything should be low priority
513 settings->setLowPriorityIframes(true); 511 settings->setLowPriorityIframes(true);
514 EXPECT_EQ(ResourceLoadPriorityVeryLow, childFetchContext->modifyPriorityForE xperiments(ResourceLoadPriorityVeryHigh, Resource::MainResource, request, Resour cePriority::NotVisible)); 512 EXPECT_EQ(ResourceLoadPriorityVeryLow, childFetchContext->modifyPriorityForE xperiments(ResourceLoadPriorityVeryHigh, Resource::MainResource, request, Resour cePriority::NotVisible));
515 EXPECT_EQ(ResourceLoadPriorityVeryLow, childFetchContext->modifyPriorityForE xperiments(ResourceLoadPriorityMedium, Resource::Script, request, ResourcePriori ty::NotVisible)); 513 EXPECT_EQ(ResourceLoadPriorityVeryLow, childFetchContext->modifyPriorityForE xperiments(ResourceLoadPriorityMedium, Resource::Script, request, ResourcePriori ty::NotVisible));
516 } 514 }
517 515
518 } // namespace 516 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698