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 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1599 | 1599 |
1600 ASSERT_NE(nullptr, element); | 1600 ASSERT_NE(nullptr, element); |
1601 EXPECT_EQ(String("oldValue"), element->innerText()); | 1601 EXPECT_EQ(String("oldValue"), element->innerText()); |
1602 | 1602 |
1603 PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPoint, hitPoint, IntSize(0, 0), 0, PlatformEvent::NoModifiers); | 1603 PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPoint, hitPoint, IntSize(0, 0), 0, PlatformEvent::NoModifiers); |
1604 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handle GestureEvent(gestureEvent); | 1604 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handle GestureEvent(gestureEvent); |
1605 // when pressed, the button changes its own text to "updatedValue" | 1605 // when pressed, the button changes its own text to "updatedValue" |
1606 EXPECT_EQ(String("updatedValue"), element->innerText()); | 1606 EXPECT_EQ(String("updatedValue"), element->innerText()); |
1607 } | 1607 } |
1608 | 1608 |
1609 TEST_F(WebFrameTest, FrameOwnerPropertiesMargin) | |
1610 { | |
1611 FrameTestHelpers::TestWebViewClient viewClient; | |
1612 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | |
1613 WebView* view = WebView::create(&viewClient); | |
1614 view->settings()->setJavaScriptEnabled(true); | |
1615 view->setMainFrame(remoteClient.frame()); | |
1616 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); | |
1617 root->setReplicatedOrigin(SecurityOrigin::createUnique()); | |
1618 | |
1619 WebFrameOwnerProperties properties; | |
1620 properties.marginWidth = 11; | |
1621 properties.marginHeight = 22; | |
1622 FrameTestHelpers::TestWebFrameClient localFrameClient; | |
1623 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties); | |
1624 | |
1625 registerMockedHttpURLLoad("frame_owner_properties.html"); | |
1626 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html"); | |
1627 | |
1628 { | |
1629 // Check if the LocalFrame has seen the marginwidth and marginheight | |
1630 // properties. | |
1631 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | |
1632 | |
1633 v8::Local<v8::Value> marginWidthResult = localFrame->executeScriptAndRet urnValue(WebScriptSource("parseInt(document.body.getAttribute('marginwidth') || '0');")); | |
dcheng
2015/10/15 06:06:53
Why || '0'?
lazyboy
2015/10/15 16:56:38
Removed this one since we expect non zero or not u
| |
1634 ASSERT_TRUE(marginWidthResult->IsInt32()); | |
1635 EXPECT_EQ(11, marginWidthResult.As<v8::Int32>()->Value()); | |
1636 | |
1637 v8::Local<v8::Value> marginHeightResult = localFrame->executeScriptAndRe turnValue(WebScriptSource("parseInt(document.body.getAttribute('marginheight') | | '0');")); | |
1638 ASSERT_TRUE(marginHeightResult->IsInt32()); | |
1639 EXPECT_EQ(22, marginHeightResult.As<v8::Int32>()->Value()); | |
1640 } | |
1641 | |
1642 FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView(); | |
1643 // Expect scrollbars to be enabled by default. | |
1644 EXPECT_NE(nullptr, frameView->horizontalScrollbar()); | |
1645 EXPECT_NE(nullptr, frameView->verticalScrollbar()); | |
1646 | |
1647 view->close(); | |
1648 } | |
1649 | |
1650 TEST_F(WebFrameTest, FrameOwnerPropertiesScrolling) | |
1651 { | |
1652 FrameTestHelpers::TestWebViewClient viewClient; | |
1653 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | |
1654 WebView* view = WebView::create(&viewClient); | |
1655 view->settings()->setJavaScriptEnabled(true); | |
1656 view->setMainFrame(remoteClient.frame()); | |
1657 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); | |
1658 root->setReplicatedOrigin(SecurityOrigin::createUnique()); | |
1659 | |
1660 WebFrameOwnerProperties properties; | |
1661 // Turn off scrolling in the subframe. | |
1662 properties.scrollingMode = WebFrameOwnerProperties::ScrollingMode::AlwaysOff ; | |
1663 FrameTestHelpers::TestWebFrameClient localFrameClient; | |
1664 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties); | |
1665 | |
1666 registerMockedHttpURLLoad("frame_owner_properties.html"); | |
1667 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html"); | |
1668 | |
1669 { | |
1670 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | |
1671 | |
1672 v8::Local<v8::Value> marginWidthResult = localFrame->executeScriptAndRet urnValue(WebScriptSource("parseInt(document.body.getAttribute('marginwidth') || '0');")); | |
dcheng
2015/10/15 06:06:53
Ditto, why || '0'? We can test if the return value
lazyboy
2015/10/15 16:56:38
Technically margin of 0 can come from Number(0) an
dcheng
2015/10/15 22:07:46
I don't think I follow. In the test, it should be
dcheng
2015/10/15 22:20:17
Also... since this is a unit test, maybe just use
lazyboy
2015/10/15 23:00:52
Yes, it is deterministic in this test. What I want
lazyboy
2015/10/15 23:00:52
That is just cool! Thanks.
Done.
| |
1673 ASSERT_TRUE(marginWidthResult->IsInt32()); | |
1674 EXPECT_EQ(0, marginWidthResult.As<v8::Int32>()->Value()); | |
1675 | |
1676 v8::Local<v8::Value> marginHeightResult = localFrame->executeScriptAndRe turnValue(WebScriptSource("parseInt(document.body.getAttribute('marginheight') | | '0');")); | |
1677 ASSERT_TRUE(marginHeightResult->IsInt32()); | |
1678 EXPECT_EQ(0, marginHeightResult.As<v8::Int32>()->Value()); | |
1679 } | |
1680 | |
1681 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w(); | |
1682 EXPECT_EQ(nullptr, frameView->horizontalScrollbar()); | |
1683 EXPECT_EQ(nullptr, frameView->verticalScrollbar()); | |
1684 | |
1685 view->close(); | |
1686 } | |
1687 | |
1688 | |
1609 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations ) | 1689 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations ) |
1610 { | 1690 { |
1611 UseMockScrollbarSettings mockScrollbarSettings; | 1691 UseMockScrollbarSettings mockScrollbarSettings; |
1612 registerMockedHttpURLLoad("200-by-300.html"); | 1692 registerMockedHttpURLLoad("200-by-300.html"); |
1613 registerMockedHttpURLLoad("large-div.html"); | 1693 registerMockedHttpURLLoad("large-div.html"); |
1614 | 1694 |
1615 FixedLayoutTestWebViewClient client; | 1695 FixedLayoutTestWebViewClient client; |
1616 client.m_screenInfo.deviceScaleFactor = 1; | 1696 client.m_screenInfo.deviceScaleFactor = 1; |
1617 int viewportWidth = 640; | 1697 int viewportWidth = 640; |
1618 int viewportHeight = 480; | 1698 int viewportHeight = 480; |
(...skipping 4301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5920 , m_willSendRequestCallCount(0) | 6000 , m_willSendRequestCallCount(0) |
5921 , m_childFrameCreationCount(0) | 6001 , m_childFrameCreationCount(0) |
5922 { | 6002 { |
5923 } | 6003 } |
5924 | 6004 |
5925 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; } | 6005 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; } |
5926 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } | 6006 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } |
5927 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } | 6007 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } |
5928 int childFrameCreationCount() const { return m_childFrameCreationCount; } | 6008 int childFrameCreationCount() const { return m_childFrameCreationCount; } |
5929 | 6009 |
5930 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, WebSandboxFlags) | 6010 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, WebSandboxFlags, const WebFrameOwnerProperties& frameOwn erProperties) |
5931 { | 6011 { |
5932 ASSERT(m_childClient); | 6012 ASSERT(m_childClient); |
5933 m_childFrameCreationCount++; | 6013 m_childFrameCreationCount++; |
5934 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); | 6014 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); |
5935 parent->appendChild(frame); | 6015 parent->appendChild(frame); |
5936 return frame; | 6016 return frame; |
5937 } | 6017 } |
5938 | 6018 |
5939 virtual void didStartLoading(bool toDifferentDocument) | 6019 virtual void didStartLoading(bool toDifferentDocument) |
5940 { | 6020 { |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6309 // After commit, there is. | 6389 // After commit, there is. |
6310 HistoryItem* item = mainFrameLoader.currentItem(); | 6390 HistoryItem* item = mainFrameLoader.currentItem(); |
6311 ASSERT_TRUE(item); | 6391 ASSERT_TRUE(item); |
6312 EXPECT_EQ(WTF::String(url.data()), item->urlString()); | 6392 EXPECT_EQ(WTF::String(url.data()), item->urlString()); |
6313 } | 6393 } |
6314 | 6394 |
6315 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { | 6395 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { |
6316 public: | 6396 public: |
6317 FailCreateChildFrame() : m_callCount(0) { } | 6397 FailCreateChildFrame() : m_callCount(0) { } |
6318 | 6398 |
6319 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, WebSandboxFlags sandboxFlags) override | 6399 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, WebSandboxFlags sandboxFlags, const WebFrameOwnerPrope rties& frameOwnerProperties) override |
6320 { | 6400 { |
6321 ++m_callCount; | 6401 ++m_callCount; |
6322 return 0; | 6402 return 0; |
6323 } | 6403 } |
6324 | 6404 |
6325 int callCount() const { return m_callCount; } | 6405 int callCount() const { return m_callCount; } |
6326 | 6406 |
6327 private: | 6407 private: |
6328 int m_callCount; | 6408 int m_callCount; |
6329 }; | 6409 }; |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7007 // doesn't leave behind dangling pointers. | 7087 // doesn't leave behind dangling pointers. |
7008 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame) | 7088 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame) |
7009 { | 7089 { |
7010 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o | 7090 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o |
7011 // write tests with a top-level remote frame. | 7091 // write tests with a top-level remote frame. |
7012 FrameTestHelpers::TestWebViewClient viewClient; | 7092 FrameTestHelpers::TestWebViewClient viewClient; |
7013 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7093 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7014 WebView* view = WebView::create(&viewClient); | 7094 WebView* view = WebView::create(&viewClient); |
7015 view->setMainFrame(remoteClient.frame()); | 7095 view->setMainFrame(remoteClient.frame()); |
7016 FrameTestHelpers::TestWebFrameClient childFrameClient; | 7096 FrameTestHelpers::TestWebFrameClient childFrameClient; |
7017 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); | 7097 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties()); |
7018 | 7098 |
7019 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d. | 7099 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d. |
7020 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame); | 7100 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame); |
7021 view->close(); | 7101 view->close(); |
7022 childCoreFrame.clear(); | 7102 childCoreFrame.clear(); |
7023 } | 7103 } |
7024 | 7104 |
7025 class WebFrameSwapTest : public WebFrameTest { | 7105 class WebFrameSwapTest : public WebFrameTest { |
7026 protected: | 7106 protected: |
7027 WebFrameSwapTest() | 7107 WebFrameSwapTest() |
(...skipping 14 matching lines...) Expand all Loading... | |
7042 FrameTestHelpers::WebViewHelper m_webViewHelper; | 7122 FrameTestHelpers::WebViewHelper m_webViewHelper; |
7043 }; | 7123 }; |
7044 | 7124 |
7045 TEST_F(WebFrameSwapTest, SwapMainFrame) | 7125 TEST_F(WebFrameSwapTest, SwapMainFrame) |
7046 { | 7126 { |
7047 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr); | 7127 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr); |
7048 mainFrame()->swap(remoteFrame); | 7128 mainFrame()->swap(remoteFrame); |
7049 | 7129 |
7050 FrameTestHelpers::TestWebFrameClient client; | 7130 FrameTestHelpers::TestWebFrameClient client; |
7051 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); | 7131 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); |
7052 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); | 7132 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties()); |
7053 remoteFrame->swap(localFrame); | 7133 remoteFrame->swap(localFrame); |
7054 | 7134 |
7055 // Finally, make sure an embedder triggered load in the local frame swapped | 7135 // Finally, make sure an embedder triggered load in the local frame swapped |
7056 // back in works. | 7136 // back in works. |
7057 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7137 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7058 std::string content = localFrame->contentAsText(1024).utf8(); | 7138 std::string content = localFrame->contentAsText(1024).utf8(); |
7059 EXPECT_EQ("hello", content); | 7139 EXPECT_EQ("hello", content); |
7060 | 7140 |
7061 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7141 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7062 // TestWebFrameClient. | 7142 // TestWebFrameClient. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7106 } | 7186 } |
7107 | 7187 |
7108 TEST_F(WebFrameSwapTest, SwapFirstChild) | 7188 TEST_F(WebFrameSwapTest, SwapFirstChild) |
7109 { | 7189 { |
7110 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7190 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7111 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); | 7191 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); |
7112 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame ); | 7192 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame ); |
7113 | 7193 |
7114 FrameTestHelpers::TestWebFrameClient client; | 7194 FrameTestHelpers::TestWebFrameClient client; |
7115 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); | 7195 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); |
7116 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); | 7196 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties()); |
7117 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ; | 7197 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ; |
7118 | 7198 |
7119 // FIXME: This almost certainly fires more load events on the iframe element | 7199 // FIXME: This almost certainly fires more load events on the iframe element |
7120 // than it should. | 7200 // than it should. |
7121 // Finally, make sure an embedder triggered load in the local frame swapped | 7201 // Finally, make sure an embedder triggered load in the local frame swapped |
7122 // back in works. | 7202 // back in works. |
7123 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7203 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7124 std::string content = localFrame->contentAsText(1024).utf8(); | 7204 std::string content = localFrame->contentAsText(1024).utf8(); |
7125 EXPECT_EQ("hello", content); | 7205 EXPECT_EQ("hello", content); |
7126 | 7206 |
(...skipping 18 matching lines...) Expand all Loading... | |
7145 } | 7225 } |
7146 | 7226 |
7147 TEST_F(WebFrameSwapTest, SwapMiddleChild) | 7227 TEST_F(WebFrameSwapTest, SwapMiddleChild) |
7148 { | 7228 { |
7149 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7229 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7150 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); | 7230 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); |
7151 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e); | 7231 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e); |
7152 | 7232 |
7153 FrameTestHelpers::TestWebFrameClient client; | 7233 FrameTestHelpers::TestWebFrameClient client; |
7154 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); | 7234 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); |
7155 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); | 7235 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties()); |
7156 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame ); | 7236 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame ); |
7157 | 7237 |
7158 // FIXME: This almost certainly fires more load events on the iframe element | 7238 // FIXME: This almost certainly fires more load events on the iframe element |
7159 // than it should. | 7239 // than it should. |
7160 // Finally, make sure an embedder triggered load in the local frame swapped | 7240 // Finally, make sure an embedder triggered load in the local frame swapped |
7161 // back in works. | 7241 // back in works. |
7162 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7242 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7163 std::string content = localFrame->contentAsText(1024).utf8(); | 7243 std::string content = localFrame->contentAsText(1024).utf8(); |
7164 EXPECT_EQ("hello", content); | 7244 EXPECT_EQ("hello", content); |
7165 | 7245 |
(...skipping 15 matching lines...) Expand all Loading... | |
7181 } | 7261 } |
7182 | 7262 |
7183 TEST_F(WebFrameSwapTest, SwapLastChild) | 7263 TEST_F(WebFrameSwapTest, SwapLastChild) |
7184 { | 7264 { |
7185 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7265 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7186 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); | 7266 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); |
7187 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ; | 7267 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ; |
7188 | 7268 |
7189 FrameTestHelpers::TestWebFrameClient client; | 7269 FrameTestHelpers::TestWebFrameClient client; |
7190 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); | 7270 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); |
7191 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); | 7271 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties()); |
7192 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); | 7272 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); |
7193 | 7273 |
7194 // FIXME: This almost certainly fires more load events on the iframe element | 7274 // FIXME: This almost certainly fires more load events on the iframe element |
7195 // than it should. | 7275 // than it should. |
7196 // Finally, make sure an embedder triggered load in the local frame swapped | 7276 // Finally, make sure an embedder triggered load in the local frame swapped |
7197 // back in works. | 7277 // back in works. |
7198 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7278 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7199 std::string content = localFrame->contentAsText(1024).utf8(); | 7279 std::string content = localFrame->contentAsText(1024).utf8(); |
7200 EXPECT_EQ("hello", content); | 7280 EXPECT_EQ("hello", content); |
7201 | 7281 |
(...skipping 24 matching lines...) Expand all Loading... | |
7226 | 7306 |
7227 targetFrame = mainFrame()->firstChild()->nextSibling(); | 7307 targetFrame = mainFrame()->firstChild()->nextSibling(); |
7228 EXPECT_TRUE(targetFrame); | 7308 EXPECT_TRUE(targetFrame); |
7229 | 7309 |
7230 // Create child frames in the target frame before testing the swap. | 7310 // Create child frames in the target frame before testing the swap. |
7231 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; | 7311 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; |
7232 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2); | 7312 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2); |
7233 | 7313 |
7234 FrameTestHelpers::TestWebFrameClient client; | 7314 FrameTestHelpers::TestWebFrameClient client; |
7235 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); | 7315 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); |
7236 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); | 7316 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties()); |
7237 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); | 7317 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); |
7238 | 7318 |
7239 // FIXME: This almost certainly fires more load events on the iframe element | 7319 // FIXME: This almost certainly fires more load events on the iframe element |
7240 // than it should. | 7320 // than it should. |
7241 // Finally, make sure an embedder triggered load in the local frame swapped | 7321 // Finally, make sure an embedder triggered load in the local frame swapped |
7242 // back in works. | 7322 // back in works. |
7243 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7323 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7244 std::string content = localFrame->contentAsText(1024).utf8(); | 7324 std::string content = localFrame->contentAsText(1024).utf8(); |
7245 EXPECT_EQ("hello", content); | 7325 EXPECT_EQ("hello", content); |
7246 | 7326 |
(...skipping 23 matching lines...) Expand all Loading... | |
7270 "document.querySelector('#frame2').contentWindow;")); | 7350 "document.querySelector('#frame2').contentWindow;")); |
7271 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow)); | 7351 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow)); |
7272 // Check that its view is consistent with the world. | 7352 // Check that its view is consistent with the world. |
7273 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource( | 7353 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource( |
7274 "document.querySelector('#frame2').contentWindow.top;")); | 7354 "document.querySelector('#frame2').contentWindow.top;")); |
7275 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); | 7355 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); |
7276 | 7356 |
7277 // Now check that remote -> local works too, since it goes through a differe nt code path. | 7357 // Now check that remote -> local works too, since it goes through a differe nt code path. |
7278 FrameTestHelpers::TestWebFrameClient client; | 7358 FrameTestHelpers::TestWebFrameClient client; |
7279 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); | 7359 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); |
7280 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); | 7360 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties()); |
7281 remoteFrame->swap(localFrame); | 7361 remoteFrame->swap(localFrame); |
7282 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( WebScriptSource( | 7362 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( WebScriptSource( |
7283 "document.querySelector('#frame2').contentWindow;")); | 7363 "document.querySelector('#frame2').contentWindow;")); |
7284 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); | 7364 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); |
7285 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource( | 7365 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource( |
7286 "document.querySelector('#frame2').contentWindow.top;")); | 7366 "document.querySelector('#frame2').contentWindow.top;")); |
7287 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); | 7367 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); |
7288 | 7368 |
7289 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7369 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7290 // TestWebFrameClient. | 7370 // TestWebFrameClient. |
(...skipping 13 matching lines...) Expand all Loading... | |
7304 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7384 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7305 WebRemoteFrame* remoteFrame = remoteClient.frame(); | 7385 WebRemoteFrame* remoteFrame = remoteClient.frame(); |
7306 mainFrame()->lastChild()->swap(remoteFrame); | 7386 mainFrame()->lastChild()->swap(remoteFrame); |
7307 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); | 7387 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
7308 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource("saved.top")); | 7388 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource("saved.top")); |
7309 EXPECT_TRUE(remoteWindowTop->IsObject()); | 7389 EXPECT_TRUE(remoteWindowTop->IsObject()); |
7310 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); | 7390 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); |
7311 | 7391 |
7312 FrameTestHelpers::TestWebFrameClient client; | 7392 FrameTestHelpers::TestWebFrameClient client; |
7313 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); | 7393 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); |
7314 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); | 7394 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties()); |
7315 remoteFrame->swap(localFrame); | 7395 remoteFrame->swap(localFrame); |
7316 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource("saved.top")); | 7396 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource("saved.top")); |
7317 EXPECT_TRUE(localWindowTop->IsObject()); | 7397 EXPECT_TRUE(localWindowTop->IsObject()); |
7318 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); | 7398 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); |
7319 | 7399 |
7320 reset(); | 7400 reset(); |
7321 } | 7401 } |
7322 | 7402 |
7323 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) | 7403 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) |
7324 { | 7404 { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7375 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable) | 7455 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable) |
7376 { | 7456 { |
7377 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 7457 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
7378 | 7458 |
7379 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7459 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7380 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); | 7460 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); |
7381 mainFrame()->swap(remoteParentFrame); | 7461 mainFrame()->swap(remoteParentFrame); |
7382 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); | 7462 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
7383 | 7463 |
7384 FrameTestHelpers::TestWebFrameClient childFrameClient; | 7464 FrameTestHelpers::TestWebFrameClient childFrameClient; |
7385 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); | 7465 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties()); |
7386 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); | 7466 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); |
7387 | 7467 |
7388 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window")); | 7468 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window")); |
7389 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]")); | 7469 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]")); |
7390 EXPECT_TRUE(childOfRemoteParent->IsObject()); | 7470 EXPECT_TRUE(childOfRemoteParent->IsObject()); |
7391 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); | 7471 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); |
7392 | 7472 |
7393 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length")); | 7473 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length")); |
7394 ASSERT_TRUE(windowLength->IsInt32()); | 7474 ASSERT_TRUE(windowLength->IsInt32()); |
7395 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); | 7475 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); |
7396 | 7476 |
7397 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. | 7477 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. |
7398 reset(); | 7478 reset(); |
7399 } | 7479 } |
7400 | 7480 |
7401 // Check that frames with a remote parent don't crash while accessing window.fra meElement. | 7481 // Check that frames with a remote parent don't crash while accessing window.fra meElement. |
7402 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) | 7482 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) |
7403 { | 7483 { |
7404 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 7484 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
7405 | 7485 |
7406 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7486 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7407 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); | 7487 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); |
7408 mainFrame()->swap(remoteParentFrame); | 7488 mainFrame()->swap(remoteParentFrame); |
7409 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); | 7489 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
7410 | 7490 |
7411 FrameTestHelpers::TestWebFrameClient childFrameClient; | 7491 FrameTestHelpers::TestWebFrameClient childFrameClient; |
7412 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); | 7492 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties()); |
7413 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); | 7493 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); |
7414 | 7494 |
7415 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement")); | 7495 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement")); |
7416 // frameElement shouldn't be accessible cross-origin. | 7496 // frameElement shouldn't be accessible cross-origin. |
7417 EXPECT_TRUE(frameElement.IsEmpty()); | 7497 EXPECT_TRUE(frameElement.IsEmpty()); |
7418 | 7498 |
7419 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. | 7499 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. |
7420 reset(); | 7500 reset(); |
7421 } | 7501 } |
7422 | 7502 |
(...skipping 26 matching lines...) Expand all Loading... | |
7449 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7529 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7450 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); | 7530 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); |
7451 WebFrame* targetFrame = mainFrame()->firstChild(); | 7531 WebFrame* targetFrame = mainFrame()->firstChild(); |
7452 ASSERT_TRUE(targetFrame); | 7532 ASSERT_TRUE(targetFrame); |
7453 targetFrame->swap(remoteFrame); | 7533 targetFrame->swap(remoteFrame); |
7454 ASSERT_TRUE(mainFrame()->firstChild()); | 7534 ASSERT_TRUE(mainFrame()->firstChild()); |
7455 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); | 7535 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); |
7456 | 7536 |
7457 RemoteToLocalSwapWebFrameClient client(remoteFrame); | 7537 RemoteToLocalSwapWebFrameClient client(remoteFrame); |
7458 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); | 7538 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); |
7459 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); | 7539 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties()); |
7460 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7540 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7461 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); | 7541 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); |
7462 | 7542 |
7463 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7543 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7464 // TestWebFrameClient. | 7544 // TestWebFrameClient. |
7465 reset(); | 7545 reset(); |
7466 remoteFrame->close(); | 7546 remoteFrame->close(); |
7467 } | 7547 } |
7468 | 7548 |
7469 // The commit type should be Standard if we are swapping a RemoteFrame to a | 7549 // The commit type should be Standard if we are swapping a RemoteFrame to a |
7470 // LocalFrame after commits have already happened in the frame. The browser | 7550 // LocalFrame after commits have already happened in the frame. The browser |
7471 // process will inform us via setCommittedFirstRealLoad. | 7551 // process will inform us via setCommittedFirstRealLoad. |
7472 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) | 7552 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) |
7473 { | 7553 { |
7474 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7554 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7475 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); | 7555 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); |
7476 WebFrame* targetFrame = mainFrame()->firstChild(); | 7556 WebFrame* targetFrame = mainFrame()->firstChild(); |
7477 ASSERT_TRUE(targetFrame); | 7557 ASSERT_TRUE(targetFrame); |
7478 targetFrame->swap(remoteFrame); | 7558 targetFrame->swap(remoteFrame); |
7479 ASSERT_TRUE(mainFrame()->firstChild()); | 7559 ASSERT_TRUE(mainFrame()->firstChild()); |
7480 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); | 7560 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); |
7481 | 7561 |
7482 RemoteToLocalSwapWebFrameClient client(remoteFrame); | 7562 RemoteToLocalSwapWebFrameClient client(remoteFrame); |
7483 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); | 7563 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); |
7484 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None); | 7564 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags: :None, WebFrameOwnerProperties()); |
7485 localFrame->setCommittedFirstRealLoad(); | 7565 localFrame->setCommittedFirstRealLoad(); |
7486 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7566 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7487 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); | 7567 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); |
7488 | 7568 |
7489 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7569 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7490 // TestWebFrameClient. | 7570 // TestWebFrameClient. |
7491 reset(); | 7571 reset(); |
7492 remoteFrame->close(); | 7572 remoteFrame->close(); |
7493 } | 7573 } |
7494 | 7574 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7612 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient; | 7692 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient; |
7613 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame(); | 7693 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame(); |
7614 popupView->setMainFrame(popupRemoteFrame); | 7694 popupView->setMainFrame(popupRemoteFrame); |
7615 popupRemoteFrame->setOpener(mainFrame); | 7695 popupRemoteFrame->setOpener(mainFrame); |
7616 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h ttp://foo.com")); | 7696 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h ttp://foo.com")); |
7617 EXPECT_FALSE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->s ecurityOrigin())); | 7697 EXPECT_FALSE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->s ecurityOrigin())); |
7618 | 7698 |
7619 // Do a remote-to-local swap in the popup. | 7699 // Do a remote-to-local swap in the popup. |
7620 FrameTestHelpers::TestWebFrameClient popupLocalClient; | 7700 FrameTestHelpers::TestWebFrameClient popupLocalClient; |
7621 WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Doc ument, &popupLocalClient); | 7701 WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Doc ument, &popupLocalClient); |
7622 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan dboxFlags::None); | 7702 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan dboxFlags::None, WebFrameOwnerProperties()); |
7623 popupRemoteFrame->swap(popupLocalFrame); | 7703 popupRemoteFrame->swap(popupLocalFrame); |
7624 | 7704 |
7625 // The initial document created during the remote-to-local swap should have | 7705 // The initial document created during the remote-to-local swap should have |
7626 // inherited its opener's SecurityOrigin. | 7706 // inherited its opener's SecurityOrigin. |
7627 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se curityOrigin())); | 7707 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se curityOrigin())); |
7628 | 7708 |
7629 popupView->close(); | 7709 popupView->close(); |
7630 } | 7710 } |
7631 | 7711 |
7632 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 7712 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
(...skipping 17 matching lines...) Expand all Loading... | |
7650 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) | 7730 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) |
7651 { | 7731 { |
7652 FrameTestHelpers::TestWebViewClient viewClient; | 7732 FrameTestHelpers::TestWebViewClient viewClient; |
7653 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7733 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7654 WebView* view = WebView::create(&viewClient); | 7734 WebView* view = WebView::create(&viewClient); |
7655 view->setMainFrame(remoteClient.frame()); | 7735 view->setMainFrame(remoteClient.frame()); |
7656 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica tedOrigin(SecurityOrigin::create(toKURL(m_baseURL))); | 7736 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica tedOrigin(SecurityOrigin::create(toKURL(m_baseURL))); |
7657 | 7737 |
7658 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame. | 7738 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame. |
7659 CommitTypeWebFrameClient childFrameClient; | 7739 CommitTypeWebFrameClient childFrameClient; |
7660 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); | 7740 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties()); |
7661 registerMockedHttpURLLoad("foo.html"); | 7741 registerMockedHttpURLLoad("foo.html"); |
7662 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); | 7742 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); |
7663 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() ); | 7743 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() ); |
7664 view->close(); | 7744 view->close(); |
7665 } | 7745 } |
7666 | 7746 |
7667 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient { | 7747 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient { |
7668 public: | 7748 public: |
7669 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { } | 7749 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { } |
7670 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; } | 7750 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; } |
7671 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; } | 7751 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; } |
7672 | 7752 |
7673 private: | 7753 private: |
7674 bool m_didHandleGestureEvent; | 7754 bool m_didHandleGestureEvent; |
7675 }; | 7755 }; |
7676 | 7756 |
7677 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) | 7757 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) |
7678 { | 7758 { |
7679 FrameTestHelpers::TestWebViewClient viewClient; | 7759 FrameTestHelpers::TestWebViewClient viewClient; |
7680 WebView* view = WebView::create(&viewClient); | 7760 WebView* view = WebView::create(&viewClient); |
7681 | 7761 |
7682 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7762 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7683 view->setMainFrame(remoteClient.frame()); | 7763 view->setMainFrame(remoteClient.frame()); |
7684 | 7764 |
7685 FrameTestHelpers::TestWebFrameClient childFrameClient; | 7765 FrameTestHelpers::TestWebFrameClient childFrameClient; |
7686 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr); | 7766 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties()); |
7687 | 7767 |
7688 GestureEventTestWebViewClient childViewClient; | 7768 GestureEventTestWebViewClient childViewClient; |
7689 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame ); | 7769 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame ); |
7690 | 7770 |
7691 view->resize(WebSize(1000, 1000)); | 7771 view->resize(WebSize(1000, 1000)); |
7692 view->layout(); | 7772 view->layout(); |
7693 | 7773 |
7694 widget->handleInputEvent(fatTap(20, 20)); | 7774 widget->handleInputEvent(fatTap(20, 20)); |
7695 EXPECT_TRUE(childViewClient.didHandleGestureEvent()); | 7775 EXPECT_TRUE(childViewClient.didHandleGestureEvent()); |
7696 | 7776 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7896 | 7976 |
7897 | 7977 |
7898 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling) | 7978 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling) |
7899 { | 7979 { |
7900 FrameTestHelpers::TestWebViewClient viewClient; | 7980 FrameTestHelpers::TestWebViewClient viewClient; |
7901 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7981 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7902 WebView* view = WebView::create(&viewClient); | 7982 WebView* view = WebView::create(&viewClient); |
7903 view->setMainFrame(remoteClient.frame()); | 7983 view->setMainFrame(remoteClient.frame()); |
7904 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame(); | 7984 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame(); |
7905 | 7985 |
7906 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, nullptr); | 7986 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties() ); |
7907 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, secondFrame); | 7987 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType:: Document, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerProperti es()); |
7908 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, secondFrame); | 7988 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerPropertie s()); |
7909 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, nullptr); | 7989 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D ocument, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties()) ; |
7910 | 7990 |
7911 EXPECT_EQ(firstFrame, parent->firstChild()); | 7991 EXPECT_EQ(firstFrame, parent->firstChild()); |
7912 EXPECT_EQ(nullptr, firstFrame->previousSibling()); | 7992 EXPECT_EQ(nullptr, firstFrame->previousSibling()); |
7913 EXPECT_EQ(secondFrame, firstFrame->nextSibling()); | 7993 EXPECT_EQ(secondFrame, firstFrame->nextSibling()); |
7914 | 7994 |
7915 EXPECT_EQ(firstFrame, secondFrame->previousSibling()); | 7995 EXPECT_EQ(firstFrame, secondFrame->previousSibling()); |
7916 EXPECT_EQ(thirdFrame, secondFrame->nextSibling()); | 7996 EXPECT_EQ(thirdFrame, secondFrame->nextSibling()); |
7917 | 7997 |
7918 EXPECT_EQ(secondFrame, thirdFrame->previousSibling()); | 7998 EXPECT_EQ(secondFrame, thirdFrame->previousSibling()); |
7919 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling()); | 7999 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling()); |
(...skipping 14 matching lines...) Expand all Loading... | |
7934 { | 8014 { |
7935 FrameTestHelpers::TestWebViewClient viewClient; | 8015 FrameTestHelpers::TestWebViewClient viewClient; |
7936 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 8016 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7937 WebView* view = WebView::create(&viewClient); | 8017 WebView* view = WebView::create(&viewClient); |
7938 view->settings()->setJavaScriptEnabled(true); | 8018 view->settings()->setJavaScriptEnabled(true); |
7939 view->setMainFrame(remoteClient.frame()); | 8019 view->setMainFrame(remoteClient.frame()); |
7940 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); | 8020 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); |
7941 root->setReplicatedOrigin(SecurityOrigin::createUnique()); | 8021 root->setReplicatedOrigin(SecurityOrigin::createUnique()); |
7942 | 8022 |
7943 FrameTestHelpers::TestWebFrameClient localFrameClient; | 8023 FrameTestHelpers::TestWebFrameClient localFrameClient; |
7944 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr); | 8024 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, WebFrameOwnerPropertie s()); |
7945 | 8025 |
7946 // Finally, make sure an embedder triggered load in the local frame swapped | 8026 // Finally, make sure an embedder triggered load in the local frame swapped |
7947 // back in works. | 8027 // back in works. |
7948 registerMockedHttpURLLoad("send_beacon.html"); | 8028 registerMockedHttpURLLoad("send_beacon.html"); |
7949 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon() | 8029 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon() |
7950 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html"); | 8030 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html"); |
7951 | 8031 |
7952 view->close(); | 8032 view->close(); |
7953 } | 8033 } |
7954 | 8034 |
7955 // See https://crbug.com/525285. | 8035 // See https://crbug.com/525285. |
7956 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me) | 8036 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me) |
7957 { | 8037 { |
7958 FrameTestHelpers::TestWebViewClient viewClient; | 8038 FrameTestHelpers::TestWebViewClient viewClient; |
7959 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 8039 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7960 WebView* view = WebView::create(&viewClient); | 8040 WebView* view = WebView::create(&viewClient); |
7961 view->setMainFrame(remoteClient.frame()); | 8041 view->setMainFrame(remoteClient.frame()); |
7962 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); | 8042 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); |
7963 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); | 8043 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); |
7964 | 8044 |
7965 FrameTestHelpers::TestWebFrameClient localFrameClient; | 8045 FrameTestHelpers::TestWebFrameClient localFrameClient; |
7966 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr); | 8046 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr, WebFrameOwnerProperties()); |
7967 | 8047 |
7968 // Do a remote-to-local swap of the top frame. | 8048 // Do a remote-to-local swap of the top frame. |
7969 FrameTestHelpers::TestWebFrameClient localClient; | 8049 FrameTestHelpers::TestWebFrameClient localClient; |
7970 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient); | 8050 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient); |
7971 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N one); | 8051 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N one, WebFrameOwnerProperties()); |
7972 remoteRoot->swap(localRoot); | 8052 remoteRoot->swap(localRoot); |
7973 | 8053 |
7974 // Load a page with a child frame in the new root to make sure this doesn't | 8054 // Load a page with a child frame in the new root to make sure this doesn't |
7975 // crash when the child frame invokes setCoreFrame. | 8055 // crash when the child frame invokes setCoreFrame. |
7976 registerMockedHttpURLLoad("single_iframe.html"); | 8056 registerMockedHttpURLLoad("single_iframe.html"); |
7977 registerMockedHttpURLLoad("visible_iframe.html"); | 8057 registerMockedHttpURLLoad("visible_iframe.html"); |
7978 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); | 8058 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); |
7979 | 8059 |
7980 view->close(); | 8060 view->close(); |
7981 } | 8061 } |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8285 EXPECT_TRUE(resource); | 8365 EXPECT_TRUE(resource); |
8286 EXPECT_NE(0, resource->loadFinishTime()); | 8366 EXPECT_NE(0, resource->loadFinishTime()); |
8287 | 8367 |
8288 DocumentLoader* loader = document->loader(); | 8368 DocumentLoader* loader = document->loader(); |
8289 | 8369 |
8290 EXPECT_TRUE(loader); | 8370 EXPECT_TRUE(loader); |
8291 EXPECT_EQ(loader->timing().responseEnd(), resource->loadFinishTime()); | 8371 EXPECT_EQ(loader->timing().responseEnd(), resource->loadFinishTime()); |
8292 } | 8372 } |
8293 | 8373 |
8294 } // namespace blink | 8374 } // namespace blink |
OLD | NEW |