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 6507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Finally, make sure an embedder triggered load in the local frame swapped |
| 6538 // back in works. |
| 6539 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
| 6540 std::string content = localFrame->contentAsText(1024).utf8(); |
| 6541 EXPECT_EQ("hello", content); |
| 6542 |
| 6543 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 6544 // TestWebFrameClient. |
| 6545 reset(); |
| 6546 remoteFrame->close(); |
| 6547 } |
6532 | 6548 |
6533 void swapAndVerifyFirstChildConsistency(const char* const message, WebFrame* par
ent, WebFrame* newChild) | 6549 void swapAndVerifyFirstChildConsistency(const char* const message, WebFrame* par
ent, WebFrame* newChild) |
6534 { | 6550 { |
6535 SCOPED_TRACE(message); | 6551 SCOPED_TRACE(message); |
6536 parent->firstChild()->swap(newChild); | 6552 parent->firstChild()->swap(newChild); |
6537 | 6553 |
6538 EXPECT_EQ(newChild, parent->firstChild()); | 6554 EXPECT_EQ(newChild, parent->firstChild()); |
6539 EXPECT_EQ(newChild->parent(), parent); | 6555 EXPECT_EQ(newChild->parent(), parent); |
6540 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling(
)); | 6556 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling(
)); |
6541 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling()); | 6557 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling()); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6782 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6798 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6783 | 6799 |
6784 // Neither should a page reload. | 6800 // Neither should a page reload. |
6785 localFrame->reload(); | 6801 localFrame->reload(); |
6786 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6802 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
6787 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6803 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
6788 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6804 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6789 } | 6805 } |
6790 | 6806 |
6791 } // namespace | 6807 } // namespace |
OLD | NEW |