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

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

Issue 1302333003: Adds test coverage for 521663 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: moar Created 5 years, 3 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
« no previous file with comments | « no previous file | Source/web/tests/data/frame-a-b-c.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7004 matching lines...) Expand 10 before | Expand all | Expand 10 after
7015 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7015 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7016 std::string content = localFrame->contentAsText(1024).utf8(); 7016 std::string content = localFrame->contentAsText(1024).utf8();
7017 EXPECT_EQ("hello", content); 7017 EXPECT_EQ("hello", content);
7018 7018
7019 // Manually reset to break WebViewHelper's dependency on the stack allocated 7019 // Manually reset to break WebViewHelper's dependency on the stack allocated
7020 // TestWebFrameClient. 7020 // TestWebFrameClient.
7021 reset(); 7021 reset();
7022 remoteFrame->close(); 7022 remoteFrame->close();
7023 } 7023 }
7024 7024
7025 namespace {
7026
7027 class SwapMainFrameWhenTitleChangesWebFrameClient : public FrameTestHelpers::Tes tWebFrameClient {
7028 public:
7029 SwapMainFrameWhenTitleChangesWebFrameClient() {}
7030 ~SwapMainFrameWhenTitleChangesWebFrameClient() override {}
7031
7032 void didReceiveTitle(WebLocalFrame* frame, const WebString& title, WebTextDi rection direction) override
Nate Chapin 2015/09/04 18:30:47 Style nit: drop the unused variable names.
sky 2015/09/04 18:57:13 Done.
7033 {
7034 if (!frame->parent())
7035 frame->swap(WebRemoteFrame::create(WebTreeScopeType::Document, nullp tr));
7036 }
7037
7038 private:
Nate Chapin 2015/09/04 18:30:47 Nit: remove this
sky 2015/09/04 18:57:13 Done.
7039 };
7040
7041 } // anonymous namespace
7042
7043 TEST_F(WebFrameTest, SwapMainFrameWhileLoading)
7044 {
7045 SwapMainFrameWhenTitleChangesWebFrameClient frameClient;
7046
7047 FrameTestHelpers::WebViewHelper webViewHelper;
7048 registerMockedHttpURLLoad("frame-a-b-c.html");
7049 registerMockedHttpURLLoad("subframe-a.html");
7050 registerMockedHttpURLLoad("subframe-b.html");
7051 registerMockedHttpURLLoad("subframe-c.html");
7052 registerMockedHttpURLLoad("subframe-hello.html");
7053
7054 webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html", true, &frame Client);
7055 }
7056
7025 void swapAndVerifyFirstChildConsistency(const char* const message, WebFrame* par ent, WebFrame* newChild) 7057 void swapAndVerifyFirstChildConsistency(const char* const message, WebFrame* par ent, WebFrame* newChild)
7026 { 7058 {
7027 SCOPED_TRACE(message); 7059 SCOPED_TRACE(message);
7028 parent->firstChild()->swap(newChild); 7060 parent->firstChild()->swap(newChild);
7029 7061
7030 EXPECT_EQ(newChild, parent->firstChild()); 7062 EXPECT_EQ(newChild, parent->firstChild());
7031 EXPECT_EQ(newChild->parent(), parent); 7063 EXPECT_EQ(newChild->parent(), parent);
7032 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling( )); 7064 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling( ));
7033 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling()); 7065 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling());
7034 } 7066 }
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
8092 8124
8093 TEST_F(WebFrameTest, MaxFramesDetach) 8125 TEST_F(WebFrameTest, MaxFramesDetach)
8094 { 8126 {
8095 registerMockedHttpURLLoad("max-frames-detach.html"); 8127 registerMockedHttpURLLoad("max-frames-detach.html");
8096 FrameTestHelpers::WebViewHelper webViewHelper; 8128 FrameTestHelpers::WebViewHelper webViewHelper;
8097 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); 8129 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true);
8098 webViewImpl->mainFrameImpl()->collectGarbage(); 8130 webViewImpl->mainFrameImpl()->collectGarbage();
8099 } 8131 }
8100 8132
8101 } // namespace blink 8133 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/web/tests/data/frame-a-b-c.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698