#include "WebTextCheckingResult.h"
#include "WebViewClient.h"
#include "WebViewImpl.h"
-#include "core/dom/Clipboard.h"
+#include "core/clipboard/Clipboard.h"
#include "core/dom/DocumentMarkerController.h"
-#include "core/events/MouseEvent.h"
#include "core/dom/Range.h"
#include "core/editing/Editor.h"
#include "core/editing/FrameSelection.h"
#include "core/editing/SpellChecker.h"
#include "core/editing/VisiblePosition.h"
+#include "core/events/MouseEvent.h"
#include "core/html/HTMLFormElement.h"
#include "core/loader/FrameLoadRequest.h"
#include "core/page/EventHandler.h"
void executeScript(const WebString& code)
{
m_frame->executeScript(WebScriptSource(code));
+ m_frame->view()->layout();
runPendingTasks();
}
std::vector<WebString> selectors;
selectors.push_back(WebString::fromUTF8("div.initial_on"));
m_frame->document().watchCSSSelectors(WebVector<WebString>(selectors));
+ m_frame->view()->layout();
runPendingTasks();
EXPECT_EQ(1, updateCount());
EXPECT_THAT(matchedSelectors(), testing::ElementsAre("div.initial_on"));
// Check that adding a watched selector calls back for already-present nodes.
selectors.push_back(WebString::fromUTF8("div.initial_off"));
doc().watchCSSSelectors(WebVector<WebString>(selectors));
+ m_frame->view()->layout();
runPendingTasks();
EXPECT_EQ(2, updateCount());
EXPECT_THAT(matchedSelectors(), testing::ElementsAre("div.initial_off", "div.initial_on"));
// Check that we can turn off callbacks for certain selectors.
doc().watchCSSSelectors(WebVector<WebString>());
+ m_frame->view()->layout();
runPendingTasks();
EXPECT_EQ(3, updateCount());
EXPECT_THAT(matchedSelectors(), testing::ElementsAre());
std::vector<WebString> selectors;
selectors.push_back(WebString::fromUTF8("span"));
doc().watchCSSSelectors(WebVector<WebString>(selectors));
+ m_frame->view()->layout();
runPendingTasks();
EXPECT_EQ(1, updateCount());
selectors.push_back(WebString::fromUTF8("span"));
selectors.push_back(WebString::fromUTF8("span,p"));
doc().watchCSSSelectors(WebVector<WebString>(selectors));
-
+ m_frame->view()->layout();
runPendingTasks();
+
EXPECT_EQ(1, updateCount());
EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span", "span, p"));
}
selectors.push_back(WebString::fromUTF8("[")); // Invalid.
selectors.push_back(WebString::fromUTF8("p span")); // Not compound.
doc().watchCSSSelectors(WebVector<WebString>(selectors));
-
+ m_frame->view()->layout();
runPendingTasks();
+
EXPECT_EQ(1, updateCount());
EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span"))
<< "An invalid selector shouldn't prevent other selectors from matching.";
EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width());
}
+TEST_F(WebFrameTest, ZeroHeightPositiveWidthNotIgnored)
+{
+ UseMockScrollbarSettings mockScrollbarSettings;
+
+ FixedLayoutTestWebViewClient client;
+ client.m_screenInfo.deviceScaleFactor = 1;
+ int viewportWidth = 1280;
+ int viewportHeight = 0;
+
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ webViewHelper.initialize(true, 0, &client, enableViewportSettings);
+ webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
+
+ EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width());
+ EXPECT_EQ(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height());
+}
+
TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag)
{
UseMockScrollbarSettings mockScrollbarSettings;
WebDataSource* dataSource = webViewHelper.webView()->mainFrame()->dataSource();
ASSERT_TRUE(dataSource);
- EXPECT_EQ(toKURL("about:blank"), toKURL(dataSource->request().url().spec()));
+ EXPECT_EQ(toKURL(m_baseURL + "fixed_layout.html"), toKURL(dataSource->request().url().spec()));
}
TEST_F(WebFrameTest, AppendRedirects)
};
// This fails on Mac https://bugs.webkit.org/show_bug.cgi?id=108574
-#if OS(MACOSX)
+// Also failing on Android: http://crbug.com/341314
+#if OS(MACOSX) || OS(ANDROID)
TEST_F(WebFrameTest, DISABLED_FindInPageMatchRects)
#else
TEST_F(WebFrameTest, FindInPageMatchRects)
EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->request().cachePolicy());
}
+TEST_F(WebFrameTest, BackDuringChildFrameReload)
+{
+ registerMockedHttpURLLoad("page_with_blank_iframe.html");
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", true);
+ WebFrame* mainFrame = webViewHelper.webView()->mainFrame();
+ WebFrame* childFrame = mainFrame->firstChild();
+ ASSERT_TRUE(childFrame);
+
+ // Start a history navigation, then have a different frame commit a navigation.
+ // In this case, reload an about:blank frame, which will commit synchronously.
+ // After the history navigation completes, both the appropriate document url and
+ // the current history item should reflect the history navigation.
+ registerMockedHttpURLLoad("white-1x1.png");
+ WebHistoryItem item;
+ item.initialize();
+ WebURL historyURL(toKURL(m_baseURL + "white-1x1.png"));
+ item.setURLString(historyURL.string());
+ mainFrame->loadHistoryItem(item);
+
+ childFrame->reload();
+ Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ EXPECT_EQ(item.urlString(), mainFrame->document().url().string());
+ EXPECT_EQ(item.urlString(), mainFrame->currentHistoryItem().urlString());
+}
+
TEST_F(WebFrameTest, ReloadPost)
{
registerMockedHttpURLLoad("reload_post.html");
int willSendRequestCallCount() const { return m_willSendRequestCallCount; }
int childFrameCreationCount() const { return m_childFrameCreationCount; }
- virtual WebFrame* createChildFrame(WebFrame*, const WebString&)
+ virtual WebFrame* createChildFrame(WebFrame* parent, const WebString&)
{
m_childFrameCreationCount++;
- return WebFrame::create(m_client);
+ WebFrame* frame = WebFrame::create(m_client);
+ parent->appendChild(frame);
+ return frame;
+ }
+
+ virtual void frameDetached(WebFrame* frame) OVERRIDE
+ {
+ if (frame->parent())
+ frame->parent()->removeChild(frame);
+ frame->close();
}
- virtual void willSendRequest(WebFrame* frame, unsigned, WebURLRequest& request, const WebURLResponse&)
+ virtual void willSendRequest(WebFrame* frame, unsigned, WebURLRequest& request, const WebURLResponse&) OVERRIDE
{
m_policy = request.cachePolicy();
m_willSendRequestCallCount++;
webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mainClient);
WebFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl();
- WebFrameImpl* childFrame = toWebFrameImpl(mainFrame->firstChild());
+ RefPtr<WebFrameImpl> childFrame = toWebFrameImpl(mainFrame->firstChild());
ASSERT_EQ(childFrame->client(), &childClient);
EXPECT_EQ(mainClient.childFrameCreationCount(), 1);
EXPECT_EQ(childClient.willSendRequestCallCount(), 1);
Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
// A new WebFrame should have been created, but the child WebFrameClient should be reused.
- ASSERT_FALSE(childFrame == toWebFrameImpl(mainFrame->firstChild()));
+ ASSERT_NE(childFrame, toWebFrameImpl(mainFrame->firstChild()));
ASSERT_EQ(toWebFrameImpl(mainFrame->firstChild())->client(), &childClient);
EXPECT_EQ(mainClient.childFrameCreationCount(), 2);
WebFrame* childFrame = webViewHelper.webViewImpl()->mainFrameImpl()->firstChild();
WebHistoryItem item = childFrame->currentHistoryItem();
- EXPECT_EQ(item.urlString(), WebString::fromUTF8(m_baseURL + "iframe_reload.html"));
+ EXPECT_EQ(item.urlString().utf8(), m_baseURL + "iframe_reload.html");
}
class TestSameDocumentWebFrameClient : public WebFrameClient {
EXPECT_EQ(1, client.callCount());
}
+TEST_F(WebFrameTest, fixedPositionInFixedViewport)
+{
+ UseMockScrollbarSettings mockScrollbarSettings;
+ registerMockedHttpURLLoad("fixed-position-in-fixed-viewport.html");
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ webViewHelper.initializeAndLoad(m_baseURL + "fixed-position-in-fixed-viewport.html", true, 0, 0, enableViewportSettings);
+
+ WebView* webView = webViewHelper.webView();
+ webView->resize(WebSize(100, 100));
+ webView->layout();
+
+ Document* document = toWebFrameImpl(webView->mainFrame())->frame()->document();
+ Element* bottomFixed = document->getElementById("bottom-fixed");
+ Element* topBottomFixed = document->getElementById("top-bottom-fixed");
+ Element* rightFixed = document->getElementById("right-fixed");
+ Element* leftRightFixed = document->getElementById("left-right-fixed");
+
+ webView->resize(WebSize(100, 200));
+ webView->layout();
+ EXPECT_EQ(200, bottomFixed->offsetTop() + bottomFixed->offsetHeight());
+ EXPECT_EQ(200, topBottomFixed->offsetHeight());
+
+ webView->settings()->setMainFrameResizesAreOrientationChanges(false);
+ webView->resize(WebSize(200, 200));
+ webView->layout();
+ EXPECT_EQ(200, rightFixed->offsetLeft() + rightFixed->offsetWidth());
+ EXPECT_EQ(200, leftRightFixed->offsetWidth());
+
+ webView->settings()->setMainFrameResizesAreOrientationChanges(true);
+ // Will scale the page by 1.5.
+ webView->resize(WebSize(300, 330));
+ webView->layout();
+ EXPECT_EQ(220, bottomFixed->offsetTop() + bottomFixed->offsetHeight());
+ EXPECT_EQ(220, topBottomFixed->offsetHeight());
+ EXPECT_EQ(200, rightFixed->offsetLeft() + rightFixed->offsetWidth());
+ EXPECT_EQ(200, leftRightFixed->offsetWidth());
+}
+
+TEST_F(WebFrameTest, FrameViewSetFrameRect)
+{
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ webViewHelper.initializeAndLoad("about:blank");
+
+ WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameView();
+ frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200));
+ EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), frameView->frameRect());
+ frameView->setFrameRect(WebCore::IntRect(100, 100, 200, 200));
+ EXPECT_EQ_RECT(WebCore::IntRect(100, 100, 200, 200), frameView->frameRect());
+}
+
} // namespace