Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/file_manager_browsertest/background.js |
| diff --git a/chrome/test/data/extensions/api_test/file_manager_browsertest/background.js b/chrome/test/data/extensions/api_test/file_manager_browsertest/background.js |
| index 33fd18e54d66a94b64ff7aa6d40a9eea551d7d18..e8775b3bacaed703b2d754a192c564cc739fa7b7 100644 |
| --- a/chrome/test/data/extensions/api_test/file_manager_browsertest/background.js |
| +++ b/chrome/test/data/extensions/api_test/file_manager_browsertest/background.js |
| @@ -115,8 +115,8 @@ function repeatUntil(checkFunction) { |
| /** |
| * Waits until a window having the given ID prefix appears. |
| - * @param {string} appIdPrefix ID prefix of the requested window. |
| - * @param {Promise} promise Promise to be fulfilled with a found window's ID. |
| + * @param {string} windowIdPrefix ID prefix of the requested window. |
| + * @return {Promise} promise Promise to be fulfilled with a found window's ID. |
| */ |
| function waitForWindow(windowIdPrefix) { |
| return repeatUntil(function() { |
| @@ -131,6 +131,41 @@ function waitForWindow(windowIdPrefix) { |
| } |
| /** |
| + * Closes a window and waits until the window is closed. |
| + * |
| + * @param {string} windowId ID of the window to close. |
| + * @return {Promise} promise Promise to be fulfilled with the result (true: |
| + * success, false: failed). |
| + */ |
| +function closeWindowAndWait(windowId) { |
| + // Closes the window. |
| + return callRemoteTestUtil('closeWindow', null, [windowId]).then( |
| + function(result) { |
| + // Returns false when the closing is failed. |
| + if (!result) |
| + return false; |
| + |
| + return repeatUntil(function() { |
| + return callRemoteTestUtil('getWindows', null, []).then( |
| + function(windows) { |
| + for (var id in windows) { |
| + if (id === windowId) { |
| + // Window is still available. Continues waiting. |
| + return pending('Window with the prefix ' + |
|
hirono
2014/03/05 03:55:14
nit: You can use %s format for the pending message
yoshiki
2014/03/05 04:23:02
Done.
|
| + windowId + |
| + ' is not found.'); |
| + } |
| + } |
| + // Window is not available. Closing is done successfully. |
| + return true; |
| + } |
| + ); |
| + }); |
| + } |
| + ); |
| +} |
| + |
| +/** |
| * Waits until the window turns to the given size. |
| * @param {string} windowId Target window ID. |
| * @param {number} width Requested width in pixels. |