mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Add a CefBrowser::ClearHistory() method for clearing back/forward browsing history (issue #352).
- Move RegisterDevToolsSchemeHandler() call to CefContext::Initialize() to fix assertion when using multi-threaded message loop on Windows. - Add new NavigationTest.History test. - Remove unused RequestTest.HistoryNav test. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@301 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
||||
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
@@ -295,140 +295,3 @@ TEST(RequestTest, SendRecv)
|
||||
ASSERT_TRUE(g_RequestSendRecvTestHandlerHandleBeforeBrowseCalled);
|
||||
ASSERT_TRUE(g_RequestSendRecvTestHandlerHandleBeforeResourceLoadCalled);
|
||||
}
|
||||
|
||||
// Enable this test if you have applied the patches for issue #42.
|
||||
#if 0
|
||||
|
||||
bool g_RequestHistoryNavTestDidLoadRequest;
|
||||
bool g_RequestHistoryNavTestDidReloadRequest;
|
||||
|
||||
class RequestHistoryNavTestHandler : public TestHandler
|
||||
{
|
||||
public:
|
||||
RequestHistoryNavTestHandler() : navigated_(false) {}
|
||||
|
||||
virtual void RunTest()
|
||||
{
|
||||
// Create the test request
|
||||
CreateRequest(request_);
|
||||
|
||||
// Add the resource that we will navigate to/from
|
||||
AddResource("http://tests/goto.html", "<html>To</html>", "text/html");
|
||||
|
||||
// Create the browser
|
||||
CreateBrowser(CefString());
|
||||
}
|
||||
|
||||
virtual RetVal HandleAfterCreated(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
TestHandler::HandleAfterCreated(browser);
|
||||
|
||||
// Load the test request
|
||||
browser->GetMainFrame()->LoadRequest(request_);
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
virtual RetVal HandleBeforeBrowse(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
NavType navType, bool isRedirect)
|
||||
{
|
||||
CefString url = request->GetURL();
|
||||
if(url == "http://tests/run.html")
|
||||
{
|
||||
// Verify that the request is the same
|
||||
VerifyRequestEqual(request_, request, true);
|
||||
}
|
||||
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
virtual RetVal HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefString& redirectUrl,
|
||||
CefRefPtr<CefStreamReader>& resourceStream,
|
||||
CefString& mimeType,
|
||||
int loadFlags)
|
||||
{
|
||||
CefString url = request->GetURL();
|
||||
if(url == "http://tests/run.html")
|
||||
{
|
||||
// Verify that the request is the same
|
||||
VerifyRequestEqual(request_, request, true);
|
||||
|
||||
if(!navigated_)
|
||||
{
|
||||
// Loading the request for the 1st time
|
||||
g_RequestHistoryNavTestDidLoadRequest = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Re-loading the request
|
||||
g_RequestHistoryNavTestDidReloadRequest = true;
|
||||
}
|
||||
|
||||
// Return dummy results
|
||||
std::string output = "<html>Request</html>";
|
||||
resourceStream = CefStreamReader::CreateForData((void*)output.c_str(),
|
||||
output.length());
|
||||
mimeType = "text/html";
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pass to the default handler to return the to/from page
|
||||
return TestHandler::HandleBeforeResourceLoad(browser, request,
|
||||
redirectUrl, resourceStream, mimeType, loadFlags);
|
||||
}
|
||||
}
|
||||
|
||||
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
int httpStatusCode)
|
||||
{
|
||||
if(!browser->IsPopup() && frame->IsMain())
|
||||
{
|
||||
CefString url = browser->GetMainFrame()->GetURL();
|
||||
if(url == "http://tests/run.html")
|
||||
{
|
||||
if(!navigated_)
|
||||
{
|
||||
// First resource load, go to the next page
|
||||
navigated_ = true;
|
||||
browser->GetMainFrame()->LoadURL("http://tests/goto.html");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Resource re-load, end the test
|
||||
DestroyTest();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// To/from page load, go back the the request page
|
||||
browser->GoBack();
|
||||
}
|
||||
}
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequest> request_;
|
||||
bool navigated_;
|
||||
};
|
||||
|
||||
// Verify history navigation
|
||||
// This test will only pass if the patches for issue #42 are applied.
|
||||
TEST(RequestTest, HistoryNav)
|
||||
{
|
||||
g_RequestHistoryNavTestDidLoadRequest = false;
|
||||
g_RequestHistoryNavTestDidReloadRequest = false;
|
||||
|
||||
CefRefPtr<RequestHistoryNavTestHandler> handler =
|
||||
new RequestHistoryNavTestHandler();
|
||||
handler->ExecuteTest();
|
||||
|
||||
ASSERT_TRUE(g_RequestHistoryNavTestDidLoadRequest);
|
||||
ASSERT_TRUE(g_RequestHistoryNavTestDidReloadRequest);
|
||||
}
|
||||
|
||||
#endif // 0
|
||||
|
Reference in New Issue
Block a user