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 #include "base/path_service.h" | 5 #include "base/path_service.h" |
6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "chrome/browser/devtools/devtools_window.h" | 7 #include "chrome/browser/devtools/devtools_window.h" |
8 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h" | 8 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/extensions/extension_function_test_utils.h" | 10 #include "chrome/browser/extensions/extension_function_test_utils.h" |
11 #include "chrome/browser/extensions/extension_tab_util.h" | |
11 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.h" |
13 #include "content/public/browser/render_frame_host.h" | |
12 #include "extensions/browser/app_window/app_window.h" | 14 #include "extensions/browser/app_window/app_window.h" |
13 #include "extensions/browser/app_window/app_window_registry.h" | 15 #include "extensions/browser/app_window/app_window_registry.h" |
14 | 16 |
15 namespace extensions { | 17 namespace extensions { |
16 | 18 |
17 using DeveloperPrivateApiTest = ExtensionApiTest; | 19 using DeveloperPrivateApiTest = ExtensionApiTest; |
18 | 20 |
19 IN_PROC_BROWSER_TEST_F(DeveloperPrivateApiTest, Basics) { | 21 IN_PROC_BROWSER_TEST_F(DeveloperPrivateApiTest, Basics) { |
20 // Load up some extensions so that we can query their info and adjust their | 22 // Load up some extensions so that we can query their info and adjust their |
21 // setings in the API test. | 23 // setings in the API test. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 browser(), extension_function_test_utils::NONE); | 76 browser(), extension_function_test_utils::NONE); |
75 | 77 |
76 // Verify that dev tools opened. | 78 // Verify that dev tools opened. |
77 std::list<AppWindow*> app_windows = | 79 std::list<AppWindow*> app_windows = |
78 AppWindowRegistry::Get(profile())->GetAppWindowsForApp(app->id()); | 80 AppWindowRegistry::Get(profile())->GetAppWindowsForApp(app->id()); |
79 ASSERT_EQ(1u, app_windows.size()); | 81 ASSERT_EQ(1u, app_windows.size()); |
80 EXPECT_TRUE(DevToolsWindow::GetInstanceForInspectedWebContents( | 82 EXPECT_TRUE(DevToolsWindow::GetInstanceForInspectedWebContents( |
81 (*app_windows.begin())->web_contents())); | 83 (*app_windows.begin())->web_contents())); |
82 } | 84 } |
83 | 85 |
86 IN_PROC_BROWSER_TEST_F(DeveloperPrivateApiTest, InspectEmbeddedOptionsPage) { | |
87 base::FilePath dir; | |
88 PathService::Get(chrome::DIR_TEST_DATA, &dir); | |
89 // Load an extension that only has an embedded options_ui page. | |
90 const Extension* extension = | |
91 LoadExtension(dir.AppendASCII("extensions/delayed_install/v1")); | |
Devlin
2015/12/01 00:58:20
nit: typically prefer .AppendASCII rather than pla
robwu
2015/12/01 17:19:57
Done.
| |
92 ASSERT_TRUE(extension); | |
93 | |
94 // Open the embedded options page | |
Devlin
2015/12/01 00:58:20
nitty nit: end in a '.'
robwu
2015/12/01 17:19:57
Done.
| |
95 ASSERT_TRUE(ExtensionTabUtil::OpenOptionsPage(extension, browser())); | |
96 WaitForExtensionNotIdle(extension->id()); | |
97 | |
98 // Get the info about the extension, including the inspectable views. | |
99 scoped_refptr<UIThreadExtensionFunction> function( | |
100 new api::DeveloperPrivateGetExtensionInfoFunction()); | |
101 scoped_ptr<base::Value> result( | |
102 extension_function_test_utils::RunFunctionAndReturnSingleResult( | |
103 function.get(), base::StringPrintf("[\"%s\"]", | |
104 extension->id().c_str()), | |
105 browser())); | |
106 ASSERT_TRUE(result); | |
107 scoped_ptr<api::developer_private::ExtensionInfo> info = | |
108 api::developer_private::ExtensionInfo::FromValue(*result); | |
109 ASSERT_TRUE(info); | |
110 | |
111 // The embedded options page should show up. | |
112 ASSERT_EQ(1u, info->views.size()); | |
113 api::developer_private::ExtensionView* view = info->views[0].get(); | |
114 ASSERT_TRUE(view); | |
115 ASSERT_EQ(api::developer_private::VIEW_TYPE_EXTENSION_OPTIONS, view->type); | |
116 | |
117 // Inspect the embedded options page. | |
118 function = new api::DeveloperPrivateOpenDevToolsFunction(); | |
119 extension_function_test_utils::RunFunction( | |
120 function.get(), | |
121 base::StringPrintf("[{\"renderViewId\": %d, \"renderProcessId\": %d}]", | |
122 view->render_view_id, | |
123 view->render_process_id), | |
124 browser(), extension_function_test_utils::NONE); | |
125 | |
126 // Verify that dev tools opened. | |
127 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( | |
128 view->render_process_id, view->render_view_id); | |
129 ASSERT_TRUE(rfh); | |
130 content::WebContents* wc = content::WebContents::FromRenderFrameHost(rfh); | |
131 ASSERT_TRUE(wc); | |
132 EXPECT_TRUE(DevToolsWindow::GetInstanceForInspectedWebContents(wc)); | |
133 } | |
134 | |
84 } // namespace extensions | 135 } // namespace extensions |
OLD | NEW |