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

Unified Diff: chrome/browser/extensions/api/tabs/tabs_test.cc

Issue 10697017: Tabs Extension: Implementation of tabs.duplicate api. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/tabs/tabs_test.cc
===================================================================
--- chrome/browser/extensions/api/tabs/tabs_test.cc (revision 142698)
+++ chrome/browser/extensions/api/tabs/tabs_test.cc (working copy)
@@ -547,3 +547,42 @@
browser()),
keys::kInvalidWindowStateError));
}
+
+IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTabNoPermission) {
+ scoped_refptr<CreateTabFunction> create_tab_function(new CreateTabFunction());
+ // Without a callback the function will not generate a result.
+ create_tab_function->set_has_callback(true);
+
+ static const char kNewBlankTabArgs[] =
+ "[{\"url\": \"about:blank\"}]";
+
+ scoped_ptr<base::DictionaryValue> result(utils::ToDictionary(
+ utils::RunFunctionAndReturnResult(
+ create_tab_function.get(),
+ kNewBlankTabArgs,
+ browser())));
+
+ int tab_id = utils::GetInteger(result.get(), "id");
+
+ scoped_refptr<DuplicateTabFunction> duplicate_tab_function(
+ new DuplicateTabFunction());
+ scoped_refptr<extensions::Extension> empty_extension(
+ utils::CreateEmptyExtension());
+ duplicate_tab_function->set_extension(empty_extension.get());
+ // Without a callback the function will not generate a result.
+ duplicate_tab_function->set_has_callback(true);
+
+ scoped_ptr<base::Value> duplicate_result(
+ utils::RunFunctionAndReturnResult(
+ duplicate_tab_function.get(), base::StringPrintf("[%u]", tab_id),
+ browser()));
+
+ int duplicate_tab_id = tab_id;
+ duplicate_result.get()->GetAsInteger(&duplicate_tab_id);
+ // The test empty extension has no permissions, therefore it should get
+ // tab id of TYPE_INTEGER in the function result.
+ EXPECT_EQ(base::Value::TYPE_INTEGER, duplicate_result->GetType());
+ // Duplicate tab id should be different from the original tab id.
+ EXPECT_NE(tab_id, duplicate_tab_id);
+}
+

Powered by Google App Engine
This is Rietveld 408576698