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

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

Issue 2036403002: Always use the WebFrameWidget when attaching the root graphics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adding comments Created 4 years, 5 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 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 1601 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1602 WebView* view = WebView::create(&viewClient); 1602 WebView* view = WebView::create(&viewClient);
1603 view->settings()->setJavaScriptEnabled(true); 1603 view->settings()->setJavaScriptEnabled(true);
1604 view->setMainFrame(remoteClient.frame()); 1604 view->setMainFrame(remoteClient.frame());
1605 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); 1605 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1606 root->setReplicatedOrigin(SecurityOrigin::createUnique()); 1606 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1607 1607
1608 WebFrameOwnerProperties properties; 1608 WebFrameOwnerProperties properties;
1609 properties.marginWidth = 11; 1609 properties.marginWidth = 11;
1610 properties.marginHeight = 22; 1610 properties.marginHeight = 22;
1611 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root, "frameN ame", nullptr, nullptr, properties); 1611 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root, "frameN ame", nullptr, nullptr, nullptr, properties);
1612 1612
1613 registerMockedHttpURLLoad("frame_owner_properties.html"); 1613 registerMockedHttpURLLoad("frame_owner_properties.html");
1614 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html"); 1614 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1615 1615
1616 // Check if the LocalFrame has seen the marginwidth and marginheight 1616 // Check if the LocalFrame has seen the marginwidth and marginheight
1617 // properties. 1617 // properties.
1618 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document (); 1618 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document ();
1619 EXPECT_EQ(11, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginwidthAttr)); 1619 EXPECT_EQ(11, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginwidthAttr));
1620 EXPECT_EQ(22, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginheightAttr)); 1620 EXPECT_EQ(22, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginheightAttr));
1621 1621
(...skipping 11 matching lines...) Expand all
1633 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 1633 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1634 WebView* view = WebView::create(&viewClient); 1634 WebView* view = WebView::create(&viewClient);
1635 view->settings()->setJavaScriptEnabled(true); 1635 view->settings()->setJavaScriptEnabled(true);
1636 view->setMainFrame(remoteClient.frame()); 1636 view->setMainFrame(remoteClient.frame());
1637 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); 1637 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1638 root->setReplicatedOrigin(SecurityOrigin::createUnique()); 1638 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1639 1639
1640 WebFrameOwnerProperties properties; 1640 WebFrameOwnerProperties properties;
1641 // Turn off scrolling in the subframe. 1641 // Turn off scrolling in the subframe.
1642 properties.scrollingMode = WebFrameOwnerProperties::ScrollingMode::AlwaysOff ; 1642 properties.scrollingMode = WebFrameOwnerProperties::ScrollingMode::AlwaysOff ;
1643 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root, "frameN ame", nullptr, nullptr, properties); 1643 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root, "frameN ame", nullptr, nullptr, nullptr, properties);
1644 1644
1645 registerMockedHttpURLLoad("frame_owner_properties.html"); 1645 registerMockedHttpURLLoad("frame_owner_properties.html");
1646 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html"); 1646 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1647 1647
1648 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document (); 1648 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document ();
1649 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginwidthAttr)); 1649 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginwidthAttr));
1650 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginheightAttr)); 1650 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginheightAttr));
1651 1651
1652 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w(); 1652 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w();
1653 EXPECT_EQ(nullptr, frameView->horizontalScrollbar()); 1653 EXPECT_EQ(nullptr, frameView->horizontalScrollbar());
(...skipping 5473 matching lines...) Expand 10 before | Expand all | Expand 10 after
7127 FrameTestHelpers::WebViewHelper m_webViewHelper; 7127 FrameTestHelpers::WebViewHelper m_webViewHelper;
7128 }; 7128 };
7129 7129
7130 TEST_F(WebFrameSwapTest, SwapMainFrame) 7130 TEST_F(WebFrameSwapTest, SwapMainFrame)
7131 { 7131 {
7132 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr); 7132 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr);
7133 mainFrame()->swap(remoteFrame); 7133 mainFrame()->swap(remoteFrame);
7134 7134
7135 FrameTestHelpers::TestWebFrameClient client; 7135 FrameTestHelpers::TestWebFrameClient client;
7136 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None); 7136 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None);
7137 FrameTestHelpers::TestWebWidgetClient webWidgetClient;
7138 WebFrameWidget::create(&webWidgetClient, localFrame);
7137 remoteFrame->swap(localFrame); 7139 remoteFrame->swap(localFrame);
7138 7140
7139 // Finally, make sure an embedder triggered load in the local frame swapped 7141 // Finally, make sure an embedder triggered load in the local frame swapped
7140 // back in works. 7142 // back in works.
7141 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7143 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7142 7144
7143 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10 24).utf8(); 7145 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10 24).utf8();
7144 EXPECT_EQ("hello", content); 7146 EXPECT_EQ("hello", content);
7145 7147
7146 // Manually reset to break WebViewHelper's dependency on the stack allocated 7148 // Manually reset to break WebViewHelper's dependency on the stack allocated
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
7840 7842
7841 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame. 7843 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame.
7842 CommitTypeWebFrameClient childFrameClient; 7844 CommitTypeWebFrameClient childFrameClient;
7843 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(view->mainFra me()->toWebRemoteFrame(), "frameName", &childFrameClient); 7845 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(view->mainFra me()->toWebRemoteFrame(), "frameName", &childFrameClient);
7844 registerMockedHttpURLLoad("foo.html"); 7846 registerMockedHttpURLLoad("foo.html");
7845 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); 7847 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html");
7846 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() ); 7848 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() );
7847 view->close(); 7849 view->close();
7848 } 7850 }
7849 7851
7850 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient { 7852 class GestureEventTestWebWidgetClient : public FrameTestHelpers::TestWebWidgetCl ient {
7851 public: 7853 public:
7852 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { } 7854 GestureEventTestWebWidgetClient()
7855 : m_didHandleGestureEvent(false)
7856 {
7857 }
7853 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; } 7858 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; }
7854 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; } 7859 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; }
7855 7860
7856 private: 7861 private:
7857 bool m_didHandleGestureEvent; 7862 bool m_didHandleGestureEvent;
7858 }; 7863 };
7859 7864
7860 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) 7865 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest)
7861 { 7866 {
7862 FrameTestHelpers::TestWebViewClient viewClient; 7867 FrameTestHelpers::TestWebViewClient viewClient;
7863 WebView* view = WebView::create(&viewClient); 7868 WebView* view = WebView::create(&viewClient);
7864 7869
7865 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7870 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7866 view->setMainFrame(remoteClient.frame()); 7871 view->setMainFrame(remoteClient.frame());
7867 7872
7868 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(view->mainFra me()->toWebRemoteFrame()); 7873 GestureEventTestWebWidgetClient childWidgetClient;
7869 7874 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(view->mainFra me()->toWebRemoteFrame(), WebString(), nullptr, &childWidgetClient);
7870 GestureEventTestWebViewClient childViewClient;
7871 WebFrameWidget* widget = WebFrameWidget::create(childViewClient.widgetClient (), childFrame);
7872 7875
7873 view->resize(WebSize(1000, 1000)); 7876 view->resize(WebSize(1000, 1000));
7874 7877
7875 widget->handleInputEvent(fatTap(20, 20)); 7878 childFrame->frameWidget()->handleInputEvent(fatTap(20, 20));
7876 EXPECT_TRUE(childViewClient.didHandleGestureEvent()); 7879 EXPECT_TRUE(childWidgetClient.didHandleGestureEvent());
7877 7880
7878 widget->close();
7879 view->close(); 7881 view->close();
7880 } 7882 }
7881 7883
7882 class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient { 7884 class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient {
7883 public: 7885 public:
7884 MockDocumentThreadableLoaderClient() : m_failed(false) { } 7886 MockDocumentThreadableLoaderClient() : m_failed(false) { }
7885 void didFail(const ResourceError&) override { m_failed = true;} 7887 void didFail(const ResourceError&) override { m_failed = true;}
7886 7888
7887 void reset() { m_failed = false; } 7889 void reset() { m_failed = false; }
7888 bool failed() { return m_failed; } 7890 bool failed() { return m_failed; }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
8053 8055
8054 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling) 8056 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling)
8055 { 8057 {
8056 FrameTestHelpers::TestWebViewClient viewClient; 8058 FrameTestHelpers::TestWebViewClient viewClient;
8057 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 8059 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
8058 WebView* view = WebView::create(&viewClient); 8060 WebView* view = WebView::create(&viewClient);
8059 view->setMainFrame(remoteClient.frame()); 8061 view->setMainFrame(remoteClient.frame());
8060 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame(); 8062 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame();
8061 8063
8062 WebLocalFrame* secondFrame(FrameTestHelpers::createLocalChild(parent, "name2 ")); 8064 WebLocalFrame* secondFrame(FrameTestHelpers::createLocalChild(parent, "name2 "));
8063 WebLocalFrame* fourthFrame(FrameTestHelpers::createLocalChild(parent, "name4 ", nullptr, secondFrame)); 8065 WebLocalFrame* fourthFrame(FrameTestHelpers::createLocalChild(parent, "name4 ", nullptr, nullptr, secondFrame));
8064 WebLocalFrame* thirdFrame(FrameTestHelpers::createLocalChild(parent, "name3" , nullptr, secondFrame)); 8066 WebLocalFrame* thirdFrame(FrameTestHelpers::createLocalChild(parent, "name3" , nullptr, nullptr, secondFrame));
8065 WebLocalFrame* firstFrame(FrameTestHelpers::createLocalChild(parent, "name1" )); 8067 WebLocalFrame* firstFrame(FrameTestHelpers::createLocalChild(parent, "name1" ));
8066 8068
8067 EXPECT_EQ(firstFrame, parent->firstChild()); 8069 EXPECT_EQ(firstFrame, parent->firstChild());
8068 EXPECT_EQ(nullptr, firstFrame->previousSibling()); 8070 EXPECT_EQ(nullptr, firstFrame->previousSibling());
8069 EXPECT_EQ(secondFrame, firstFrame->nextSibling()); 8071 EXPECT_EQ(secondFrame, firstFrame->nextSibling());
8070 8072
8071 EXPECT_EQ(firstFrame, secondFrame->previousSibling()); 8073 EXPECT_EQ(firstFrame, secondFrame->previousSibling());
8072 EXPECT_EQ(thirdFrame, secondFrame->nextSibling()); 8074 EXPECT_EQ(thirdFrame, secondFrame->nextSibling());
8073 8075
8074 EXPECT_EQ(secondFrame, thirdFrame->previousSibling()); 8076 EXPECT_EQ(secondFrame, thirdFrame->previousSibling());
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
8812 request.setURL(toKURL("javascript:location='" + redirectURL + "'")); 8814 request.setURL(toKURL("javascript:location='" + redirectURL + "'"));
8813 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request); 8815 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request);
8814 8816
8815 // Normally, the result of the JS url replaces the existing contents on the 8817 // Normally, the result of the JS url replaces the existing contents on the
8816 // Document. However, if the JS triggers a navigation, the contents should 8818 // Document. However, if the JS triggers a navigation, the contents should
8817 // not be replaced. 8819 // not be replaced.
8818 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum ent()->documentElement()->innerText()); 8820 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum ent()->documentElement()->innerText());
8819 } 8821 }
8820 8822
8821 } // namespace blink 8823 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698