blob: 3463d36a9daf6e5bb7bce827e498b499a7baf9cb [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"
11#include "chrome/browser/ui/browser.h"
12#include "chrome/test/base/ui_test_utils.h"
[email protected]7d478cb2012-07-24 17:19:4213#include "content/public/test/browser_test_utils.h"
[email protected]fad73672012-06-15 23:26:0614
[email protected]c80b8ee2011-12-03 04:26:5215IN_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]fad73672012-06-15 23:26:0620
21// Tests that an error raised during an async function still fires
22// the callback, but sets chrome.extension.lastError.
23IN_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]3a1dc572012-07-31 22:25:1330 extensions::ExtensionHost* host = FindHostWithPath(manager, "/bg.html", 1);
[email protected]fad73672012-06-15 23:26:0631
32 bool result = false;
[email protected]7d478cb2012-07-24 17:19:4233 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
[email protected]fad73672012-06-15 23:26:0634 host->render_view_host(), L"", L"testLastError()", &result));
35 EXPECT_TRUE(result);
36}