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 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1598 WebView* view = WebView::create(&viewClient); | 1598 WebView* view = WebView::create(&viewClient); |
1599 view->settings()->setJavaScriptEnabled(true); | 1599 view->settings()->setJavaScriptEnabled(true); |
1600 view->setMainFrame(remoteClient.frame()); | 1600 view->setMainFrame(remoteClient.frame()); |
1601 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); | 1601 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); |
1602 root->setReplicatedOrigin(SecurityOrigin::createUnique()); | 1602 root->setReplicatedOrigin(SecurityOrigin::createUnique()); |
1603 | 1603 |
1604 WebFrameOwnerProperties properties; | 1604 WebFrameOwnerProperties properties; |
1605 properties.marginWidth = 11; | 1605 properties.marginWidth = 11; |
1606 properties.marginHeight = 22; | 1606 properties.marginHeight = 22; |
1607 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root, "frameN ame", nullptr, nullptr, properties); | 1607 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root, "frameN ame", nullptr, nullptr, properties); |
1608 FrameTestHelpers::TestWebWidgetClient widgetClient; | |
1609 WebWidget* widget = WebFrameWidget::create(&widgetClient, localFrame); | |
dcheng
2016/06/08 00:10:17
I wonder if we can make this simpler for test code
lfg
2016/06/08 21:09:47
I think that's doable, but there's one test that n
dcheng
2016/06/09 04:43:51
That seems reasonable to me.
| |
1608 | 1610 |
1609 registerMockedHttpURLLoad("frame_owner_properties.html"); | 1611 registerMockedHttpURLLoad("frame_owner_properties.html"); |
1610 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html"); | 1612 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html"); |
1611 | 1613 |
1612 // Check if the LocalFrame has seen the marginwidth and marginheight | 1614 // Check if the LocalFrame has seen the marginwidth and marginheight |
1613 // properties. | 1615 // properties. |
1614 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document (); | 1616 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document (); |
1615 EXPECT_EQ(11, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginwidthAttr)); | 1617 EXPECT_EQ(11, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginwidthAttr)); |
1616 EXPECT_EQ(22, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginheightAttr)); | 1618 EXPECT_EQ(22, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginheightAttr)); |
1617 | 1619 |
1618 FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView(); | 1620 FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView(); |
1619 // Expect scrollbars to be enabled by default. | 1621 // Expect scrollbars to be enabled by default. |
1620 EXPECT_NE(nullptr, frameView->horizontalScrollbar()); | 1622 EXPECT_NE(nullptr, frameView->horizontalScrollbar()); |
1621 EXPECT_NE(nullptr, frameView->verticalScrollbar()); | 1623 EXPECT_NE(nullptr, frameView->verticalScrollbar()); |
1622 | 1624 |
1625 widget->close(); | |
1623 view->close(); | 1626 view->close(); |
1624 } | 1627 } |
1625 | 1628 |
1626 TEST_F(WebFrameTest, FrameOwnerPropertiesScrolling) | 1629 TEST_F(WebFrameTest, FrameOwnerPropertiesScrolling) |
1627 { | 1630 { |
1628 FrameTestHelpers::TestWebViewClient viewClient; | 1631 FrameTestHelpers::TestWebViewClient viewClient; |
1629 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 1632 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
1630 WebView* view = WebView::create(&viewClient); | 1633 WebView* view = WebView::create(&viewClient); |
1631 view->settings()->setJavaScriptEnabled(true); | 1634 view->settings()->setJavaScriptEnabled(true); |
1632 view->setMainFrame(remoteClient.frame()); | 1635 view->setMainFrame(remoteClient.frame()); |
1633 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); | 1636 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); |
1634 root->setReplicatedOrigin(SecurityOrigin::createUnique()); | 1637 root->setReplicatedOrigin(SecurityOrigin::createUnique()); |
1635 | 1638 |
1636 WebFrameOwnerProperties properties; | 1639 WebFrameOwnerProperties properties; |
1637 // Turn off scrolling in the subframe. | 1640 // Turn off scrolling in the subframe. |
1638 properties.scrollingMode = WebFrameOwnerProperties::ScrollingMode::AlwaysOff ; | 1641 properties.scrollingMode = WebFrameOwnerProperties::ScrollingMode::AlwaysOff ; |
1639 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root, "frameN ame", nullptr, nullptr, properties); | 1642 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root, "frameN ame", nullptr, nullptr, properties); |
1643 FrameTestHelpers::TestWebWidgetClient widgetClient; | |
1644 WebWidget* widget = WebFrameWidget::create(&widgetClient, localFrame); | |
1640 | 1645 |
1641 registerMockedHttpURLLoad("frame_owner_properties.html"); | 1646 registerMockedHttpURLLoad("frame_owner_properties.html"); |
1642 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html"); | 1647 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html"); |
1643 | 1648 |
1644 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document (); | 1649 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document (); |
1645 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginwidthAttr)); | 1650 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginwidthAttr)); |
1646 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginheightAttr)); | 1651 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginheightAttr)); |
1647 | 1652 |
1648 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w(); | 1653 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w(); |
1649 EXPECT_EQ(nullptr, frameView->horizontalScrollbar()); | 1654 EXPECT_EQ(nullptr, frameView->horizontalScrollbar()); |
1650 EXPECT_EQ(nullptr, frameView->verticalScrollbar()); | 1655 EXPECT_EQ(nullptr, frameView->verticalScrollbar()); |
1651 | 1656 |
1657 widget->close(); | |
1652 view->close(); | 1658 view->close(); |
1653 } | 1659 } |
1654 | 1660 |
1655 | 1661 |
1656 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations ) | 1662 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations ) |
1657 { | 1663 { |
1658 registerMockedHttpURLLoad("200-by-300.html"); | 1664 registerMockedHttpURLLoad("200-by-300.html"); |
1659 registerMockedHttpURLLoad("large-div.html"); | 1665 registerMockedHttpURLLoad("large-div.html"); |
1660 | 1666 |
1661 FixedLayoutTestWebViewClient client; | 1667 FixedLayoutTestWebViewClient client; |
(...skipping 5466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7128 FrameTestHelpers::WebViewHelper m_webViewHelper; | 7134 FrameTestHelpers::WebViewHelper m_webViewHelper; |
7129 }; | 7135 }; |
7130 | 7136 |
7131 TEST_F(WebFrameSwapTest, SwapMainFrame) | 7137 TEST_F(WebFrameSwapTest, SwapMainFrame) |
7132 { | 7138 { |
7133 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr); | 7139 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, nullptr); |
7134 mainFrame()->swap(remoteFrame); | 7140 mainFrame()->swap(remoteFrame); |
7135 | 7141 |
7136 FrameTestHelpers::TestWebFrameClient client; | 7142 FrameTestHelpers::TestWebFrameClient client; |
7137 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None); | 7143 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None); |
7144 FrameTestHelpers::TestWebWidgetClient widgetClient; | |
7145 WebWidget* widget = WebFrameWidget::create(&widgetClient, localFrame); | |
7138 remoteFrame->swap(localFrame); | 7146 remoteFrame->swap(localFrame); |
7139 | 7147 |
7140 // Finally, make sure an embedder triggered load in the local frame swapped | 7148 // Finally, make sure an embedder triggered load in the local frame swapped |
7141 // back in works. | 7149 // back in works. |
7142 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7150 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7143 | 7151 |
7144 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10 24).utf8(); | 7152 std::string content = WebFrameContentDumper::dumpWebViewAsText(webView(), 10 24).utf8(); |
7145 EXPECT_EQ("hello", content); | 7153 EXPECT_EQ("hello", content); |
7146 | 7154 |
7155 widget->close(); | |
7156 | |
7147 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7157 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7148 // TestWebFrameClient. | 7158 // TestWebFrameClient. |
7149 reset(); | 7159 reset(); |
7150 remoteFrame->close(); | 7160 remoteFrame->close(); |
7151 } | 7161 } |
7152 | 7162 |
7153 TEST_F(WebFrameSwapTest, ValidateSizeOnRemoteToLocalMainFrameSwap) | 7163 TEST_F(WebFrameSwapTest, ValidateSizeOnRemoteToLocalMainFrameSwap) |
7154 { | 7164 { |
7155 WebSize size(111, 222); | 7165 WebSize size(111, 222); |
7156 | 7166 |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7492 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable) | 7502 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable) |
7493 { | 7503 { |
7494 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 7504 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
7495 | 7505 |
7496 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7506 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7497 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); | 7507 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); |
7498 mainFrame()->swap(remoteParentFrame); | 7508 mainFrame()->swap(remoteParentFrame); |
7499 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); | 7509 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
7500 | 7510 |
7501 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(remoteParentF rame); | 7511 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(remoteParentF rame); |
7512 FrameTestHelpers::TestWebWidgetClient widgetClient; | |
7513 WebWidget* widget = WebFrameWidget::create(&widgetClient, childFrame); | |
7502 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); | 7514 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); |
7503 | 7515 |
7504 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window")); | 7516 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window")); |
7505 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]")); | 7517 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]")); |
7506 EXPECT_TRUE(childOfRemoteParent->IsObject()); | 7518 EXPECT_TRUE(childOfRemoteParent->IsObject()); |
7507 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); | 7519 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); |
7508 | 7520 |
7509 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length")); | 7521 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length")); |
7510 ASSERT_TRUE(windowLength->IsInt32()); | 7522 ASSERT_TRUE(windowLength->IsInt32()); |
7511 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); | 7523 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); |
7512 | 7524 |
7525 widget->close(); | |
7526 | |
7513 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. | 7527 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. |
7514 reset(); | 7528 reset(); |
7515 } | 7529 } |
7516 | 7530 |
7517 // Check that frames with a remote parent don't crash while accessing window.fra meElement. | 7531 // Check that frames with a remote parent don't crash while accessing window.fra meElement. |
7518 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) | 7532 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) |
7519 { | 7533 { |
7520 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 7534 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
7521 | 7535 |
7522 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7536 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7523 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); | 7537 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); |
7524 mainFrame()->swap(remoteParentFrame); | 7538 mainFrame()->swap(remoteParentFrame); |
7525 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); | 7539 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
7526 | 7540 |
7527 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(remoteParentF rame); | 7541 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(remoteParentF rame); |
7542 FrameTestHelpers::TestWebWidgetClient widgetClient; | |
7543 WebWidget* widget = WebFrameWidget::create(&widgetClient, childFrame); | |
7528 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); | 7544 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); |
7529 | 7545 |
7530 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement")); | 7546 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement")); |
7531 // frameElement should be null if cross-origin. | 7547 // frameElement should be null if cross-origin. |
7532 ASSERT_FALSE(frameElement.IsEmpty()); | 7548 ASSERT_FALSE(frameElement.IsEmpty()); |
7533 EXPECT_TRUE(frameElement->IsNull()); | 7549 EXPECT_TRUE(frameElement->IsNull()); |
7534 | 7550 |
7551 widget->close(); | |
7552 | |
7535 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. | 7553 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. |
7536 reset(); | 7554 reset(); |
7537 } | 7555 } |
7538 | 7556 |
7539 class RemoteToLocalSwapWebFrameClient : public FrameTestHelpers::TestWebFrameCli ent { | 7557 class RemoteToLocalSwapWebFrameClient : public FrameTestHelpers::TestWebFrameCli ent { |
7540 public: | 7558 public: |
7541 explicit RemoteToLocalSwapWebFrameClient(WebRemoteFrame* remoteFrame) | 7559 explicit RemoteToLocalSwapWebFrameClient(WebRemoteFrame* remoteFrame) |
7542 : m_historyCommitType(WebHistoryInertCommit) | 7560 : m_historyCommitType(WebHistoryInertCommit) |
7543 , m_remoteFrame(remoteFrame) | 7561 , m_remoteFrame(remoteFrame) |
7544 { | 7562 { |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7835 { | 7853 { |
7836 FrameTestHelpers::TestWebViewClient viewClient; | 7854 FrameTestHelpers::TestWebViewClient viewClient; |
7837 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7855 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7838 WebView* view = WebView::create(&viewClient); | 7856 WebView* view = WebView::create(&viewClient); |
7839 view->setMainFrame(remoteClient.frame()); | 7857 view->setMainFrame(remoteClient.frame()); |
7840 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createFromStrin g(WebString::fromUTF8(m_baseURL))); | 7858 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createFromStrin g(WebString::fromUTF8(m_baseURL))); |
7841 | 7859 |
7842 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame. | 7860 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame. |
7843 CommitTypeWebFrameClient childFrameClient; | 7861 CommitTypeWebFrameClient childFrameClient; |
7844 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(view->mainFra me()->toWebRemoteFrame(), "frameName", &childFrameClient); | 7862 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(view->mainFra me()->toWebRemoteFrame(), "frameName", &childFrameClient); |
7863 FrameTestHelpers::TestWebWidgetClient widgetClient; | |
7864 WebWidget* widget = WebFrameWidget::create(&widgetClient, childFrame); | |
7845 registerMockedHttpURLLoad("foo.html"); | 7865 registerMockedHttpURLLoad("foo.html"); |
7846 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); | 7866 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); |
7847 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() ); | 7867 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() ); |
7868 widget->close(); | |
7848 view->close(); | 7869 view->close(); |
7849 } | 7870 } |
7850 | 7871 |
7851 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient { | 7872 class GestureEventTestWebWidgetClient : public FrameTestHelpers::TestWebWidgetCl ient { |
7852 public: | 7873 public: |
7853 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { } | 7874 GestureEventTestWebWidgetClient() : m_didHandleGestureEvent(false) { } |
7854 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; } | 7875 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; } |
7855 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; } | 7876 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; } |
7856 | 7877 |
7857 private: | 7878 private: |
7858 bool m_didHandleGestureEvent; | 7879 bool m_didHandleGestureEvent; |
7859 }; | 7880 }; |
7860 | 7881 |
7861 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) | 7882 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) |
7862 { | 7883 { |
7863 FrameTestHelpers::TestWebViewClient viewClient; | 7884 FrameTestHelpers::TestWebViewClient viewClient; |
7864 WebView* view = WebView::create(&viewClient); | 7885 WebView* view = WebView::create(&viewClient); |
7865 | 7886 |
7866 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7887 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7867 view->setMainFrame(remoteClient.frame()); | 7888 view->setMainFrame(remoteClient.frame()); |
7868 | 7889 |
7869 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(view->mainFra me()->toWebRemoteFrame()); | 7890 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(view->mainFra me()->toWebRemoteFrame()); |
7870 | 7891 |
7871 GestureEventTestWebViewClient childViewClient; | 7892 GestureEventTestWebWidgetClient childWidgetClient; |
7872 WebFrameWidget* widget = WebFrameWidget::create(childViewClient.widgetClient (), childFrame); | 7893 WebFrameWidget* widget = WebFrameWidget::create(&childWidgetClient, childFra me); |
7873 | 7894 |
7874 view->resize(WebSize(1000, 1000)); | 7895 view->resize(WebSize(1000, 1000)); |
7875 | 7896 |
7876 widget->handleInputEvent(fatTap(20, 20)); | 7897 widget->handleInputEvent(fatTap(20, 20)); |
7877 EXPECT_TRUE(childViewClient.didHandleGestureEvent()); | 7898 EXPECT_TRUE(childWidgetClient.didHandleGestureEvent()); |
7878 | 7899 |
7879 widget->close(); | 7900 widget->close(); |
7880 view->close(); | 7901 view->close(); |
7881 } | 7902 } |
7882 | 7903 |
7883 class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient { | 7904 class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient { |
7884 public: | 7905 public: |
7885 MockDocumentThreadableLoaderClient() : m_failed(false) { } | 7906 MockDocumentThreadableLoaderClient() : m_failed(false) { } |
7886 void didFail(const ResourceError&) override { m_failed = true;} | 7907 void didFail(const ResourceError&) override { m_failed = true;} |
7887 | 7908 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8091 { | 8112 { |
8092 FrameTestHelpers::TestWebViewClient viewClient; | 8113 FrameTestHelpers::TestWebViewClient viewClient; |
8093 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 8114 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
8094 WebView* view = WebView::create(&viewClient); | 8115 WebView* view = WebView::create(&viewClient); |
8095 view->settings()->setJavaScriptEnabled(true); | 8116 view->settings()->setJavaScriptEnabled(true); |
8096 view->setMainFrame(remoteClient.frame()); | 8117 view->setMainFrame(remoteClient.frame()); |
8097 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); | 8118 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); |
8098 root->setReplicatedOrigin(SecurityOrigin::createUnique()); | 8119 root->setReplicatedOrigin(SecurityOrigin::createUnique()); |
8099 | 8120 |
8100 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root); | 8121 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root); |
8122 FrameTestHelpers::TestWebWidgetClient widgetClient; | |
8123 WebWidget* widget = WebFrameWidget::create(&widgetClient, localFrame); | |
8101 | 8124 |
8102 // Finally, make sure an embedder triggered load in the local frame swapped | 8125 // Finally, make sure an embedder triggered load in the local frame swapped |
8103 // back in works. | 8126 // back in works. |
8104 registerMockedHttpURLLoad("send_beacon.html"); | 8127 registerMockedHttpURLLoad("send_beacon.html"); |
8105 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon() | 8128 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon() |
8106 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html"); | 8129 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html"); |
8107 | 8130 |
8131 widget->close(); | |
8108 view->close(); | 8132 view->close(); |
8109 } | 8133 } |
8110 | 8134 |
8111 // See https://crbug.com/525285. | 8135 // See https://crbug.com/525285. |
8112 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me) | 8136 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me) |
8113 { | 8137 { |
8114 FrameTestHelpers::TestWebViewClient viewClient; | 8138 FrameTestHelpers::TestWebViewClient viewClient; |
8115 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 8139 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
8116 WebView* view = WebView::create(&viewClient); | 8140 WebView* view = WebView::create(&viewClient); |
8117 view->setMainFrame(remoteClient.frame()); | 8141 view->setMainFrame(remoteClient.frame()); |
8118 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); | 8142 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); |
8119 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); | 8143 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); |
8120 | 8144 |
8121 FrameTestHelpers::createLocalChild(remoteRoot); | 8145 FrameTestHelpers::createLocalChild(remoteRoot); |
8122 | 8146 |
8123 // Do a remote-to-local swap of the top frame. | 8147 // Do a remote-to-local swap of the top frame. |
8124 FrameTestHelpers::TestWebFrameClient localClient; | 8148 FrameTestHelpers::TestWebFrameClient localClient; |
8125 WebLocalFrame* localRoot = WebLocalFrame::createProvisional(&localClient, re moteRoot, WebSandboxFlags::None); | 8149 WebLocalFrame* localRoot = WebLocalFrame::createProvisional(&localClient, re moteRoot, WebSandboxFlags::None); |
8150 FrameTestHelpers::TestWebViewWidgetClient widgetClient(&viewClient); | |
8151 WebWidget* widget = WebFrameWidget::create(&widgetClient, view, localRoot); | |
8126 remoteRoot->swap(localRoot); | 8152 remoteRoot->swap(localRoot); |
8127 | 8153 |
8128 // Load a page with a child frame in the new root to make sure this doesn't | 8154 // 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. | 8155 // crash when the child frame invokes setCoreFrame. |
8130 registerMockedHttpURLLoad("single_iframe.html"); | 8156 registerMockedHttpURLLoad("single_iframe.html"); |
8131 registerMockedHttpURLLoad("visible_iframe.html"); | 8157 registerMockedHttpURLLoad("visible_iframe.html"); |
8132 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); | 8158 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); |
8133 | 8159 |
8160 widget->close(); | |
8134 view->close(); | 8161 view->close(); |
8135 } | 8162 } |
8136 | 8163 |
8137 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { | 8164 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { |
8138 public: | 8165 public: |
8139 MOCK_METHOD4(didOverscroll, void(const WebFloatSize&, const WebFloatSize&, c onst WebFloatPoint&, const WebFloatSize&)); | 8166 MOCK_METHOD4(didOverscroll, void(const WebFloatSize&, const WebFloatSize&, c onst WebFloatPoint&, const WebFloatSize&)); |
8140 }; | 8167 }; |
8141 | 8168 |
8142 class WebFrameOverscrollTest : public WebFrameTest, public ::testing::WithParamI nterface<blink::WebGestureDevice> { | 8169 class WebFrameOverscrollTest : public WebFrameTest, public ::testing::WithParamI nterface<blink::WebGestureDevice> { |
8143 protected: | 8170 protected: |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8684 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); | 8711 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); |
8685 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 8712 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
8686 mainFrame->executeScript(WebScriptSource("hello = 'world';")); | 8713 mainFrame->executeScript(WebScriptSource("hello = 'world';")); |
8687 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); | 8714 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); |
8688 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello")); | 8715 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello")); |
8689 ASSERT_TRUE(result->IsString()); | 8716 ASSERT_TRUE(result->IsString()); |
8690 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC ontext()).ToLocalChecked())); | 8717 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC ontext()).ToLocalChecked())); |
8691 } | 8718 } |
8692 | 8719 |
8693 } // namespace blink | 8720 } // namespace blink |
OLD | NEW |