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