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

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: content_unittests compile fix Created 5 years, 1 month 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "core/events/MouseEvent.h" 51 #include "core/events/MouseEvent.h"
52 #include "core/fetch/FetchRequest.h" 52 #include "core/fetch/FetchRequest.h"
53 #include "core/fetch/MemoryCache.h" 53 #include "core/fetch/MemoryCache.h"
54 #include "core/fetch/ResourceFetcher.h" 54 #include "core/fetch/ResourceFetcher.h"
55 #include "core/frame/FrameHost.h" 55 #include "core/frame/FrameHost.h"
56 #include "core/frame/FrameView.h" 56 #include "core/frame/FrameView.h"
57 #include "core/frame/LocalFrame.h" 57 #include "core/frame/LocalFrame.h"
58 #include "core/frame/RemoteFrame.h" 58 #include "core/frame/RemoteFrame.h"
59 #include "core/frame/Settings.h" 59 #include "core/frame/Settings.h"
60 #include "core/frame/VisualViewport.h" 60 #include "core/frame/VisualViewport.h"
61 #include "core/html/HTMLBodyElement.h"
61 #include "core/html/HTMLDocument.h" 62 #include "core/html/HTMLDocument.h"
62 #include "core/html/HTMLFormElement.h" 63 #include "core/html/HTMLFormElement.h"
63 #include "core/html/HTMLMediaElement.h" 64 #include "core/html/HTMLMediaElement.h"
64 #include "core/html/ImageDocument.h" 65 #include "core/html/ImageDocument.h"
65 #include "core/input/EventHandler.h" 66 #include "core/input/EventHandler.h"
66 #include "core/layout/HitTestResult.h" 67 #include "core/layout/HitTestResult.h"
67 #include "core/layout/LayoutFullScreen.h" 68 #include "core/layout/LayoutFullScreen.h"
68 #include "core/layout/LayoutView.h" 69 #include "core/layout/LayoutView.h"
69 #include "core/layout/compositing/PaintLayerCompositor.h" 70 #include "core/layout/compositing/PaintLayerCompositor.h"
70 #include "core/loader/DocumentLoader.h" 71 #include "core/loader/DocumentLoader.h"
(...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 1570
1570 ASSERT_NE(nullptr, element); 1571 ASSERT_NE(nullptr, element);
1571 EXPECT_EQ(String("oldValue"), element->innerText()); 1572 EXPECT_EQ(String("oldValue"), element->innerText());
1572 1573
1573 PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPoint, hitPoint, IntSize(0, 0), 0, PlatformEvent::NoModifiers, PlatformGestureSourceTo uchscreen); 1574 PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPoint, hitPoint, IntSize(0, 0), 0, PlatformEvent::NoModifiers, PlatformGestureSourceTo uchscreen);
1574 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handle GestureEvent(gestureEvent); 1575 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handle GestureEvent(gestureEvent);
1575 // when pressed, the button changes its own text to "updatedValue" 1576 // when pressed, the button changes its own text to "updatedValue"
1576 EXPECT_EQ(String("updatedValue"), element->innerText()); 1577 EXPECT_EQ(String("updatedValue"), element->innerText());
1577 } 1578 }
1578 1579
1580 TEST_F(WebFrameTest, FrameOwnerPropertiesMargin)
1581 {
1582 FrameTestHelpers::TestWebViewClient viewClient;
1583 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1584 WebView* view = WebView::create(&viewClient);
1585 view->settings()->setJavaScriptEnabled(true);
1586 view->setMainFrame(remoteClient.frame());
1587 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1588 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1589
1590 WebFrameOwnerProperties properties;
1591 properties.marginWidth = 11;
1592 properties.marginHeight = 22;
1593 FrameTestHelpers::TestWebFrameClient localFrameClient;
1594 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);
1595
1596 registerMockedHttpURLLoad("frame_owner_properties.html");
1597 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1598
1599 // Check if the LocalFrame has seen the marginwidth and marginheight
1600 // properties.
1601 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document ();
1602 EXPECT_EQ(11, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginwidthAttr));
1603 EXPECT_EQ(22, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginheightAttr));
1604
1605 FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView();
1606 // Expect scrollbars to be enabled by default.
1607 EXPECT_NE(nullptr, frameView->horizontalScrollbar());
1608 EXPECT_NE(nullptr, frameView->verticalScrollbar());
1609
1610 view->close();
1611 }
1612
1613 TEST_F(WebFrameTest, FrameOwnerPropertiesScrolling)
1614 {
1615 FrameTestHelpers::TestWebViewClient viewClient;
1616 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1617 WebView* view = WebView::create(&viewClient);
1618 view->settings()->setJavaScriptEnabled(true);
1619 view->setMainFrame(remoteClient.frame());
1620 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1621 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1622
1623 WebFrameOwnerProperties properties;
1624 // Turn off scrolling in the subframe.
1625 properties.scrollingMode = WebFrameOwnerProperties::ScrollingMode::AlwaysOff ;
1626 FrameTestHelpers::TestWebFrameClient localFrameClient;
1627 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);
1628
1629 registerMockedHttpURLLoad("frame_owner_properties.html");
1630 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1631
1632 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document ();
1633 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginwidthAttr));
1634 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginheightAttr));
1635
1636 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w();
1637 EXPECT_EQ(nullptr, frameView->horizontalScrollbar());
1638 EXPECT_EQ(nullptr, frameView->verticalScrollbar());
1639
1640 view->close();
1641 }
1642
1643
1579 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations ) 1644 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations )
1580 { 1645 {
1581 registerMockedHttpURLLoad("200-by-300.html"); 1646 registerMockedHttpURLLoad("200-by-300.html");
1582 registerMockedHttpURLLoad("large-div.html"); 1647 registerMockedHttpURLLoad("large-div.html");
1583 1648
1584 FixedLayoutTestWebViewClient client; 1649 FixedLayoutTestWebViewClient client;
1585 client.m_screenInfo.deviceScaleFactor = 1; 1650 client.m_screenInfo.deviceScaleFactor = 1;
1586 int viewportWidth = 640; 1651 int viewportWidth = 640;
1587 int viewportHeight = 480; 1652 int viewportHeight = 480;
1588 1653
(...skipping 4273 matching lines...) Expand 10 before | Expand all | Expand 10 after
5862 , m_willSendRequestCallCount(0) 5927 , m_willSendRequestCallCount(0)
5863 , m_childFrameCreationCount(0) 5928 , m_childFrameCreationCount(0)
5864 { 5929 {
5865 } 5930 }
5866 5931
5867 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; } 5932 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; }
5868 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } 5933 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; }
5869 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } 5934 int willSendRequestCallCount() const { return m_willSendRequestCallCount; }
5870 int childFrameCreationCount() const { return m_childFrameCreationCount; } 5935 int childFrameCreationCount() const { return m_childFrameCreationCount; }
5871 5936
5872 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, WebSandboxFlags) 5937 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, WebSandboxFlags, const WebFrameOwnerProperties& frameOwn erProperties)
5873 { 5938 {
5874 ASSERT(m_childClient); 5939 ASSERT(m_childClient);
5875 m_childFrameCreationCount++; 5940 m_childFrameCreationCount++;
5876 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); 5941 WebFrame* frame = WebLocalFrame::create(scope, m_childClient);
5877 parent->appendChild(frame); 5942 parent->appendChild(frame);
5878 return frame; 5943 return frame;
5879 } 5944 }
5880 5945
5881 virtual void didStartLoading(bool toDifferentDocument) 5946 virtual void didStartLoading(bool toDifferentDocument)
5882 { 5947 {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
6251 // After commit, there is. 6316 // After commit, there is.
6252 HistoryItem* item = mainFrameLoader.currentItem(); 6317 HistoryItem* item = mainFrameLoader.currentItem();
6253 ASSERT_TRUE(item); 6318 ASSERT_TRUE(item);
6254 EXPECT_EQ(WTF::String(url.data()), item->urlString()); 6319 EXPECT_EQ(WTF::String(url.data()), item->urlString());
6255 } 6320 }
6256 6321
6257 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { 6322 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient {
6258 public: 6323 public:
6259 FailCreateChildFrame() : m_callCount(0) { } 6324 FailCreateChildFrame() : m_callCount(0) { }
6260 6325
6261 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, WebSandboxFlags sandboxFlags) override 6326 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, WebSandboxFlags sandboxFlags, const WebFrameOwnerPrope rties& frameOwnerProperties) override
6262 { 6327 {
6263 ++m_callCount; 6328 ++m_callCount;
6264 return 0; 6329 return 0;
6265 } 6330 }
6266 6331
6267 int callCount() const { return m_callCount; } 6332 int callCount() const { return m_callCount; }
6268 6333
6269 private: 6334 private:
6270 int m_callCount; 6335 int m_callCount;
6271 }; 6336 };
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
6910 // doesn't leave behind dangling pointers. 6975 // doesn't leave behind dangling pointers.
6911 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame) 6976 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame)
6912 { 6977 {
6913 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o 6978 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o
6914 // write tests with a top-level remote frame. 6979 // write tests with a top-level remote frame.
6915 FrameTestHelpers::TestWebViewClient viewClient; 6980 FrameTestHelpers::TestWebViewClient viewClient;
6916 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 6981 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
6917 WebView* view = WebView::create(&viewClient); 6982 WebView* view = WebView::create(&viewClient);
6918 view->setMainFrame(remoteClient.frame()); 6983 view->setMainFrame(remoteClient.frame());
6919 FrameTestHelpers::TestWebFrameClient childFrameClient; 6984 FrameTestHelpers::TestWebFrameClient childFrameClient;
6920 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 6985 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
6921 6986
6922 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d. 6987 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d.
6923 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame); 6988 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame);
6924 view->close(); 6989 view->close();
6925 childCoreFrame.clear(); 6990 childCoreFrame.clear();
6926 } 6991 }
6927 6992
6928 class WebFrameSwapTest : public WebFrameTest { 6993 class WebFrameSwapTest : public WebFrameTest {
6929 protected: 6994 protected:
6930 WebFrameSwapTest() 6995 WebFrameSwapTest()
(...skipping 14 matching lines...) Expand all
6945 FrameTestHelpers::WebViewHelper m_webViewHelper; 7010 FrameTestHelpers::WebViewHelper m_webViewHelper;
6946 }; 7011 };
6947 7012
6948 TEST_F(WebFrameSwapTest, SwapMainFrame) 7013 TEST_F(WebFrameSwapTest, SwapMainFrame)
6949 { 7014 {
6950 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr); 7015 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr);
6951 mainFrame()->swap(remoteFrame); 7016 mainFrame()->swap(remoteFrame);
6952 7017
6953 FrameTestHelpers::TestWebFrameClient client; 7018 FrameTestHelpers::TestWebFrameClient client;
6954 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7019 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
6955 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7020 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
6956 remoteFrame->swap(localFrame); 7021 remoteFrame->swap(localFrame);
6957 7022
6958 // Finally, make sure an embedder triggered load in the local frame swapped 7023 // Finally, make sure an embedder triggered load in the local frame swapped
6959 // back in works. 7024 // back in works.
6960 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7025 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
6961 std::string content = localFrame->contentAsText(1024).utf8(); 7026 std::string content = localFrame->contentAsText(1024).utf8();
6962 EXPECT_EQ("hello", content); 7027 EXPECT_EQ("hello", content);
6963 7028
6964 // Manually reset to break WebViewHelper's dependency on the stack allocated 7029 // Manually reset to break WebViewHelper's dependency on the stack allocated
6965 // TestWebFrameClient. 7030 // TestWebFrameClient.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
7021 } 7086 }
7022 7087
7023 TEST_F(WebFrameSwapTest, SwapFirstChild) 7088 TEST_F(WebFrameSwapTest, SwapFirstChild)
7024 { 7089 {
7025 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7090 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7026 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7091 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7027 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame ); 7092 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame );
7028 7093
7029 FrameTestHelpers::TestWebFrameClient client; 7094 FrameTestHelpers::TestWebFrameClient client;
7030 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7095 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7031 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7096 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7032 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ; 7097 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ;
7033 7098
7034 // FIXME: This almost certainly fires more load events on the iframe element 7099 // FIXME: This almost certainly fires more load events on the iframe element
7035 // than it should. 7100 // than it should.
7036 // Finally, make sure an embedder triggered load in the local frame swapped 7101 // Finally, make sure an embedder triggered load in the local frame swapped
7037 // back in works. 7102 // back in works.
7038 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7103 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7039 std::string content = localFrame->contentAsText(1024).utf8(); 7104 std::string content = localFrame->contentAsText(1024).utf8();
7040 EXPECT_EQ("hello", content); 7105 EXPECT_EQ("hello", content);
7041 7106
(...skipping 18 matching lines...) Expand all
7060 } 7125 }
7061 7126
7062 TEST_F(WebFrameSwapTest, SwapMiddleChild) 7127 TEST_F(WebFrameSwapTest, SwapMiddleChild)
7063 { 7128 {
7064 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7129 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7065 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7130 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7066 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e); 7131 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e);
7067 7132
7068 FrameTestHelpers::TestWebFrameClient client; 7133 FrameTestHelpers::TestWebFrameClient client;
7069 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7134 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7070 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7135 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7071 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame ); 7136 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame );
7072 7137
7073 // FIXME: This almost certainly fires more load events on the iframe element 7138 // FIXME: This almost certainly fires more load events on the iframe element
7074 // than it should. 7139 // than it should.
7075 // Finally, make sure an embedder triggered load in the local frame swapped 7140 // Finally, make sure an embedder triggered load in the local frame swapped
7076 // back in works. 7141 // back in works.
7077 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7142 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7078 std::string content = localFrame->contentAsText(1024).utf8(); 7143 std::string content = localFrame->contentAsText(1024).utf8();
7079 EXPECT_EQ("hello", content); 7144 EXPECT_EQ("hello", content);
7080 7145
(...skipping 15 matching lines...) Expand all
7096 } 7161 }
7097 7162
7098 TEST_F(WebFrameSwapTest, SwapLastChild) 7163 TEST_F(WebFrameSwapTest, SwapLastChild)
7099 { 7164 {
7100 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7165 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7101 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7166 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7102 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ; 7167 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ;
7103 7168
7104 FrameTestHelpers::TestWebFrameClient client; 7169 FrameTestHelpers::TestWebFrameClient client;
7105 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7170 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7106 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7171 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7107 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); 7172 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame);
7108 7173
7109 // FIXME: This almost certainly fires more load events on the iframe element 7174 // FIXME: This almost certainly fires more load events on the iframe element
7110 // than it should. 7175 // than it should.
7111 // Finally, make sure an embedder triggered load in the local frame swapped 7176 // Finally, make sure an embedder triggered load in the local frame swapped
7112 // back in works. 7177 // back in works.
7113 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7178 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7114 std::string content = localFrame->contentAsText(1024).utf8(); 7179 std::string content = localFrame->contentAsText(1024).utf8();
7115 EXPECT_EQ("hello", content); 7180 EXPECT_EQ("hello", content);
7116 7181
(...skipping 24 matching lines...) Expand all
7141 7206
7142 targetFrame = mainFrame()->firstChild()->nextSibling(); 7207 targetFrame = mainFrame()->firstChild()->nextSibling();
7143 EXPECT_TRUE(targetFrame); 7208 EXPECT_TRUE(targetFrame);
7144 7209
7145 // Create child frames in the target frame before testing the swap. 7210 // Create child frames in the target frame before testing the swap.
7146 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; 7211 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2;
7147 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2); 7212 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2);
7148 7213
7149 FrameTestHelpers::TestWebFrameClient client; 7214 FrameTestHelpers::TestWebFrameClient client;
7150 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7215 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7151 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7216 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7152 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); 7217 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame);
7153 7218
7154 // FIXME: This almost certainly fires more load events on the iframe element 7219 // FIXME: This almost certainly fires more load events on the iframe element
7155 // than it should. 7220 // than it should.
7156 // Finally, make sure an embedder triggered load in the local frame swapped 7221 // Finally, make sure an embedder triggered load in the local frame swapped
7157 // back in works. 7222 // back in works.
7158 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7223 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7159 std::string content = localFrame->contentAsText(1024).utf8(); 7224 std::string content = localFrame->contentAsText(1024).utf8();
7160 EXPECT_EQ("hello", content); 7225 EXPECT_EQ("hello", content);
7161 7226
(...skipping 23 matching lines...) Expand all
7185 "document.querySelector('#frame2').contentWindow;")); 7250 "document.querySelector('#frame2').contentWindow;"));
7186 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow)); 7251 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow));
7187 // Check that its view is consistent with the world. 7252 // Check that its view is consistent with the world.
7188 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource( 7253 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource(
7189 "document.querySelector('#frame2').contentWindow.top;")); 7254 "document.querySelector('#frame2').contentWindow.top;"));
7190 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); 7255 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop));
7191 7256
7192 // Now check that remote -> local works too, since it goes through a differe nt code path. 7257 // Now check that remote -> local works too, since it goes through a differe nt code path.
7193 FrameTestHelpers::TestWebFrameClient client; 7258 FrameTestHelpers::TestWebFrameClient client;
7194 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7259 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7195 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7260 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7196 remoteFrame->swap(localFrame); 7261 remoteFrame->swap(localFrame);
7197 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( WebScriptSource( 7262 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( WebScriptSource(
7198 "document.querySelector('#frame2').contentWindow;")); 7263 "document.querySelector('#frame2').contentWindow;"));
7199 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); 7264 EXPECT_TRUE(originalWindow->StrictEquals(localWindow));
7200 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource( 7265 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource(
7201 "document.querySelector('#frame2').contentWindow.top;")); 7266 "document.querySelector('#frame2').contentWindow.top;"));
7202 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); 7267 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop));
7203 7268
7204 // Manually reset to break WebViewHelper's dependency on the stack allocated 7269 // Manually reset to break WebViewHelper's dependency on the stack allocated
7205 // TestWebFrameClient. 7270 // TestWebFrameClient.
(...skipping 13 matching lines...) Expand all
7219 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7284 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7220 WebRemoteFrame* remoteFrame = remoteClient.frame(); 7285 WebRemoteFrame* remoteFrame = remoteClient.frame();
7221 mainFrame()->lastChild()->swap(remoteFrame); 7286 mainFrame()->lastChild()->swap(remoteFrame);
7222 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7287 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7223 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource("saved.top")); 7288 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource("saved.top"));
7224 EXPECT_TRUE(remoteWindowTop->IsObject()); 7289 EXPECT_TRUE(remoteWindowTop->IsObject());
7225 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); 7290 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop));
7226 7291
7227 FrameTestHelpers::TestWebFrameClient client; 7292 FrameTestHelpers::TestWebFrameClient client;
7228 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7293 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7229 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7294 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7230 remoteFrame->swap(localFrame); 7295 remoteFrame->swap(localFrame);
7231 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource("saved.top")); 7296 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource("saved.top"));
7232 EXPECT_TRUE(localWindowTop->IsObject()); 7297 EXPECT_TRUE(localWindowTop->IsObject());
7233 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); 7298 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop));
7234 7299
7235 reset(); 7300 reset();
7236 } 7301 }
7237 7302
7238 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) 7303 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable)
7239 { 7304 {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
7290 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable) 7355 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable)
7291 { 7356 {
7292 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7357 v8::HandleScope scope(v8::Isolate::GetCurrent());
7293 7358
7294 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7359 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7295 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); 7360 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7296 mainFrame()->swap(remoteParentFrame); 7361 mainFrame()->swap(remoteParentFrame);
7297 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7362 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7298 7363
7299 FrameTestHelpers::TestWebFrameClient childFrameClient; 7364 FrameTestHelpers::TestWebFrameClient childFrameClient;
7300 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); 7365 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties());
7301 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); 7366 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7302 7367
7303 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window")); 7368 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window"));
7304 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]")); 7369 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]"));
7305 EXPECT_TRUE(childOfRemoteParent->IsObject()); 7370 EXPECT_TRUE(childOfRemoteParent->IsObject());
7306 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); 7371 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent));
7307 7372
7308 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length")); 7373 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length"));
7309 ASSERT_TRUE(windowLength->IsInt32()); 7374 ASSERT_TRUE(windowLength->IsInt32());
7310 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); 7375 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value());
7311 7376
7312 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. 7377 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7313 reset(); 7378 reset();
7314 } 7379 }
7315 7380
7316 // Check that frames with a remote parent don't crash while accessing window.fra meElement. 7381 // Check that frames with a remote parent don't crash while accessing window.fra meElement.
7317 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) 7382 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent)
7318 { 7383 {
7319 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7384 v8::HandleScope scope(v8::Isolate::GetCurrent());
7320 7385
7321 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7386 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7322 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); 7387 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7323 mainFrame()->swap(remoteParentFrame); 7388 mainFrame()->swap(remoteParentFrame);
7324 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7389 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7325 7390
7326 FrameTestHelpers::TestWebFrameClient childFrameClient; 7391 FrameTestHelpers::TestWebFrameClient childFrameClient;
7327 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); 7392 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties());
7328 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); 7393 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7329 7394
7330 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement")); 7395 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement"));
7331 // frameElement should be null if cross-origin. 7396 // frameElement should be null if cross-origin.
7332 ASSERT_FALSE(frameElement.IsEmpty()); 7397 ASSERT_FALSE(frameElement.IsEmpty());
7333 EXPECT_TRUE(frameElement->IsNull()); 7398 EXPECT_TRUE(frameElement->IsNull());
7334 7399
7335 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. 7400 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7336 reset(); 7401 reset();
7337 } 7402 }
(...skipping 27 matching lines...) Expand all
7365 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7430 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7366 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7431 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7367 WebFrame* targetFrame = mainFrame()->firstChild(); 7432 WebFrame* targetFrame = mainFrame()->firstChild();
7368 ASSERT_TRUE(targetFrame); 7433 ASSERT_TRUE(targetFrame);
7369 targetFrame->swap(remoteFrame); 7434 targetFrame->swap(remoteFrame);
7370 ASSERT_TRUE(mainFrame()->firstChild()); 7435 ASSERT_TRUE(mainFrame()->firstChild());
7371 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 7436 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
7372 7437
7373 RemoteToLocalSwapWebFrameClient client(remoteFrame); 7438 RemoteToLocalSwapWebFrameClient client(remoteFrame);
7374 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7439 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7375 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7440 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7376 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7441 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7377 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); 7442 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType());
7378 7443
7379 // Manually reset to break WebViewHelper's dependency on the stack allocated 7444 // Manually reset to break WebViewHelper's dependency on the stack allocated
7380 // TestWebFrameClient. 7445 // TestWebFrameClient.
7381 reset(); 7446 reset();
7382 remoteFrame->close(); 7447 remoteFrame->close();
7383 } 7448 }
7384 7449
7385 // The commit type should be Standard if we are swapping a RemoteFrame to a 7450 // The commit type should be Standard if we are swapping a RemoteFrame to a
7386 // LocalFrame after commits have already happened in the frame. The browser 7451 // LocalFrame after commits have already happened in the frame. The browser
7387 // process will inform us via setCommittedFirstRealLoad. 7452 // process will inform us via setCommittedFirstRealLoad.
7388 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) 7453 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap)
7389 { 7454 {
7390 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7455 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7391 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7456 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7392 WebFrame* targetFrame = mainFrame()->firstChild(); 7457 WebFrame* targetFrame = mainFrame()->firstChild();
7393 ASSERT_TRUE(targetFrame); 7458 ASSERT_TRUE(targetFrame);
7394 targetFrame->swap(remoteFrame); 7459 targetFrame->swap(remoteFrame);
7395 ASSERT_TRUE(mainFrame()->firstChild()); 7460 ASSERT_TRUE(mainFrame()->firstChild());
7396 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 7461 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
7397 7462
7398 RemoteToLocalSwapWebFrameClient client(remoteFrame); 7463 RemoteToLocalSwapWebFrameClient client(remoteFrame);
7399 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7464 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7400 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7465 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7401 localFrame->setCommittedFirstRealLoad(); 7466 localFrame->setCommittedFirstRealLoad();
7402 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7467 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7403 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); 7468 EXPECT_EQ(WebStandardCommit, client.historyCommitType());
7404 7469
7405 // Manually reset to break WebViewHelper's dependency on the stack allocated 7470 // Manually reset to break WebViewHelper's dependency on the stack allocated
7406 // TestWebFrameClient. 7471 // TestWebFrameClient.
7407 reset(); 7472 reset();
7408 remoteFrame->close(); 7473 remoteFrame->close();
7409 } 7474 }
7410 7475
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
7528 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient; 7593 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient;
7529 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame(); 7594 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame();
7530 popupView->setMainFrame(popupRemoteFrame); 7595 popupView->setMainFrame(popupRemoteFrame);
7531 popupRemoteFrame->setOpener(mainFrame); 7596 popupRemoteFrame->setOpener(mainFrame);
7532 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h ttp://foo.com")); 7597 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h ttp://foo.com"));
7533 EXPECT_FALSE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->s ecurityOrigin())); 7598 EXPECT_FALSE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->s ecurityOrigin()));
7534 7599
7535 // Do a remote-to-local swap in the popup. 7600 // Do a remote-to-local swap in the popup.
7536 FrameTestHelpers::TestWebFrameClient popupLocalClient; 7601 FrameTestHelpers::TestWebFrameClient popupLocalClient;
7537 WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Doc ument, &popupLocalClient); 7602 WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Doc ument, &popupLocalClient);
7538 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan dboxFlags::None); 7603 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan dboxFlags::None, WebFrameOwnerProperties());
7539 popupRemoteFrame->swap(popupLocalFrame); 7604 popupRemoteFrame->swap(popupLocalFrame);
7540 7605
7541 // The initial document created during the remote-to-local swap should have 7606 // The initial document created during the remote-to-local swap should have
7542 // inherited its opener's SecurityOrigin. 7607 // inherited its opener's SecurityOrigin.
7543 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se curityOrigin())); 7608 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se curityOrigin()));
7544 7609
7545 popupView->close(); 7610 popupView->close();
7546 } 7611 }
7547 7612
7548 TEST_F(WebFrameTest, SwapWithOpenerCycle) 7613 TEST_F(WebFrameTest, SwapWithOpenerCycle)
7549 { 7614 {
7550 // First, create a remote main frame with itself as the opener. 7615 // First, create a remote main frame with itself as the opener.
7551 FrameTestHelpers::TestWebViewClient viewClient; 7616 FrameTestHelpers::TestWebViewClient viewClient;
7552 WebView* view = WebView::create(&viewClient); 7617 WebView* view = WebView::create(&viewClient);
7553 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7618 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7554 WebRemoteFrame* remoteFrame = remoteClient.frame(); 7619 WebRemoteFrame* remoteFrame = remoteClient.frame();
7555 view->setMainFrame(remoteFrame); 7620 view->setMainFrame(remoteFrame);
7556 remoteFrame->setOpener(remoteFrame); 7621 remoteFrame->setOpener(remoteFrame);
7557 7622
7558 // Now swap in a local frame. It shouldn't crash. 7623 // Now swap in a local frame. It shouldn't crash.
7559 FrameTestHelpers::TestWebFrameClient localClient; 7624 FrameTestHelpers::TestWebFrameClient localClient;
7560 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &localClient); 7625 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &localClient);
7561 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7626 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7562 remoteFrame->swap(localFrame); 7627 remoteFrame->swap(localFrame);
7563 7628
7564 // And the opener cycle should still be preserved. 7629 // And the opener cycle should still be preserved.
7565 EXPECT_EQ(localFrame, localFrame->opener()); 7630 EXPECT_EQ(localFrame, localFrame->opener());
7566 7631
7567 view->close(); 7632 view->close();
7568 } 7633 }
7569 7634
7570 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 7635 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
7571 public: 7636 public:
(...skipping 16 matching lines...) Expand all
7588 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) 7653 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType)
7589 { 7654 {
7590 FrameTestHelpers::TestWebViewClient viewClient; 7655 FrameTestHelpers::TestWebViewClient viewClient;
7591 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7656 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7592 WebView* view = WebView::create(&viewClient); 7657 WebView* view = WebView::create(&viewClient);
7593 view->setMainFrame(remoteClient.frame()); 7658 view->setMainFrame(remoteClient.frame());
7594 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica tedOrigin(SecurityOrigin::create(toKURL(m_baseURL))); 7659 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica tedOrigin(SecurityOrigin::create(toKURL(m_baseURL)));
7595 7660
7596 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame. 7661 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame.
7597 CommitTypeWebFrameClient childFrameClient; 7662 CommitTypeWebFrameClient childFrameClient;
7598 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 7663 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
7599 registerMockedHttpURLLoad("foo.html"); 7664 registerMockedHttpURLLoad("foo.html");
7600 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); 7665 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html");
7601 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() ); 7666 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() );
7602 view->close(); 7667 view->close();
7603 } 7668 }
7604 7669
7605 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient { 7670 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient {
7606 public: 7671 public:
7607 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { } 7672 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { }
7608 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; } 7673 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; }
7609 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; } 7674 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; }
7610 7675
7611 private: 7676 private:
7612 bool m_didHandleGestureEvent; 7677 bool m_didHandleGestureEvent;
7613 }; 7678 };
7614 7679
7615 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) 7680 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest)
7616 { 7681 {
7617 FrameTestHelpers::TestWebViewClient viewClient; 7682 FrameTestHelpers::TestWebViewClient viewClient;
7618 WebView* view = WebView::create(&viewClient); 7683 WebView* view = WebView::create(&viewClient);
7619 7684
7620 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7685 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7621 view->setMainFrame(remoteClient.frame()); 7686 view->setMainFrame(remoteClient.frame());
7622 7687
7623 FrameTestHelpers::TestWebFrameClient childFrameClient; 7688 FrameTestHelpers::TestWebFrameClient childFrameClient;
7624 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 7689 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
7625 7690
7626 GestureEventTestWebViewClient childViewClient; 7691 GestureEventTestWebViewClient childViewClient;
7627 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame ); 7692 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame );
7628 7693
7629 view->resize(WebSize(1000, 1000)); 7694 view->resize(WebSize(1000, 1000));
7630 view->layout(); 7695 view->layout();
7631 7696
7632 widget->handleInputEvent(fatTap(20, 20)); 7697 widget->handleInputEvent(fatTap(20, 20));
7633 EXPECT_TRUE(childViewClient.didHandleGestureEvent()); 7698 EXPECT_TRUE(childViewClient.didHandleGestureEvent());
7634 7699
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
7834 7899
7835 7900
7836 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling) 7901 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling)
7837 { 7902 {
7838 FrameTestHelpers::TestWebViewClient viewClient; 7903 FrameTestHelpers::TestWebViewClient viewClient;
7839 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7904 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7840 WebView* view = WebView::create(&viewClient); 7905 WebView* view = WebView::create(&viewClient);
7841 view->setMainFrame(remoteClient.frame()); 7906 view->setMainFrame(remoteClient.frame());
7842 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame(); 7907 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame();
7843 7908
7844 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, nullptr); 7909 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties() );
7845 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, secondFrame); 7910 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerProperti es());
7846 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, secondFrame); 7911 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerPropertie s());
7847 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, nullptr); 7912 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties()) ;
7848 7913
7849 EXPECT_EQ(firstFrame, parent->firstChild()); 7914 EXPECT_EQ(firstFrame, parent->firstChild());
7850 EXPECT_EQ(nullptr, firstFrame->previousSibling()); 7915 EXPECT_EQ(nullptr, firstFrame->previousSibling());
7851 EXPECT_EQ(secondFrame, firstFrame->nextSibling()); 7916 EXPECT_EQ(secondFrame, firstFrame->nextSibling());
7852 7917
7853 EXPECT_EQ(firstFrame, secondFrame->previousSibling()); 7918 EXPECT_EQ(firstFrame, secondFrame->previousSibling());
7854 EXPECT_EQ(thirdFrame, secondFrame->nextSibling()); 7919 EXPECT_EQ(thirdFrame, secondFrame->nextSibling());
7855 7920
7856 EXPECT_EQ(secondFrame, thirdFrame->previousSibling()); 7921 EXPECT_EQ(secondFrame, thirdFrame->previousSibling());
7857 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling()); 7922 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling());
(...skipping 14 matching lines...) Expand all
7872 { 7937 {
7873 FrameTestHelpers::TestWebViewClient viewClient; 7938 FrameTestHelpers::TestWebViewClient viewClient;
7874 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7939 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7875 WebView* view = WebView::create(&viewClient); 7940 WebView* view = WebView::create(&viewClient);
7876 view->settings()->setJavaScriptEnabled(true); 7941 view->settings()->setJavaScriptEnabled(true);
7877 view->setMainFrame(remoteClient.frame()); 7942 view->setMainFrame(remoteClient.frame());
7878 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); 7943 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
7879 root->setReplicatedOrigin(SecurityOrigin::createUnique()); 7944 root->setReplicatedOrigin(SecurityOrigin::createUnique());
7880 7945
7881 FrameTestHelpers::TestWebFrameClient localFrameClient; 7946 FrameTestHelpers::TestWebFrameClient localFrameClient;
7882 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr); 7947 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, WebFrameOwnerPropertie s());
7883 7948
7884 // Finally, make sure an embedder triggered load in the local frame swapped 7949 // Finally, make sure an embedder triggered load in the local frame swapped
7885 // back in works. 7950 // back in works.
7886 registerMockedHttpURLLoad("send_beacon.html"); 7951 registerMockedHttpURLLoad("send_beacon.html");
7887 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon() 7952 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon()
7888 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html"); 7953 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html");
7889 7954
7890 view->close(); 7955 view->close();
7891 } 7956 }
7892 7957
7893 // See https://crbug.com/525285. 7958 // See https://crbug.com/525285.
7894 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me) 7959 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me)
7895 { 7960 {
7896 FrameTestHelpers::TestWebViewClient viewClient; 7961 FrameTestHelpers::TestWebViewClient viewClient;
7897 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7962 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7898 WebView* view = WebView::create(&viewClient); 7963 WebView* view = WebView::create(&viewClient);
7899 view->setMainFrame(remoteClient.frame()); 7964 view->setMainFrame(remoteClient.frame());
7900 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); 7965 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame();
7901 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); 7966 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique());
7902 7967
7903 FrameTestHelpers::TestWebFrameClient localFrameClient; 7968 FrameTestHelpers::TestWebFrameClient localFrameClient;
7904 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr); 7969 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr, WebFrameOwnerProperties());
7905 7970
7906 // Do a remote-to-local swap of the top frame. 7971 // Do a remote-to-local swap of the top frame.
7907 FrameTestHelpers::TestWebFrameClient localClient; 7972 FrameTestHelpers::TestWebFrameClient localClient;
7908 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient); 7973 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient);
7909 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N one); 7974 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N one, WebFrameOwnerProperties());
7910 remoteRoot->swap(localRoot); 7975 remoteRoot->swap(localRoot);
7911 7976
7912 // Load a page with a child frame in the new root to make sure this doesn't 7977 // Load a page with a child frame in the new root to make sure this doesn't
7913 // crash when the child frame invokes setCoreFrame. 7978 // crash when the child frame invokes setCoreFrame.
7914 registerMockedHttpURLLoad("single_iframe.html"); 7979 registerMockedHttpURLLoad("single_iframe.html");
7915 registerMockedHttpURLLoad("visible_iframe.html"); 7980 registerMockedHttpURLLoad("visible_iframe.html");
7916 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); 7981 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html");
7917 7982
7918 view->close(); 7983 view->close();
7919 } 7984 }
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
8226 EXPECT_TRUE(resource); 8291 EXPECT_TRUE(resource);
8227 EXPECT_NE(0, resource->loadFinishTime()); 8292 EXPECT_NE(0, resource->loadFinishTime());
8228 8293
8229 DocumentLoader* loader = document->loader(); 8294 DocumentLoader* loader = document->loader();
8230 8295
8231 EXPECT_TRUE(loader); 8296 EXPECT_TRUE(loader);
8232 EXPECT_EQ(loader->timing().responseEnd(), resource->loadFinishTime()); 8297 EXPECT_EQ(loader->timing().responseEnd(), resource->loadFinishTime());
8233 } 8298 }
8234 8299
8235 } // namespace blink 8300 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/FrameTestHelpers.cpp ('k') | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698