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

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: Added FrameTreeHelpers::createLocalChild. 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 4251 matching lines...) Expand 10 before | Expand all | Expand 10 after
5880 , m_willSendRequestCallCount(0) 5878 , m_willSendRequestCallCount(0)
5881 , m_childFrameCreationCount(0) 5879 , m_childFrameCreationCount(0)
5882 { 5880 {
5883 } 5881 }
5884 5882
5885 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; } 5883 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; }
5886 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } 5884 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; }
5887 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } 5885 int willSendRequestCallCount() const { return m_willSendRequestCallCount; }
5888 int childFrameCreationCount() const { return m_childFrameCreationCount; } 5886 int childFrameCreationCount() const { return m_childFrameCreationCount; }
5889 5887
5890 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, WebSandboxFlags, const WebFrameOwnerProperties& frameOwn erProperties) 5888 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, const WebString&, WebSandboxFlags, const WebFrameOwnerPr operties& frameOwnerProperties)
5891 { 5889 {
5892 ASSERT(m_childClient); 5890 ASSERT(m_childClient);
5893 m_childFrameCreationCount++; 5891 m_childFrameCreationCount++;
5894 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); 5892 WebFrame* frame = WebLocalFrame::create(scope, m_childClient);
5895 parent->appendChild(frame); 5893 parent->appendChild(frame);
5896 return frame; 5894 return frame;
5897 } 5895 }
5898 5896
5899 virtual void didStartLoading(bool toDifferentDocument) 5897 virtual void didStartLoading(bool toDifferentDocument)
5900 { 5898 {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
6269 // After commit, there is. 6267 // After commit, there is.
6270 HistoryItem* item = mainFrameLoader.currentItem(); 6268 HistoryItem* item = mainFrameLoader.currentItem();
6271 ASSERT_TRUE(item); 6269 ASSERT_TRUE(item);
6272 EXPECT_EQ(WTF::String(url.data()), item->urlString()); 6270 EXPECT_EQ(WTF::String(url.data()), item->urlString());
6273 } 6271 }
6274 6272
6275 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { 6273 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient {
6276 public: 6274 public:
6277 FailCreateChildFrame() : m_callCount(0) { } 6275 FailCreateChildFrame() : m_callCount(0) { }
6278 6276
6279 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, WebSandboxFlags sandboxFlags, const WebFrameOwnerPrope rties& frameOwnerProperties) override 6277 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, const WebString& frameUniqueName, WebSandboxFlags sand boxFlags, const WebFrameOwnerProperties& frameOwnerProperties) override
6280 { 6278 {
6281 ++m_callCount; 6279 ++m_callCount;
6282 return 0; 6280 return 0;
6283 } 6281 }
6284 6282
6285 int callCount() const { return m_callCount; } 6283 int callCount() const { return m_callCount; }
6286 6284
6287 private: 6285 private:
6288 int m_callCount; 6286 int m_callCount;
6289 }; 6287 };
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
6927 // Make sure that an embedder-triggered detach with a remote frame parent 6925 // Make sure that an embedder-triggered detach with a remote frame parent
6928 // doesn't leave behind dangling pointers. 6926 // doesn't leave behind dangling pointers.
6929 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame) 6927 TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame)
6930 { 6928 {
6931 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o 6929 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o
6932 // write tests with a top-level remote frame. 6930 // write tests with a top-level remote frame.
6933 FrameTestHelpers::TestWebViewClient viewClient; 6931 FrameTestHelpers::TestWebViewClient viewClient;
6934 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 6932 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
6935 WebView* view = WebView::create(&viewClient); 6933 WebView* view = WebView::create(&viewClient);
6936 view->setMainFrame(remoteClient.frame()); 6934 view->setMainFrame(remoteClient.frame());
6937 FrameTestHelpers::TestWebFrameClient childFrameClient; 6935 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(view->mainFra me()->toWebRemoteFrame());
6938 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
6939 6936
6940 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d. 6937 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d.
6941 RefPtrWillBePersistent<Frame> childCoreFrame = childFrame->toImplBase()->fra me(); 6938 RefPtrWillBePersistent<Frame> childCoreFrame = childFrame->toImplBase()->fra me();
6942 view->close(); 6939 view->close();
6943 childCoreFrame.clear(); 6940 childCoreFrame.clear();
6944 } 6941 }
6945 6942
6946 class WebFrameSwapTest : public WebFrameTest { 6943 class WebFrameSwapTest : public WebFrameTest {
6947 protected: 6944 protected:
6948 WebFrameSwapTest() 6945 WebFrameSwapTest()
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
7176 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient1); 7173 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient1);
7177 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling(); 7174 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling();
7178 EXPECT_TRUE(targetFrame); 7175 EXPECT_TRUE(targetFrame);
7179 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame); 7176 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame);
7180 7177
7181 targetFrame = mainFrame()->firstChild()->nextSibling(); 7178 targetFrame = mainFrame()->firstChild()->nextSibling();
7182 EXPECT_TRUE(targetFrame); 7179 EXPECT_TRUE(targetFrame);
7183 7180
7184 // Create child frames in the target frame before testing the swap. 7181 // Create child frames in the target frame before testing the swap.
7185 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; 7182 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2;
7186 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", WebSandboxFlags::None, &remoteFrameClient2); 7183 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", "uniqueName0", WebSandboxFlags::None, &remoteFrameClient2) ;
7187 7184
7188 FrameTestHelpers::TestWebFrameClient client; 7185 FrameTestHelpers::TestWebFrameClient client;
7189 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7186 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties());
7190 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); 7187 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame);
7191 7188
7192 // FIXME: This almost certainly fires more load events on the iframe element 7189 // FIXME: This almost certainly fires more load events on the iframe element
7193 // than it should. 7190 // than it should.
7194 // Finally, make sure an embedder triggered load in the local frame swapped 7191 // Finally, make sure an embedder triggered load in the local frame swapped
7195 // back in works. 7192 // back in works.
7196 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7193 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
7325 // clean these tests up. 7322 // clean these tests up.
7326 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable) 7323 TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable)
7327 { 7324 {
7328 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7325 v8::HandleScope scope(v8::Isolate::GetCurrent());
7329 7326
7330 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7327 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7331 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); 7328 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7332 mainFrame()->swap(remoteParentFrame); 7329 mainFrame()->swap(remoteParentFrame);
7333 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7330 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7334 7331
7335 FrameTestHelpers::TestWebFrameClient childFrameClient; 7332 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(remoteParentF rame);
7336 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties());
7337 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); 7333 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7338 7334
7339 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window")); 7335 v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScr iptSource("window"));
7340 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]")); 7336 v8::Local<v8::Value> childOfRemoteParent = childFrame->executeScriptAndRetur nValue(WebScriptSource("parent.frames[0]"));
7341 EXPECT_TRUE(childOfRemoteParent->IsObject()); 7337 EXPECT_TRUE(childOfRemoteParent->IsObject());
7342 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); 7338 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent));
7343 7339
7344 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length")); 7340 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length"));
7345 ASSERT_TRUE(windowLength->IsInt32()); 7341 ASSERT_TRUE(windowLength->IsInt32());
7346 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); 7342 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value());
7347 7343
7348 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. 7344 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7349 reset(); 7345 reset();
7350 } 7346 }
7351 7347
7352 // Check that frames with a remote parent don't crash while accessing window.fra meElement. 7348 // Check that frames with a remote parent don't crash while accessing window.fra meElement.
7353 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) 7349 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent)
7354 { 7350 {
7355 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7351 v8::HandleScope scope(v8::Isolate::GetCurrent());
7356 7352
7357 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7353 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7358 WebRemoteFrame* remoteParentFrame = remoteClient.frame(); 7354 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7359 mainFrame()->swap(remoteParentFrame); 7355 mainFrame()->swap(remoteParentFrame);
7360 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 7356 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7361 7357
7362 FrameTestHelpers::TestWebFrameClient childFrameClient; 7358 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(remoteParentF rame);
7363 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScope Type::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameO wnerProperties());
7364 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); 7359 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7365 7360
7366 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement")); 7361 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement"));
7367 // frameElement should be null if cross-origin. 7362 // frameElement should be null if cross-origin.
7368 ASSERT_FALSE(frameElement.IsEmpty()); 7363 ASSERT_FALSE(frameElement.IsEmpty());
7369 EXPECT_TRUE(frameElement->IsNull()); 7364 EXPECT_TRUE(frameElement->IsNull());
7370 7365
7371 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. 7366 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7372 reset(); 7367 reset();
7373 } 7368 }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
7670 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) 7665 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType)
7671 { 7666 {
7672 FrameTestHelpers::TestWebViewClient viewClient; 7667 FrameTestHelpers::TestWebViewClient viewClient;
7673 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7668 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7674 WebView* view = WebView::create(&viewClient); 7669 WebView* view = WebView::create(&viewClient);
7675 view->setMainFrame(remoteClient.frame()); 7670 view->setMainFrame(remoteClient.frame());
7676 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createFromStrin g(WebString::fromUTF8(m_baseURL))); 7671 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createFromStrin g(WebString::fromUTF8(m_baseURL)));
7677 7672
7678 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame. 7673 // If an iframe has a remote main frame, ensure the inital commit is correct ly identified as WebInitialCommitInChildFrame.
7679 CommitTypeWebFrameClient childFrameClient; 7674 CommitTypeWebFrameClient childFrameClient;
7680 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties()); 7675 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(view->mainFra me()->toWebRemoteFrame(), "frameName", &childFrameClient);
7681 registerMockedHttpURLLoad("foo.html"); 7676 registerMockedHttpURLLoad("foo.html");
7682 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); 7677 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html");
7683 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() ); 7678 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType() );
7684 view->close(); 7679 view->close();
7685 } 7680 }
7686 7681
7687 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient { 7682 class GestureEventTestWebViewClient : public FrameTestHelpers::TestWebViewClient {
7688 public: 7683 public:
7689 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { } 7684 GestureEventTestWebViewClient() : m_didHandleGestureEvent(false) { }
7690 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; } 7685 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled ) override { m_didHandleGestureEvent = true; }
7691 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; } 7686 bool didHandleGestureEvent() const { return m_didHandleGestureEvent; }
7692 7687
7693 private: 7688 private:
7694 bool m_didHandleGestureEvent; 7689 bool m_didHandleGestureEvent;
7695 }; 7690 };
7696 7691
7697 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) 7692 TEST_P(ParameterizedWebFrameTest, FrameWidgetTest)
7698 { 7693 {
7699 FrameTestHelpers::TestWebViewClient viewClient; 7694 FrameTestHelpers::TestWebViewClient viewClient;
7700 WebView* view = WebView::create(&viewClient); 7695 WebView* view = WebView::create(&viewClient);
7701 7696
7702 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7697 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7703 view->setMainFrame(remoteClient.frame()); 7698 view->setMainFrame(remoteClient.frame());
7704 7699
7705 FrameTestHelpers::TestWebFrameClient childFrameClient; 7700 WebLocalFrame* childFrame = FrameTestHelpers::createLocalChild(view->mainFra me()->toWebRemoteFrame());
7706 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient , nullptr, WebFrameOwnerProperties());
7707 7701
7708 GestureEventTestWebViewClient childViewClient; 7702 GestureEventTestWebViewClient childViewClient;
7709 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame ); 7703 WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame );
7710 7704
7711 view->resize(WebSize(1000, 1000)); 7705 view->resize(WebSize(1000, 1000));
7712 7706
7713 widget->handleInputEvent(fatTap(20, 20)); 7707 widget->handleInputEvent(fatTap(20, 20));
7714 EXPECT_TRUE(childViewClient.didHandleGestureEvent()); 7708 EXPECT_TRUE(childViewClient.didHandleGestureEvent());
7715 7709
7716 widget->close(); 7710 widget->close();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
7762 EXPECT_FALSE(client.failed()); 7756 EXPECT_FALSE(client.failed());
7763 } 7757 }
7764 7758
7765 TEST_P(ParameterizedWebFrameTest, DetachRemoteFrame) 7759 TEST_P(ParameterizedWebFrameTest, DetachRemoteFrame)
7766 { 7760 {
7767 FrameTestHelpers::TestWebViewClient viewClient; 7761 FrameTestHelpers::TestWebViewClient viewClient;
7768 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7762 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7769 WebView* view = WebView::create(&viewClient); 7763 WebView* view = WebView::create(&viewClient);
7770 view->setMainFrame(remoteClient.frame()); 7764 view->setMainFrame(remoteClient.frame());
7771 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; 7765 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient;
7772 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe moteChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClie nt); 7766 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe moteChild(WebTreeScopeType::Document, "", "uniqueName1", WebSandboxFlags::None, &childFrameClient);
7773 childFrame->detach(); 7767 childFrame->detach();
7774 view->close(); 7768 view->close();
7775 childFrame->close(); 7769 childFrame->close();
7776 } 7770 }
7777 7771
7778 class TestConsoleMessageWebFrameClient : public FrameTestHelpers::TestWebFrameCl ient { 7772 class TestConsoleMessageWebFrameClient : public FrameTestHelpers::TestWebFrameCl ient {
7779 public: 7773 public:
7780 virtual void didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine, const WebString& stackTrace) 7774 virtual void didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine, const WebString& stackTrace)
7781 { 7775 {
7782 messages.append(message); 7776 messages.append(message);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
7915 7909
7916 7910
7917 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling) 7911 TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling)
7918 { 7912 {
7919 FrameTestHelpers::TestWebViewClient viewClient; 7913 FrameTestHelpers::TestWebViewClient viewClient;
7920 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7914 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7921 WebView* view = WebView::create(&viewClient); 7915 WebView* view = WebView::create(&viewClient);
7922 view->setMainFrame(remoteClient.frame()); 7916 view->setMainFrame(remoteClient.frame());
7923 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame(); 7917 WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame();
7924 7918
7925 WebLocalFrameScope secondFrame(parent->createLocalChild(WebTreeScopeType::Do cument, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties())) ; 7919 WebLocalFrameScope secondFrame(FrameTestHelpers::createLocalChild(parent, "n ame2"));
7926 WebLocalFrameScope fourthFrame(parent->createLocalChild(WebTreeScopeType::Do cument, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerProperties ())); 7920 WebLocalFrameScope fourthFrame(FrameTestHelpers::createLocalChild(parent, "n ame4", nullptr, secondFrame));
7927 WebLocalFrameScope thirdFrame(parent->createLocalChild(WebTreeScopeType::Doc ument, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerProperties( ))); 7921 WebLocalFrameScope thirdFrame(FrameTestHelpers::createLocalChild(parent, "na me3", nullptr, secondFrame));
7928 WebLocalFrameScope firstFrame(parent->createLocalChild(WebTreeScopeType::Doc ument, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties())); 7922 WebLocalFrameScope firstFrame(FrameTestHelpers::createLocalChild(parent, "na me1"));
7929 7923
7930 EXPECT_EQ(firstFrame, parent->firstChild()); 7924 EXPECT_EQ(firstFrame, parent->firstChild());
7931 EXPECT_EQ(nullptr, firstFrame->previousSibling()); 7925 EXPECT_EQ(nullptr, firstFrame->previousSibling());
7932 EXPECT_EQ(secondFrame, firstFrame->nextSibling()); 7926 EXPECT_EQ(secondFrame, firstFrame->nextSibling());
7933 7927
7934 EXPECT_EQ(firstFrame, secondFrame->previousSibling()); 7928 EXPECT_EQ(firstFrame, secondFrame->previousSibling());
7935 EXPECT_EQ(thirdFrame, secondFrame->nextSibling()); 7929 EXPECT_EQ(thirdFrame, secondFrame->nextSibling());
7936 7930
7937 EXPECT_EQ(secondFrame, thirdFrame->previousSibling()); 7931 EXPECT_EQ(secondFrame, thirdFrame->previousSibling());
7938 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling()); 7932 EXPECT_EQ(fourthFrame, thirdFrame->nextSibling());
(...skipping 13 matching lines...) Expand all
7952 TEST_P(ParameterizedWebFrameTest, SendBeaconFromChildWithRemoteMainFrame) 7946 TEST_P(ParameterizedWebFrameTest, SendBeaconFromChildWithRemoteMainFrame)
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->settings()->setJavaScriptEnabled(true); 7951 view->settings()->setJavaScriptEnabled(true);
7958 view->setMainFrame(remoteClient.frame()); 7952 view->setMainFrame(remoteClient.frame());
7959 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); 7953 WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame();
7960 root->setReplicatedOrigin(SecurityOrigin::createUnique()); 7954 root->setReplicatedOrigin(SecurityOrigin::createUnique());
7961 7955
7962 FrameTestHelpers::TestWebFrameClient localFrameClient; 7956 WebLocalFrame* localFrame = FrameTestHelpers::createLocalChild(root);
7963 WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Documen t, "", WebSandboxFlags::None, &localFrameClient, nullptr, WebFrameOwnerPropertie s());
7964 7957
7965 // Finally, make sure an embedder triggered load in the local frame swapped 7958 // Finally, make sure an embedder triggered load in the local frame swapped
7966 // back in works. 7959 // back in works.
7967 registerMockedHttpURLLoad("send_beacon.html"); 7960 registerMockedHttpURLLoad("send_beacon.html");
7968 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon() 7961 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon()
7969 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html"); 7962 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html");
7970 7963
7971 view->close(); 7964 view->close();
7972 } 7965 }
7973 7966
7974 // See https://crbug.com/525285. 7967 // See https://crbug.com/525285.
7975 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me) 7968 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me)
7976 { 7969 {
7977 FrameTestHelpers::TestWebViewClient viewClient; 7970 FrameTestHelpers::TestWebViewClient viewClient;
7978 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7971 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7979 WebView* view = WebView::create(&viewClient); 7972 WebView* view = WebView::create(&viewClient);
7980 view->setMainFrame(remoteClient.frame()); 7973 view->setMainFrame(remoteClient.frame());
7981 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); 7974 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame();
7982 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); 7975 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique());
7983 7976
7984 FrameTestHelpers::TestWebFrameClient localFrameClient; 7977 FrameTestHelpers::createLocalChild(remoteRoot);
7985 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr, WebFrameOwnerProperties());
7986 7978
7987 // Do a remote-to-local swap of the top frame. 7979 // Do a remote-to-local swap of the top frame.
7988 FrameTestHelpers::TestWebFrameClient localClient; 7980 FrameTestHelpers::TestWebFrameClient localClient;
7989 WebLocalFrame* localRoot = WebLocalFrame::createProvisional(&localClient, re moteRoot, WebSandboxFlags::None, WebFrameOwnerProperties()); 7981 WebLocalFrame* localRoot = WebLocalFrame::createProvisional(&localClient, re moteRoot, WebSandboxFlags::None, WebFrameOwnerProperties());
7990 remoteRoot->swap(localRoot); 7982 remoteRoot->swap(localRoot);
7991 7983
7992 // Load a page with a child frame in the new root to make sure this doesn't 7984 // Load a page with a child frame in the new root to make sure this doesn't
7993 // crash when the child frame invokes setCoreFrame. 7985 // crash when the child frame invokes setCoreFrame.
7994 registerMockedHttpURLLoad("single_iframe.html"); 7986 registerMockedHttpURLLoad("single_iframe.html");
7995 registerMockedHttpURLLoad("visible_iframe.html"); 7987 registerMockedHttpURLLoad("visible_iframe.html");
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
8407 } 8399 }
8408 8400
8409 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) 8401 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange)
8410 { 8402 {
8411 swapLocalFrameToRemoteFrame(); 8403 swapLocalFrameToRemoteFrame();
8412 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p arentElement.style.display = 'none';")); 8404 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p arentElement.style.display = 'none';"));
8413 EXPECT_FALSE(remoteFrameClient()->isVisible()); 8405 EXPECT_FALSE(remoteFrameClient()->isVisible());
8414 } 8406 }
8415 8407
8416 } // namespace blink 8408 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698