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