Index: chrome/test/data/extensions/api_test/sessions/sessions.js |
diff --git a/chrome/test/data/extensions/api_test/sessions/sessions.js b/chrome/test/data/extensions/api_test/sessions/sessions.js |
index 431edbec72fb11ed0a052bebb3a721a68cc1e13f..4ad6f504aa43f98542e3fd18a28237684f381da3 100644 |
--- a/chrome/test/data/extensions/api_test/sessions/sessions.js |
+++ b/chrome/test/data/extensions/api_test/sessions/sessions.js |
@@ -59,6 +59,26 @@ function checkEntries(expectedEntries, actualEntries) { |
}); |
} |
+function checkOnChangedEvent(expectedCallbackCount) { |
+ var callbackCount = 0; |
+ var doneListening = chrome.test.listenForever( |
+ chrome.sessions.onChanged, |
not at google - send to devlin
2014/03/26 21:12:38
I keep reading this as a function body, because th
|
+ function() { |
+ callbackCount++; |
+ } |
+ ); |
+ |
+ var checkEvent = function() { |
+ if (callbackCount < expectedCallbackCount) |
+ window.setTimeout(checkEvent, 100); |
+ else { |
+ assertEq(callbackCount, expectedCallbackCount); |
+ doneListening(); |
+ } |
+ }; |
+ window.setTimeout(checkEvent, 1000); |
not at google - send to devlin
2014/03/26 21:12:38
It would be nice to notify the user why this test
|
+} |
+ |
chrome.test.runTests([ |
// After setupWindows |
// |
@@ -108,6 +128,8 @@ chrome.test.runTests([ |
function retrieveClosedTabs() { |
// Check that the recently closed list contains what we expect |
// after removing tabs. |
+ checkOnChangedEvent(2); |
+ |
callForEach( |
chrome.tabs.remove, |
firstWindowTabIds.slice(0, 2).reverse(), |
@@ -134,6 +156,8 @@ chrome.test.runTests([ |
function retrieveClosedWindows() { |
// Check that the recently closed list contains what we expect |
// after removing windows. |
+ checkOnChangedEvent(2); |
+ |
callForEach( |
chrome.windows.remove, |
windowIds.slice(1, 3).reverse(), |
@@ -197,6 +221,8 @@ chrome.test.runTests([ |
}, |
function restoreClosedTabs() { |
+ checkOnChangedEvent(2); |
+ |
chrome.windows.get(windowIds[0], {"populate": true}, |
callbackPass(function(win) { |
var tabCountBeforeRestore = win.tabs.length; |
@@ -219,6 +245,8 @@ chrome.test.runTests([ |
}, |
function restoreTabInClosedWindow() { |
+ checkOnChangedEvent(1); |
+ |
chrome.windows.getAll({"populate": true}, callbackPass(function(win) { |
var windowCountBeforeRestore = win.length; |
chrome.sessions.restore(recentlyClosedSecondWindowTabIds[0], |
@@ -237,6 +265,8 @@ chrome.test.runTests([ |
}, |
function restoreClosedWindows() { |
+ checkOnChangedEvent(1); |
+ |
chrome.windows.getAll({"populate": true}, callbackPass(function(win) { |
var windowCountBeforeRestore = win.length; |
chrome.sessions.restore(recentlyClosedWindowIds[0], |
@@ -285,6 +315,8 @@ chrome.test.runTests([ |
}, |
function restoreMostRecentEntry() { |
+ checkOnChangedEvent(1); |
+ |
chrome.windows.getAll({"populate": true}, callbackPass(function(win) { |
var windowCountBeforeRestore = win.length; |
chrome.sessions.restore(callbackPass(function(win_session) { |