Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / alert_apitest.cc
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
3 // found in the LICENSE file.
4
5 #include "base/strings/utf_string_conversions.h"
6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/test/base/ui_test_utils.h"
10 #include "components/app_modal_dialogs/app_modal_dialog.h"
11 #include "content/public/browser/render_frame_host.h"
12 #include "extensions/browser/extension_host.h"
13 #include "extensions/browser/process_manager.h"
14 #include "extensions/common/extension.h"
15
16 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, AlertBasic) {
17   ASSERT_TRUE(RunExtensionTest("alert")) << message_;
18
19   const extensions::Extension* extension = GetSingleLoadedExtension();
20   extensions::ExtensionHost* host =
21       extensions::ProcessManager::Get(browser()->profile())
22           ->GetBackgroundHostForExtension(extension->id());
23   ASSERT_TRUE(host);
24   host->host_contents()->GetMainFrame()->ExecuteJavaScript(
25       base::ASCIIToUTF16("alert('This should not crash.');"));
26
27   AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
28   ASSERT_TRUE(alert);
29   alert->CloseModalDialog();
30 }