Revert of Don't install OEM default apps for enterprise users (patchset #1 id:1 of...
[chromium-blink-merge.git] / chrome / browser / extensions / extension_bindings_apitest.cc
blobc78fb200044d9607adaf631df21881a5245f9fe8
1 // Copyright (c) 2012 The Chromium Authors. 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 // Contains holistic tests of the bindings infrastructure
7 #include "chrome/browser/extensions/api/permissions/permissions_api.h"
8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "content/public/test/browser_test_utils.h"
11 #include "extensions/browser/extension_host.h"
12 #include "extensions/browser/process_manager.h"
13 #include "extensions/test/extension_test_message_listener.h"
14 #include "extensions/test/result_catcher.h"
16 namespace extensions {
17 namespace {
19 class ExtensionBindingsApiTest : public ExtensionApiTest {};
21 IN_PROC_BROWSER_TEST_F(ExtensionBindingsApiTest,
22 UnavailableBindingsNeverRegistered) {
23 // Test will request the 'storage' permission.
24 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true);
25 ASSERT_TRUE(RunExtensionTest(
26 "bindings/unavailable_bindings_never_registered")) << message_;
29 IN_PROC_BROWSER_TEST_F(ExtensionBindingsApiTest,
30 ExceptionInHandlerShouldNotCrash) {
31 ASSERT_TRUE(RunExtensionSubtest(
32 "bindings/exception_in_handler_should_not_crash",
33 "page.html")) << message_;
36 // Tests that an error raised during an async function still fires
37 // the callback, but sets chrome.runtime.lastError.
38 // FIXME should be in ExtensionBindingsApiTest.
39 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, LastError) {
40 ASSERT_TRUE(LoadExtension(
41 test_data_dir_.AppendASCII("browsertest").AppendASCII("last_error")));
43 // Get the ExtensionHost that is hosting our background page.
44 extensions::ProcessManager* manager =
45 extensions::ProcessManager::Get(browser()->profile());
46 extensions::ExtensionHost* host = FindHostWithPath(manager, "/bg.html", 1);
48 bool result = false;
49 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
50 host->render_view_host(), "testLastError()", &result));
51 EXPECT_TRUE(result);
54 // Regression test that we don't delete our own bindings with about:blank
55 // iframes.
56 IN_PROC_BROWSER_TEST_F(ExtensionBindingsApiTest, AboutBlankIframe) {
57 ResultCatcher catcher;
58 ExtensionTestMessageListener listener("load", true);
60 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("bindings")
61 .AppendASCII("about_blank_iframe")));
63 ASSERT_TRUE(listener.WaitUntilSatisfied());
65 const Extension* extension = LoadExtension(
66 test_data_dir_.AppendASCII("bindings")
67 .AppendASCII("internal_apis_not_on_chrome_object"));
68 ASSERT_TRUE(extension);
69 listener.Reply(extension->id());
71 ASSERT_TRUE(catcher.GetNextResult()) << message_;
74 IN_PROC_BROWSER_TEST_F(ExtensionBindingsApiTest,
75 InternalAPIsNotOnChromeObject) {
76 ASSERT_TRUE(RunExtensionSubtest(
77 "bindings/internal_apis_not_on_chrome_object",
78 "page.html")) << message_;
81 // Tests that we don't override events when bindings are re-injected.
82 // Regression test for http://crbug.com/269149.
83 // Regression test for http://crbug.com/436593.
84 IN_PROC_BROWSER_TEST_F(ExtensionBindingsApiTest, EventOverriding) {
85 ASSERT_TRUE(RunExtensionTest("bindings/event_overriding")) << message_;
88 // Tests the effectiveness of the 'nocompile' feature file property.
89 // Regression test for http://crbug.com/356133.
90 IN_PROC_BROWSER_TEST_F(ExtensionBindingsApiTest, Nocompile) {
91 ASSERT_TRUE(RunExtensionSubtest("bindings/nocompile", "page.html"))
92 << message_;
95 IN_PROC_BROWSER_TEST_F(ExtensionBindingsApiTest, ApiEnums) {
96 ASSERT_TRUE(RunExtensionTest("bindings/api_enums")) << message_;
99 } // namespace
100 } // namespace extensions