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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 1938753002: OOPIF: Replicate allowFullscreen flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 7088 matching lines...) Expand 10 before | Expand all | Expand 10 after
7099 private: 7099 private:
7100 FrameTestHelpers::WebViewHelper m_webViewHelper; 7100 FrameTestHelpers::WebViewHelper m_webViewHelper;
7101 }; 7101 };
7102 7102
7103 TEST_F(WebFrameSwapTest, SwapMainFrame) 7103 TEST_F(WebFrameSwapTest, SwapMainFrame)
7104 { 7104 {
7105 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr); 7105 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr);
7106 mainFrame()->swap(remoteFrame); 7106 mainFrame()->swap(remoteFrame);
7107 7107
7108 FrameTestHelpers::TestWebFrameClient client; 7108 FrameTestHelpers::TestWebFrameClient client;
7109 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7109 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None);
7110 remoteFrame->swap(localFrame); 7110 remoteFrame->swap(localFrame);
7111 7111
7112 // Finally, make sure an embedder triggered load in the local frame swapped 7112 // Finally, make sure an embedder triggered load in the local frame swapped
7113 // back in works. 7113 // back in works.
7114 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7114 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7115 7115
7116 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10 24).utf8(); 7116 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10 24).utf8();
7117 EXPECT_EQ("hello", content); 7117 EXPECT_EQ("hello", content);
7118 7118
7119 // Manually reset to break WebViewHelper's dependency on the stack allocated 7119 // Manually reset to break WebViewHelper's dependency on the stack allocated
7120 // TestWebFrameClient. 7120 // TestWebFrameClient.
7121 reset(); 7121 reset();
7122 remoteFrame->close(); 7122 remoteFrame->close();
7123 } 7123 }
7124 7124
7125 TEST_F(WebFrameSwapTest, ValidateSizeOnRemoteToLocalMainFrameSwap) 7125 TEST_F(WebFrameSwapTest, ValidateSizeOnRemoteToLocalMainFrameSwap)
7126 { 7126 {
7127 WebSize size(111, 222); 7127 WebSize size(111, 222);
7128 7128
7129 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr); 7129 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr);
7130 mainFrame()->swap(remoteFrame); 7130 mainFrame()->swap(remoteFrame);
7131 7131
7132 remoteFrame->view()->resize(size); 7132 remoteFrame->view()->resize(size);
7133 7133
7134 FrameTestHelpers::TestWebFrameClient client; 7134 FrameTestHelpers::TestWebFrameClient client;
7135 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7135 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None);
7136 remoteFrame->swap(localFrame); 7136 remoteFrame->swap(localFrame);
7137 7137
7138 // Verify that the size that was set with a remote main frame is correct 7138 // Verify that the size that was set with a remote main frame is correct
7139 // after swapping to a local frame. 7139 // after swapping to a local frame.
7140 FrameHost* host = toWebViewImpl(localFrame->view())->page()->mainFrame()->ho st(); 7140 FrameHost* host = toWebViewImpl(localFrame->view())->page()->mainFrame()->ho st();
7141 EXPECT_EQ(size.width, host->visualViewport().size().width()); 7141 EXPECT_EQ(size.width, host->visualViewport().size().width());
7142 EXPECT_EQ(size.height, host->visualViewport().size().height()); 7142 EXPECT_EQ(size.height, host->visualViewport().size().height());
7143 7143
7144 // Manually reset to break WebViewHelper's dependency on the stack allocated 7144 // Manually reset to break WebViewHelper's dependency on the stack allocated
7145 // TestWebFrameClient. 7145 // TestWebFrameClient.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
7200 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling()); 7200 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling());
7201 } 7201 }
7202 7202
7203 TEST_F(WebFrameSwapTest, SwapFirstChild) 7203 TEST_F(WebFrameSwapTest, SwapFirstChild)
7204 { 7204 {
7205 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7205 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7206 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7206 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7207 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame ); 7207 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame );
7208 7208
7209 FrameTestHelpers::TestWebFrameClient client; 7209 FrameTestHelpers::TestWebFrameClient client;
7210 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7210 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None);
7211 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ; 7211 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ;
7212 7212
7213 // FIXME: This almost certainly fires more load events on the iframe element 7213 // FIXME: This almost certainly fires more load events on the iframe element
7214 // than it should. 7214 // than it should.
7215 // Finally, make sure an embedder triggered load in the local frame swapped 7215 // Finally, make sure an embedder triggered load in the local frame swapped
7216 // back in works. 7216 // back in works.
7217 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7217 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7218 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10 24).utf8(); 7218 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10 24).utf8();
7219 EXPECT_EQ(" \n\nhello\n\nb \n\na\n\nc", content); 7219 EXPECT_EQ(" \n\nhello\n\nb \n\na\n\nc", content);
7220 7220
(...skipping 17 matching lines...) Expand all
7238 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()); 7238 EXPECT_EQ(newChild->nextSibling(), parent->lastChild());
7239 } 7239 }
7240 7240
7241 TEST_F(WebFrameSwapTest, SwapMiddleChild) 7241 TEST_F(WebFrameSwapTest, SwapMiddleChild)
7242 { 7242 {
7243 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7243 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7244 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7244 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7245 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e); 7245 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e);
7246 7246
7247 FrameTestHelpers::TestWebFrameClient client; 7247 FrameTestHelpers::TestWebFrameClient client;
7248 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7248 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None);
7249 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame ); 7249 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame );
7250 7250
7251 // FIXME: This almost certainly fires more load events on the iframe element 7251 // FIXME: This almost certainly fires more load events on the iframe element
7252 // than it should. 7252 // than it should.
7253 // Finally, make sure an embedder triggered load in the local frame swapped 7253 // Finally, make sure an embedder triggered load in the local frame swapped
7254 // back in works. 7254 // back in works.
7255 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7255 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7256 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10 24).utf8(); 7256 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10 24).utf8();
7257 EXPECT_EQ(" \n\na\n\nhello\n\nc", content); 7257 EXPECT_EQ(" \n\na\n\nhello\n\nc", content);
7258 7258
(...skipping 14 matching lines...) Expand all
7273 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()->nextSibling()); 7273 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()->nextSibling());
7274 } 7274 }
7275 7275
7276 TEST_F(WebFrameSwapTest, SwapLastChild) 7276 TEST_F(WebFrameSwapTest, SwapLastChild)
7277 { 7277 {
7278 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7278 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7279 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7279 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7280 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ; 7280 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ;
7281 7281
7282 FrameTestHelpers::TestWebFrameClient client; 7282 FrameTestHelpers::TestWebFrameClient client;
7283 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7283 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None);
7284 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); 7284 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame);
7285 7285
7286 // FIXME: This almost certainly fires more load events on the iframe element 7286 // FIXME: This almost certainly fires more load events on the iframe element
7287 // than it should. 7287 // than it should.
7288 // Finally, make sure an embedder triggered load in the local frame swapped 7288 // Finally, make sure an embedder triggered load in the local frame swapped
7289 // back in works. 7289 // back in works.
7290 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7290 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7291 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10 24).utf8(); 7291 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10 24).utf8();
7292 EXPECT_EQ(" \n\na\n\nb \n\na\n\nhello", content); 7292 EXPECT_EQ(" \n\na\n\nb \n\na\n\nhello", content);
7293 7293
(...skipping 23 matching lines...) Expand all
7317 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame); 7317 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame);
7318 7318
7319 targetFrame = mainFrame()->firstChild()->nextSibling(); 7319 targetFrame = mainFrame()->firstChild()->nextSibling();
7320 EXPECT_TRUE(targetFrame); 7320 EXPECT_TRUE(targetFrame);
7321 7321
7322 // Create child frames in the target frame before testing the swap. 7322 // Create child frames in the target frame before testing the swap.
7323 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; 7323 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2;
7324 WebRemoteFrame* childRemoteFrame = FrameTestHelpers::createRemoteChild(remot eFrame, &remoteFrameClient2); 7324 WebRemoteFrame* childRemoteFrame = FrameTestHelpers::createRemoteChild(remot eFrame, &remoteFrameClient2);
7325 7325
7326 FrameTestHelpers::TestWebFrameClient client; 7326 FrameTestHelpers::TestWebFrameClient client;
7327 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7327 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None);
7328 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); 7328 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame);
7329 7329
7330 // FIXME: This almost certainly fires more load events on the iframe element 7330 // FIXME: This almost certainly fires more load events on the iframe element
7331 // than it should. 7331 // than it should.
7332 // Finally, make sure an embedder triggered load in the local frame swapped 7332 // Finally, make sure an embedder triggered load in the local frame swapped
7333 // back in works. 7333 // back in works.
7334 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7334 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7335 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10 24).utf8(); 7335 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10 24).utf8();
7336 EXPECT_EQ(" \n\na\n\nhello\n\nc", content); 7336 EXPECT_EQ(" \n\na\n\nhello\n\nc", content);
7337 7337
(...skipping 22 matching lines...) Expand all
7360 v8::Local<v8::Value> remoteWindow = mainFrame()->executeScriptAndReturnValue (WebScriptSource( 7360 v8::Local<v8::Value> remoteWindow = mainFrame()->executeScriptAndReturnValue (WebScriptSource(
7361 "document.querySelector('#frame2').contentWindow;")); 7361 "document.querySelector('#frame2').contentWindow;"));
7362 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow)); 7362 EXPECT_TRUE(originalWindow->StrictEquals(remoteWindow));
7363 // Check that its view is consistent with the world. 7363 // Check that its view is consistent with the world.
7364 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource( 7364 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource(
7365 "document.querySelector('#frame2').contentWindow.top;")); 7365 "document.querySelector('#frame2').contentWindow.top;"));
7366 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); 7366 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop));
7367 7367
7368 // Now check that remote -> local works too, since it goes through a differe nt code path. 7368 // Now check that remote -> local works too, since it goes through a differe nt code path.
7369 FrameTestHelpers::TestWebFrameClient client; 7369 FrameTestHelpers::TestWebFrameClient client;
7370 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7370 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None);
7371 remoteFrame->swap(localFrame); 7371 remoteFrame->swap(localFrame);
7372 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( WebScriptSource( 7372 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( WebScriptSource(
7373 "document.querySelector('#frame2').contentWindow;")); 7373 "document.querySelector('#frame2').contentWindow;"));
7374 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); 7374 EXPECT_TRUE(originalWindow->StrictEquals(localWindow));
7375 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource( 7375 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource(
7376 "document.querySelector('#frame2').contentWindow.top;")); 7376 "document.querySelector('#frame2').contentWindow.top;"));
7377 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); 7377 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop));
7378 7378
7379 // Manually reset to break WebViewHelper's dependency on the stack allocated 7379 // Manually reset to break WebViewHelper's dependency on the stack allocated
7380 // TestWebFrameClient. 7380 // TestWebFrameClient.
(...skipping 12 matching lines...) Expand all
7393 7393
7394 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7394 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7395 WebRemoteFrame* remoteFrame = remoteClient.frame(); 7395 WebRemoteFrame* remoteFrame = remoteClient.frame();
7396 mainFrame()->lastChild()->swap(remoteFrame); 7396 mainFrame()->lastChild()->swap(remoteFrame);
7397 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7397 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7398 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource("saved.top")); 7398 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa lue(WebScriptSource("saved.top"));
7399 EXPECT_TRUE(remoteWindowTop->IsObject()); 7399 EXPECT_TRUE(remoteWindowTop->IsObject());
7400 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); 7400 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop));
7401 7401
7402 FrameTestHelpers::TestWebFrameClient client; 7402 FrameTestHelpers::TestWebFrameClient client;
7403 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7403 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None);
7404 remoteFrame->swap(localFrame); 7404 remoteFrame->swap(localFrame);
7405 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource("saved.top")); 7405 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource("saved.top"));
7406 EXPECT_TRUE(localWindowTop->IsObject()); 7406 EXPECT_TRUE(localWindowTop->IsObject());
7407 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); 7407 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop));
7408 7408
7409 reset(); 7409 reset();
7410 } 7410 }
7411 7411
7412 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) 7412 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable)
7413 { 7413 {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
7536 { 7536 {
7537 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7537 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7538 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7538 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7539 WebFrame* targetFrame = mainFrame()->firstChild(); 7539 WebFrame* targetFrame = mainFrame()->firstChild();
7540 ASSERT_TRUE(targetFrame); 7540 ASSERT_TRUE(targetFrame);
7541 targetFrame->swap(remoteFrame); 7541 targetFrame->swap(remoteFrame);
7542 ASSERT_TRUE(mainFrame()->firstChild()); 7542 ASSERT_TRUE(mainFrame()->firstChild());
7543 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 7543 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
7544 7544
7545 RemoteToLocalSwapWebFrameClient client(remoteFrame); 7545 RemoteToLocalSwapWebFrameClient client(remoteFrame);
7546 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7546 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None);
7547 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7547 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7548 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); 7548 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType());
7549 7549
7550 // Manually reset to break WebViewHelper's dependency on the stack allocated 7550 // Manually reset to break WebViewHelper's dependency on the stack allocated
7551 // TestWebFrameClient. 7551 // TestWebFrameClient.
7552 reset(); 7552 reset();
7553 remoteFrame->close(); 7553 remoteFrame->close();
7554 } 7554 }
7555 7555
7556 // The commit type should be Standard if we are swapping a RemoteFrame to a 7556 // The commit type should be Standard if we are swapping a RemoteFrame to a
7557 // LocalFrame after commits have already happened in the frame. The browser 7557 // LocalFrame after commits have already happened in the frame. The browser
7558 // process will inform us via setCommittedFirstRealLoad. 7558 // process will inform us via setCommittedFirstRealLoad.
7559 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) 7559 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap)
7560 { 7560 {
7561 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7561 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7562 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7562 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7563 WebFrame* targetFrame = mainFrame()->firstChild(); 7563 WebFrame* targetFrame = mainFrame()->firstChild();
7564 ASSERT_TRUE(targetFrame); 7564 ASSERT_TRUE(targetFrame);
7565 targetFrame->swap(remoteFrame); 7565 targetFrame->swap(remoteFrame);
7566 ASSERT_TRUE(mainFrame()->firstChild()); 7566 ASSERT_TRUE(mainFrame()->firstChild());
7567 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 7567 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
7568 7568
7569 RemoteToLocalSwapWebFrameClient client(remoteFrame); 7569 RemoteToLocalSwapWebFrameClient client(remoteFrame);
7570 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7570 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None);
7571 localFrame->setCommittedFirstRealLoad(); 7571 localFrame->setCommittedFirstRealLoad();
7572 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7572 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7573 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); 7573 EXPECT_EQ(WebStandardCommit, client.historyCommitType());
7574 7574
7575 // Manually reset to break WebViewHelper's dependency on the stack allocated 7575 // Manually reset to break WebViewHelper's dependency on the stack allocated
7576 // TestWebFrameClient. 7576 // TestWebFrameClient.
7577 reset(); 7577 reset();
7578 remoteFrame->close(); 7578 remoteFrame->close();
7579 } 7579 }
7580 7580
(...skipping 10 matching lines...) Expand all
7591 // Swap to a RemoteFrame. 7591 // Swap to a RemoteFrame.
7592 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7592 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7593 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); 7593 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient);
7594 targetFrame->swap(remoteFrame); 7594 targetFrame->swap(remoteFrame);
7595 ASSERT_TRUE(mainFrame()->firstChild()); 7595 ASSERT_TRUE(mainFrame()->firstChild());
7596 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 7596 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
7597 EXPECT_EQ(uniqueName.utf8(), WebString(toWebRemoteFrameImpl(remoteFrame)->fr ame()->tree().uniqueName()).utf8()); 7597 EXPECT_EQ(uniqueName.utf8(), WebString(toWebRemoteFrameImpl(remoteFrame)->fr ame()->tree().uniqueName()).utf8());
7598 7598
7599 // Swap back to a LocalFrame. 7599 // Swap back to a LocalFrame.
7600 RemoteToLocalSwapWebFrameClient client(remoteFrame); 7600 RemoteToLocalSwapWebFrameClient client(remoteFrame);
7601 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7601 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None);
7602 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7602 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7603 EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8()); 7603 EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8());
7604 EXPECT_EQ(uniqueName.utf8(), WebString(toWebLocalFrameImpl(localFrame)->fram e()->loader().currentItem()->target()).utf8()); 7604 EXPECT_EQ(uniqueName.utf8(), WebString(toWebLocalFrameImpl(localFrame)->fram e()->loader().currentItem()->target()).utf8());
7605 7605
7606 // Repeat with no name on the frame. 7606 // Repeat with no name on the frame.
7607 localFrame->setName(""); 7607 localFrame->setName("");
7608 WebString uniqueName2 = localFrame->uniqueName(); 7608 WebString uniqueName2 = localFrame->uniqueName();
7609 EXPECT_EQ("<!--framePath //<!--frame2-->-->", uniqueName2.utf8()); 7609 EXPECT_EQ("<!--framePath //<!--frame2-->-->", uniqueName2.utf8());
7610 7610
7611 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; 7611 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2;
7612 WebRemoteFrame* remoteFrame2 = WebRemoteFrame::create(WebTreeScopeType::Docu ment, &remoteFrameClient2); 7612 WebRemoteFrame* remoteFrame2 = WebRemoteFrame::create(WebTreeScopeType::Docu ment, &remoteFrameClient2);
7613 localFrame->swap(remoteFrame2); 7613 localFrame->swap(remoteFrame2);
7614 ASSERT_TRUE(mainFrame()->firstChild()); 7614 ASSERT_TRUE(mainFrame()->firstChild());
7615 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame2); 7615 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame2);
7616 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebRemoteFrameImpl(remoteFrame2)-> frame()->tree().uniqueName()).utf8()); 7616 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebRemoteFrameImpl(remoteFrame2)-> frame()->tree().uniqueName()).utf8());
7617 7617
7618 RemoteToLocalSwapWebFrameClient client2(remoteFrame2); 7618 RemoteToLocalSwapWebFrameClient client2(remoteFrame2);
7619 WebLocalFrame* localFrame2 = WebLocalFrame::createProvisional(&client2, remo teFrame2, WebSandboxFlags::None, WebFrameOwnerProperties()); 7619 WebLocalFrame* localFrame2 = WebLocalFrame::createProvisional(&client2, remo teFrame2, WebSandboxFlags::None);
7620 FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html"); 7620 FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html");
7621 EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8()); 7621 EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8());
7622 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebLocalFrameImpl(localFrame2)->fr ame()->loader().currentItem()->target()).utf8()); 7622 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebLocalFrameImpl(localFrame2)->fr ame()->loader().currentItem()->target()).utf8());
7623 7623
7624 // Manually reset to break WebViewHelper's dependency on the stack allocated 7624 // Manually reset to break WebViewHelper's dependency on the stack allocated
7625 // TestWebFrameClient. 7625 // TestWebFrameClient.
7626 reset(); 7626 reset();
7627 remoteFrame->close(); 7627 remoteFrame->close();
7628 remoteFrame2->close(); 7628 remoteFrame2->close();
7629 } 7629 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
7747 WebView* popupView = WebView::create(&popupViewClient); 7747 WebView* popupView = WebView::create(&popupViewClient);
7748 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient; 7748 FrameTestHelpers::TestWebRemoteFrameClient popupRemoteClient;
7749 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame(); 7749 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame();
7750 popupView->setMainFrame(popupRemoteFrame); 7750 popupView->setMainFrame(popupRemoteFrame);
7751 popupRemoteFrame->setOpener(mainFrame); 7751 popupRemoteFrame->setOpener(mainFrame);
7752 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h ttp://foo.com")); 7752 popupRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("h ttp://foo.com"));
7753 EXPECT_FALSE(mainFrame->getSecurityOrigin().canAccess(popupView->mainFrame() ->getSecurityOrigin())); 7753 EXPECT_FALSE(mainFrame->getSecurityOrigin().canAccess(popupView->mainFrame() ->getSecurityOrigin()));
7754 7754
7755 // Do a remote-to-local swap in the popup. 7755 // Do a remote-to-local swap in the popup.
7756 FrameTestHelpers::TestWebFrameClient popupLocalClient; 7756 FrameTestHelpers::TestWebFrameClient popupLocalClient;
7757 WebLocalFrame* popupLocalFrame = WebLocalFrame::createProvisional(&popupLoca lClient, popupRemoteFrame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7757 WebLocalFrame* popupLocalFrame = WebLocalFrame::createProvisional(&popupLoca lClient, popupRemoteFrame, WebSandboxFlags::None);
7758 popupRemoteFrame->swap(popupLocalFrame); 7758 popupRemoteFrame->swap(popupLocalFrame);
7759 7759
7760 // The initial document created during the remote-to-local swap should have 7760 // The initial document created during the remote-to-local swap should have
7761 // inherited its opener's SecurityOrigin. 7761 // inherited its opener's SecurityOrigin.
7762 EXPECT_TRUE(mainFrame->getSecurityOrigin().canAccess(popupView->mainFrame()- >getSecurityOrigin())); 7762 EXPECT_TRUE(mainFrame->getSecurityOrigin().canAccess(popupView->mainFrame()- >getSecurityOrigin()));
7763 7763
7764 popupView->close(); 7764 popupView->close();
7765 } 7765 }
7766 7766
7767 TEST_F(WebFrameTest, SwapWithOpenerCycle) 7767 TEST_F(WebFrameTest, SwapWithOpenerCycle)
7768 { 7768 {
7769 // First, create a remote main frame with itself as the opener. 7769 // First, create a remote main frame with itself as the opener.
7770 FrameTestHelpers::TestWebViewClient viewClient; 7770 FrameTestHelpers::TestWebViewClient viewClient;
7771 WebView* view = WebView::create(&viewClient); 7771 WebView* view = WebView::create(&viewClient);
7772 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7772 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7773 WebRemoteFrame* remoteFrame = remoteClient.frame(); 7773 WebRemoteFrame* remoteFrame = remoteClient.frame();
7774 view->setMainFrame(remoteFrame); 7774 view->setMainFrame(remoteFrame);
7775 remoteFrame->setOpener(remoteFrame); 7775 remoteFrame->setOpener(remoteFrame);
7776 7776
7777 // Now swap in a local frame. It shouldn't crash. 7777 // Now swap in a local frame. It shouldn't crash.
7778 FrameTestHelpers::TestWebFrameClient localClient; 7778 FrameTestHelpers::TestWebFrameClient localClient;
7779 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&localClient, r emoteFrame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7779 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&localClient, r emoteFrame, WebSandboxFlags::None);
7780 remoteFrame->swap(localFrame); 7780 remoteFrame->swap(localFrame);
7781 7781
7782 // And the opener cycle should still be preserved. 7782 // And the opener cycle should still be preserved.
7783 EXPECT_EQ(localFrame, localFrame->opener()); 7783 EXPECT_EQ(localFrame, localFrame->opener());
7784 7784
7785 view->close(); 7785 view->close();
7786 } 7786 }
7787 7787
7788 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 7788 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
7789 public: 7789 public:
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
8085 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 8085 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
8086 WebView* view = WebView::create(&viewClient); 8086 WebView* view = WebView::create(&viewClient);
8087 view->setMainFrame(remoteClient.frame()); 8087 view->setMainFrame(remoteClient.frame());
8088 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); 8088 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame();
8089 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); 8089 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique());
8090 8090
8091 FrameTestHelpers::createLocalChild(remoteRoot); 8091 FrameTestHelpers::createLocalChild(remoteRoot);
8092 8092
8093 // Do a remote-to-local swap of the top frame. 8093 // Do a remote-to-local swap of the top frame.
8094 FrameTestHelpers::TestWebFrameClient localClient; 8094 FrameTestHelpers::TestWebFrameClient localClient;
8095 WebLocalFrame* localRoot = WebLocalFrame::createProvisional(&localClient, re moteRoot, WebSandboxFlags::None, WebFrameOwnerProperties()); 8095 WebLocalFrame* localRoot = WebLocalFrame::createProvisional(&localClient, re moteRoot, WebSandboxFlags::None);
8096 remoteRoot->swap(localRoot); 8096 remoteRoot->swap(localRoot);
8097 8097
8098 // Load a page with a child frame in the new root to make sure this doesn't 8098 // Load a page with a child frame in the new root to make sure this doesn't
8099 // crash when the child frame invokes setCoreFrame. 8099 // crash when the child frame invokes setCoreFrame.
8100 registerMockedHttpURLLoad("single_iframe.html"); 8100 registerMockedHttpURLLoad("single_iframe.html");
8101 registerMockedHttpURLLoad("visible_iframe.html"); 8101 registerMockedHttpURLLoad("visible_iframe.html");
8102 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); 8102 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html");
8103 8103
8104 view->close(); 8104 view->close();
8105 } 8105 }
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
8654 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); 8654 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame();
8655 v8::HandleScope scope(v8::Isolate::GetCurrent()); 8655 v8::HandleScope scope(v8::Isolate::GetCurrent());
8656 mainFrame->executeScript(WebScriptSource("hello = 'world';")); 8656 mainFrame->executeScript(WebScriptSource("hello = 'world';"));
8657 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); 8657 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page");
8658 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello")); 8658 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello"));
8659 ASSERT_TRUE(result->IsString()); 8659 ASSERT_TRUE(result->IsString());
8660 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC ontext()).ToLocalChecked())); 8660 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC ontext()).ToLocalChecked()));
8661 } 8661 }
8662 8662
8663 } // namespace blink 8663 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698