| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 11867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11878 WebLocalFrameImpl* local_frame = FrameTestHelpers::CreateLocalChild(root); | 11878 WebLocalFrameImpl* local_frame = FrameTestHelpers::CreateLocalChild(root); |
| 11879 FrameTestHelpers::LoadFrame(local_frame, "data:text/html,some page"); | 11879 FrameTestHelpers::LoadFrame(local_frame, "data:text/html,some page"); |
| 11880 | 11880 |
| 11881 // Local frame with remote parent should have transparent baseBackgroundColor. | 11881 // Local frame with remote parent should have transparent baseBackgroundColor. |
| 11882 Color color = local_frame->GetFrameView()->BaseBackgroundColor(); | 11882 Color color = local_frame->GetFrameView()->BaseBackgroundColor(); |
| 11883 EXPECT_EQ(Color::kTransparent, color); | 11883 EXPECT_EQ(Color::kTransparent, color); |
| 11884 | 11884 |
| 11885 view->Close(); | 11885 view->Close(); |
| 11886 } | 11886 } |
| 11887 | 11887 |
| 11888 class TestFallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 11889 public: |
| 11890 explicit TestFallbackWebFrameClient() : child_client_(nullptr) {} |
| 11891 |
| 11892 void SetChildWebFrameClient(TestFallbackWebFrameClient* client) { |
| 11893 child_client_ = client; |
| 11894 } |
| 11895 |
| 11896 WebLocalFrame* CreateChildFrame( |
| 11897 WebLocalFrame* parent, |
| 11898 WebTreeScopeType scope, |
| 11899 const WebString&, |
| 11900 const WebString&, |
| 11901 WebSandboxFlags, |
| 11902 const WebFrameOwnerProperties& frameOwnerProperties) override { |
| 11903 DCHECK(child_client_); |
| 11904 WebLocalFrame* frame = |
| 11905 WebLocalFrame::Create(scope, child_client_, nullptr, nullptr); |
| 11906 parent->AppendChild(frame); |
| 11907 return frame; |
| 11908 } |
| 11909 |
| 11910 WebNavigationPolicy DecidePolicyForNavigation( |
| 11911 const NavigationPolicyInfo& info) override { |
| 11912 if (child_client_ || KURL(info.url_request.Url()) == BlankURL()) |
| 11913 return kWebNavigationPolicyCurrentTab; |
| 11914 return kWebNavigationPolicyHandledByClient; |
| 11915 } |
| 11916 |
| 11917 private: |
| 11918 TestFallbackWebFrameClient* child_client_; |
| 11919 }; |
| 11920 |
| 11921 TEST_F(WebFrameTest, FallbackForNonexistentProvisionalNavigation) { |
| 11922 RegisterMockedHttpURLLoad("fallback.html"); |
| 11923 TestFallbackWebFrameClient mainClient; |
| 11924 TestFallbackWebFrameClient childClient; |
| 11925 mainClient.SetChildWebFrameClient(&childClient); |
| 11926 |
| 11927 FrameTestHelpers::WebViewHelper webViewHelper; |
| 11928 webViewHelper.Initialize(true, &mainClient); |
| 11929 |
| 11930 WebLocalFrameImpl* main_frame = webViewHelper.WebView()->MainFrameImpl(); |
| 11931 WebURLRequest request(ToKURL(base_url_ + "fallback.html")); |
| 11932 main_frame->LoadRequest(request); |
| 11933 |
| 11934 // Because the child frame will be HandledByClient, the main frame will not |
| 11935 // finish loading, so we cant use |
| 11936 // FrameTestHelpers::pumpPendingRequestsForFrameToLoad. |
| 11937 Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests(); |
| 11938 |
| 11939 // Overwrite the client-handled child frame navigation with about:blank. |
| 11940 WebLocalFrame* child = main_frame->FirstChild()->ToWebLocalFrame(); |
| 11941 child->LoadRequest(WebURLRequest(BlankURL())); |
| 11942 |
| 11943 // Failing the original child frame navigation and trying to render fallback |
| 11944 // content shouldn't crash. It should return NoLoadInProgress. This is so the |
| 11945 // caller won't attempt to replace the correctly empty frame with an error |
| 11946 // page. |
| 11947 EXPECT_EQ(WebLocalFrame::NoLoadInProgress, |
| 11948 child->MaybeRenderFallbackContent(WebURLError())); |
| 11949 } |
| 11950 |
| 11888 } // namespace blink | 11951 } // namespace blink |
| OLD | NEW |