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

Side by Side Diff: chrome/test/data/extensions/api_test/tabs/basics/pinned.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="pinned.js"></script>
3 <script>
4 var firstWindowId;
5
6 chrome.test.runTests([
7 function setupWindow() {
8 createWindow(["about:blank", "chrome://newtab/", pageUrl("a")], {},
9 pass(function(winId, tabIds) {
10 firstWindowId = winId;
11 }));
12 },
13
14 function createPinned() {
15 var winOptions = {"windowId": firstWindowId, "pinned": true};
16 var onUpdatedCompleted = chrome.test.listenForever(
17 chrome.tabs.onUpdated,
18 function(tabId, changeInfo, tab) {
19 if ('pinned' in changeInfo) {
20 assertEq(false, changeInfo.pinned);
21 assertEq(false, tab.pinned);
22 onUpdatedCompleted();
23 }
24 }
25 );
26 chrome.tabs.create(winOptions, pass(function(tab) {
27 assertEq(true, tab.pinned);
28 chrome.tabs.update(tab.id, {"pinned":false}, pass(function() {
29 // Leave a clean slate for the next test.
30 chrome.tabs.remove(tab.id);
31 }));
32 }));
33 },
34
35 function updatePinned() {
36 // A helper function that (un)pins a tab and verifies that both the callback
37 // and the chrome.tabs.onUpdated event listeners are called.
38 var pinTab = function(id, pinnedState, callback) {
39 var onUpdatedCompleted = chrome.test.listenForever(
40 chrome.tabs.onUpdated,
41 function(tabId, changeInfo, tab) {
42 if ('pinned' in changeInfo) {
43 assertEq(tabId, id);
44 assertEq(pinnedState, tab.pinned);
45 onUpdatedCompleted();
46 if (callback)
47 callback(tab);
48 }
49 }
50 );
51 chrome.tabs.update(id, { "pinned": pinnedState }, pass(function(tab) {
52 assertEq(pinnedState, tab.pinned);
53 }));
54 };
55
56 // We pin and unpin these tabs because the TabStripModelObserver used to
57 // have multiple notification code paths depending on the tab moves as a
58 // result of being pinned or unpinned.
59 // This works as follows:
60 // 1. Pin first tab (does not move, pinning)
61 // 2. Pin 3rd tab (moves to 2nd tab, pinning)
62 // 3. Unpin 1st tab (moves to 2nd tab, unpinning)
63 // 4. Unpin (new) 1st tab (does not move. unpinning)
64 chrome.tabs.getAllInWindow(firstWindowId,
65 pass(function(tabs) {
66 assertEq(tabs.length, 3);
67 for (var i = 0; i < tabs.length; i++)
68 assertEq(false, tabs[i].pinned);
69
70 pinTab(tabs[0].id, true, function(tab) {
71 assertEq(tabs[0].index, tab.index);
72 pinTab(tabs[2].id, true, function(tab) {
73 assertEq(1, tab.index);
74 pinTab(tabs[0].id, false, function(tab) {
75 assertEq(1, tab.index);
76 pinTab(tabs[2].id, false, function (tab) {
77 assertEq(0, tab.index);
78 });
79 });
80 });
81 });
82 }));
83 }
84 ]);
85 </script>
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/tabs/basics/move.js ('k') | chrome/test/data/extensions/api_test/tabs/basics/pinned.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698