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

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: move setSandboxFlags call 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 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/LayoutView.h" 68 #include "core/layout/LayoutView.h"
68 #include "core/layout/compositing/PaintLayerCompositor.h" 69 #include "core/layout/compositing/PaintLayerCompositor.h"
69 #include "core/loader/DocumentLoader.h" 70 #include "core/loader/DocumentLoader.h"
70 #include "core/loader/DocumentThreadableLoader.h" 71 #include "core/loader/DocumentThreadableLoader.h"
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 1600
1600 ASSERT_NE(nullptr, element); 1601 ASSERT_NE(nullptr, element);
1601 EXPECT_EQ(String("oldValue"), element->innerText()); 1602 EXPECT_EQ(String("oldValue"), element->innerText());
1602 1603
1603 PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPoint, hitPoint, IntSize(0, 0), 0, PlatformEvent::NoModifiers, PlatformGestureSourceTo uchscreen); 1604 PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPoint, hitPoint, IntSize(0, 0), 0, PlatformEvent::NoModifiers, PlatformGestureSourceTo uchscreen);
1604 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handle GestureEvent(gestureEvent); 1605 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handle GestureEvent(gestureEvent);
1605 // when pressed, the button changes its own text to "updatedValue" 1606 // when pressed, the button changes its own text to "updatedValue"
1606 EXPECT_EQ(String("updatedValue"), element->innerText()); 1607 EXPECT_EQ(String("updatedValue"), element->innerText());
1607 } 1608 }
1608 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 // Check if the LocalFrame has seen the marginwidth and marginheight
1630 // properties.
1631 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document ();
1632 EXPECT_EQ(11, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginwidthAttr));
1633 EXPECT_EQ(22, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginheightAttr));
1634
1635 FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView();
1636 // Expect scrollbars to be enabled by default.
1637 EXPECT_NE(nullptr, frameView->horizontalScrollbar());
1638 EXPECT_NE(nullptr, frameView->verticalScrollbar());
1639
1640 view->close();
1641 }
1642
1643 TEST_F(WebFrameTest, FrameOwnerPropertiesScrolling)
1644 {
1645 FrameTestHelpers::TestWebViewClient viewClient;
1646 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1647 WebView* view = WebView::create(&viewClient);
1648 view->settings()->setJavaScriptEnabled(true);
1649 view->setMainFrame(remoteClient.frame());
1650 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1651 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1652
1653 WebFrameOwnerProperties properties;
1654 // Turn off scrolling in the subframe.
1655 properties.scrollingMode = WebFrameOwnerProperties::ScrollingMode::AlwaysOff ;
1656 FrameTestHelpers::TestWebFrameClient localFrameClient;
1657 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);
1658
1659 registerMockedHttpURLLoad("frame_owner_properties.html");
1660 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1661
1662 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document ();
1663 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginwidthAttr));
1664 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginheightAttr));
1665
1666 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w();
1667 EXPECT_EQ(nullptr, frameView->horizontalScrollbar());
1668 EXPECT_EQ(nullptr, frameView->verticalScrollbar());
1669
1670 view->close();
1671 }
1672
1673
1609 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations ) 1674 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations )
1610 { 1675 {
1611 UseMockScrollbarSettings mockScrollbarSettings; 1676 UseMockScrollbarSettings mockScrollbarSettings;
1612 registerMockedHttpURLLoad("200-by-300.html"); 1677 registerMockedHttpURLLoad("200-by-300.html");
1613 registerMockedHttpURLLoad("large-div.html"); 1678 registerMockedHttpURLLoad("large-div.html");
1614 1679
1615 FixedLayoutTestWebViewClient client; 1680 FixedLayoutTestWebViewClient client;
1616 client.m_screenInfo.deviceScaleFactor = 1; 1681 client.m_screenInfo.deviceScaleFactor = 1;
1617 int viewportWidth = 640; 1682 int viewportWidth = 640;
1618 int viewportHeight = 480; 1683 int viewportHeight = 480;
(...skipping 4311 matching lines...) Expand 10 before | Expand all | Expand 10 after
5930 , m_willSendRequestCallCount(0) 5995 , m_willSendRequestCallCount(0)
5931 , m_childFrameCreationCount(0) 5996 , m_childFrameCreationCount(0)
5932 { 5997 {
5933 } 5998 }
5934 5999
5935 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; } 6000 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; }
5936 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } 6001 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; }
5937 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } 6002 int willSendRequestCallCount() const { return m_willSendRequestCallCount; }
5938 int childFrameCreationCount() const { return m_childFrameCreationCount; } 6003 int childFrameCreationCount() const { return m_childFrameCreationCount; }
5939 6004
5940 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, WebSandboxFlags) 6005 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, WebSandboxFlags, const WebFrameOwnerProperties& frameOwn erProperties)
5941 { 6006 {
5942 ASSERT(m_childClient); 6007 ASSERT(m_childClient);
5943 m_childFrameCreationCount++; 6008 m_childFrameCreationCount++;
5944 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); 6009 WebFrame* frame = WebLocalFrame::create(scope, m_childClient);
5945 parent->appendChild(frame); 6010 parent->appendChild(frame);
5946 return frame; 6011 return frame;
5947 } 6012 }
5948 6013
5949 virtual void didStartLoading(bool toDifferentDocument) 6014 virtual void didStartLoading(bool toDifferentDocument)
5950 { 6015 {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
6319 // After commit, there is. 6384 // After commit, there is.
6320 HistoryItem* item = mainFrameLoader.currentItem(); 6385 HistoryItem* item = mainFrameLoader.currentItem();
6321 ASSERT_TRUE(item); 6386 ASSERT_TRUE(item);
6322 EXPECT_EQ(WTF::String(url.data()), item->urlString()); 6387 EXPECT_EQ(WTF::String(url.data()), item->urlString());
6323 } 6388 }
6324 6389
6325 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { 6390 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient {
6326 public: 6391 public:
6327 FailCreateChildFrame() : m_callCount(0) { } 6392 FailCreateChildFrame() : m_callCount(0) { }
6328 6393
6329 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, WebSandboxFlags sandboxFlags) override 6394 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, WebSandboxFlags sandboxFlags, const WebFrameOwnerPrope rties& frameOwnerProperties) override
6330 { 6395 {
6331 ++m_callCount; 6396 ++m_callCount;
6332 return 0; 6397 return 0;
6333 } 6398 }
6334 6399
6335 int callCount() const { return m_callCount; } 6400 int callCount() const { return m_callCount; }
6336 6401
6337 private: 6402 private:
6338 int m_callCount; 6403 int m_callCount;
6339 }; 6404 };
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
7017 // doesn't leave behind dangling pointers. 7082 // doesn't leave behind dangling pointers.
7018 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame) 7083 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame)
7019 { 7084 {
7020 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o 7085 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o
7021 // write tests with a top-level remote frame. 7086 // write tests with a top-level remote frame.
7022 FrameTestHelpers::TestWebViewClient viewClient; 7087 FrameTestHelpers::TestWebViewClient viewClient;
7023 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7088 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7024 WebView* view = WebView::create(&viewClient); 7089 WebView* view = WebView::create(&viewClient);
7025 view->setMainFrame(remoteClient.frame()); 7090 view->setMainFrame(remoteClient.frame());
7026 FrameTestHelpers::TestWebFrameClient childFrameClient; 7091 FrameTestHelpers::TestWebFrameClient childFrameClient;
7027 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 7092 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
7028 7093
7029 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d. 7094 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d.
7030 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame); 7095 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame);
7031 view->close(); 7096 view->close();
7032 childCoreFrame.clear(); 7097 childCoreFrame.clear();
7033 } 7098 }
7034 7099
7035 class WebFrameSwapTest : public WebFrameTest { 7100 class WebFrameSwapTest : public WebFrameTest {
7036 protected: 7101 protected:
7037 WebFrameSwapTest() 7102 WebFrameSwapTest()
(...skipping 14 matching lines...) Expand all
7052 FrameTestHelpers::WebViewHelper m_webViewHelper; 7117 FrameTestHelpers::WebViewHelper m_webViewHelper;
7053 }; 7118 };
7054 7119
7055 TEST_F(WebFrameSwapTest, SwapMainFrame) 7120 TEST_F(WebFrameSwapTest, SwapMainFrame)
7056 { 7121 {
7057 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr); 7122 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr);
7058 mainFrame()->swap(remoteFrame); 7123 mainFrame()->swap(remoteFrame);
7059 7124
7060 FrameTestHelpers::TestWebFrameClient client; 7125 FrameTestHelpers::TestWebFrameClient client;
7061 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7126 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7062 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7127 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7063 remoteFrame->swap(localFrame); 7128 remoteFrame->swap(localFrame);
7064 7129
7065 // Finally, make sure an embedder triggered load in the local frame swapped 7130 // Finally, make sure an embedder triggered load in the local frame swapped
7066 // back in works. 7131 // back in works.
7067 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7132 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7068 std::string content = localFrame->contentAsText(1024).utf8(); 7133 std::string content = localFrame->contentAsText(1024).utf8();
7069 EXPECT_EQ("hello", content); 7134 EXPECT_EQ("hello", content);
7070 7135
7071 // Manually reset to break WebViewHelper's dependency on the stack allocated 7136 // Manually reset to break WebViewHelper's dependency on the stack allocated
7072 // TestWebFrameClient. 7137 // TestWebFrameClient.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
7128 } 7193 }
7129 7194
7130 TEST_F(WebFrameSwapTest, SwapFirstChild) 7195 TEST_F(WebFrameSwapTest, SwapFirstChild)
7131 { 7196 {
7132 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7197 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7133 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7198 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7134 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame ); 7199 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame );
7135 7200
7136 FrameTestHelpers::TestWebFrameClient client; 7201 FrameTestHelpers::TestWebFrameClient client;
7137 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7202 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7138 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7203 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7139 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ; 7204 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ;
7140 7205
7141 // FIXME: This almost certainly fires more load events on the iframe element 7206 // FIXME: This almost certainly fires more load events on the iframe element
7142 // than it should. 7207 // than it should.
7143 // Finally, make sure an embedder triggered load in the local frame swapped 7208 // Finally, make sure an embedder triggered load in the local frame swapped
7144 // back in works. 7209 // back in works.
7145 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7210 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7146 std::string content = localFrame->contentAsText(1024).utf8(); 7211 std::string content = localFrame->contentAsText(1024).utf8();
7147 EXPECT_EQ("hello", content); 7212 EXPECT_EQ("hello", content);
7148 7213
(...skipping 18 matching lines...) Expand all
7167 } 7232 }
7168 7233
7169 TEST_F(WebFrameSwapTest, SwapMiddleChild) 7234 TEST_F(WebFrameSwapTest, SwapMiddleChild)
7170 { 7235 {
7171 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7236 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7172 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7237 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7173 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e); 7238 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e);
7174 7239
7175 FrameTestHelpers::TestWebFrameClient client; 7240 FrameTestHelpers::TestWebFrameClient client;
7176 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7241 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7177 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7242 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7178 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame ); 7243 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame );
7179 7244
7180 // FIXME: This almost certainly fires more load events on the iframe element 7245 // FIXME: This almost certainly fires more load events on the iframe element
7181 // than it should. 7246 // than it should.
7182 // Finally, make sure an embedder triggered load in the local frame swapped 7247 // Finally, make sure an embedder triggered load in the local frame swapped
7183 // back in works. 7248 // back in works.
7184 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7249 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7185 std::string content = localFrame->contentAsText(1024).utf8(); 7250 std::string content = localFrame->contentAsText(1024).utf8();
7186 EXPECT_EQ("hello", content); 7251 EXPECT_EQ("hello", content);
7187 7252
(...skipping 15 matching lines...) Expand all
7203 } 7268 }
7204 7269
7205 TEST_F(WebFrameSwapTest, SwapLastChild) 7270 TEST_F(WebFrameSwapTest, SwapLastChild)
7206 { 7271 {
7207 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7272 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7208 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7273 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7209 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ; 7274 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ;
7210 7275
7211 FrameTestHelpers::TestWebFrameClient client; 7276 FrameTestHelpers::TestWebFrameClient client;
7212 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7277 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7213 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7278 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7214 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); 7279 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame);
7215 7280
7216 // FIXME: This almost certainly fires more load events on the iframe element 7281 // FIXME: This almost certainly fires more load events on the iframe element
7217 // than it should. 7282 // than it should.
7218 // Finally, make sure an embedder triggered load in the local frame swapped 7283 // Finally, make sure an embedder triggered load in the local frame swapped
7219 // back in works. 7284 // back in works.
7220 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7285 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7221 std::string content = localFrame->contentAsText(1024).utf8(); 7286 std::string content = localFrame->contentAsText(1024).utf8();
7222 EXPECT_EQ("hello", content); 7287 EXPECT_EQ("hello", content);
7223 7288
(...skipping 24 matching lines...) Expand all
7248 7313
7249 targetFrame = mainFrame()->firstChild()->nextSibling(); 7314 targetFrame = mainFrame()->firstChild()->nextSibling();
7250 EXPECT_TRUE(targetFrame); 7315 EXPECT_TRUE(targetFrame);
7251 7316
7252 // Create child frames in the target frame before testing the swap. 7317 // Create child frames in the target frame before testing the swap.
7253 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; 7318 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2;
7254 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2); 7319 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2);
7255 7320
7256 FrameTestHelpers::TestWebFrameClient client; 7321 FrameTestHelpers::TestWebFrameClient client;
7257 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7322 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7258 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7323 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7259 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); 7324 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame);
7260 7325
7261 // FIXME: This almost certainly fires more load events on the iframe element 7326 // FIXME: This almost certainly fires more load events on the iframe element
7262 // than it should. 7327 // than it should.
7263 // Finally, make sure an embedder triggered load in the local frame swapped 7328 // Finally, make sure an embedder triggered load in the local frame swapped
7264 // back in works. 7329 // back in works.
7265 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7330 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7266 std::string content = localFrame->contentAsText(1024).utf8(); 7331 std::string content = localFrame->contentAsText(1024).utf8();
7267 EXPECT_EQ("hello", content); 7332 EXPECT_EQ("hello", content);
7268 7333
(...skipping 23 matching lines...) Expand all
7292 "document.querySelector('#frame2').contentWindow;")); 7357 "document.querySelector('#frame2').contentWindow;"));
7293 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow)); 7358 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow));
7294 // Check that its view is consistent with the world. 7359 // Check that its view is consistent with the world.
7295 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource( 7360 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource(
7296 "document.querySelector('#frame2').contentWindow.top;")); 7361 "document.querySelector('#frame2').contentWindow.top;"));
7297 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); 7362 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop));
7298 7363
7299 // Now check that remote -> local works too, since it goes through a differe nt code path. 7364 // Now check that remote -> local works too, since it goes through a differe nt code path.
7300 FrameTestHelpers::TestWebFrameClient client; 7365 FrameTestHelpers::TestWebFrameClient client;
7301 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7366 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7302 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7367 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7303 remoteFrame->swap(localFrame); 7368 remoteFrame->swap(localFrame);
7304 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( WebScriptSource( 7369 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( WebScriptSource(
7305 "document.querySelector('#frame2').contentWindow;")); 7370 "document.querySelector('#frame2').contentWindow;"));
7306 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); 7371 EXPECT_TRUE(originalWindow->StrictEquals(localWindow));
7307 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource( 7372 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource(
7308 "document.querySelector('#frame2').contentWindow.top;")); 7373 "document.querySelector('#frame2').contentWindow.top;"));
7309 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); 7374 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop));
7310 7375
7311 // Manually reset to break WebViewHelper's dependency on the stack allocated 7376 // Manually reset to break WebViewHelper's dependency on the stack allocated
7312 // TestWebFrameClient. 7377 // TestWebFrameClient.
(...skipping 13 matching lines...) Expand all
7326 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7391 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7327 WebRemoteFrame* remoteFrame = remoteClient.frame(); 7392 WebRemoteFrame* remoteFrame = remoteClient.frame();
7328 mainFrame()->lastChild()->swap(remoteFrame); 7393 mainFrame()->lastChild()->swap(remoteFrame);
7329 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7394 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7330 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource("saved.top")); 7395 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource("saved.top"));
7331 EXPECT_TRUE(remoteWindowTop->IsObject()); 7396 EXPECT_TRUE(remoteWindowTop->IsObject());
7332 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); 7397 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop));
7333 7398
7334 FrameTestHelpers::TestWebFrameClient client; 7399 FrameTestHelpers::TestWebFrameClient client;
7335 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7400 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7336 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7401 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7337 remoteFrame->swap(localFrame); 7402 remoteFrame->swap(localFrame);
7338 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource("saved.top")); 7403 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource("saved.top"));
7339 EXPECT_TRUE(localWindowTop->IsObject()); 7404 EXPECT_TRUE(localWindowTop->IsObject());
7340 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); 7405 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop));
7341 7406
7342 reset(); 7407 reset();
7343 } 7408 }
7344 7409
7345 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) 7410 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable)
7346 { 7411 {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
7397 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable) 7462 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable)
7398 { 7463 {
7399 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7464 v8::HandleScope scope(v8::Isolate::GetCurrent());
7400 7465
7401 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7466 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7402 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); 7467 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7403 mainFrame()->swap(remoteParentFrame); 7468 mainFrame()->swap(remoteParentFrame);
7404 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7469 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7405 7470
7406 FrameTestHelpers::TestWebFrameClient childFrameClient; 7471 FrameTestHelpers::TestWebFrameClient childFrameClient;
7407 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); 7472 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties());
7408 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); 7473 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7409 7474
7410 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window")); 7475 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window"));
7411 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]")); 7476 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]"));
7412 EXPECT_TRUE(childOfRemoteParent->IsObject()); 7477 EXPECT_TRUE(childOfRemoteParent->IsObject());
7413 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); 7478 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent));
7414 7479
7415 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length")); 7480 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length"));
7416 ASSERT_TRUE(windowLength->IsInt32()); 7481 ASSERT_TRUE(windowLength->IsInt32());
7417 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); 7482 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value());
7418 7483
7419 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. 7484 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7420 reset(); 7485 reset();
7421 } 7486 }
7422 7487
7423 // Check that frames with a remote parent don't crash while accessing window.fra meElement. 7488 // Check that frames with a remote parent don't crash while accessing window.fra meElement.
7424 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) 7489 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent)
7425 { 7490 {
7426 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7491 v8::HandleScope scope(v8::Isolate::GetCurrent());
7427 7492
7428 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7493 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7429 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); 7494 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7430 mainFrame()->swap(remoteParentFrame); 7495 mainFrame()->swap(remoteParentFrame);
7431 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7496 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7432 7497
7433 FrameTestHelpers::TestWebFrameClient childFrameClient; 7498 FrameTestHelpers::TestWebFrameClient childFrameClient;
7434 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); 7499 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties());
7435 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); 7500 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7436 7501
7437 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement")); 7502 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement"));
7438 // frameElement shouldn't be accessible cross-origin. 7503 // frameElement shouldn't be accessible cross-origin.
7439 EXPECT_TRUE(frameElement.IsEmpty()); 7504 EXPECT_TRUE(frameElement.IsEmpty());
7440 7505
7441 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. 7506 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7442 reset(); 7507 reset();
7443 } 7508 }
7444 7509
(...skipping 26 matching lines...) Expand all
7471 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7536 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7472 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7537 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7473 WebFrame* targetFrame = mainFrame()->firstChild(); 7538 WebFrame* targetFrame = mainFrame()->firstChild();
7474 ASSERT_TRUE(targetFrame); 7539 ASSERT_TRUE(targetFrame);
7475 targetFrame->swap(remoteFrame); 7540 targetFrame->swap(remoteFrame);
7476 ASSERT_TRUE(mainFrame()->firstChild()); 7541 ASSERT_TRUE(mainFrame()->firstChild());
7477 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 7542 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
7478 7543
7479 RemoteToLocalSwapWebFrameClient client(remoteFrame); 7544 RemoteToLocalSwapWebFrameClient client(remoteFrame);
7480 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7545 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7481 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7546 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7482 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7547 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7483 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); 7548 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType());
7484 7549
7485 // Manually reset to break WebViewHelper's dependency on the stack allocated 7550 // Manually reset to break WebViewHelper's dependency on the stack allocated
7486 // TestWebFrameClient. 7551 // TestWebFrameClient.
7487 reset(); 7552 reset();
7488 remoteFrame->close(); 7553 remoteFrame->close();
7489 } 7554 }
7490 7555
7491 // The commit type should be Standard if we are swapping a RemoteFrame to a 7556 // The commit type should be Standard if we are swapping a RemoteFrame to a
7492 // LocalFrame after commits have already happened in the frame. The browser 7557 // LocalFrame after commits have already happened in the frame. The browser
7493 // process will inform us via setCommittedFirstRealLoad. 7558 // process will inform us via setCommittedFirstRealLoad.
7494 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) 7559 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap)
7495 { 7560 {
7496 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7561 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7497 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7562 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7498 WebFrame* targetFrame = mainFrame()->firstChild(); 7563 WebFrame* targetFrame = mainFrame()->firstChild();
7499 ASSERT_TRUE(targetFrame); 7564 ASSERT_TRUE(targetFrame);
7500 targetFrame->swap(remoteFrame); 7565 targetFrame->swap(remoteFrame);
7501 ASSERT_TRUE(mainFrame()->firstChild()); 7566 ASSERT_TRUE(mainFrame()->firstChild());
7502 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 7567 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
7503 7568
7504 RemoteToLocalSwapWebFrameClient client(remoteFrame); 7569 RemoteToLocalSwapWebFrameClient client(remoteFrame);
7505 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); 7570 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client);
7506 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); 7571 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties());
7507 localFrame->setCommittedFirstRealLoad(); 7572 localFrame->setCommittedFirstRealLoad();
7508 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7573 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7509 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); 7574 EXPECT_EQ(WebStandardCommit, client.historyCommitType());
7510 7575
7511 // Manually reset to break WebViewHelper's dependency on the stack allocated 7576 // Manually reset to break WebViewHelper's dependency on the stack allocated
7512 // TestWebFrameClient. 7577 // TestWebFrameClient.
7513 reset(); 7578 reset();
7514 remoteFrame->close(); 7579 remoteFrame->close();
7515 } 7580 }
7516 7581
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
7634 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient; 7699 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient;
7635 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame(); 7700 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame();
7636 popupView->setMainFrame(popupRemoteFrame); 7701 popupView->setMainFrame(popupRemoteFrame);
7637 popupRemoteFrame->setOpener(mainFrame); 7702 popupRemoteFrame->setOpener(mainFrame);
7638 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h ttp://foo.com")); 7703 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h ttp://foo.com"));
7639 EXPECT_FALSE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->s ecurityOrigin())); 7704 EXPECT_FALSE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->s ecurityOrigin()));
7640 7705
7641 // Do a remote-to-local swap in the popup. 7706 // Do a remote-to-local swap in the popup.
7642 FrameTestHelpers::TestWebFrameClient popupLocalClient; 7707 FrameTestHelpers::TestWebFrameClient popupLocalClient;
7643 WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Doc ument, &popupLocalClient); 7708 WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Doc ument, &popupLocalClient);
7644 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan dboxFlags::None); 7709 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan dboxFlags::None, WebFrameOwnerProperties());
7645 popupRemoteFrame->swap(popupLocalFrame); 7710 popupRemoteFrame->swap(popupLocalFrame);
7646 7711
7647 // The initial document created during the remote-to-local swap should have 7712 // The initial document created during the remote-to-local swap should have
7648 // inherited its opener's SecurityOrigin. 7713 // inherited its opener's SecurityOrigin.
7649 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se curityOrigin())); 7714 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se curityOrigin()));
7650 7715
7651 popupView->close(); 7716 popupView->close();
7652 } 7717 }
7653 7718
7654 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 7719 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
(...skipping 17 matching lines...) Expand all
7672 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) 7737 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType)
7673 { 7738 {
7674 FrameTestHelpers::TestWebViewClient viewClient; 7739 FrameTestHelpers::TestWebViewClient viewClient;
7675 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7740 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7676 WebView* view = WebView::create(&viewClient); 7741 WebView* view = WebView::create(&viewClient);
7677 view->setMainFrame(remoteClient.frame()); 7742 view->setMainFrame(remoteClient.frame());
7678 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica tedOrigin(SecurityOrigin::create(toKURL(m_baseURL))); 7743 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica tedOrigin(SecurityOrigin::create(toKURL(m_baseURL)));
7679 7744
7680 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame. 7745 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame.
7681 CommitTypeWebFrameClient childFrameClient; 7746 CommitTypeWebFrameClient childFrameClient;
7682 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 7747 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
7683 registerMockedHttpURLLoad("foo.html"); 7748 registerMockedHttpURLLoad("foo.html");
7684 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); 7749 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html");
7685 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() ); 7750 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() );
7686 view->close(); 7751 view->close();
7687 } 7752 }
7688 7753
7689 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient { 7754 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient {
7690 public: 7755 public:
7691 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { } 7756 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { }
7692 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; } 7757 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; }
7693 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; } 7758 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; }
7694 7759
7695 private: 7760 private:
7696 bool m_didHandleGestureEvent; 7761 bool m_didHandleGestureEvent;
7697 }; 7762 };
7698 7763
7699 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) 7764 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest)
7700 { 7765 {
7701 FrameTestHelpers::TestWebViewClient viewClient; 7766 FrameTestHelpers::TestWebViewClient viewClient;
7702 WebView* view = WebView::create(&viewClient); 7767 WebView* view = WebView::create(&viewClient);
7703 7768
7704 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7769 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7705 view->setMainFrame(remoteClient.frame()); 7770 view->setMainFrame(remoteClient.frame());
7706 7771
7707 FrameTestHelpers::TestWebFrameClient childFrameClient; 7772 FrameTestHelpers::TestWebFrameClient childFrameClient;
7708 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); 7773 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
7709 7774
7710 GestureEventTestWebViewClient childViewClient; 7775 GestureEventTestWebViewClient childViewClient;
7711 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame ); 7776 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame );
7712 7777
7713 view->resize(WebSize(1000, 1000)); 7778 view->resize(WebSize(1000, 1000));
7714 view->layout(); 7779 view->layout();
7715 7780
7716 widget->handleInputEvent(fatTap(20, 20)); 7781 widget->handleInputEvent(fatTap(20, 20));
7717 EXPECT_TRUE(childViewClient.didHandleGestureEvent()); 7782 EXPECT_TRUE(childViewClient.didHandleGestureEvent());
7718 7783
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
7918 7983
7919 7984
7920 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling) 7985 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling)
7921 { 7986 {
7922 FrameTestHelpers::TestWebViewClient viewClient; 7987 FrameTestHelpers::TestWebViewClient viewClient;
7923 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7988 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7924 WebView* view = WebView::create(&viewClient); 7989 WebView* view = WebView::create(&viewClient);
7925 view->setMainFrame(remoteClient.frame()); 7990 view->setMainFrame(remoteClient.frame());
7926 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame(); 7991 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame();
7927 7992
7928 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, nullptr); 7993 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties() );
7929 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, secondFrame); 7994 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerProperti es());
7930 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, secondFrame); 7995 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerPropertie s());
7931 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, nullptr); 7996 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties()) ;
7932 7997
7933 EXPECT_EQ(firstFrame, parent->firstChild()); 7998 EXPECT_EQ(firstFrame, parent->firstChild());
7934 EXPECT_EQ(nullptr, firstFrame->previousSibling()); 7999 EXPECT_EQ(nullptr, firstFrame->previousSibling());
7935 EXPECT_EQ(secondFrame, firstFrame->nextSibling()); 8000 EXPECT_EQ(secondFrame, firstFrame->nextSibling());
7936 8001
7937 EXPECT_EQ(firstFrame, secondFrame->previousSibling()); 8002 EXPECT_EQ(firstFrame, secondFrame->previousSibling());
7938 EXPECT_EQ(thirdFrame, secondFrame->nextSibling()); 8003 EXPECT_EQ(thirdFrame, secondFrame->nextSibling());
7939 8004
7940 EXPECT_EQ(secondFrame, thirdFrame->previousSibling()); 8005 EXPECT_EQ(secondFrame, thirdFrame->previousSibling());
7941 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling()); 8006 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling());
(...skipping 14 matching lines...) Expand all
7956 { 8021 {
7957 FrameTestHelpers::TestWebViewClient viewClient; 8022 FrameTestHelpers::TestWebViewClient viewClient;
7958 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 8023 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7959 WebView* view = WebView::create(&viewClient); 8024 WebView* view = WebView::create(&viewClient);
7960 view->settings()->setJavaScriptEnabled(true); 8025 view->settings()->setJavaScriptEnabled(true);
7961 view->setMainFrame(remoteClient.frame()); 8026 view->setMainFrame(remoteClient.frame());
7962 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); 8027 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
7963 root->setReplicatedOrigin(SecurityOrigin::createUnique()); 8028 root->setReplicatedOrigin(SecurityOrigin::createUnique());
7964 8029
7965 FrameTestHelpers::TestWebFrameClient localFrameClient; 8030 FrameTestHelpers::TestWebFrameClient localFrameClient;
7966 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr); 8031 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, WebFrameOwnerPropertie s());
7967 8032
7968 // Finally, make sure an embedder triggered load in the local frame swapped 8033 // Finally, make sure an embedder triggered load in the local frame swapped
7969 // back in works. 8034 // back in works.
7970 registerMockedHttpURLLoad("send_beacon.html"); 8035 registerMockedHttpURLLoad("send_beacon.html");
7971 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon() 8036 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon()
7972 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html"); 8037 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html");
7973 8038
7974 view->close(); 8039 view->close();
7975 } 8040 }
7976 8041
7977 // See https://crbug.com/525285. 8042 // See https://crbug.com/525285.
7978 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me) 8043 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me)
7979 { 8044 {
7980 FrameTestHelpers::TestWebViewClient viewClient; 8045 FrameTestHelpers::TestWebViewClient viewClient;
7981 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 8046 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7982 WebView* view = WebView::create(&viewClient); 8047 WebView* view = WebView::create(&viewClient);
7983 view->setMainFrame(remoteClient.frame()); 8048 view->setMainFrame(remoteClient.frame());
7984 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); 8049 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame();
7985 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); 8050 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique());
7986 8051
7987 FrameTestHelpers::TestWebFrameClient localFrameClient; 8052 FrameTestHelpers::TestWebFrameClient localFrameClient;
7988 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr); 8053 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr, WebFrameOwnerProperties());
7989 8054
7990 // Do a remote-to-local swap of the top frame. 8055 // Do a remote-to-local swap of the top frame.
7991 FrameTestHelpers::TestWebFrameClient localClient; 8056 FrameTestHelpers::TestWebFrameClient localClient;
7992 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient); 8057 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient);
7993 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N one); 8058 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N one, WebFrameOwnerProperties());
7994 remoteRoot->swap(localRoot); 8059 remoteRoot->swap(localRoot);
7995 8060
7996 // Load a page with a child frame in the new root to make sure this doesn't 8061 // Load a page with a child frame in the new root to make sure this doesn't
7997 // crash when the child frame invokes setCoreFrame. 8062 // crash when the child frame invokes setCoreFrame.
7998 registerMockedHttpURLLoad("single_iframe.html"); 8063 registerMockedHttpURLLoad("single_iframe.html");
7999 registerMockedHttpURLLoad("visible_iframe.html"); 8064 registerMockedHttpURLLoad("visible_iframe.html");
8000 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); 8065 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html");
8001 8066
8002 view->close(); 8067 view->close();
8003 } 8068 }
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
8310 EXPECT_TRUE(resource); 8375 EXPECT_TRUE(resource);
8311 EXPECT_NE(0, resource->loadFinishTime()); 8376 EXPECT_NE(0, resource->loadFinishTime());
8312 8377
8313 DocumentLoader* loader = document->loader(); 8378 DocumentLoader* loader = document->loader();
8314 8379
8315 EXPECT_TRUE(loader); 8380 EXPECT_TRUE(loader);
8316 EXPECT_EQ(loader->timing().responseEnd(), resource->loadFinishTime()); 8381 EXPECT_EQ(loader->timing().responseEnd(), resource->loadFinishTime());
8317 } 8382 }
8318 8383
8319 } // namespace blink 8384 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698