mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-26 19:55:39 +00:00
9552c26f47
The mochitest-chrome harness sends a custom "contentEvent" event from redirect.html to a listener in browser-test.js. It is possible for redirect.html to be loaded and send contentEvent before the listener is set up in browser-test.js. In the absence of a better synchronization strategy, redirect.html now retries the send after a few seconds. If the first contentEvent was received, the second will be ignored; if the first contentEvent was not received, the second should avoid an intermittent harness hang and timeout.
42 lines
1.0 KiB
HTML
42 lines
1.0 KiB
HTML
<html>
|
|
<head>
|
|
<title>redirecting...</title>
|
|
|
|
<script type="text/javascript">
|
|
function redirect(aURL)
|
|
{
|
|
// We create a listener for this event in browser-test.js which will
|
|
// get picked up when specifying --flavor=chrome or --flavor=a11y
|
|
var event = new CustomEvent("contentEvent", {
|
|
bubbles: true,
|
|
detail: {
|
|
"data": aURL + location.search,
|
|
"type": "loadURI"
|
|
}
|
|
});
|
|
document.dispatchEvent(event);
|
|
}
|
|
|
|
function redirectToHarness()
|
|
{
|
|
redirect("chrome://mochikit/content/harness.xul");
|
|
}
|
|
|
|
function onLoad() {
|
|
// Wait for MozAfterPaint, since the listener in browser-test.js is not
|
|
// added until then.
|
|
window.addEventListener("MozAfterPaint", function() {
|
|
setTimeout(redirectToHarness, 0);
|
|
// In case the listener was not ready, try again after a few seconds.
|
|
setTimeout(redirectToHarness, 5000);
|
|
}, {once: true});
|
|
|
|
}
|
|
</script>
|
|
</head>
|
|
|
|
<body onload="onLoad();">
|
|
redirecting...
|
|
</body>
|
|
</html>
|