blob: 487005439ea2aefc83e5e195dbfaf35f0a6820f6 [file] [log] [blame]
[email protected]fad73672012-06-15 23:26:061// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]c80b8ee2011-12-03 04:26:522// 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]fad73672012-06-15 23:26:069#include "chrome/browser/extensions/extension_host.h"
10#include "chrome/browser/extensions/extension_process_manager.h"
[email protected]be93bba02012-10-24 16:44:0311#include "chrome/browser/extensions/extension_system.h"
[email protected]fad73672012-06-15 23:26:0612#include "chrome/browser/ui/browser.h"
13#include "chrome/test/base/ui_test_utils.h"
[email protected]7d478cb2012-07-24 17:19:4214#include "content/public/test/browser_test_utils.h"
[email protected]fad73672012-06-15 23:26:0615
[email protected]c80b8ee2011-12-03 04:26:5216IN_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]fad73672012-06-15 23:26:0621
22// Tests that an error raised during an async function still fires
[email protected]754ea8b72013-01-08 15:10:3123// the callback, but sets chrome.runtime.lastError.
[email protected]fad73672012-06-15 23:26:0624IN_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]be93bba02012-10-24 16:44:0330 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
[email protected]3a1dc572012-07-31 22:25:1331 extensions::ExtensionHost* host = FindHostWithPath(manager, "/bg.html", 1);
[email protected]fad73672012-06-15 23:26:0632
33 bool result = false;
[email protected]b6987e02013-01-04 18:30:4334 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
35 host->render_view_host(), "testLastError()", &result));
[email protected]fad73672012-06-15 23:26:0636 EXPECT_TRUE(result);
37}