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

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: nits and merge 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 7025 matching lines...) Expand 10 before | Expand all | Expand 10 after
7036 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7036 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7037 std::string content = localFrame->contentAsText(1024).utf8(); 7037 std::string content = localFrame->contentAsText(1024).utf8();
7038 EXPECT_EQ("hello", content); 7038 EXPECT_EQ("hello", content);
7039 7039
7040 // Manually reset to break WebViewHelper's dependency on the stack allocated 7040 // Manually reset to break WebViewHelper's dependency on the stack allocated
7041 // TestWebFrameClient. 7041 // TestWebFrameClient.
7042 reset(); 7042 reset();
7043 remoteFrame->close(); 7043 remoteFrame->close();
7044 } 7044 }
7045 7045
7046 namespace {
7047
7048 class SwapMainFrameWhenTitleChangesWebFrameClient : public FrameTestHelpers::Tes tWebFrameClient {
7049 public:
7050 SwapMainFrameWhenTitleChangesWebFrameClient() {}
7051 ~SwapMainFrameWhenTitleChangesWebFrameClient() override {}
7052
7053 void didReceiveTitle(WebLocalFrame* frame, const WebString&, WebTextDirectio n) override
7054 {
7055 if (!frame->parent())
7056 frame->swap(WebRemoteFrame::create(WebTreeScopeType::Document, nullp tr));
7057 }
7058 };
7059
7060 } // anonymous namespace
7061
7062 TEST_F(WebFrameTest, SwapMainFrameWhileLoading)
7063 {
7064 SwapMainFrameWhenTitleChangesWebFrameClient frameClient;
7065
7066 FrameTestHelpers::WebViewHelper webViewHelper;
7067 registerMockedHttpURLLoad("frame-a-b-c.html");
7068 registerMockedHttpURLLoad("subframe-a.html");
7069 registerMockedHttpURLLoad("subframe-b.html");
7070 registerMockedHttpURLLoad("subframe-c.html");
7071 registerMockedHttpURLLoad("subframe-hello.html");
7072
7073 webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html", true, &frame Client);
7074 }
7075
7046 void swapAndVerifyFirstChildConsistency(const char* const message, WebFrame* par ent, WebFrame* newChild) 7076 void swapAndVerifyFirstChildConsistency(const char* const message, WebFrame* par ent, WebFrame* newChild)
7047 { 7077 {
7048 SCOPED_TRACE(message); 7078 SCOPED_TRACE(message);
7049 parent->firstChild()->swap(newChild); 7079 parent->firstChild()->swap(newChild);
7050 7080
7051 EXPECT_EQ(newChild, parent->firstChild()); 7081 EXPECT_EQ(newChild, parent->firstChild());
7052 EXPECT_EQ(newChild->parent(), parent); 7082 EXPECT_EQ(newChild->parent(), parent);
7053 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling( )); 7083 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling( ));
7054 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling()); 7084 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling());
7055 } 7085 }
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
8200 8230
8201 TEST_F(WebFrameTest, MaxFramesDetach) 8231 TEST_F(WebFrameTest, MaxFramesDetach)
8202 { 8232 {
8203 registerMockedHttpURLLoad("max-frames-detach.html"); 8233 registerMockedHttpURLLoad("max-frames-detach.html");
8204 FrameTestHelpers::WebViewHelper webViewHelper; 8234 FrameTestHelpers::WebViewHelper webViewHelper;
8205 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); 8235 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true);
8206 webViewImpl->mainFrameImpl()->collectGarbage(); 8236 webViewImpl->mainFrameImpl()->collectGarbage();
8207 } 8237 }
8208 8238
8209 } // namespace blink 8239 } // 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