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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "chrome/browser/extensions/api/debugger/debugger_api.h" | 11 #include "chrome/browser/extensions/api/debugger/debugger_api.h" |
12 #include "chrome/browser/extensions/extension_apitest.h" | 12 #include "chrome/browser/extensions/extension_apitest.h" |
13 #include "chrome/browser/extensions/extension_function_test_utils.h" | 13 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 14 #include "chrome/browser/sessions/session_tab_helper.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
18 #include "extensions/browser/extension_function.h" | 19 #include "extensions/browser/extension_function.h" |
19 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
20 #include "extensions/common/extension_builder.h" | 21 #include "extensions/common/extension_builder.h" |
21 #include "extensions/common/manifest_constants.h" | 22 #include "extensions/common/manifest_constants.h" |
22 #include "extensions/common/switches.h" | 23 #include "extensions/common/switches.h" |
23 #include "extensions/common/value_builder.h" | 24 #include "extensions/common/value_builder.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 .Set("manifest_version", 2) | 65 .Set("manifest_version", 2) |
65 .Set("permissions", | 66 .Set("permissions", |
66 ListBuilder().Append("debugger"))).Build(); | 67 ListBuilder().Append("debugger"))).Build(); |
67 } | 68 } |
68 | 69 |
69 testing::AssertionResult DebuggerApiTest::RunAttachFunction( | 70 testing::AssertionResult DebuggerApiTest::RunAttachFunction( |
70 const GURL& url, const std::string& expected_error) { | 71 const GURL& url, const std::string& expected_error) { |
71 ui_test_utils::NavigateToURL(browser(), url); | 72 ui_test_utils::NavigateToURL(browser(), url); |
72 content::WebContents* web_contents = | 73 content::WebContents* web_contents = |
73 browser()->tab_strip_model()->GetActiveWebContents(); | 74 browser()->tab_strip_model()->GetActiveWebContents(); |
74 int tab_id = SessionID::IdForTab(web_contents); | 75 int tab_id = SessionTabHelper::IdForTab(web_contents); |
75 scoped_refptr<DebuggerAttachFunction> attach_function = | 76 scoped_refptr<DebuggerAttachFunction> attach_function = |
76 new DebuggerAttachFunction(); | 77 new DebuggerAttachFunction(); |
77 attach_function->set_extension(extension_); | 78 attach_function->set_extension(extension_); |
78 std::string args = base::StringPrintf("[{\"tabId\": %d}, \"1.1\"]", tab_id); | 79 std::string args = base::StringPrintf("[{\"tabId\": %d}, \"1.1\"]", tab_id); |
79 | 80 |
80 if (!expected_error.empty()) { | 81 if (!expected_error.empty()) { |
81 std::string actual_error = | 82 std::string actual_error = |
82 extension_function_test_utils::RunFunctionAndReturnError( | 83 extension_function_test_utils::RunFunctionAndReturnError( |
83 attach_function, args, browser()); | 84 attach_function, args, browser()); |
84 if (actual_error != expected_error) { | 85 if (actual_error != expected_error) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 extension()->id().c_str())), | 137 extension()->id().c_str())), |
137 std::string())); | 138 std::string())); |
138 | 139 |
139 // Append extensions on chrome urls switch. The extension should now be able | 140 // Append extensions on chrome urls switch. The extension should now be able |
140 // to debug any extension. | 141 // to debug any extension. |
141 command_line()->AppendSwitch(switches::kExtensionsOnChromeURLs); | 142 command_line()->AppendSwitch(switches::kExtensionsOnChromeURLs); |
142 EXPECT_TRUE(RunAttachFunction(other_ext_url, std::string())); | 143 EXPECT_TRUE(RunAttachFunction(other_ext_url, std::string())); |
143 } | 144 } |
144 | 145 |
145 } // namespace extensions | 146 } // namespace extensions |
OLD | NEW |