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 NamespaceReadOnlyExtensionTest : public XWalkExtensionsTestBase {
20 void SetUp() override {
21 XWalkExtensionService::SetExternalExtensionsPathForTesting(
22 GetExternalExtensionTestPath(FILE_PATH_LITERAL("multiple_extension")));
23 XWalkExtensionsTestBase::SetUp();
27 IN_PROC_BROWSER_TEST_F(NamespaceReadOnlyExtensionTest, NamespaceReadOnly) {
28 GURL url = GetExtensionsTestURL(base::FilePath(),
29 base::FilePath().AppendASCII(
30 "namespace_read_only.html"));
31 Runtime* runtime = CreateRuntime();
32 content::TitleWatcher title_watcher(runtime->web_contents(), kPassString);
33 title_watcher.AlsoWaitForTitle(kFailString);
35 xwalk_test_utils::NavigateToURL(runtime, url);
36 WaitForLoadStop(runtime->web_contents());
38 EXPECT_EQ(kPassString, title_watcher.WaitAndGetTitle());
41 IN_PROC_BROWSER_TEST_F(
42 NamespaceReadOnlyExtensionTest, NamespaceReadOnlyAfterEntryPointCalled) {
43 GURL url = GetExtensionsTestURL(base::FilePath(),
44 base::FilePath().AppendASCII("namespace_read_only_with_entrypoint.html"));
45 Runtime* runtime = CreateRuntime();
46 content::TitleWatcher title_watcher(runtime->web_contents(), kPassString);
47 title_watcher.AlsoWaitForTitle(kFailString);
49 xwalk_test_utils::NavigateToURL(runtime, url);
50 WaitForLoadStop(runtime->web_contents());
52 EXPECT_EQ(kPassString, title_watcher.WaitAndGetTitle());