Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / xwalk / extensions / test / crash_extension_process.cc
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.
4
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"
14
15 using xwalk::extensions::XWalkExtensionService;
16 using xwalk::Runtime;
17
18 class CrashExtensionTest : public XWalkExtensionsTestBase {
19  public:
20   void SetUp() override {
21     XWalkExtensionService::SetExternalExtensionsPathForTesting(
22         GetExternalExtensionTestPath(FILE_PATH_LITERAL("crash_extension")));
23     XWalkExtensionsTestBase::SetUp();
24   }
25 };
26
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.";
32     return;
33   }
34
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);
39
40   xwalk_test_utils::NavigateToURL(runtime, url);
41   WaitForLoadStop(runtime->web_contents());
42
43   EXPECT_EQ(kPassString, title_watcher.WaitAndGetTitle());
44 }