| OLD | NEW |
| 1 // tabs api test | 1 // tabs api test |
| 2 // browser_tests.exe --gtest_filter=ExtensionApiTest.Tabs | 2 // browser_tests.exe --gtest_filter=ExtensionApiTest.Tabs |
| 3 | 3 |
| 4 // We have a bunch of places where we need to remember some state from one | 4 // We have a bunch of places where we need to remember some state from one |
| 5 // test (or setup code) to subsequent tests. | 5 // test (or setup code) to subsequent tests. |
| 6 var firstWindowId = null; | 6 var firstWindowId = null; |
| 7 var secondWindowId = null; | 7 var secondWindowId = null; |
| 8 var firstTabIndex = null; | 8 var firstTabIndex = null; |
| 9 var testTabId = null; | 9 var testTabId = null; |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 firstTabIndex = tab.index; | 28 firstTabIndex = tab.index; |
| 29 })); | 29 })); |
| 30 }, | 30 }, |
| 31 | 31 |
| 32 function create() { | 32 function create() { |
| 33 chrome.tabs.create({"windowId" : firstWindowId, "selected" : false}, | 33 chrome.tabs.create({"windowId" : firstWindowId, "selected" : false}, |
| 34 pass(function(tab){ | 34 pass(function(tab){ |
| 35 assertTrue(tab.index > firstTabIndex); | 35 assertTrue(tab.index > firstTabIndex); |
| 36 assertEq(firstWindowId, tab.windowId); | 36 assertEq(firstWindowId, tab.windowId); |
| 37 assertEq(false, tab.selected); | 37 assertEq(false, tab.selected); |
| 38 assertEq("chrome://newtab/", tab.url); | |
| 39 })); | 38 })); |
| 40 }, | 39 }, |
| 41 | 40 |
| 42 function createInOtherWindow() { | 41 function createInOtherWindow() { |
| 43 chrome.windows.create({}, pass(function(win) { | 42 chrome.windows.create({}, pass(function(win) { |
| 44 // The newly created window is now the currentWindow. | 43 // The newly created window is now the currentWindow. |
| 45 // Create a tab in the older window. | 44 // Create a tab in the older window. |
| 46 chrome.tabs.create({"windowId" : firstWindowId, "selected" : false}, | 45 chrome.tabs.create({"windowId" : firstWindowId, "selected" : false}, |
| 47 pass(function(tab) { | 46 pass(function(tab) { |
| 48 assertEq(firstWindowId, tab.windowId); | 47 assertEq(firstWindowId, tab.windowId); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 chrome.tabs.remove(moveTabIds["d"], pass(function() { | 233 chrome.tabs.remove(moveTabIds["d"], pass(function() { |
| 235 chrome.tabs.getAllInWindow(secondWindowId, | 234 chrome.tabs.getAllInWindow(secondWindowId, |
| 236 pass(function(tabs) { | 235 pass(function(tabs) { |
| 237 assertEq(2, tabs.length); | 236 assertEq(2, tabs.length); |
| 238 assertEq(pageUrl("b"), tabs[0].url); | 237 assertEq(pageUrl("b"), tabs[0].url); |
| 239 assertEq("chrome://newtab/", tabs[1].url); | 238 assertEq("chrome://newtab/", tabs[1].url); |
| 240 })); | 239 })); |
| 241 })); | 240 })); |
| 242 }, | 241 }, |
| 243 | 242 |
| 243 function focus() { |
| 244 chrome.test.listenOnce(chrome.windows.onFocusChanged, function(winId) { |
| 245 assertEq(firstWindowId, winId); |
| 246 }); |
| 247 |
| 248 chrome.windows.update(firstWindowId, {focused: true}, pass()); |
| 249 }, |
| 250 |
| 244 /* | 251 /* |
| 245 // TODO(jcampan): http://crbug.com/30662 the detection language library | 252 // TODO(jcampan): http://crbug.com/30662 the detection language library |
| 246 // crashes on some sites and has been temporarily disabled. | 253 // crashes on some sites and has been temporarily disabled. |
| 247 function detectLanguage() { | 254 function detectLanguage() { |
| 248 chrome.tabs.getAllInWindow(firstWindowId, pass(function(tabs) { | 255 chrome.tabs.getAllInWindow(firstWindowId, pass(function(tabs) { |
| 249 chrome.tabs.detectLanguage(tabs[0].id, pass(function(lang) { | 256 chrome.tabs.detectLanguage(tabs[0].id, pass(function(lang) { |
| 250 assertEq("en", lang); | 257 assertEq("en", lang); |
| 251 })); | 258 })); |
| 252 })); | 259 })); |
| 253 }, | 260 }, |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 var request = "test"; | 577 var request = "test"; |
| 571 chrome.tabs.sendRequest(testTabId, request, pass(function(response) { | 578 chrome.tabs.sendRequest(testTabId, request, pass(function(response) { |
| 572 assertEq(request, response); | 579 assertEq(request, response); |
| 573 })); | 580 })); |
| 574 }, | 581 }, |
| 575 | 582 |
| 576 // TODO(asargent) | 583 // TODO(asargent) |
| 577 // It would be an improvement to check the captureVisibleTab results | 584 // It would be an improvement to check the captureVisibleTab results |
| 578 // against a known-good result. | 585 // against a known-good result. |
| 579 ]); | 586 ]); |
| OLD | NEW |