[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" | ||||
11 | #include "chrome/browser/ui/browser.h" | ||||
12 | #include "chrome/test/base/ui_test_utils.h" | ||||
[email protected] | 7d478cb | 2012-07-24 17:19:42 | [diff] [blame] | 13 | #include "content/public/test/browser_test_utils.h" |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 14 | |
[email protected] | c80b8ee | 2011-12-03 04:26:52 | [diff] [blame] | 15 | IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ExceptionInHandlerShouldNotCrash) { |
16 | ASSERT_TRUE(RunExtensionSubtest( | ||||
17 | "bindings/exception_in_handler_should_not_crash", | ||||
18 | "page.html")) << message_; | ||||
19 | } | ||||
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 20 | |
21 | // Tests that an error raised during an async function still fires | ||||
22 | // the callback, but sets chrome.extension.lastError. | ||||
23 | IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, LastError) { | ||||
24 | ASSERT_TRUE(LoadExtension( | ||||
25 | test_data_dir_.AppendASCII("browsertest").AppendASCII("last_error"))); | ||||
26 | |||||
27 | // Get the ExtensionHost that is hosting our background page. | ||||
28 | ExtensionProcessManager* manager = | ||||
29 | browser()->profile()->GetExtensionProcessManager(); | ||||
[email protected] | 3a1dc57 | 2012-07-31 22:25:13 | [diff] [blame^] | 30 | extensions::ExtensionHost* host = FindHostWithPath(manager, "/bg.html", 1); |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 31 | |
32 | bool result = false; | ||||
[email protected] | 7d478cb | 2012-07-24 17:19:42 | [diff] [blame] | 33 | ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 34 | host->render_view_host(), L"", L"testLastError()", &result)); |
35 | EXPECT_TRUE(result); | ||||
36 | } |