Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs_api_unittest.cc

Issue 2630753003: Separate validation failures from other failures in ExecuteCodeFunction. (Closed)
Patch Set: address comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/strings/stringprintf.h" 5 #include "base/strings/stringprintf.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/extensions/api/tabs/tabs_api.h" 7 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
8 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
8 #include "chrome/browser/extensions/extension_function_test_utils.h" 9 #include "chrome/browser/extensions/extension_function_test_utils.h"
9 #include "chrome/browser/extensions/extension_service_test_base.h" 10 #include "chrome/browser/extensions/extension_service_test_base.h"
10 #include "chrome/browser/extensions/extension_tab_util.h" 11 #include "chrome/browser/extensions/extension_tab_util.h"
11 #include "chrome/browser/sessions/session_tab_helper.h" 12 #include "chrome/browser/sessions/session_tab_helper.h"
12 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/test/base/test_browser_window.h" 15 #include "chrome/test/base/test_browser_window.h"
15 #include "content/public/browser/navigation_entry.h" 16 #include "content/public/browser/navigation_entry.h"
16 #include "content/public/common/browser_side_navigation_policy.h" 17 #include "content/public/common/browser_side_navigation_policy.h"
17 #include "content/public/test/browser_side_navigation_test_utils.h" 18 #include "content/public/test/browser_side_navigation_test_utils.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 EXPECT_EQ(kGoogle, web_contents->GetLastCommittedURL()); 264 EXPECT_EQ(kGoogle, web_contents->GetLastCommittedURL());
264 EXPECT_EQ(kGoogle, web_contents->GetVisibleURL()); 265 EXPECT_EQ(kGoogle, web_contents->GetVisibleURL());
265 266
266 // Clean up. 267 // Clean up.
267 response_helper.WaitForResponse(); 268 response_helper.WaitForResponse();
268 while (!browser()->tab_strip_model()->empty()) 269 while (!browser()->tab_strip_model()->empty())
269 browser()->tab_strip_model()->CloseWebContentsAt(0, 0); 270 browser()->tab_strip_model()->CloseWebContentsAt(0, 0);
270 base::RunLoop().RunUntilIdle(); 271 base::RunLoop().RunUntilIdle();
271 } 272 }
272 273
274 // Tests that non-validation failure in tabs.executeScript results in error, and
275 // not bad_message.
276 // Regression test for https://crbug.com/642794.
277 TEST_F(TabsApiUnitTest, ExecuteScriptNoTabIsNonFatalError) {
278 // An extension with "tabs" permission.
279 scoped_refptr<const Extension> extension =
280 ExtensionBuilder()
281 .SetManifest(
282 DictionaryBuilder()
283 .Set("name", "Extension with tabs permission")
284 .Set("version", "1.0")
285 .Set("manifest_version", 2)
286 .Set("permissions", ListBuilder().Append("tabs").Build())
287 .Build())
288 .Build();
289 scoped_refptr<TabsExecuteScriptFunction> function(
290 new TabsExecuteScriptFunction());
291 function->set_extension(extension);
292 const char* kArgs = R"(["", {"code": ""}])";
293 std::string error = extension_function_test_utils::RunFunctionAndReturnError(
294 function.get(), kArgs,
295 browser(), // browser() doesn't have any tabs.
296 extension_function_test_utils::NONE);
297 EXPECT_EQ(tabs_constants::kNoTabInBrowserWindowError, error);
298 }
299
273 } // namespace extensions 300 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_api.cc ('k') | chrome/browser/extensions/api/tabs/tabs_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698