Chromium Code Reviews| Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| index 6ccabebaf585749882754bfb8139c8719d6095a9..c6b3efe7540d7adc638f175ad97ee0cf2c2a4ec1 100644 |
| --- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| @@ -1607,6 +1607,90 @@ TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksWithRelayoutsWhenHeightChanged |
| EXPECT_EQ(String("updatedValue"), element->innerText()); |
| } |
| +TEST_F(WebFrameTest, FrameOwnerPropertiesMargin) |
| +{ |
| + FrameTestHelpers::TestWebViewClient viewClient; |
| + FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
| + WebView* view = WebView::create(&viewClient); |
| + view->settings()->setJavaScriptEnabled(true); |
| + view->setMainFrame(remoteClient.frame()); |
| + WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); |
| + root->setReplicatedOrigin(SecurityOrigin::createUnique()); |
| + |
| + WebFrameOwnerProperties properties; |
| + properties.marginWidth = 11; |
| + properties.marginHeight = 22; |
| + FrameTestHelpers::TestWebFrameClient localFrameClient; |
| + WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties); |
| + |
| + registerMockedHttpURLLoad("frame_owner_properties.html"); |
| + FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties.html"); |
| + |
| + { |
| + // Check if the LocalFrame has seen the marginwidth and marginheight |
| + // properties. |
| + v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
| + |
| + v8::Local<v8::Value> marginWidthResult = localFrame->executeScriptAndReturnValue(WebScriptSource("bodyMarginWidth")); |
|
dcheng
2015/10/14 07:20:43
document.body.marginwidth directly here? Similar c
lazyboy
2015/10/14 20:05:29
Done.
I need document.body.getAttribute('marginwid
|
| + ASSERT_TRUE(marginWidthResult->IsString()); |
| + v8::String::Utf8Value widthUtf8(marginWidthResult); |
| + EXPECT_EQ("11", std::string(*widthUtf8, widthUtf8.length())); |
|
dcheng
2015/10/14 07:20:43
I think it might be easier to verify the result wi
lazyboy
2015/10/14 20:05:29
Done.
Using parseInt() to force int.
|
| + |
| + v8::Local<v8::Value> marginHeightResult = localFrame->executeScriptAndReturnValue(WebScriptSource("bodyMarginHeight")); |
| + ASSERT_TRUE(marginHeightResult->IsString()); |
| + v8::String::Utf8Value heightUtf8(marginHeightResult); |
| + EXPECT_EQ("22", std::string(*heightUtf8, heightUtf8.length())); |
| + } |
| + |
| + FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView(); |
| + // Expect scrollbars to be enabled by default. |
| + EXPECT_NE(nullptr, frameView->horizontalScrollbar()); |
| + EXPECT_NE(nullptr, frameView->verticalScrollbar()); |
| + |
| + view->close(); |
| +} |
| + |
| +TEST_F(WebFrameTest, FrameOwnerPropertiesScrolling) |
| +{ |
| + FrameTestHelpers::TestWebViewClient viewClient; |
| + FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
| + WebView* view = WebView::create(&viewClient); |
| + view->settings()->setJavaScriptEnabled(true); |
| + view->setMainFrame(remoteClient.frame()); |
| + WebRemoteFrame* root = view->mainFrame()->toWebRemoteFrame(); |
| + root->setReplicatedOrigin(SecurityOrigin::createUnique()); |
| + |
| + WebFrameOwnerProperties properties; |
| + // Turn off scrolling in the subframe. |
| + properties.scrollingMode = WebFrameOwnerProperties::ScrollingMode::AlwaysOff; |
| + FrameTestHelpers::TestWebFrameClient localFrameClient; |
| + WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties); |
| + |
| + registerMockedHttpURLLoad("frame_owner_properties.html"); |
| + FrameTestHelpers::loadFrame(localFrame, m_baseURL + "frame_owner_properties.html"); |
| + |
| + { |
| + v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
| + |
| + v8::Local<v8::Value> marginWidthResult = localFrame->executeScriptAndReturnValue(WebScriptSource("bodyMarginWidth")); |
| + ASSERT_TRUE(marginWidthResult->IsString()); |
| + v8::String::Utf8Value widthUtf8(marginWidthResult); |
| + EXPECT_EQ("0", std::string(*widthUtf8, widthUtf8.length())); |
| + |
| + v8::Local<v8::Value> marginHeightResult = localFrame->executeScriptAndReturnValue(WebScriptSource("bodyMarginHeight")); |
| + ASSERT_TRUE(marginHeightResult->IsString()); |
| + v8::String::Utf8Value heightUtf8(marginHeightResult); |
| + EXPECT_EQ("0", std::string(*heightUtf8, heightUtf8.length())); |
| + } |
| + |
| + FrameView* frameView = static_cast<WebLocalFrameImpl*>(localFrame)->frameView(); |
| + EXPECT_EQ(nullptr, frameView->horizontalScrollbar()); |
| + EXPECT_EQ(nullptr, frameView->verticalScrollbar()); |
| + |
| + view->close(); |
| +} |
| + |
| + |
| TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations) |
| { |
| UseMockScrollbarSettings mockScrollbarSettings; |
| @@ -5928,7 +6012,7 @@ public: |
| int willSendRequestCallCount() const { return m_willSendRequestCallCount; } |
| int childFrameCreationCount() const { return m_childFrameCreationCount; } |
| - virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, const WebString&, WebSandboxFlags) |
| + virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, const WebString&, WebSandboxFlags, const WebFrameOwnerProperties& frameOwnerProperties) |
| { |
| ASSERT(m_childClient); |
| m_childFrameCreationCount++; |
| @@ -6317,7 +6401,7 @@ class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { |
| public: |
| FailCreateChildFrame() : m_callCount(0) { } |
| - WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, const WebString& frameName, WebSandboxFlags sandboxFlags) override |
| + WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, const WebString& frameName, WebSandboxFlags sandboxFlags, const WebFrameOwnerProperties& frameOwnerProperties) override |
| { |
| ++m_callCount; |
| return 0; |
| @@ -6979,7 +7063,7 @@ TEST_P(ParameterizedWebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame) |
| WebView* view = WebView::create(&viewClient); |
| view->setMainFrame(remoteClient.frame()); |
| FrameTestHelpers::TestWebFrameClient childFrameClient; |
| - WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); |
| + WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameOwnerProperties()); |
| // Purposely keep the LocalFrame alive so it's the last thing to be destroyed. |
| RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame); |
| @@ -7014,7 +7098,7 @@ TEST_F(WebFrameSwapTest, SwapMainFrame) |
| FrameTestHelpers::TestWebFrameClient client; |
| WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document, &client); |
| - localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None); |
| + localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None, WebFrameOwnerProperties()); |
| remoteFrame->swap(localFrame); |
| // Finally, make sure an embedder triggered load in the local frame swapped |
| @@ -7078,7 +7162,7 @@ TEST_F(WebFrameSwapTest, SwapFirstChild) |
| FrameTestHelpers::TestWebFrameClient client; |
| WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document, &client); |
| - localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None); |
| + localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None, WebFrameOwnerProperties()); |
| swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame); |
| // FIXME: This almost certainly fires more load events on the iframe element |
| @@ -7117,7 +7201,7 @@ TEST_F(WebFrameSwapTest, SwapMiddleChild) |
| FrameTestHelpers::TestWebFrameClient client; |
| WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document, &client); |
| - localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None); |
| + localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None, WebFrameOwnerProperties()); |
| swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame); |
| // FIXME: This almost certainly fires more load events on the iframe element |
| @@ -7153,7 +7237,7 @@ TEST_F(WebFrameSwapTest, SwapLastChild) |
| FrameTestHelpers::TestWebFrameClient client; |
| WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document, &client); |
| - localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None); |
| + localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None, WebFrameOwnerProperties()); |
| swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); |
| // FIXME: This almost certainly fires more load events on the iframe element |
| @@ -7198,7 +7282,7 @@ TEST_F(WebFrameSwapTest, SwapParentShouldDetachChildren) |
| FrameTestHelpers::TestWebFrameClient client; |
| WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document, &client); |
| - localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None); |
| + localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None, WebFrameOwnerProperties()); |
| swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); |
| // FIXME: This almost certainly fires more load events on the iframe element |
| @@ -7242,7 +7326,7 @@ TEST_F(WebFrameSwapTest, SwapPreservesGlobalContext) |
| // Now check that remote -> local works too, since it goes through a different code path. |
| FrameTestHelpers::TestWebFrameClient client; |
| WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document, &client); |
| - localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None); |
| + localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None, WebFrameOwnerProperties()); |
| remoteFrame->swap(localFrame); |
| v8::Local<v8::Value> localWindow = mainFrame()->executeScriptAndReturnValue(WebScriptSource( |
| "document.querySelector('#frame2').contentWindow;")); |
| @@ -7276,7 +7360,7 @@ TEST_F(WebFrameSwapTest, SwapInitializesGlobal) |
| FrameTestHelpers::TestWebFrameClient client; |
| WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document, &client); |
| - localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None); |
| + localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None, WebFrameOwnerProperties()); |
| remoteFrame->swap(localFrame); |
| v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnValue(WebScriptSource("saved.top")); |
| EXPECT_TRUE(localWindowTop->IsObject()); |
| @@ -7347,7 +7431,7 @@ TEST_F(WebFrameSwapTest, FramesOfRemoteParentAreIndexable) |
| remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
| FrameTestHelpers::TestWebFrameClient childFrameClient; |
| - WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); |
| + WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameOwnerProperties()); |
| FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); |
| v8::Local<v8::Value> window = childFrame->executeScriptAndReturnValue(WebScriptSource("window")); |
| @@ -7374,7 +7458,7 @@ TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent) |
| remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
| FrameTestHelpers::TestWebFrameClient childFrameClient; |
| - WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); |
| + WebLocalFrame* childFrame = remoteParentFrame->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameOwnerProperties()); |
| FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html"); |
| v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue(WebScriptSource("window.frameElement")); |
| @@ -7421,7 +7505,7 @@ TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterNewRemoteToLocalSwap) |
| RemoteToLocalSwapWebFrameClient client(remoteFrame); |
| WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document, &client); |
| - localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None); |
| + localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None, WebFrameOwnerProperties()); |
| FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
| EXPECT_EQ(WebInitialCommitInChildFrame, client.historyCommitType()); |
| @@ -7446,7 +7530,7 @@ TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterExistingRemoteToLocalSwap) |
| RemoteToLocalSwapWebFrameClient client(remoteFrame); |
| WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document, &client); |
| - localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None); |
| + localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags::None, WebFrameOwnerProperties()); |
| localFrame->setCommittedFirstRealLoad(); |
| FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
| EXPECT_EQ(WebStandardCommit, client.historyCommitType()); |
| @@ -7584,7 +7668,7 @@ TEST_F(WebFrameTest, NavigateRemoteToLocalWithOpener) |
| // Do a remote-to-local swap in the popup. |
| FrameTestHelpers::TestWebFrameClient popupLocalClient; |
| WebLocalFrame* popupLocalFrame = WebLocalFrame::create(WebTreeScopeType::Document, &popupLocalClient); |
| - popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSandboxFlags::None); |
| + popupLocalFrame->initializeToReplaceRemoteFrame(popupRemoteFrame, "", WebSandboxFlags::None, WebFrameOwnerProperties()); |
| popupRemoteFrame->swap(popupLocalFrame); |
| // The initial document created during the remote-to-local swap should have |
| @@ -7622,7 +7706,7 @@ TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) |
| // If an iframe has a remote main frame, ensure the inital commit is correctly identified as WebInitialCommitInChildFrame. |
| CommitTypeWebFrameClient childFrameClient; |
| - WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); |
| + WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameOwnerProperties()); |
| registerMockedHttpURLLoad("foo.html"); |
| FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); |
| EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType()); |
| @@ -7648,7 +7732,7 @@ TEST_P(ParameterizedWebFrameTest, FrameWidgetTest) |
| view->setMainFrame(remoteClient.frame()); |
| FrameTestHelpers::TestWebFrameClient childFrameClient; |
| - WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr); |
| + WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient, nullptr, WebFrameOwnerProperties()); |
| GestureEventTestWebViewClient childViewClient; |
| WebFrameWidget* widget = WebFrameWidget::create(&childViewClient, childFrame); |
| @@ -7868,10 +7952,10 @@ TEST_P(ParameterizedWebFrameTest, CreateLocalChildWithPreviousSibling) |
| view->setMainFrame(remoteClient.frame()); |
| WebRemoteFrame* parent = view->mainFrame()->toWebRemoteFrame(); |
| - WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, nullptr, nullptr); |
| - WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, nullptr, secondFrame); |
| - WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, nullptr, secondFrame); |
| - WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, nullptr, nullptr); |
| + WebLocalFrameScope secondFrame = parent->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties()); |
| + WebLocalFrameScope fourthFrame = parent->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerProperties()); |
| + WebLocalFrameScope thirdFrame = parent->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, nullptr, secondFrame, WebFrameOwnerProperties()); |
| + WebLocalFrameScope firstFrame = parent->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, nullptr, nullptr, WebFrameOwnerProperties()); |
| EXPECT_EQ(firstFrame, parent->firstChild()); |
| EXPECT_EQ(nullptr, firstFrame->previousSibling()); |
| @@ -7906,7 +7990,7 @@ TEST_P(ParameterizedWebFrameTest, SendBeaconFromChildWithRemoteMainFrame) |
| root->setReplicatedOrigin(SecurityOrigin::createUnique()); |
| FrameTestHelpers::TestWebFrameClient localFrameClient; |
| - WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &localFrameClient, nullptr); |
| + WebLocalFrame* localFrame = root->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &localFrameClient, nullptr, WebFrameOwnerProperties()); |
| // Finally, make sure an embedder triggered load in the local frame swapped |
| // back in works. |
| @@ -7928,12 +8012,12 @@ TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra |
| remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); |
| FrameTestHelpers::TestWebFrameClient localFrameClient; |
| - remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &localFrameClient, nullptr); |
| + remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &localFrameClient, nullptr, WebFrameOwnerProperties()); |
| // Do a remote-to-local swap of the top frame. |
| FrameTestHelpers::TestWebFrameClient localClient; |
| WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient); |
| - localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::None); |
| + localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::None, WebFrameOwnerProperties()); |
| remoteRoot->swap(localRoot); |
| // Load a page with a child frame in the new root to make sure this doesn't |