| OLD | NEW |
| 1 <!-- |
| 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this |
| 3 * source code is governed by a BSD-style license that can be found in the |
| 4 * LICENSE file. |
| 5 --> |
| 1 <script src="tabs_util.js"></script> | 6 <script src="tabs_util.js"></script> |
| 2 | 7 <script src="crud.js"></script> |
| 3 <script> | |
| 4 var firstWindowId; | |
| 5 | |
| 6 chrome.test.runTests([ | |
| 7 function getSelected() { | |
| 8 chrome.tabs.getSelected(null, pass(function(tab) { | |
| 9 assertEq(location.href, tab.url); | |
| 10 assertEq(location.href, tab.title); | |
| 11 firstWindowId = tab.windowId; | |
| 12 })); | |
| 13 }, | |
| 14 | |
| 15 function create() { | |
| 16 chrome.tabs.create({"windowId" : firstWindowId, "active" : false}, | |
| 17 pass(function(tab){ | |
| 18 assertEq(1, tab.index); | |
| 19 assertEq(firstWindowId, tab.windowId); | |
| 20 assertEq(false, tab.selected); | |
| 21 assertEq("chrome://newtab/", tab.url); | |
| 22 assertEq(false, tab.pinned); | |
| 23 })); | |
| 24 }, | |
| 25 | |
| 26 function createInOtherWindow() { | |
| 27 chrome.windows.create({}, pass(function(win) { | |
| 28 // Create a tab in the older window. | |
| 29 chrome.tabs.create({"windowId" : firstWindowId, "active" : false}, | |
| 30 pass(function(tab) { | |
| 31 assertEq(firstWindowId, tab.windowId); | |
| 32 })); | |
| 33 // Create a tab in this new window. | |
| 34 chrome.tabs.create({"windowId" : win.id}, pass(function(tab) { | |
| 35 assertEq(win.id, tab.windowId); | |
| 36 })); | |
| 37 })); | |
| 38 }, | |
| 39 | |
| 40 function createAtIndex() { | |
| 41 chrome.tabs.create({"windowId" : firstWindowId, "index" : 1}, | |
| 42 pass(function(tab) { | |
| 43 assertEq(1, tab.index); | |
| 44 })); | |
| 45 }, | |
| 46 | |
| 47 function createSelected() { | |
| 48 chrome.tabs.create({"windowId" : firstWindowId, "active" : true}, | |
| 49 pass(function(tab) { | |
| 50 assertTrue(tab.active && tab.selected); | |
| 51 chrome.tabs.getSelected(firstWindowId, pass(function(selectedTab) { | |
| 52 assertEq(tab.id, selectedTab.id); | |
| 53 })); | |
| 54 })); | |
| 55 }, | |
| 56 | |
| 57 function createWindowWithDefaultTab() { | |
| 58 var verify_default = function() { | |
| 59 return pass(function(win) { | |
| 60 assertEq(1, win.tabs.length); | |
| 61 assertEq("chrome://newtab/", win.tabs[0].url); | |
| 62 }); | |
| 63 }; | |
| 64 | |
| 65 // Make sure the window always has the NTP when no URL is supplied. | |
| 66 chrome.windows.create({}, verify_default()); | |
| 67 chrome.windows.create({url:[]}, verify_default()); | |
| 68 }, | |
| 69 | |
| 70 function createWindowWithExistingTab() { | |
| 71 // Create a tab in the old window | |
| 72 chrome.tabs.create({"windowId" : firstWindowId, "url": pageUrl('a'), | |
| 73 "active" : false}, | |
| 74 pass(function(tab) { | |
| 75 assertEq(firstWindowId, tab.windowId); | |
| 76 assertEq(pageUrl('a'), tab.url); | |
| 77 | |
| 78 // Create a new window with this tab | |
| 79 chrome.windows.create({"tabId": tab.id}, pass(function(win) { | |
| 80 assertEq(1, win.tabs.length); | |
| 81 assertEq(tab.id, win.tabs[0].id); | |
| 82 assertEq(win.id, win.tabs[0].windowId); | |
| 83 assertEq(pageUrl('a'), win.tabs[0].url); | |
| 84 })); | |
| 85 })); | |
| 86 }, | |
| 87 | |
| 88 function getAllInWindowNullArg() { | |
| 89 chrome.tabs.getAllInWindow(null, pass(function(tabs) { | |
| 90 assertEq(5, tabs.length); | |
| 91 assertEq(firstWindowId, tabs[0].windowId); | |
| 92 })); | |
| 93 }, | |
| 94 | |
| 95 function detectLanguage() { | |
| 96 chrome.tabs.getAllInWindow(firstWindowId, pass(function(tabs) { | |
| 97 chrome.tabs.detectLanguage(tabs[0].id, pass(function(lang) { | |
| 98 assertEq("und", lang); | |
| 99 })); | |
| 100 })); | |
| 101 }, | |
| 102 | |
| 103 function windowCreate() { | |
| 104 chrome.windows.create({type: "popup"}, pass(function(window) { | |
| 105 assertEq("popup", window.type); | |
| 106 assertTrue(!window.incognito); | |
| 107 })); | |
| 108 chrome.windows.create({incognito: true}, pass(function(window) { | |
| 109 // This extension is not incognito-enabled, so it shouldn't be able to | |
| 110 // see the incognito window. | |
| 111 assertEq(null, window); | |
| 112 })); | |
| 113 }, | |
| 114 | |
| 115 /* Disabled -- see http://bugs.chromium.org/58229. | |
| 116 function windowSetFocused() { | |
| 117 chrome.windows.getCurrent(function(oldWin) { | |
| 118 chrome.windows.create({}, function(newWin) { | |
| 119 assertTrue(newWin.focused); | |
| 120 chrome.windows.update(oldWin.id, {focused:true}); | |
| 121 chrome.windows.get(oldWin.id, pass(function(oldWin2) { | |
| 122 assertTrue(oldWin2.focused); | |
| 123 })); | |
| 124 }); | |
| 125 }); | |
| 126 }, | |
| 127 */ | |
| 128 ]); | |
| 129 </script> | |
| OLD | NEW |