| 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 11841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11852 WebLocalFrameImpl* local_frame = FrameTestHelpers::CreateLocalChild(root); | 11852 WebLocalFrameImpl* local_frame = FrameTestHelpers::CreateLocalChild(root); |
| 11853 FrameTestHelpers::LoadFrame(local_frame, "data:text/html,some page"); | 11853 FrameTestHelpers::LoadFrame(local_frame, "data:text/html,some page"); |
| 11854 | 11854 |
| 11855 // Local frame with remote parent should have transparent baseBackgroundColor. | 11855 // Local frame with remote parent should have transparent baseBackgroundColor. |
| 11856 Color color = local_frame->GetFrameView()->BaseBackgroundColor(); | 11856 Color color = local_frame->GetFrameView()->BaseBackgroundColor(); |
| 11857 EXPECT_EQ(Color::kTransparent, color); | 11857 EXPECT_EQ(Color::kTransparent, color); |
| 11858 | 11858 |
| 11859 view->Close(); | 11859 view->Close(); |
| 11860 } | 11860 } |
| 11861 | 11861 |
| 11862 class TestFallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 11863 public: |
| 11864 explicit TestFallbackWebFrameClient() : child_client_(nullptr) {} |
| 11865 |
| 11866 void SetChildWebFrameClient(TestFallbackWebFrameClient* client) { |
| 11867 child_client_ = client; |
| 11868 } |
| 11869 |
| 11870 WebLocalFrame* CreateChildFrame( |
| 11871 WebLocalFrame* parent, |
| 11872 WebTreeScopeType scope, |
| 11873 const WebString&, |
| 11874 const WebString&, |
| 11875 WebSandboxFlags, |
| 11876 const WebFrameOwnerProperties& frameOwnerProperties) override { |
| 11877 DCHECK(child_client_); |
| 11878 WebLocalFrame* frame = |
| 11879 WebLocalFrame::Create(scope, child_client_, nullptr, nullptr); |
| 11880 parent->AppendChild(frame); |
| 11881 return frame; |
| 11882 } |
| 11883 |
| 11884 WebNavigationPolicy DecidePolicyForNavigation( |
| 11885 const NavigationPolicyInfo& info) override { |
| 11886 if (child_client_ || KURL(info.url_request.Url()) == BlankURL()) |
| 11887 return kWebNavigationPolicyCurrentTab; |
| 11888 return kWebNavigationPolicyHandledByClient; |
| 11889 } |
| 11890 |
| 11891 private: |
| 11892 TestFallbackWebFrameClient* child_client_; |
| 11893 }; |
| 11894 |
| 11895 TEST_F(WebFrameTest, FallbackForNonexistentProvisionalNavigation) { |
| 11896 RegisterMockedHttpURLLoad("fallback.html"); |
| 11897 TestFallbackWebFrameClient mainClient; |
| 11898 TestFallbackWebFrameClient childClient; |
| 11899 mainClient.SetChildWebFrameClient(&childClient); |
| 11900 |
| 11901 FrameTestHelpers::WebViewHelper webViewHelper; |
| 11902 webViewHelper.Initialize(true, &mainClient); |
| 11903 |
| 11904 WebLocalFrameImpl* main_frame = webViewHelper.WebView()->MainFrameImpl(); |
| 11905 WebURLRequest request(ToKURL(base_url_ + "fallback.html")); |
| 11906 main_frame->LoadRequest(request); |
| 11907 |
| 11908 // Because the child frame will be HandledByClient, the main frame will not |
| 11909 // finish loading, so we cant use |
| 11910 // FrameTestHelpers::pumpPendingRequestsForFrameToLoad. |
| 11911 Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests(); |
| 11912 |
| 11913 // Overwrite the client-handled child frame navigation with about:blank. |
| 11914 WebLocalFrame* child = main_frame->FirstChild()->ToWebLocalFrame(); |
| 11915 child->LoadRequest(WebURLRequest(BlankURL())); |
| 11916 |
| 11917 // Failing the original child frame navigation and trying to render fallback |
| 11918 // content shouldn't crash. It should return NoLoadInProgress. This is so the |
| 11919 // caller won't attempt to replace the correctly empty frame with an error |
| 11920 // page. |
| 11921 EXPECT_EQ(WebLocalFrame::NoLoadInProgress, |
| 11922 child->MaybeRenderFallbackContent(WebURLError())); |
| 11923 } |
| 11924 |
| 11862 } // namespace blink | 11925 } // namespace blink |
| OLD | NEW |