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

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: Address comments from Daniel 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 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 1600
1601 ASSERT_NE(nullptr, element); 1601 ASSERT_NE(nullptr, element);
1602 EXPECT_EQ(String("oldValue"), element->innerText()); 1602 EXPECT_EQ(String("oldValue"), element->innerText());
1603 1603
1604 PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPoint, hitPoint, IntSize(0, 0), 0, PlatformEvent::NoModifiers); 1604 PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPoint, hitPoint, IntSize(0, 0), 0, PlatformEvent::NoModifiers);
1605 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handle GestureEvent(gestureEvent); 1605 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handle GestureEvent(gestureEvent);
1606 // when pressed, the button changes its own text to "updatedValue" 1606 // when pressed, the button changes its own text to "updatedValue"
1607 EXPECT_EQ(String("updatedValue"), element->innerText()); 1607 EXPECT_EQ(String("updatedValue"), element->innerText());
1608 } 1608 }
1609 1609
1610 TEST_F(WebFrameTest, FrameOwnerPropertiesMargin)
1611 {
1612 FrameTestHelpers::TestWebViewClient viewClient;
1613 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1614 WebView* view = WebView::create(&viewClient);
1615 view->settings()->setJavaScriptEnabled(true);
1616 view->setMainFrame(remoteClient.frame());
1617 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1618 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1619
1620 WebFrameOwnerProperties properties;
1621 properties.marginWidth = 11;
1622 properties.marginHeight = 22;
1623 FrameTestHelpers::TestWebFrameClient localFrameClient;
1624 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);
1625
1626 registerMockedHttpURLLoad("frame_owner_properties.html");
1627 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1628
1629 {
1630 // Check if the LocalFrame has seen the marginwidth and marginheight
1631 // properties.
1632 v8::HandleScope handleScope(v8::Isolate::GetCurrent());
1633
1634 v8::Local<v8::Value> marginWidthResult = localFrame->executeScriptAndRet urnValue(WebScriptSource("bodyMarginWidth"));
dcheng 2015/10/14 07:20:43 document.body.marginwidth directly here? Similar c
lazyboy 2015/10/14 20:05:29 Done. I need document.body.getAttribute('marginwid
1635 ASSERT_TRUE(marginWidthResult->IsString());
1636 v8::String::Utf8Value widthUtf8(marginWidthResult);
1637 EXPECT_EQ("11", std::string(*widthUtf8, widthUtf8.length()));
dcheng 2015/10/14 07:20:43 I think it might be easier to verify the result wi
lazyboy 2015/10/14 20:05:29 Done. Using parseInt() to force int.
1638
1639 v8::Local<v8::Value> marginHeightResult = localFrame->executeScriptAndRe turnValue(WebScriptSource("bodyMarginHeight"));
1640 ASSERT_TRUE(marginHeightResult->IsString());
1641 v8::String::Utf8Value heightUtf8(marginHeightResult);
1642 EXPECT_EQ("22", std::string(*heightUtf8, heightUtf8.length()));
1643 }
1644
1645 FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView();
1646 // Expect scrollbars to be enabled by default.
1647 EXPECT_NE(nullptr, frameView->horizontalScrollbar());
1648 EXPECT_NE(nullptr, frameView->verticalScrollbar());
1649
1650 view->close();
1651 }
1652
1653 TEST_F(WebFrameTest, FrameOwnerPropertiesScrolling)
1654 {
1655 FrameTestHelpers::TestWebViewClient viewClient;
1656 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1657 WebView* view = WebView::create(&viewClient);
1658 view->settings()->setJavaScriptEnabled(true);
1659 view->setMainFrame(remoteClient.frame());
1660 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1661 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1662
1663 WebFrameOwnerProperties properties;
1664 // Turn off scrolling in the subframe.
1665 properties.scrollingMode = WebFrameOwnerProperties::ScrollingMode::AlwaysOff ;
1666 FrameTestHelpers::TestWebFrameClient localFrameClient;
1667 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);
1668
1669 registerMockedHttpURLLoad("frame_owner_properties.html");
1670 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1671
1672 {
1673 v8::HandleScope handleScope(v8::Isolate::GetCurrent());
1674
1675 v8::Local<v8::Value> marginWidthResult = localFrame->executeScriptAndRet urnValue(WebScriptSource("bodyMarginWidth"));
1676 ASSERT_TRUE(marginWidthResult->IsString());
1677 v8::String::Utf8Value widthUtf8(marginWidthResult);
1678 EXPECT_EQ("0", std::string(*widthUtf8, widthUtf8.length()));
1679
1680 v8::Local<v8::Value> marginHeightResult = localFrame->executeScriptAndRe turnValue(WebScriptSource("bodyMarginHeight"));
1681 ASSERT_TRUE(marginHeightResult->IsString());
1682 v8::String::Utf8Value heightUtf8(marginHeightResult);
1683 EXPECT_EQ("0", std::string(*heightUtf8, heightUtf8.length()));
1684 }
1685
1686 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w();
1687 EXPECT_EQ(nullptr, frameView->horizontalScrollbar());
1688 EXPECT_EQ(nullptr, frameView->verticalScrollbar());
1689
1690 view->close();
1691 }
1692
1693
1610 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations ) 1694 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations )
1611 { 1695 {
1612 UseMockScrollbarSettings mockScrollbarSettings; 1696 UseMockScrollbarSettings mockScrollbarSettings;
1613 registerMockedHttpURLLoad("200-by-300.html"); 1697 registerMockedHttpURLLoad("200-by-300.html");
1614 registerMockedHttpURLLoad("large-div.html"); 1698 registerMockedHttpURLLoad("large-div.html");
1615 1699
1616 FixedLayoutTestWebViewClient client; 1700 FixedLayoutTestWebViewClient client;
1617 client.m_screenInfo.deviceScaleFactor = 1; 1701 client.m_screenInfo.deviceScaleFactor = 1;
1618 int viewportWidth = 640; 1702 int viewportWidth = 640;
1619 int viewportHeight = 480; 1703 int viewportHeight = 480;
(...skipping 4301 matching lines...) Expand 10 before | Expand all | Expand 10 after
5921 , m_willSendRequestCallCount(0) 6005 , m_willSendRequestCallCount(0)
5922 , m_childFrameCreationCount(0) 6006 , m_childFrameCreationCount(0)
5923 { 6007 {
5924 } 6008 }
5925 6009
5926 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; } 6010 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; }
5927 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } 6011 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; }
5928 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } 6012 int willSendRequestCallCount() const { return m_willSendRequestCallCount; }
5929 int childFrameCreationCount() const { return m_childFrameCreationCount; } 6013 int childFrameCreationCount() const { return m_childFrameCreationCount; }
5930 6014
5931 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, WebSandboxFlags) 6015 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, WebSandboxFlags, const WebFrameOwnerProperties& frameOwn erProperties)
5932 { 6016 {
5933 ASSERT(m_childClient); 6017 ASSERT(m_childClient);
5934 m_childFrameCreationCount++; 6018 m_childFrameCreationCount++;
5935 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); 6019 WebFrame* frame = WebLocalFrame::create(scope, m_childClient);
5936 parent->appendChild(frame); 6020 parent->appendChild(frame);
5937 return frame; 6021 return frame;
5938 } 6022 }
5939 6023
5940 virtual void didStartLoading(bool toDifferentDocument) 6024 virtual void didStartLoading(bool toDifferentDocument)
5941 { 6025 {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
6310 // After commit, there is. 6394 // After commit, there is.
6311 HistoryItem* item = mainFrameLoader.currentItem(); 6395 HistoryItem* item = mainFrameLoader.currentItem();
6312 ASSERT_TRUE(item); 6396 ASSERT_TRUE(item);
6313 EXPECT_EQ(WTF::String(url.data()), item->urlString()); 6397 EXPECT_EQ(WTF::String(url.data()), item->urlString());
6314 } 6398 }
6315 6399
6316 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { 6400 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient {
6317 public: 6401 public:
6318 FailCreateChildFrame() : m_callCount(0) { } 6402 FailCreateChildFrame() : m_callCount(0) { }
6319 6403
6320 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, WebSandboxFlags sandboxFlags) override 6404 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, WebSandboxFlags sandboxFlags, const WebFrameOwnerPrope rties& frameOwnerProperties) override
6321 { 6405 {
6322 ++m_callCount; 6406 ++m_callCount;
6323 return 0; 6407 return 0;
6324 } 6408 }
6325 6409
6326 int callCount() const { return m_callCount; } 6410 int callCount() const { return m_callCount; }
6327 6411
6328 private: 6412 private:
6329 int m_callCount; 6413 int m_callCount;
6330 }; 6414 };
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
6972 // doesn't leave behind dangling pointers. 7056 // doesn't leave behind dangling pointers.
6973 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame) 7057 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame)
6974 { 7058 {
6975 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o 7059 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o
6976 // write tests with a top-level remote frame. 7060 // write tests with a top-level remote frame.
6977 FrameTestHelpers::TestWebViewClient viewClient; 7061 FrameTestHelpers::TestWebViewClient viewClient;
6978 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7062 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
6979 WebView* view = WebView::create(&viewClient); 7063 WebView* view = WebView::create(&viewClient);
6980 view->setMainFrame(remoteClient.frame()); 7064 view->setMainFrame(remoteClient.frame());
6981 FrameTestHelpers::TestWebFrameClient childFrameClient; 7065 FrameTestHelpers::TestWebFrameClient childFrameClient;
6982 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 7066 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
6983 7067
6984 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d. 7068 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d.
6985 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame); 7069 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame);
6986 view->close(); 7070 view->close();
6987 childCoreFrame.clear(); 7071 childCoreFrame.clear();
6988 } 7072 }
6989 7073
6990 class WebFrameSwapTest : public WebFrameTest { 7074 class WebFrameSwapTest : public WebFrameTest {
6991 protected: 7075 protected:
6992 WebFrameSwapTest() 7076 WebFrameSwapTest()
(...skipping 14 matching lines...) Expand all
7007 FrameTestHelpers::WebViewHelper m_webViewHelper; 7091 FrameTestHelpers::WebViewHelper m_webViewHelper;
7008 }; 7092 };
7009 7093
7010 TEST_F(WebFrameSwapTest, SwapMainFrame) 7094 TEST_F(WebFrameSwapTest, SwapMainFrame)
7011 { 7095 {
7012 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr); 7096 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr);
7013 mainFrame()->swap(remoteFrame); 7097 mainFrame()->swap(remoteFrame);
7014 7098
7015 FrameTestHelpers::TestWebFrameClient client; 7099 FrameTestHelpers::TestWebFrameClient client;
7016 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7100 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7017 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7101 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7018 remoteFrame->swap(localFrame); 7102 remoteFrame->swap(localFrame);
7019 7103
7020 // Finally, make sure an embedder triggered load in the local frame swapped 7104 // Finally, make sure an embedder triggered load in the local frame swapped
7021 // back in works. 7105 // back in works.
7022 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7106 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7023 std::string content = localFrame->contentAsText(1024).utf8(); 7107 std::string content = localFrame->contentAsText(1024).utf8();
7024 EXPECT_EQ("hello", content); 7108 EXPECT_EQ("hello", content);
7025 7109
7026 // Manually reset to break WebViewHelper's dependency on the stack allocated 7110 // Manually reset to break WebViewHelper's dependency on the stack allocated
7027 // TestWebFrameClient. 7111 // TestWebFrameClient.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
7071 } 7155 }
7072 7156
7073 TEST_F(WebFrameSwapTest, SwapFirstChild) 7157 TEST_F(WebFrameSwapTest, SwapFirstChild)
7074 { 7158 {
7075 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7159 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7076 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7160 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7077 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame ); 7161 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame );
7078 7162
7079 FrameTestHelpers::TestWebFrameClient client; 7163 FrameTestHelpers::TestWebFrameClient client;
7080 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7164 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7081 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7165 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7082 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ; 7166 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ;
7083 7167
7084 // FIXME: This almost certainly fires more load events on the iframe element 7168 // FIXME: This almost certainly fires more load events on the iframe element
7085 // than it should. 7169 // than it should.
7086 // Finally, make sure an embedder triggered load in the local frame swapped 7170 // Finally, make sure an embedder triggered load in the local frame swapped
7087 // back in works. 7171 // back in works.
7088 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7172 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7089 std::string content = localFrame->contentAsText(1024).utf8(); 7173 std::string content = localFrame->contentAsText(1024).utf8();
7090 EXPECT_EQ("hello", content); 7174 EXPECT_EQ("hello", content);
7091 7175
(...skipping 18 matching lines...) Expand all
7110 } 7194 }
7111 7195
7112 TEST_F(WebFrameSwapTest, SwapMiddleChild) 7196 TEST_F(WebFrameSwapTest, SwapMiddleChild)
7113 { 7197 {
7114 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7198 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7115 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7199 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7116 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e); 7200 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e);
7117 7201
7118 FrameTestHelpers::TestWebFrameClient client; 7202 FrameTestHelpers::TestWebFrameClient client;
7119 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7203 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7120 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7204 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7121 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame ); 7205 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame );
7122 7206
7123 // FIXME: This almost certainly fires more load events on the iframe element 7207 // FIXME: This almost certainly fires more load events on the iframe element
7124 // than it should. 7208 // than it should.
7125 // Finally, make sure an embedder triggered load in the local frame swapped 7209 // Finally, make sure an embedder triggered load in the local frame swapped
7126 // back in works. 7210 // back in works.
7127 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7211 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7128 std::string content = localFrame->contentAsText(1024).utf8(); 7212 std::string content = localFrame->contentAsText(1024).utf8();
7129 EXPECT_EQ("hello", content); 7213 EXPECT_EQ("hello", content);
7130 7214
(...skipping 15 matching lines...) Expand all
7146 } 7230 }
7147 7231
7148 TEST_F(WebFrameSwapTest, SwapLastChild) 7232 TEST_F(WebFrameSwapTest, SwapLastChild)
7149 { 7233 {
7150 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7234 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7151 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7235 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7152 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ; 7236 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ;
7153 7237
7154 FrameTestHelpers::TestWebFrameClient client; 7238 FrameTestHelpers::TestWebFrameClient client;
7155 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7239 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7156 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7240 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7157 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); 7241 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame);
7158 7242
7159 // FIXME: This almost certainly fires more load events on the iframe element 7243 // FIXME: This almost certainly fires more load events on the iframe element
7160 // than it should. 7244 // than it should.
7161 // Finally, make sure an embedder triggered load in the local frame swapped 7245 // Finally, make sure an embedder triggered load in the local frame swapped
7162 // back in works. 7246 // back in works.
7163 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7247 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7164 std::string content = localFrame->contentAsText(1024).utf8(); 7248 std::string content = localFrame->contentAsText(1024).utf8();
7165 EXPECT_EQ("hello", content); 7249 EXPECT_EQ("hello", content);
7166 7250
(...skipping 24 matching lines...) Expand all
7191 7275
7192 targetFrame = mainFrame()->firstChild()->nextSibling(); 7276 targetFrame = mainFrame()->firstChild()->nextSibling();
7193 EXPECT_TRUE(targetFrame); 7277 EXPECT_TRUE(targetFrame);
7194 7278
7195 // Create child frames in the target frame before testing the swap. 7279 // Create child frames in the target frame before testing the swap.
7196 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; 7280 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2;
7197 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2); 7281 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2);
7198 7282
7199 FrameTestHelpers::TestWebFrameClient client; 7283 FrameTestHelpers::TestWebFrameClient client;
7200 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7284 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7201 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7285 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7202 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); 7286 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame);
7203 7287
7204 // FIXME: This almost certainly fires more load events on the iframe element 7288 // FIXME: This almost certainly fires more load events on the iframe element
7205 // than it should. 7289 // than it should.
7206 // Finally, make sure an embedder triggered load in the local frame swapped 7290 // Finally, make sure an embedder triggered load in the local frame swapped
7207 // back in works. 7291 // back in works.
7208 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7292 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7209 std::string content = localFrame->contentAsText(1024).utf8(); 7293 std::string content = localFrame->contentAsText(1024).utf8();
7210 EXPECT_EQ("hello", content); 7294 EXPECT_EQ("hello", content);
7211 7295
(...skipping 23 matching lines...) Expand all
7235 "document.querySelector('#frame2').contentWindow;")); 7319 "document.querySelector('#frame2').contentWindow;"));
7236 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow)); 7320 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow));
7237 // Check that its view is consistent with the world. 7321 // Check that its view is consistent with the world.
7238 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource( 7322 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource(
7239 "document.querySelector('#frame2').contentWindow.top;")); 7323 "document.querySelector('#frame2').contentWindow.top;"));
7240 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); 7324 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop));
7241 7325
7242 // Now check that remote -> local works too, since it goes through a differe nt code path. 7326 // Now check that remote -> local works too, since it goes through a differe nt code path.
7243 FrameTestHelpers::TestWebFrameClient client; 7327 FrameTestHelpers::TestWebFrameClient client;
7244 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7328 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7245 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7329 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7246 remoteFrame->swap(localFrame); 7330 remoteFrame->swap(localFrame);
7247 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( WebScriptSource( 7331 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( WebScriptSource(
7248 "document.querySelector('#frame2').contentWindow;")); 7332 "document.querySelector('#frame2').contentWindow;"));
7249 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); 7333 EXPECT_TRUE(originalWindow->StrictEquals(localWindow));
7250 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource( 7334 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource(
7251 "document.querySelector('#frame2').contentWindow.top;")); 7335 "document.querySelector('#frame2').contentWindow.top;"));
7252 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); 7336 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop));
7253 7337
7254 // Manually reset to break WebViewHelper's dependency on the stack allocated 7338 // Manually reset to break WebViewHelper's dependency on the stack allocated
7255 // TestWebFrameClient. 7339 // TestWebFrameClient.
(...skipping 13 matching lines...) Expand all
7269 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7353 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7270 WebRemoteFrame* remoteFrame = remoteClient.frame(); 7354 WebRemoteFrame* remoteFrame = remoteClient.frame();
7271 mainFrame()->lastChild()->swap(remoteFrame); 7355 mainFrame()->lastChild()->swap(remoteFrame);
7272 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7356 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7273 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource("saved.top")); 7357 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource("saved.top"));
7274 EXPECT_TRUE(remoteWindowTop->IsObject()); 7358 EXPECT_TRUE(remoteWindowTop->IsObject());
7275 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); 7359 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop));
7276 7360
7277 FrameTestHelpers::TestWebFrameClient client; 7361 FrameTestHelpers::TestWebFrameClient client;
7278 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7362 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7279 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7363 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7280 remoteFrame->swap(localFrame); 7364 remoteFrame->swap(localFrame);
7281 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource("saved.top")); 7365 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource("saved.top"));
7282 EXPECT_TRUE(localWindowTop->IsObject()); 7366 EXPECT_TRUE(localWindowTop->IsObject());
7283 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); 7367 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop));
7284 7368
7285 reset(); 7369 reset();
7286 } 7370 }
7287 7371
7288 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) 7372 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable)
7289 { 7373 {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
7340 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable) 7424 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable)
7341 { 7425 {
7342 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7426 v8::HandleScope scope(v8::Isolate::GetCurrent());
7343 7427
7344 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7428 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7345 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); 7429 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7346 mainFrame()->swap(remoteParentFrame); 7430 mainFrame()->swap(remoteParentFrame);
7347 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7431 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7348 7432
7349 FrameTestHelpers::TestWebFrameClient childFrameClient; 7433 FrameTestHelpers::TestWebFrameClient childFrameClient;
7350 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); 7434 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties());
7351 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); 7435 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7352 7436
7353 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window")); 7437 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window"));
7354 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]")); 7438 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]"));
7355 EXPECT_TRUE(childOfRemoteParent->IsObject()); 7439 EXPECT_TRUE(childOfRemoteParent->IsObject());
7356 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); 7440 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent));
7357 7441
7358 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length")); 7442 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length"));
7359 ASSERT_TRUE(windowLength->IsInt32()); 7443 ASSERT_TRUE(windowLength->IsInt32());
7360 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); 7444 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value());
7361 7445
7362 // 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.
7363 reset(); 7447 reset();
7364 } 7448 }
7365 7449
7366 // Check that frames with a remote parent don't crash while accessing window.fra meElement. 7450 // Check that frames with a remote parent don't crash while accessing window.fra meElement.
7367 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) 7451 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent)
7368 { 7452 {
7369 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7453 v8::HandleScope scope(v8::Isolate::GetCurrent());
7370 7454
7371 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7455 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7372 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); 7456 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7373 mainFrame()->swap(remoteParentFrame); 7457 mainFrame()->swap(remoteParentFrame);
7374 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7458 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7375 7459
7376 FrameTestHelpers::TestWebFrameClient childFrameClient; 7460 FrameTestHelpers::TestWebFrameClient childFrameClient;
7377 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); 7461 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties());
7378 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); 7462 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7379 7463
7380 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement")); 7464 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement"));
7381 // frameElement shouldn't be accessible cross-origin. 7465 // frameElement shouldn't be accessible cross-origin.
7382 EXPECT_TRUE(frameElement.IsEmpty()); 7466 EXPECT_TRUE(frameElement.IsEmpty());
7383 7467
7384 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. 7468 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7385 reset(); 7469 reset();
7386 } 7470 }
7387 7471
(...skipping 26 matching lines...) Expand all
7414 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7498 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7415 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7499 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7416 WebFrame* targetFrame = mainFrame()->firstChild(); 7500 WebFrame* targetFrame = mainFrame()->firstChild();
7417 ASSERT_TRUE(targetFrame); 7501 ASSERT_TRUE(targetFrame);
7418 targetFrame->swap(remoteFrame); 7502 targetFrame->swap(remoteFrame);
7419 ASSERT_TRUE(mainFrame()->firstChild()); 7503 ASSERT_TRUE(mainFrame()->firstChild());
7420 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 7504 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
7421 7505
7422 RemoteToLocalSwapWebFrameClient client(remoteFrame); 7506 RemoteToLocalSwapWebFrameClient client(remoteFrame);
7423 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7507 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7424 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7508 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7425 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7509 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7426 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); 7510 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType());
7427 7511
7428 // Manually reset to break WebViewHelper's dependency on the stack allocated 7512 // Manually reset to break WebViewHelper's dependency on the stack allocated
7429 // TestWebFrameClient. 7513 // TestWebFrameClient.
7430 reset(); 7514 reset();
7431 remoteFrame->close(); 7515 remoteFrame->close();
7432 } 7516 }
7433 7517
7434 // The commit type should be Standard if we are swapping a RemoteFrame to a 7518 // The commit type should be Standard if we are swapping a RemoteFrame to a
7435 // LocalFrame after commits have already happened in the frame. The browser 7519 // LocalFrame after commits have already happened in the frame. The browser
7436 // process will inform us via setCommittedFirstRealLoad. 7520 // process will inform us via setCommittedFirstRealLoad.
7437 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) 7521 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap)
7438 { 7522 {
7439 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7523 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7440 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7524 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7441 WebFrame* targetFrame = mainFrame()->firstChild(); 7525 WebFrame* targetFrame = mainFrame()->firstChild();
7442 ASSERT_TRUE(targetFrame); 7526 ASSERT_TRUE(targetFrame);
7443 targetFrame->swap(remoteFrame); 7527 targetFrame->swap(remoteFrame);
7444 ASSERT_TRUE(mainFrame()->firstChild()); 7528 ASSERT_TRUE(mainFrame()->firstChild());
7445 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 7529 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
7446 7530
7447 RemoteToLocalSwapWebFrameClient client(remoteFrame); 7531 RemoteToLocalSwapWebFrameClient client(remoteFrame);
7448 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7532 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7449 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7533 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7450 localFrame->setCommittedFirstRealLoad(); 7534 localFrame->setCommittedFirstRealLoad();
7451 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7535 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7452 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); 7536 EXPECT_EQ(WebStandardCommit, client.historyCommitType());
7453 7537
7454 // Manually reset to break WebViewHelper's dependency on the stack allocated 7538 // Manually reset to break WebViewHelper's dependency on the stack allocated
7455 // TestWebFrameClient. 7539 // TestWebFrameClient.
7456 reset(); 7540 reset();
7457 remoteFrame->close(); 7541 remoteFrame->close();
7458 } 7542 }
7459 7543
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
7577 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient; 7661 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient;
7578 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame(); 7662 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame();
7579 popupView->setMainFrame(popupRemoteFrame); 7663 popupView->setMainFrame(popupRemoteFrame);
7580 popupRemoteFrame->setOpener(mainFrame); 7664 popupRemoteFrame->setOpener(mainFrame);
7581 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h ttp://foo.com")); 7665 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h ttp://foo.com"));
7582 EXPECT_FALSE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->s ecurityOrigin())); 7666 EXPECT_FALSE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->s ecurityOrigin()));
7583 7667
7584 // Do a remote-to-local swap in the popup. 7668 // Do a remote-to-local swap in the popup.
7585 FrameTestHelpers::TestWebFrameClient popupLocalClient; 7669 FrameTestHelpers::TestWebFrameClient popupLocalClient;
7586 WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Doc ument, &popupLocalClient); 7670 WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Doc ument, &popupLocalClient);
7587 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan dboxFlags::None); 7671 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan dboxFlags::None, WebFrameOwnerProperties());
7588 popupRemoteFrame->swap(popupLocalFrame); 7672 popupRemoteFrame->swap(popupLocalFrame);
7589 7673
7590 // The initial document created during the remote-to-local swap should have 7674 // The initial document created during the remote-to-local swap should have
7591 // inherited its opener's SecurityOrigin. 7675 // inherited its opener's SecurityOrigin.
7592 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se curityOrigin())); 7676 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se curityOrigin()));
7593 7677
7594 popupView->close(); 7678 popupView->close();
7595 } 7679 }
7596 7680
7597 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 7681 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
(...skipping 17 matching lines...) Expand all
7615 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) 7699 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType)
7616 { 7700 {
7617 FrameTestHelpers::TestWebViewClient viewClient; 7701 FrameTestHelpers::TestWebViewClient viewClient;
7618 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7702 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7619 WebView* view = WebView::create(&viewClient); 7703 WebView* view = WebView::create(&viewClient);
7620 view->setMainFrame(remoteClient.frame()); 7704 view->setMainFrame(remoteClient.frame());
7621 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica tedOrigin(SecurityOrigin::create(toKURL(m_baseURL))); 7705 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica tedOrigin(SecurityOrigin::create(toKURL(m_baseURL)));
7622 7706
7623 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame. 7707 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame.
7624 CommitTypeWebFrameClient childFrameClient; 7708 CommitTypeWebFrameClient childFrameClient;
7625 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 7709 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
7626 registerMockedHttpURLLoad("foo.html"); 7710 registerMockedHttpURLLoad("foo.html");
7627 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); 7711 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html");
7628 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() ); 7712 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() );
7629 view->close(); 7713 view->close();
7630 } 7714 }
7631 7715
7632 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient { 7716 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient {
7633 public: 7717 public:
7634 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { } 7718 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { }
7635 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; } 7719 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; }
7636 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; } 7720 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; }
7637 7721
7638 private: 7722 private:
7639 bool m_didHandleGestureEvent; 7723 bool m_didHandleGestureEvent;
7640 }; 7724 };
7641 7725
7642 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) 7726 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest)
7643 { 7727 {
7644 FrameTestHelpers::TestWebViewClient viewClient; 7728 FrameTestHelpers::TestWebViewClient viewClient;
7645 WebView* view = WebView::create(&viewClient); 7729 WebView* view = WebView::create(&viewClient);
7646 7730
7647 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7731 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7648 view->setMainFrame(remoteClient.frame()); 7732 view->setMainFrame(remoteClient.frame());
7649 7733
7650 FrameTestHelpers::TestWebFrameClient childFrameClient; 7734 FrameTestHelpers::TestWebFrameClient childFrameClient;
7651 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 7735 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
7652 7736
7653 GestureEventTestWebViewClient childViewClient; 7737 GestureEventTestWebViewClient childViewClient;
7654 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame ); 7738 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame );
7655 7739
7656 view->resize(WebSize(1000, 1000)); 7740 view->resize(WebSize(1000, 1000));
7657 view->layout(); 7741 view->layout();
7658 7742
7659 widget->handleInputEvent(fatTap(20, 20)); 7743 widget->handleInputEvent(fatTap(20, 20));
7660 EXPECT_TRUE(childViewClient.didHandleGestureEvent()); 7744 EXPECT_TRUE(childViewClient.didHandleGestureEvent());
7661 7745
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
7861 7945
7862 7946
7863 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling) 7947 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling)
7864 { 7948 {
7865 FrameTestHelpers::TestWebViewClient viewClient; 7949 FrameTestHelpers::TestWebViewClient viewClient;
7866 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7950 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7867 WebView* view = WebView::create(&viewClient); 7951 WebView* view = WebView::create(&viewClient);
7868 view->setMainFrame(remoteClient.frame()); 7952 view->setMainFrame(remoteClient.frame());
7869 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame(); 7953 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame();
7870 7954
7871 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, nullptr); 7955 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties() );
7872 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, secondFrame); 7956 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerProperti es());
7873 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, secondFrame); 7957 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerPropertie s());
7874 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, nullptr); 7958 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties()) ;
7875 7959
7876 EXPECT_EQ(firstFrame, parent->firstChild()); 7960 EXPECT_EQ(firstFrame, parent->firstChild());
7877 EXPECT_EQ(nullptr, firstFrame->previousSibling()); 7961 EXPECT_EQ(nullptr, firstFrame->previousSibling());
7878 EXPECT_EQ(secondFrame, firstFrame->nextSibling()); 7962 EXPECT_EQ(secondFrame, firstFrame->nextSibling());
7879 7963
7880 EXPECT_EQ(firstFrame, secondFrame->previousSibling()); 7964 EXPECT_EQ(firstFrame, secondFrame->previousSibling());
7881 EXPECT_EQ(thirdFrame, secondFrame->nextSibling()); 7965 EXPECT_EQ(thirdFrame, secondFrame->nextSibling());
7882 7966
7883 EXPECT_EQ(secondFrame, thirdFrame->previousSibling()); 7967 EXPECT_EQ(secondFrame, thirdFrame->previousSibling());
7884 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling()); 7968 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling());
(...skipping 14 matching lines...) Expand all
7899 { 7983 {
7900 FrameTestHelpers::TestWebViewClient viewClient; 7984 FrameTestHelpers::TestWebViewClient viewClient;
7901 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7985 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7902 WebView* view = WebView::create(&viewClient); 7986 WebView* view = WebView::create(&viewClient);
7903 view->settings()->setJavaScriptEnabled(true); 7987 view->settings()->setJavaScriptEnabled(true);
7904 view->setMainFrame(remoteClient.frame()); 7988 view->setMainFrame(remoteClient.frame());
7905 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); 7989 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
7906 root->setReplicatedOrigin(SecurityOrigin::createUnique()); 7990 root->setReplicatedOrigin(SecurityOrigin::createUnique());
7907 7991
7908 FrameTestHelpers::TestWebFrameClient localFrameClient; 7992 FrameTestHelpers::TestWebFrameClient localFrameClient;
7909 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr); 7993 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, WebFrameOwnerPropertie s());
7910 7994
7911 // Finally, make sure an embedder triggered load in the local frame swapped 7995 // Finally, make sure an embedder triggered load in the local frame swapped
7912 // back in works. 7996 // back in works.
7913 registerMockedHttpURLLoad("send_beacon.html"); 7997 registerMockedHttpURLLoad("send_beacon.html");
7914 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon() 7998 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon()
7915 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html"); 7999 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html");
7916 8000
7917 view->close(); 8001 view->close();
7918 } 8002 }
7919 8003
7920 // See https://crbug.com/525285. 8004 // See https://crbug.com/525285.
7921 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me) 8005 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me)
7922 { 8006 {
7923 FrameTestHelpers::TestWebViewClient viewClient; 8007 FrameTestHelpers::TestWebViewClient viewClient;
7924 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 8008 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7925 WebView* view = WebView::create(&viewClient); 8009 WebView* view = WebView::create(&viewClient);
7926 view->setMainFrame(remoteClient.frame()); 8010 view->setMainFrame(remoteClient.frame());
7927 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); 8011 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame();
7928 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); 8012 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique());
7929 8013
7930 FrameTestHelpers::TestWebFrameClient localFrameClient; 8014 FrameTestHelpers::TestWebFrameClient localFrameClient;
7931 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr); 8015 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr, WebFrameOwnerProperties());
7932 8016
7933 // Do a remote-to-local swap of the top frame. 8017 // Do a remote-to-local swap of the top frame.
7934 FrameTestHelpers::TestWebFrameClient localClient; 8018 FrameTestHelpers::TestWebFrameClient localClient;
7935 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient); 8019 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient);
7936 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N one); 8020 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N one, WebFrameOwnerProperties());
7937 remoteRoot->swap(localRoot); 8021 remoteRoot->swap(localRoot);
7938 8022
7939 // Load a page with a child frame in the new root to make sure this doesn't 8023 // Load a page with a child frame in the new root to make sure this doesn't
7940 // crash when the child frame invokes setCoreFrame. 8024 // crash when the child frame invokes setCoreFrame.
7941 registerMockedHttpURLLoad("single_iframe.html"); 8025 registerMockedHttpURLLoad("single_iframe.html");
7942 registerMockedHttpURLLoad("visible_iframe.html"); 8026 registerMockedHttpURLLoad("visible_iframe.html");
7943 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); 8027 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html");
7944 8028
7945 view->close(); 8029 view->close();
7946 } 8030 }
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
8250 EXPECT_TRUE(resource); 8334 EXPECT_TRUE(resource);
8251 EXPECT_NE(0, resource->loadFinishTime()); 8335 EXPECT_NE(0, resource->loadFinishTime());
8252 8336
8253 DocumentLoader* loader = document->loader(); 8337 DocumentLoader* loader = document->loader();
8254 8338
8255 EXPECT_TRUE(loader); 8339 EXPECT_TRUE(loader);
8256 EXPECT_EQ(loader->timing().responseEnd(), resource->loadFinishTime()); 8340 EXPECT_EQ(loader->timing().responseEnd(), resource->loadFinishTime());
8257 } 8341 }
8258 8342
8259 } // namespace blink 8343 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698