| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 | 676 |
| 677 // Navigations to normal HTTP URLs can be handled locally. | 677 // Navigations to normal HTTP URLs can be handled locally. |
| 678 blink::WebURLRequest request(GURL("http://foo.com")); | 678 blink::WebURLRequest request(GURL("http://foo.com")); |
| 679 request.setFetchRequestMode(blink::WebURLRequest::FetchRequestModeNavigate); | 679 request.setFetchRequestMode(blink::WebURLRequest::FetchRequestModeNavigate); |
| 680 request.setFetchCredentialsMode( | 680 request.setFetchCredentialsMode( |
| 681 blink::WebURLRequest::FetchCredentialsModeInclude); | 681 blink::WebURLRequest::FetchCredentialsModeInclude); |
| 682 request.setFetchRedirectMode(blink::WebURLRequest::FetchRedirectModeManual); | 682 request.setFetchRedirectMode(blink::WebURLRequest::FetchRedirectModeManual); |
| 683 request.setFrameType(blink::WebURLRequest::FrameTypeTopLevel); | 683 request.setFrameType(blink::WebURLRequest::FrameTypeTopLevel); |
| 684 request.setRequestContext(blink::WebURLRequest::RequestContextInternal); | 684 request.setRequestContext(blink::WebURLRequest::RequestContextInternal); |
| 685 blink::WebFrameClient::NavigationPolicyInfo policy_info(request); | 685 blink::WebFrameClient::NavigationPolicyInfo policy_info(request); |
| 686 policy_info.navigationType = blink::WebNavigationTypeLinkClicked; | 686 policy_info.loadType = blink::WebFrameLoadType::Standard; |
| 687 policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab; | 687 policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab; |
| 688 blink::WebNavigationPolicy policy = frame()->decidePolicyForNavigation( | 688 blink::WebNavigationPolicy policy = frame()->decidePolicyForNavigation( |
| 689 policy_info); | 689 policy_info); |
| 690 if (!IsBrowserSideNavigationEnabled()) { | 690 if (!IsBrowserSideNavigationEnabled()) { |
| 691 EXPECT_EQ(blink::WebNavigationPolicyCurrentTab, policy); | 691 EXPECT_EQ(blink::WebNavigationPolicyCurrentTab, policy); |
| 692 } else { | 692 } else { |
| 693 // If this is a renderer-initiated navigation that just begun, it should | 693 // If this is a renderer-initiated navigation that just begun, it should |
| 694 // stop and be sent to the browser. | 694 // stop and be sent to the browser. |
| 695 EXPECT_EQ(blink::WebNavigationPolicyHandledByClient, policy); | 695 EXPECT_EQ(blink::WebNavigationPolicyHandledByClient, policy); |
| 696 | 696 |
| 697 // If this a navigation that is ready to commit, it should be handled | 697 // If this a navigation that is ready to commit, it should be handled |
| 698 // locally. | 698 // locally. |
| 699 request.setCheckForBrowserSideNavigation(false); | 699 request.setCheckForBrowserSideNavigation(false); |
| 700 policy = frame()->decidePolicyForNavigation(policy_info); | 700 policy = frame()->decidePolicyForNavigation(policy_info); |
| 701 EXPECT_EQ(blink::WebNavigationPolicyCurrentTab, policy); | 701 EXPECT_EQ(blink::WebNavigationPolicyCurrentTab, policy); |
| 702 } | 702 } |
| 703 | 703 |
| 704 // Verify that form posts to WebUI URLs will be sent to the browser process. | 704 // Verify that form posts to WebUI URLs will be sent to the browser process. |
| 705 blink::WebURLRequest form_request(GURL("chrome://foo")); | 705 blink::WebURLRequest form_request(GURL("chrome://foo")); |
| 706 blink::WebFrameClient::NavigationPolicyInfo form_policy_info(form_request); | 706 blink::WebFrameClient::NavigationPolicyInfo form_policy_info(form_request); |
| 707 form_policy_info.navigationType = blink::WebNavigationTypeFormSubmitted; | 707 policy_info.loadType = blink::WebFrameLoadType::Standard; |
| 708 form_policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab; | 708 form_policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab; |
| 709 form_request.setHTTPMethod("POST"); | 709 form_request.setHTTPMethod("POST"); |
| 710 policy = frame()->decidePolicyForNavigation(form_policy_info); | 710 policy = frame()->decidePolicyForNavigation(form_policy_info); |
| 711 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); | 711 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); |
| 712 | 712 |
| 713 // Verify that popup links to WebUI URLs also are sent to browser. | 713 // Verify that popup links to WebUI URLs also are sent to browser. |
| 714 blink::WebURLRequest popup_request(GURL("chrome://foo")); | 714 blink::WebURLRequest popup_request(GURL("chrome://foo")); |
| 715 blink::WebFrameClient::NavigationPolicyInfo popup_policy_info(popup_request); | 715 blink::WebFrameClient::NavigationPolicyInfo popup_policy_info(popup_request); |
| 716 popup_policy_info.navigationType = blink::WebNavigationTypeLinkClicked; | 716 policy_info.loadType = blink::WebFrameLoadType::Standard; |
| 717 popup_policy_info.defaultPolicy = blink::WebNavigationPolicyNewForegroundTab; | 717 popup_policy_info.defaultPolicy = blink::WebNavigationPolicyNewForegroundTab; |
| 718 policy = frame()->decidePolicyForNavigation(popup_policy_info); | 718 policy = frame()->decidePolicyForNavigation(popup_policy_info); |
| 719 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); | 719 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); |
| 720 } | 720 } |
| 721 | 721 |
| 722 TEST_F(RenderViewImplTest, DecideNavigationPolicyHandlesAllTopLevel) { | 722 TEST_F(RenderViewImplTest, DecideNavigationPolicyHandlesAllTopLevel) { |
| 723 DocumentState state; | 723 DocumentState state; |
| 724 state.set_navigation_state(NavigationStateImpl::CreateContentInitiated()); | 724 state.set_navigation_state(NavigationStateImpl::CreateContentInitiated()); |
| 725 | 725 |
| 726 RendererPreferences prefs = view()->renderer_preferences(); | 726 RendererPreferences prefs = view()->renderer_preferences(); |
| 727 prefs.browser_handles_all_top_level_requests = true; | 727 prefs.browser_handles_all_top_level_requests = true; |
| 728 view()->OnSetRendererPrefs(prefs); | 728 view()->OnSetRendererPrefs(prefs); |
| 729 | 729 |
| 730 const blink::WebNavigationType kNavTypes[] = { | 730 const blink::WebFrameLoadType kLoadTypes[] = { |
| 731 blink::WebNavigationTypeLinkClicked, | 731 blink::WebFrameLoadType::Standard, |
| 732 blink::WebNavigationTypeFormSubmitted, | 732 blink::WebFrameLoadType::BackForward, |
| 733 blink::WebNavigationTypeBackForward, | 733 blink::WebFrameLoadType::Reload, |
| 734 blink::WebNavigationTypeReload, | 734 blink::WebFrameLoadType::ReloadMainResource, |
| 735 blink::WebNavigationTypeFormResubmitted, | 735 blink::WebFrameLoadType::ReplaceCurrentItem, |
| 736 blink::WebNavigationTypeOther, | 736 blink::WebFrameLoadType::InitialInChildFrame, |
| 737 blink::WebFrameLoadType::InitialHistoryLoad, |
| 738 blink::WebFrameLoadType::ReloadBypassingCache |
| 737 }; | 739 }; |
| 738 | 740 |
| 739 blink::WebURLRequest request(GURL("http://foo.com")); | 741 blink::WebURLRequest request(GURL("http://foo.com")); |
| 740 blink::WebFrameClient::NavigationPolicyInfo policy_info(request); | 742 blink::WebFrameClient::NavigationPolicyInfo policy_info(request); |
| 741 policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab; | 743 policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab; |
| 742 | 744 |
| 743 for (size_t i = 0; i < arraysize(kNavTypes); ++i) { | 745 for (size_t i = 0; i < arraysize(kLoadTypes); ++i) { |
| 744 policy_info.navigationType = kNavTypes[i]; | 746 policy_info.loadType = kLoadTypes[i]; |
| 745 | 747 |
| 746 blink::WebNavigationPolicy policy = frame()->decidePolicyForNavigation( | 748 blink::WebNavigationPolicy policy = frame()->decidePolicyForNavigation( |
| 747 policy_info); | 749 policy_info); |
| 748 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); | 750 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); |
| 749 } | 751 } |
| 750 } | 752 } |
| 751 | 753 |
| 752 TEST_F(RenderViewImplTest, DecideNavigationPolicyForWebUI) { | 754 TEST_F(RenderViewImplTest, DecideNavigationPolicyForWebUI) { |
| 753 // Enable bindings to simulate a WebUI view. | 755 // Enable bindings to simulate a WebUI view. |
| 754 view()->OnAllowBindings(BINDINGS_POLICY_WEB_UI); | 756 view()->OnAllowBindings(BINDINGS_POLICY_WEB_UI); |
| 755 | 757 |
| 756 DocumentState state; | 758 DocumentState state; |
| 757 state.set_navigation_state(NavigationStateImpl::CreateContentInitiated()); | 759 state.set_navigation_state(NavigationStateImpl::CreateContentInitiated()); |
| 758 | 760 |
| 759 // Navigations to normal HTTP URLs will be sent to browser process. | 761 // Navigations to normal HTTP URLs will be sent to browser process. |
| 760 blink::WebURLRequest request(GURL("http://foo.com")); | 762 blink::WebURLRequest request(GURL("http://foo.com")); |
| 761 blink::WebFrameClient::NavigationPolicyInfo policy_info(request); | 763 blink::WebFrameClient::NavigationPolicyInfo policy_info(request); |
| 762 policy_info.navigationType = blink::WebNavigationTypeLinkClicked; | 764 policy_info.loadType = blink::WebFrameLoadType::Standard; |
| 763 policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab; | 765 policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab; |
| 764 | 766 |
| 765 blink::WebNavigationPolicy policy = frame()->decidePolicyForNavigation( | 767 blink::WebNavigationPolicy policy = frame()->decidePolicyForNavigation( |
| 766 policy_info); | 768 policy_info); |
| 767 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); | 769 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); |
| 768 | 770 |
| 769 // Navigations to WebUI URLs will also be sent to browser process. | 771 // Navigations to WebUI URLs will also be sent to browser process. |
| 770 blink::WebURLRequest webui_request(GURL("chrome://foo")); | 772 blink::WebURLRequest webui_request(GURL("chrome://foo")); |
| 771 blink::WebFrameClient::NavigationPolicyInfo webui_policy_info(webui_request); | 773 blink::WebFrameClient::NavigationPolicyInfo webui_policy_info(webui_request); |
| 772 webui_policy_info.navigationType = blink::WebNavigationTypeLinkClicked; | 774 policy_info.loadType = blink::WebFrameLoadType::Standard; |
| 773 webui_policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab; | 775 webui_policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab; |
| 774 policy = frame()->decidePolicyForNavigation(webui_policy_info); | 776 policy = frame()->decidePolicyForNavigation(webui_policy_info); |
| 775 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); | 777 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); |
| 776 | 778 |
| 777 // Verify that form posts to data URLs will be sent to the browser process. | 779 // Verify that form posts to data URLs will be sent to the browser process. |
| 778 blink::WebURLRequest data_request(GURL("data:text/html,foo")); | 780 blink::WebURLRequest data_request(GURL("data:text/html,foo")); |
| 779 blink::WebFrameClient::NavigationPolicyInfo data_policy_info(data_request); | 781 blink::WebFrameClient::NavigationPolicyInfo data_policy_info(data_request); |
| 780 data_policy_info.navigationType = blink::WebNavigationTypeFormSubmitted; | 782 policy_info.loadType = blink::WebFrameLoadType::Standard; |
| 781 data_policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab; | 783 data_policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab; |
| 782 data_request.setHTTPMethod("POST"); | 784 data_request.setHTTPMethod("POST"); |
| 783 policy = frame()->decidePolicyForNavigation(data_policy_info); | 785 policy = frame()->decidePolicyForNavigation(data_policy_info); |
| 784 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); | 786 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); |
| 785 | 787 |
| 786 // Verify that a popup that creates a view first and then navigates to a | 788 // Verify that a popup that creates a view first and then navigates to a |
| 787 // normal HTTP URL will be sent to the browser process, even though the | 789 // normal HTTP URL will be sent to the browser process, even though the |
| 788 // new view does not have any enabled_bindings_. | 790 // new view does not have any enabled_bindings_. |
| 789 blink::WebURLRequest popup_request(GURL("http://foo.com")); | 791 blink::WebURLRequest popup_request(GURL("http://foo.com")); |
| 790 blink::WebView* new_web_view = view()->createView( | 792 blink::WebView* new_web_view = view()->createView( |
| 791 GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo", | 793 GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo", |
| 792 blink::WebNavigationPolicyNewForegroundTab, false); | 794 blink::WebNavigationPolicyNewForegroundTab, false); |
| 793 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view); | 795 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view); |
| 794 blink::WebFrameClient::NavigationPolicyInfo popup_policy_info(popup_request); | 796 blink::WebFrameClient::NavigationPolicyInfo popup_policy_info(popup_request); |
| 795 popup_policy_info.navigationType = blink::WebNavigationTypeLinkClicked; | 797 policy_info.loadType = blink::WebFrameLoadType::Standard; |
| 796 popup_policy_info.defaultPolicy = blink::WebNavigationPolicyNewForegroundTab; | 798 popup_policy_info.defaultPolicy = blink::WebNavigationPolicyNewForegroundTab; |
| 797 policy = static_cast<RenderFrameImpl*>(new_view->GetMainRenderFrame())-> | 799 policy = static_cast<RenderFrameImpl*>(new_view->GetMainRenderFrame())-> |
| 798 decidePolicyForNavigation(popup_policy_info); | 800 decidePolicyForNavigation(popup_policy_info); |
| 799 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); | 801 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); |
| 800 | 802 |
| 801 CloseRenderView(new_view); | 803 CloseRenderView(new_view); |
| 802 } | 804 } |
| 803 | 805 |
| 804 // Verify that security origins are replicated properly to RenderFrameProxies | 806 // Verify that security origins are replicated properly to RenderFrameProxies |
| 805 // when swapping out. | 807 // when swapping out. |
| (...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1957 GetMainFrame()->dataSource()->getRequest().getExtraData()); | 1959 GetMainFrame()->dataSource()->getRequest().getExtraData()); |
| 1958 ASSERT_TRUE(extra_data); | 1960 ASSERT_TRUE(extra_data); |
| 1959 EXPECT_EQ(extra_data->service_worker_provider_id(), | 1961 EXPECT_EQ(extra_data->service_worker_provider_id(), |
| 1960 provider->provider_id()); | 1962 provider->provider_id()); |
| 1961 | 1963 |
| 1962 // See that subresource requests are also tagged with the provider's id. | 1964 // See that subresource requests are also tagged with the provider's id. |
| 1963 EXPECT_EQ(frame(), RenderFrameImpl::FromWebFrame(GetMainFrame())); | 1965 EXPECT_EQ(frame(), RenderFrameImpl::FromWebFrame(GetMainFrame())); |
| 1964 blink::WebURLRequest request(GURL("http://foo.com")); | 1966 blink::WebURLRequest request(GURL("http://foo.com")); |
| 1965 request.setRequestContext(blink::WebURLRequest::RequestContextSubresource); | 1967 request.setRequestContext(blink::WebURLRequest::RequestContextSubresource); |
| 1966 blink::WebURLResponse redirect_response; | 1968 blink::WebURLResponse redirect_response; |
| 1967 frame()->willSendRequest(GetMainFrame(), request); | 1969 frame()->willSendRequest(GetMainFrame(), request, |
| 1970 blink::WebFrameLoadType::Standard); |
| 1968 extra_data = static_cast<RequestExtraData*>(request.getExtraData()); | 1971 extra_data = static_cast<RequestExtraData*>(request.getExtraData()); |
| 1969 ASSERT_TRUE(extra_data); | 1972 ASSERT_TRUE(extra_data); |
| 1970 EXPECT_EQ(extra_data->service_worker_provider_id(), | 1973 EXPECT_EQ(extra_data->service_worker_provider_id(), |
| 1971 provider->provider_id()); | 1974 provider->provider_id()); |
| 1972 } | 1975 } |
| 1973 | 1976 |
| 1974 TEST_F(RenderViewImplTest, OnSetAccessibilityMode) { | 1977 TEST_F(RenderViewImplTest, OnSetAccessibilityMode) { |
| 1975 ASSERT_EQ(AccessibilityModeOff, frame()->accessibility_mode()); | 1978 ASSERT_EQ(AccessibilityModeOff, frame()->accessibility_mode()); |
| 1976 ASSERT_FALSE(frame()->render_accessibility()); | 1979 ASSERT_FALSE(frame()->render_accessibility()); |
| 1977 | 1980 |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2557 ExpectPauseAndResume(3); | 2560 ExpectPauseAndResume(3); |
| 2558 blink::WebScriptSource source2( | 2561 blink::WebScriptSource source2( |
| 2559 WebString::fromUTF8("function func2() { func1(); }; func2();")); | 2562 WebString::fromUTF8("function func2() { func1(); }; func2();")); |
| 2560 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1); | 2563 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1); |
| 2561 | 2564 |
| 2562 EXPECT_FALSE(IsPaused()); | 2565 EXPECT_FALSE(IsPaused()); |
| 2563 Detach(); | 2566 Detach(); |
| 2564 } | 2567 } |
| 2565 | 2568 |
| 2566 } // namespace content | 2569 } // namespace content |
| OLD | NEW |