| 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 6677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6688 class WebFrameSwapTest : public WebFrameTest { | 6688 class WebFrameSwapTest : public WebFrameTest { |
| 6689 protected: | 6689 protected: |
| 6690 WebFrameSwapTest() | 6690 WebFrameSwapTest() |
| 6691 { | 6691 { |
| 6692 registerMockedHttpURLLoad("frame-a-b-c.html"); | 6692 registerMockedHttpURLLoad("frame-a-b-c.html"); |
| 6693 registerMockedHttpURLLoad("subframe-a.html"); | 6693 registerMockedHttpURLLoad("subframe-a.html"); |
| 6694 registerMockedHttpURLLoad("subframe-b.html"); | 6694 registerMockedHttpURLLoad("subframe-b.html"); |
| 6695 registerMockedHttpURLLoad("subframe-c.html"); | 6695 registerMockedHttpURLLoad("subframe-c.html"); |
| 6696 registerMockedHttpURLLoad("subframe-hello.html"); | 6696 registerMockedHttpURLLoad("subframe-hello.html"); |
| 6697 | 6697 |
| 6698 m_webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html"); | 6698 m_webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html", true); |
| 6699 } | 6699 } |
| 6700 | 6700 |
| 6701 void reset() { m_webViewHelper.reset(); } | 6701 void reset() { m_webViewHelper.reset(); } |
| 6702 WebFrame* mainFrame() const { return m_webViewHelper.webView()->mainFrame();
} | 6702 WebFrame* mainFrame() const { return m_webViewHelper.webView()->mainFrame();
} |
| 6703 | 6703 |
| 6704 private: | 6704 private: |
| 6705 FrameTestHelpers::WebViewHelper m_webViewHelper; | 6705 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 6706 }; | 6706 }; |
| 6707 | 6707 |
| 6708 TEST_F(WebFrameSwapTest, SwapMainFrame) | 6708 TEST_F(WebFrameSwapTest, SwapMainFrame) |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6908 localFrame->initializeToReplaceRemoteFrame(remoteFrame); | 6908 localFrame->initializeToReplaceRemoteFrame(remoteFrame); |
| 6909 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 6909 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
| 6910 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); | 6910 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); |
| 6911 | 6911 |
| 6912 // Manually reset to break WebViewHelper's dependency on the stack allocated | 6912 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 6913 // TestWebFrameClient. | 6913 // TestWebFrameClient. |
| 6914 reset(); | 6914 reset(); |
| 6915 remoteFrame->close(); | 6915 remoteFrame->close(); |
| 6916 } | 6916 } |
| 6917 | 6917 |
| 6918 class RemoteNavigationClient : public FrameTestHelpers::TestWebRemoteFrameClient
{ |
| 6919 public: |
| 6920 void navigate(const WebURLRequest& request, bool shouldReplaceCurrentEntry)
override |
| 6921 { |
| 6922 m_lastRequest = request; |
| 6923 } |
| 6924 |
| 6925 const WebURLRequest& lastRequest() const { return m_lastRequest; } |
| 6926 |
| 6927 private: |
| 6928 WebURLRequest m_lastRequest; |
| 6929 }; |
| 6930 |
| 6931 TEST_F(WebFrameSwapTest, NavigateRemoteFrameViaLocation) |
| 6932 { |
| 6933 RemoteNavigationClient client; |
| 6934 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(&client); |
| 6935 WebFrame* targetFrame = mainFrame()->firstChild(); |
| 6936 ASSERT_TRUE(targetFrame); |
| 6937 targetFrame->swap(remoteFrame); |
| 6938 ASSERT_TRUE(mainFrame()->firstChild()); |
| 6939 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); |
| 6940 |
| 6941 remoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("http:/
/127.0.0.1")); |
| 6942 mainFrame()->executeScript(WebScriptSource( |
| 6943 "document.getElementsByTagName('iframe')[0].contentWindow.location = 'da
ta:text/html,hi'")); |
| 6944 ASSERT_FALSE(client.lastRequest().isNull()); |
| 6945 EXPECT_EQ(WebURL(toKURL("data:text/html,hi")), client.lastRequest().url()); |
| 6946 |
| 6947 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 6948 // TestWebFrameClient. |
| 6949 reset(); |
| 6950 remoteFrame->close(); |
| 6951 } |
| 6952 |
| 6918 class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient
{ | 6953 class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient
{ |
| 6919 public: | 6954 public: |
| 6920 MockDocumentThreadableLoaderClient() : m_failed(false) { } | 6955 MockDocumentThreadableLoaderClient() : m_failed(false) { } |
| 6921 virtual void didFail(const ResourceError&) override { m_failed = true;} | 6956 virtual void didFail(const ResourceError&) override { m_failed = true;} |
| 6922 | 6957 |
| 6923 void reset() { m_failed = false; } | 6958 void reset() { m_failed = false; } |
| 6924 bool failed() { return m_failed; } | 6959 bool failed() { return m_failed; } |
| 6925 | 6960 |
| 6926 bool m_failed; | 6961 bool m_failed; |
| 6927 }; | 6962 }; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7019 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 7054 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
| 7020 | 7055 |
| 7021 // Neither should a page reload. | 7056 // Neither should a page reload. |
| 7022 localFrame->reload(); | 7057 localFrame->reload(); |
| 7023 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 7058 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
| 7024 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 7059 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
| 7025 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 7060 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
| 7026 } | 7061 } |
| 7027 | 7062 |
| 7028 } // namespace | 7063 } // namespace |
| OLD | NEW |