Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 scoped_refptr<const Extension> extension = test_util::CreateEmptyExtension(); | |
|
Devlin
2017/01/17 18:52:09
nit: it seems like this could pretty easily break
lazyboy
2017/01/18 02:29:10
Done.
| |
| 279 scoped_refptr<TabsExecuteScriptFunction> function( | |
| 280 new TabsExecuteScriptFunction()); | |
| 281 function->set_extension(extension); | |
| 282 const char* kArgs = "[\"\", {\"code\": \"\"}]"; | |
| 283 std::string error = extension_function_test_utils::RunFunctionAndReturnError( | |
| 284 function.get(), kArgs, | |
| 285 browser(), // browser() doesn't have any tabs. | |
| 286 extension_function_test_utils::NONE); | |
| 287 EXPECT_EQ(tabs_constants::kNoTabInBrowserWindowError, error); | |
| 288 } | |
| 289 | |
| 273 } // namespace extensions | 290 } // namespace extensions |
| OLD | NEW |