Commit c591a584 authored by Kevin Marshall's avatar Kevin Marshall Committed by Commit Bot

[fuchsia] Implement the Frame::Stop() method.

This method calls directly into WebContents::Stop(). Added a test case
for end-to-end verification of browser behavior.

Bug: 852145
Change-Id: Ia1301976542e3b4996579422b98e4d2ae41ea646
Reviewed-on: https://chromium-review.googlesource.com/1185737
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585320}
parent 7329f70b
......@@ -7,6 +7,7 @@
#include "base/macros.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -510,4 +511,53 @@ IN_PROC_BROWSER_TEST_F(ContextImplTest, DelayedNavigationEventAck) {
}
}
// Observes events specific to the Stop() test case.
struct WebContentsObserverForStop : public content::WebContentsObserver {
using content::WebContentsObserver::Observe;
MOCK_METHOD1(DidStartNavigation, void(content::NavigationHandle*));
MOCK_METHOD0(NavigationStopped, void());
};
IN_PROC_BROWSER_TEST_F(ContextImplTest, Stop) {
chromium::web::FramePtr frame = CreateFrame();
chromium::web::NavigationControllerPtr controller;
frame->GetNavigationController(controller.NewRequest());
net::test_server::RegisterDefaultHandlers(embedded_test_server());
ASSERT_TRUE(embedded_test_server()->Start());
// Use a request handler that will accept the connection and stall
// indefinitely.
GURL hung_url(embedded_test_server()->GetURL("/hung"));
WebContentsObserverForStop observer;
observer.Observe(
context_impl()->GetFrameImplForTest(&frame)->web_contents_.get());
{
base::RunLoop run_loop;
EXPECT_CALL(observer, DidStartNavigation(_))
.WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); }));
controller->LoadUrl(hung_url.spec(), nullptr);
run_loop.Run();
Mock::VerifyAndClearExpectations(this);
}
EXPECT_TRUE(
context_impl()->GetFrameImplForTest(&frame)->web_contents_->IsLoading());
{
base::RunLoop run_loop;
EXPECT_CALL(observer, NavigationStopped())
.WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); }));
controller->Stop();
run_loop.Run();
Mock::VerifyAndClearExpectations(this);
}
EXPECT_FALSE(
context_impl()->GetFrameImplForTest(&frame)->web_contents_->IsLoading());
}
} // namespace webrunner
......@@ -161,7 +161,7 @@ void FrameImpl::GoForward() {
}
void FrameImpl::Stop() {
NOTIMPLEMENTED();
web_contents_->Stop();
}
void FrameImpl::Reload(chromium::web::ReloadType type) {
......
......@@ -75,6 +75,7 @@ class FrameImpl : public chromium::web::Frame,
FRIEND_TEST_ALL_PREFIXES(ContextImplTest, NavigationObserverDisconnected);
FRIEND_TEST_ALL_PREFIXES(ContextImplTest, NoNavigationObserverAttached);
FRIEND_TEST_ALL_PREFIXES(ContextImplTest, ReloadFrame);
FRIEND_TEST_ALL_PREFIXES(ContextImplTest, Stop);
// Sends |pending_navigation_event_| to the observer if there are any changes
// to be reported.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment