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

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

Issue 1635873003: Replicating WebFrame::uniqueName across renderers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dump-render-tree3
Patch Set: Rebasing... Created 4 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 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 1574 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1575 WebView* view = WebView::create(&viewClient); 1575 WebView* view = WebView::create(&viewClient);
1576 view->settings()->setJavaScriptEnabled(true); 1576 view->settings()->setJavaScriptEnabled(true);
1577 view->setMainFrame(remoteClient.frame()); 1577 view->setMainFrame(remoteClient.frame());
1578 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); 1578 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1579 root->setReplicatedOrigin(SecurityOrigin::createUnique()); 1579 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1580 1580
1581 WebFrameOwnerProperties properties; 1581 WebFrameOwnerProperties properties;
1582 properties.marginWidth = 11; 1582 properties.marginWidth = 11;
1583 properties.marginHeight = 22; 1583 properties.marginHeight = 22;
1584 FrameTestHelpers::TestWebFrameClient localFrameClient; 1584 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root, "frameN ame", nullptr, nullptr, properties);
1585 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);
1586 1585
1587 registerMockedHttpURLLoad("frame_owner_properties.html"); 1586 registerMockedHttpURLLoad("frame_owner_properties.html");
1588 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html"); 1587 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1589 1588
1590 // Check if the LocalFrame has seen the marginwidth and marginheight 1589 // Check if the LocalFrame has seen the marginwidth and marginheight
1591 // properties. 1590 // properties.
1592 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document (); 1591 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document ();
1593 EXPECT_EQ(11, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginwidthAttr)); 1592 EXPECT_EQ(11, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginwidthAttr));
1594 EXPECT_EQ(22, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginheightAttr)); 1593 EXPECT_EQ(22, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNa mes::marginheightAttr));
1595 1594
(...skipping 11 matching lines...) Expand all
1607 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 1606 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
1608 WebView* view = WebView::create(&viewClient); 1607 WebView* view = WebView::create(&viewClient);
1609 view->settings()->setJavaScriptEnabled(true); 1608 view->settings()->setJavaScriptEnabled(true);
1610 view->setMainFrame(remoteClient.frame()); 1609 view->setMainFrame(remoteClient.frame());
1611 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); 1610 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
1612 root->setReplicatedOrigin(SecurityOrigin::createUnique()); 1611 root->setReplicatedOrigin(SecurityOrigin::createUnique());
1613 1612
1614 WebFrameOwnerProperties properties; 1613 WebFrameOwnerProperties properties;
1615 // Turn off scrolling in the subframe. 1614 // Turn off scrolling in the subframe.
1616 properties.scrollingMode = WebFrameOwnerProperties::ScrollingMode::AlwaysOff ; 1615 properties.scrollingMode = WebFrameOwnerProperties::ScrollingMode::AlwaysOff ;
1617 FrameTestHelpers::TestWebFrameClient localFrameClient; 1616 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root, "frameN ame", nullptr, nullptr, properties);
1618 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);
1619 1617
1620 registerMockedHttpURLLoad("frame_owner_properties.html"); 1618 registerMockedHttpURLLoad("frame_owner_properties.html");
1621 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html"); 1619 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties. html");
1622 1620
1623 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document (); 1621 Document* childDocument = toWebLocalFrameImpl(localFrame)->frame()->document ();
1624 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginwidthAttr)); 1622 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginwidthAttr));
1625 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginheightAttr)); 1623 EXPECT_EQ(0, childDocument->firstBodyElement()->getIntegralAttribute(HTMLNam es::marginheightAttr));
1626 1624
1627 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w(); 1625 FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameVie w();
1628 EXPECT_EQ(nullptr, frameView->horizontalScrollbar()); 1626 EXPECT_EQ(nullptr, frameView->horizontalScrollbar());
(...skipping 4286 matching lines...) Expand 10 before | Expand all | Expand 10 after
5915 , m_willSendRequestCallCount(0) 5913 , m_willSendRequestCallCount(0)
5916 , m_childFrameCreationCount(0) 5914 , m_childFrameCreationCount(0)
5917 { 5915 {
5918 } 5916 }
5919 5917
5920 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; } 5918 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; }
5921 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } 5919 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; }
5922 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } 5920 int willSendRequestCallCount() const { return m_willSendRequestCallCount; }
5923 int childFrameCreationCount() const { return m_childFrameCreationCount; } 5921 int childFrameCreationCount() const { return m_childFrameCreationCount; }
5924 5922
5925 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, WebSandboxFlags, const WebFrameOwnerProperties& frameOwn erProperties) 5923 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, const WebString&, WebSandboxFlags, const WebFrameOwnerPr operties& frameOwnerProperties)
5926 { 5924 {
5927 ASSERT(m_childClient); 5925 ASSERT(m_childClient);
5928 m_childFrameCreationCount++; 5926 m_childFrameCreationCount++;
5929 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); 5927 WebFrame* frame = WebLocalFrame::create(scope, m_childClient);
5930 parent->appendChild(frame); 5928 parent->appendChild(frame);
5931 return frame; 5929 return frame;
5932 } 5930 }
5933 5931
5934 virtual void didStartLoading(bool toDifferentDocument) 5932 virtual void didStartLoading(bool toDifferentDocument)
5935 { 5933 {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
6304 // After commit, there is. 6302 // After commit, there is.
6305 HistoryItem* item = mainFrameLoader.currentItem(); 6303 HistoryItem* item = mainFrameLoader.currentItem();
6306 ASSERT_TRUE(item); 6304 ASSERT_TRUE(item);
6307 EXPECT_EQ(WTF::String(url.data()), item->urlString()); 6305 EXPECT_EQ(WTF::String(url.data()), item->urlString());
6308 } 6306 }
6309 6307
6310 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { 6308 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient {
6311 public: 6309 public:
6312 FailCreateChildFrame() : m_callCount(0) { } 6310 FailCreateChildFrame() : m_callCount(0) { }
6313 6311
6314 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, WebSandboxFlags sandboxFlags, const WebFrameOwnerPrope rties& frameOwnerProperties) override 6312 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, const WebString& frameUniqueName, WebSandboxFlags sand boxFlags, const WebFrameOwnerProperties& frameOwnerProperties) override
6315 { 6313 {
6316 ++m_callCount; 6314 ++m_callCount;
6317 return 0; 6315 return 0;
6318 } 6316 }
6319 6317
6320 int callCount() const { return m_callCount; } 6318 int callCount() const { return m_callCount; }
6321 6319
6322 private: 6320 private:
6323 int m_callCount; 6321 int m_callCount;
6324 }; 6322 };
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
6962 // Make sure that an embedder-triggered detach with a remote frame parent 6960 // Make sure that an embedder-triggered detach with a remote frame parent
6963 // doesn't leave behind dangling pointers. 6961 // doesn't leave behind dangling pointers.
6964 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame) 6962 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame)
6965 { 6963 {
6966 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o 6964 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o
6967 // write tests with a top-level remote frame. 6965 // write tests with a top-level remote frame.
6968 FrameTestHelpers::TestWebViewClient viewClient; 6966 FrameTestHelpers::TestWebViewClient viewClient;
6969 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 6967 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
6970 WebView* view = WebView::create(&viewClient); 6968 WebView* view = WebView::create(&viewClient);
6971 view->setMainFrame(remoteClient.frame()); 6969 view->setMainFrame(remoteClient.frame());
6972 FrameTestHelpers::TestWebFrameClient childFrameClient; 6970 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(view->mainFra me()->toWebRemoteFrame());
6973 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
6974 6971
6975 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d. 6972 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d.
6976 RefPtrWillBePersistent<Frame> childCoreFrame = childFrame->toImplBase()->fra me(); 6973 RefPtrWillBePersistent<Frame> childCoreFrame = childFrame->toImplBase()->fra me();
6977 view->close(); 6974 view->close();
6978 childCoreFrame.clear(); 6975 childCoreFrame.clear();
6979 } 6976 }
6980 6977
6981 class WebFrameSwapTest : public WebFrameTest { 6978 class WebFrameSwapTest : public WebFrameTest {
6982 protected: 6979 protected:
6983 WebFrameSwapTest() 6980 WebFrameSwapTest()
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
7211 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient1); 7208 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient1);
7212 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling(); 7209 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling();
7213 EXPECT_TRUE(targetFrame); 7210 EXPECT_TRUE(targetFrame);
7214 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame); 7211 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame);
7215 7212
7216 targetFrame = mainFrame()->firstChild()->nextSibling(); 7213 targetFrame = mainFrame()->firstChild()->nextSibling();
7217 EXPECT_TRUE(targetFrame); 7214 EXPECT_TRUE(targetFrame);
7218 7215
7219 // Create child frames in the target frame before testing the swap. 7216 // Create child frames in the target frame before testing the swap.
7220 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; 7217 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2;
7221 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2); 7218 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", "uniqueName0", WebSandboxFlags::None, &remoteFrameClient2) ;
7222 7219
7223 FrameTestHelpers::TestWebFrameClient client; 7220 FrameTestHelpers::TestWebFrameClient client;
7224 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7221 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties());
7225 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); 7222 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame);
7226 7223
7227 // FIXME: This almost certainly fires more load events on the iframe element 7224 // FIXME: This almost certainly fires more load events on the iframe element
7228 // than it should. 7225 // than it should.
7229 // Finally, make sure an embedder triggered load in the local frame swapped 7226 // Finally, make sure an embedder triggered load in the local frame swapped
7230 // back in works. 7227 // back in works.
7231 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7228 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
7360 // clean these tests up. 7357 // clean these tests up.
7361 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable) 7358 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable)
7362 { 7359 {
7363 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7360 v8::HandleScope scope(v8::Isolate::GetCurrent());
7364 7361
7365 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7362 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7366 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); 7363 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7367 mainFrame()->swap(remoteParentFrame); 7364 mainFrame()->swap(remoteParentFrame);
7368 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7365 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7369 7366
7370 FrameTestHelpers::TestWebFrameClient childFrameClient; 7367 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(remoteParentF rame);
7371 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties());
7372 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); 7368 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7373 7369
7374 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window")); 7370 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window"));
7375 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]")); 7371 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]"));
7376 EXPECT_TRUE(childOfRemoteParent->IsObject()); 7372 EXPECT_TRUE(childOfRemoteParent->IsObject());
7377 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); 7373 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent));
7378 7374
7379 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length")); 7375 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length"));
7380 ASSERT_TRUE(windowLength->IsInt32()); 7376 ASSERT_TRUE(windowLength->IsInt32());
7381 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); 7377 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value());
7382 7378
7383 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. 7379 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7384 reset(); 7380 reset();
7385 } 7381 }
7386 7382
7387 // Check that frames with a remote parent don't crash while accessing window.fra meElement. 7383 // Check that frames with a remote parent don't crash while accessing window.fra meElement.
7388 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) 7384 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent)
7389 { 7385 {
7390 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7386 v8::HandleScope scope(v8::Isolate::GetCurrent());
7391 7387
7392 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7388 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7393 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); 7389 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7394 mainFrame()->swap(remoteParentFrame); 7390 mainFrame()->swap(remoteParentFrame);
7395 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7391 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7396 7392
7397 FrameTestHelpers::TestWebFrameClient childFrameClient; 7393 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(remoteParentF rame);
7398 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties());
7399 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); 7394 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7400 7395
7401 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement")); 7396 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement"));
7402 // frameElement should be null if cross-origin. 7397 // frameElement should be null if cross-origin.
7403 ASSERT_FALSE(frameElement.IsEmpty()); 7398 ASSERT_FALSE(frameElement.IsEmpty());
7404 EXPECT_TRUE(frameElement->IsNull()); 7399 EXPECT_TRUE(frameElement->IsNull());
7405 7400
7406 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. 7401 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7407 reset(); 7402 reset();
7408 } 7403 }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
7705 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) 7700 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType)
7706 { 7701 {
7707 FrameTestHelpers::TestWebViewClient viewClient; 7702 FrameTestHelpers::TestWebViewClient viewClient;
7708 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7703 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7709 WebView* view = WebView::create(&viewClient); 7704 WebView* view = WebView::create(&viewClient);
7710 view->setMainFrame(remoteClient.frame()); 7705 view->setMainFrame(remoteClient.frame());
7711 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createFromStrin g(WebString::fromUTF8(m_baseURL))); 7706 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createFromStrin g(WebString::fromUTF8(m_baseURL)));
7712 7707
7713 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame. 7708 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame.
7714 CommitTypeWebFrameClient childFrameClient; 7709 CommitTypeWebFrameClient childFrameClient;
7715 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties()); 7710 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(view->mainFra me()->toWebRemoteFrame(), "frameName", &childFrameClient);
7716 registerMockedHttpURLLoad("foo.html"); 7711 registerMockedHttpURLLoad("foo.html");
7717 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); 7712 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html");
7718 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() ); 7713 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() );
7719 view->close(); 7714 view->close();
7720 } 7715 }
7721 7716
7722 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient { 7717 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient {
7723 public: 7718 public:
7724 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { } 7719 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { }
7725 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; } 7720 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; }
7726 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; } 7721 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; }
7727 7722
7728 private: 7723 private:
7729 bool m_didHandleGestureEvent; 7724 bool m_didHandleGestureEvent;
7730 }; 7725 };
7731 7726
7732 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) 7727 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest)
7733 { 7728 {
7734 FrameTestHelpers::TestWebViewClient viewClient; 7729 FrameTestHelpers::TestWebViewClient viewClient;
7735 WebView* view = WebView::create(&viewClient); 7730 WebView* view = WebView::create(&viewClient);
7736 7731
7737 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7732 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7738 view->setMainFrame(remoteClient.frame()); 7733 view->setMainFrame(remoteClient.frame());
7739 7734
7740 FrameTestHelpers::TestWebFrameClient childFrameClient; 7735 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(view->mainFra me()->toWebRemoteFrame());
7741 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
7742 7736
7743 GestureEventTestWebViewClient childViewClient; 7737 GestureEventTestWebViewClient childViewClient;
7744 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame ); 7738 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame );
7745 7739
7746 view->resize(WebSize(1000, 1000)); 7740 view->resize(WebSize(1000, 1000));
7747 7741
7748 widget->handleInputEvent(fatTap(20, 20)); 7742 widget->handleInputEvent(fatTap(20, 20));
7749 EXPECT_TRUE(childViewClient.didHandleGestureEvent()); 7743 EXPECT_TRUE(childViewClient.didHandleGestureEvent());
7750 7744
7751 widget->close(); 7745 widget->close();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
7797 EXPECT_FALSE(client.failed()); 7791 EXPECT_FALSE(client.failed());
7798 } 7792 }
7799 7793
7800 TEST_P(ParameterizedWebFrameTest, DetachRemoteFrame) 7794 TEST_P(ParameterizedWebFrameTest, DetachRemoteFrame)
7801 { 7795 {
7802 FrameTestHelpers::TestWebViewClient viewClient; 7796 FrameTestHelpers::TestWebViewClient viewClient;
7803 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7797 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7804 WebView* view = WebView::create(&viewClient); 7798 WebView* view = WebView::create(&viewClient);
7805 view->setMainFrame(remoteClient.frame()); 7799 view->setMainFrame(remoteClient.frame());
7806 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; 7800 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient;
7807 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe moteChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClie nt); 7801 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe moteChild(WebTreeScopeType::Document, "", "uniqueName1", WebSandboxFlags::None, &childFrameClient);
7808 childFrame->detach(); 7802 childFrame->detach();
7809 view->close(); 7803 view->close();
7810 childFrame->close(); 7804 childFrame->close();
7811 } 7805 }
7812 7806
7813 class TestConsoleMessageWebFrameClient : public FrameTestHelpers::TestWebFrameCl ient { 7807 class TestConsoleMessageWebFrameClient : public FrameTestHelpers::TestWebFrameCl ient {
7814 public: 7808 public:
7815 virtual void didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine, const WebString& stackTrace) 7809 virtual void didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine, const WebString& stackTrace)
7816 { 7810 {
7817 messages.append(message); 7811 messages.append(message);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
7950 7944
7951 7945
7952 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling) 7946 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling)
7953 { 7947 {
7954 FrameTestHelpers::TestWebViewClient viewClient; 7948 FrameTestHelpers::TestWebViewClient viewClient;
7955 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7949 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7956 WebView* view = WebView::create(&viewClient); 7950 WebView* view = WebView::create(&viewClient);
7957 view->setMainFrame(remoteClient.frame()); 7951 view->setMainFrame(remoteClient.frame());
7958 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame(); 7952 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame();
7959 7953
7960 WebLocalFrameScope secondFrame(parent->createLocalChild(WebTreeScopeType::Do cument, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties())) ; 7954 WebLocalFrameScope secondFrame(FrameTestHelpers::createLocalChild(parent, "n ame2"));
7961 WebLocalFrameScope fourthFrame(parent->createLocalChild(WebTreeScopeType::Do cument, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerProperties ())); 7955 WebLocalFrameScope fourthFrame(FrameTestHelpers::createLocalChild(parent, "n ame4", nullptr, secondFrame));
7962 WebLocalFrameScope thirdFrame(parent->createLocalChild(WebTreeScopeType::Doc ument, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerProperties( ))); 7956 WebLocalFrameScope thirdFrame(FrameTestHelpers::createLocalChild(parent, "na me3", nullptr, secondFrame));
7963 WebLocalFrameScope firstFrame(parent->createLocalChild(WebTreeScopeType::Doc ument, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties())); 7957 WebLocalFrameScope firstFrame(FrameTestHelpers::createLocalChild(parent, "na me1"));
7964 7958
7965 EXPECT_EQ(firstFrame, parent->firstChild()); 7959 EXPECT_EQ(firstFrame, parent->firstChild());
7966 EXPECT_EQ(nullptr, firstFrame->previousSibling()); 7960 EXPECT_EQ(nullptr, firstFrame->previousSibling());
7967 EXPECT_EQ(secondFrame, firstFrame->nextSibling()); 7961 EXPECT_EQ(secondFrame, firstFrame->nextSibling());
7968 7962
7969 EXPECT_EQ(firstFrame, secondFrame->previousSibling()); 7963 EXPECT_EQ(firstFrame, secondFrame->previousSibling());
7970 EXPECT_EQ(thirdFrame, secondFrame->nextSibling()); 7964 EXPECT_EQ(thirdFrame, secondFrame->nextSibling());
7971 7965
7972 EXPECT_EQ(secondFrame, thirdFrame->previousSibling()); 7966 EXPECT_EQ(secondFrame, thirdFrame->previousSibling());
7973 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling()); 7967 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling());
(...skipping 13 matching lines...) Expand all
7987 TEST_P(ParameterizedWebFrameTest, SendBeaconFromChildWithRemoteMainFrame) 7981 TEST_P(ParameterizedWebFrameTest, SendBeaconFromChildWithRemoteMainFrame)
7988 { 7982 {
7989 FrameTestHelpers::TestWebViewClient viewClient; 7983 FrameTestHelpers::TestWebViewClient viewClient;
7990 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7984 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7991 WebView* view = WebView::create(&viewClient); 7985 WebView* view = WebView::create(&viewClient);
7992 view->settings()->setJavaScriptEnabled(true); 7986 view->settings()->setJavaScriptEnabled(true);
7993 view->setMainFrame(remoteClient.frame()); 7987 view->setMainFrame(remoteClient.frame());
7994 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); 7988 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
7995 root->setReplicatedOrigin(SecurityOrigin::createUnique()); 7989 root->setReplicatedOrigin(SecurityOrigin::createUnique());
7996 7990
7997 FrameTestHelpers::TestWebFrameClient localFrameClient; 7991 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root);
7998 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, WebFrameOwnerPropertie s());
7999 7992
8000 // Finally, make sure an embedder triggered load in the local frame swapped 7993 // Finally, make sure an embedder triggered load in the local frame swapped
8001 // back in works. 7994 // back in works.
8002 registerMockedHttpURLLoad("send_beacon.html"); 7995 registerMockedHttpURLLoad("send_beacon.html");
8003 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon() 7996 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon()
8004 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html"); 7997 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html");
8005 7998
8006 view->close(); 7999 view->close();
8007 } 8000 }
8008 8001
8009 // See https://crbug.com/525285. 8002 // See https://crbug.com/525285.
8010 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me) 8003 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me)
8011 { 8004 {
8012 FrameTestHelpers::TestWebViewClient viewClient; 8005 FrameTestHelpers::TestWebViewClient viewClient;
8013 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 8006 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
8014 WebView* view = WebView::create(&viewClient); 8007 WebView* view = WebView::create(&viewClient);
8015 view->setMainFrame(remoteClient.frame()); 8008 view->setMainFrame(remoteClient.frame());
8016 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); 8009 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame();
8017 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); 8010 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique());
8018 8011
8019 FrameTestHelpers::TestWebFrameClient localFrameClient; 8012 FrameTestHelpers::createLocalChild(remoteRoot);
8020 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr, WebFrameOwnerProperties());
8021 8013
8022 // Do a remote-to-local swap of the top frame. 8014 // Do a remote-to-local swap of the top frame.
8023 FrameTestHelpers::TestWebFrameClient localClient; 8015 FrameTestHelpers::TestWebFrameClient localClient;
8024 WebLocalFrame* localRoot = WebLocalFrame::createProvisional(&localClient, re moteRoot, WebSandboxFlags::None, WebFrameOwnerProperties()); 8016 WebLocalFrame* localRoot = WebLocalFrame::createProvisional(&localClient, re moteRoot, WebSandboxFlags::None, WebFrameOwnerProperties());
8025 remoteRoot->swap(localRoot); 8017 remoteRoot->swap(localRoot);
8026 8018
8027 // Load a page with a child frame in the new root to make sure this doesn't 8019 // Load a page with a child frame in the new root to make sure this doesn't
8028 // crash when the child frame invokes setCoreFrame. 8020 // crash when the child frame invokes setCoreFrame.
8029 registerMockedHttpURLLoad("single_iframe.html"); 8021 registerMockedHttpURLLoad("single_iframe.html");
8030 registerMockedHttpURLLoad("visible_iframe.html"); 8022 registerMockedHttpURLLoad("visible_iframe.html");
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
8442 } 8434 }
8443 8435
8444 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) 8436 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange)
8445 { 8437 {
8446 swapLocalFrameToRemoteFrame(); 8438 swapLocalFrameToRemoteFrame();
8447 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p arentElement.style.display = 'none';")); 8439 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p arentElement.style.display = 'none';"));
8448 EXPECT_FALSE(remoteFrameClient()->isVisible()); 8440 EXPECT_FALSE(remoteFrameClient()->isVisible());
8449 } 8441 }
8450 8442
8451 } // namespace blink 8443 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/FrameThrottlingTest.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