| 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 "chrome/browser/extensions/api/tabs/tabs.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 | 540 |
| 541 static const char kArgsMaximizedWithBounds[] = | 541 static const char kArgsMaximizedWithBounds[] = |
| 542 "[%u, {\"state\": \"maximized\", \"width\": 500}]"; | 542 "[%u, {\"state\": \"maximized\", \"width\": 500}]"; |
| 543 EXPECT_TRUE(MatchPattern( | 543 EXPECT_TRUE(MatchPattern( |
| 544 utils::RunFunctionAndReturnError( | 544 utils::RunFunctionAndReturnError( |
| 545 new UpdateWindowFunction(), | 545 new UpdateWindowFunction(), |
| 546 base::StringPrintf(kArgsMaximizedWithBounds, window_id), | 546 base::StringPrintf(kArgsMaximizedWithBounds, window_id), |
| 547 browser()), | 547 browser()), |
| 548 keys::kInvalidWindowStateError)); | 548 keys::kInvalidWindowStateError)); |
| 549 } | 549 } |
| 550 |
| 551 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTabNoPermission) { |
| 552 scoped_refptr<CreateTabFunction> create_tab_function(new CreateTabFunction()); |
| 553 // Without a callback the function will not generate a result. |
| 554 create_tab_function->set_has_callback(true); |
| 555 |
| 556 static const char kNewBlankTabArgs[] = |
| 557 "[{\"url\": \"about:blank\"}]"; |
| 558 |
| 559 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( |
| 560 utils::RunFunctionAndReturnResult( |
| 561 create_tab_function.get(), |
| 562 kNewBlankTabArgs, |
| 563 browser()))); |
| 564 |
| 565 int tab_id = utils::GetInteger(result.get(), "id"); |
| 566 |
| 567 scoped_refptr<DuplicateTabFunction> duplicate_tab_function( |
| 568 new DuplicateTabFunction()); |
| 569 scoped_refptr<extensions::Extension> empty_extension( |
| 570 utils::CreateEmptyExtension()); |
| 571 duplicate_tab_function->set_extension(empty_extension.get()); |
| 572 // Without a callback the function will not generate a result. |
| 573 duplicate_tab_function->set_has_callback(true); |
| 574 |
| 575 scoped_ptr<base::Value> duplicate_result( |
| 576 utils::RunFunctionAndReturnResult( |
| 577 duplicate_tab_function.get(), base::StringPrintf("[%u]", tab_id), |
| 578 browser())); |
| 579 |
| 580 int duplicate_tab_id = tab_id; |
| 581 duplicate_result.get()->GetAsInteger(&duplicate_tab_id); |
| 582 // The test empty extension has no permissions, therefore it should get |
| 583 // tab id of TYPE_INTEGER in the function result. |
| 584 EXPECT_EQ(base::Value::TYPE_INTEGER, duplicate_result->GetType()); |
| 585 // Duplicate tab id should be different from the original tab id. |
| 586 EXPECT_NE(tab_id, duplicate_tab_id); |
| 587 } |
| 588 |
| OLD | NEW |