Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2783743002: Fix nullptr deref in maybeRenderFallbackContent() (Closed)
Patch Set: Fix tests, handled the non-loading cause in the maybeRenderFallbackContent() if block Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 11570 matching lines...) Expand 10 before | Expand all | Expand 10 after
11581 WebLocalFrameImpl* localFrame = FrameTestHelpers::createLocalChild(root); 11581 WebLocalFrameImpl* localFrame = FrameTestHelpers::createLocalChild(root);
11582 FrameTestHelpers::loadFrame(localFrame, "data:text/html,some page"); 11582 FrameTestHelpers::loadFrame(localFrame, "data:text/html,some page");
11583 11583
11584 // Local frame with remote parent should have transparent baseBackgroundColor. 11584 // Local frame with remote parent should have transparent baseBackgroundColor.
11585 Color color = localFrame->frameView()->baseBackgroundColor(); 11585 Color color = localFrame->frameView()->baseBackgroundColor();
11586 EXPECT_EQ(Color::transparent, color); 11586 EXPECT_EQ(Color::transparent, color);
11587 11587
11588 view->close(); 11588 view->close();
11589 } 11589 }
11590 11590
11591 class TestFallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
11592 public:
11593 explicit TestFallbackWebFrameClient() : m_childClient(nullptr) {}
11594
11595 void setChildWebFrameClient(TestFallbackWebFrameClient* client) {
11596 m_childClient = client;
11597 }
11598
11599 WebLocalFrame* createChildFrame(
11600 WebLocalFrame* parent,
11601 WebTreeScopeType scope,
11602 const WebString&,
11603 const WebString&,
11604 WebSandboxFlags,
11605 const WebFrameOwnerProperties& frameOwnerProperties) override {
11606 DCHECK(m_childClient);
11607 WebLocalFrame* frame =
11608 WebLocalFrame::create(scope, m_childClient, nullptr, nullptr);
11609 parent->appendChild(frame);
11610 return frame;
11611 }
11612
11613 WebNavigationPolicy decidePolicyForNavigation(
11614 const NavigationPolicyInfo& info) override {
11615 if (m_childClient || KURL(info.urlRequest.url()) == blankURL())
11616 return WebNavigationPolicyCurrentTab;
11617 return WebNavigationPolicyHandledByClient;
11618 }
11619
11620 private:
11621 TestFallbackWebFrameClient* m_childClient;
11622 };
11623
11624 TEST_F(WebFrameTest, FallbackForNonexistentProvisionalNavigation) {
11625 registerMockedHttpURLLoad("fallback.html");
11626 TestFallbackWebFrameClient mainClient;
11627 TestFallbackWebFrameClient childClient;
11628 mainClient.setChildWebFrameClient(&childClient);
11629
11630 FrameTestHelpers::WebViewHelper webViewHelper;
11631 webViewHelper.initialize(true, &mainClient);
11632
11633 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl();
11634 WebURLRequest request(toKURL(m_baseURL + "fallback.html"));
11635 mainFrame->loadRequest(request);
11636
11637 // Because the child frame will be HandledByClient, the main frame will not
11638 // finish loading, so we cant use
11639 // FrameTestHelpers::pumpPendingRequestsForFrameToLoad.
11640 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests();
11641
11642 // Overwrite the client-handled child frame navigation with about:blank.
11643 WebLocalFrame* child = mainFrame->firstChild()->toWebLocalFrame();
11644 child->loadRequest(WebURLRequest(blankURL()));
11645
11646 // Failing the original child frame navigation and trying to render fallback
11647 // content shouldn't crash. It should return true as though it showed
11648 // fallback. This is so the caller won't attempt to replace the correctly
11649 // empty frame with an error page.
11650 EXPECT_TRUE(child->maybeRenderFallbackContent(WebURLError()));
11651 }
11652
11591 } // namespace blink 11653 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698