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