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