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 6057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6068 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 6068 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
6069 std::string content = localFrame->contentAsText(1024).utf8(); | 6069 std::string content = localFrame->contentAsText(1024).utf8(); |
6070 EXPECT_EQ("hello", content); | 6070 EXPECT_EQ("hello", content); |
6071 | 6071 |
6072 // Manually reset to break WebViewHelper's dependency on the stack allocated | 6072 // Manually reset to break WebViewHelper's dependency on the stack allocated |
6073 // TestWebFrameClient. | 6073 // TestWebFrameClient. |
6074 reset(); | 6074 reset(); |
6075 remoteFrame->close(); | 6075 remoteFrame->close(); |
6076 } | 6076 } |
6077 | 6077 |
| 6078 void swapAndVerifySubframeConsistency(const char* const message, WebFrame* oldFr
ame, WebFrame* newFrame) |
| 6079 { |
| 6080 SCOPED_TRACE(message); |
| 6081 |
| 6082 EXPECT_TRUE(oldFrame->firstChild()); |
| 6083 oldFrame->swap(newFrame); |
| 6084 |
| 6085 EXPECT_FALSE(newFrame->firstChild()); |
| 6086 EXPECT_FALSE(newFrame->lastChild()); |
| 6087 } |
| 6088 |
| 6089 TEST_F(WebFrameSwapTest, SwapParentShouldDetachChildren) |
| 6090 { |
| 6091 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(0); |
| 6092 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling(); |
| 6093 EXPECT_TRUE(targetFrame); |
| 6094 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame); |
| 6095 |
| 6096 targetFrame = mainFrame()->firstChild()->nextSibling(); |
| 6097 EXPECT_TRUE(targetFrame); |
| 6098 |
| 6099 // Create child frames in the target frame before testing the swap. |
| 6100 FrameTestHelpers::TestWebFrameClient remoteFrameClient; |
| 6101 remoteFrame->createRemoteChild("", &remoteFrameClient); |
| 6102 |
| 6103 FrameTestHelpers::TestWebFrameClient client; |
| 6104 WebFrame* localFrame = WebLocalFrame::create(&client); |
| 6105 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); |
| 6106 |
| 6107 // FIXME: This almost certainly fires more load events on the iframe element |
| 6108 // than it should. |
| 6109 // Finally, make sure an embedder triggered load in the local frame swapped |
| 6110 // back in works. |
| 6111 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
| 6112 std::string content = localFrame->contentAsText(1024).utf8(); |
| 6113 EXPECT_EQ("hello", content); |
| 6114 |
| 6115 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 6116 // TestWebFrameClient. |
| 6117 reset(); |
| 6118 remoteFrame->close(); |
| 6119 } |
| 6120 |
6078 class MockDocumentThreadableLoaderClient : public blink::DocumentThreadableLoade
rClient { | 6121 class MockDocumentThreadableLoaderClient : public blink::DocumentThreadableLoade
rClient { |
6079 public: | 6122 public: |
6080 MockDocumentThreadableLoaderClient() : m_failed(false) { } | 6123 MockDocumentThreadableLoaderClient() : m_failed(false) { } |
6081 virtual void didFail(const blink::ResourceError&) OVERRIDE { m_failed = true
;} | 6124 virtual void didFail(const blink::ResourceError&) OVERRIDE { m_failed = true
;} |
6082 | 6125 |
6083 void reset() { m_failed = false; } | 6126 void reset() { m_failed = false; } |
6084 bool failed() { return m_failed; } | 6127 bool failed() { return m_failed; } |
6085 | 6128 |
6086 bool m_failed; | 6129 bool m_failed; |
6087 }; | 6130 }; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6179 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6222 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6180 | 6223 |
6181 // Neither should a page reload. | 6224 // Neither should a page reload. |
6182 localFrame->reload(); | 6225 localFrame->reload(); |
6183 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6226 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
6184 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6227 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
6185 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6228 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6186 } | 6229 } |
6187 | 6230 |
6188 } // namespace | 6231 } // namespace |
OLD | NEW |