Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(992)

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 1319863006: (blink) Propagate scrolling/marginwidth/marginheight property values to child frame. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address nits Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/web/tests/FrameTestHelpers.cpp ('k') | Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 1596
1597 ASSERT_NE(nullptr, element); 1597 ASSERT_NE(nullptr, element);
1598 EXPECT_EQ(String("oldValue"), element->innerText()); 1598 EXPECT_EQ(String("oldValue"), element->innerText());
1599 1599
1600 PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPoint, hitPoint, IntSize(0, 0), 0, false, false, false, false); 1600 PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPoint, hitPoint, IntSize(0, 0), 0, false, false, false, false);
1601 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handle GestureEvent(gestureEvent); 1601 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handle GestureEvent(gestureEvent);
1602 // when pressed, the button changes its own text to "updatedValue" 1602 // when pressed, the button changes its own text to "updatedValue"
1603 EXPECT_EQ(String("updatedValue"), element->innerText()); 1603 EXPECT_EQ(String("updatedValue"), element->innerText());
1604 } 1604 }
1605 1605
1606 TEST_F(WebFrameTest, FrameOwnerPropertiesMargin)
1607 {
1608 FrameTestHelpers::TestWebViewClient viewClient;
1609 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1610 WebView* view = WebView::create(&viewClient);
1611 view->settings()->setJavaScriptEnabled(true);
1612 view->setMainFrame(remoteClient.frame());
1613 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1614 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1615
1616 WebFrameOwnerProperties properties;
1617 properties.marginWidth = 11;
1618 properties.marginHeight = 22;
1619 FrameTestHelpers::TestWebFrameClient localFrameClient;
1620 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);
1621
1622 registerMockedHttpURLLoad("frame_owner_properties.html");
1623 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1624
1625 std::string content = localFrame->contentAsText(1024).utf8();
1626 // Check if the LocalFrame has seen the marginwidth and marginheight propert ies.
1627 EXPECT_EQ("11/22", content);
1628
1629 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w();
1630 // Expect scrollbars to be enabled by default.
1631 EXPECT_NE(nullptr, frameView->horizontalScrollbar());
1632 EXPECT_NE(nullptr, frameView->verticalScrollbar());
1633
1634 view->close();
1635 }
1636
1637 TEST_F(WebFrameTest, FrameOwnerPropertiesScrolling)
1638 {
1639 FrameTestHelpers::TestWebViewClient viewClient;
1640 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1641 WebView* view = WebView::create(&viewClient);
1642 view->settings()->setJavaScriptEnabled(true);
1643 view->setMainFrame(remoteClient.frame());
1644 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1645 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1646
1647 WebFrameOwnerProperties properties;
1648 // Turn off scrolling in the subframe.
1649 properties.scrollingMode = static_cast<WebFrameOwnerProperties::ScrollingMod e>(ScrollbarAlwaysOff);
1650 FrameTestHelpers::TestWebFrameClient localFrameClient;
1651 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);
1652
1653 registerMockedHttpURLLoad("frame_owner_properties.html");
1654 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1655
1656 std::string content = localFrame->contentAsText(1024).utf8();
1657 EXPECT_EQ("0/0", content);
1658
1659 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w();
1660 EXPECT_EQ(nullptr, frameView->horizontalScrollbar());
1661 EXPECT_EQ(nullptr, frameView->verticalScrollbar());
1662
1663 view->close();
1664 }
1665
1666
1606 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations ) 1667 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations )
1607 { 1668 {
1608 UseMockScrollbarSettings mockScrollbarSettings; 1669 UseMockScrollbarSettings mockScrollbarSettings;
1609 registerMockedHttpURLLoad("200-by-300.html"); 1670 registerMockedHttpURLLoad("200-by-300.html");
1610 registerMockedHttpURLLoad("large-div.html"); 1671 registerMockedHttpURLLoad("large-div.html");
1611 1672
1612 FixedLayoutTestWebViewClient client; 1673 FixedLayoutTestWebViewClient client;
1613 client.m_screenInfo.deviceScaleFactor = 1; 1674 client.m_screenInfo.deviceScaleFactor = 1;
1614 int viewportWidth = 640; 1675 int viewportWidth = 640;
1615 int viewportHeight = 480; 1676 int viewportHeight = 480;
(...skipping 4306 matching lines...) Expand 10 before | Expand all | Expand 10 after
5922 , m_willSendRequestCallCount(0) 5983 , m_willSendRequestCallCount(0)
5923 , m_childFrameCreationCount(0) 5984 , m_childFrameCreationCount(0)
5924 { 5985 {
5925 } 5986 }
5926 5987
5927 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; } 5988 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; }
5928 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } 5989 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; }
5929 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } 5990 int willSendRequestCallCount() const { return m_willSendRequestCallCount; }
5930 int childFrameCreationCount() const { return m_childFrameCreationCount; } 5991 int childFrameCreationCount() const { return m_childFrameCreationCount; }
5931 5992
5932 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, WebSandboxFlags) 5993 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, WebSandboxFlags, const WebFrameOwnerProperties& frameOwn erProperties)
5933 { 5994 {
5934 ASSERT(m_childClient); 5995 ASSERT(m_childClient);
5935 m_childFrameCreationCount++; 5996 m_childFrameCreationCount++;
5936 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); 5997 WebFrame* frame = WebLocalFrame::create(scope, m_childClient);
5937 parent->appendChild(frame); 5998 parent->appendChild(frame);
5938 return frame; 5999 return frame;
5939 } 6000 }
5940 6001
5941 virtual void didStartLoading(bool toDifferentDocument) 6002 virtual void didStartLoading(bool toDifferentDocument)
5942 { 6003 {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
6311 // After commit, there is. 6372 // After commit, there is.
6312 HistoryItem* item = mainFrameLoader.currentItem(); 6373 HistoryItem* item = mainFrameLoader.currentItem();
6313 ASSERT_TRUE(item); 6374 ASSERT_TRUE(item);
6314 EXPECT_EQ(WTF::String(url.data()), item->urlString()); 6375 EXPECT_EQ(WTF::String(url.data()), item->urlString());
6315 } 6376 }
6316 6377
6317 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { 6378 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient {
6318 public: 6379 public:
6319 FailCreateChildFrame() : m_callCount(0) { } 6380 FailCreateChildFrame() : m_callCount(0) { }
6320 6381
6321 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, WebSandboxFlags sandboxFlags) override 6382 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, WebSandboxFlags sandboxFlags, const WebFrameOwnerPrope rties& frameOwnerProperties) override
6322 { 6383 {
6323 ++m_callCount; 6384 ++m_callCount;
6324 return 0; 6385 return 0;
6325 } 6386 }
6326 6387
6327 int callCount() const { return m_callCount; } 6388 int callCount() const { return m_callCount; }
6328 6389
6329 private: 6390 private:
6330 int m_callCount; 6391 int m_callCount;
6331 }; 6392 };
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
6973 // doesn't leave behind dangling pointers. 7034 // doesn't leave behind dangling pointers.
6974 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame) 7035 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame)
6975 { 7036 {
6976 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o 7037 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o
6977 // write tests with a top-level remote frame. 7038 // write tests with a top-level remote frame.
6978 FrameTestHelpers::TestWebViewClient viewClient; 7039 FrameTestHelpers::TestWebViewClient viewClient;
6979 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7040 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
6980 WebView* view = WebView::create(&viewClient); 7041 WebView* view = WebView::create(&viewClient);
6981 view->setMainFrame(remoteClient.frame()); 7042 view->setMainFrame(remoteClient.frame());
6982 FrameTestHelpers::TestWebFrameClient childFrameClient; 7043 FrameTestHelpers::TestWebFrameClient childFrameClient;
6983 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 7044 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
6984 7045
6985 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d. 7046 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d.
6986 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame); 7047 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame);
6987 view->close(); 7048 view->close();
6988 childCoreFrame.clear(); 7049 childCoreFrame.clear();
6989 } 7050 }
6990 7051
6991 class WebFrameSwapTest : public WebFrameTest { 7052 class WebFrameSwapTest : public WebFrameTest {
6992 protected: 7053 protected:
6993 WebFrameSwapTest() 7054 WebFrameSwapTest()
(...skipping 14 matching lines...) Expand all
7008 FrameTestHelpers::WebViewHelper m_webViewHelper; 7069 FrameTestHelpers::WebViewHelper m_webViewHelper;
7009 }; 7070 };
7010 7071
7011 TEST_F(WebFrameSwapTest, SwapMainFrame) 7072 TEST_F(WebFrameSwapTest, SwapMainFrame)
7012 { 7073 {
7013 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr); 7074 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr);
7014 mainFrame()->swap(remoteFrame); 7075 mainFrame()->swap(remoteFrame);
7015 7076
7016 FrameTestHelpers::TestWebFrameClient client; 7077 FrameTestHelpers::TestWebFrameClient client;
7017 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7078 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7018 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7079 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7019 remoteFrame->swap(localFrame); 7080 remoteFrame->swap(localFrame);
7020 7081
7021 // Finally, make sure an embedder triggered load in the local frame swapped 7082 // Finally, make sure an embedder triggered load in the local frame swapped
7022 // back in works. 7083 // back in works.
7023 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7084 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7024 std::string content = localFrame->contentAsText(1024).utf8(); 7085 std::string content = localFrame->contentAsText(1024).utf8();
7025 EXPECT_EQ("hello", content); 7086 EXPECT_EQ("hello", content);
7026 7087
7027 // Manually reset to break WebViewHelper's dependency on the stack allocated 7088 // Manually reset to break WebViewHelper's dependency on the stack allocated
7028 // TestWebFrameClient. 7089 // TestWebFrameClient.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
7072 } 7133 }
7073 7134
7074 TEST_F(WebFrameSwapTest, SwapFirstChild) 7135 TEST_F(WebFrameSwapTest, SwapFirstChild)
7075 { 7136 {
7076 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7137 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7077 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7138 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7078 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame ); 7139 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame );
7079 7140
7080 FrameTestHelpers::TestWebFrameClient client; 7141 FrameTestHelpers::TestWebFrameClient client;
7081 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7142 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7082 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7143 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7083 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ; 7144 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ;
7084 7145
7085 // FIXME: This almost certainly fires more load events on the iframe element 7146 // FIXME: This almost certainly fires more load events on the iframe element
7086 // than it should. 7147 // than it should.
7087 // Finally, make sure an embedder triggered load in the local frame swapped 7148 // Finally, make sure an embedder triggered load in the local frame swapped
7088 // back in works. 7149 // back in works.
7089 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7150 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7090 std::string content = localFrame->contentAsText(1024).utf8(); 7151 std::string content = localFrame->contentAsText(1024).utf8();
7091 EXPECT_EQ("hello", content); 7152 EXPECT_EQ("hello", content);
7092 7153
(...skipping 18 matching lines...) Expand all
7111 } 7172 }
7112 7173
7113 TEST_F(WebFrameSwapTest, SwapMiddleChild) 7174 TEST_F(WebFrameSwapTest, SwapMiddleChild)
7114 { 7175 {
7115 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7176 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7116 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7177 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7117 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e); 7178 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e);
7118 7179
7119 FrameTestHelpers::TestWebFrameClient client; 7180 FrameTestHelpers::TestWebFrameClient client;
7120 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7181 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7121 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7182 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7122 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame ); 7183 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame );
7123 7184
7124 // FIXME: This almost certainly fires more load events on the iframe element 7185 // FIXME: This almost certainly fires more load events on the iframe element
7125 // than it should. 7186 // than it should.
7126 // Finally, make sure an embedder triggered load in the local frame swapped 7187 // Finally, make sure an embedder triggered load in the local frame swapped
7127 // back in works. 7188 // back in works.
7128 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7189 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7129 std::string content = localFrame->contentAsText(1024).utf8(); 7190 std::string content = localFrame->contentAsText(1024).utf8();
7130 EXPECT_EQ("hello", content); 7191 EXPECT_EQ("hello", content);
7131 7192
(...skipping 15 matching lines...) Expand all
7147 } 7208 }
7148 7209
7149 TEST_F(WebFrameSwapTest, SwapLastChild) 7210 TEST_F(WebFrameSwapTest, SwapLastChild)
7150 { 7211 {
7151 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7212 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7152 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7213 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7153 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ; 7214 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ;
7154 7215
7155 FrameTestHelpers::TestWebFrameClient client; 7216 FrameTestHelpers::TestWebFrameClient client;
7156 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7217 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7157 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7218 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7158 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); 7219 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame);
7159 7220
7160 // FIXME: This almost certainly fires more load events on the iframe element 7221 // FIXME: This almost certainly fires more load events on the iframe element
7161 // than it should. 7222 // than it should.
7162 // Finally, make sure an embedder triggered load in the local frame swapped 7223 // Finally, make sure an embedder triggered load in the local frame swapped
7163 // back in works. 7224 // back in works.
7164 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7225 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7165 std::string content = localFrame->contentAsText(1024).utf8(); 7226 std::string content = localFrame->contentAsText(1024).utf8();
7166 EXPECT_EQ("hello", content); 7227 EXPECT_EQ("hello", content);
7167 7228
(...skipping 24 matching lines...) Expand all
7192 7253
7193 targetFrame = mainFrame()->firstChild()->nextSibling(); 7254 targetFrame = mainFrame()->firstChild()->nextSibling();
7194 EXPECT_TRUE(targetFrame); 7255 EXPECT_TRUE(targetFrame);
7195 7256
7196 // Create child frames in the target frame before testing the swap. 7257 // Create child frames in the target frame before testing the swap.
7197 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; 7258 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2;
7198 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2); 7259 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2);
7199 7260
7200 FrameTestHelpers::TestWebFrameClient client; 7261 FrameTestHelpers::TestWebFrameClient client;
7201 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7262 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7202 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7263 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7203 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); 7264 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame);
7204 7265
7205 // FIXME: This almost certainly fires more load events on the iframe element 7266 // FIXME: This almost certainly fires more load events on the iframe element
7206 // than it should. 7267 // than it should.
7207 // Finally, make sure an embedder triggered load in the local frame swapped 7268 // Finally, make sure an embedder triggered load in the local frame swapped
7208 // back in works. 7269 // back in works.
7209 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7270 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7210 std::string content = localFrame->contentAsText(1024).utf8(); 7271 std::string content = localFrame->contentAsText(1024).utf8();
7211 EXPECT_EQ("hello", content); 7272 EXPECT_EQ("hello", content);
7212 7273
(...skipping 23 matching lines...) Expand all
7236 "document.querySelector('#frame2').contentWindow;")); 7297 "document.querySelector('#frame2').contentWindow;"));
7237 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow)); 7298 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow));
7238 // Check that its view is consistent with the world. 7299 // Check that its view is consistent with the world.
7239 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource( 7300 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource(
7240 "document.querySelector('#frame2').contentWindow.top;")); 7301 "document.querySelector('#frame2').contentWindow.top;"));
7241 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); 7302 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop));
7242 7303
7243 // Now check that remote -> local works too, since it goes through a differe nt code path. 7304 // Now check that remote -> local works too, since it goes through a differe nt code path.
7244 FrameTestHelpers::TestWebFrameClient client; 7305 FrameTestHelpers::TestWebFrameClient client;
7245 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7306 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7246 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7307 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7247 remoteFrame->swap(localFrame); 7308 remoteFrame->swap(localFrame);
7248 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( WebScriptSource( 7309 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( WebScriptSource(
7249 "document.querySelector('#frame2').contentWindow;")); 7310 "document.querySelector('#frame2').contentWindow;"));
7250 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); 7311 EXPECT_TRUE(originalWindow->StrictEquals(localWindow));
7251 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource( 7312 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource(
7252 "document.querySelector('#frame2').contentWindow.top;")); 7313 "document.querySelector('#frame2').contentWindow.top;"));
7253 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); 7314 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop));
7254 7315
7255 // Manually reset to break WebViewHelper's dependency on the stack allocated 7316 // Manually reset to break WebViewHelper's dependency on the stack allocated
7256 // TestWebFrameClient. 7317 // TestWebFrameClient.
(...skipping 13 matching lines...) Expand all
7270 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7331 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7271 WebRemoteFrame* remoteFrame = remoteClient.frame(); 7332 WebRemoteFrame* remoteFrame = remoteClient.frame();
7272 mainFrame()->lastChild()->swap(remoteFrame); 7333 mainFrame()->lastChild()->swap(remoteFrame);
7273 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7334 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7274 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource("saved.top")); 7335 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource("saved.top"));
7275 EXPECT_TRUE(remoteWindowTop->IsObject()); 7336 EXPECT_TRUE(remoteWindowTop->IsObject());
7276 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); 7337 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop));
7277 7338
7278 FrameTestHelpers::TestWebFrameClient client; 7339 FrameTestHelpers::TestWebFrameClient client;
7279 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7340 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7280 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7341 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7281 remoteFrame->swap(localFrame); 7342 remoteFrame->swap(localFrame);
7282 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource("saved.top")); 7343 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource("saved.top"));
7283 EXPECT_TRUE(localWindowTop->IsObject()); 7344 EXPECT_TRUE(localWindowTop->IsObject());
7284 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); 7345 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop));
7285 7346
7286 reset(); 7347 reset();
7287 } 7348 }
7288 7349
7289 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) 7350 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable)
7290 { 7351 {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
7341 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable) 7402 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable)
7342 { 7403 {
7343 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7404 v8::HandleScope scope(v8::Isolate::GetCurrent());
7344 7405
7345 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7406 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7346 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); 7407 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7347 mainFrame()->swap(remoteParentFrame); 7408 mainFrame()->swap(remoteParentFrame);
7348 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7409 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7349 7410
7350 FrameTestHelpers::TestWebFrameClient childFrameClient; 7411 FrameTestHelpers::TestWebFrameClient childFrameClient;
7351 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); 7412 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties());
7352 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); 7413 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7353 7414
7354 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window")); 7415 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window"));
7355 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]")); 7416 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]"));
7356 EXPECT_TRUE(childOfRemoteParent->IsObject()); 7417 EXPECT_TRUE(childOfRemoteParent->IsObject());
7357 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); 7418 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent));
7358 7419
7359 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length")); 7420 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length"));
7360 ASSERT_TRUE(windowLength->IsInt32()); 7421 ASSERT_TRUE(windowLength->IsInt32());
7361 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); 7422 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value());
7362 7423
7363 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. 7424 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7364 reset(); 7425 reset();
7365 } 7426 }
7366 7427
7367 // Check that frames with a remote parent don't crash while accessing window.fra meElement. 7428 // Check that frames with a remote parent don't crash while accessing window.fra meElement.
7368 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) 7429 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent)
7369 { 7430 {
7370 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7431 v8::HandleScope scope(v8::Isolate::GetCurrent());
7371 7432
7372 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7433 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7373 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); 7434 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7374 mainFrame()->swap(remoteParentFrame); 7435 mainFrame()->swap(remoteParentFrame);
7375 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7436 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7376 7437
7377 FrameTestHelpers::TestWebFrameClient childFrameClient; 7438 FrameTestHelpers::TestWebFrameClient childFrameClient;
7378 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); 7439 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties());
7379 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); 7440 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7380 7441
7381 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement")); 7442 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement"));
7382 // frameElement shouldn't be accessible cross-origin. 7443 // frameElement shouldn't be accessible cross-origin.
7383 EXPECT_TRUE(frameElement.IsEmpty()); 7444 EXPECT_TRUE(frameElement.IsEmpty());
7384 7445
7385 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. 7446 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7386 reset(); 7447 reset();
7387 } 7448 }
7388 7449
(...skipping 26 matching lines...) Expand all
7415 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7476 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7416 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7477 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7417 WebFrame* targetFrame = mainFrame()->firstChild(); 7478 WebFrame* targetFrame = mainFrame()->firstChild();
7418 ASSERT_TRUE(targetFrame); 7479 ASSERT_TRUE(targetFrame);
7419 targetFrame->swap(remoteFrame); 7480 targetFrame->swap(remoteFrame);
7420 ASSERT_TRUE(mainFrame()->firstChild()); 7481 ASSERT_TRUE(mainFrame()->firstChild());
7421 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 7482 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
7422 7483
7423 RemoteToLocalSwapWebFrameClient client(remoteFrame); 7484 RemoteToLocalSwapWebFrameClient client(remoteFrame);
7424 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7485 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7425 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7486 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7426 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7487 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7427 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); 7488 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType());
7428 7489
7429 // Manually reset to break WebViewHelper's dependency on the stack allocated 7490 // Manually reset to break WebViewHelper's dependency on the stack allocated
7430 // TestWebFrameClient. 7491 // TestWebFrameClient.
7431 reset(); 7492 reset();
7432 remoteFrame->close(); 7493 remoteFrame->close();
7433 } 7494 }
7434 7495
7435 // The commit type should be Standard if we are swapping a RemoteFrame to a 7496 // The commit type should be Standard if we are swapping a RemoteFrame to a
7436 // LocalFrame after commits have already happened in the frame. The browser 7497 // LocalFrame after commits have already happened in the frame. The browser
7437 // process will inform us via setCommittedFirstRealLoad. 7498 // process will inform us via setCommittedFirstRealLoad.
7438 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) 7499 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap)
7439 { 7500 {
7440 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7501 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7441 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7502 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7442 WebFrame* targetFrame = mainFrame()->firstChild(); 7503 WebFrame* targetFrame = mainFrame()->firstChild();
7443 ASSERT_TRUE(targetFrame); 7504 ASSERT_TRUE(targetFrame);
7444 targetFrame->swap(remoteFrame); 7505 targetFrame->swap(remoteFrame);
7445 ASSERT_TRUE(mainFrame()->firstChild()); 7506 ASSERT_TRUE(mainFrame()->firstChild());
7446 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 7507 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
7447 7508
7448 RemoteToLocalSwapWebFrameClient client(remoteFrame); 7509 RemoteToLocalSwapWebFrameClient client(remoteFrame);
7449 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7510 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7450 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7511 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7451 localFrame->setCommittedFirstRealLoad(); 7512 localFrame->setCommittedFirstRealLoad();
7452 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7513 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7453 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); 7514 EXPECT_EQ(WebStandardCommit, client.historyCommitType());
7454 7515
7455 // Manually reset to break WebViewHelper's dependency on the stack allocated 7516 // Manually reset to break WebViewHelper's dependency on the stack allocated
7456 // TestWebFrameClient. 7517 // TestWebFrameClient.
7457 reset(); 7518 reset();
7458 remoteFrame->close(); 7519 remoteFrame->close();
7459 } 7520 }
7460 7521
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
7578 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient; 7639 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient;
7579 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame(); 7640 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame();
7580 popupView->setMainFrame(popupRemoteFrame); 7641 popupView->setMainFrame(popupRemoteFrame);
7581 popupRemoteFrame->setOpener(mainFrame); 7642 popupRemoteFrame->setOpener(mainFrame);
7582 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h ttp://foo.com")); 7643 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h ttp://foo.com"));
7583 EXPECT_FALSE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->s ecurityOrigin())); 7644 EXPECT_FALSE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->s ecurityOrigin()));
7584 7645
7585 // Do a remote-to-local swap in the popup. 7646 // Do a remote-to-local swap in the popup.
7586 FrameTestHelpers::TestWebFrameClient popupLocalClient; 7647 FrameTestHelpers::TestWebFrameClient popupLocalClient;
7587 WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Doc ument, &popupLocalClient); 7648 WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Doc ument, &popupLocalClient);
7588 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan dboxFlags::None); 7649 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan dboxFlags::None, WebFrameOwnerProperties());
7589 popupRemoteFrame->swap(popupLocalFrame); 7650 popupRemoteFrame->swap(popupLocalFrame);
7590 7651
7591 // The initial document created during the remote-to-local swap should have 7652 // The initial document created during the remote-to-local swap should have
7592 // inherited its opener's SecurityOrigin. 7653 // inherited its opener's SecurityOrigin.
7593 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se curityOrigin())); 7654 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se curityOrigin()));
7594 7655
7595 popupView->close(); 7656 popupView->close();
7596 } 7657 }
7597 7658
7598 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 7659 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
(...skipping 17 matching lines...) Expand all
7616 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) 7677 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType)
7617 { 7678 {
7618 FrameTestHelpers::TestWebViewClient viewClient; 7679 FrameTestHelpers::TestWebViewClient viewClient;
7619 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7680 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7620 WebView* view = WebView::create(&viewClient); 7681 WebView* view = WebView::create(&viewClient);
7621 view->setMainFrame(remoteClient.frame()); 7682 view->setMainFrame(remoteClient.frame());
7622 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica tedOrigin(SecurityOrigin::create(toKURL(m_baseURL))); 7683 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica tedOrigin(SecurityOrigin::create(toKURL(m_baseURL)));
7623 7684
7624 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame. 7685 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame.
7625 CommitTypeWebFrameClient childFrameClient; 7686 CommitTypeWebFrameClient childFrameClient;
7626 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 7687 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
7627 registerMockedHttpURLLoad("foo.html"); 7688 registerMockedHttpURLLoad("foo.html");
7628 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); 7689 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html");
7629 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() ); 7690 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() );
7630 view->close(); 7691 view->close();
7631 } 7692 }
7632 7693
7633 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient { 7694 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient {
7634 public: 7695 public:
7635 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { } 7696 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { }
7636 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; } 7697 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; }
7637 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; } 7698 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; }
7638 7699
7639 private: 7700 private:
7640 bool m_didHandleGestureEvent; 7701 bool m_didHandleGestureEvent;
7641 }; 7702 };
7642 7703
7643 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) 7704 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest)
7644 { 7705 {
7645 FrameTestHelpers::TestWebViewClient viewClient; 7706 FrameTestHelpers::TestWebViewClient viewClient;
7646 WebView* view = WebView::create(&viewClient); 7707 WebView* view = WebView::create(&viewClient);
7647 7708
7648 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7709 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7649 view->setMainFrame(remoteClient.frame()); 7710 view->setMainFrame(remoteClient.frame());
7650 7711
7651 FrameTestHelpers::TestWebFrameClient childFrameClient; 7712 FrameTestHelpers::TestWebFrameClient childFrameClient;
7652 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 7713 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
7653 7714
7654 GestureEventTestWebViewClient childViewClient; 7715 GestureEventTestWebViewClient childViewClient;
7655 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame ); 7716 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame );
7656 7717
7657 view->resize(WebSize(1000, 1000)); 7718 view->resize(WebSize(1000, 1000));
7658 view->layout(); 7719 view->layout();
7659 7720
7660 widget->handleInputEvent(fatTap(20, 20)); 7721 widget->handleInputEvent(fatTap(20, 20));
7661 EXPECT_TRUE(childViewClient.didHandleGestureEvent()); 7722 EXPECT_TRUE(childViewClient.didHandleGestureEvent());
7662 7723
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
7862 7923
7863 7924
7864 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling) 7925 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling)
7865 { 7926 {
7866 FrameTestHelpers::TestWebViewClient viewClient; 7927 FrameTestHelpers::TestWebViewClient viewClient;
7867 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7928 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7868 WebView* view = WebView::create(&viewClient); 7929 WebView* view = WebView::create(&viewClient);
7869 view->setMainFrame(remoteClient.frame()); 7930 view->setMainFrame(remoteClient.frame());
7870 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame(); 7931 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame();
7871 7932
7872 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, nullptr); 7933 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties() );
7873 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, secondFrame); 7934 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerProperti es());
7874 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, secondFrame); 7935 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerPropertie s());
7875 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, nullptr); 7936 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties()) ;
7876 7937
7877 EXPECT_EQ(firstFrame, parent->firstChild()); 7938 EXPECT_EQ(firstFrame, parent->firstChild());
7878 EXPECT_EQ(nullptr, firstFrame->previousSibling()); 7939 EXPECT_EQ(nullptr, firstFrame->previousSibling());
7879 EXPECT_EQ(secondFrame, firstFrame->nextSibling()); 7940 EXPECT_EQ(secondFrame, firstFrame->nextSibling());
7880 7941
7881 EXPECT_EQ(firstFrame, secondFrame->previousSibling()); 7942 EXPECT_EQ(firstFrame, secondFrame->previousSibling());
7882 EXPECT_EQ(thirdFrame, secondFrame->nextSibling()); 7943 EXPECT_EQ(thirdFrame, secondFrame->nextSibling());
7883 7944
7884 EXPECT_EQ(secondFrame, thirdFrame->previousSibling()); 7945 EXPECT_EQ(secondFrame, thirdFrame->previousSibling());
7885 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling()); 7946 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling());
(...skipping 14 matching lines...) Expand all
7900 { 7961 {
7901 FrameTestHelpers::TestWebViewClient viewClient; 7962 FrameTestHelpers::TestWebViewClient viewClient;
7902 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7963 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7903 WebView* view = WebView::create(&viewClient); 7964 WebView* view = WebView::create(&viewClient);
7904 view->settings()->setJavaScriptEnabled(true); 7965 view->settings()->setJavaScriptEnabled(true);
7905 view->setMainFrame(remoteClient.frame()); 7966 view->setMainFrame(remoteClient.frame());
7906 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); 7967 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
7907 root->setReplicatedOrigin(SecurityOrigin::createUnique()); 7968 root->setReplicatedOrigin(SecurityOrigin::createUnique());
7908 7969
7909 FrameTestHelpers::TestWebFrameClient localFrameClient; 7970 FrameTestHelpers::TestWebFrameClient localFrameClient;
7910 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr); 7971 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, WebFrameOwnerPropertie s());
7911 7972
7912 // Finally, make sure an embedder triggered load in the local frame swapped 7973 // Finally, make sure an embedder triggered load in the local frame swapped
7913 // back in works. 7974 // back in works.
7914 registerMockedHttpURLLoad("send_beacon.html"); 7975 registerMockedHttpURLLoad("send_beacon.html");
7915 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon() 7976 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon()
7916 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html"); 7977 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html");
7917 7978
7918 view->close(); 7979 view->close();
7919 } 7980 }
7920 7981
7921 // See https://crbug.com/525285. 7982 // See https://crbug.com/525285.
7922 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me) 7983 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me)
7923 { 7984 {
7924 FrameTestHelpers::TestWebViewClient viewClient; 7985 FrameTestHelpers::TestWebViewClient viewClient;
7925 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7986 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7926 WebView* view = WebView::create(&viewClient); 7987 WebView* view = WebView::create(&viewClient);
7927 view->setMainFrame(remoteClient.frame()); 7988 view->setMainFrame(remoteClient.frame());
7928 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); 7989 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame();
7929 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); 7990 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique());
7930 7991
7931 FrameTestHelpers::TestWebFrameClient localFrameClient; 7992 FrameTestHelpers::TestWebFrameClient localFrameClient;
7932 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr); 7993 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr, WebFrameOwnerProperties());
7933 7994
7934 // Do a remote-to-local swap of the top frame. 7995 // Do a remote-to-local swap of the top frame.
7935 FrameTestHelpers::TestWebFrameClient localClient; 7996 FrameTestHelpers::TestWebFrameClient localClient;
7936 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient); 7997 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient);
7937 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N one); 7998 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N one, WebFrameOwnerProperties());
7938 remoteRoot->swap(localRoot); 7999 remoteRoot->swap(localRoot);
7939 8000
7940 // Load a page with a child frame in the new root to make sure this doesn't 8001 // Load a page with a child frame in the new root to make sure this doesn't
7941 // crash when the child frame invokes setCoreFrame. 8002 // crash when the child frame invokes setCoreFrame.
7942 registerMockedHttpURLLoad("single_iframe.html"); 8003 registerMockedHttpURLLoad("single_iframe.html");
7943 registerMockedHttpURLLoad("visible_iframe.html"); 8004 registerMockedHttpURLLoad("visible_iframe.html");
7944 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); 8005 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html");
7945 8006
7946 view->close(); 8007 view->close();
7947 } 8008 }
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
8223 8284
8224 TEST_F(WebFrameTest, MaxFramesDetach) 8285 TEST_F(WebFrameTest, MaxFramesDetach)
8225 { 8286 {
8226 registerMockedHttpURLLoad("max-frames-detach.html"); 8287 registerMockedHttpURLLoad("max-frames-detach.html");
8227 FrameTestHelpers::WebViewHelper webViewHelper; 8288 FrameTestHelpers::WebViewHelper webViewHelper;
8228 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); 8289 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true);
8229 webViewImpl->mainFrameImpl()->collectGarbage(); 8290 webViewImpl->mainFrameImpl()->collectGarbage();
8230 } 8291 }
8231 8292
8232 } // namespace blink 8293 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/tests/FrameTestHelpers.cpp ('k') | Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698