| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "content/test/mock_keyboard.h" | 41 #include "content/test/mock_keyboard.h" |
| 42 #include "net/base/net_errors.h" | 42 #include "net/base/net_errors.h" |
| 43 #include "net/cert/cert_status_flags.h" | 43 #include "net/cert/cert_status_flags.h" |
| 44 #include "testing/gtest/include/gtest/gtest.h" | 44 #include "testing/gtest/include/gtest/gtest.h" |
| 45 #include "third_party/WebKit/public/platform/WebData.h" | 45 #include "third_party/WebKit/public/platform/WebData.h" |
| 46 #include "third_party/WebKit/public/platform/WebHTTPBody.h" | 46 #include "third_party/WebKit/public/platform/WebHTTPBody.h" |
| 47 #include "third_party/WebKit/public/platform/WebString.h" | 47 #include "third_party/WebKit/public/platform/WebString.h" |
| 48 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 48 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 49 #include "third_party/WebKit/public/web/WebDataSource.h" | 49 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 50 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" | 50 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" |
| 51 #include "third_party/WebKit/public/web/WebHistoryCommitType.h" |
| 51 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 52 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
| 52 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 53 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 53 #include "third_party/WebKit/public/web/WebPerformance.h" | 54 #include "third_party/WebKit/public/web/WebPerformance.h" |
| 54 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 55 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 55 #include "third_party/WebKit/public/web/WebView.h" | 56 #include "third_party/WebKit/public/web/WebView.h" |
| 56 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 57 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
| 57 #include "ui/events/event.h" | 58 #include "ui/events/event.h" |
| 58 #include "ui/events/keycodes/keyboard_codes.h" | 59 #include "ui/events/keycodes/keyboard_codes.h" |
| 59 #include "ui/gfx/codec/jpeg_codec.h" | 60 #include "ui/gfx/codec/jpeg_codec.h" |
| 60 #include "ui/gfx/range/range.h" | 61 #include "ui/gfx/range/range.h" |
| (...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1606 | 1607 |
| 1607 // Start a load that will reach provisional state synchronously, | 1608 // Start a load that will reach provisional state synchronously, |
| 1608 // but won't complete synchronously. | 1609 // but won't complete synchronously. |
| 1609 CommonNavigationParams common_params; | 1610 CommonNavigationParams common_params; |
| 1610 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1611 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1611 common_params.url = GURL("data:text/html,test data"); | 1612 common_params.url = GURL("data:text/html,test data"); |
| 1612 frame()->OnNavigate(common_params, StartNavigationParams(), | 1613 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 1613 RequestNavigationParams()); | 1614 RequestNavigationParams()); |
| 1614 | 1615 |
| 1615 // An error occurred. | 1616 // An error occurred. |
| 1616 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 1617 view()->GetMainRenderFrame()->didFailProvisionalLoad( |
| 1618 web_frame, error, blink::WebStandardCommit); |
| 1617 // Frame should exit view-source mode. | 1619 // Frame should exit view-source mode. |
| 1618 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); | 1620 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); |
| 1619 } | 1621 } |
| 1620 | 1622 |
| 1621 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { | 1623 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { |
| 1622 GetMainFrame()->enableViewSourceMode(true); | 1624 GetMainFrame()->enableViewSourceMode(true); |
| 1623 WebURLError error; | 1625 WebURLError error; |
| 1624 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1626 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 1625 error.reason = net::ERR_ABORTED; | 1627 error.reason = net::ERR_ABORTED; |
| 1626 error.unreachableURL = GURL("http://foo"); | 1628 error.unreachableURL = GURL("http://foo"); |
| 1627 WebLocalFrame* web_frame = GetMainFrame(); | 1629 WebLocalFrame* web_frame = GetMainFrame(); |
| 1628 | 1630 |
| 1629 // Start a load that will reach provisional state synchronously, | 1631 // Start a load that will reach provisional state synchronously, |
| 1630 // but won't complete synchronously. | 1632 // but won't complete synchronously. |
| 1631 CommonNavigationParams common_params; | 1633 CommonNavigationParams common_params; |
| 1632 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1634 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1633 common_params.url = GURL("data:text/html,test data"); | 1635 common_params.url = GURL("data:text/html,test data"); |
| 1634 frame()->OnNavigate(common_params, StartNavigationParams(), | 1636 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 1635 RequestNavigationParams()); | 1637 RequestNavigationParams()); |
| 1636 | 1638 |
| 1637 // A cancellation occurred. | 1639 // A cancellation occurred. |
| 1638 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 1640 view()->GetMainRenderFrame()->didFailProvisionalLoad( |
| 1641 web_frame, error, blink::WebStandardCommit); |
| 1639 // Frame should stay in view-source mode. | 1642 // Frame should stay in view-source mode. |
| 1640 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); | 1643 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); |
| 1641 } | 1644 } |
| 1642 | 1645 |
| 1643 // Regression test for http://crbug.com/41562 | 1646 // Regression test for http://crbug.com/41562 |
| 1644 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { | 1647 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { |
| 1645 const GURL invalid_gurl("http://"); | 1648 const GURL invalid_gurl("http://"); |
| 1646 view()->setMouseOverURL(blink::WebURL(invalid_gurl)); | 1649 view()->setMouseOverURL(blink::WebURL(invalid_gurl)); |
| 1647 EXPECT_EQ(invalid_gurl, view()->target_url_); | 1650 EXPECT_EQ(invalid_gurl, view()->target_url_); |
| 1648 } | 1651 } |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 | 2028 |
| 2026 // Start a load that will reach provisional state synchronously, | 2029 // Start a load that will reach provisional state synchronously, |
| 2027 // but won't complete synchronously. | 2030 // but won't complete synchronously. |
| 2028 CommonNavigationParams common_params; | 2031 CommonNavigationParams common_params; |
| 2029 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2032 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2030 common_params.url = GURL("data:text/html,test data"); | 2033 common_params.url = GURL("data:text/html,test data"); |
| 2031 frame()->OnNavigate(common_params, StartNavigationParams(), | 2034 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 2032 RequestNavigationParams()); | 2035 RequestNavigationParams()); |
| 2033 | 2036 |
| 2034 // An error occurred. | 2037 // An error occurred. |
| 2035 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 2038 view()->GetMainRenderFrame()->didFailProvisionalLoad( |
| 2039 web_frame, error, blink::WebStandardCommit); |
| 2036 const int kMaxOutputCharacters = 22; | 2040 const int kMaxOutputCharacters = 22; |
| 2037 EXPECT_EQ("", | 2041 EXPECT_EQ("", |
| 2038 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2042 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
| 2039 } | 2043 } |
| 2040 | 2044 |
| 2041 #if defined(OS_ANDROID) | 2045 #if defined(OS_ANDROID) |
| 2042 // Crashing on Android: http://crbug.com/311341 | 2046 // Crashing on Android: http://crbug.com/311341 |
| 2043 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress | 2047 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress |
| 2044 #else | 2048 #else |
| 2045 #define MAYBE_DoesNotSuppress DoesNotSuppress | 2049 #define MAYBE_DoesNotSuppress DoesNotSuppress |
| 2046 #endif | 2050 #endif |
| 2047 | 2051 |
| 2048 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { | 2052 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { |
| 2049 WebURLError error; | 2053 WebURLError error; |
| 2050 error.domain = WebString::fromUTF8(net::kErrorDomain); | 2054 error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 2051 error.reason = net::ERR_FILE_NOT_FOUND; | 2055 error.reason = net::ERR_FILE_NOT_FOUND; |
| 2052 error.unreachableURL = GURL("http://example.com/dont-suppress"); | 2056 error.unreachableURL = GURL("http://example.com/dont-suppress"); |
| 2053 WebLocalFrame* web_frame = GetMainFrame(); | 2057 WebLocalFrame* web_frame = GetMainFrame(); |
| 2054 | 2058 |
| 2055 // Start a load that will reach provisional state synchronously, | 2059 // Start a load that will reach provisional state synchronously, |
| 2056 // but won't complete synchronously. | 2060 // but won't complete synchronously. |
| 2057 CommonNavigationParams common_params; | 2061 CommonNavigationParams common_params; |
| 2058 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2062 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 2059 common_params.url = GURL("data:text/html,test data"); | 2063 common_params.url = GURL("data:text/html,test data"); |
| 2060 frame()->OnNavigate(common_params, StartNavigationParams(), | 2064 frame()->OnNavigate(common_params, StartNavigationParams(), |
| 2061 RequestNavigationParams()); | 2065 RequestNavigationParams()); |
| 2062 | 2066 |
| 2063 // An error occurred. | 2067 // An error occurred. |
| 2064 view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error); | 2068 view()->GetMainRenderFrame()->didFailProvisionalLoad( |
| 2069 web_frame, error, blink::WebStandardCommit); |
| 2065 // The error page itself is loaded asynchronously. | 2070 // The error page itself is loaded asynchronously. |
| 2066 FrameLoadWaiter(frame()).Wait(); | 2071 FrameLoadWaiter(frame()).Wait(); |
| 2067 const int kMaxOutputCharacters = 22; | 2072 const int kMaxOutputCharacters = 22; |
| 2068 EXPECT_EQ("A suffusion of yellow.", | 2073 EXPECT_EQ("A suffusion of yellow.", |
| 2069 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2074 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
| 2070 } | 2075 } |
| 2071 | 2076 |
| 2072 // Tests if IME API's candidatewindow* events sent from browser are handled | 2077 // Tests if IME API's candidatewindow* events sent from browser are handled |
| 2073 // in renderer. | 2078 // in renderer. |
| 2074 TEST_F(RenderViewImplTest, SendCandidateWindowEvents) { | 2079 TEST_F(RenderViewImplTest, SendCandidateWindowEvents) { |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2329 frame()->OnNavigate(CommonNavigationParams(), StartNavigationParams(), | 2334 frame()->OnNavigate(CommonNavigationParams(), StartNavigationParams(), |
| 2330 request_params); | 2335 request_params); |
| 2331 | 2336 |
| 2332 // The history list in RenderView should have been updated. | 2337 // The history list in RenderView should have been updated. |
| 2333 EXPECT_EQ(1, view()->historyBackListCount()); | 2338 EXPECT_EQ(1, view()->historyBackListCount()); |
| 2334 EXPECT_EQ(2, view()->historyBackListCount() + | 2339 EXPECT_EQ(2, view()->historyBackListCount() + |
| 2335 view()->historyForwardListCount() + 1); | 2340 view()->historyForwardListCount() + 1); |
| 2336 } | 2341 } |
| 2337 | 2342 |
| 2338 } // namespace content | 2343 } // namespace content |
| OLD | NEW |