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