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

Unified Diff: chrome/test/data/extensions/api_test/sessions/sessions.js

Issue 21022018: Sessions API - previously Session Restore API. Supports restoring currently open foreign windows an… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added assert true to test Created 7 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/sessions/sessions.js
diff --git a/chrome/test/data/extensions/api_test/session_restore/session_restore.js b/chrome/test/data/extensions/api_test/sessions/sessions.js
similarity index 82%
rename from chrome/test/data/extensions/api_test/session_restore/session_restore.js
rename to chrome/test/data/extensions/api_test/sessions/sessions.js
index 2869c8007f6c5c4bb11645df886b06c1456e9671..363fd924ff0594a74e19fc025ac4f3bd3399740d 100644
--- a/chrome/test/data/extensions/api_test/session_restore/session_restore.js
+++ b/chrome/test/data/extensions/api_test/sessions/sessions.js
@@ -66,14 +66,14 @@ chrome.test.runTests([
// Window2: a,b
// Window3: a,b
//
- // After retriveClosedTabs:
+ // After retrieveClosedTabs:
//
// Window1: c
// Window2: a,b
// Window3: a,b
// ClosedList: a,b
//
- // After retriveClosedWindows:
+ // After retrieveClosedWindows:
//
// Window1: c
// ClosedList: Window2,Window3,a,b
@@ -114,7 +114,7 @@ chrome.test.runTests([
function each() {
},
function done() {
- chrome.sessionRestore.getRecentlyClosed(
+ chrome.sessions.getRecentlyClosed(
{maxResults: 2, entryType: "tab"},
callbackPass(function(entries) {
var expectedEntries = [
@@ -123,7 +123,7 @@ chrome.test.runTests([
];
checkEntries(expectedEntries, entries);
entries.forEach(function(entry) {
- recentlyClosedTabIds.push(entry.id);
+ recentlyClosedTabIds.push(entry.tab.sessionId);
});
})
);
@@ -140,7 +140,7 @@ chrome.test.runTests([
function each() {
},
function done() {
- chrome.sessionRestore.getRecentlyClosed(
+ chrome.sessions.getRecentlyClosed(
{maxResults: 2, entryType: "window"},
callbackPass(function(entries) {
var expectedEntries = [
@@ -149,10 +149,10 @@ chrome.test.runTests([
];
checkEntries(expectedEntries, entries);
entries[0].window.tabs.forEach(function(tab) {
- recentlyClosedSecondWindowTabIds.push(tab.id);
+ recentlyClosedSecondWindowTabIds.push(tab.sessionId);
});
entries.forEach(function(entry) {
- recentlyClosedWindowIds.push(entry.id);
+ recentlyClosedWindowIds.push(entry.window.sessionId);
});
})
);
@@ -163,7 +163,7 @@ chrome.test.runTests([
function retrieveClosedEntries() {
// Check that the recently closed list contains what we expect
// after removing tabs and windows.
- chrome.sessionRestore.getRecentlyClosed(
+ chrome.sessions.getRecentlyClosed(
callbackPass(function(entries) {
var expectedEntries = [
{ window: { tabsLength: 2 } },
@@ -181,7 +181,7 @@ chrome.test.runTests([
function retrieveMaxEntries() {
// Check that the recently closed list contains what we expect
// after removing tabs and windows.
- chrome.sessionRestore.getRecentlyClosed({maxResults: 25},
+ chrome.sessions.getRecentlyClosed({maxResults: 25},
callbackPass(function(entries) {
var expectedEntries = [
{ window: { tabsLength: 2 } },
@@ -200,21 +200,19 @@ chrome.test.runTests([
chrome.windows.get(windowIds[0], {"populate": true},
callbackPass(function(win) {
var tabCountBeforeRestore = win.tabs.length;
- callForEach(
- chrome.sessionRestore.restore,
- recentlyClosedTabIds.slice(0, 2),
- function each() {
- },
- function done() {
- chrome.windows.get(windowIds[0], {"populate": true},
- callbackPass(function(win){
- assertEq(tabCountBeforeRestore + 2, win.tabs.length);
- win.tabs.forEach(function(tab, i) {
- assertEq(pages[i++], tab.url);
- });
- })
- );
- }
+ chrome.sessions.restore(recentlyClosedTabIds[0], function(tab) {
+ assertEq(pages[0], tab.url);
+ });
+ chrome.sessions.restore(recentlyClosedTabIds[1], function(tab) {
+ assertEq(pages[1], tab.url);
+ });
+ chrome.windows.get(windowIds[0], {"populate": true},
+ callbackPass(function(win){
+ assertEq(tabCountBeforeRestore + 2, win.tabs.length);
+ win.tabs.forEach(function(tab, i) {
+ assertEq(pages[i++], tab.url);
+ });
+ })
);
})
);
@@ -223,8 +221,9 @@ chrome.test.runTests([
function restoreTabInClosedWindow() {
chrome.windows.getAll({"populate": true}, callbackPass(function(win) {
var windowCountBeforeRestore = win.length;
- chrome.sessionRestore.restore(recentlyClosedSecondWindowTabIds[0],
- callbackPass(function() {
+ chrome.sessions.restore(recentlyClosedSecondWindowTabIds[0],
+ callbackPass(function(tab) {
+ assertEq(pages[0], tab.url);
chrome.windows.getAll({"populate": true},
callbackPass(function(win) {
assertEq(windowCountBeforeRestore + 1, win.length);
@@ -240,26 +239,23 @@ chrome.test.runTests([
function restoreClosedWindows() {
chrome.windows.getAll({"populate": true}, callbackPass(function(win) {
var windowCountBeforeRestore = win.length;
- callForEach(
- chrome.sessionRestore.restore,
- recentlyClosedWindowIds.slice(0, 1),
- function each() {
- },
- function done() {
- chrome.windows.getAll({"populate": true},
- callbackPass(function(win) {
- assertEq(windowCountBeforeRestore + 1, win.length);
- })
- );
- }
- );
+ chrome.sessions.restore(recentlyClosedWindowIds[0], function(window) {
+ assertEq(1, window.tabs.length);
+ });
+ function done() {
+ chrome.windows.getAll({"populate": true},
+ callbackPass(function(win) {
+ assertEq(windowCountBeforeRestore + 1, win.length);
+ })
+ );
+ }
}));
},
function restoreSameEntryTwice() {
chrome.windows.getAll({"populate": true}, callbackPass(function(win) {
var windowCountBeforeRestore = win.length;
- chrome.sessionRestore.restore(recentlyClosedWindowIds[0],
+ chrome.sessions.restore(recentlyClosedWindowIds[0],
callbackFail("Invalid session id.", function() {
chrome.windows.getAll({"populate": true},
callbackPass(function(win) {
@@ -274,7 +270,7 @@ chrome.test.runTests([
function restoreInvalidEntries() {
chrome.windows.getAll({"populate": true}, callbackPass(function(win) {
var windowCountBeforeRestore = win.length;
- chrome.sessionRestore.restore(-1,
+ chrome.sessions.restore("-1",
callbackFail("Invalid session id.", function() {
chrome.windows.getAll({"populate": true},
callbackPass(function(win) {
@@ -289,7 +285,8 @@ chrome.test.runTests([
function restoreMostRecentEntry() {
chrome.windows.getAll({"populate": true}, callbackPass(function(win) {
var windowCountBeforeRestore = win.length;
- chrome.sessionRestore.restore(callbackPass(function() {
+ chrome.sessions.restore(callbackPass(function(restoredWindow) {
+ assertEq(2, restoredWindow.tabs.length);
chrome.windows.getAll({"populate": true},
callbackPass(function(win) {
assertEq(windowCountBeforeRestore + 1, win.length);
@@ -302,7 +299,7 @@ chrome.test.runTests([
function checkRecentlyClosedListEmpty() {
chrome.windows.getAll({"populate": true}, callbackPass(function(win) {
var windowCountBeforeRestore = win.length;
- chrome.sessionRestore.restore(
+ chrome.sessions.restore(
callbackFail("There are no recently closed sessions.", function() {
chrome.windows.getAll({"populate": true},
callbackPass(function(win) {
@@ -313,5 +310,4 @@ chrome.test.runTests([
);
}));
}
-
]);

Powered by Google App Engine
This is Rietveld 408576698