1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/native_library.h"
7 #include "base/path_service.h"
8 #include "xwalk/extensions/browser/xwalk_extension_service.h"
9 #include "xwalk/extensions/common/xwalk_extension_switches.h"
10 #include "xwalk/extensions/test/xwalk_extensions_test_base.h"
11 #include "xwalk/runtime/browser/runtime.h"
12 #include "xwalk/test/base/xwalk_test_utils.h"
13 #include "content/public/test/browser_test_utils.h"
15 using xwalk::extensions::XWalkExtensionService;
18 class CrashExtensionTest : public XWalkExtensionsTestBase {
20 void SetUp() override {
21 XWalkExtensionService::SetExternalExtensionsPathForTesting(
22 GetExternalExtensionTestPath(FILE_PATH_LITERAL("crash_extension")));
23 XWalkExtensionsTestBase::SetUp();
27 IN_PROC_BROWSER_TEST_F(CrashExtensionTest, CrashExtensionProcessKeepBPAlive) {
28 CommandLine* cmd_line = CommandLine::ForCurrentProcess();
29 if (cmd_line->HasSwitch(switches::kXWalkDisableExtensionProcess)) {
30 LOG(INFO) << "--disable-extension-process not supported by " \
31 "CrashExtensionProcessKeepBPAlive. Skipping test.";
35 GURL url = GetExtensionsTestURL(base::FilePath(),
36 base::FilePath().AppendASCII("crash.html"));
37 Runtime* runtime = CreateRuntime();
38 content::TitleWatcher title_watcher(runtime->web_contents(), kPassString);
40 xwalk_test_utils::NavigateToURL(runtime, url);
41 WaitForLoadStop(runtime->web_contents());
43 EXPECT_EQ(kPassString, title_watcher.WaitAndGetTitle());