| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/public/browser/resource_dispatcher_host.h" | 5 #include "content/public/browser/resource_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 21 #include "content/browser/download/download_manager_impl.h" | 21 #include "content/browser/download/download_manager_impl.h" |
| 22 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 22 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 23 #include "content/browser/web_contents/web_contents_impl.h" | 23 #include "content/browser/web_contents/web_contents_impl.h" |
| 24 #include "content/public/browser/browser_context.h" | 24 #include "content/public/browser/browser_context.h" |
| 25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 26 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| 27 #include "content/public/browser/resource_request_info.h" | 27 #include "content/public/browser/resource_request_info.h" |
| 28 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 29 #include "content/public/common/browser_side_navigation_policy.h" | 29 #include "content/public/common/browser_side_navigation_policy.h" |
| 30 #include "content/public/common/previews_state.h" |
| 30 #include "content/public/common/url_constants.h" | 31 #include "content/public/common/url_constants.h" |
| 31 #include "content/public/test/browser_test_utils.h" | 32 #include "content/public/test/browser_test_utils.h" |
| 32 #include "content/public/test/content_browser_test.h" | 33 #include "content/public/test/content_browser_test.h" |
| 33 #include "content/public/test/content_browser_test_utils.h" | 34 #include "content/public/test/content_browser_test_utils.h" |
| 34 #include "content/public/test/test_navigation_observer.h" | 35 #include "content/public/test/test_navigation_observer.h" |
| 35 #include "content/public/test/test_utils.h" | 36 #include "content/public/test/test_utils.h" |
| 36 #include "content/shell/browser/shell.h" | 37 #include "content/shell/browser/shell.h" |
| 37 #include "content/shell/browser/shell_content_browser_client.h" | 38 #include "content/shell/browser/shell_content_browser_client.h" |
| 38 #include "content/shell/browser/shell_network_delegate.h" | 39 #include "content/shell/browser/shell_network_delegate.h" |
| 39 #include "net/base/net_errors.h" | 40 #include "net/base/net_errors.h" |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 shell(), | 589 shell(), |
| 589 embedded_test_server()->GetURL("/client_redirect.html"), | 590 embedded_test_server()->GetURL("/client_redirect.html"), |
| 590 2); | 591 2); |
| 591 | 592 |
| 592 EXPECT_TRUE( | 593 EXPECT_TRUE( |
| 593 delegate.page_transition() & ui::PAGE_TRANSITION_CLIENT_REDIRECT); | 594 delegate.page_transition() & ui::PAGE_TRANSITION_CLIENT_REDIRECT); |
| 594 } | 595 } |
| 595 | 596 |
| 596 namespace { | 597 namespace { |
| 597 | 598 |
| 598 // Checks whether the given urls are requested, and that IsUsingLofi() returns | 599 // Checks whether the given urls are requested, and that GetPreviewsState() |
| 599 // the appropriate value when the Lo-Fi state is set. | 600 // returns the appropriate value when the Previews are set. |
| 600 class LoFiModeResourceDispatcherHostDelegate | 601 class PreviewsStateResourceDispatcherHostDelegate |
| 601 : public ResourceDispatcherHostDelegate { | 602 : public ResourceDispatcherHostDelegate { |
| 602 public: | 603 public: |
| 603 LoFiModeResourceDispatcherHostDelegate(const GURL& main_frame_url, | 604 PreviewsStateResourceDispatcherHostDelegate(const GURL& main_frame_url, |
| 604 const GURL& subresource_url, | 605 const GURL& subresource_url, |
| 605 const GURL& iframe_url) | 606 const GURL& iframe_url) |
| 606 : main_frame_url_(main_frame_url), | 607 : main_frame_url_(main_frame_url), |
| 607 subresource_url_(subresource_url), | 608 subresource_url_(subresource_url), |
| 608 iframe_url_(iframe_url), | 609 iframe_url_(iframe_url), |
| 609 main_frame_url_seen_(false), | 610 main_frame_url_seen_(false), |
| 610 subresource_url_seen_(false), | 611 subresource_url_seen_(false), |
| 611 iframe_url_seen_(false), | 612 iframe_url_seen_(false), |
| 612 use_lofi_(false), | 613 previews_state_(PREVIEWS_OFF), |
| 613 should_enable_lofi_mode_called_(false) {} | 614 should_get_previews_state_called_(false) {} |
| 614 | 615 |
| 615 ~LoFiModeResourceDispatcherHostDelegate() override {} | 616 ~PreviewsStateResourceDispatcherHostDelegate() override {} |
| 616 | 617 |
| 617 // ResourceDispatcherHostDelegate implementation: | 618 // ResourceDispatcherHostDelegate implementation: |
| 618 void RequestBeginning( | 619 void RequestBeginning( |
| 619 net::URLRequest* request, | 620 net::URLRequest* request, |
| 620 ResourceContext* resource_context, | 621 ResourceContext* resource_context, |
| 621 AppCacheService* appcache_service, | 622 AppCacheService* appcache_service, |
| 622 ResourceType resource_type, | 623 ResourceType resource_type, |
| 623 std::vector<std::unique_ptr<ResourceThrottle>>* throttles) override { | 624 std::vector<std::unique_ptr<ResourceThrottle>>* throttles) override { |
| 624 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 625 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 625 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 626 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 626 if (request->url() != main_frame_url_ && request->url() != subresource_url_ | 627 if (request->url() != main_frame_url_ && request->url() != subresource_url_ |
| 627 && request->url() != iframe_url_) | 628 && request->url() != iframe_url_) |
| 628 return; | 629 return; |
| 629 if (request->url() == main_frame_url_) { | 630 if (request->url() == main_frame_url_) { |
| 630 EXPECT_FALSE(main_frame_url_seen_); | 631 EXPECT_FALSE(main_frame_url_seen_); |
| 631 main_frame_url_seen_ = true; | 632 main_frame_url_seen_ = true; |
| 632 } else if (request->url() == subresource_url_) { | 633 } else if (request->url() == subresource_url_) { |
| 633 EXPECT_TRUE(main_frame_url_seen_); | 634 EXPECT_TRUE(main_frame_url_seen_); |
| 634 EXPECT_FALSE(subresource_url_seen_); | 635 EXPECT_FALSE(subresource_url_seen_); |
| 635 subresource_url_seen_ = true; | 636 subresource_url_seen_ = true; |
| 636 } else if (request->url() == iframe_url_) { | 637 } else if (request->url() == iframe_url_) { |
| 637 EXPECT_TRUE(main_frame_url_seen_); | 638 EXPECT_TRUE(main_frame_url_seen_); |
| 638 EXPECT_FALSE(iframe_url_seen_); | 639 EXPECT_FALSE(iframe_url_seen_); |
| 639 iframe_url_seen_ = true; | 640 iframe_url_seen_ = true; |
| 640 } | 641 } |
| 641 EXPECT_EQ(use_lofi_, info->IsUsingLoFi()); | 642 EXPECT_EQ(previews_state_, info->GetPreviewsState()); |
| 642 } | 643 } |
| 643 | 644 |
| 644 void SetDelegate() { | 645 void SetDelegate() { |
| 645 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 646 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 646 ResourceDispatcherHost::Get()->SetDelegate(this); | 647 ResourceDispatcherHost::Get()->SetDelegate(this); |
| 647 } | 648 } |
| 648 | 649 |
| 649 bool ShouldEnableLoFiMode( | 650 PreviewsState GetPreviewsState( |
| 650 const net::URLRequest& request, | 651 const net::URLRequest& request, |
| 651 content::ResourceContext* resource_context) override { | 652 content::ResourceContext* resource_context) override { |
| 652 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 653 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 653 EXPECT_FALSE(should_enable_lofi_mode_called_); | 654 EXPECT_FALSE(should_get_previews_state_called_); |
| 654 should_enable_lofi_mode_called_ = true; | 655 should_get_previews_state_called_ = true; |
| 655 EXPECT_EQ(main_frame_url_, request.url()); | 656 EXPECT_EQ(main_frame_url_, request.url()); |
| 656 return use_lofi_; | 657 return previews_state_; |
| 657 } | 658 } |
| 658 | 659 |
| 659 void Reset(bool use_lofi) { | 660 void Reset(PreviewsState previews_state) { |
| 660 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 661 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 661 main_frame_url_seen_ = false; | 662 main_frame_url_seen_ = false; |
| 662 subresource_url_seen_ = false; | 663 subresource_url_seen_ = false; |
| 663 iframe_url_seen_ = false; | 664 iframe_url_seen_ = false; |
| 664 use_lofi_ = use_lofi; | 665 previews_state_ = previews_state; |
| 665 should_enable_lofi_mode_called_ = false; | 666 should_get_previews_state_called_ = false; |
| 666 } | 667 } |
| 667 | 668 |
| 668 void CheckResourcesRequested(bool should_enable_lofi_mode_called) { | 669 void CheckResourcesRequested(bool should_get_previews_state_called) { |
| 669 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 670 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 670 EXPECT_EQ(should_enable_lofi_mode_called, should_enable_lofi_mode_called_); | 671 EXPECT_EQ(should_get_previews_state_called, |
| 672 should_get_previews_state_called_); |
| 671 EXPECT_TRUE(main_frame_url_seen_); | 673 EXPECT_TRUE(main_frame_url_seen_); |
| 672 EXPECT_TRUE(subresource_url_seen_); | 674 EXPECT_TRUE(subresource_url_seen_); |
| 673 EXPECT_TRUE(iframe_url_seen_); | 675 EXPECT_TRUE(iframe_url_seen_); |
| 674 } | 676 } |
| 675 | 677 |
| 676 private: | 678 private: |
| 677 const GURL main_frame_url_; | 679 const GURL main_frame_url_; |
| 678 const GURL subresource_url_; | 680 const GURL subresource_url_; |
| 679 const GURL iframe_url_; | 681 const GURL iframe_url_; |
| 680 | 682 |
| 681 bool main_frame_url_seen_; | 683 bool main_frame_url_seen_; |
| 682 bool subresource_url_seen_; | 684 bool subresource_url_seen_; |
| 683 bool iframe_url_seen_; | 685 bool iframe_url_seen_; |
| 684 bool use_lofi_; | 686 PreviewsState previews_state_; |
| 685 bool should_enable_lofi_mode_called_; | 687 bool should_get_previews_state_called_; |
| 686 | 688 |
| 687 DISALLOW_COPY_AND_ASSIGN(LoFiModeResourceDispatcherHostDelegate); | 689 DISALLOW_COPY_AND_ASSIGN(PreviewsStateResourceDispatcherHostDelegate); |
| 688 }; | 690 }; |
| 689 | 691 |
| 690 } // namespace | 692 } // namespace |
| 691 | 693 |
| 692 class LoFiResourceDispatcherHostBrowserTest : public ContentBrowserTest { | 694 class PreviewsStateResourceDispatcherHostBrowserTest |
| 695 : public ContentBrowserTest { |
| 693 public: | 696 public: |
| 694 ~LoFiResourceDispatcherHostBrowserTest() override {} | 697 ~PreviewsStateResourceDispatcherHostBrowserTest() override {} |
| 695 | 698 |
| 696 protected: | 699 protected: |
| 697 void SetUpOnMainThread() override { | 700 void SetUpOnMainThread() override { |
| 698 ContentBrowserTest::SetUpOnMainThread(); | 701 ContentBrowserTest::SetUpOnMainThread(); |
| 699 | 702 |
| 700 ASSERT_TRUE(embedded_test_server()->Start()); | 703 ASSERT_TRUE(embedded_test_server()->Start()); |
| 701 | 704 |
| 702 delegate_.reset(new LoFiModeResourceDispatcherHostDelegate( | 705 delegate_.reset(new PreviewsStateResourceDispatcherHostDelegate( |
| 703 embedded_test_server()->GetURL("/page_with_iframe.html"), | 706 embedded_test_server()->GetURL("/page_with_iframe.html"), |
| 704 embedded_test_server()->GetURL("/image.jpg"), | 707 embedded_test_server()->GetURL("/image.jpg"), |
| 705 embedded_test_server()->GetURL("/title1.html"))); | 708 embedded_test_server()->GetURL("/title1.html"))); |
| 706 | 709 |
| 707 content::BrowserThread::PostTask( | 710 content::BrowserThread::PostTask( |
| 708 content::BrowserThread::IO, | 711 content::BrowserThread::IO, |
| 709 FROM_HERE, | 712 FROM_HERE, |
| 710 base::Bind(&LoFiModeResourceDispatcherHostDelegate::SetDelegate, | 713 base::Bind(&PreviewsStateResourceDispatcherHostDelegate::SetDelegate, |
| 711 base::Unretained(delegate_.get()))); | 714 base::Unretained(delegate_.get()))); |
| 712 } | 715 } |
| 713 | 716 |
| 714 void Reset(bool use_lofi) { | 717 void Reset(PreviewsState previews_state) { |
| 715 content::BrowserThread::PostTask( | 718 content::BrowserThread::PostTask( |
| 716 content::BrowserThread::IO, FROM_HERE, | 719 content::BrowserThread::IO, FROM_HERE, |
| 717 base::Bind(&LoFiModeResourceDispatcherHostDelegate::Reset, | 720 base::Bind(&PreviewsStateResourceDispatcherHostDelegate::Reset, |
| 718 base::Unretained(delegate_.get()), use_lofi)); | 721 base::Unretained(delegate_.get()), previews_state)); |
| 719 } | 722 } |
| 720 | 723 |
| 721 void CheckResourcesRequested( | 724 void CheckResourcesRequested( |
| 722 bool should_enable_lofi_mode_called) { | 725 bool should_get_previews_state_called) { |
| 723 content::BrowserThread::PostTask( | 726 content::BrowserThread::PostTask( |
| 724 content::BrowserThread::IO, FROM_HERE, | 727 content::BrowserThread::IO, FROM_HERE, |
| 725 base::Bind( | 728 base::Bind(&PreviewsStateResourceDispatcherHostDelegate:: |
| 726 &LoFiModeResourceDispatcherHostDelegate::CheckResourcesRequested, | 729 CheckResourcesRequested, |
| 727 base::Unretained(delegate_.get()), should_enable_lofi_mode_called)); | 730 base::Unretained(delegate_.get()), |
| 731 should_get_previews_state_called)); |
| 728 } | 732 } |
| 729 | 733 |
| 730 private: | 734 private: |
| 731 std::unique_ptr<LoFiModeResourceDispatcherHostDelegate> delegate_; | 735 std::unique_ptr<PreviewsStateResourceDispatcherHostDelegate> delegate_; |
| 732 }; | 736 }; |
| 733 | 737 |
| 734 // Test that navigating with ShouldEnableLoFiMode returning true fetches the | 738 // Test that navigating calls GetPreviewsState with SERVER_LOFI_ON. |
| 735 // resources with LOFI_ON. | 739 IN_PROC_BROWSER_TEST_F(PreviewsStateResourceDispatcherHostBrowserTest, |
| 736 IN_PROC_BROWSER_TEST_F(LoFiResourceDispatcherHostBrowserTest, | |
| 737 ShouldEnableLoFiModeOn) { | 740 ShouldEnableLoFiModeOn) { |
| 738 // Navigate with ShouldEnableLoFiMode returning true. | 741 // Navigate with ShouldEnableLoFiMode returning true. |
| 739 Reset(true); | 742 Reset(SERVER_LOFI_ON); |
| 740 NavigateToURLBlockUntilNavigationsComplete( | 743 NavigateToURLBlockUntilNavigationsComplete( |
| 741 shell(), embedded_test_server()->GetURL("/page_with_iframe.html"), 1); | 744 shell(), embedded_test_server()->GetURL("/page_with_iframe.html"), 1); |
| 742 CheckResourcesRequested(true); | 745 CheckResourcesRequested(true); |
| 743 } | 746 } |
| 744 | 747 |
| 745 // Test that navigating with ShouldEnableLoFiMode returning false fetches the | 748 // Test that navigating calls GetPreviewsState returning PREVIEWS_OFF. |
| 746 // resources with LOFI_OFF. | 749 IN_PROC_BROWSER_TEST_F(PreviewsStateResourceDispatcherHostBrowserTest, |
| 747 IN_PROC_BROWSER_TEST_F(LoFiResourceDispatcherHostBrowserTest, | |
| 748 ShouldEnableLoFiModeOff) { | 750 ShouldEnableLoFiModeOff) { |
| 749 // Navigate with ShouldEnableLoFiMode returning false. | 751 // Navigate with GetPreviewsState returning false. |
| 750 NavigateToURLBlockUntilNavigationsComplete( | 752 NavigateToURLBlockUntilNavigationsComplete( |
| 751 shell(), embedded_test_server()->GetURL("/page_with_iframe.html"), 1); | 753 shell(), embedded_test_server()->GetURL("/page_with_iframe.html"), 1); |
| 752 CheckResourcesRequested(true); | 754 CheckResourcesRequested(true); |
| 753 } | 755 } |
| 754 | 756 |
| 755 // Test that reloading calls ShouldEnableLoFiMode again and changes the Lo-Fi | 757 // Test that reloading calls GetPreviewsState again and changes the Previews |
| 756 // state. | 758 // state. |
| 757 IN_PROC_BROWSER_TEST_F(LoFiResourceDispatcherHostBrowserTest, | 759 IN_PROC_BROWSER_TEST_F(PreviewsStateResourceDispatcherHostBrowserTest, |
| 758 ShouldEnableLoFiModeReload) { | 760 ShouldEnableLoFiModeReload) { |
| 759 // Navigate with ShouldEnableLoFiMode returning false. | 761 // Navigate with GetPreviewsState returning PREVIEWS_OFF. |
| 760 NavigateToURLBlockUntilNavigationsComplete( | 762 NavigateToURLBlockUntilNavigationsComplete( |
| 761 shell(), embedded_test_server()->GetURL("/page_with_iframe.html"), 1); | 763 shell(), embedded_test_server()->GetURL("/page_with_iframe.html"), 1); |
| 762 CheckResourcesRequested(true); | 764 CheckResourcesRequested(true); |
| 763 | 765 |
| 764 // Reload. ShouldEnableLoFiMode should be called. | 766 // Reload. GetPreviewsState should be called. |
| 765 Reset(true); | 767 Reset(SERVER_LOFI_ON); |
| 766 ReloadBlockUntilNavigationsComplete(shell(), 1); | 768 ReloadBlockUntilNavigationsComplete(shell(), 1); |
| 767 CheckResourcesRequested(true); | 769 CheckResourcesRequested(true); |
| 768 } | 770 } |
| 769 | 771 |
| 770 // Test that navigating backwards calls ShouldEnableLoFiMode again and changes | 772 // Test that navigating backwards calls GetPreviewsState again and changes |
| 771 // the Lo-Fi state. | 773 // the Previews state. |
| 772 IN_PROC_BROWSER_TEST_F(LoFiResourceDispatcherHostBrowserTest, | 774 IN_PROC_BROWSER_TEST_F(PreviewsStateResourceDispatcherHostBrowserTest, |
| 773 ShouldEnableLoFiModeNavigateBackThenForward) { | 775 ShouldEnableLoFiModeNavigateBackThenForward) { |
| 774 // Navigate with ShouldEnableLoFiMode returning false. | 776 // Navigate with GetPreviewsState returning false. |
| 775 NavigateToURLBlockUntilNavigationsComplete( | 777 NavigateToURLBlockUntilNavigationsComplete( |
| 776 shell(), embedded_test_server()->GetURL("/page_with_iframe.html"), 1); | 778 shell(), embedded_test_server()->GetURL("/page_with_iframe.html"), 1); |
| 777 CheckResourcesRequested(true); | 779 CheckResourcesRequested(true); |
| 778 | 780 |
| 779 // Go to a different page. | 781 // Go to a different page. |
| 780 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); | 782 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
| 781 | 783 |
| 782 // Go back with ShouldEnableLoFiMode returning true. | 784 // Go back with GetPreviewsState returning SERVER_LOFI_ON. |
| 783 Reset(true); | 785 Reset(SERVER_LOFI_ON); |
| 784 TestNavigationObserver tab_observer(shell()->web_contents(), 1); | 786 TestNavigationObserver tab_observer(shell()->web_contents(), 1); |
| 785 shell()->GoBackOrForward(-1); | 787 shell()->GoBackOrForward(-1); |
| 786 tab_observer.Wait(); | 788 tab_observer.Wait(); |
| 787 CheckResourcesRequested(true); | 789 CheckResourcesRequested(true); |
| 788 } | 790 } |
| 789 | 791 |
| 790 // Test that reloading with Lo-Fi disabled doesn't call ShouldEnableLoFiMode and | 792 // Test that reloading with Lo-Fi disabled doesn't call ShouldEnableLoFiMode and |
| 791 // already has LOFI_OFF. | 793 // already has LOFI_OFF. |
| 792 IN_PROC_BROWSER_TEST_F(LoFiResourceDispatcherHostBrowserTest, | 794 IN_PROC_BROWSER_TEST_F(PreviewsStateResourceDispatcherHostBrowserTest, |
| 793 ShouldEnableLoFiModeReloadDisableLoFi) { | 795 ShouldEnableLoFiModeReloadDisableLoFi) { |
| 794 // Navigate with ShouldEnableLoFiMode returning true. | 796 // Navigate with GetPreviewsState returning SERVER_LOFI_ON. |
| 795 Reset(true); | 797 Reset(SERVER_LOFI_ON); |
| 796 NavigateToURLBlockUntilNavigationsComplete( | 798 NavigateToURLBlockUntilNavigationsComplete( |
| 797 shell(), embedded_test_server()->GetURL("/page_with_iframe.html"), 1); | 799 shell(), embedded_test_server()->GetURL("/page_with_iframe.html"), 1); |
| 798 CheckResourcesRequested(true); | 800 CheckResourcesRequested(true); |
| 799 | 801 |
| 800 // Reload with Lo-Fi disabled. | 802 // Reload with Lo-Fi disabled. |
| 801 Reset(false); | 803 Reset(PREVIEWS_OFF); |
| 802 TestNavigationObserver tab_observer(shell()->web_contents(), 1); | 804 TestNavigationObserver tab_observer(shell()->web_contents(), 1); |
| 803 shell()->web_contents()->GetController().Reload(ReloadType::DISABLE_LOFI_MODE, | 805 shell()->web_contents()->GetController().Reload(ReloadType::DISABLE_LOFI_MODE, |
| 804 true); | 806 true); |
| 805 tab_observer.Wait(); | 807 tab_observer.Wait(); |
| 806 CheckResourcesRequested(false); | 808 CheckResourcesRequested(false); |
| 807 } | 809 } |
| 808 | 810 |
| 809 namespace { | 811 namespace { |
| 810 | 812 |
| 811 struct RequestDataForDelegate { | 813 struct RequestDataForDelegate { |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 EXPECT_EQ(top_origin, delegate_->data()[2]->initiator); | 1137 EXPECT_EQ(top_origin, delegate_->data()[2]->initiator); |
| 1136 | 1138 |
| 1137 // Cross-origin subresource requests have a unique first-party, and an | 1139 // Cross-origin subresource requests have a unique first-party, and an |
| 1138 // initiator that matches the document in which they're embedded. | 1140 // initiator that matches the document in which they're embedded. |
| 1139 EXPECT_EQ(nested_js_url, delegate_->data()[3]->url); | 1141 EXPECT_EQ(nested_js_url, delegate_->data()[3]->url); |
| 1140 EXPECT_EQ(kURLWithUniqueOrigin, delegate_->data()[3]->first_party); | 1142 EXPECT_EQ(kURLWithUniqueOrigin, delegate_->data()[3]->first_party); |
| 1141 EXPECT_EQ(nested_origin, delegate_->data()[3]->initiator); | 1143 EXPECT_EQ(nested_origin, delegate_->data()[3]->initiator); |
| 1142 } | 1144 } |
| 1143 | 1145 |
| 1144 } // namespace content | 1146 } // namespace content |
| OLD | NEW |