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 7027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7038 m_willSendRequestCallCount(0), | 7038 m_willSendRequestCallCount(0), |
7039 m_childFrameCreationCount(0) {} | 7039 m_childFrameCreationCount(0) {} |
7040 | 7040 |
7041 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { | 7041 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { |
7042 m_childClient = client; | 7042 m_childClient = client; |
7043 } | 7043 } |
7044 WebCachePolicy getCachePolicy() const { return m_policy; } | 7044 WebCachePolicy getCachePolicy() const { return m_policy; } |
7045 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } | 7045 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } |
7046 int childFrameCreationCount() const { return m_childFrameCreationCount; } | 7046 int childFrameCreationCount() const { return m_childFrameCreationCount; } |
7047 | 7047 |
7048 virtual WebLocalFrame* createChildFrame( | 7048 WebLocalFrame* createChildFrame( |
7049 WebLocalFrame* parent, | 7049 WebLocalFrame* parent, |
7050 WebTreeScopeType scope, | 7050 WebTreeScopeType scope, |
7051 const WebString&, | 7051 const WebString&, |
7052 const WebString&, | 7052 const WebString&, |
7053 WebSandboxFlags, | 7053 WebSandboxFlags, |
7054 const WebFrameOwnerProperties& frameOwnerProperties) { | 7054 const WebFrameOwnerProperties& frameOwnerProperties) override { |
7055 DCHECK(m_childClient); | 7055 DCHECK(m_childClient); |
7056 m_childFrameCreationCount++; | 7056 m_childFrameCreationCount++; |
7057 WebLocalFrame* frame = | 7057 WebLocalFrame* frame = |
7058 WebLocalFrame::create(scope, m_childClient, nullptr, nullptr); | 7058 WebLocalFrame::create(scope, m_childClient, nullptr, nullptr); |
7059 parent->appendChild(frame); | 7059 parent->appendChild(frame); |
7060 return frame; | 7060 return frame; |
7061 } | 7061 } |
7062 | 7062 |
7063 virtual void didStartLoading(bool toDifferentDocument) { | 7063 virtual void didStartLoading(bool toDifferentDocument) { |
7064 if (m_parentClient) { | 7064 if (m_parentClient) { |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7450 EXPECT_EQ(WTF::String(url.data()), item->urlString()); | 7450 EXPECT_EQ(WTF::String(url.data()), item->urlString()); |
7451 } | 7451 } |
7452 | 7452 |
7453 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { | 7453 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { |
7454 public: | 7454 public: |
7455 FailCreateChildFrame() : m_callCount(0) {} | 7455 FailCreateChildFrame() : m_callCount(0) {} |
7456 | 7456 |
7457 WebLocalFrame* createChildFrame( | 7457 WebLocalFrame* createChildFrame( |
7458 WebLocalFrame* parent, | 7458 WebLocalFrame* parent, |
7459 WebTreeScopeType scope, | 7459 WebTreeScopeType scope, |
7460 const WebString& frameName, | 7460 const WebString& name, |
7461 const WebString& frameUniqueName, | 7461 const WebString& fallbackName, |
7462 WebSandboxFlags sandboxFlags, | 7462 WebSandboxFlags sandboxFlags, |
7463 const WebFrameOwnerProperties& frameOwnerProperties) override { | 7463 const WebFrameOwnerProperties& frameOwnerProperties) override { |
7464 ++m_callCount; | 7464 ++m_callCount; |
7465 return nullptr; | 7465 return nullptr; |
7466 } | 7466 } |
7467 | 7467 |
7468 int callCount() const { return m_callCount; } | 7468 int callCount() const { return m_callCount; } |
7469 | 7469 |
7470 private: | 7470 private: |
7471 int m_callCount; | 7471 int m_callCount; |
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9038 localFrame->setCommittedFirstRealLoad(); | 9038 localFrame->setCommittedFirstRealLoad(); |
9039 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 9039 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
9040 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); | 9040 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); |
9041 | 9041 |
9042 // Manually reset to break WebViewHelper's dependency on the stack allocated | 9042 // Manually reset to break WebViewHelper's dependency on the stack allocated |
9043 // TestWebFrameClient. | 9043 // TestWebFrameClient. |
9044 reset(); | 9044 reset(); |
9045 remoteFrame->close(); | 9045 remoteFrame->close(); |
9046 } | 9046 } |
9047 | 9047 |
9048 // The uniqueName should be preserved when swapping to a RemoteFrame and back, | |
9049 // whether the frame has a name or not. | |
9050 TEST_F(WebFrameSwapTest, UniqueNameAfterRemoteToLocalSwap) { | |
dcheng
2017/03/01 23:57:26
Working on a browser test for this, since we can't
Charlie Reis
2017/03/02 23:59:17
Yes, I think a browser test for this is worthwhile
dcheng
2017/03/03 10:22:07
I'm going to put this in a separate CL (that will
| |
9051 // Start with a named frame. | |
9052 WebFrame* targetFrame = mainFrame()->firstChild(); | |
9053 ASSERT_TRUE(targetFrame); | |
9054 WebString uniqueName = targetFrame->uniqueName(); | |
9055 EXPECT_EQ("frame1", uniqueName.utf8()); | |
9056 | |
9057 // Swap to a RemoteFrame. | |
9058 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | |
9059 WebRemoteFrameImpl* remoteFrame = WebRemoteFrameImpl::create( | |
9060 WebTreeScopeType::Document, &remoteFrameClient); | |
9061 targetFrame->swap(remoteFrame); | |
9062 ASSERT_TRUE(mainFrame()->firstChild()); | |
9063 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); | |
9064 EXPECT_EQ(uniqueName.utf8(), | |
9065 WebString(remoteFrame->frame()->tree().uniqueName()).utf8()); | |
9066 | |
9067 // Swap back to a LocalFrame. | |
9068 RemoteToLocalSwapWebFrameClient client(remoteFrame); | |
9069 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( | |
9070 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None); | |
9071 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | |
9072 EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8()); | |
9073 EXPECT_EQ(uniqueName.utf8(), WebString(toWebLocalFrameImpl(localFrame) | |
9074 ->frame() | |
9075 ->loader() | |
9076 .currentItem() | |
9077 ->target()) | |
9078 .utf8()); | |
9079 | |
9080 // Repeat with no name on the frame. | |
9081 // (note that uniqueName is immutable after first real commit). | |
9082 localFrame->setName(""); | |
9083 WebString uniqueName2 = localFrame->uniqueName(); | |
9084 EXPECT_EQ("frame1", uniqueName2.utf8()); | |
9085 | |
9086 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; | |
9087 WebRemoteFrameImpl* remoteFrame2 = WebRemoteFrameImpl::create( | |
9088 WebTreeScopeType::Document, &remoteFrameClient2); | |
9089 localFrame->swap(remoteFrame2); | |
9090 ASSERT_TRUE(mainFrame()->firstChild()); | |
9091 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame2); | |
9092 EXPECT_EQ(uniqueName2.utf8(), | |
9093 WebString(remoteFrame2->frame()->tree().uniqueName()).utf8()); | |
9094 | |
9095 RemoteToLocalSwapWebFrameClient client2(remoteFrame2); | |
9096 WebLocalFrame* localFrame2 = WebLocalFrame::createProvisional( | |
9097 &client2, nullptr, nullptr, remoteFrame2, WebSandboxFlags::None); | |
9098 FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html"); | |
9099 EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8()); | |
9100 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebLocalFrameImpl(localFrame2) | |
9101 ->frame() | |
9102 ->loader() | |
9103 .currentItem() | |
9104 ->target()) | |
9105 .utf8()); | |
9106 | |
9107 // Manually reset to break WebViewHelper's dependency on the stack allocated | |
9108 // TestWebFrameClient. | |
9109 reset(); | |
9110 remoteFrame->close(); | |
9111 remoteFrame2->close(); | |
9112 } | |
9113 | |
9114 class RemoteNavigationClient | 9048 class RemoteNavigationClient |
9115 : public FrameTestHelpers::TestWebRemoteFrameClient { | 9049 : public FrameTestHelpers::TestWebRemoteFrameClient { |
9116 public: | 9050 public: |
9117 void navigate(const WebURLRequest& request, | 9051 void navigate(const WebURLRequest& request, |
9118 bool shouldReplaceCurrentEntry) override { | 9052 bool shouldReplaceCurrentEntry) override { |
9119 m_lastRequest = request; | 9053 m_lastRequest = request; |
9120 } | 9054 } |
9121 | 9055 |
9122 const WebURLRequest& lastRequest() const { return m_lastRequest; } | 9056 const WebURLRequest& lastRequest() const { return m_lastRequest; } |
9123 | 9057 |
(...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11244 scrollableArea->mouseEnteredScrollbar(*scrollableArea->verticalScrollbar()); | 11178 scrollableArea->mouseEnteredScrollbar(*scrollableArea->verticalScrollbar()); |
11245 testing::runDelayedTasks(kMockOverlayFadeOutDelayMs); | 11179 testing::runDelayedTasks(kMockOverlayFadeOutDelayMs); |
11246 EXPECT_FALSE(scrollableArea->scrollbarsHidden()); | 11180 EXPECT_FALSE(scrollableArea->scrollbarsHidden()); |
11247 scrollableArea->mouseExitedScrollbar(*scrollableArea->verticalScrollbar()); | 11181 scrollableArea->mouseExitedScrollbar(*scrollableArea->verticalScrollbar()); |
11248 testing::runDelayedTasks(kMockOverlayFadeOutDelayMs); | 11182 testing::runDelayedTasks(kMockOverlayFadeOutDelayMs); |
11249 EXPECT_TRUE(scrollableArea->scrollbarsHidden()); | 11183 EXPECT_TRUE(scrollableArea->scrollbarsHidden()); |
11250 | 11184 |
11251 mockOverlayTheme.setOverlayScrollbarFadeOutDelay(0.0); | 11185 mockOverlayTheme.setOverlayScrollbarFadeOutDelay(0.0); |
11252 } | 11186 } |
11253 | 11187 |
11254 TEST_F(WebFrameTest, UniqueNames) { | |
11255 registerMockedHttpURLLoad("frameset-repeated-name.html"); | |
11256 registerMockedHttpURLLoad("frameset-dest.html"); | |
11257 FrameTestHelpers::WebViewHelper webViewHelper; | |
11258 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html"); | |
11259 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); | |
11260 HashSet<AtomicString> names; | |
11261 for (Frame* frame = mainFrame->tree().firstChild(); frame; | |
11262 frame = frame->tree().traverseNext()) { | |
11263 EXPECT_TRUE(names.insert(frame->tree().uniqueName()).isNewEntry); | |
11264 } | |
11265 EXPECT_EQ(10u, names.size()); | |
11266 } | |
11267 | |
11268 TEST_F(WebFrameTest, NoLoadingCompletionCallbacksInDetach) { | 11188 TEST_F(WebFrameTest, NoLoadingCompletionCallbacksInDetach) { |
11269 class LoadingObserverFrameClient | 11189 class LoadingObserverFrameClient |
11270 : public FrameTestHelpers::TestWebFrameClient { | 11190 : public FrameTestHelpers::TestWebFrameClient { |
11271 public: | 11191 public: |
11272 void frameDetached(WebLocalFrame*, DetachType) override { | 11192 void frameDetached(WebLocalFrame*, DetachType) override { |
11273 m_didCallFrameDetached = true; | 11193 m_didCallFrameDetached = true; |
11274 } | 11194 } |
11275 | 11195 |
11276 void didStopLoading() override { | 11196 void didStopLoading() override { |
11277 // TODO(dcheng): Investigate not calling this as well during frame detach. | 11197 // TODO(dcheng): Investigate not calling this as well during frame detach. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11316 bool m_didCallDidStopLoading = false; | 11236 bool m_didCallDidStopLoading = false; |
11317 bool m_didCallDidFinishDocumentLoad = false; | 11237 bool m_didCallDidFinishDocumentLoad = false; |
11318 bool m_didCallDidHandleOnloadEvents = false; | 11238 bool m_didCallDidHandleOnloadEvents = false; |
11319 }; | 11239 }; |
11320 | 11240 |
11321 class MainFrameClient : public FrameTestHelpers::TestWebFrameClient { | 11241 class MainFrameClient : public FrameTestHelpers::TestWebFrameClient { |
11322 public: | 11242 public: |
11323 WebLocalFrame* createChildFrame(WebLocalFrame* parent, | 11243 WebLocalFrame* createChildFrame(WebLocalFrame* parent, |
11324 WebTreeScopeType scope, | 11244 WebTreeScopeType scope, |
11325 const WebString& name, | 11245 const WebString& name, |
11326 const WebString& uniqueName, | 11246 const WebString& fallbackName, |
11327 WebSandboxFlags sandboxFlags, | 11247 WebSandboxFlags sandboxFlags, |
11328 const WebFrameOwnerProperties&) override { | 11248 const WebFrameOwnerProperties&) override { |
11329 WebLocalFrame* frame = | 11249 WebLocalFrame* frame = |
11330 WebLocalFrame::create(scope, &m_childClient, nullptr, nullptr); | 11250 WebLocalFrame::create(scope, &m_childClient, nullptr, nullptr); |
11331 parent->appendChild(frame); | 11251 parent->appendChild(frame); |
11332 return frame; | 11252 return frame; |
11333 } | 11253 } |
11334 | 11254 |
11335 LoadingObserverFrameClient& childClient() { return m_childClient; } | 11255 LoadingObserverFrameClient& childClient() { return m_childClient; } |
11336 | 11256 |
(...skipping 25 matching lines...) Expand all Loading... | |
11362 FrameTestHelpers::WebViewHelper openerHelper; | 11282 FrameTestHelpers::WebViewHelper openerHelper; |
11363 openerHelper.initialize(false, nullptr, &openerWebViewClient); | 11283 openerHelper.initialize(false, nullptr, &openerWebViewClient); |
11364 FrameTestHelpers::WebViewHelper helper; | 11284 FrameTestHelpers::WebViewHelper helper; |
11365 helper.initializeWithOpener(openerHelper.webView()->mainFrame()); | 11285 helper.initializeWithOpener(openerHelper.webView()->mainFrame()); |
11366 | 11286 |
11367 openerHelper.reset(); | 11287 openerHelper.reset(); |
11368 EXPECT_EQ(nullptr, helper.webView()->mainFrameImpl()->opener()); | 11288 EXPECT_EQ(nullptr, helper.webView()->mainFrameImpl()->opener()); |
11369 } | 11289 } |
11370 | 11290 |
11371 } // namespace blink | 11291 } // namespace blink |
OLD | NEW |