[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | c80b8ee | 2011-12-03 04:26:52 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Contains holistic tests of the bindings infrastructure |
| 6 | |
| 7 | #include "chrome/browser/extensions/extension_apitest.h" |
| 8 | |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 9 | #include "chrome/browser/extensions/extension_host.h" |
| 10 | #include "chrome/browser/extensions/extension_process_manager.h" |
[email protected] | be93bba0 | 2012-10-24 16:44:03 | [diff] [blame] | 11 | #include "chrome/browser/extensions/extension_system.h" |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 12 | #include "chrome/browser/ui/browser.h" |
| 13 | #include "chrome/test/base/ui_test_utils.h" |
[email protected] | 7d478cb | 2012-07-24 17:19:42 | [diff] [blame] | 14 | #include "content/public/test/browser_test_utils.h" |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 15 | |
[email protected] | c80b8ee | 2011-12-03 04:26:52 | [diff] [blame] | 16 | IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ExceptionInHandlerShouldNotCrash) { |
| 17 | ASSERT_TRUE(RunExtensionSubtest( |
| 18 | "bindings/exception_in_handler_should_not_crash", |
| 19 | "page.html")) << message_; |
| 20 | } |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 21 | |
| 22 | // Tests that an error raised during an async function still fires |
[email protected] | 754ea8b7 | 2013-01-08 15:10:31 | [diff] [blame] | 23 | // the callback, but sets chrome.runtime.lastError. |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 24 | IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, LastError) { |
| 25 | ASSERT_TRUE(LoadExtension( |
| 26 | test_data_dir_.AppendASCII("browsertest").AppendASCII("last_error"))); |
| 27 | |
| 28 | // Get the ExtensionHost that is hosting our background page. |
| 29 | ExtensionProcessManager* manager = |
[email protected] | be93bba0 | 2012-10-24 16:44:03 | [diff] [blame] | 30 | extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); |
[email protected] | 3a1dc57 | 2012-07-31 22:25:13 | [diff] [blame] | 31 | extensions::ExtensionHost* host = FindHostWithPath(manager, "/bg.html", 1); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 32 | |
| 33 | bool result = false; |
[email protected] | b6987e0 | 2013-01-04 18:30:43 | [diff] [blame] | 34 | ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 35 | host->render_view_host(), "testLastError()", &result)); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 36 | EXPECT_TRUE(result); |
| 37 | } |
[email protected] | 52eafbd | 2013-04-03 04:43:19 | [diff] [blame^] | 38 | |
| 39 | IN_PROC_BROWSER_TEST_F(ExtensionApiTest, InternalAPIsNotOnChromeObject) { |
| 40 | ASSERT_TRUE(RunExtensionSubtest( |
| 41 | "bindings/internal_apis_not_on_chrome_object", |
| 42 | "page.html")) << message_; |
| 43 | } |