| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Contains holistic tests of the bindings infrastructure | 5 // Contains holistic tests of the bindings infrastructure |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
| 10 #include "chrome/browser/extensions/extension_process_manager.h" | 10 #include "chrome/browser/extensions/extension_process_manager.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/test/base/ui_test_utils.h" | 12 #include "chrome/test/base/ui_test_utils.h" |
| 13 #include "content/public/test/browser_test_utils.h" |
| 13 | 14 |
| 14 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ExceptionInHandlerShouldNotCrash) { | 15 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ExceptionInHandlerShouldNotCrash) { |
| 15 ASSERT_TRUE(RunExtensionSubtest( | 16 ASSERT_TRUE(RunExtensionSubtest( |
| 16 "bindings/exception_in_handler_should_not_crash", | 17 "bindings/exception_in_handler_should_not_crash", |
| 17 "page.html")) << message_; | 18 "page.html")) << message_; |
| 18 } | 19 } |
| 19 | 20 |
| 20 // Tests that an error raised during an async function still fires | 21 // Tests that an error raised during an async function still fires |
| 21 // the callback, but sets chrome.extension.lastError. | 22 // the callback, but sets chrome.extension.lastError. |
| 22 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, LastError) { | 23 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, LastError) { |
| 23 ASSERT_TRUE(LoadExtension( | 24 ASSERT_TRUE(LoadExtension( |
| 24 test_data_dir_.AppendASCII("browsertest").AppendASCII("last_error"))); | 25 test_data_dir_.AppendASCII("browsertest").AppendASCII("last_error"))); |
| 25 | 26 |
| 26 // Get the ExtensionHost that is hosting our background page. | 27 // Get the ExtensionHost that is hosting our background page. |
| 27 ExtensionProcessManager* manager = | 28 ExtensionProcessManager* manager = |
| 28 browser()->profile()->GetExtensionProcessManager(); | 29 browser()->profile()->GetExtensionProcessManager(); |
| 29 ExtensionHost* host = FindHostWithPath(manager, "/bg.html", 1); | 30 ExtensionHost* host = FindHostWithPath(manager, "/bg.html", 1); |
| 30 | 31 |
| 31 bool result = false; | 32 bool result = false; |
| 32 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 33 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 33 host->render_view_host(), L"", L"testLastError()", &result)); | 34 host->render_view_host(), L"", L"testLastError()", &result)); |
| 34 EXPECT_TRUE(result); | 35 EXPECT_TRUE(result); |
| 35 } | 36 } |
| OLD | NEW |