Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
fix bug 694806 - 19 of 21 tests pass for cfx test -f window-utils - b…
Browse files Browse the repository at this point in the history
…y waiting for the test window to be loaded/focused before running tests; r=@Gozala
  • Loading branch information
ochameau authored and mykmelez committed Nov 15, 2011
1 parent 6423793 commit 11adb5a
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions packages/test-harness/lib/run-tests.js
Expand Up @@ -68,13 +68,31 @@ function runTests(iterations, filter, profileMemory, verbose, rootPaths, exit, p
}
};

harness.runTests({iterations: iterations,
filter: filter,
profileMemory: profileMemory,
verbose: verbose,
rootPaths: rootPaths,
print: print,
onDone: onDone});
// We have to wait for this window to be fully loaded *and* focused
// in order to avoid it to mess with our various window/focus tests.
// We are first waiting for our window to be fully loaded before ensuring
// that it will take the focus, and then we wait for it to be focused.
window.addEventListener("load", function onload() {
window.removeEventListener("load", onload, true);

window.addEventListener("focus", function onfocus() {
window.removeEventListener("focus", onfocus, true);
// Finally, we have to run test on next cycle, otherwise XPCOM components
// are not correctly updated.
// For ex: nsIFocusManager.getFocusedElementForWindow may throw
// NS_ERROR_ILLEGAL_VALUE exception.
require("timer").setTimeout(function () {
harness.runTests({iterations: iterations,
filter: filter,
profileMemory: profileMemory,
verbose: verbose,
rootPaths: rootPaths,
print: print,
onDone: onDone});
}, 0);
}, true);
window.focus();
}, true);
}

function printFailedTests(tests, verbose, print) {
Expand Down

0 comments on commit 11adb5a

Please sign in to comment.