Chromium Code Reviews| 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 11547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11558 TEST_F(WebFrameTest, ContextMenuData) { | 11558 TEST_F(WebFrameTest, ContextMenuData) { |
| 11559 EXPECT_FALSE(testSelectAll("<textarea></textarea>")); | 11559 EXPECT_FALSE(testSelectAll("<textarea></textarea>")); |
| 11560 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>")); | 11560 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>")); |
| 11561 EXPECT_FALSE(testSelectAll("<input>")); | 11561 EXPECT_FALSE(testSelectAll("<input>")); |
| 11562 EXPECT_TRUE(testSelectAll("<input value='nonempty'>")); | 11562 EXPECT_TRUE(testSelectAll("<input value='nonempty'>")); |
| 11563 // TODO(amaralp): Empty contenteditable should not have select all enabled. | 11563 // TODO(amaralp): Empty contenteditable should not have select all enabled. |
| 11564 EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); | 11564 EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); |
| 11565 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); | 11565 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); |
| 11566 } | 11566 } |
| 11567 | 11567 |
| 11568 class TestFallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | |
| 11569 public: | |
| 11570 explicit TestFallbackWebFrameClient() : m_childClient(nullptr) {} | |
| 11571 | |
| 11572 void setChildWebFrameClient(TestFallbackWebFrameClient* client) { | |
| 11573 m_childClient = client; | |
| 11574 } | |
| 11575 | |
| 11576 WebLocalFrame* createChildFrame( | |
| 11577 WebLocalFrame* parent, | |
| 11578 WebTreeScopeType scope, | |
| 11579 const WebString&, | |
| 11580 const WebString&, | |
| 11581 WebSandboxFlags, | |
| 11582 const WebFrameOwnerProperties& frameOwnerProperties) override { | |
| 11583 DCHECK(m_childClient); | |
| 11584 WebLocalFrame* frame = | |
| 11585 WebLocalFrame::create(scope, m_childClient, nullptr, nullptr); | |
| 11586 parent->appendChild(frame); | |
| 11587 return frame; | |
| 11588 } | |
| 11589 | |
| 11590 WebNavigationPolicy decidePolicyForNavigation( | |
| 11591 const NavigationPolicyInfo& info) override { | |
| 11592 if (m_childClient || KURL(info.urlRequest.url()) == blankURL()) | |
| 11593 return WebNavigationPolicyCurrentTab; | |
| 11594 return WebNavigationPolicyHandledByClient; | |
| 11595 } | |
| 11596 | |
| 11597 private: | |
| 11598 TestFallbackWebFrameClient* m_childClient; | |
| 11599 }; | |
| 11600 | |
| 11601 TEST_F(WebFrameTest, FallbackForNonexistentProvisionalNavigation) { | |
| 11602 registerMockedHttpURLLoad("fallback.html"); | |
| 11603 TestFallbackWebFrameClient mainClient; | |
| 11604 TestFallbackWebFrameClient childClient; | |
| 11605 mainClient.setChildWebFrameClient(&childClient); | |
| 11606 | |
| 11607 FrameTestHelpers::WebViewHelper webViewHelper; | |
| 11608 webViewHelper.initialize(true, &mainClient); | |
| 11609 | |
| 11610 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); | |
| 11611 WebURLRequest request(toKURL(m_baseURL + "fallback.html")); | |
| 11612 mainFrame->loadRequest(request); | |
| 11613 | |
| 11614 // Because the child frame will be HandledByClient, the main frame will not | |
| 11615 // finish loading, so we cant use | |
| 11616 // FrameTestHelpers::pumpPendingRequestsForFrameToLoad. | |
| 11617 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); | |
| 11618 | |
| 11619 // Overwrite the client-handled child frame navigation with about:blank | |
|
arthursonzogni
2017/03/31 09:16:33
Nit: maybe a dot at the end of the line.
Nate Chapin
2017/03/31 23:59:59
Done.
| |
| 11620 WebLocalFrame* child = mainFrame->firstChild()->toWebLocalFrame(); | |
| 11621 child->loadRequest(WebURLRequest(blankURL())); | |
| 11622 | |
| 11623 // Failing the original child frame navigation and trying to render fallback | |
| 11624 // content shouldn't crash. It should return true as though it showed | |
| 11625 // fallback. This is so the caller won't attempt to replace the correctly | |
| 11626 // empty frame with an error page. | |
| 11627 EXPECT_TRUE(child->maybeRenderFallbackContent(WebURLError())); | |
| 11628 } | |
| 11629 | |
| 11568 } // namespace blink | 11630 } // namespace blink |
| OLD | NEW |