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 5904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5915 , m_willSendRequestCallCount(0) | 5915 , m_willSendRequestCallCount(0) |
5916 , m_childFrameCreationCount(0) | 5916 , m_childFrameCreationCount(0) |
5917 { | 5917 { |
5918 } | 5918 } |
5919 | 5919 |
5920 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child
Client = client; } | 5920 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child
Client = client; } |
5921 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } | 5921 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } |
5922 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } | 5922 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } |
5923 int childFrameCreationCount() const { return m_childFrameCreationCount; } | 5923 int childFrameCreationCount() const { return m_childFrameCreationCount; } |
5924 | 5924 |
5925 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s
cope, const WebString&, WebSandboxFlags) | 5925 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s
cope, const WebString&, WebSandboxFlags, const WebFrameOwnerProperties& frameOwn
erProperties) |
5926 { | 5926 { |
5927 ASSERT(m_childClient); | 5927 ASSERT(m_childClient); |
5928 m_childFrameCreationCount++; | 5928 m_childFrameCreationCount++; |
5929 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); | 5929 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); |
5930 parent->appendChild(frame); | 5930 parent->appendChild(frame); |
5931 return frame; | 5931 return frame; |
5932 } | 5932 } |
5933 | 5933 |
5934 virtual void didStartLoading(bool toDifferentDocument) | 5934 virtual void didStartLoading(bool toDifferentDocument) |
5935 { | 5935 { |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6304 // After commit, there is. | 6304 // After commit, there is. |
6305 HistoryItem* item = mainFrameLoader.currentItem(); | 6305 HistoryItem* item = mainFrameLoader.currentItem(); |
6306 ASSERT_TRUE(item); | 6306 ASSERT_TRUE(item); |
6307 EXPECT_EQ(WTF::String(url.data()), item->urlString()); | 6307 EXPECT_EQ(WTF::String(url.data()), item->urlString()); |
6308 } | 6308 } |
6309 | 6309 |
6310 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { | 6310 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { |
6311 public: | 6311 public: |
6312 FailCreateChildFrame() : m_callCount(0) { } | 6312 FailCreateChildFrame() : m_callCount(0) { } |
6313 | 6313 |
6314 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co
nst WebString& frameName, WebSandboxFlags sandboxFlags) override | 6314 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co
nst WebString& frameName, WebSandboxFlags sandboxFlags, const WebFrameOwnerPrope
rties& frameOwnerProperties) override |
6315 { | 6315 { |
6316 ++m_callCount; | 6316 ++m_callCount; |
6317 return 0; | 6317 return 0; |
6318 } | 6318 } |
6319 | 6319 |
6320 int callCount() const { return m_callCount; } | 6320 int callCount() const { return m_callCount; } |
6321 | 6321 |
6322 private: | 6322 private: |
6323 int m_callCount; | 6323 int m_callCount; |
6324 }; | 6324 }; |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6966 // doesn't leave behind dangling pointers. | 6966 // doesn't leave behind dangling pointers. |
6967 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame) | 6967 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame) |
6968 { | 6968 { |
6969 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t
o | 6969 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t
o |
6970 // write tests with a top-level remote frame. | 6970 // write tests with a top-level remote frame. |
6971 FrameTestHelpers::TestWebViewClient viewClient; | 6971 FrameTestHelpers::TestWebViewClient viewClient; |
6972 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 6972 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
6973 WebView* view = WebView::create(&viewClient); | 6973 WebView* view = WebView::create(&viewClient); |
6974 view->setMainFrame(remoteClient.frame()); | 6974 view->setMainFrame(remoteClient.frame()); |
6975 FrameTestHelpers::TestWebFrameClient childFrameClient; | 6975 FrameTestHelpers::TestWebFrameClient childFrameClient; |
6976 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc
alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient
, nullptr); | 6976 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc
alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient
, nullptr, WebFrameOwnerProperties()); |
6977 | 6977 |
6978 // Purposely keep the LocalFrame alive so it's the last thing to be destroye
d. | 6978 // Purposely keep the LocalFrame alive so it's the last thing to be destroye
d. |
6979 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame); | 6979 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame); |
6980 view->close(); | 6980 view->close(); |
6981 childCoreFrame.clear(); | 6981 childCoreFrame.clear(); |
6982 } | 6982 } |
6983 | 6983 |
6984 class WebFrameSwapTest : public WebFrameTest { | 6984 class WebFrameSwapTest : public WebFrameTest { |
6985 protected: | 6985 protected: |
6986 WebFrameSwapTest() | 6986 WebFrameSwapTest() |
(...skipping 14 matching lines...) Expand all Loading... |
7001 FrameTestHelpers::WebViewHelper m_webViewHelper; | 7001 FrameTestHelpers::WebViewHelper m_webViewHelper; |
7002 }; | 7002 }; |
7003 | 7003 |
7004 TEST_F(WebFrameSwapTest, SwapMainFrame) | 7004 TEST_F(WebFrameSwapTest, SwapMainFrame) |
7005 { | 7005 { |
7006 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, nullptr); | 7006 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, nullptr); |
7007 mainFrame()->swap(remoteFrame); | 7007 mainFrame()->swap(remoteFrame); |
7008 | 7008 |
7009 FrameTestHelpers::TestWebFrameClient client; | 7009 FrameTestHelpers::TestWebFrameClient client; |
7010 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); | 7010 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); |
7011 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None); | 7011 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None, WebFrameOwnerProperties()); |
7012 remoteFrame->swap(localFrame); | 7012 remoteFrame->swap(localFrame); |
7013 | 7013 |
7014 // Finally, make sure an embedder triggered load in the local frame swapped | 7014 // Finally, make sure an embedder triggered load in the local frame swapped |
7015 // back in works. | 7015 // back in works. |
7016 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7016 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7017 std::string content = localFrame->contentAsText(1024).utf8(); | 7017 std::string content = localFrame->contentAsText(1024).utf8(); |
7018 EXPECT_EQ("hello", content); | 7018 EXPECT_EQ("hello", content); |
7019 | 7019 |
7020 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7020 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7021 // TestWebFrameClient. | 7021 // TestWebFrameClient. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7065 } | 7065 } |
7066 | 7066 |
7067 TEST_F(WebFrameSwapTest, SwapFirstChild) | 7067 TEST_F(WebFrameSwapTest, SwapFirstChild) |
7068 { | 7068 { |
7069 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7069 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7070 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); | 7070 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); |
7071 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame
); | 7071 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame
); |
7072 | 7072 |
7073 FrameTestHelpers::TestWebFrameClient client; | 7073 FrameTestHelpers::TestWebFrameClient client; |
7074 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); | 7074 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); |
7075 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None); | 7075 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None, WebFrameOwnerProperties()); |
7076 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame)
; | 7076 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame)
; |
7077 | 7077 |
7078 // FIXME: This almost certainly fires more load events on the iframe element | 7078 // FIXME: This almost certainly fires more load events on the iframe element |
7079 // than it should. | 7079 // than it should. |
7080 // Finally, make sure an embedder triggered load in the local frame swapped | 7080 // Finally, make sure an embedder triggered load in the local frame swapped |
7081 // back in works. | 7081 // back in works. |
7082 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7082 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7083 std::string content = localFrame->contentAsText(1024).utf8(); | 7083 std::string content = localFrame->contentAsText(1024).utf8(); |
7084 EXPECT_EQ("hello", content); | 7084 EXPECT_EQ("hello", content); |
7085 | 7085 |
(...skipping 18 matching lines...) Expand all Loading... |
7104 } | 7104 } |
7105 | 7105 |
7106 TEST_F(WebFrameSwapTest, SwapMiddleChild) | 7106 TEST_F(WebFrameSwapTest, SwapMiddleChild) |
7107 { | 7107 { |
7108 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7108 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7109 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); | 7109 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); |
7110 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram
e); | 7110 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram
e); |
7111 | 7111 |
7112 FrameTestHelpers::TestWebFrameClient client; | 7112 FrameTestHelpers::TestWebFrameClient client; |
7113 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); | 7113 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); |
7114 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None); | 7114 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None, WebFrameOwnerProperties()); |
7115 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame
); | 7115 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame
); |
7116 | 7116 |
7117 // FIXME: This almost certainly fires more load events on the iframe element | 7117 // FIXME: This almost certainly fires more load events on the iframe element |
7118 // than it should. | 7118 // than it should. |
7119 // Finally, make sure an embedder triggered load in the local frame swapped | 7119 // Finally, make sure an embedder triggered load in the local frame swapped |
7120 // back in works. | 7120 // back in works. |
7121 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7121 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7122 std::string content = localFrame->contentAsText(1024).utf8(); | 7122 std::string content = localFrame->contentAsText(1024).utf8(); |
7123 EXPECT_EQ("hello", content); | 7123 EXPECT_EQ("hello", content); |
7124 | 7124 |
(...skipping 15 matching lines...) Expand all Loading... |
7140 } | 7140 } |
7141 | 7141 |
7142 TEST_F(WebFrameSwapTest, SwapLastChild) | 7142 TEST_F(WebFrameSwapTest, SwapLastChild) |
7143 { | 7143 { |
7144 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7144 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7145 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); | 7145 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); |
7146 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame)
; | 7146 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame)
; |
7147 | 7147 |
7148 FrameTestHelpers::TestWebFrameClient client; | 7148 FrameTestHelpers::TestWebFrameClient client; |
7149 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); | 7149 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); |
7150 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None); | 7150 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None, WebFrameOwnerProperties()); |
7151 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); | 7151 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); |
7152 | 7152 |
7153 // FIXME: This almost certainly fires more load events on the iframe element | 7153 // FIXME: This almost certainly fires more load events on the iframe element |
7154 // than it should. | 7154 // than it should. |
7155 // Finally, make sure an embedder triggered load in the local frame swapped | 7155 // Finally, make sure an embedder triggered load in the local frame swapped |
7156 // back in works. | 7156 // back in works. |
7157 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7157 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7158 std::string content = localFrame->contentAsText(1024).utf8(); | 7158 std::string content = localFrame->contentAsText(1024).utf8(); |
7159 EXPECT_EQ("hello", content); | 7159 EXPECT_EQ("hello", content); |
7160 | 7160 |
(...skipping 24 matching lines...) Expand all Loading... |
7185 | 7185 |
7186 targetFrame = mainFrame()->firstChild()->nextSibling(); | 7186 targetFrame = mainFrame()->firstChild()->nextSibling(); |
7187 EXPECT_TRUE(targetFrame); | 7187 EXPECT_TRUE(targetFrame); |
7188 | 7188 |
7189 // Create child frames in the target frame before testing the swap. | 7189 // Create child frames in the target frame before testing the swap. |
7190 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; | 7190 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; |
7191 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco
peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2); | 7191 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco
peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2); |
7192 | 7192 |
7193 FrameTestHelpers::TestWebFrameClient client; | 7193 FrameTestHelpers::TestWebFrameClient client; |
7194 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); | 7194 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); |
7195 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None); | 7195 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None, WebFrameOwnerProperties()); |
7196 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); | 7196 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); |
7197 | 7197 |
7198 // FIXME: This almost certainly fires more load events on the iframe element | 7198 // FIXME: This almost certainly fires more load events on the iframe element |
7199 // than it should. | 7199 // than it should. |
7200 // Finally, make sure an embedder triggered load in the local frame swapped | 7200 // Finally, make sure an embedder triggered load in the local frame swapped |
7201 // back in works. | 7201 // back in works. |
7202 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7202 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7203 std::string content = localFrame->contentAsText(1024).utf8(); | 7203 std::string content = localFrame->contentAsText(1024).utf8(); |
7204 EXPECT_EQ("hello", content); | 7204 EXPECT_EQ("hello", content); |
7205 | 7205 |
(...skipping 23 matching lines...) Expand all Loading... |
7229 "document.querySelector('#frame2').contentWindow;")); | 7229 "document.querySelector('#frame2').contentWindow;")); |
7230 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow)); | 7230 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow)); |
7231 // Check that its view is consistent with the world. | 7231 // Check that its view is consistent with the world. |
7232 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa
lue(WebScriptSource( | 7232 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa
lue(WebScriptSource( |
7233 "document.querySelector('#frame2').contentWindow.top;")); | 7233 "document.querySelector('#frame2').contentWindow.top;")); |
7234 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); | 7234 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); |
7235 | 7235 |
7236 // Now check that remote -> local works too, since it goes through a differe
nt code path. | 7236 // Now check that remote -> local works too, since it goes through a differe
nt code path. |
7237 FrameTestHelpers::TestWebFrameClient client; | 7237 FrameTestHelpers::TestWebFrameClient client; |
7238 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); | 7238 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); |
7239 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None); | 7239 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None, WebFrameOwnerProperties()); |
7240 remoteFrame->swap(localFrame); | 7240 remoteFrame->swap(localFrame); |
7241 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue(
WebScriptSource( | 7241 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue(
WebScriptSource( |
7242 "document.querySelector('#frame2').contentWindow;")); | 7242 "document.querySelector('#frame2').contentWindow;")); |
7243 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); | 7243 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); |
7244 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal
ue(WebScriptSource( | 7244 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal
ue(WebScriptSource( |
7245 "document.querySelector('#frame2').contentWindow.top;")); | 7245 "document.querySelector('#frame2').contentWindow.top;")); |
7246 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); | 7246 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); |
7247 | 7247 |
7248 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7248 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7249 // TestWebFrameClient. | 7249 // TestWebFrameClient. |
(...skipping 13 matching lines...) Expand all Loading... |
7263 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7263 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7264 WebRemoteFrame* remoteFrame = remoteClient.frame(); | 7264 WebRemoteFrame* remoteFrame = remoteClient.frame(); |
7265 mainFrame()->lastChild()->swap(remoteFrame); | 7265 mainFrame()->lastChild()->swap(remoteFrame); |
7266 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); | 7266 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
7267 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa
lue(WebScriptSource("saved.top")); | 7267 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa
lue(WebScriptSource("saved.top")); |
7268 EXPECT_TRUE(remoteWindowTop->IsObject()); | 7268 EXPECT_TRUE(remoteWindowTop->IsObject()); |
7269 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); | 7269 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); |
7270 | 7270 |
7271 FrameTestHelpers::TestWebFrameClient client; | 7271 FrameTestHelpers::TestWebFrameClient client; |
7272 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); | 7272 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); |
7273 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None); | 7273 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None, WebFrameOwnerProperties()); |
7274 remoteFrame->swap(localFrame); | 7274 remoteFrame->swap(localFrame); |
7275 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal
ue(WebScriptSource("saved.top")); | 7275 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal
ue(WebScriptSource("saved.top")); |
7276 EXPECT_TRUE(localWindowTop->IsObject()); | 7276 EXPECT_TRUE(localWindowTop->IsObject()); |
7277 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); | 7277 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); |
7278 | 7278 |
7279 reset(); | 7279 reset(); |
7280 } | 7280 } |
7281 | 7281 |
7282 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) | 7282 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) |
7283 { | 7283 { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7334 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable) | 7334 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable) |
7335 { | 7335 { |
7336 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 7336 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
7337 | 7337 |
7338 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7338 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7339 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); | 7339 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); |
7340 mainFrame()->swap(remoteParentFrame); | 7340 mainFrame()->swap(remoteParentFrame); |
7341 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); | 7341 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
7342 | 7342 |
7343 FrameTestHelpers::TestWebFrameClient childFrameClient; | 7343 FrameTestHelpers::TestWebFrameClient childFrameClient; |
7344 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope
Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); | 7344 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope
Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO
wnerProperties()); |
7345 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); | 7345 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); |
7346 | 7346 |
7347 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr
iptSource("window")); | 7347 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr
iptSource("window")); |
7348 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur
nValue(WebScriptSource("parent.frames[0]")); | 7348 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur
nValue(WebScriptSource("parent.frames[0]")); |
7349 EXPECT_TRUE(childOfRemoteParent->IsObject()); | 7349 EXPECT_TRUE(childOfRemoteParent->IsObject()); |
7350 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); | 7350 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); |
7351 | 7351 |
7352 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue(
WebScriptSource("parent.frames.length")); | 7352 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue(
WebScriptSource("parent.frames.length")); |
7353 ASSERT_TRUE(windowLength->IsInt32()); | 7353 ASSERT_TRUE(windowLength->IsInt32()); |
7354 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); | 7354 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); |
7355 | 7355 |
7356 // Manually reset to break WebViewHelper's dependency on the stack allocated
clients. | 7356 // Manually reset to break WebViewHelper's dependency on the stack allocated
clients. |
7357 reset(); | 7357 reset(); |
7358 } | 7358 } |
7359 | 7359 |
7360 // Check that frames with a remote parent don't crash while accessing window.fra
meElement. | 7360 // Check that frames with a remote parent don't crash while accessing window.fra
meElement. |
7361 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) | 7361 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) |
7362 { | 7362 { |
7363 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 7363 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
7364 | 7364 |
7365 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7365 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7366 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); | 7366 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); |
7367 mainFrame()->swap(remoteParentFrame); | 7367 mainFrame()->swap(remoteParentFrame); |
7368 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); | 7368 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
7369 | 7369 |
7370 FrameTestHelpers::TestWebFrameClient childFrameClient; | 7370 FrameTestHelpers::TestWebFrameClient childFrameClient; |
7371 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope
Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); | 7371 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope
Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO
wnerProperties()); |
7372 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); | 7372 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); |
7373 | 7373 |
7374 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue(
WebScriptSource("window.frameElement")); | 7374 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue(
WebScriptSource("window.frameElement")); |
7375 // frameElement shouldn't be accessible cross-origin. | 7375 // frameElement shouldn't be accessible cross-origin. |
7376 EXPECT_TRUE(frameElement.IsEmpty()); | 7376 EXPECT_TRUE(frameElement.IsEmpty()); |
7377 | 7377 |
7378 // Manually reset to break WebViewHelper's dependency on the stack allocated
clients. | 7378 // Manually reset to break WebViewHelper's dependency on the stack allocated
clients. |
7379 reset(); | 7379 reset(); |
7380 } | 7380 } |
7381 | 7381 |
(...skipping 26 matching lines...) Expand all Loading... |
7408 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7408 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7409 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); | 7409 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); |
7410 WebFrame* targetFrame = mainFrame()->firstChild(); | 7410 WebFrame* targetFrame = mainFrame()->firstChild(); |
7411 ASSERT_TRUE(targetFrame); | 7411 ASSERT_TRUE(targetFrame); |
7412 targetFrame->swap(remoteFrame); | 7412 targetFrame->swap(remoteFrame); |
7413 ASSERT_TRUE(mainFrame()->firstChild()); | 7413 ASSERT_TRUE(mainFrame()->firstChild()); |
7414 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); | 7414 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); |
7415 | 7415 |
7416 RemoteToLocalSwapWebFrameClient client(remoteFrame); | 7416 RemoteToLocalSwapWebFrameClient client(remoteFrame); |
7417 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); | 7417 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); |
7418 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None); | 7418 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None, WebFrameOwnerProperties()); |
7419 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7419 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7420 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); | 7420 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); |
7421 | 7421 |
7422 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7422 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7423 // TestWebFrameClient. | 7423 // TestWebFrameClient. |
7424 reset(); | 7424 reset(); |
7425 remoteFrame->close(); | 7425 remoteFrame->close(); |
7426 } | 7426 } |
7427 | 7427 |
7428 // The commit type should be Standard if we are swapping a RemoteFrame to a | 7428 // The commit type should be Standard if we are swapping a RemoteFrame to a |
7429 // LocalFrame after commits have already happened in the frame. The browser | 7429 // LocalFrame after commits have already happened in the frame. The browser |
7430 // process will inform us via setCommittedFirstRealLoad. | 7430 // process will inform us via setCommittedFirstRealLoad. |
7431 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) | 7431 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) |
7432 { | 7432 { |
7433 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7433 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7434 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); | 7434 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); |
7435 WebFrame* targetFrame = mainFrame()->firstChild(); | 7435 WebFrame* targetFrame = mainFrame()->firstChild(); |
7436 ASSERT_TRUE(targetFrame); | 7436 ASSERT_TRUE(targetFrame); |
7437 targetFrame->swap(remoteFrame); | 7437 targetFrame->swap(remoteFrame); |
7438 ASSERT_TRUE(mainFrame()->firstChild()); | 7438 ASSERT_TRUE(mainFrame()->firstChild()); |
7439 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); | 7439 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); |
7440 | 7440 |
7441 RemoteToLocalSwapWebFrameClient client(remoteFrame); | 7441 RemoteToLocalSwapWebFrameClient client(remoteFrame); |
7442 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); | 7442 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); |
7443 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None); | 7443 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None, WebFrameOwnerProperties()); |
7444 localFrame->setCommittedFirstRealLoad(); | 7444 localFrame->setCommittedFirstRealLoad(); |
7445 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7445 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7446 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); | 7446 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); |
7447 | 7447 |
7448 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7448 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7449 // TestWebFrameClient. | 7449 // TestWebFrameClient. |
7450 reset(); | 7450 reset(); |
7451 remoteFrame->close(); | 7451 remoteFrame->close(); |
7452 } | 7452 } |
7453 | 7453 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7571 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient; | 7571 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient; |
7572 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame(); | 7572 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame(); |
7573 popupView->setMainFrame(popupRemoteFrame); | 7573 popupView->setMainFrame(popupRemoteFrame); |
7574 popupRemoteFrame->setOpener(mainFrame); | 7574 popupRemoteFrame->setOpener(mainFrame); |
7575 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h
ttp://foo.com")); | 7575 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h
ttp://foo.com")); |
7576 EXPECT_FALSE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->s
ecurityOrigin())); | 7576 EXPECT_FALSE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->s
ecurityOrigin())); |
7577 | 7577 |
7578 // Do a remote-to-local swap in the popup. | 7578 // Do a remote-to-local swap in the popup. |
7579 FrameTestHelpers::TestWebFrameClient popupLocalClient; | 7579 FrameTestHelpers::TestWebFrameClient popupLocalClient; |
7580 WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Doc
ument, &popupLocalClient); | 7580 WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Doc
ument, &popupLocalClient); |
7581 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan
dboxFlags::None); | 7581 popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSan
dboxFlags::None, WebFrameOwnerProperties()); |
7582 popupRemoteFrame->swap(popupLocalFrame); | 7582 popupRemoteFrame->swap(popupLocalFrame); |
7583 | 7583 |
7584 // The initial document created during the remote-to-local swap should have | 7584 // The initial document created during the remote-to-local swap should have |
7585 // inherited its opener's SecurityOrigin. | 7585 // inherited its opener's SecurityOrigin. |
7586 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se
curityOrigin())); | 7586 EXPECT_TRUE(mainFrame->securityOrigin().canAccess(popupView->mainFrame()->se
curityOrigin())); |
7587 | 7587 |
7588 popupView->close(); | 7588 popupView->close(); |
7589 } | 7589 } |
7590 | 7590 |
7591 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 7591 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
(...skipping 17 matching lines...) Expand all Loading... |
7609 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) | 7609 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) |
7610 { | 7610 { |
7611 FrameTestHelpers::TestWebViewClient viewClient; | 7611 FrameTestHelpers::TestWebViewClient viewClient; |
7612 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7612 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7613 WebView* view = WebView::create(&viewClient); | 7613 WebView* view = WebView::create(&viewClient); |
7614 view->setMainFrame(remoteClient.frame()); | 7614 view->setMainFrame(remoteClient.frame()); |
7615 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica
tedOrigin(SecurityOrigin::create(toKURL(m_baseURL))); | 7615 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica
tedOrigin(SecurityOrigin::create(toKURL(m_baseURL))); |
7616 | 7616 |
7617 // If an iframe has a remote main frame, ensure the inital commit is correct
ly identified as WebInitialCommitInChildFrame. | 7617 // If an iframe has a remote main frame, ensure the inital commit is correct
ly identified as WebInitialCommitInChildFrame. |
7618 CommitTypeWebFrameClient childFrameClient; | 7618 CommitTypeWebFrameClient childFrameClient; |
7619 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc
alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient
, nullptr); | 7619 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc
alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient
, nullptr, WebFrameOwnerProperties()); |
7620 registerMockedHttpURLLoad("foo.html"); | 7620 registerMockedHttpURLLoad("foo.html"); |
7621 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); | 7621 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); |
7622 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType()
); | 7622 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType()
); |
7623 view->close(); | 7623 view->close(); |
7624 } | 7624 } |
7625 | 7625 |
7626 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient
{ | 7626 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient
{ |
7627 public: | 7627 public: |
7628 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { } | 7628 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { } |
7629 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled
) override { m_didHandleGestureEvent = true; } | 7629 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled
) override { m_didHandleGestureEvent = true; } |
7630 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; } | 7630 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; } |
7631 | 7631 |
7632 private: | 7632 private: |
7633 bool m_didHandleGestureEvent; | 7633 bool m_didHandleGestureEvent; |
7634 }; | 7634 }; |
7635 | 7635 |
7636 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) | 7636 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) |
7637 { | 7637 { |
7638 FrameTestHelpers::TestWebViewClient viewClient; | 7638 FrameTestHelpers::TestWebViewClient viewClient; |
7639 WebView* view = WebView::create(&viewClient); | 7639 WebView* view = WebView::create(&viewClient); |
7640 | 7640 |
7641 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7641 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7642 view->setMainFrame(remoteClient.frame()); | 7642 view->setMainFrame(remoteClient.frame()); |
7643 | 7643 |
7644 FrameTestHelpers::TestWebFrameClient childFrameClient; | 7644 FrameTestHelpers::TestWebFrameClient childFrameClient; |
7645 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc
alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient
, nullptr); | 7645 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc
alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient
, nullptr, WebFrameOwnerProperties()); |
7646 | 7646 |
7647 GestureEventTestWebViewClient childViewClient; | 7647 GestureEventTestWebViewClient childViewClient; |
7648 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame
); | 7648 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame
); |
7649 | 7649 |
7650 view->resize(WebSize(1000, 1000)); | 7650 view->resize(WebSize(1000, 1000)); |
7651 view->layout(); | 7651 view->layout(); |
7652 | 7652 |
7653 widget->handleInputEvent(fatTap(20, 20)); | 7653 widget->handleInputEvent(fatTap(20, 20)); |
7654 EXPECT_TRUE(childViewClient.didHandleGestureEvent()); | 7654 EXPECT_TRUE(childViewClient.didHandleGestureEvent()); |
7655 | 7655 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7841 | 7841 |
7842 | 7842 |
7843 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling) | 7843 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling) |
7844 { | 7844 { |
7845 FrameTestHelpers::TestWebViewClient viewClient; | 7845 FrameTestHelpers::TestWebViewClient viewClient; |
7846 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7846 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7847 WebView* view = WebView::create(&viewClient); | 7847 WebView* view = WebView::create(&viewClient); |
7848 view->setMainFrame(remoteClient.frame()); | 7848 view->setMainFrame(remoteClient.frame()); |
7849 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame(); | 7849 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame(); |
7850 | 7850 |
7851 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType::
Document, "", WebSandboxFlags::None, nullptr, nullptr); | 7851 WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType::
Document, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties()
); |
7852 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType::
Document, "", WebSandboxFlags::None, nullptr, secondFrame); | 7852 WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType::
Document, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerProperti
es()); |
7853 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D
ocument, "", WebSandboxFlags::None, nullptr, secondFrame); | 7853 WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::D
ocument, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerPropertie
s()); |
7854 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D
ocument, "", WebSandboxFlags::None, nullptr, nullptr); | 7854 WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::D
ocument, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties())
; |
7855 | 7855 |
7856 EXPECT_EQ(firstFrame, parent->firstChild()); | 7856 EXPECT_EQ(firstFrame, parent->firstChild()); |
7857 EXPECT_EQ(nullptr, firstFrame->previousSibling()); | 7857 EXPECT_EQ(nullptr, firstFrame->previousSibling()); |
7858 EXPECT_EQ(secondFrame, firstFrame->nextSibling()); | 7858 EXPECT_EQ(secondFrame, firstFrame->nextSibling()); |
7859 | 7859 |
7860 EXPECT_EQ(firstFrame, secondFrame->previousSibling()); | 7860 EXPECT_EQ(firstFrame, secondFrame->previousSibling()); |
7861 EXPECT_EQ(thirdFrame, secondFrame->nextSibling()); | 7861 EXPECT_EQ(thirdFrame, secondFrame->nextSibling()); |
7862 | 7862 |
7863 EXPECT_EQ(secondFrame, thirdFrame->previousSibling()); | 7863 EXPECT_EQ(secondFrame, thirdFrame->previousSibling()); |
7864 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling()); | 7864 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling()); |
(...skipping 14 matching lines...) Expand all Loading... |
7879 { | 7879 { |
7880 FrameTestHelpers::TestWebViewClient viewClient; | 7880 FrameTestHelpers::TestWebViewClient viewClient; |
7881 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7881 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7882 WebView* view = WebView::create(&viewClient); | 7882 WebView* view = WebView::create(&viewClient); |
7883 view->settings()->setJavaScriptEnabled(true); | 7883 view->settings()->setJavaScriptEnabled(true); |
7884 view->setMainFrame(remoteClient.frame()); | 7884 view->setMainFrame(remoteClient.frame()); |
7885 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); | 7885 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); |
7886 root->setReplicatedOrigin(SecurityOrigin::createUnique()); | 7886 root->setReplicatedOrigin(SecurityOrigin::createUnique()); |
7887 | 7887 |
7888 FrameTestHelpers::TestWebFrameClient localFrameClient; | 7888 FrameTestHelpers::TestWebFrameClient localFrameClient; |
7889 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen
t, "", WebSandboxFlags::None, &localFrameClient, nullptr); | 7889 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen
t, "", WebSandboxFlags::None, &localFrameClient, nullptr, WebFrameOwnerPropertie
s()); |
7890 | 7890 |
7891 // Finally, make sure an embedder triggered load in the local frame swapped | 7891 // Finally, make sure an embedder triggered load in the local frame swapped |
7892 // back in works. | 7892 // back in works. |
7893 registerMockedHttpURLLoad("send_beacon.html"); | 7893 registerMockedHttpURLLoad("send_beacon.html"); |
7894 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon() | 7894 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon() |
7895 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html"); | 7895 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html"); |
7896 | 7896 |
7897 view->close(); | 7897 view->close(); |
7898 } | 7898 } |
7899 | 7899 |
7900 // See https://crbug.com/525285. | 7900 // See https://crbug.com/525285. |
7901 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra
me) | 7901 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra
me) |
7902 { | 7902 { |
7903 FrameTestHelpers::TestWebViewClient viewClient; | 7903 FrameTestHelpers::TestWebViewClient viewClient; |
7904 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7904 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7905 WebView* view = WebView::create(&viewClient); | 7905 WebView* view = WebView::create(&viewClient); |
7906 view->setMainFrame(remoteClient.frame()); | 7906 view->setMainFrame(remoteClient.frame()); |
7907 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); | 7907 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); |
7908 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); | 7908 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); |
7909 | 7909 |
7910 FrameTestHelpers::TestWebFrameClient localFrameClient; | 7910 FrameTestHelpers::TestWebFrameClient localFrameClient; |
7911 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags
::None, &localFrameClient, nullptr); | 7911 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags
::None, &localFrameClient, nullptr, WebFrameOwnerProperties()); |
7912 | 7912 |
7913 // Do a remote-to-local swap of the top frame. | 7913 // Do a remote-to-local swap of the top frame. |
7914 FrameTestHelpers::TestWebFrameClient localClient; | 7914 FrameTestHelpers::TestWebFrameClient localClient; |
7915 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document,
&localClient); | 7915 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document,
&localClient); |
7916 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N
one); | 7916 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N
one, WebFrameOwnerProperties()); |
7917 remoteRoot->swap(localRoot); | 7917 remoteRoot->swap(localRoot); |
7918 | 7918 |
7919 // Load a page with a child frame in the new root to make sure this doesn't | 7919 // Load a page with a child frame in the new root to make sure this doesn't |
7920 // crash when the child frame invokes setCoreFrame. | 7920 // crash when the child frame invokes setCoreFrame. |
7921 registerMockedHttpURLLoad("single_iframe.html"); | 7921 registerMockedHttpURLLoad("single_iframe.html"); |
7922 registerMockedHttpURLLoad("visible_iframe.html"); | 7922 registerMockedHttpURLLoad("visible_iframe.html"); |
7923 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); | 7923 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); |
7924 | 7924 |
7925 view->close(); | 7925 view->close(); |
7926 } | 7926 } |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8202 | 8202 |
8203 TEST_F(WebFrameTest, MaxFramesDetach) | 8203 TEST_F(WebFrameTest, MaxFramesDetach) |
8204 { | 8204 { |
8205 registerMockedHttpURLLoad("max-frames-detach.html"); | 8205 registerMockedHttpURLLoad("max-frames-detach.html"); |
8206 FrameTestHelpers::WebViewHelper webViewHelper; | 8206 FrameTestHelpers::WebViewHelper webViewHelper; |
8207 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max-
frames-detach.html", true); | 8207 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max-
frames-detach.html", true); |
8208 webViewImpl->mainFrameImpl()->collectGarbage(); | 8208 webViewImpl->mainFrameImpl()->collectGarbage(); |
8209 } | 8209 } |
8210 | 8210 |
8211 } // namespace blink | 8211 } // namespace blink |
OLD | NEW |