| Index: content/browser/webkit_browsertest.cc
|
| diff --git a/content/browser/webkit_browsertest.cc b/content/browser/webkit_browsertest.cc
|
| index 1d33755ac58879a1894a4ab6b3d3cd1f12517aeb..e6af3012fc6751fea6b6f8e681267355dd4d6fc0 100644
|
| --- a/content/browser/webkit_browsertest.cc
|
| +++ b/content/browser/webkit_browsertest.cc
|
| @@ -2,16 +2,75 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "base/path_service.h"
|
| +
|
| +#include "content/browser/loader/resource_dispatcher_host_impl.h"
|
| #include "content/browser/web_contents/web_contents_impl.h"
|
| +#include "content/public/browser/render_widget_host_view.h"
|
| +#include "content/public/browser/resource_dispatcher_host_delegate.h"
|
| #include "content/public/browser/web_contents.h"
|
| +#include "content/public/common/content_paths.h"
|
| +#include "content/public/test/browser_test_utils.h"
|
| #include "content/shell/browser/shell.h"
|
| #include "content/test/content_browser_test.h"
|
| #include "content/test/content_browser_test_utils.h"
|
| #include "content/test/net/url_request_abort_on_end_job.h"
|
|
|
| +#include "net/base/host_port_pair.h"
|
| +#include "net/base/net_util.h"
|
| +
|
| +#include "ui/gfx/size.h"
|
| +
|
| +
|
| namespace content {
|
|
|
| -typedef ContentBrowserTest WebKitBrowserTest;
|
| +class WebKitBrowserTestResourceDispatcherHostDelegate
|
| + : public content::ResourceDispatcherHostDelegate {
|
| + public:
|
| + WebKitBrowserTestResourceDispatcherHostDelegate()
|
| + : should_allow_request_(true) {}
|
| +
|
| + virtual bool ShouldBeginRequest(
|
| + int child_id,
|
| + int route_id,
|
| + const std::string& method,
|
| + const GURL& url,
|
| + ResourceType::Type,
|
| + ResourceContext*) OVERRIDE { return should_allow_request_; };
|
| +
|
| + void set_should_allow_request(bool allow) { should_allow_request_ = allow; }
|
| +
|
| + private:
|
| + bool should_allow_request_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WebKitBrowserTestResourceDispatcherHostDelegate);
|
| +};
|
| +
|
| +
|
| +class WebKitBrowserTest : public ContentBrowserTest {
|
| + public:
|
| + // ContentBrowserTest implementation:
|
| + virtual void SetUpOnMainThread() OVERRIDE {
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO, FROM_HERE,
|
| + base::Bind(
|
| + &WebKitBrowserTest::InjectResourceDisptcherHostDelegate,
|
| + base::Unretained(this)));
|
| + }
|
| +
|
| + void InjectResourceDisptcherHostDelegate() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + ResourceDispatcherHostImpl::Get()->SetDelegate(&dispatcher_delegate_);
|
| + }
|
| +
|
| + WebKitBrowserTestResourceDispatcherHostDelegate& dispatcher_delegate() {
|
| + return dispatcher_delegate_;
|
| + }
|
| +
|
| + private:
|
| + WebKitBrowserTestResourceDispatcherHostDelegate dispatcher_delegate_;
|
| +};
|
| +
|
|
|
| const char kAsyncScriptThatAbortsOnEndPage[] =
|
| "files/webkit/async_script_abort_on_end.html";
|
| @@ -76,4 +135,31 @@ IN_PROC_BROWSER_TEST_F(WebKitBrowserTest, PrerenderNoCrash) {
|
| EXPECT_FALSE(shell()->web_contents()->IsCrashed());
|
| }
|
|
|
| +// This is a browser test because of how intertwined WebCore::DocumentLoader is
|
| +// to other parts of Blink. Essentially, it's written to reproduce issue 34977,
|
| +// performing the same steps taken in the bug report.
|
| +const char kDocumentLoaderNoCrashPage[] =
|
| + "bad-ssl.mht";
|
| +IN_PROC_BROWSER_TEST_F(WebKitBrowserTest, DocumentLoaderNoCrash) {
|
| + base::FilePath content_test_data_dir;
|
| + ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &content_test_data_dir));
|
| + GURL test_url = net::FilePathToFileURL(
|
| + content_test_data_dir.AppendASCII(kDocumentLoaderNoCrashPage));
|
| + NavigateToURL(shell(), test_url);
|
| +
|
| + RenderWidgetHostView* rwhv =
|
| + shell()->web_contents()->GetRenderWidgetHostView();
|
| + ASSERT_TRUE(rwhv);
|
| +
|
| + dispatcher_delegate().set_should_allow_request(false);
|
| + NavigateToURL(shell(), GURL("http://www.ulv.no"));
|
| +
|
| + rwhv->SetSize(gfx::Size(200, 200));
|
| +
|
| + // Just something synchronous, allowing WebContents::crashed_status_ to sync
|
| + NavigateToURL(shell(), GURL("http://www.sau.no"));
|
| +
|
| + EXPECT_FALSE(shell()->web_contents()->IsCrashed());
|
| +}
|
| +
|
| } // namespace content
|
|
|