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

Unified Diff: Source/web/tests/WebFrameTest.cpp

Issue 271793007: Fix webkit_unit_tests to use the threaded parser and enable everywhere. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add loadHistoryItem wrapper Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/web/tests/WebFrameTest.cpp
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index ccbe015cf3c76e75956f97e136536b61717cd04c..4d4473ef76772ec5ff154a112d44b6b8664c9adf 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -294,13 +294,7 @@ TEST_F(WebFrameTest, LocationSetHostWithMissingPort)
// Setting host to "hostname:" should be treated as "hostname:0".
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascript:location.host = 'www.test.com:'; void 0;");
- runPendingTasks();
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
-
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascript:document.body.textContent = location.href; void 0;");
- // Required to see any updates in contentAsText.
- runPendingTasks();
- webViewHelper.webView()->layout();
std::string content = webViewHelper.webView()->mainFrame()->contentAsText(1024).utf8();
EXPECT_EQ("http://www.test.com:0/" + fileName, content);
@@ -319,13 +313,7 @@ TEST_F(WebFrameTest, LocationSetEmptyPort)
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascript:location.port = ''; void 0;");
- runPendingTasks();
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
-
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascript:document.body.textContent = location.href; void 0;");
- // Required to see any updates in contentAsText.
- runPendingTasks();
- webViewHelper.webView()->layout();
std::string content = webViewHelper.webView()->mainFrame()->contentAsText(1024).utf8();
EXPECT_EQ("http://www.test.com:0/" + fileName, content);
@@ -384,10 +372,9 @@ protected:
return m_client.m_matchedSelectors[m_frame];
}
- void loadHTML(const WebData& html)
+ void loadHTML(const std::string& html)
{
- m_frame->loadHTMLString(html, toKURL("about:blank"));
- runPendingTasks();
+ FrameTestHelpers::loadHTMLString(m_frame, html, toKURL("about:blank"));
}
void executeScript(const WebString& code)
@@ -1384,7 +1371,6 @@ TEST_F(WebFrameTest, WideViewportAndWideContentWithInitialScale)
webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "wide_document_width_viewport.html");
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
int wideDocumentWidth = 800;
@@ -1411,7 +1397,6 @@ TEST_F(WebFrameTest, WideViewportQuirkClobbersHeight)
webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport-height-1000.html");
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
EXPECT_EQ(800, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height());
@@ -1436,7 +1421,6 @@ TEST_F(WebFrameTest, LayoutSize320Quirk)
webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport/viewport-30.html");
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
EXPECT_EQ(600, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width());
@@ -1487,7 +1471,6 @@ TEST_F(WebFrameTest, ZeroValuesQuirk)
webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
webViewHelper.webView()->settings()->setViewportMetaLayoutSizeQuirk(true);
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport-zero-values.html");
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width());
@@ -1511,7 +1494,6 @@ TEST_F(WebFrameTest, OverflowHiddenDisablesScrolling)
FrameTestHelpers::WebViewHelper webViewHelper;
webViewHelper.initialize(true, 0, &client);
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "body-overflow-hidden.html");
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView();
@@ -1531,7 +1513,6 @@ TEST_F(WebFrameTest, IgnoreOverflowHiddenQuirk)
webViewHelper.initialize(true, 0, &client);
webViewHelper.webView()->settings()->setIgnoreMainFrameOverflowHiddenQuirk(true);
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "body-overflow-hidden.html");
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView();
@@ -1554,7 +1535,6 @@ TEST_F(WebFrameTest, NonZeroValuesNoQuirk)
webViewHelper.webView()->settings()->setViewportMetaZeroValuesQuirk(true);
webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "viewport-nonzero-values.html");
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
EXPECT_EQ(viewportWidth / expectedPageScaleFactor, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width());
@@ -1621,7 +1601,6 @@ TEST_F(WebFrameTest, setPageScaleFactorBeforeFrameHasView)
webViewHelper.webView()->setPageScaleFactor(pageScaleFactor);
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "fixed_layout.html");
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView();
EXPECT_EQ(pageScaleFactor, view->visibleContentScaleFactor());
}
@@ -2199,8 +2178,6 @@ TEST_F(WebFrameTest, updateOverlayScrollbarLayers)
webViewHelper.webView()->resize(WebSize(viewWidth, viewHeight));
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "large-div.html");
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
- webViewHelper.webView()->layout();
WebCore::FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView();
EXPECT_TRUE(view->renderView()->compositor()->layerForHorizontalScrollbar());
@@ -2682,11 +2659,28 @@ TEST_F(WebFrameTest, ReloadDoesntSetRedirect)
webViewHelper.initializeAndLoad(m_baseURL + "form.html", false, &webFrameClient);
webViewHelper.webView()->mainFrame()->reload(true);
- // start reload before request is delivered.
- webViewHelper.webView()->mainFrame()->reload(true);
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ // start another reload before request is delivered.
+ FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFrame());
}
+class ReloadWithOverrideURLTask : public WebThread::Task {
+public:
+ ReloadWithOverrideURLTask(WebFrame* frame, const WebCore::KURL& url, bool ignoreCache)
+ : m_frame(frame), m_url(url), m_ignoreCache(ignoreCache)
+ {
+ }
+
+ virtual void run() OVERRIDE
+ {
+ m_frame->reloadWithOverrideURL(m_url, m_ignoreCache);
+ }
+
+private:
+ WebFrame* const m_frame;
+ const WebCore::KURL m_url;
+ const bool m_ignoreCache;
+};
+
TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState)
{
const std::string firstURL = "find.html";
@@ -2710,14 +2704,16 @@ TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState)
float previousScale = webViewHelper.webViewImpl()->pageScaleFactor();
// Reload the page using the cache.
- webViewHelper.webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + secondURL), false);
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ Platform::current()->currentThread()->postTask(
+ new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->mainFrame(), toKURL(m_baseURL + secondURL), false));
+ FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->mainFrame());
ASSERT_EQ(previousOffset, webViewHelper.webViewImpl()->mainFrame()->scrollOffset());
ASSERT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor());
// Reload the page while ignoring the cache.
- webViewHelper.webViewImpl()->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + thirdURL), true);
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ Platform::current()->currentThread()->postTask(
+ new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->mainFrame(), toKURL(m_baseURL + thirdURL), true));
+ FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->mainFrame());
ASSERT_EQ(previousOffset, webViewHelper.webViewImpl()->mainFrame()->scrollOffset());
ASSERT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor());
}
@@ -2730,11 +2726,12 @@ TEST_F(WebFrameTest, ReloadWhileProvisional)
FrameTestHelpers::WebViewHelper webViewHelper;
webViewHelper.initialize();
- FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "fixed_layout.html");
+ WebURLRequest request;
+ request.initialize();
+ request.setURL(toKURL(m_baseURL + "fixed_layout.html"));
+ webViewHelper.webView()->mainFrame()->loadRequest(request);
// start reload before first request is delivered.
- webViewHelper.webView()->mainFrame()->reload(true);
-
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ FrameTestHelpers::reloadFrameIgnoringCache(webViewHelper.webView()->mainFrame());
WebDataSource* dataSource = webViewHelper.webView()->mainFrame()->dataSource();
ASSERT_TRUE(dataSource);
@@ -2767,7 +2764,8 @@ TEST_F(WebFrameTest, IframeRedirect)
FrameTestHelpers::WebViewHelper webViewHelper;
webViewHelper.initializeAndLoad(m_baseURL + "iframe_redirect.html", true);
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); // Load the iframe.
+ // Pump pending requests one more time. The test page loads script that navigates.
+ FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainFrame());
WebFrame* iframe = webViewHelper.webView()->findFrameByName(WebString::fromUTF8("ifr"));
ASSERT_TRUE(iframe);
@@ -2908,8 +2906,7 @@ TEST_F(WebFrameTest, ContextNotificationsReload)
webViewHelper.initializeAndLoad(m_baseURL + "context_notifications_test.html", true, &webFrameClient);
// Refresh, we should get two release notifications and two more create notifications.
- webViewHelper.webView()->mainFrame()->reload(false);
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame());
ASSERT_EQ(4u, webFrameClient.createNotifications.size());
ASSERT_EQ(2u, webFrameClient.releaseNotifications.size());
@@ -3047,8 +3044,7 @@ TEST_F(WebFrameTest, GetContentAsPlainText)
// Generate a simple test case.
const char simpleSource[] = "<div>Foo bar</div><div></div>baz";
WebCore::KURL testURL = toKURL("about:blank");
- frame->loadHTMLString(simpleSource, testURL);
- runPendingTasks();
+ FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL);
// Make sure it comes out OK.
const std::string expected("Foo bar\nbaz");
@@ -3062,14 +3058,12 @@ TEST_F(WebFrameTest, GetContentAsPlainText)
// Now do a new test with a subframe.
const char outerFrameSource[] = "Hello<iframe></iframe> world";
- frame->loadHTMLString(outerFrameSource, testURL);
- runPendingTasks();
+ FrameTestHelpers::loadHTMLString(frame, outerFrameSource, testURL);
// Load something into the subframe.
WebFrame* subframe = frame->firstChild();
ASSERT_TRUE(subframe);
- subframe->loadHTMLString("sub<p>text", testURL);
- runPendingTasks();
+ FrameTestHelpers::loadHTMLString(subframe, "sub<p>text", testURL);
text = frame->contentAsText(std::numeric_limits<size_t>::max());
EXPECT_EQ("Hello world\n\nsub\ntext", text.utf8());
@@ -3089,8 +3083,7 @@ TEST_F(WebFrameTest, GetFullHtmlOfPage)
// Generate a simple test case.
const char simpleSource[] = "<p>Hello</p><p>World</p>";
WebCore::KURL testURL = toKURL("about:blank");
- frame->loadHTMLString(simpleSource, testURL);
- runPendingTasks();
+ FrameTestHelpers::loadHTMLString(frame, simpleSource, testURL);
WebString text = frame->contentAsText(std::numeric_limits<size_t>::max());
EXPECT_EQ("Hello\n\nWorld", text.utf8());
@@ -3098,8 +3091,7 @@ TEST_F(WebFrameTest, GetFullHtmlOfPage)
const std::string html = frame->contentAsMarkup().utf8();
// Load again with the output html.
- frame->loadHTMLString(WebData(html.c_str(), html.length()), testURL);
- runPendingTasks();
+ FrameTestHelpers::loadHTMLString(frame, html, testURL);
EXPECT_EQ(html, frame->contentAsMarkup().utf8());
@@ -3132,8 +3124,7 @@ TEST_F(WebFrameTest, ExecuteScriptDuringDidCreateScriptContext)
FrameTestHelpers::WebViewHelper webViewHelper;
webViewHelper.initializeAndLoad(m_baseURL + "hello_world.html", true, &webFrameClient);
- webViewHelper.webView()->mainFrame()->reload();
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame());
}
class FindUpdateWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
@@ -4068,7 +4059,6 @@ public:
virtual void didFailProvisionalLoad(WebLocalFrame* frame, const WebURLError& error)
{
frame->loadHTMLString("This should appear", toKURL("data:text/html,chromewebdata"), error.unreachableURL, true);
- runPendingTasks();
}
virtual void didCommitProvisionalLoad(WebLocalFrame* frame, const WebHistoryItem&, WebHistoryCommitType)
@@ -4089,7 +4079,6 @@ TEST_F(WebFrameTest, ReplaceNavigationAfterHistoryNavigation)
FrameTestHelpers::WebViewHelper webViewHelper;
webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient);
- runPendingTasks();
WebFrame* frame = webViewHelper.webView()->mainFrame();
// Load a url as a history navigation that will return an error. TestSubstituteDataWebFrameClient
@@ -4109,8 +4098,7 @@ TEST_F(WebFrameTest, ReplaceNavigationAfterHistoryNavigation)
errorHistoryItem.initialize();
errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL.length()));
Platform::current()->unitTestSupport()->registerMockedErrorURL(URLTestHelpers::toKURL(errorURL), response, error);
- frame->loadHistoryItem(errorHistoryItem, WebHistoryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy);
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ FrameTestHelpers::loadHistoryItem(frame, errorHistoryItem, WebHistoryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy);
WebString text = frame->contentAsText(std::numeric_limits<size_t>::max());
EXPECT_EQ("This should appear", text.utf8());
@@ -4536,7 +4524,6 @@ TEST_F(WebFrameTest, DidAccessInitialDocumentViaJavascriptUrl)
// Access the initial document from a javascript: URL.
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascript:document.body.appendChild(document.createTextNode('Modified'))");
- runPendingTasks();
EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument);
}
@@ -4829,6 +4816,7 @@ TEST_F(WebFrameTest, ModifiedClickNewWindow)
frameRequest.setTriggeringEvent(event);
WebCore::UserGestureIndicator gesture(WebCore::DefinitelyProcessingUserGesture);
webViewHelper.webViewImpl()->page()->mainFrame()->loader().load(frameRequest);
+ FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainFrame());
// decidePolicyForNavigation should be called both for the original request and the ctrl+click.
EXPECT_EQ(2, webFrameClient.decidePolicyCallCount());
@@ -4846,15 +4834,12 @@ TEST_F(WebFrameTest, BackToReload)
registerMockedHttpURLLoad("white-1x1.png");
FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png");
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem());
- frame->loadHistoryItem(WebHistoryItem(firstItem.get()), WebHistoryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy);
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), WebHistoryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy);
EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem());
- frame->reload();
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ FrameTestHelpers::reloadFrame(frame);
EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->request().cachePolicy());
}
@@ -4879,8 +4864,7 @@ TEST_F(WebFrameTest, BackDuringChildFrameReload)
item.setURLString(historyURL.string());
mainFrame->loadHistoryItem(item, WebHistoryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy);
- childFrame->reload();
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ FrameTestHelpers::reloadFrame(childFrame);
EXPECT_EQ(item.urlString(), mainFrame->document().url().string());
EXPECT_EQ(item.urlString(), WebString(mainFrameLoader.currentItem()->urlString()));
}
@@ -4893,12 +4877,12 @@ TEST_F(WebFrameTest, ReloadPost)
WebFrame* frame = webViewHelper.webView()->mainFrame();
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascript:document.forms[0].submit()");
- runPendingTasks();
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ // Pump requests one more time after the javascript URL has executed to
+ // trigger the actual POST load request.
+ FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainFrame());
EXPECT_EQ(WebString::fromUTF8("POST"), frame->dataSource()->request().httpMethod());
- frame->reload();
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ FrameTestHelpers::reloadFrame(frame);
EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->request().cachePolicy());
EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationType());
}
@@ -4915,45 +4899,56 @@ TEST_F(WebFrameTest, LoadHistoryItemReload)
registerMockedHttpURLLoad("white-1x1.png");
FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png");
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem());
// Cache policy overrides should take.
- frame->loadHistoryItem(WebHistoryItem(firstItem), WebHistoryDifferentDocumentLoad, WebURLRequest::ReloadIgnoringCacheData);
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), WebHistoryDifferentDocumentLoad, WebURLRequest::ReloadIgnoringCacheData);
EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem());
EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->request().cachePolicy());
}
-class TestCachePolicyWebFrameClient : public WebFrameClient {
+class TestCachePolicyWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
public:
- TestCachePolicyWebFrameClient()
- : m_policy(WebURLRequest::UseProtocolCachePolicy)
- , m_client(0)
+ explicit TestCachePolicyWebFrameClient(TestCachePolicyWebFrameClient* parentClient)
+ : m_parentClient(parentClient)
+ , m_policy(WebURLRequest::UseProtocolCachePolicy)
+ , m_childClient(0)
, m_willSendRequestCallCount(0)
, m_childFrameCreationCount(0)
{
}
- void setChildWebFrameClient(WebFrameClient* client) { m_client = client; }
+ void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_childClient = client; }
WebURLRequest::CachePolicy cachePolicy() const { return m_policy; }
int willSendRequestCallCount() const { return m_willSendRequestCallCount; }
int childFrameCreationCount() const { return m_childFrameCreationCount; }
virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString&)
{
+ ASSERT(m_childClient);
m_childFrameCreationCount++;
- WebFrame* frame = WebLocalFrame::create(m_client);
+ WebFrame* frame = WebLocalFrame::create(m_childClient);
parent->appendChild(frame);
return frame;
}
- virtual void frameDetached(WebFrame* frame) OVERRIDE
+ virtual void didStartLoading(bool toDifferentDocument)
{
- if (frame->parent())
- frame->parent()->removeChild(frame);
- frame->close();
+ if (m_parentClient) {
+ m_parentClient->didStartLoading(toDifferentDocument);
+ return;
+ }
+ TestWebFrameClient::didStartLoading(toDifferentDocument);
+ }
+
+ virtual void didStopLoading()
+ {
+ if (m_parentClient) {
+ m_parentClient->didStopLoading();
+ return;
+ }
+ TestWebFrameClient::didStopLoading();
}
virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest& request, const WebURLResponse&) OVERRIDE
@@ -4963,8 +4958,10 @@ public:
}
private:
+ TestCachePolicyWebFrameClient* m_parentClient;
+
WebURLRequest::CachePolicy m_policy;
- WebFrameClient* m_client;
+ TestCachePolicyWebFrameClient* m_childClient;
int m_willSendRequestCallCount;
int m_childFrameCreationCount;
};
@@ -4973,8 +4970,8 @@ TEST_F(WebFrameTest, ReloadIframe)
{
registerMockedHttpURLLoad("iframe_reload.html");
registerMockedHttpURLLoad("visible_iframe.html");
- TestCachePolicyWebFrameClient mainClient;
- TestCachePolicyWebFrameClient childClient;
+ TestCachePolicyWebFrameClient mainClient(0);
+ TestCachePolicyWebFrameClient childClient(&mainClient);
mainClient.setChildWebFrameClient(&childClient);
FrameTestHelpers::WebViewHelper webViewHelper;
@@ -4987,8 +4984,7 @@ TEST_F(WebFrameTest, ReloadIframe)
EXPECT_EQ(childClient.willSendRequestCallCount(), 1);
EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::UseProtocolCachePolicy);
- mainFrame->reload(false);
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ FrameTestHelpers::reloadFrame(mainFrame);
// A new WebFrame should have been created, but the child WebFrameClient should be reused.
ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild()));
@@ -5028,7 +5024,7 @@ TEST_F(WebFrameTest, NavigateToSame)
WebCore::FrameLoadRequest frameRequest(0, WebCore::ResourceRequest(webViewHelper.webViewImpl()->page()->mainFrame()->document()->url()));
webViewHelper.webViewImpl()->page()->mainFrame()->loader().load(frameRequest);
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainFrame());
EXPECT_TRUE(client.frameLoadTypeSameSeen());
}
@@ -5043,8 +5039,7 @@ TEST_F(WebFrameTest, WebNodeImageContents)
// Load up the image and test that we can extract the contents.
WebCore::KURL testURL = toKURL("about:blank");
- frame->loadHTMLString(bluePNG, testURL);
- runPendingTasks();
+ FrameTestHelpers::loadHTMLString(frame, bluePNG, testURL);
WebNode node = frame->document().body().firstChild();
EXPECT_TRUE(node.isElementNode());
@@ -5060,7 +5055,7 @@ TEST_F(WebFrameTest, WebNodeImageContents)
// EXPECT_EQ(bitmap.getColor(0, 0), SK_ColorBLUE);
}
-class TestStartStopCallbackWebFrameClient : public WebFrameClient {
+class TestStartStopCallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
public:
TestStartStopCallbackWebFrameClient()
: m_startLoadingCount(0)
@@ -5071,6 +5066,7 @@ public:
virtual void didStartLoading(bool toDifferentDocument) OVERRIDE
{
+ TestWebFrameClient::didStartLoading(toDifferentDocument);
m_startLoadingCount++;
if (toDifferentDocument)
m_differentDocumentStartCount++;
@@ -5078,6 +5074,7 @@ public:
virtual void didStopLoading() OVERRIDE
{
+ TestWebFrameClient::didStopLoading();
m_stopLoadingCount++;
}
@@ -5097,14 +5094,13 @@ TEST_F(WebFrameTest, PushStateStartsAndStops)
TestStartStopCallbackWebFrameClient client;
FrameTestHelpers::WebViewHelper webViewHelper;
webViewHelper.initializeAndLoad(m_baseURL + "push_state.html", true, &client);
- runPendingTasks();
EXPECT_EQ(client.startLoadingCount(), 2);
EXPECT_EQ(client.stopLoadingCount(), 2);
EXPECT_EQ(client.differentDocumentStartCount(), 1);
}
-class TestHistoryWebFrameClient : public WebFrameClient {
+class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
public:
TestHistoryWebFrameClient()
{
@@ -5136,31 +5132,23 @@ TEST_F(WebFrameTest, DISABLED_FirstFrameNavigationReplacesHistory)
FrameTestHelpers::WebViewHelper webViewHelper;
TestHistoryWebFrameClient client;
webViewHelper.initializeAndLoad("about:blank", true, &client);
- runPendingTasks();
EXPECT_TRUE(client.replacesCurrentHistoryItem());
WebFrame* frame = webViewHelper.webView()->mainFrame();
FrameTestHelpers::loadFrame(frame,
"javascript:document.body.appendChild(document.createElement('iframe'))");
- // Need to call runPendingTasks in order for the JavaScript above to be
- // evaluated and executed.
- runPendingTasks();
WebFrame* iframe = frame->firstChild();
EXPECT_EQ(client.frame(), iframe);
EXPECT_TRUE(client.replacesCurrentHistoryItem());
FrameTestHelpers::loadFrame(frame,
"javascript:window.frames[0].location.assign('" + m_baseURL + "history.html')");
- runPendingTasks();
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
EXPECT_EQ(client.frame(), iframe);
EXPECT_TRUE(client.replacesCurrentHistoryItem());
FrameTestHelpers::loadFrame(frame,
"javascript:window.frames[0].location.assign('" + m_baseURL + "find.html')");
- runPendingTasks();
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
EXPECT_EQ(client.frame(), iframe);
EXPECT_FALSE(client.replacesCurrentHistoryItem());
@@ -5170,8 +5158,6 @@ TEST_F(WebFrameTest, DISABLED_FirstFrameNavigationReplacesHistory)
"javascript:var f = document.createElement('iframe'); "
"f.src = '" + m_baseURL + "history.html';"
"document.body.appendChild(f)");
- runPendingTasks();
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
iframe = frame->firstChild()->nextSibling();
EXPECT_EQ(client.frame(), iframe);
@@ -5179,8 +5165,6 @@ TEST_F(WebFrameTest, DISABLED_FirstFrameNavigationReplacesHistory)
FrameTestHelpers::loadFrame(frame,
"javascript:window.frames[1].location.assign('" + m_baseURL + "find.html')");
- runPendingTasks();
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
EXPECT_EQ(client.frame(), iframe);
EXPECT_FALSE(client.replacesCurrentHistoryItem());
}
@@ -5196,8 +5180,6 @@ TEST_F(WebFrameTest, overflowHiddenRewrite)
webViewHelper.webView()->resize(WebSize(100, 100));
FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "non-scrollable.html");
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
- webViewHelper.webView()->layout();
WebCore::RenderLayerCompositor* compositor = webViewHelper.webViewImpl()->compositor();
ASSERT_TRUE(compositor->scrollLayer());
@@ -5226,12 +5208,15 @@ TEST_F(WebFrameTest, CurrentHistoryItem)
webViewHelper.initialize();
WebFrame* frame = webViewHelper.webView()->mainFrame();
const WebCore::FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameImpl()->frame()->loader();
- FrameTestHelpers::loadFrame(frame, url);
+ WebURLRequest request;
+ request.initialize();
+ request.setURL(toKURL(url));
+ frame->loadRequest(request);
// Before commit, there is no history item.
EXPECT_FALSE(mainFrameLoader.currentItem());
- Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ FrameTestHelpers::pumpPendingRequestsDoNotUse(frame);
// After commit, there is.
WebCore::HistoryItem* item = mainFrameLoader.currentItem();
@@ -5239,7 +5224,7 @@ TEST_F(WebFrameTest, CurrentHistoryItem)
EXPECT_EQ(WTF::String(url.data()), item->urlString());
}
-class FailCreateChildFrame : public WebFrameClient {
+class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient {
public:
FailCreateChildFrame() : m_callCount(0) { }
@@ -5249,11 +5234,6 @@ public:
return 0;
}
- virtual void frameDetached(WebFrame* frame) OVERRIDE
- {
- frame->close();
- }
-
int callCount() const { return m_callCount; }
private:

Powered by Google App Engine
This is Rietveld 408576698