Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: chrome/test/data/extensions/api_test/tabs/basics/move.html

Issue 8762014: Move another set of extension tests to manifest_version 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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="move.js"></script>
3 <script>
4 var firstWindowId;
5 var secondWindowId;
6 var moveTabIds = {};
7
8 chrome.test.runTests([
9 // Do a series of moves and removes so that we get the following
10 //
11 // Before:
12 // Window1: (newtab),a,b,c,d,e
13 // Window2: (newtab)
14 //
15 // After:
16 // Window1: (newtab),a
17 // Window2: b,(newtab)
18 function setupLetterPages() {
19 var pages = ["chrome://newtab/", pageUrl('a'), pageUrl('b'),
20 pageUrl('c'), pageUrl('d'), pageUrl('e')];
21 createWindow(pages, {}, pass(function(winId, tabIds) {
22 firstWindowId = winId;
23 moveTabIds['a'] = tabIds[1];
24 moveTabIds['b'] = tabIds[2];
25 moveTabIds['c'] = tabIds[3];
26 moveTabIds['d'] = tabIds[4];
27 moveTabIds['e'] = tabIds[5];
28 createWindow(["chrome://newtab/"], {}, pass(function(winId, tabIds) {
29 secondWindowId = winId;
30 }));
31 chrome.tabs.getAllInWindow(firstWindowId, pass(function(tabs) {
32 assertEq(pages.length, tabs.length);
33 for (var i in tabs) {
34 assertEq(pages[i], tabs[i].url);
35 }
36 }));
37 }));
38 },
39
40 function move() {
41 // Check that the tab/window state is what we expect after doing moves.
42 function checkMoveResults() {
43 chrome.tabs.getAllInWindow(firstWindowId, pass(function(tabs) {
44 assertEq(4, tabs.length);
45 assertEq("chrome://newtab/", tabs[0].url);
46 assertEq(pageUrl("a"), tabs[1].url);
47 assertEq(pageUrl("e"), tabs[2].url);
48 assertEq(pageUrl("c"), tabs[3].url);
49
50 chrome.tabs.getAllInWindow(secondWindowId, pass(function(tabs) {
51 assertEq(3, tabs.length);
52 assertEq(pageUrl("b"), tabs[0].url);
53 assertEq("chrome://newtab/", tabs[1].url);
54 assertEq(pageUrl("d"), tabs[2].url);
55 }));
56 }));
57 }
58
59 chrome.tabs.move(moveTabIds['b'], {"windowId": secondWindowId, "index": 0},
60 pass(function(tabB) {
61 chrome.test.assertEq(0, tabB.index);
62 chrome.tabs.move(moveTabIds['e'], {"index": 2},
63 pass(function(tabE) {
64 chrome.test.assertEq(2, tabE.index);
65 chrome.tabs.move(moveTabIds['d'], {"windowId": secondWindowId,
66 "index": 2}, pass(function(tabD) {
67 chrome.test.assertEq(2, tabD.index);
68 checkMoveResults();
69 }));
70 }));
71 }));
72 },
73
74 function remove() {
75 chrome.tabs.remove(moveTabIds["d"], pass(function() {
76 chrome.tabs.getAllInWindow(secondWindowId,
77 pass(function(tabs) {
78 assertEq(2, tabs.length);
79 assertEq(pageUrl("b"), tabs[0].url);
80 assertEq("chrome://newtab/", tabs[1].url);
81 }));
82 }));
83 },
84
85 function moveMultipleTabs() {
86 chrome.tabs.move([moveTabIds['e'], moveTabIds['c']],
87 {windowId: secondWindowId, index: 1},
88 pass(function(tabsA) {
89 assertEq(2, tabsA.length);
90 assertEq(secondWindowId, tabsA[0].windowId);
91 assertEq(pageUrl('e'), tabsA[0].url);
92 assertEq(1, tabsA[0].index);
93 assertEq(secondWindowId, tabsA[1].windowId);
94 assertEq(pageUrl('c'), tabsA[1].url);
95 assertEq(2, tabsA[1].index);
96 chrome.tabs.query({windowId: secondWindowId}, pass(function(tabsB) {
97 assertEq(4, tabsB.length);
98 }));
99 }));
100 },
101
102 function removeMultipleTabs() {
103 chrome.tabs.remove([moveTabIds['e'], moveTabIds['c']], pass(function() {
104 chrome.tabs.query({windowId: secondWindowId}, pass(function(tabs) {
105 assertEq(2, tabs.length);
106 assertEq(pageUrl("b"), tabs[0].url);
107 assertEq("chrome://newtab/", tabs[1].url);
108 }));
109 }));
110 },
111
112 // Make sure we don't crash when the index is out of range.
113 function moveToInvalidTab() {
114 var error_msg = "Invalid value for argument 2. Property 'index': " +
115 "Value must not be less than 0.";
116 try {
117 chrome.tabs.move(moveTabIds['b'], {index: -1}, function(tab) {
118 chrome.test.fail("Moved a tab to an invalid index");
119 });
120 } catch (e) {
121 assertEq(error_msg, e.message);
122 }
123 chrome.tabs.move(moveTabIds['b'], {index: 10000}, pass(function(tabB) {
124 assertEq(1, tabB.index);
125 }));
126 }
127 ]);
128 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698