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

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

Issue 1307013004: Propagate scrolling/marginwidth/marginheight property values to child frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync + fix html_viewer compile Created 5 years, 2 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
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 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 1594
1595 ASSERT_NE(nullptr, element); 1595 ASSERT_NE(nullptr, element);
1596 EXPECT_EQ(String("oldValue"), element->innerText()); 1596 EXPECT_EQ(String("oldValue"), element->innerText());
1597 1597
1598 PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPoint, hitPoint, IntSize(0, 0), 0, PlatformEvent::NoModifiers); 1598 PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPoint, hitPoint, IntSize(0, 0), 0, PlatformEvent::NoModifiers);
1599 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handle GestureEvent(gestureEvent); 1599 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handle GestureEvent(gestureEvent);
1600 // when pressed, the button changes its own text to "updatedValue" 1600 // when pressed, the button changes its own text to "updatedValue"
1601 EXPECT_EQ(String("updatedValue"), element->innerText()); 1601 EXPECT_EQ(String("updatedValue"), element->innerText());
1602 } 1602 }
1603 1603
1604 TEST_F(WebFrameTest, FrameOwnerPropertiesMargin)
1605 {
1606 FrameTestHelpers::TestWebViewClient viewClient;
1607 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1608 WebView* view = WebView::create(&viewClient);
1609 view->settings()->setJavaScriptEnabled(true);
1610 view->setMainFrame(remoteClient.frame());
1611 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1612 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1613
1614 WebFrameOwnerProperties properties;
1615 properties.marginWidth = 11;
1616 properties.marginHeight = 22;
1617 FrameTestHelpers::TestWebFrameClient localFrameClient;
1618 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);
1619
1620 registerMockedHttpURLLoad("frame_owner_properties.html");
1621 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1622
1623 std::string content = localFrame->contentAsText(1024).utf8();
1624 // Check if the LocalFrame has seen the marginwidth and marginheight propert ies.
1625 EXPECT_EQ("11/22", content);
1626
1627 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w();
1628 // Expect scrollbars to be enabled by default.
1629 EXPECT_NE(nullptr, frameView->horizontalScrollbar());
1630 EXPECT_NE(nullptr, frameView->verticalScrollbar());
1631
1632 view->close();
1633 }
1634
1635 TEST_F(WebFrameTest, FrameOwnerPropertiesScrolling)
1636 {
1637 FrameTestHelpers::TestWebViewClient viewClient;
1638 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1639 WebView* view = WebView::create(&viewClient);
1640 view->settings()->setJavaScriptEnabled(true);
1641 view->setMainFrame(remoteClient.frame());
1642 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1643 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1644
1645 WebFrameOwnerProperties properties;
1646 // Turn off scrolling in the subframe.
1647 properties.scrollingMode = static_cast<WebFrameOwnerProperties::ScrollingMod e>(ScrollbarAlwaysOff);
1648 FrameTestHelpers::TestWebFrameClient localFrameClient;
1649 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);
1650
1651 registerMockedHttpURLLoad("frame_owner_properties.html");
1652 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1653
1654 std::string content = localFrame->contentAsText(1024).utf8();
1655 EXPECT_EQ("0/0", content);
1656
1657 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w();
1658 EXPECT_EQ(nullptr, frameView->horizontalScrollbar());
1659 EXPECT_EQ(nullptr, frameView->verticalScrollbar());
1660
1661 view->close();
1662 }
1663
1664
1604 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations ) 1665 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations )
1605 { 1666 {
1606 UseMockScrollbarSettings mockScrollbarSettings; 1667 UseMockScrollbarSettings mockScrollbarSettings;
1607 registerMockedHttpURLLoad("200-by-300.html"); 1668 registerMockedHttpURLLoad("200-by-300.html");
1608 registerMockedHttpURLLoad("large-div.html"); 1669 registerMockedHttpURLLoad("large-div.html");
1609 1670
1610 FixedLayoutTestWebViewClient client; 1671 FixedLayoutTestWebViewClient client;
1611 client.m_screenInfo.deviceScaleFactor = 1; 1672 client.m_screenInfo.deviceScaleFactor = 1;
1612 int viewportWidth = 640; 1673 int viewportWidth = 640;
1613 int viewportHeight = 480; 1674 int viewportHeight = 480;
(...skipping 4301 matching lines...) Expand 10 before | Expand all | Expand 10 after
5915 , m_willSendRequestCallCount(0) 5976 , m_willSendRequestCallCount(0)
5916 , m_childFrameCreationCount(0) 5977 , m_childFrameCreationCount(0)
5917 { 5978 {
5918 } 5979 }
5919 5980
5920 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; } 5981 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; }
5921 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } 5982 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; }
5922 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } 5983 int willSendRequestCallCount() const { return m_willSendRequestCallCount; }
5923 int childFrameCreationCount() const { return m_childFrameCreationCount; } 5984 int childFrameCreationCount() const { return m_childFrameCreationCount; }
5924 5985
5925 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, WebSandboxFlags) 5986 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, WebSandboxFlags, const WebFrameOwnerProperties& frameOwn erProperties)
5926 { 5987 {
5927 ASSERT(m_childClient); 5988 ASSERT(m_childClient);
5928 m_childFrameCreationCount++; 5989 m_childFrameCreationCount++;
5929 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); 5990 WebFrame* frame = WebLocalFrame::create(scope, m_childClient);
5930 parent->appendChild(frame); 5991 parent->appendChild(frame);
5931 return frame; 5992 return frame;
5932 } 5993 }
5933 5994
5934 virtual void didStartLoading(bool toDifferentDocument) 5995 virtual void didStartLoading(bool toDifferentDocument)
5935 { 5996 {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
6304 // After commit, there is. 6365 // After commit, there is.
6305 HistoryItem* item = mainFrameLoader.currentItem(); 6366 HistoryItem* item = mainFrameLoader.currentItem();
6306 ASSERT_TRUE(item); 6367 ASSERT_TRUE(item);
6307 EXPECT_EQ(WTF::String(url.data()), item->urlString()); 6368 EXPECT_EQ(WTF::String(url.data()), item->urlString());
6308 } 6369 }
6309 6370
6310 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { 6371 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient {
6311 public: 6372 public:
6312 FailCreateChildFrame() : m_callCount(0) { } 6373 FailCreateChildFrame() : m_callCount(0) { }
6313 6374
6314 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, WebSandboxFlags sandboxFlags) override 6375 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, WebSandboxFlags sandboxFlags, const WebFrameOwnerPrope rties& frameOwnerProperties) override
6315 { 6376 {
6316 ++m_callCount; 6377 ++m_callCount;
6317 return 0; 6378 return 0;
6318 } 6379 }
6319 6380
6320 int callCount() const { return m_callCount; } 6381 int callCount() const { return m_callCount; }
6321 6382
6322 private: 6383 private:
6323 int m_callCount; 6384 int m_callCount;
6324 }; 6385 };
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
6966 // doesn't leave behind dangling pointers. 7027 // doesn't leave behind dangling pointers.
6967 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame) 7028 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame)
6968 { 7029 {
6969 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o 7030 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o
6970 // write tests with a top-level remote frame. 7031 // write tests with a top-level remote frame.
6971 FrameTestHelpers::TestWebViewClient viewClient; 7032 FrameTestHelpers::TestWebViewClient viewClient;
6972 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7033 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
6973 WebView* view = WebView::create(&viewClient); 7034 WebView* view = WebView::create(&viewClient);
6974 view->setMainFrame(remoteClient.frame()); 7035 view->setMainFrame(remoteClient.frame());
6975 FrameTestHelpers::TestWebFrameClient childFrameClient; 7036 FrameTestHelpers::TestWebFrameClient childFrameClient;
6976 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 7037 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
6977 7038
6978 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d. 7039 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d.
6979 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame); 7040 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame);
6980 view->close(); 7041 view->close();
6981 childCoreFrame.clear(); 7042 childCoreFrame.clear();
6982 } 7043 }
6983 7044
6984 class WebFrameSwapTest : public WebFrameTest { 7045 class WebFrameSwapTest : public WebFrameTest {
6985 protected: 7046 protected:
6986 WebFrameSwapTest() 7047 WebFrameSwapTest()
(...skipping 14 matching lines...) Expand all
7001 FrameTestHelpers::WebViewHelper m_webViewHelper; 7062 FrameTestHelpers::WebViewHelper m_webViewHelper;
7002 }; 7063 };
7003 7064
7004 TEST_F(WebFrameSwapTest, SwapMainFrame) 7065 TEST_F(WebFrameSwapTest, SwapMainFrame)
7005 { 7066 {
7006 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr); 7067 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr);
7007 mainFrame()->swap(remoteFrame); 7068 mainFrame()->swap(remoteFrame);
7008 7069
7009 FrameTestHelpers::TestWebFrameClient client; 7070 FrameTestHelpers::TestWebFrameClient client;
7010 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7071 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7011 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7072 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7012 remoteFrame->swap(localFrame); 7073 remoteFrame->swap(localFrame);
7013 7074
7014 // Finally, make sure an embedder triggered load in the local frame swapped 7075 // Finally, make sure an embedder triggered load in the local frame swapped
7015 // back in works. 7076 // back in works.
7016 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7077 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7017 std::string content = localFrame->contentAsText(1024).utf8(); 7078 std::string content = localFrame->contentAsText(1024).utf8();
7018 EXPECT_EQ("hello", content); 7079 EXPECT_EQ("hello", content);
7019 7080
7020 // Manually reset to break WebViewHelper's dependency on the stack allocated 7081 // Manually reset to break WebViewHelper's dependency on the stack allocated
7021 // TestWebFrameClient. 7082 // TestWebFrameClient.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
7065 } 7126 }
7066 7127
7067 TEST_F(WebFrameSwapTest, SwapFirstChild) 7128 TEST_F(WebFrameSwapTest, SwapFirstChild)
7068 { 7129 {
7069 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7130 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7070 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7131 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7071 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame ); 7132 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame );
7072 7133
7073 FrameTestHelpers::TestWebFrameClient client; 7134 FrameTestHelpers::TestWebFrameClient client;
7074 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7135 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7075 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7136 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7076 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ; 7137 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ;
7077 7138
7078 // FIXME: This almost certainly fires more load events on the iframe element 7139 // FIXME: This almost certainly fires more load events on the iframe element
7079 // than it should. 7140 // than it should.
7080 // Finally, make sure an embedder triggered load in the local frame swapped 7141 // Finally, make sure an embedder triggered load in the local frame swapped
7081 // back in works. 7142 // back in works.
7082 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7143 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7083 std::string content = localFrame->contentAsText(1024).utf8(); 7144 std::string content = localFrame->contentAsText(1024).utf8();
7084 EXPECT_EQ("hello", content); 7145 EXPECT_EQ("hello", content);
7085 7146
(...skipping 18 matching lines...) Expand all
7104 } 7165 }
7105 7166
7106 TEST_F(WebFrameSwapTest, SwapMiddleChild) 7167 TEST_F(WebFrameSwapTest, SwapMiddleChild)
7107 { 7168 {
7108 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7169 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7109 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7170 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7110 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e); 7171 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e);
7111 7172
7112 FrameTestHelpers::TestWebFrameClient client; 7173 FrameTestHelpers::TestWebFrameClient client;
7113 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7174 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7114 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7175 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7115 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame ); 7176 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame );
7116 7177
7117 // FIXME: This almost certainly fires more load events on the iframe element 7178 // FIXME: This almost certainly fires more load events on the iframe element
7118 // than it should. 7179 // than it should.
7119 // Finally, make sure an embedder triggered load in the local frame swapped 7180 // Finally, make sure an embedder triggered load in the local frame swapped
7120 // back in works. 7181 // back in works.
7121 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7182 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7122 std::string content = localFrame->contentAsText(1024).utf8(); 7183 std::string content = localFrame->contentAsText(1024).utf8();
7123 EXPECT_EQ("hello", content); 7184 EXPECT_EQ("hello", content);
7124 7185
(...skipping 15 matching lines...) Expand all
7140 } 7201 }
7141 7202
7142 TEST_F(WebFrameSwapTest, SwapLastChild) 7203 TEST_F(WebFrameSwapTest, SwapLastChild)
7143 { 7204 {
7144 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7205 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7145 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7206 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7146 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ; 7207 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ;
7147 7208
7148 FrameTestHelpers::TestWebFrameClient client; 7209 FrameTestHelpers::TestWebFrameClient client;
7149 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7210 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7150 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7211 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7151 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); 7212 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame);
7152 7213
7153 // FIXME: This almost certainly fires more load events on the iframe element 7214 // FIXME: This almost certainly fires more load events on the iframe element
7154 // than it should. 7215 // than it should.
7155 // Finally, make sure an embedder triggered load in the local frame swapped 7216 // Finally, make sure an embedder triggered load in the local frame swapped
7156 // back in works. 7217 // back in works.
7157 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7218 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7158 std::string content = localFrame->contentAsText(1024).utf8(); 7219 std::string content = localFrame->contentAsText(1024).utf8();
7159 EXPECT_EQ("hello", content); 7220 EXPECT_EQ("hello", content);
7160 7221
(...skipping 24 matching lines...) Expand all
7185 7246
7186 targetFrame = mainFrame()->firstChild()->nextSibling(); 7247 targetFrame = mainFrame()->firstChild()->nextSibling();
7187 EXPECT_TRUE(targetFrame); 7248 EXPECT_TRUE(targetFrame);
7188 7249
7189 // Create child frames in the target frame before testing the swap. 7250 // Create child frames in the target frame before testing the swap.
7190 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; 7251 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2;
7191 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2); 7252 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2);
7192 7253
7193 FrameTestHelpers::TestWebFrameClient client; 7254 FrameTestHelpers::TestWebFrameClient client;
7194 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7255 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7195 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7256 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7196 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); 7257 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame);
7197 7258
7198 // FIXME: This almost certainly fires more load events on the iframe element 7259 // FIXME: This almost certainly fires more load events on the iframe element
7199 // than it should. 7260 // than it should.
7200 // Finally, make sure an embedder triggered load in the local frame swapped 7261 // Finally, make sure an embedder triggered load in the local frame swapped
7201 // back in works. 7262 // back in works.
7202 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7263 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7203 std::string content = localFrame->contentAsText(1024).utf8(); 7264 std::string content = localFrame->contentAsText(1024).utf8();
7204 EXPECT_EQ("hello", content); 7265 EXPECT_EQ("hello", content);
7205 7266
(...skipping 23 matching lines...) Expand all
7229 "document.querySelector('#frame2').contentWindow;")); 7290 "document.querySelector('#frame2').contentWindow;"));
7230 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow)); 7291 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow));
7231 // Check that its view is consistent with the world. 7292 // Check that its view is consistent with the world.
7232 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource( 7293 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource(
7233 "document.querySelector('#frame2').contentWindow.top;")); 7294 "document.querySelector('#frame2').contentWindow.top;"));
7234 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); 7295 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop));
7235 7296
7236 // Now check that remote -> local works too, since it goes through a differe nt code path. 7297 // Now check that remote -> local works too, since it goes through a differe nt code path.
7237 FrameTestHelpers::TestWebFrameClient client; 7298 FrameTestHelpers::TestWebFrameClient client;
7238 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7299 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7239 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7300 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7240 remoteFrame->swap(localFrame); 7301 remoteFrame->swap(localFrame);
7241 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( WebScriptSource( 7302 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( WebScriptSource(
7242 "document.querySelector('#frame2').contentWindow;")); 7303 "document.querySelector('#frame2').contentWindow;"));
7243 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); 7304 EXPECT_TRUE(originalWindow->StrictEquals(localWindow));
7244 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource( 7305 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource(
7245 "document.querySelector('#frame2').contentWindow.top;")); 7306 "document.querySelector('#frame2').contentWindow.top;"));
7246 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); 7307 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop));
7247 7308
7248 // Manually reset to break WebViewHelper's dependency on the stack allocated 7309 // Manually reset to break WebViewHelper's dependency on the stack allocated
7249 // TestWebFrameClient. 7310 // TestWebFrameClient.
(...skipping 13 matching lines...) Expand all
7263 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7324 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7264 WebRemoteFrame* remoteFrame = remoteClient.frame(); 7325 WebRemoteFrame* remoteFrame = remoteClient.frame();
7265 mainFrame()->lastChild()->swap(remoteFrame); 7326 mainFrame()->lastChild()->swap(remoteFrame);
7266 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7327 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7267 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource("saved.top")); 7328 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource("saved.top"));
7268 EXPECT_TRUE(remoteWindowTop->IsObject()); 7329 EXPECT_TRUE(remoteWindowTop->IsObject());
7269 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); 7330 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop));
7270 7331
7271 FrameTestHelpers::TestWebFrameClient client; 7332 FrameTestHelpers::TestWebFrameClient client;
7272 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7333 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7273 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7334 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7274 remoteFrame->swap(localFrame); 7335 remoteFrame->swap(localFrame);
7275 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource("saved.top")); 7336 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource("saved.top"));
7276 EXPECT_TRUE(localWindowTop->IsObject()); 7337 EXPECT_TRUE(localWindowTop->IsObject());
7277 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); 7338 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop));
7278 7339
7279 reset(); 7340 reset();
7280 } 7341 }
7281 7342
7282 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) 7343 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable)
7283 { 7344 {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
7334 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable) 7395 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable)
7335 { 7396 {
7336 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7397 v8::HandleScope scope(v8::Isolate::GetCurrent());
7337 7398
7338 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7399 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7339 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); 7400 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7340 mainFrame()->swap(remoteParentFrame); 7401 mainFrame()->swap(remoteParentFrame);
7341 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7402 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7342 7403
7343 FrameTestHelpers::TestWebFrameClient childFrameClient; 7404 FrameTestHelpers::TestWebFrameClient childFrameClient;
7344 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); 7405 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties());
7345 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); 7406 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7346 7407
7347 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window")); 7408 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window"));
7348 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]")); 7409 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]"));
7349 EXPECT_TRUE(childOfRemoteParent->IsObject()); 7410 EXPECT_TRUE(childOfRemoteParent->IsObject());
7350 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); 7411 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent));
7351 7412
7352 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length")); 7413 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length"));
7353 ASSERT_TRUE(windowLength->IsInt32()); 7414 ASSERT_TRUE(windowLength->IsInt32());
7354 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); 7415 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value());
7355 7416
7356 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. 7417 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7357 reset(); 7418 reset();
7358 } 7419 }
7359 7420
7360 // Check that frames with a remote parent don't crash while accessing window.fra meElement. 7421 // Check that frames with a remote parent don't crash while accessing window.fra meElement.
7361 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) 7422 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent)
7362 { 7423 {
7363 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7424 v8::HandleScope scope(v8::Isolate::GetCurrent());
7364 7425
7365 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7426 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7366 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); 7427 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7367 mainFrame()->swap(remoteParentFrame); 7428 mainFrame()->swap(remoteParentFrame);
7368 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7429 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7369 7430
7370 FrameTestHelpers::TestWebFrameClient childFrameClient; 7431 FrameTestHelpers::TestWebFrameClient childFrameClient;
7371 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); 7432 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties());
7372 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); 7433 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7373 7434
7374 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement")); 7435 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement"));
7375 // frameElement shouldn't be accessible cross-origin. 7436 // frameElement shouldn't be accessible cross-origin.
7376 EXPECT_TRUE(frameElement.IsEmpty()); 7437 EXPECT_TRUE(frameElement.IsEmpty());
7377 7438
7378 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. 7439 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7379 reset(); 7440 reset();
7380 } 7441 }
7381 7442
(...skipping 26 matching lines...) Expand all
7408 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7469 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7409 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7470 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7410 WebFrame* targetFrame = mainFrame()->firstChild(); 7471 WebFrame* targetFrame = mainFrame()->firstChild();
7411 ASSERT_TRUE(targetFrame); 7472 ASSERT_TRUE(targetFrame);
7412 targetFrame->swap(remoteFrame); 7473 targetFrame->swap(remoteFrame);
7413 ASSERT_TRUE(mainFrame()->firstChild()); 7474 ASSERT_TRUE(mainFrame()->firstChild());
7414 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 7475 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
7415 7476
7416 RemoteToLocalSwapWebFrameClient client(remoteFrame); 7477 RemoteToLocalSwapWebFrameClient client(remoteFrame);
7417 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7478 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7418 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7479 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7419 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7480 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7420 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); 7481 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType());
7421 7482
7422 // Manually reset to break WebViewHelper's dependency on the stack allocated 7483 // Manually reset to break WebViewHelper's dependency on the stack allocated
7423 // TestWebFrameClient. 7484 // TestWebFrameClient.
7424 reset(); 7485 reset();
7425 remoteFrame->close(); 7486 remoteFrame->close();
7426 } 7487 }
7427 7488
7428 // The commit type should be Standard if we are swapping a RemoteFrame to a 7489 // The commit type should be Standard if we are swapping a RemoteFrame to a
7429 // LocalFrame after commits have already happened in the frame. The browser 7490 // LocalFrame after commits have already happened in the frame. The browser
7430 // process will inform us via setCommittedFirstRealLoad. 7491 // process will inform us via setCommittedFirstRealLoad.
7431 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) 7492 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap)
7432 { 7493 {
7433 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7494 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7434 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7495 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7435 WebFrame* targetFrame = mainFrame()->firstChild(); 7496 WebFrame* targetFrame = mainFrame()->firstChild();
7436 ASSERT_TRUE(targetFrame); 7497 ASSERT_TRUE(targetFrame);
7437 targetFrame->swap(remoteFrame); 7498 targetFrame->swap(remoteFrame);
7438 ASSERT_TRUE(mainFrame()->firstChild()); 7499 ASSERT_TRUE(mainFrame()->firstChild());
7439 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 7500 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
7440 7501
7441 RemoteToLocalSwapWebFrameClient client(remoteFrame); 7502 RemoteToLocalSwapWebFrameClient client(remoteFrame);
7442 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7503 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7443 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7504 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7444 localFrame->setCommittedFirstRealLoad(); 7505 localFrame->setCommittedFirstRealLoad();
7445 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7506 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7446 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); 7507 EXPECT_EQ(WebStandardCommit, client.historyCommitType());
7447 7508
7448 // Manually reset to break WebViewHelper's dependency on the stack allocated 7509 // Manually reset to break WebViewHelper's dependency on the stack allocated
7449 // TestWebFrameClient. 7510 // TestWebFrameClient.
7450 reset(); 7511 reset();
7451 remoteFrame->close(); 7512 remoteFrame->close();
7452 } 7513 }
7453 7514
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
7571 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient; 7632 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient;
7572 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame(); 7633 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame();
7573 popupView->setMainFrame(popupRemoteFrame); 7634 popupView->setMainFrame(popupRemoteFrame);
7574 popupRemoteFrame->setOpener(mainFrame); 7635 popupRemoteFrame->setOpener(mainFrame);
7575 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h ttp://foo.com")); 7636 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h ttp://foo.com"));
7576 EXPECT_FALSE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->s ecurityOrigin())); 7637 EXPECT_FALSE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->s ecurityOrigin()));
7577 7638
7578 // Do a remote-to-local swap in the popup. 7639 // Do a remote-to-local swap in the popup.
7579 FrameTestHelpers::TestWebFrameClient popupLocalClient; 7640 FrameTestHelpers::TestWebFrameClient popupLocalClient;
7580 WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Doc ument, &popupLocalClient); 7641 WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Doc ument, &popupLocalClient);
7581 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan dboxFlags::None); 7642 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan dboxFlags::None, WebFrameOwnerProperties());
7582 popupRemoteFrame->swap(popupLocalFrame); 7643 popupRemoteFrame->swap(popupLocalFrame);
7583 7644
7584 // The initial document created during the remote-to-local swap should have 7645 // The initial document created during the remote-to-local swap should have
7585 // inherited its opener's SecurityOrigin. 7646 // inherited its opener's SecurityOrigin.
7586 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se curityOrigin())); 7647 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se curityOrigin()));
7587 7648
7588 popupView->close(); 7649 popupView->close();
7589 } 7650 }
7590 7651
7591 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 7652 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
(...skipping 17 matching lines...) Expand all
7609 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) 7670 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType)
7610 { 7671 {
7611 FrameTestHelpers::TestWebViewClient viewClient; 7672 FrameTestHelpers::TestWebViewClient viewClient;
7612 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7673 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7613 WebView* view = WebView::create(&viewClient); 7674 WebView* view = WebView::create(&viewClient);
7614 view->setMainFrame(remoteClient.frame()); 7675 view->setMainFrame(remoteClient.frame());
7615 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica tedOrigin(SecurityOrigin::create(toKURL(m_baseURL))); 7676 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica tedOrigin(SecurityOrigin::create(toKURL(m_baseURL)));
7616 7677
7617 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame. 7678 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame.
7618 CommitTypeWebFrameClient childFrameClient; 7679 CommitTypeWebFrameClient childFrameClient;
7619 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 7680 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
7620 registerMockedHttpURLLoad("foo.html"); 7681 registerMockedHttpURLLoad("foo.html");
7621 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); 7682 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html");
7622 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() ); 7683 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() );
7623 view->close(); 7684 view->close();
7624 } 7685 }
7625 7686
7626 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient { 7687 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient {
7627 public: 7688 public:
7628 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { } 7689 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { }
7629 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; } 7690 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; }
7630 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; } 7691 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; }
7631 7692
7632 private: 7693 private:
7633 bool m_didHandleGestureEvent; 7694 bool m_didHandleGestureEvent;
7634 }; 7695 };
7635 7696
7636 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) 7697 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest)
7637 { 7698 {
7638 FrameTestHelpers::TestWebViewClient viewClient; 7699 FrameTestHelpers::TestWebViewClient viewClient;
7639 WebView* view = WebView::create(&viewClient); 7700 WebView* view = WebView::create(&viewClient);
7640 7701
7641 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7702 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7642 view->setMainFrame(remoteClient.frame()); 7703 view->setMainFrame(remoteClient.frame());
7643 7704
7644 FrameTestHelpers::TestWebFrameClient childFrameClient; 7705 FrameTestHelpers::TestWebFrameClient childFrameClient;
7645 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 7706 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
7646 7707
7647 GestureEventTestWebViewClient childViewClient; 7708 GestureEventTestWebViewClient childViewClient;
7648 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame ); 7709 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame );
7649 7710
7650 view->resize(WebSize(1000, 1000)); 7711 view->resize(WebSize(1000, 1000));
7651 view->layout(); 7712 view->layout();
7652 7713
7653 widget->handleInputEvent(fatTap(20, 20)); 7714 widget->handleInputEvent(fatTap(20, 20));
7654 EXPECT_TRUE(childViewClient.didHandleGestureEvent()); 7715 EXPECT_TRUE(childViewClient.didHandleGestureEvent());
7655 7716
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
7855 7916
7856 7917
7857 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling) 7918 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling)
7858 { 7919 {
7859 FrameTestHelpers::TestWebViewClient viewClient; 7920 FrameTestHelpers::TestWebViewClient viewClient;
7860 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7921 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7861 WebView* view = WebView::create(&viewClient); 7922 WebView* view = WebView::create(&viewClient);
7862 view->setMainFrame(remoteClient.frame()); 7923 view->setMainFrame(remoteClient.frame());
7863 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame(); 7924 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame();
7864 7925
7865 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, nullptr); 7926 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties() );
7866 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, secondFrame); 7927 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerProperti es());
7867 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, secondFrame); 7928 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerPropertie s());
7868 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, nullptr); 7929 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties()) ;
7869 7930
7870 EXPECT_EQ(firstFrame, parent->firstChild()); 7931 EXPECT_EQ(firstFrame, parent->firstChild());
7871 EXPECT_EQ(nullptr, firstFrame->previousSibling()); 7932 EXPECT_EQ(nullptr, firstFrame->previousSibling());
7872 EXPECT_EQ(secondFrame, firstFrame->nextSibling()); 7933 EXPECT_EQ(secondFrame, firstFrame->nextSibling());
7873 7934
7874 EXPECT_EQ(firstFrame, secondFrame->previousSibling()); 7935 EXPECT_EQ(firstFrame, secondFrame->previousSibling());
7875 EXPECT_EQ(thirdFrame, secondFrame->nextSibling()); 7936 EXPECT_EQ(thirdFrame, secondFrame->nextSibling());
7876 7937
7877 EXPECT_EQ(secondFrame, thirdFrame->previousSibling()); 7938 EXPECT_EQ(secondFrame, thirdFrame->previousSibling());
7878 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling()); 7939 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling());
(...skipping 14 matching lines...) Expand all
7893 { 7954 {
7894 FrameTestHelpers::TestWebViewClient viewClient; 7955 FrameTestHelpers::TestWebViewClient viewClient;
7895 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7956 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7896 WebView* view = WebView::create(&viewClient); 7957 WebView* view = WebView::create(&viewClient);
7897 view->settings()->setJavaScriptEnabled(true); 7958 view->settings()->setJavaScriptEnabled(true);
7898 view->setMainFrame(remoteClient.frame()); 7959 view->setMainFrame(remoteClient.frame());
7899 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); 7960 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
7900 root->setReplicatedOrigin(SecurityOrigin::createUnique()); 7961 root->setReplicatedOrigin(SecurityOrigin::createUnique());
7901 7962
7902 FrameTestHelpers::TestWebFrameClient localFrameClient; 7963 FrameTestHelpers::TestWebFrameClient localFrameClient;
7903 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr); 7964 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, WebFrameOwnerPropertie s());
7904 7965
7905 // Finally, make sure an embedder triggered load in the local frame swapped 7966 // Finally, make sure an embedder triggered load in the local frame swapped
7906 // back in works. 7967 // back in works.
7907 registerMockedHttpURLLoad("send_beacon.html"); 7968 registerMockedHttpURLLoad("send_beacon.html");
7908 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon() 7969 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon()
7909 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html"); 7970 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html");
7910 7971
7911 view->close(); 7972 view->close();
7912 } 7973 }
7913 7974
7914 // See https://crbug.com/525285. 7975 // See https://crbug.com/525285.
7915 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me) 7976 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me)
7916 { 7977 {
7917 FrameTestHelpers::TestWebViewClient viewClient; 7978 FrameTestHelpers::TestWebViewClient viewClient;
7918 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7979 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7919 WebView* view = WebView::create(&viewClient); 7980 WebView* view = WebView::create(&viewClient);
7920 view->setMainFrame(remoteClient.frame()); 7981 view->setMainFrame(remoteClient.frame());
7921 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); 7982 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame();
7922 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); 7983 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique());
7923 7984
7924 FrameTestHelpers::TestWebFrameClient localFrameClient; 7985 FrameTestHelpers::TestWebFrameClient localFrameClient;
7925 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr); 7986 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr, WebFrameOwnerProperties());
7926 7987
7927 // Do a remote-to-local swap of the top frame. 7988 // Do a remote-to-local swap of the top frame.
7928 FrameTestHelpers::TestWebFrameClient localClient; 7989 FrameTestHelpers::TestWebFrameClient localClient;
7929 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient); 7990 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient);
7930 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N one); 7991 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N one, WebFrameOwnerProperties());
7931 remoteRoot->swap(localRoot); 7992 remoteRoot->swap(localRoot);
7932 7993
7933 // Load a page with a child frame in the new root to make sure this doesn't 7994 // Load a page with a child frame in the new root to make sure this doesn't
7934 // crash when the child frame invokes setCoreFrame. 7995 // crash when the child frame invokes setCoreFrame.
7935 registerMockedHttpURLLoad("single_iframe.html"); 7996 registerMockedHttpURLLoad("single_iframe.html");
7936 registerMockedHttpURLLoad("visible_iframe.html"); 7997 registerMockedHttpURLLoad("visible_iframe.html");
7937 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); 7998 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html");
7938 7999
7939 view->close(); 8000 view->close();
7940 } 8001 }
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
8216 8277
8217 TEST_F(WebFrameTest, MaxFramesDetach) 8278 TEST_F(WebFrameTest, MaxFramesDetach)
8218 { 8279 {
8219 registerMockedHttpURLLoad("max-frames-detach.html"); 8280 registerMockedHttpURLLoad("max-frames-detach.html");
8220 FrameTestHelpers::WebViewHelper webViewHelper; 8281 FrameTestHelpers::WebViewHelper webViewHelper;
8221 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); 8282 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true);
8222 webViewImpl->mainFrameImpl()->collectGarbage(); 8283 webViewImpl->mainFrameImpl()->collectGarbage();
8223 } 8284 }
8224 8285
8225 } // namespace blink 8286 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698