• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/extensions/extension_host.h"
8 #include "chrome/browser/extensions/extension_process_manager.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/test/ui_test_utils.h"
13 #include "content/browser/renderer_host/render_view_host.h"
14 
IN_PROC_BROWSER_TEST_F(ExtensionApiTest,AlertBasic)15 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, AlertBasic) {
16   ASSERT_TRUE(RunExtensionTest("alert")) << message_;
17 
18   const Extension* extension = GetSingleLoadedExtension();
19   ExtensionHost* host = browser()->profile()->GetExtensionProcessManager()->
20       GetBackgroundHostForExtension(extension);
21   ASSERT_TRUE(host);
22   host->render_view_host()->ExecuteJavascriptInWebFrame(string16(),
23       ASCIIToUTF16("alert('This should not crash.');"));
24 
25   AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
26   ASSERT_TRUE(alert);
27   alert->CloseModalDialog();
28 }
29