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/native_library.h"
6 #include "base/path_service.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "xwalk/extensions/browser/xwalk_extension_service.h"
9 #include "xwalk/extensions/test/xwalk_extensions_test_base.h"
10 #include "xwalk/runtime/browser/runtime.h"
11 #include "xwalk/test/base/xwalk_test_utils.h"
12 #include "content/public/test/browser_test_utils.h"
13 #include "content/public/test/test_utils.h"
16 using xwalk::extensions::XWalkExtensionService;
18 class BadExtensionTest : public XWalkExtensionsTestBase {
20 void SetUp() override {
21 XWalkExtensionService::SetExternalExtensionsPathForTesting(
22 GetExternalExtensionTestPath(FILE_PATH_LITERAL("bad_extension")));
23 XWalkExtensionsTestBase::SetUp();
27 IN_PROC_BROWSER_TEST_F(BadExtensionTest, DoNotCrash) {
28 LOG(WARNING) << "This test will produce a lot warnings which are expected."
29 << " The goal is to not crash.";
30 GURL url = GetExtensionsTestURL(base::FilePath(),
31 base::FilePath().AppendASCII("bad.html"));
32 Runtime* runtime = CreateRuntime();
33 content::TitleWatcher title_watcher(runtime->web_contents(), kPassString);
34 title_watcher.AlsoWaitForTitle(kFailString);
35 xwalk_test_utils::NavigateToURL(runtime, url);
36 EXPECT_EQ(kPassString, title_watcher.WaitAndGetTitle());
39 IN_PROC_BROWSER_TEST_F(BadExtensionTest, NavigateDoNotCrash) {
40 LOG(WARNING) << "This test will produce a lot warnings which are expected."
41 << " The goal is to not crash.";
42 GURL url = GetExtensionsTestURL(base::FilePath(),
43 base::FilePath().AppendASCII("bad.html"));
44 Runtime* runtime = CreateRuntime();
45 content::TitleWatcher title_watcher(runtime->web_contents(), kPassString);
46 title_watcher.AlsoWaitForTitle(kFailString);
48 for (int i = 0; i < 5; i++) {
49 xwalk_test_utils::NavigateToURL(runtime, url);
50 WaitForLoadStop(runtime->web_contents());
51 EXPECT_EQ(kPassString, title_watcher.WaitAndGetTitle());