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

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

Issue 2651583007: Plumbing blink::Interface{Provider|Registry} through WebLocalFrame's constructor. (Closed)
Patch Set: Rebasing... Created 3 years, 10 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 7057 matching lines...) Expand 10 before | Expand all | Expand 10 after
7068 7068
7069 virtual WebLocalFrame* createChildFrame( 7069 virtual WebLocalFrame* createChildFrame(
7070 WebLocalFrame* parent, 7070 WebLocalFrame* parent,
7071 WebTreeScopeType scope, 7071 WebTreeScopeType scope,
7072 const WebString&, 7072 const WebString&,
7073 const WebString&, 7073 const WebString&,
7074 WebSandboxFlags, 7074 WebSandboxFlags,
7075 const WebFrameOwnerProperties& frameOwnerProperties) { 7075 const WebFrameOwnerProperties& frameOwnerProperties) {
7076 DCHECK(m_childClient); 7076 DCHECK(m_childClient);
7077 m_childFrameCreationCount++; 7077 m_childFrameCreationCount++;
7078 WebLocalFrame* frame = WebLocalFrame::create(scope, m_childClient); 7078 WebLocalFrame* frame =
7079 WebLocalFrame::create(scope, m_childClient, nullptr, nullptr);
7079 parent->appendChild(frame); 7080 parent->appendChild(frame);
7080 return frame; 7081 return frame;
7081 } 7082 }
7082 7083
7083 virtual void didStartLoading(bool toDifferentDocument) { 7084 virtual void didStartLoading(bool toDifferentDocument) {
7084 if (m_parentClient) { 7085 if (m_parentClient) {
7085 m_parentClient->didStartLoading(toDifferentDocument); 7086 m_parentClient->didStartLoading(toDifferentDocument);
7086 return; 7087 return;
7087 } 7088 }
7088 TestWebFrameClient::didStartLoading(toDifferentDocument); 7089 TestWebFrameClient::didStartLoading(toDifferentDocument);
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
8481 FrameTestHelpers::WebViewHelper m_webViewHelper; 8482 FrameTestHelpers::WebViewHelper m_webViewHelper;
8482 }; 8483 };
8483 8484
8484 TEST_F(WebFrameSwapTest, SwapMainFrame) { 8485 TEST_F(WebFrameSwapTest, SwapMainFrame) {
8485 WebRemoteFrame* remoteFrame = 8486 WebRemoteFrame* remoteFrame =
8486 WebRemoteFrame::create(WebTreeScopeType::Document, nullptr); 8487 WebRemoteFrame::create(WebTreeScopeType::Document, nullptr);
8487 mainFrame()->swap(remoteFrame); 8488 mainFrame()->swap(remoteFrame);
8488 8489
8489 FrameTestHelpers::TestWebFrameClient client; 8490 FrameTestHelpers::TestWebFrameClient client;
8490 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( 8491 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
8491 &client, remoteFrame, WebSandboxFlags::None); 8492 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
8492 FrameTestHelpers::TestWebWidgetClient webWidgetClient; 8493 FrameTestHelpers::TestWebWidgetClient webWidgetClient;
8493 WebFrameWidget::create(&webWidgetClient, localFrame); 8494 WebFrameWidget::create(&webWidgetClient, localFrame);
8494 remoteFrame->swap(localFrame); 8495 remoteFrame->swap(localFrame);
8495 8496
8496 // Finally, make sure an embedder triggered load in the local frame swapped 8497 // Finally, make sure an embedder triggered load in the local frame swapped
8497 // back in works. 8498 // back in works.
8498 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 8499 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
8499 8500
8500 std::string content = 8501 std::string content =
8501 WebFrameContentDumper::dumpWebViewAsText(webView(), 1024).utf8(); 8502 WebFrameContentDumper::dumpWebViewAsText(webView(), 1024).utf8();
8502 EXPECT_EQ("hello", content); 8503 EXPECT_EQ("hello", content);
8503 8504
8504 // Manually reset to break WebViewHelper's dependency on the stack allocated 8505 // Manually reset to break WebViewHelper's dependency on the stack allocated
8505 // TestWebFrameClient. 8506 // TestWebFrameClient.
8506 reset(); 8507 reset();
8507 remoteFrame->close(); 8508 remoteFrame->close();
8508 } 8509 }
8509 8510
8510 TEST_F(WebFrameSwapTest, ValidateSizeOnRemoteToLocalMainFrameSwap) { 8511 TEST_F(WebFrameSwapTest, ValidateSizeOnRemoteToLocalMainFrameSwap) {
8511 WebSize size(111, 222); 8512 WebSize size(111, 222);
8512 8513
8513 WebRemoteFrame* remoteFrame = 8514 WebRemoteFrame* remoteFrame =
8514 WebRemoteFrame::create(WebTreeScopeType::Document, nullptr); 8515 WebRemoteFrame::create(WebTreeScopeType::Document, nullptr);
8515 mainFrame()->swap(remoteFrame); 8516 mainFrame()->swap(remoteFrame);
8516 8517
8517 remoteFrame->view()->resize(size); 8518 remoteFrame->view()->resize(size);
8518 8519
8519 FrameTestHelpers::TestWebFrameClient client; 8520 FrameTestHelpers::TestWebFrameClient client;
8520 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( 8521 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
8521 &client, remoteFrame, WebSandboxFlags::None); 8522 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
8522 remoteFrame->swap(localFrame); 8523 remoteFrame->swap(localFrame);
8523 8524
8524 // Verify that the size that was set with a remote main frame is correct 8525 // Verify that the size that was set with a remote main frame is correct
8525 // after swapping to a local frame. 8526 // after swapping to a local frame.
8526 FrameHost* host = 8527 FrameHost* host =
8527 toWebViewImpl(localFrame->view())->page()->mainFrame()->host(); 8528 toWebViewImpl(localFrame->view())->page()->mainFrame()->host();
8528 EXPECT_EQ(size.width, host->visualViewport().size().width()); 8529 EXPECT_EQ(size.width, host->visualViewport().size().width());
8529 EXPECT_EQ(size.height, host->visualViewport().size().height()); 8530 EXPECT_EQ(size.height, host->visualViewport().size().height());
8530 8531
8531 // Manually reset to break WebViewHelper's dependency on the stack allocated 8532 // Manually reset to break WebViewHelper's dependency on the stack allocated
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
8590 } 8591 }
8591 8592
8592 TEST_F(WebFrameSwapTest, SwapFirstChild) { 8593 TEST_F(WebFrameSwapTest, SwapFirstChild) {
8593 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 8594 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
8594 WebRemoteFrame* remoteFrame = 8595 WebRemoteFrame* remoteFrame =
8595 WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient); 8596 WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient);
8596 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame); 8597 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame);
8597 8598
8598 FrameTestHelpers::TestWebFrameClient client; 8599 FrameTestHelpers::TestWebFrameClient client;
8599 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( 8600 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
8600 &client, remoteFrame, WebSandboxFlags::None); 8601 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
8601 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame); 8602 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame);
8602 8603
8603 // FIXME: This almost certainly fires more load events on the iframe element 8604 // FIXME: This almost certainly fires more load events on the iframe element
8604 // than it should. 8605 // than it should.
8605 // Finally, make sure an embedder triggered load in the local frame swapped 8606 // Finally, make sure an embedder triggered load in the local frame swapped
8606 // back in works. 8607 // back in works.
8607 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 8608 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
8608 std::string content = 8609 std::string content =
8609 WebFrameContentDumper::dumpWebViewAsText(webView(), 1024).utf8(); 8610 WebFrameContentDumper::dumpWebViewAsText(webView(), 1024).utf8();
8610 EXPECT_EQ(" \n\nhello\n\nb \n\na\n\nc", content); 8611 EXPECT_EQ(" \n\nhello\n\nb \n\na\n\nc", content);
(...skipping 22 matching lines...) Expand all
8633 8634
8634 TEST_F(WebFrameSwapTest, SwapMiddleChild) { 8635 TEST_F(WebFrameSwapTest, SwapMiddleChild) {
8635 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 8636 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
8636 WebRemoteFrame* remoteFrame = 8637 WebRemoteFrame* remoteFrame =
8637 WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient); 8638 WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient);
8638 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), 8639 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(),
8639 remoteFrame); 8640 remoteFrame);
8640 8641
8641 FrameTestHelpers::TestWebFrameClient client; 8642 FrameTestHelpers::TestWebFrameClient client;
8642 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( 8643 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
8643 &client, remoteFrame, WebSandboxFlags::None); 8644 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
8644 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame); 8645 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame);
8645 8646
8646 // FIXME: This almost certainly fires more load events on the iframe element 8647 // FIXME: This almost certainly fires more load events on the iframe element
8647 // than it should. 8648 // than it should.
8648 // Finally, make sure an embedder triggered load in the local frame swapped 8649 // Finally, make sure an embedder triggered load in the local frame swapped
8649 // back in works. 8650 // back in works.
8650 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 8651 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
8651 std::string content = 8652 std::string content =
8652 WebFrameContentDumper::dumpWebViewAsText(webView(), 1024).utf8(); 8653 WebFrameContentDumper::dumpWebViewAsText(webView(), 1024).utf8();
8653 EXPECT_EQ(" \n\na\n\nhello\n\nc", content); 8654 EXPECT_EQ(" \n\na\n\nhello\n\nc", content);
(...skipping 17 matching lines...) Expand all
8671 } 8672 }
8672 8673
8673 TEST_F(WebFrameSwapTest, SwapLastChild) { 8674 TEST_F(WebFrameSwapTest, SwapLastChild) {
8674 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 8675 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
8675 WebRemoteFrame* remoteFrame = 8676 WebRemoteFrame* remoteFrame =
8676 WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient); 8677 WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient);
8677 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame); 8678 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame);
8678 8679
8679 FrameTestHelpers::TestWebFrameClient client; 8680 FrameTestHelpers::TestWebFrameClient client;
8680 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( 8681 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
8681 &client, remoteFrame, WebSandboxFlags::None); 8682 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
8682 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); 8683 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame);
8683 8684
8684 // FIXME: This almost certainly fires more load events on the iframe element 8685 // FIXME: This almost certainly fires more load events on the iframe element
8685 // than it should. 8686 // than it should.
8686 // Finally, make sure an embedder triggered load in the local frame swapped 8687 // Finally, make sure an embedder triggered load in the local frame swapped
8687 // back in works. 8688 // back in works.
8688 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 8689 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
8689 std::string content = 8690 std::string content =
8690 WebFrameContentDumper::dumpWebViewAsText(webView(), 1024).utf8(); 8691 WebFrameContentDumper::dumpWebViewAsText(webView(), 1024).utf8();
8691 EXPECT_EQ(" \n\na\n\nb \n\na\n\nhello", content); 8692 EXPECT_EQ(" \n\na\n\nb \n\na\n\nhello", content);
8692 8693
8693 // Manually reset to break WebViewHelper's dependency on the stack allocated 8694 // Manually reset to break WebViewHelper's dependency on the stack allocated
8694 // TestWebFrameClient. 8695 // TestWebFrameClient.
8695 reset(); 8696 reset();
8696 remoteFrame->close(); 8697 remoteFrame->close();
8697 } 8698 }
8698 8699
8699 TEST_F(WebFrameSwapTest, DetachProvisionalFrame) { 8700 TEST_F(WebFrameSwapTest, DetachProvisionalFrame) {
8700 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 8701 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
8701 WebRemoteFrameImpl* remoteFrame = WebRemoteFrameImpl::create( 8702 WebRemoteFrameImpl* remoteFrame = WebRemoteFrameImpl::create(
8702 WebTreeScopeType::Document, &remoteFrameClient); 8703 WebTreeScopeType::Document, &remoteFrameClient);
8703 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), 8704 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(),
8704 remoteFrame); 8705 remoteFrame);
8705 8706
8706 FrameTestHelpers::TestWebFrameClient client; 8707 FrameTestHelpers::TestWebFrameClient client;
8707 WebLocalFrameImpl* provisionalFrame = WebLocalFrameImpl::createProvisional( 8708 WebLocalFrameImpl* provisionalFrame = WebLocalFrameImpl::createProvisional(
8708 &client, remoteFrame, WebSandboxFlags::None); 8709 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
8709 8710
8710 // The provisional frame should have a local frame owner. 8711 // The provisional frame should have a local frame owner.
8711 FrameOwner* owner = provisionalFrame->frame()->owner(); 8712 FrameOwner* owner = provisionalFrame->frame()->owner();
8712 ASSERT_TRUE(owner->isLocal()); 8713 ASSERT_TRUE(owner->isLocal());
8713 8714
8714 // But the owner should point to |remoteFrame|, since the new frame is still 8715 // But the owner should point to |remoteFrame|, since the new frame is still
8715 // provisional. 8716 // provisional.
8716 EXPECT_EQ(remoteFrame->frame(), owner->contentFrame()); 8717 EXPECT_EQ(remoteFrame->frame(), owner->contentFrame());
8717 8718
8718 // After detaching the provisional frame, the frame owner should still point 8719 // After detaching the provisional frame, the frame owner should still point
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
8751 targetFrame = mainFrame()->firstChild()->nextSibling(); 8752 targetFrame = mainFrame()->firstChild()->nextSibling();
8752 EXPECT_TRUE(targetFrame); 8753 EXPECT_TRUE(targetFrame);
8753 8754
8754 // Create child frames in the target frame before testing the swap. 8755 // Create child frames in the target frame before testing the swap.
8755 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; 8756 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2;
8756 WebRemoteFrame* childRemoteFrame = 8757 WebRemoteFrame* childRemoteFrame =
8757 FrameTestHelpers::createRemoteChild(remoteFrame, &remoteFrameClient2); 8758 FrameTestHelpers::createRemoteChild(remoteFrame, &remoteFrameClient2);
8758 8759
8759 FrameTestHelpers::TestWebFrameClient client; 8760 FrameTestHelpers::TestWebFrameClient client;
8760 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( 8761 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
8761 &client, remoteFrame, WebSandboxFlags::None); 8762 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
8762 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); 8763 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame);
8763 8764
8764 // FIXME: This almost certainly fires more load events on the iframe element 8765 // FIXME: This almost certainly fires more load events on the iframe element
8765 // than it should. 8766 // than it should.
8766 // Finally, make sure an embedder triggered load in the local frame swapped 8767 // Finally, make sure an embedder triggered load in the local frame swapped
8767 // back in works. 8768 // back in works.
8768 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 8769 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
8769 std::string content = 8770 std::string content =
8770 WebFrameContentDumper::dumpWebViewAsText(webView(), 1024).utf8(); 8771 WebFrameContentDumper::dumpWebViewAsText(webView(), 1024).utf8();
8771 EXPECT_EQ(" \n\na\n\nhello\n\nc", content); 8772 EXPECT_EQ(" \n\na\n\nhello\n\nc", content);
(...skipping 27 matching lines...) Expand all
8799 // Check that its view is consistent with the world. 8800 // Check that its view is consistent with the world.
8800 v8::Local<v8::Value> remoteWindowTop = 8801 v8::Local<v8::Value> remoteWindowTop =
8801 mainFrame()->executeScriptAndReturnValue(WebScriptSource( 8802 mainFrame()->executeScriptAndReturnValue(WebScriptSource(
8802 "document.querySelector('#frame2').contentWindow.top;")); 8803 "document.querySelector('#frame2').contentWindow.top;"));
8803 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); 8804 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop));
8804 8805
8805 // Now check that remote -> local works too, since it goes through a different 8806 // Now check that remote -> local works too, since it goes through a different
8806 // code path. 8807 // code path.
8807 FrameTestHelpers::TestWebFrameClient client; 8808 FrameTestHelpers::TestWebFrameClient client;
8808 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( 8809 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
8809 &client, remoteFrame, WebSandboxFlags::None); 8810 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
8810 remoteFrame->swap(localFrame); 8811 remoteFrame->swap(localFrame);
8811 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue( 8812 v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue(
8812 WebScriptSource("document.querySelector('#frame2').contentWindow;")); 8813 WebScriptSource("document.querySelector('#frame2').contentWindow;"));
8813 EXPECT_TRUE(originalWindow->StrictEquals(localWindow)); 8814 EXPECT_TRUE(originalWindow->StrictEquals(localWindow));
8814 v8::Local<v8::Value> localWindowTop = 8815 v8::Local<v8::Value> localWindowTop =
8815 mainFrame()->executeScriptAndReturnValue(WebScriptSource( 8816 mainFrame()->executeScriptAndReturnValue(WebScriptSource(
8816 "document.querySelector('#frame2').contentWindow.top;")); 8817 "document.querySelector('#frame2').contentWindow.top;"));
8817 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); 8818 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop));
8818 8819
8819 // Manually reset to break WebViewHelper's dependency on the stack allocated 8820 // Manually reset to break WebViewHelper's dependency on the stack allocated
(...skipping 16 matching lines...) Expand all
8836 WebRemoteFrame* remoteFrame = remoteClient.frame(); 8837 WebRemoteFrame* remoteFrame = remoteClient.frame();
8837 WebFrameTest::lastChild(mainFrame())->swap(remoteFrame); 8838 WebFrameTest::lastChild(mainFrame())->swap(remoteFrame);
8838 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 8839 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
8839 v8::Local<v8::Value> remoteWindowTop = 8840 v8::Local<v8::Value> remoteWindowTop =
8840 mainFrame()->executeScriptAndReturnValue(WebScriptSource("saved.top")); 8841 mainFrame()->executeScriptAndReturnValue(WebScriptSource("saved.top"));
8841 EXPECT_TRUE(remoteWindowTop->IsObject()); 8842 EXPECT_TRUE(remoteWindowTop->IsObject());
8842 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); 8843 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop));
8843 8844
8844 FrameTestHelpers::TestWebFrameClient client; 8845 FrameTestHelpers::TestWebFrameClient client;
8845 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( 8846 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
8846 &client, remoteFrame, WebSandboxFlags::None); 8847 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
8847 remoteFrame->swap(localFrame); 8848 remoteFrame->swap(localFrame);
8848 v8::Local<v8::Value> localWindowTop = 8849 v8::Local<v8::Value> localWindowTop =
8849 mainFrame()->executeScriptAndReturnValue(WebScriptSource("saved.top")); 8850 mainFrame()->executeScriptAndReturnValue(WebScriptSource("saved.top"));
8850 EXPECT_TRUE(localWindowTop->IsObject()); 8851 EXPECT_TRUE(localWindowTop->IsObject());
8851 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); 8852 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop));
8852 8853
8853 reset(); 8854 reset();
8854 } 8855 }
8855 8856
8856 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) { 8857 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
8993 WebRemoteFrame* remoteFrame = 8994 WebRemoteFrame* remoteFrame =
8994 WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient); 8995 WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient);
8995 WebFrame* targetFrame = mainFrame()->firstChild(); 8996 WebFrame* targetFrame = mainFrame()->firstChild();
8996 ASSERT_TRUE(targetFrame); 8997 ASSERT_TRUE(targetFrame);
8997 targetFrame->swap(remoteFrame); 8998 targetFrame->swap(remoteFrame);
8998 ASSERT_TRUE(mainFrame()->firstChild()); 8999 ASSERT_TRUE(mainFrame()->firstChild());
8999 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 9000 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
9000 9001
9001 RemoteToLocalSwapWebFrameClient client(remoteFrame); 9002 RemoteToLocalSwapWebFrameClient client(remoteFrame);
9002 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( 9003 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
9003 &client, remoteFrame, WebSandboxFlags::None); 9004 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
9004 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 9005 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
9005 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); 9006 EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType());
9006 9007
9007 // Manually reset to break WebViewHelper's dependency on the stack allocated 9008 // Manually reset to break WebViewHelper's dependency on the stack allocated
9008 // TestWebFrameClient. 9009 // TestWebFrameClient.
9009 reset(); 9010 reset();
9010 remoteFrame->close(); 9011 remoteFrame->close();
9011 } 9012 }
9012 9013
9013 // The commit type should be Standard if we are swapping a RemoteFrame to a 9014 // The commit type should be Standard if we are swapping a RemoteFrame to a
9014 // LocalFrame after commits have already happened in the frame. The browser 9015 // LocalFrame after commits have already happened in the frame. The browser
9015 // process will inform us via setCommittedFirstRealLoad. 9016 // process will inform us via setCommittedFirstRealLoad.
9016 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) { 9017 TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) {
9017 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 9018 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
9018 WebRemoteFrame* remoteFrame = 9019 WebRemoteFrame* remoteFrame =
9019 WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient); 9020 WebRemoteFrame::create(WebTreeScopeType::Document, &remoteFrameClient);
9020 WebFrame* targetFrame = mainFrame()->firstChild(); 9021 WebFrame* targetFrame = mainFrame()->firstChild();
9021 ASSERT_TRUE(targetFrame); 9022 ASSERT_TRUE(targetFrame);
9022 targetFrame->swap(remoteFrame); 9023 targetFrame->swap(remoteFrame);
9023 ASSERT_TRUE(mainFrame()->firstChild()); 9024 ASSERT_TRUE(mainFrame()->firstChild());
9024 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 9025 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
9025 9026
9026 RemoteToLocalSwapWebFrameClient client(remoteFrame); 9027 RemoteToLocalSwapWebFrameClient client(remoteFrame);
9027 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( 9028 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
9028 &client, remoteFrame, WebSandboxFlags::None); 9029 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
9029 localFrame->setCommittedFirstRealLoad(); 9030 localFrame->setCommittedFirstRealLoad();
9030 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 9031 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
9031 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); 9032 EXPECT_EQ(WebStandardCommit, client.historyCommitType());
9032 9033
9033 // Manually reset to break WebViewHelper's dependency on the stack allocated 9034 // Manually reset to break WebViewHelper's dependency on the stack allocated
9034 // TestWebFrameClient. 9035 // TestWebFrameClient.
9035 reset(); 9036 reset();
9036 remoteFrame->close(); 9037 remoteFrame->close();
9037 } 9038 }
9038 9039
(...skipping 12 matching lines...) Expand all
9051 WebTreeScopeType::Document, &remoteFrameClient); 9052 WebTreeScopeType::Document, &remoteFrameClient);
9052 targetFrame->swap(remoteFrame); 9053 targetFrame->swap(remoteFrame);
9053 ASSERT_TRUE(mainFrame()->firstChild()); 9054 ASSERT_TRUE(mainFrame()->firstChild());
9054 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 9055 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
9055 EXPECT_EQ(uniqueName.utf8(), 9056 EXPECT_EQ(uniqueName.utf8(),
9056 WebString(remoteFrame->frame()->tree().uniqueName()).utf8()); 9057 WebString(remoteFrame->frame()->tree().uniqueName()).utf8());
9057 9058
9058 // Swap back to a LocalFrame. 9059 // Swap back to a LocalFrame.
9059 RemoteToLocalSwapWebFrameClient client(remoteFrame); 9060 RemoteToLocalSwapWebFrameClient client(remoteFrame);
9060 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( 9061 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
9061 &client, remoteFrame, WebSandboxFlags::None); 9062 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
9062 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 9063 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
9063 EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8()); 9064 EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8());
9064 EXPECT_EQ(uniqueName.utf8(), WebString(toWebLocalFrameImpl(localFrame) 9065 EXPECT_EQ(uniqueName.utf8(), WebString(toWebLocalFrameImpl(localFrame)
9065 ->frame() 9066 ->frame()
9066 ->loader() 9067 ->loader()
9067 .currentItem() 9068 .currentItem()
9068 ->target()) 9069 ->target())
9069 .utf8()); 9070 .utf8());
9070 9071
9071 // Repeat with no name on the frame. 9072 // Repeat with no name on the frame.
9072 // (note that uniqueName is immutable after first real commit). 9073 // (note that uniqueName is immutable after first real commit).
9073 localFrame->setName(""); 9074 localFrame->setName("");
9074 WebString uniqueName2 = localFrame->uniqueName(); 9075 WebString uniqueName2 = localFrame->uniqueName();
9075 EXPECT_EQ("frame1", uniqueName2.utf8()); 9076 EXPECT_EQ("frame1", uniqueName2.utf8());
9076 9077
9077 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; 9078 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2;
9078 WebRemoteFrameImpl* remoteFrame2 = WebRemoteFrameImpl::create( 9079 WebRemoteFrameImpl* remoteFrame2 = WebRemoteFrameImpl::create(
9079 WebTreeScopeType::Document, &remoteFrameClient2); 9080 WebTreeScopeType::Document, &remoteFrameClient2);
9080 localFrame->swap(remoteFrame2); 9081 localFrame->swap(remoteFrame2);
9081 ASSERT_TRUE(mainFrame()->firstChild()); 9082 ASSERT_TRUE(mainFrame()->firstChild());
9082 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame2); 9083 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame2);
9083 EXPECT_EQ(uniqueName2.utf8(), 9084 EXPECT_EQ(uniqueName2.utf8(),
9084 WebString(remoteFrame2->frame()->tree().uniqueName()).utf8()); 9085 WebString(remoteFrame2->frame()->tree().uniqueName()).utf8());
9085 9086
9086 RemoteToLocalSwapWebFrameClient client2(remoteFrame2); 9087 RemoteToLocalSwapWebFrameClient client2(remoteFrame2);
9087 WebLocalFrame* localFrame2 = WebLocalFrame::createProvisional( 9088 WebLocalFrame* localFrame2 = WebLocalFrame::createProvisional(
9088 &client2, remoteFrame2, WebSandboxFlags::None); 9089 &client2, nullptr, nullptr, remoteFrame2, WebSandboxFlags::None);
9089 FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html"); 9090 FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html");
9090 EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8()); 9091 EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8());
9091 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebLocalFrameImpl(localFrame2) 9092 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebLocalFrameImpl(localFrame2)
9092 ->frame() 9093 ->frame()
9093 ->loader() 9094 ->loader()
9094 .currentItem() 9095 .currentItem()
9095 ->target()) 9096 ->target())
9096 .utf8()); 9097 .utf8());
9097 9098
9098 // Manually reset to break WebViewHelper's dependency on the stack allocated 9099 // Manually reset to break WebViewHelper's dependency on the stack allocated
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
9223 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame(); 9224 WebRemoteFrame* popupRemoteFrame = popupRemoteClient.frame();
9224 popupView->setMainFrame(popupRemoteFrame); 9225 popupView->setMainFrame(popupRemoteFrame);
9225 popupRemoteFrame->setOpener(mainFrame); 9226 popupRemoteFrame->setOpener(mainFrame);
9226 popupRemoteFrame->setReplicatedOrigin( 9227 popupRemoteFrame->setReplicatedOrigin(
9227 WebSecurityOrigin::createFromString("http://foo.com")); 9228 WebSecurityOrigin::createFromString("http://foo.com"));
9228 EXPECT_FALSE(mainFrame->getSecurityOrigin().canAccess( 9229 EXPECT_FALSE(mainFrame->getSecurityOrigin().canAccess(
9229 popupView->mainFrame()->getSecurityOrigin())); 9230 popupView->mainFrame()->getSecurityOrigin()));
9230 9231
9231 // Do a remote-to-local swap in the popup. 9232 // Do a remote-to-local swap in the popup.
9232 FrameTestHelpers::TestWebFrameClient popupLocalClient; 9233 FrameTestHelpers::TestWebFrameClient popupLocalClient;
9233 WebLocalFrame* popupLocalFrame = WebLocalFrame::createProvisional( 9234 WebLocalFrame* popupLocalFrame =
9234 &popupLocalClient, popupRemoteFrame, WebSandboxFlags::None); 9235 WebLocalFrame::createProvisional(&popupLocalClient, nullptr, nullptr,
9236 popupRemoteFrame, WebSandboxFlags::None);
9235 popupRemoteFrame->swap(popupLocalFrame); 9237 popupRemoteFrame->swap(popupLocalFrame);
9236 9238
9237 // The initial document created during the remote-to-local swap should have 9239 // The initial document created during the remote-to-local swap should have
9238 // inherited its opener's SecurityOrigin. 9240 // inherited its opener's SecurityOrigin.
9239 EXPECT_TRUE(mainFrame->getSecurityOrigin().canAccess( 9241 EXPECT_TRUE(mainFrame->getSecurityOrigin().canAccess(
9240 popupView->mainFrame()->getSecurityOrigin())); 9242 popupView->mainFrame()->getSecurityOrigin()));
9241 9243
9242 popupView->close(); 9244 popupView->close();
9243 } 9245 }
9244 9246
9245 TEST_F(WebFrameTest, SwapWithOpenerCycle) { 9247 TEST_F(WebFrameTest, SwapWithOpenerCycle) {
9246 // First, create a remote main frame with itself as the opener. 9248 // First, create a remote main frame with itself as the opener.
9247 FrameTestHelpers::TestWebViewClient viewClient; 9249 FrameTestHelpers::TestWebViewClient viewClient;
9248 WebView* view = WebView::create(&viewClient, WebPageVisibilityStateVisible); 9250 WebView* view = WebView::create(&viewClient, WebPageVisibilityStateVisible);
9249 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 9251 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
9250 WebRemoteFrame* remoteFrame = remoteClient.frame(); 9252 WebRemoteFrame* remoteFrame = remoteClient.frame();
9251 view->setMainFrame(remoteFrame); 9253 view->setMainFrame(remoteFrame);
9252 remoteFrame->setOpener(remoteFrame); 9254 remoteFrame->setOpener(remoteFrame);
9253 9255
9254 // Now swap in a local frame. It shouldn't crash. 9256 // Now swap in a local frame. It shouldn't crash.
9255 FrameTestHelpers::TestWebFrameClient localClient; 9257 FrameTestHelpers::TestWebFrameClient localClient;
9256 WebLocalFrame* localFrame = WebLocalFrame::createProvisional( 9258 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
9257 &localClient, remoteFrame, WebSandboxFlags::None); 9259 &localClient, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
9258 remoteFrame->swap(localFrame); 9260 remoteFrame->swap(localFrame);
9259 9261
9260 // And the opener cycle should still be preserved. 9262 // And the opener cycle should still be preserved.
9261 EXPECT_EQ(localFrame, localFrame->opener()); 9263 EXPECT_EQ(localFrame, localFrame->opener());
9262 9264
9263 view->close(); 9265 view->close();
9264 } 9266 }
9265 9267
9266 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 9268 class CommitTypeWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
9267 public: 9269 public:
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
9653 WebView* view = WebView::create(&viewClient, WebPageVisibilityStateVisible); 9655 WebView* view = WebView::create(&viewClient, WebPageVisibilityStateVisible);
9654 view->setMainFrame(remoteClient.frame()); 9656 view->setMainFrame(remoteClient.frame());
9655 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); 9657 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame();
9656 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); 9658 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique());
9657 9659
9658 FrameTestHelpers::createLocalChild(remoteRoot); 9660 FrameTestHelpers::createLocalChild(remoteRoot);
9659 9661
9660 // Do a remote-to-local swap of the top frame. 9662 // Do a remote-to-local swap of the top frame.
9661 FrameTestHelpers::TestWebFrameClient localClient; 9663 FrameTestHelpers::TestWebFrameClient localClient;
9662 WebLocalFrame* localRoot = WebLocalFrame::createProvisional( 9664 WebLocalFrame* localRoot = WebLocalFrame::createProvisional(
9663 &localClient, remoteRoot, WebSandboxFlags::None); 9665 &localClient, nullptr, nullptr, remoteRoot, WebSandboxFlags::None);
9664 FrameTestHelpers::TestWebWidgetClient webWidgetClient; 9666 FrameTestHelpers::TestWebWidgetClient webWidgetClient;
9665 WebFrameWidget::create(&webWidgetClient, localRoot); 9667 WebFrameWidget::create(&webWidgetClient, localRoot);
9666 remoteRoot->swap(localRoot); 9668 remoteRoot->swap(localRoot);
9667 9669
9668 // Load a page with a child frame in the new root to make sure this doesn't 9670 // Load a page with a child frame in the new root to make sure this doesn't
9669 // crash when the child frame invokes setCoreFrame. 9671 // crash when the child frame invokes setCoreFrame.
9670 registerMockedHttpURLLoad("single_iframe.html"); 9672 registerMockedHttpURLLoad("single_iframe.html");
9671 registerMockedHttpURLLoad("visible_iframe.html"); 9673 registerMockedHttpURLLoad("visible_iframe.html");
9672 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); 9674 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html");
9673 9675
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
11203 }; 11205 };
11204 11206
11205 class MainFrameClient : public FrameTestHelpers::TestWebFrameClient { 11207 class MainFrameClient : public FrameTestHelpers::TestWebFrameClient {
11206 public: 11208 public:
11207 WebLocalFrame* createChildFrame(WebLocalFrame* parent, 11209 WebLocalFrame* createChildFrame(WebLocalFrame* parent,
11208 WebTreeScopeType scope, 11210 WebTreeScopeType scope,
11209 const WebString& name, 11211 const WebString& name,
11210 const WebString& uniqueName, 11212 const WebString& uniqueName,
11211 WebSandboxFlags sandboxFlags, 11213 WebSandboxFlags sandboxFlags,
11212 const WebFrameOwnerProperties&) override { 11214 const WebFrameOwnerProperties&) override {
11213 WebLocalFrame* frame = WebLocalFrame::create(scope, &m_childClient); 11215 WebLocalFrame* frame =
11216 WebLocalFrame::create(scope, &m_childClient, nullptr, nullptr);
11214 parent->appendChild(frame); 11217 parent->appendChild(frame);
11215 return frame; 11218 return frame;
11216 } 11219 }
11217 11220
11218 LoadingObserverFrameClient& childClient() { return m_childClient; } 11221 LoadingObserverFrameClient& childClient() { return m_childClient; }
11219 11222
11220 private: 11223 private:
11221 LoadingObserverFrameClient m_childClient; 11224 LoadingObserverFrameClient m_childClient;
11222 }; 11225 };
11223 11226
(...skipping 10 matching lines...) Expand all
11234 11237
11235 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); 11238 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached());
11236 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); 11239 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading());
11237 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); 11240 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad());
11238 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); 11241 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents());
11239 11242
11240 webViewHelper.reset(); 11243 webViewHelper.reset();
11241 } 11244 }
11242 11245
11243 } // namespace blink 11246 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/FrameTestHelpers.cpp ('k') | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698