| OLD | NEW |
| 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 ClientHintsPreferences preferences; | 316 ClientHintsPreferences preferences; |
| 317 preferences.setShouldSendDPR(true); | 317 preferences.setShouldSendDPR(true); |
| 318 preferences.setShouldSendResourceWidth(true); | 318 preferences.setShouldSendResourceWidth(true); |
| 319 preferences.setShouldSendViewportWidth(true); | 319 preferences.setShouldSendViewportWidth(true); |
| 320 document->clientHintsPreferences().updateFrom(preferences); | 320 document->clientHintsPreferences().updateFrom(preferences); |
| 321 expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); | 321 expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); |
| 322 expectHeader("http://www.example.com/1.gif", "Width", true, "400", 400); | 322 expectHeader("http://www.example.com/1.gif", "Width", true, "400", 400); |
| 323 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500"); | 323 expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500"); |
| 324 } | 324 } |
| 325 | 325 |
| 326 class StubFrameLoaderClientWithParent : public EmptyFrameLoaderClient { | 326 class StubFrameLoaderClientWithParent final : public EmptyFrameLoaderClient { |
| 327 public: | 327 public: |
| 328 static PassOwnPtrWillBeRawPtr<StubFrameLoaderClientWithParent> create(Frame*
parent) |
| 329 { |
| 330 return adoptPtrWillBeNoop(new StubFrameLoaderClientWithParent(parent)); |
| 331 } |
| 332 |
| 333 DEFINE_INLINE_VIRTUAL_TRACE() |
| 334 { |
| 335 visitor->trace(m_parent); |
| 336 EmptyFrameLoaderClient::trace(visitor); |
| 337 } |
| 338 |
| 339 Frame* parent() const override { return m_parent.get(); } |
| 340 |
| 341 private: |
| 328 explicit StubFrameLoaderClientWithParent(Frame* parent) | 342 explicit StubFrameLoaderClientWithParent(Frame* parent) |
| 329 : m_parent(parent) | 343 : m_parent(parent) |
| 330 { | 344 { |
| 331 } | 345 } |
| 332 | 346 |
| 333 Frame* parent() const override { return m_parent; } | 347 RawPtrWillBeMember<Frame> m_parent; |
| 334 | |
| 335 private: | |
| 336 Frame* m_parent; | |
| 337 }; | 348 }; |
| 338 | 349 |
| 339 class StubFrameOwner : public NoBaseWillBeGarbageCollectedFinalized<StubFrameOwn
er>, public FrameOwner { | 350 class StubFrameOwner : public NoBaseWillBeGarbageCollectedFinalized<StubFrameOwn
er>, public FrameOwner { |
| 340 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(StubFrameOwner); | 351 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(StubFrameOwner); |
| 341 public: | 352 public: |
| 342 DEFINE_INLINE_VIRTUAL_TRACE() { FrameOwner::trace(visitor); } | 353 DEFINE_INLINE_VIRTUAL_TRACE() { FrameOwner::trace(visitor); } |
| 343 | 354 |
| 344 bool isLocal() const override { return false; } | 355 bool isLocal() const override { return false; } |
| 345 SandboxFlags sandboxFlags() const override { return SandboxNone; } | 356 SandboxFlags sandboxFlags() const override { return SandboxNone; } |
| 346 void dispatchLoad() override { } | 357 void dispatchLoad() override { } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 document->frame()->loader().setLoadType(FrameLoadTypeSame); | 412 document->frame()->loader().setLoadType(FrameLoadTypeSame); |
| 402 EXPECT_EQ(ReloadIgnoringCacheData, fetchContext->resourceRequestCachePolicy(
request, Resource::MainResource)); | 413 EXPECT_EQ(ReloadIgnoringCacheData, fetchContext->resourceRequestCachePolicy(
request, Resource::MainResource)); |
| 403 | 414 |
| 404 // Conditional request | 415 // Conditional request |
| 405 document->frame()->loader().setLoadType(FrameLoadTypeStandard); | 416 document->frame()->loader().setLoadType(FrameLoadTypeStandard); |
| 406 ResourceRequest conditional("http://www.example.com"); | 417 ResourceRequest conditional("http://www.example.com"); |
| 407 conditional.setHTTPHeaderField("If-Modified-Since", "foo"); | 418 conditional.setHTTPHeaderField("If-Modified-Since", "foo"); |
| 408 EXPECT_EQ(ReloadIgnoringCacheData, fetchContext->resourceRequestCachePolicy(
conditional, Resource::MainResource)); | 419 EXPECT_EQ(ReloadIgnoringCacheData, fetchContext->resourceRequestCachePolicy(
conditional, Resource::MainResource)); |
| 409 | 420 |
| 410 // Set up a child frame | 421 // Set up a child frame |
| 411 StubFrameLoaderClientWithParent client(document->frame()); | 422 OwnPtrWillBeRawPtr<StubFrameLoaderClientWithParent> client = StubFrameLoader
ClientWithParent::create(document->frame()); |
| 412 StubFrameOwner owner; | 423 StubFrameOwner owner; |
| 413 RefPtrWillBeRawPtr<LocalFrame> childFrame = LocalFrame::create(&client, docu
ment->frame()->host(), &owner); | 424 RefPtrWillBeRawPtr<LocalFrame> childFrame = LocalFrame::create(client.get(),
document->frame()->host(), &owner); |
| 414 childFrame->setView(FrameView::create(childFrame.get(), IntSize(500, 500))); | 425 childFrame->setView(FrameView::create(childFrame.get(), IntSize(500, 500))); |
| 415 childFrame->init(); | 426 childFrame->init(); |
| 416 RefPtrWillBePersistent<DocumentLoader> childDocumentLoader = | 427 RefPtrWillBePersistent<DocumentLoader> childDocumentLoader = |
| 417 DocumentLoader::create(childFrame.get(), ResourceRequest("http://www.exa
mple.com"), SubstituteData()); | 428 DocumentLoader::create(childFrame.get(), ResourceRequest("http://www.exa
mple.com"), SubstituteData()); |
| 418 RefPtrWillBePersistent<Document> childDocument = childFrame->document(); | 429 RefPtrWillBePersistent<Document> childDocument = childFrame->document(); |
| 419 FrameFetchContext* childFetchContext = static_cast<FrameFetchContext*>(&chil
dDocumentLoader->fetcher()->context()); | 430 FrameFetchContext* childFetchContext = static_cast<FrameFetchContext*>(&chil
dDocumentLoader->fetcher()->context()); |
| 420 FrameFetchContext::provideDocumentToContext(*childFetchContext, childDocumen
t.get()); | 431 FrameFetchContext::provideDocumentToContext(*childFetchContext, childDocumen
t.get()); |
| 421 | 432 |
| 422 // Child frame as part of back/forward | 433 // Child frame as part of back/forward |
| 423 document->frame()->loader().setLoadType(FrameLoadTypeBackForward); | 434 document->frame()->loader().setLoadType(FrameLoadTypeBackForward); |
| 424 EXPECT_EQ(ReturnCacheDataElseLoad, childFetchContext->resourceRequestCachePo
licy(request, Resource::MainResource)); | 435 EXPECT_EQ(ReturnCacheDataElseLoad, childFetchContext->resourceRequestCachePo
licy(request, Resource::MainResource)); |
| 425 | 436 |
| 426 // Child frame as part of reload | 437 // Child frame as part of reload |
| 427 document->frame()->loader().setLoadType(FrameLoadTypeReload); | 438 document->frame()->loader().setLoadType(FrameLoadTypeReload); |
| 428 EXPECT_EQ(ReloadIgnoringCacheData, childFetchContext->resourceRequestCachePo
licy(request, Resource::MainResource)); | 439 EXPECT_EQ(ReloadIgnoringCacheData, childFetchContext->resourceRequestCachePo
licy(request, Resource::MainResource)); |
| 429 | 440 |
| 430 // Child frame as part of end to end reload | 441 // Child frame as part of end to end reload |
| 431 document->frame()->loader().setLoadType(FrameLoadTypeReloadFromOrigin); | 442 document->frame()->loader().setLoadType(FrameLoadTypeReloadFromOrigin); |
| 432 EXPECT_EQ(ReloadBypassingCache, childFetchContext->resourceRequestCachePolic
y(request, Resource::MainResource)); | 443 EXPECT_EQ(ReloadBypassingCache, childFetchContext->resourceRequestCachePolic
y(request, Resource::MainResource)); |
| 433 | 444 |
| 434 childDocumentLoader->detachFromFrame(); | 445 childDocumentLoader->detachFromFrame(); |
| 435 childDocumentLoader.clear(); | 446 childDocumentLoader.clear(); |
| 436 childFrame->detach(FrameDetachType::Remove); | 447 childFrame->detach(FrameDetachType::Remove); |
| 437 } | 448 } |
| 438 | 449 |
| 439 } // namespace | 450 } // namespace |
| OLD | NEW |