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 6719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6730 class WebFrameSwapTest : public WebFrameTest { | 6730 class WebFrameSwapTest : public WebFrameTest { |
6731 protected: | 6731 protected: |
6732 WebFrameSwapTest() | 6732 WebFrameSwapTest() |
6733 { | 6733 { |
6734 registerMockedHttpURLLoad("frame-a-b-c.html"); | 6734 registerMockedHttpURLLoad("frame-a-b-c.html"); |
6735 registerMockedHttpURLLoad("subframe-a.html"); | 6735 registerMockedHttpURLLoad("subframe-a.html"); |
6736 registerMockedHttpURLLoad("subframe-b.html"); | 6736 registerMockedHttpURLLoad("subframe-b.html"); |
6737 registerMockedHttpURLLoad("subframe-c.html"); | 6737 registerMockedHttpURLLoad("subframe-c.html"); |
6738 registerMockedHttpURLLoad("subframe-hello.html"); | 6738 registerMockedHttpURLLoad("subframe-hello.html"); |
6739 | 6739 |
6740 m_webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html"); | 6740 m_webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html", true); |
6741 } | 6741 } |
6742 | 6742 |
6743 void reset() { m_webViewHelper.reset(); } | 6743 void reset() { m_webViewHelper.reset(); } |
6744 WebFrame* mainFrame() const { return m_webViewHelper.webView()->mainFrame();
} | 6744 WebFrame* mainFrame() const { return m_webViewHelper.webView()->mainFrame();
} |
6745 | 6745 |
6746 private: | 6746 private: |
6747 FrameTestHelpers::WebViewHelper m_webViewHelper; | 6747 FrameTestHelpers::WebViewHelper m_webViewHelper; |
6748 }; | 6748 }; |
6749 | 6749 |
6750 TEST_F(WebFrameSwapTest, SwapMainFrame) | 6750 TEST_F(WebFrameSwapTest, SwapMainFrame) |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6950 localFrame->initializeToReplaceRemoteFrame(remoteFrame); | 6950 localFrame->initializeToReplaceRemoteFrame(remoteFrame); |
6951 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 6951 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
6952 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); | 6952 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); |
6953 | 6953 |
6954 // Manually reset to break WebViewHelper's dependency on the stack allocated | 6954 // Manually reset to break WebViewHelper's dependency on the stack allocated |
6955 // TestWebFrameClient. | 6955 // TestWebFrameClient. |
6956 reset(); | 6956 reset(); |
6957 remoteFrame->close(); | 6957 remoteFrame->close(); |
6958 } | 6958 } |
6959 | 6959 |
| 6960 class RemoteNavigationClient : public FrameTestHelpers::TestWebRemoteFrameClient
{ |
| 6961 public: |
| 6962 void navigate(const WebURLRequest& request, bool shouldReplaceCurrentEntry)
override |
| 6963 { |
| 6964 m_lastRequest = request; |
| 6965 } |
| 6966 |
| 6967 const WebURLRequest& lastRequest() const { return m_lastRequest; } |
| 6968 |
| 6969 private: |
| 6970 WebURLRequest m_lastRequest; |
| 6971 }; |
| 6972 |
| 6973 TEST_F(WebFrameSwapTest, NavigateRemoteFrameViaLocation) |
| 6974 { |
| 6975 RemoteNavigationClient client; |
| 6976 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(&client); |
| 6977 WebFrame* targetFrame = mainFrame()->firstChild(); |
| 6978 ASSERT_TRUE(targetFrame); |
| 6979 targetFrame->swap(remoteFrame); |
| 6980 ASSERT_TRUE(mainFrame()->firstChild()); |
| 6981 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); |
| 6982 |
| 6983 remoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("http:/
/127.0.0.1")); |
| 6984 mainFrame()->executeScript(WebScriptSource( |
| 6985 "document.getElementsByTagName('iframe')[0].contentWindow.location = 'da
ta:text/html,hi'")); |
| 6986 ASSERT_FALSE(client.lastRequest().isNull()); |
| 6987 EXPECT_EQ(WebURL(toKURL("data:text/html,hi")), client.lastRequest().url()); |
| 6988 |
| 6989 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 6990 // TestWebFrameClient. |
| 6991 reset(); |
| 6992 remoteFrame->close(); |
| 6993 } |
| 6994 |
6960 class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient
{ | 6995 class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient
{ |
6961 public: | 6996 public: |
6962 MockDocumentThreadableLoaderClient() : m_failed(false) { } | 6997 MockDocumentThreadableLoaderClient() : m_failed(false) { } |
6963 virtual void didFail(const ResourceError&) override { m_failed = true;} | 6998 virtual void didFail(const ResourceError&) override { m_failed = true;} |
6964 | 6999 |
6965 void reset() { m_failed = false; } | 7000 void reset() { m_failed = false; } |
6966 bool failed() { return m_failed; } | 7001 bool failed() { return m_failed; } |
6967 | 7002 |
6968 bool m_failed; | 7003 bool m_failed; |
6969 }; | 7004 }; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7061 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 7096 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
7062 | 7097 |
7063 // Neither should a page reload. | 7098 // Neither should a page reload. |
7064 localFrame->reload(); | 7099 localFrame->reload(); |
7065 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 7100 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
7066 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 7101 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
7067 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 7102 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
7068 } | 7103 } |
7069 | 7104 |
7070 } // namespace | 7105 } // namespace |
OLD | NEW |