@@ -175,11 +175,11 @@ TestCase {
175175
176176
177177 // Find an object with the given name in the children tree of "obj"
178− function findChild(obj, objectName) {
178+ function findChild(obj, objectName, timeout) {
179179 if (!obj)
180180 qtest_fail("no obj given", 1);
181181
182− return findChildIn(obj, "children", objectName);
182+ return findChildInWithTimeout(obj, "children", objectName);
183183 }
184184
185185 // Find an object with the given name in the children tree of "obj"
@@ -187,11 +187,32 @@ TestCase {
187187 // Note: you should use findChild if you're not sure you need this
188188 // as this tree is much bigger and might contain stuff that goes
189189 // away randomly.
190− function findInvisibleChild(obj, objectName) {
190+ function findInvisibleChild(obj, objectName, timeout) {
191191 if (!obj)
192192 qtest_fail("no obj given", 1);
193193
194− return findChildIn(obj, "data", objectName);
194+ return findChildInWithTimeout(obj, "data", objectName, timeout);
195+ }
196+
197+ // Find a child in the named property with timeout
198+ function findChildInWithTimeout(obj, prop, objectName, timeout) {
199+ if (!obj)
200+ qtest_fail("no obj given", 1);
201+
202+ var timeSpent = 0
203+ if (timeout === undefined)
204+ timeout = 5000;
205+
206+ var child = findChildIn(obj, prop, objectName);
207+
208+ while (timeSpent < timeout && !child) {
209+ child = findChildIn(obj, prop, objectName);
210+ if (!child) {
211+ wait(50)
212+ timeSpent += 50
213+ }
214+ }
215+ return child;
195216 }
196217
197218 // Find a child in the named property