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

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

Issue 409823002: Add a basic test for main frame swap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed test Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 6507 matching lines...) Expand 10 before | Expand all | Expand 10 after
6518 m_webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html"); 6518 m_webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html");
6519 } 6519 }
6520 6520
6521 void reset() { m_webViewHelper.reset(); } 6521 void reset() { m_webViewHelper.reset(); }
6522 WebFrame* mainFrame() const { return m_webViewHelper.webView()->mainFrame(); } 6522 WebFrame* mainFrame() const { return m_webViewHelper.webView()->mainFrame(); }
6523 6523
6524 private: 6524 private:
6525 FrameTestHelpers::WebViewHelper m_webViewHelper; 6525 FrameTestHelpers::WebViewHelper m_webViewHelper;
6526 }; 6526 };
6527 6527
6528 // FIXME: We should have tests for main frame swaps, but it interacts poorly 6528 TEST_F(WebFrameSwapTest, SwapMainFrame)
6529 // with the geolocation inspector agent, since the lifetime of the inspector 6529 {
6530 // agent is tied to the Page, but the inspector agent is created by the 6530 WebFrame* remoteFrame = WebRemoteFrame::create(0);
6531 // instantiation of the main frame. 6531 mainFrame()->swap(remoteFrame);
6532
6533 FrameTestHelpers::TestWebFrameClient client;
6534 WebFrame* localFrame = WebLocalFrame::create(&client);
6535 remoteFrame->swap(localFrame);
6536
6537 // FIXME: This almost certainly fires more load events on the iframe element
6538 // than it should.
Nate Chapin 2014/10/16 21:17:46 This comment seems out of place?
dcheng 2014/10/16 21:20:20 It's about the call to loadFrame() below... but I
Nate Chapin 2014/10/16 21:21:47 Well, maybe I'm missing something, but I don't see
dcheng 2014/10/16 21:23:22 Hm. Good point. I've removed this FIXME.
6539 // Finally, make sure an embedder triggered load in the local frame swapped
6540 // back in works.
6541 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
6542 std::string content = localFrame->contentAsText(1024).utf8();
6543 EXPECT_EQ("hello", content);
6544
6545 // Manually reset to break WebViewHelper's dependency on the stack allocated
6546 // TestWebFrameClient.
6547 reset();
6548 remoteFrame->close();
6549 }
6532 6550
6533 void swapAndVerifyFirstChildConsistency(const char* const message, WebFrame* par ent, WebFrame* newChild) 6551 void swapAndVerifyFirstChildConsistency(const char* const message, WebFrame* par ent, WebFrame* newChild)
6534 { 6552 {
6535 SCOPED_TRACE(message); 6553 SCOPED_TRACE(message);
6536 parent->firstChild()->swap(newChild); 6554 parent->firstChild()->swap(newChild);
6537 6555
6538 EXPECT_EQ(newChild, parent->firstChild()); 6556 EXPECT_EQ(newChild, parent->firstChild());
6539 EXPECT_EQ(newChild->parent(), parent); 6557 EXPECT_EQ(newChild->parent(), parent);
6540 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling( )); 6558 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling( ));
6541 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling()); 6559 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling());
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
6782 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6800 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6783 6801
6784 // Neither should a page reload. 6802 // Neither should a page reload.
6785 localFrame->reload(); 6803 localFrame->reload();
6786 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); 6804 EXPECT_EQ(4u, frameClient.provisionalLoadCount());
6787 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); 6805 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition());
6788 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6806 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6789 } 6807 }
6790 6808
6791 } // namespace 6809 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698