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 <limits.h> | 5 #include <limits.h> |
6 #include <stddef.h> | 6 #include <stddef.h> |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 base::MatchPattern(RunCreateWindowExpectError( | 1127 base::MatchPattern(RunCreateWindowExpectError( |
1128 "[{\"state\": \"maximized\", \"width\": 500}]"), | 1128 "[{\"state\": \"maximized\", \"width\": 500}]"), |
1129 keys::kInvalidWindowStateError)); | 1129 keys::kInvalidWindowStateError)); |
1130 EXPECT_TRUE( | 1130 EXPECT_TRUE( |
1131 base::MatchPattern(RunCreateWindowExpectError( | 1131 base::MatchPattern(RunCreateWindowExpectError( |
1132 "[{\"state\": \"fullscreen\", \"width\": 500}]"), | 1132 "[{\"state\": \"fullscreen\", \"width\": 500}]"), |
1133 keys::kInvalidWindowStateError)); | 1133 keys::kInvalidWindowStateError)); |
1134 } | 1134 } |
1135 | 1135 |
1136 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) { | 1136 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) { |
1137 content::OpenURLParams params(GURL(url::kAboutBlankURL), | 1137 content::OpenURLParams params(GURL(url::kAboutBlankURL), content::Referrer(), |
1138 content::Referrer(), | 1138 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
1139 NEW_FOREGROUND_TAB, | 1139 ui::PAGE_TRANSITION_LINK, false); |
1140 ui::PAGE_TRANSITION_LINK, | |
1141 false); | |
1142 content::WebContents* web_contents = browser()->OpenURL(params); | 1140 content::WebContents* web_contents = browser()->OpenURL(params); |
1143 int tab_id = ExtensionTabUtil::GetTabId(web_contents); | 1141 int tab_id = ExtensionTabUtil::GetTabId(web_contents); |
1144 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); | 1142 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); |
1145 int tab_index = -1; | 1143 int tab_index = -1; |
1146 TabStripModel* tab_strip; | 1144 TabStripModel* tab_strip; |
1147 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); | 1145 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); |
1148 | 1146 |
1149 scoped_refptr<TabsDuplicateFunction> duplicate_tab_function( | 1147 scoped_refptr<TabsDuplicateFunction> duplicate_tab_function( |
1150 new TabsDuplicateFunction()); | 1148 new TabsDuplicateFunction()); |
1151 std::unique_ptr<base::DictionaryValue> test_extension_value( | 1149 std::unique_ptr<base::DictionaryValue> test_extension_value( |
(...skipping 19 matching lines...) Expand all Loading... |
1171 EXPECT_NE(tab_id, duplicate_tab_id); | 1169 EXPECT_NE(tab_id, duplicate_tab_id); |
1172 EXPECT_EQ(window_id, duplicate_tab_window_id); | 1170 EXPECT_EQ(window_id, duplicate_tab_window_id); |
1173 EXPECT_EQ(tab_index + 1, duplicate_tab_index); | 1171 EXPECT_EQ(tab_index + 1, duplicate_tab_index); |
1174 // The test empty tab extension has tabs permissions, therefore | 1172 // The test empty tab extension has tabs permissions, therefore |
1175 // |duplicate_result| should contain url, title, and faviconUrl | 1173 // |duplicate_result| should contain url, title, and faviconUrl |
1176 // in the function result. | 1174 // in the function result. |
1177 EXPECT_TRUE(utils::HasPrivacySensitiveFields(duplicate_result.get())); | 1175 EXPECT_TRUE(utils::HasPrivacySensitiveFields(duplicate_result.get())); |
1178 } | 1176 } |
1179 | 1177 |
1180 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTabNoPermission) { | 1178 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTabNoPermission) { |
1181 content::OpenURLParams params(GURL(url::kAboutBlankURL), | 1179 content::OpenURLParams params(GURL(url::kAboutBlankURL), content::Referrer(), |
1182 content::Referrer(), | 1180 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
1183 NEW_FOREGROUND_TAB, | 1181 ui::PAGE_TRANSITION_LINK, false); |
1184 ui::PAGE_TRANSITION_LINK, | |
1185 false); | |
1186 content::WebContents* web_contents = browser()->OpenURL(params); | 1182 content::WebContents* web_contents = browser()->OpenURL(params); |
1187 int tab_id = ExtensionTabUtil::GetTabId(web_contents); | 1183 int tab_id = ExtensionTabUtil::GetTabId(web_contents); |
1188 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); | 1184 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); |
1189 int tab_index = -1; | 1185 int tab_index = -1; |
1190 TabStripModel* tab_strip; | 1186 TabStripModel* tab_strip; |
1191 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); | 1187 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); |
1192 | 1188 |
1193 scoped_refptr<TabsDuplicateFunction> duplicate_tab_function( | 1189 scoped_refptr<TabsDuplicateFunction> duplicate_tab_function( |
1194 new TabsDuplicateFunction()); | 1190 new TabsDuplicateFunction()); |
1195 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); | 1191 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); | 1311 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); |
1316 } | 1312 } |
1317 | 1313 |
1318 // TODO(georgesak): change this browsertest to an unittest. | 1314 // TODO(georgesak): change this browsertest to an unittest. |
1319 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DiscardedProperty) { | 1315 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DiscardedProperty) { |
1320 ASSERT_TRUE(g_browser_process && g_browser_process->GetTabManager()); | 1316 ASSERT_TRUE(g_browser_process && g_browser_process->GetTabManager()); |
1321 memory::TabManager* tab_manager = g_browser_process->GetTabManager(); | 1317 memory::TabManager* tab_manager = g_browser_process->GetTabManager(); |
1322 | 1318 |
1323 // Create two aditional tabs. | 1319 // Create two aditional tabs. |
1324 content::OpenURLParams params(GURL(url::kAboutBlankURL), content::Referrer(), | 1320 content::OpenURLParams params(GURL(url::kAboutBlankURL), content::Referrer(), |
1325 NEW_BACKGROUND_TAB, ui::PAGE_TRANSITION_LINK, | 1321 WindowOpenDisposition::NEW_BACKGROUND_TAB, |
1326 false); | 1322 ui::PAGE_TRANSITION_LINK, false); |
1327 content::WebContents* web_contents_a = browser()->OpenURL(params); | 1323 content::WebContents* web_contents_a = browser()->OpenURL(params); |
1328 content::WebContents* web_contents_b = browser()->OpenURL(params); | 1324 content::WebContents* web_contents_b = browser()->OpenURL(params); |
1329 | 1325 |
1330 // Set up query function with an extension. | 1326 // Set up query function with an extension. |
1331 scoped_refptr<const Extension> extension = test_util::CreateEmptyExtension(); | 1327 scoped_refptr<const Extension> extension = test_util::CreateEmptyExtension(); |
1332 auto RunQueryFunction = [this, &extension](const char* query_info) { | 1328 auto RunQueryFunction = [this, &extension](const char* query_info) { |
1333 scoped_refptr<TabsQueryFunction> function = new TabsQueryFunction(); | 1329 scoped_refptr<TabsQueryFunction> function = new TabsQueryFunction(); |
1334 function->set_extension(extension.get()); | 1330 function->set_extension(extension.get()); |
1335 return utils::ToList(utils::RunFunctionAndReturnSingleResult( | 1331 return utils::ToList(utils::RunFunctionAndReturnSingleResult( |
1336 function.get(), query_info, browser())); | 1332 function.get(), query_info, browser())); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1433 // Get discarded tabs after activating a discarded tab. | 1429 // Get discarded tabs after activating a discarded tab. |
1434 { | 1430 { |
1435 std::unique_ptr<base::ListValue> result( | 1431 std::unique_ptr<base::ListValue> result( |
1436 RunQueryFunction("[{\"discarded\": true}]")); | 1432 RunQueryFunction("[{\"discarded\": true}]")); |
1437 EXPECT_EQ(1u, result->GetSize()); | 1433 EXPECT_EQ(1u, result->GetSize()); |
1438 } | 1434 } |
1439 } | 1435 } |
1440 | 1436 |
1441 // Tests chrome.tabs.discard(tabId). | 1437 // Tests chrome.tabs.discard(tabId). |
1442 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DiscardWithId) { | 1438 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DiscardWithId) { |
1443 // Create an aditional tab. | 1439 // Create an additional tab. |
1444 ui_test_utils::NavigateToURLWithDisposition( | 1440 ui_test_utils::NavigateToURLWithDisposition( |
1445 browser(), GURL(url::kAboutBlankURL), NEW_BACKGROUND_TAB, | 1441 browser(), GURL(url::kAboutBlankURL), |
| 1442 WindowOpenDisposition::NEW_BACKGROUND_TAB, |
1446 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1443 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1447 content::WebContents* web_contents = | 1444 content::WebContents* web_contents = |
1448 browser()->tab_strip_model()->GetWebContentsAt(1); | 1445 browser()->tab_strip_model()->GetWebContentsAt(1); |
1449 | 1446 |
1450 // Set up the function with an extension. | 1447 // Set up the function with an extension. |
1451 scoped_refptr<const Extension> extension = test_util::CreateEmptyExtension(); | 1448 scoped_refptr<const Extension> extension = test_util::CreateEmptyExtension(); |
1452 scoped_refptr<TabsDiscardFunction> discard(new TabsDiscardFunction()); | 1449 scoped_refptr<TabsDiscardFunction> discard(new TabsDiscardFunction()); |
1453 discard->set_extension(extension.get()); | 1450 discard->set_extension(extension.get()); |
1454 | 1451 |
1455 // Run function passing the tab id as argument. | 1452 // Run function passing the tab id as argument. |
(...skipping 17 matching lines...) Expand all Loading... |
1473 // return the error stating that the tab couldn't be discarded. | 1470 // return the error stating that the tab couldn't be discarded. |
1474 scoped_refptr<TabsDiscardFunction> discarded(new TabsDiscardFunction()); | 1471 scoped_refptr<TabsDiscardFunction> discarded(new TabsDiscardFunction()); |
1475 discarded->set_extension(extension.get()); | 1472 discarded->set_extension(extension.get()); |
1476 std::string error = utils::RunFunctionAndReturnError( | 1473 std::string error = utils::RunFunctionAndReturnError( |
1477 discarded.get(), base::StringPrintf("[%u]", tab_id), browser()); | 1474 discarded.get(), base::StringPrintf("[%u]", tab_id), browser()); |
1478 EXPECT_TRUE(base::MatchPattern(error, keys::kCannotDiscardTab)); | 1475 EXPECT_TRUE(base::MatchPattern(error, keys::kCannotDiscardTab)); |
1479 } | 1476 } |
1480 | 1477 |
1481 // Tests chrome.tabs.discard(invalidId). | 1478 // Tests chrome.tabs.discard(invalidId). |
1482 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DiscardWithInvalidId) { | 1479 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DiscardWithInvalidId) { |
1483 // Create an aditional tab. | 1480 // Create an additional tab. |
1484 ui_test_utils::NavigateToURLWithDisposition( | 1481 ui_test_utils::NavigateToURLWithDisposition( |
1485 browser(), GURL(url::kAboutBlankURL), NEW_BACKGROUND_TAB, | 1482 browser(), GURL(url::kAboutBlankURL), |
| 1483 WindowOpenDisposition::NEW_BACKGROUND_TAB, |
1486 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1484 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1487 | 1485 |
1488 // Set up the function with an extension. | 1486 // Set up the function with an extension. |
1489 scoped_refptr<const Extension> extension = test_util::CreateEmptyExtension(); | 1487 scoped_refptr<const Extension> extension = test_util::CreateEmptyExtension(); |
1490 scoped_refptr<TabsDiscardFunction> discard(new TabsDiscardFunction()); | 1488 scoped_refptr<TabsDiscardFunction> discard(new TabsDiscardFunction()); |
1491 discard->set_extension(extension.get()); | 1489 discard->set_extension(extension.get()); |
1492 | 1490 |
1493 // Run function passing an invalid id as argument. | 1491 // Run function passing an invalid id as argument. |
1494 int tab_invalid_id = ExtensionTabUtil::GetTabId( | 1492 int tab_invalid_id = ExtensionTabUtil::GetTabId( |
1495 browser()->tab_strip_model()->GetWebContentsAt(0)); | 1493 browser()->tab_strip_model()->GetWebContentsAt(0)); |
1496 tab_invalid_id = std::max( | 1494 tab_invalid_id = std::max( |
1497 tab_invalid_id, ExtensionTabUtil::GetTabId( | 1495 tab_invalid_id, ExtensionTabUtil::GetTabId( |
1498 browser()->tab_strip_model()->GetWebContentsAt(1))); | 1496 browser()->tab_strip_model()->GetWebContentsAt(1))); |
1499 tab_invalid_id++; | 1497 tab_invalid_id++; |
1500 | 1498 |
1501 std::string error = utils::RunFunctionAndReturnError( | 1499 std::string error = utils::RunFunctionAndReturnError( |
1502 discard.get(), base::StringPrintf("[%u]", tab_invalid_id), browser()); | 1500 discard.get(), base::StringPrintf("[%u]", tab_invalid_id), browser()); |
1503 | 1501 |
1504 // Discarded state should still be false as no tab was discarded. | 1502 // Discarded state should still be false as no tab was discarded. |
1505 EXPECT_FALSE(g_browser_process->GetTabManager()->IsTabDiscarded( | 1503 EXPECT_FALSE(g_browser_process->GetTabManager()->IsTabDiscarded( |
1506 browser()->tab_strip_model()->GetWebContentsAt(1))); | 1504 browser()->tab_strip_model()->GetWebContentsAt(1))); |
1507 | 1505 |
1508 // Check error message. | 1506 // Check error message. |
1509 EXPECT_TRUE(base::MatchPattern(error, keys::kTabNotFoundError)); | 1507 EXPECT_TRUE(base::MatchPattern(error, keys::kTabNotFoundError)); |
1510 } | 1508 } |
1511 | 1509 |
1512 // Tests chrome.tabs.discard(). | 1510 // Tests chrome.tabs.discard(). |
1513 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DiscardWithoutId) { | 1511 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DiscardWithoutId) { |
1514 // Create an aditional tab. | 1512 // Create an additional tab. |
1515 ui_test_utils::NavigateToURLWithDisposition( | 1513 ui_test_utils::NavigateToURLWithDisposition( |
1516 browser(), GURL(url::kAboutBlankURL), NEW_BACKGROUND_TAB, | 1514 browser(), GURL(url::kAboutBlankURL), |
| 1515 WindowOpenDisposition::NEW_BACKGROUND_TAB, |
1517 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1516 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1518 content::WebContents* web_contents = | 1517 content::WebContents* web_contents = |
1519 browser()->tab_strip_model()->GetWebContentsAt(1); | 1518 browser()->tab_strip_model()->GetWebContentsAt(1); |
1520 | 1519 |
1521 // Set up the function with an extension. | 1520 // Set up the function with an extension. |
1522 scoped_refptr<const Extension> extension = test_util::CreateEmptyExtension(); | 1521 scoped_refptr<const Extension> extension = test_util::CreateEmptyExtension(); |
1523 scoped_refptr<TabsDiscardFunction> discard(new TabsDiscardFunction()); | 1522 scoped_refptr<TabsDiscardFunction> discard(new TabsDiscardFunction()); |
1524 discard->set_extension(extension.get()); | 1523 discard->set_extension(extension.get()); |
1525 | 1524 |
1526 // Disable protection time to discard the tab without passing id. | 1525 // Disable protection time to discard the tab without passing id. |
(...skipping 11 matching lines...) Expand all Loading... |
1538 | 1537 |
1539 // Make sure the returned tab is the one discarded and its discarded state is | 1538 // Make sure the returned tab is the one discarded and its discarded state is |
1540 // correct. | 1539 // correct. |
1541 EXPECT_EQ(ExtensionTabUtil::GetTabId(web_contents), | 1540 EXPECT_EQ(ExtensionTabUtil::GetTabId(web_contents), |
1542 api_test_utils::GetInteger(result.get(), "id")); | 1541 api_test_utils::GetInteger(result.get(), "id")); |
1543 EXPECT_TRUE(api_test_utils::GetBoolean(result.get(), "discarded")); | 1542 EXPECT_TRUE(api_test_utils::GetBoolean(result.get(), "discarded")); |
1544 } | 1543 } |
1545 | 1544 |
1546 // Tests chrome.tabs.discard() without disabling protection time. | 1545 // Tests chrome.tabs.discard() without disabling protection time. |
1547 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DiscardNoTabProtection) { | 1546 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DiscardNoTabProtection) { |
1548 // Create an aditional tab. | 1547 // Create an additional tab. |
1549 ui_test_utils::NavigateToURLWithDisposition( | 1548 ui_test_utils::NavigateToURLWithDisposition( |
1550 browser(), GURL(url::kAboutBlankURL), NEW_BACKGROUND_TAB, | 1549 browser(), GURL(url::kAboutBlankURL), |
| 1550 WindowOpenDisposition::NEW_BACKGROUND_TAB, |
1551 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1551 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1552 | 1552 |
1553 // Make sure protection time isn't disabled. | 1553 // Make sure protection time isn't disabled. |
1554 g_browser_process->GetTabManager()->set_minimum_protection_time_for_tests( | 1554 g_browser_process->GetTabManager()->set_minimum_protection_time_for_tests( |
1555 base::TimeDelta::FromMinutes(10)); | 1555 base::TimeDelta::FromMinutes(10)); |
1556 | 1556 |
1557 // Set up the function with an extension. | 1557 // Set up the function with an extension. |
1558 scoped_refptr<const Extension> extension = test_util::CreateEmptyExtension(); | 1558 scoped_refptr<const Extension> extension = test_util::CreateEmptyExtension(); |
1559 scoped_refptr<TabsDiscardFunction> discard(new TabsDiscardFunction()); | 1559 scoped_refptr<TabsDiscardFunction> discard(new TabsDiscardFunction()); |
1560 discard->set_extension(extension.get()); | 1560 discard->set_extension(extension.get()); |
1561 | 1561 |
1562 // Run without passing an id. In this case the tab couldn't be discarded | 1562 // Run without passing an id. In this case the tab couldn't be discarded |
1563 // because of protection time. | 1563 // because of protection time. |
1564 std::string error = | 1564 std::string error = |
1565 utils::RunFunctionAndReturnError(discard.get(), "[]", browser()); | 1565 utils::RunFunctionAndReturnError(discard.get(), "[]", browser()); |
1566 | 1566 |
1567 // Discarded state should be false for both tabs as no tab was discarded. | 1567 // Discarded state should be false for both tabs as no tab was discarded. |
1568 EXPECT_FALSE(g_browser_process->GetTabManager()->IsTabDiscarded( | 1568 EXPECT_FALSE(g_browser_process->GetTabManager()->IsTabDiscarded( |
1569 browser()->tab_strip_model()->GetWebContentsAt(1))); | 1569 browser()->tab_strip_model()->GetWebContentsAt(1))); |
1570 EXPECT_FALSE(g_browser_process->GetTabManager()->IsTabDiscarded( | 1570 EXPECT_FALSE(g_browser_process->GetTabManager()->IsTabDiscarded( |
1571 browser()->tab_strip_model()->GetWebContentsAt(0))); | 1571 browser()->tab_strip_model()->GetWebContentsAt(0))); |
1572 | 1572 |
1573 // Check error message. | 1573 // Check error message. |
1574 EXPECT_TRUE(base::MatchPattern(error, keys::kCannotFindTabToDiscard)); | 1574 EXPECT_TRUE(base::MatchPattern(error, keys::kCannotFindTabToDiscard)); |
1575 } | 1575 } |
1576 | 1576 |
1577 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, AutoDiscardableProperty) { | 1577 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, AutoDiscardableProperty) { |
1578 // Create two aditional tabs. | 1578 // Create two aditional tabs. |
1579 content::OpenURLParams params(GURL(url::kAboutBlankURL), content::Referrer(), | 1579 content::OpenURLParams params(GURL(url::kAboutBlankURL), content::Referrer(), |
1580 NEW_BACKGROUND_TAB, ui::PAGE_TRANSITION_LINK, | 1580 WindowOpenDisposition::NEW_BACKGROUND_TAB, |
1581 false); | 1581 ui::PAGE_TRANSITION_LINK, false); |
1582 content::WebContents* web_contents_a = browser()->OpenURL(params); | 1582 content::WebContents* web_contents_a = browser()->OpenURL(params); |
1583 content::WebContents* web_contents_b = browser()->OpenURL(params); | 1583 content::WebContents* web_contents_b = browser()->OpenURL(params); |
1584 | 1584 |
1585 // Creates Tab object to ensure the property is correct for the extension. | 1585 // Creates Tab object to ensure the property is correct for the extension. |
1586 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 1586 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
1587 std::unique_ptr<api::tabs::Tab> tab_object_a = | 1587 std::unique_ptr<api::tabs::Tab> tab_object_a = |
1588 ExtensionTabUtil::CreateTabObject(web_contents_a, tab_strip_model, 0); | 1588 ExtensionTabUtil::CreateTabObject(web_contents_a, tab_strip_model, 0); |
1589 EXPECT_TRUE(tab_object_a->auto_discardable); | 1589 EXPECT_TRUE(tab_object_a->auto_discardable); |
1590 | 1590 |
1591 // Set up query and update functions with the extension. | 1591 // Set up query and update functions with the extension. |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1861 "\"scope\": \"%s\"}]", | 1861 "\"scope\": \"%s\"}]", |
1862 tab_id, | 1862 tab_id, |
1863 mode, | 1863 mode, |
1864 scope), | 1864 scope), |
1865 browser()); | 1865 browser()); |
1866 } | 1866 } |
1867 | 1867 |
1868 content::WebContents* ExtensionTabsZoomTest::OpenUrlAndWaitForLoad( | 1868 content::WebContents* ExtensionTabsZoomTest::OpenUrlAndWaitForLoad( |
1869 const GURL& url) { | 1869 const GURL& url) { |
1870 ui_test_utils::NavigateToURLWithDisposition( | 1870 ui_test_utils::NavigateToURLWithDisposition( |
1871 browser(), | 1871 browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
1872 url, | |
1873 NEW_FOREGROUND_TAB, | |
1874 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1872 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1875 return browser()->tab_strip_model()->GetActiveWebContents(); | 1873 return browser()->tab_strip_model()->GetActiveWebContents(); |
1876 } | 1874 } |
1877 | 1875 |
1878 namespace { | 1876 namespace { |
1879 | 1877 |
1880 double GetZoomLevel(const content::WebContents* web_contents) { | 1878 double GetZoomLevel(const content::WebContents* web_contents) { |
1881 return zoom::ZoomController::FromWebContents(web_contents)->GetZoomLevel(); | 1879 return zoom::ZoomController::FromWebContents(web_contents)->GetZoomLevel(); |
1882 } | 1880 } |
1883 | 1881 |
1884 content::OpenURLParams GetOpenParams(const char* url) { | 1882 content::OpenURLParams GetOpenParams(const char* url) { |
1885 return content::OpenURLParams(GURL(url), | 1883 return content::OpenURLParams(GURL(url), content::Referrer(), |
1886 content::Referrer(), | 1884 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
1887 NEW_FOREGROUND_TAB, | 1885 ui::PAGE_TRANSITION_LINK, false); |
1888 ui::PAGE_TRANSITION_LINK, | |
1889 false); | |
1890 } | 1886 } |
1891 | 1887 |
1892 } // namespace | 1888 } // namespace |
1893 | 1889 |
1894 IN_PROC_BROWSER_TEST_F(ExtensionTabsZoomTest, SetAndGetZoom) { | 1890 IN_PROC_BROWSER_TEST_F(ExtensionTabsZoomTest, SetAndGetZoom) { |
1895 content::OpenURLParams params(GetOpenParams(url::kAboutBlankURL)); | 1891 content::OpenURLParams params(GetOpenParams(url::kAboutBlankURL)); |
1896 content::WebContents* web_contents = OpenUrlAndWaitForLoad(params.url); | 1892 content::WebContents* web_contents = OpenUrlAndWaitForLoad(params.url); |
1897 int tab_id = ExtensionTabUtil::GetTabId(web_contents); | 1893 int tab_id = ExtensionTabUtil::GetTabId(web_contents); |
1898 | 1894 |
1899 // Test default values before we set anything. | 1895 // Test default values before we set anything. |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2112 EXPECT_TRUE( | 2108 EXPECT_TRUE( |
2113 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 2109 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
2114 | 2110 |
2115 // chrome.tabs.setZoomSettings(). | 2111 // chrome.tabs.setZoomSettings(). |
2116 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); | 2112 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); |
2117 EXPECT_TRUE( | 2113 EXPECT_TRUE( |
2118 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 2114 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
2119 } | 2115 } |
2120 | 2116 |
2121 } // namespace extensions | 2117 } // namespace extensions |
OLD | NEW |