Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Namespace for test related things. | 6 * Namespace for test related things. |
| 7 */ | 7 */ |
| 8 var test = test || {}; | 8 var test = test || {}; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 background.appWindows[appId].contentWindow) { | 104 background.appWindows[appId].contentWindow) { |
| 105 callback(appId); | 105 callback(appId); |
| 106 return true; | 106 return true; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 return false; | 109 return false; |
| 110 }); | 110 }); |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 /** | 113 /** |
| 114 * Close the specified window and wait until it closes. | |
|
hirono
2014/03/04 09:14:13
nit: Closes
yoshiki
2014/03/05 02:24:44
Done.
| |
| 115 * | |
| 116 * @param {string} appId AppId of window to be closed. | |
| 117 * @param {function(boolean)} callback Completion callback with the result. True | |
| 118 * if success, false otherwise. | |
| 119 */ | |
| 120 test.util.async.closeWindow = function(appId, callback) { | |
| 121 if (appId in background.appWindows && | |
| 122 background.appWindows[appId].contentWindow) { | |
| 123 background.appWindows[appId].close(); | |
| 124 | |
| 125 test.util.repeatUntilTrue_(function() { | |
| 126 if (appId in background.appWindows) { | |
| 127 return false; | |
| 128 } else { | |
| 129 callback(true); | |
| 130 return true; | |
| 131 } | |
| 132 }); | |
| 133 } else { | |
| 134 callback(false); | |
| 135 } | |
| 136 }; | |
| 137 | |
| 138 /** | |
| 114 * Gets a document in the Files.app's window, including iframes. | 139 * Gets a document in the Files.app's window, including iframes. |
| 115 * | 140 * |
| 116 * @param {Window} contentWindow Window to be used. | 141 * @param {Window} contentWindow Window to be used. |
| 117 * @param {string=} opt_iframeQuery Query for the iframe. | 142 * @param {string=} opt_iframeQuery Query for the iframe. |
| 118 * @return {Document=} Returns the found document or undefined if not found. | 143 * @return {Document=} Returns the found document or undefined if not found. |
| 119 * @private | 144 * @private |
| 120 */ | 145 */ |
| 121 test.util.sync.getDocument_ = function(contentWindow, opt_iframeQuery) { | 146 test.util.sync.getDocument_ = function(contentWindow, opt_iframeQuery) { |
| 122 if (opt_iframeQuery) { | 147 if (opt_iframeQuery) { |
| 123 var iframe = contentWindow.document.querySelector(opt_iframeQuery); | 148 var iframe = contentWindow.document.querySelector(opt_iframeQuery); |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 906 return false; | 931 return false; |
| 907 } else { | 932 } else { |
| 908 console.error('Invalid function name.'); | 933 console.error('Invalid function name.'); |
| 909 return false; | 934 return false; |
| 910 } | 935 } |
| 911 }); | 936 }); |
| 912 }; | 937 }; |
| 913 | 938 |
| 914 // Register the test utils. | 939 // Register the test utils. |
| 915 test.util.registerRemoteTestUtils(); | 940 test.util.registerRemoteTestUtils(); |
| OLD | NEW |