Bug 527099, use waitForFocus to wait for the frameset window

This commit is contained in:
Neil Deakin 2010-05-17 09:21:11 -04:00
Родитель 397561047a
Коммит 3384016566
2 изменённых файлов: 6 добавлений и 16 удалений

Просмотреть файл

@ -5,12 +5,10 @@
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
dump("frameset script parsed\n");
SimpleTest.waitForFocus(function () dump("focus on frameset occured\n"));
SimpleTest.waitForFocus(function () opener.framesetWindowLoaded(window));
</script>
<frameset rows="30%, 70%" onload="dump('frameset load ' + event.target.location + ' ' + window.location + '\n'); window.loaded = true; if (window.loaded === window.focused) opener.framesetWindowLoaded(window)"
onfocus="dump('frameset focus: ' + event.target.location + ' ' + window.location + '\n'); window.focused = true; if (window.loaded === window.focused) opener.framesetWindowLoaded(window)">
<frameset rows="30%, 70%">
<frame src="data:text/html,&lt;html id='f1' &gt;&lt;body id='framebody1'&gt;&lt;input id='f2'&gt;&lt;body&gt;&lt;/html&gt;">
<frameset cols="30%, 33%, 34%">
<frame src="data:text/html,&lt;html id='f3'&gt;&lt;body id='framebody2'&gt;&lt;input id='f4'&gt;&lt;body&gt;&lt;/html&gt;">

Просмотреть файл

@ -269,14 +269,6 @@ SimpleTest.waitForFocus = function (callback, targetWindow) {
(fm.focusedWindow ? "(" + fm.focusedWindow + ") " + fm.focusedWindow.location : "<no window focused>") +
" desired window: (" + targetWindow + ") " + targetWindow.location +
" docshell visible: " + baseWindow.visibility);
dump(prefix + " -- loaded: " + targetWindow.document.readyState +
" active window: " +
(fm.activeWindow ? "(" + fm.activeWindow + ") " + fm.activeWindow.location : "<no window active>") +
" focused window: " +
(fm.focusedWindow ? "(" + fm.focusedWindow + ") " + fm.focusedWindow.location : "<no window focused>") +
" desired window: (" + targetWindow + ") " + targetWindow.location +
" docshell visible: " + baseWindow.visibility);
}
debugFocusLog("before wait for focus");
@ -296,14 +288,14 @@ SimpleTest.waitForFocus = function (callback, targetWindow) {
SimpleTest["waitForFocus_" + event.type + "ed"] = true;
targetWindow.removeEventListener(event.type, waitForEvent, false);
if (event.type == "MozAfterPaint")
dump("MozAfterPaint event received");
SimpleTest.ok(true, "MozAfterPaint event received");
maybeRunTests();
}
// wait for the page to load if it hasn't already
SimpleTest.waitForFocus_loaded = (targetWindow.document.readyState == "complete");
if (!SimpleTest.waitForFocus_loaded) {
dump("must wait for load");
SimpleTest.ok(true, "must wait for load");
targetWindow.addEventListener("load", waitForEvent, false);
}
@ -315,12 +307,12 @@ SimpleTest.waitForFocus = function (callback, targetWindow) {
// if this is a child frame, ensure that the frame is focused
SimpleTest.waitForFocus_focused = (focusedWindow.value == targetWindow);
if (SimpleTest.waitForFocus_focused) {
dump("already focused");
SimpleTest.ok(true, "already focused");
// if the frame is already focused and loaded, call the callback directly
maybeRunTests();
}
else {
dump("must wait for focus");
SimpleTest.ok(true, "must wait for focus");
targetWindow.addEventListener("focus", waitForEvent, false);
targetWindow.focus();
}