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 7116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7127 private: | 7127 private: |
7128 FrameTestHelpers::WebViewHelper m_webViewHelper; | 7128 FrameTestHelpers::WebViewHelper m_webViewHelper; |
7129 }; | 7129 }; |
7130 | 7130 |
7131 TEST_F(WebFrameSwapTest, SwapMainFrame) | 7131 TEST_F(WebFrameSwapTest, SwapMainFrame) |
7132 { | 7132 { |
7133 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, nullptr); | 7133 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, nullptr); |
7134 mainFrame()->swap(remoteFrame); | 7134 mainFrame()->swap(remoteFrame); |
7135 | 7135 |
7136 FrameTestHelpers::TestWebFrameClient client; | 7136 FrameTestHelpers::TestWebFrameClient client; |
7137 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7137 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None); |
7138 remoteFrame->swap(localFrame); | 7138 remoteFrame->swap(localFrame); |
7139 | 7139 |
7140 // Finally, make sure an embedder triggered load in the local frame swapped | 7140 // Finally, make sure an embedder triggered load in the local frame swapped |
7141 // back in works. | 7141 // back in works. |
7142 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7142 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7143 | 7143 |
7144 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); | 7144 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); |
7145 EXPECT_EQ("hello", content); | 7145 EXPECT_EQ("hello", content); |
7146 | 7146 |
7147 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7147 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7148 // TestWebFrameClient. | 7148 // TestWebFrameClient. |
7149 reset(); | 7149 reset(); |
7150 remoteFrame->close(); | 7150 remoteFrame->close(); |
7151 } | 7151 } |
7152 | 7152 |
7153 TEST_F(WebFrameSwapTest, ValidateSizeOnRemoteToLocalMainFrameSwap) | 7153 TEST_F(WebFrameSwapTest, ValidateSizeOnRemoteToLocalMainFrameSwap) |
7154 { | 7154 { |
7155 WebSize size(111, 222); | 7155 WebSize size(111, 222); |
7156 | 7156 |
7157 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, nullptr); | 7157 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, nullptr); |
7158 mainFrame()->swap(remoteFrame); | 7158 mainFrame()->swap(remoteFrame); |
7159 | 7159 |
7160 remoteFrame->view()->resize(size); | 7160 remoteFrame->view()->resize(size); |
7161 | 7161 |
7162 FrameTestHelpers::TestWebFrameClient client; | 7162 FrameTestHelpers::TestWebFrameClient client; |
7163 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7163 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None); |
7164 remoteFrame->swap(localFrame); | 7164 remoteFrame->swap(localFrame); |
7165 | 7165 |
7166 // Verify that the size that was set with a remote main frame is correct | 7166 // Verify that the size that was set with a remote main frame is correct |
7167 // after swapping to a local frame. | 7167 // after swapping to a local frame. |
7168 FrameHost* host = toWebViewImpl(localFrame->view())->page()->mainFrame()->ho
st(); | 7168 FrameHost* host = toWebViewImpl(localFrame->view())->page()->mainFrame()->ho
st(); |
7169 EXPECT_EQ(size.width, host->visualViewport().size().width()); | 7169 EXPECT_EQ(size.width, host->visualViewport().size().width()); |
7170 EXPECT_EQ(size.height, host->visualViewport().size().height()); | 7170 EXPECT_EQ(size.height, host->visualViewport().size().height()); |
7171 | 7171 |
7172 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7172 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7173 // TestWebFrameClient. | 7173 // TestWebFrameClient. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7228 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling()); | 7228 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling()); |
7229 } | 7229 } |
7230 | 7230 |
7231 TEST_F(WebFrameSwapTest, SwapFirstChild) | 7231 TEST_F(WebFrameSwapTest, SwapFirstChild) |
7232 { | 7232 { |
7233 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7233 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7234 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); | 7234 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); |
7235 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame
); | 7235 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame
); |
7236 | 7236 |
7237 FrameTestHelpers::TestWebFrameClient client; | 7237 FrameTestHelpers::TestWebFrameClient client; |
7238 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7238 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None); |
7239 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame)
; | 7239 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame)
; |
7240 | 7240 |
7241 // FIXME: This almost certainly fires more load events on the iframe element | 7241 // FIXME: This almost certainly fires more load events on the iframe element |
7242 // than it should. | 7242 // than it should. |
7243 // Finally, make sure an embedder triggered load in the local frame swapped | 7243 // Finally, make sure an embedder triggered load in the local frame swapped |
7244 // back in works. | 7244 // back in works. |
7245 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7245 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7246 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); | 7246 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); |
7247 EXPECT_EQ(" \n\nhello\n\nb \n\na\n\nc", content); | 7247 EXPECT_EQ(" \n\nhello\n\nb \n\na\n\nc", content); |
7248 | 7248 |
(...skipping 17 matching lines...) Expand all Loading... |
7266 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()); | 7266 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()); |
7267 } | 7267 } |
7268 | 7268 |
7269 TEST_F(WebFrameSwapTest, SwapMiddleChild) | 7269 TEST_F(WebFrameSwapTest, SwapMiddleChild) |
7270 { | 7270 { |
7271 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7271 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7272 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); | 7272 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); |
7273 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram
e); | 7273 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram
e); |
7274 | 7274 |
7275 FrameTestHelpers::TestWebFrameClient client; | 7275 FrameTestHelpers::TestWebFrameClient client; |
7276 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7276 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None); |
7277 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame
); | 7277 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame
); |
7278 | 7278 |
7279 // FIXME: This almost certainly fires more load events on the iframe element | 7279 // FIXME: This almost certainly fires more load events on the iframe element |
7280 // than it should. | 7280 // than it should. |
7281 // Finally, make sure an embedder triggered load in the local frame swapped | 7281 // Finally, make sure an embedder triggered load in the local frame swapped |
7282 // back in works. | 7282 // back in works. |
7283 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7283 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7284 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); | 7284 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); |
7285 EXPECT_EQ(" \n\na\n\nhello\n\nc", content); | 7285 EXPECT_EQ(" \n\na\n\nhello\n\nc", content); |
7286 | 7286 |
(...skipping 14 matching lines...) Expand all Loading... |
7301 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()->nextSibling()); | 7301 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()->nextSibling()); |
7302 } | 7302 } |
7303 | 7303 |
7304 TEST_F(WebFrameSwapTest, SwapLastChild) | 7304 TEST_F(WebFrameSwapTest, SwapLastChild) |
7305 { | 7305 { |
7306 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7306 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7307 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); | 7307 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); |
7308 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame)
; | 7308 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame)
; |
7309 | 7309 |
7310 FrameTestHelpers::TestWebFrameClient client; | 7310 FrameTestHelpers::TestWebFrameClient client; |
7311 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7311 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None); |
7312 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); | 7312 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); |
7313 | 7313 |
7314 // FIXME: This almost certainly fires more load events on the iframe element | 7314 // FIXME: This almost certainly fires more load events on the iframe element |
7315 // than it should. | 7315 // than it should. |
7316 // Finally, make sure an embedder triggered load in the local frame swapped | 7316 // Finally, make sure an embedder triggered load in the local frame swapped |
7317 // back in works. | 7317 // back in works. |
7318 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7318 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7319 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); | 7319 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); |
7320 EXPECT_EQ(" \n\na\n\nb \n\na\n\nhello", content); | 7320 EXPECT_EQ(" \n\na\n\nb \n\na\n\nhello", content); |
7321 | 7321 |
(...skipping 23 matching lines...) Expand all Loading... |
7345 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame); | 7345 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame); |
7346 | 7346 |
7347 targetFrame = mainFrame()->firstChild()->nextSibling(); | 7347 targetFrame = mainFrame()->firstChild()->nextSibling(); |
7348 EXPECT_TRUE(targetFrame); | 7348 EXPECT_TRUE(targetFrame); |
7349 | 7349 |
7350 // Create child frames in the target frame before testing the swap. | 7350 // Create child frames in the target frame before testing the swap. |
7351 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; | 7351 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; |
7352 WebRemoteFrame* childRemoteFrame = FrameTestHelpers::createRemoteChild(remot
eFrame, &remoteFrameClient2); | 7352 WebRemoteFrame* childRemoteFrame = FrameTestHelpers::createRemoteChild(remot
eFrame, &remoteFrameClient2); |
7353 | 7353 |
7354 FrameTestHelpers::TestWebFrameClient client; | 7354 FrameTestHelpers::TestWebFrameClient client; |
7355 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7355 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None); |
7356 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); | 7356 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); |
7357 | 7357 |
7358 // FIXME: This almost certainly fires more load events on the iframe element | 7358 // FIXME: This almost certainly fires more load events on the iframe element |
7359 // than it should. | 7359 // than it should. |
7360 // Finally, make sure an embedder triggered load in the local frame swapped | 7360 // Finally, make sure an embedder triggered load in the local frame swapped |
7361 // back in works. | 7361 // back in works. |
7362 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7362 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7363 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); | 7363 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10
24).utf8(); |
7364 EXPECT_EQ(" \n\na\n\nhello\n\nc", content); | 7364 EXPECT_EQ(" \n\na\n\nhello\n\nc", content); |
7365 | 7365 |
(...skipping 22 matching lines...) Expand all Loading... |
7388 v8::Local<v8::Value> remoteWindow = mainFrame()->executeScriptAndReturnValue
(WebScriptSource( | 7388 v8::Local<v8::Value> remoteWindow = mainFrame()->executeScriptAndReturnValue
(WebScriptSource( |
7389 "document.querySelector('#frame2').contentWindow;")); | 7389 "document.querySelector('#frame2').contentWindow;")); |
7390 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow)); | 7390 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow)); |
7391 // Check that its view is consistent with the world. | 7391 // Check that its view is consistent with the world. |
7392 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa
lue(WebScriptSource( | 7392 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa
lue(WebScriptSource( |
7393 "document.querySelector('#frame2').contentWindow.top;")); | 7393 "document.querySelector('#frame2').contentWindow.top;")); |
7394 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); | 7394 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); |
7395 | 7395 |
7396 // Now check that remote -> local works too, since it goes through a differe
nt code path. | 7396 // Now check that remote -> local works too, since it goes through a differe
nt code path. |
7397 FrameTestHelpers::TestWebFrameClient client; | 7397 FrameTestHelpers::TestWebFrameClient client; |
7398 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7398 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None); |
7399 remoteFrame->swap(localFrame); | 7399 remoteFrame->swap(localFrame); |
7400 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue(
WebScriptSource( | 7400 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue(
WebScriptSource( |
7401 "document.querySelector('#frame2').contentWindow;")); | 7401 "document.querySelector('#frame2').contentWindow;")); |
7402 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); | 7402 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); |
7403 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal
ue(WebScriptSource( | 7403 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal
ue(WebScriptSource( |
7404 "document.querySelector('#frame2').contentWindow.top;")); | 7404 "document.querySelector('#frame2').contentWindow.top;")); |
7405 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); | 7405 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); |
7406 | 7406 |
7407 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7407 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7408 // TestWebFrameClient. | 7408 // TestWebFrameClient. |
(...skipping 12 matching lines...) Expand all Loading... |
7421 | 7421 |
7422 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7422 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7423 WebRemoteFrame* remoteFrame = remoteClient.frame(); | 7423 WebRemoteFrame* remoteFrame = remoteClient.frame(); |
7424 mainFrame()->lastChild()->swap(remoteFrame); | 7424 mainFrame()->lastChild()->swap(remoteFrame); |
7425 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); | 7425 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
7426 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa
lue(WebScriptSource("saved.top")); | 7426 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa
lue(WebScriptSource("saved.top")); |
7427 EXPECT_TRUE(remoteWindowTop->IsObject()); | 7427 EXPECT_TRUE(remoteWindowTop->IsObject()); |
7428 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); | 7428 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); |
7429 | 7429 |
7430 FrameTestHelpers::TestWebFrameClient client; | 7430 FrameTestHelpers::TestWebFrameClient client; |
7431 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7431 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None); |
7432 remoteFrame->swap(localFrame); | 7432 remoteFrame->swap(localFrame); |
7433 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal
ue(WebScriptSource("saved.top")); | 7433 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal
ue(WebScriptSource("saved.top")); |
7434 EXPECT_TRUE(localWindowTop->IsObject()); | 7434 EXPECT_TRUE(localWindowTop->IsObject()); |
7435 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); | 7435 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); |
7436 | 7436 |
7437 reset(); | 7437 reset(); |
7438 } | 7438 } |
7439 | 7439 |
7440 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) | 7440 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) |
7441 { | 7441 { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7564 { | 7564 { |
7565 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7565 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7566 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); | 7566 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); |
7567 WebFrame* targetFrame = mainFrame()->firstChild(); | 7567 WebFrame* targetFrame = mainFrame()->firstChild(); |
7568 ASSERT_TRUE(targetFrame); | 7568 ASSERT_TRUE(targetFrame); |
7569 targetFrame->swap(remoteFrame); | 7569 targetFrame->swap(remoteFrame); |
7570 ASSERT_TRUE(mainFrame()->firstChild()); | 7570 ASSERT_TRUE(mainFrame()->firstChild()); |
7571 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); | 7571 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); |
7572 | 7572 |
7573 RemoteToLocalSwapWebFrameClient client(remoteFrame); | 7573 RemoteToLocalSwapWebFrameClient client(remoteFrame); |
7574 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7574 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None); |
7575 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7575 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7576 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); | 7576 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); |
7577 | 7577 |
7578 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7578 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7579 // TestWebFrameClient. | 7579 // TestWebFrameClient. |
7580 reset(); | 7580 reset(); |
7581 remoteFrame->close(); | 7581 remoteFrame->close(); |
7582 } | 7582 } |
7583 | 7583 |
7584 // The commit type should be Standard if we are swapping a RemoteFrame to a | 7584 // The commit type should be Standard if we are swapping a RemoteFrame to a |
7585 // LocalFrame after commits have already happened in the frame. The browser | 7585 // LocalFrame after commits have already happened in the frame. The browser |
7586 // process will inform us via setCommittedFirstRealLoad. | 7586 // process will inform us via setCommittedFirstRealLoad. |
7587 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) | 7587 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) |
7588 { | 7588 { |
7589 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7589 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7590 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); | 7590 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); |
7591 WebFrame* targetFrame = mainFrame()->firstChild(); | 7591 WebFrame* targetFrame = mainFrame()->firstChild(); |
7592 ASSERT_TRUE(targetFrame); | 7592 ASSERT_TRUE(targetFrame); |
7593 targetFrame->swap(remoteFrame); | 7593 targetFrame->swap(remoteFrame); |
7594 ASSERT_TRUE(mainFrame()->firstChild()); | 7594 ASSERT_TRUE(mainFrame()->firstChild()); |
7595 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); | 7595 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); |
7596 | 7596 |
7597 RemoteToLocalSwapWebFrameClient client(remoteFrame); | 7597 RemoteToLocalSwapWebFrameClient client(remoteFrame); |
7598 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7598 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None); |
7599 localFrame->setCommittedFirstRealLoad(); | 7599 localFrame->setCommittedFirstRealLoad(); |
7600 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7600 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7601 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); | 7601 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); |
7602 | 7602 |
7603 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7603 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7604 // TestWebFrameClient. | 7604 // TestWebFrameClient. |
7605 reset(); | 7605 reset(); |
7606 remoteFrame->close(); | 7606 remoteFrame->close(); |
7607 } | 7607 } |
7608 | 7608 |
(...skipping 10 matching lines...) Expand all Loading... |
7619 // Swap to a RemoteFrame. | 7619 // Swap to a RemoteFrame. |
7620 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 7620 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
7621 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); | 7621 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); |
7622 targetFrame->swap(remoteFrame); | 7622 targetFrame->swap(remoteFrame); |
7623 ASSERT_TRUE(mainFrame()->firstChild()); | 7623 ASSERT_TRUE(mainFrame()->firstChild()); |
7624 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); | 7624 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); |
7625 EXPECT_EQ(uniqueName.utf8(), WebString(toWebRemoteFrameImpl(remoteFrame)->fr
ame()->tree().uniqueName()).utf8()); | 7625 EXPECT_EQ(uniqueName.utf8(), WebString(toWebRemoteFrameImpl(remoteFrame)->fr
ame()->tree().uniqueName()).utf8()); |
7626 | 7626 |
7627 // Swap back to a LocalFrame. | 7627 // Swap back to a LocalFrame. |
7628 RemoteToLocalSwapWebFrameClient client(remoteFrame); | 7628 RemoteToLocalSwapWebFrameClient client(remoteFrame); |
7629 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7629 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None); |
7630 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7630 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7631 EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8()); | 7631 EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8()); |
7632 EXPECT_EQ(uniqueName.utf8(), WebString(toWebLocalFrameImpl(localFrame)->fram
e()->loader().currentItem()->target()).utf8()); | 7632 EXPECT_EQ(uniqueName.utf8(), WebString(toWebLocalFrameImpl(localFrame)->fram
e()->loader().currentItem()->target()).utf8()); |
7633 | 7633 |
7634 // Repeat with no name on the frame. | 7634 // Repeat with no name on the frame. |
7635 localFrame->setName(""); | 7635 localFrame->setName(""); |
7636 WebString uniqueName2 = localFrame->uniqueName(); | 7636 WebString uniqueName2 = localFrame->uniqueName(); |
7637 EXPECT_EQ("<!--framePath //<!--frame2-->-->", uniqueName2.utf8()); | 7637 EXPECT_EQ("<!--framePath //<!--frame2-->-->", uniqueName2.utf8()); |
7638 | 7638 |
7639 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; | 7639 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; |
7640 WebRemoteFrame* remoteFrame2 = WebRemoteFrame::create(WebTreeScopeType::Docu
ment, &remoteFrameClient2); | 7640 WebRemoteFrame* remoteFrame2 = WebRemoteFrame::create(WebTreeScopeType::Docu
ment, &remoteFrameClient2); |
7641 localFrame->swap(remoteFrame2); | 7641 localFrame->swap(remoteFrame2); |
7642 ASSERT_TRUE(mainFrame()->firstChild()); | 7642 ASSERT_TRUE(mainFrame()->firstChild()); |
7643 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame2); | 7643 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame2); |
7644 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebRemoteFrameImpl(remoteFrame2)->
frame()->tree().uniqueName()).utf8()); | 7644 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebRemoteFrameImpl(remoteFrame2)->
frame()->tree().uniqueName()).utf8()); |
7645 | 7645 |
7646 RemoteToLocalSwapWebFrameClient client2(remoteFrame2); | 7646 RemoteToLocalSwapWebFrameClient client2(remoteFrame2); |
7647 WebLocalFrame* localFrame2 = WebLocalFrame::createProvisional(&client2, remo
teFrame2, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7647 WebLocalFrame* localFrame2 = WebLocalFrame::createProvisional(&client2, remo
teFrame2, WebSandboxFlags::None); |
7648 FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html"); | 7648 FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html"); |
7649 EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8()); | 7649 EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8()); |
7650 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebLocalFrameImpl(localFrame2)->fr
ame()->loader().currentItem()->target()).utf8()); | 7650 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebLocalFrameImpl(localFrame2)->fr
ame()->loader().currentItem()->target()).utf8()); |
7651 | 7651 |
7652 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7652 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7653 // TestWebFrameClient. | 7653 // TestWebFrameClient. |
7654 reset(); | 7654 reset(); |
7655 remoteFrame->close(); | 7655 remoteFrame->close(); |
7656 remoteFrame2->close(); | 7656 remoteFrame2->close(); |
7657 } | 7657 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7775 WebView* popupView = WebView::create(&popupViewClient); | 7775 WebView* popupView = WebView::create(&popupViewClient); |
7776 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient; | 7776 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient; |
7777 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame(); | 7777 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame(); |
7778 popupView->setMainFrame(popupRemoteFrame); | 7778 popupView->setMainFrame(popupRemoteFrame); |
7779 popupRemoteFrame->setOpener(mainFrame); | 7779 popupRemoteFrame->setOpener(mainFrame); |
7780 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h
ttp://foo.com")); | 7780 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h
ttp://foo.com")); |
7781 EXPECT_FALSE(mainFrame->getSecurityOrigin().canAccess(popupView->mainFrame()
->getSecurityOrigin())); | 7781 EXPECT_FALSE(mainFrame->getSecurityOrigin().canAccess(popupView->mainFrame()
->getSecurityOrigin())); |
7782 | 7782 |
7783 // Do a remote-to-local swap in the popup. | 7783 // Do a remote-to-local swap in the popup. |
7784 FrameTestHelpers::TestWebFrameClient popupLocalClient; | 7784 FrameTestHelpers::TestWebFrameClient popupLocalClient; |
7785 WebLocalFrame* popupLocalFrame = WebLocalFrame::createProvisional(&popupLoca
lClient, popupRemoteFrame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7785 WebLocalFrame* popupLocalFrame = WebLocalFrame::createProvisional(&popupLoca
lClient, popupRemoteFrame, WebSandboxFlags::None); |
7786 popupRemoteFrame->swap(popupLocalFrame); | 7786 popupRemoteFrame->swap(popupLocalFrame); |
7787 | 7787 |
7788 // The initial document created during the remote-to-local swap should have | 7788 // The initial document created during the remote-to-local swap should have |
7789 // inherited its opener's SecurityOrigin. | 7789 // inherited its opener's SecurityOrigin. |
7790 EXPECT_TRUE(mainFrame->getSecurityOrigin().canAccess(popupView->mainFrame()-
>getSecurityOrigin())); | 7790 EXPECT_TRUE(mainFrame->getSecurityOrigin().canAccess(popupView->mainFrame()-
>getSecurityOrigin())); |
7791 | 7791 |
7792 popupView->close(); | 7792 popupView->close(); |
7793 } | 7793 } |
7794 | 7794 |
7795 TEST_F(WebFrameTest, SwapWithOpenerCycle) | 7795 TEST_F(WebFrameTest, SwapWithOpenerCycle) |
7796 { | 7796 { |
7797 // First, create a remote main frame with itself as the opener. | 7797 // First, create a remote main frame with itself as the opener. |
7798 FrameTestHelpers::TestWebViewClient viewClient; | 7798 FrameTestHelpers::TestWebViewClient viewClient; |
7799 WebView* view = WebView::create(&viewClient); | 7799 WebView* view = WebView::create(&viewClient); |
7800 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7800 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7801 WebRemoteFrame* remoteFrame = remoteClient.frame(); | 7801 WebRemoteFrame* remoteFrame = remoteClient.frame(); |
7802 view->setMainFrame(remoteFrame); | 7802 view->setMainFrame(remoteFrame); |
7803 remoteFrame->setOpener(remoteFrame); | 7803 remoteFrame->setOpener(remoteFrame); |
7804 | 7804 |
7805 // Now swap in a local frame. It shouldn't crash. | 7805 // Now swap in a local frame. It shouldn't crash. |
7806 FrameTestHelpers::TestWebFrameClient localClient; | 7806 FrameTestHelpers::TestWebFrameClient localClient; |
7807 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&localClient, r
emoteFrame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7807 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&localClient, r
emoteFrame, WebSandboxFlags::None); |
7808 remoteFrame->swap(localFrame); | 7808 remoteFrame->swap(localFrame); |
7809 | 7809 |
7810 // And the opener cycle should still be preserved. | 7810 // And the opener cycle should still be preserved. |
7811 EXPECT_EQ(localFrame, localFrame->opener()); | 7811 EXPECT_EQ(localFrame, localFrame->opener()); |
7812 | 7812 |
7813 view->close(); | 7813 view->close(); |
7814 } | 7814 } |
7815 | 7815 |
7816 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 7816 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
7817 public: | 7817 public: |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8115 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 8115 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
8116 WebView* view = WebView::create(&viewClient); | 8116 WebView* view = WebView::create(&viewClient); |
8117 view->setMainFrame(remoteClient.frame()); | 8117 view->setMainFrame(remoteClient.frame()); |
8118 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); | 8118 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); |
8119 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); | 8119 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); |
8120 | 8120 |
8121 FrameTestHelpers::createLocalChild(remoteRoot); | 8121 FrameTestHelpers::createLocalChild(remoteRoot); |
8122 | 8122 |
8123 // Do a remote-to-local swap of the top frame. | 8123 // Do a remote-to-local swap of the top frame. |
8124 FrameTestHelpers::TestWebFrameClient localClient; | 8124 FrameTestHelpers::TestWebFrameClient localClient; |
8125 WebLocalFrame* localRoot = WebLocalFrame::createProvisional(&localClient, re
moteRoot, WebSandboxFlags::None, WebFrameOwnerProperties()); | 8125 WebLocalFrame* localRoot = WebLocalFrame::createProvisional(&localClient, re
moteRoot, WebSandboxFlags::None); |
8126 remoteRoot->swap(localRoot); | 8126 remoteRoot->swap(localRoot); |
8127 | 8127 |
8128 // Load a page with a child frame in the new root to make sure this doesn't | 8128 // Load a page with a child frame in the new root to make sure this doesn't |
8129 // crash when the child frame invokes setCoreFrame. | 8129 // crash when the child frame invokes setCoreFrame. |
8130 registerMockedHttpURLLoad("single_iframe.html"); | 8130 registerMockedHttpURLLoad("single_iframe.html"); |
8131 registerMockedHttpURLLoad("visible_iframe.html"); | 8131 registerMockedHttpURLLoad("visible_iframe.html"); |
8132 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); | 8132 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); |
8133 | 8133 |
8134 view->close(); | 8134 view->close(); |
8135 } | 8135 } |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8684 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); | 8684 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); |
8685 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 8685 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
8686 mainFrame->executeScript(WebScriptSource("hello = 'world';")); | 8686 mainFrame->executeScript(WebScriptSource("hello = 'world';")); |
8687 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); | 8687 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); |
8688 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri
ptSource("hello")); | 8688 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri
ptSource("hello")); |
8689 ASSERT_TRUE(result->IsString()); | 8689 ASSERT_TRUE(result->IsString()); |
8690 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC
ontext()).ToLocalChecked())); | 8690 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC
ontext()).ToLocalChecked())); |
8691 } | 8691 } |
8692 | 8692 |
8693 } // namespace blink | 8693 } // namespace blink |
OLD | NEW |