| 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 var firstWindowId; | 5 var firstWindowId; |
| 6 | 6 |
| 7 chrome.test.runTests([ | 7 chrome.test.runTests([ |
| 8 function getSelected() { | 8 function getSelected() { |
| 9 chrome.tabs.getSelected(null, pass(function(tab) { | 9 chrome.tabs.getSelected(null, pass(function(tab) { |
| 10 assertEq(location.href, tab.url); | 10 assertEq(location.href, tab.url); |
| 11 assertEq(location.href, tab.title); | 11 assertEq(location.href, tab.title); |
| 12 firstWindowId = tab.windowId; | 12 firstWindowId = tab.windowId; |
| 13 })); | 13 })); |
| 14 }, | 14 }, |
| 15 | 15 |
| 16 function create() { | 16 function create() { |
| 17 chrome.tabs.create({"windowId" : firstWindowId, "active" : false}, | 17 chrome.tabs.create({"windowId" : firstWindowId, "active" : false}, |
| 18 pass(function(tab){ | 18 pass(function(tab){ |
| 19 assertEq(1, tab.index); | 19 assertEq(1, tab.index); |
| 20 assertEq(firstWindowId, tab.windowId); | 20 assertEq(firstWindowId, tab.windowId); |
| 21 assertEq(false, tab.selected); | 21 assertEq(false, tab.selected); |
| 22 assertEq("chrome://newtab/", tab.url); | 22 assertEq("chrome-search://local-ntp/local-ntp.html", tab.url); |
| 23 assertEq(false, tab.pinned); | 23 assertEq(false, tab.pinned); |
| 24 })); | 24 })); |
| 25 }, | 25 }, |
| 26 | 26 |
| 27 function createInCurrent() { | 27 function createInCurrent() { |
| 28 chrome.tabs.create({'windowId': chrome.windows.WINDOW_ID_CURRENT}, | 28 chrome.tabs.create({'windowId': chrome.windows.WINDOW_ID_CURRENT}, |
| 29 pass(function(tab) { | 29 pass(function(tab) { |
| 30 chrome.windows.getCurrent(pass(function(win) { | 30 chrome.windows.getCurrent(pass(function(win) { |
| 31 assertEq(win.id, tab.windowId); | 31 assertEq(win.id, tab.windowId); |
| 32 })); | 32 })); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 61 chrome.tabs.getSelected(firstWindowId, pass(function(selectedTab) { | 61 chrome.tabs.getSelected(firstWindowId, pass(function(selectedTab) { |
| 62 assertEq(tab.id, selectedTab.id); | 62 assertEq(tab.id, selectedTab.id); |
| 63 })); | 63 })); |
| 64 })); | 64 })); |
| 65 }, | 65 }, |
| 66 | 66 |
| 67 function createWindowWithDefaultTab() { | 67 function createWindowWithDefaultTab() { |
| 68 var verify_default = function() { | 68 var verify_default = function() { |
| 69 return pass(function(win) { | 69 return pass(function(win) { |
| 70 assertEq(1, win.tabs.length); | 70 assertEq(1, win.tabs.length); |
| 71 assertEq("chrome://newtab/", win.tabs[0].url); | 71 assertEq("chrome-search://local-ntp/local-ntp.html", win.tabs[0].url); |
| 72 }); | 72 }); |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 // Make sure the window always has the NTP when no URL is supplied. | 75 // Make sure the window always has the NTP when no URL is supplied. |
| 76 chrome.windows.create({}, verify_default()); | 76 chrome.windows.create({}, verify_default()); |
| 77 chrome.windows.create({url:[]}, verify_default()); | 77 chrome.windows.create({url:[]}, verify_default()); |
| 78 }, | 78 }, |
| 79 | 79 |
| 80 function createWindowWithExistingTab() { | 80 function createWindowWithExistingTab() { |
| 81 // Create a tab in the old window | 81 // Create a tab in the old window |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 assertTrue(newWin.focused); | 139 assertTrue(newWin.focused); |
| 140 chrome.windows.update(oldWin.id, {focused:true}); | 140 chrome.windows.update(oldWin.id, {focused:true}); |
| 141 chrome.windows.get(oldWin.id, pass(function(oldWin2) { | 141 chrome.windows.get(oldWin.id, pass(function(oldWin2) { |
| 142 assertTrue(oldWin2.focused); | 142 assertTrue(oldWin2.focused); |
| 143 })); | 143 })); |
| 144 }); | 144 }); |
| 145 }); | 145 }); |
| 146 }, | 146 }, |
| 147 */ | 147 */ |
| 148 ]); | 148 ]); |
| OLD | NEW |