Replace timeouts by event listeners in test cases for bug 92473 and bug 134911

This commit is contained in:
Simon Montagu 2009-07-13 01:16:52 -07:00
parent c124a0981e
commit b8c1fb5700
2 changed files with 12 additions and 6 deletions

View File

@ -10,23 +10,26 @@ const enteredText2="\u03BE\u03B5\u03C3\u03BA\u03B5\u03C0\u03AC\u03B6\u03C9\u0020
var testPage;
function test() {
testPage = Application.activeWindow.open(url("chrome://mochikit/content/browser/docshell/test/browser/test-form_sjis.html"));
testPage = Application.activeWindow.open(url("about:blank"));
testPage.events.addListener("load", afterOpen);
testPage.load(url("chrome://mochikit/content/browser/docshell/test/browser/test-form_sjis.html"));
testPage.focus();
waitForExplicitFinish();
setTimeout(afterOpen, 1000);
}
function afterOpen() {
testPage.events.removeListener("load", afterOpen);
testPage.events.addListener("load", afterChangeCharset);
testPage.document.getElementById("testtextarea").value=enteredText1;
testPage.document.getElementById("testinput").value=enteredText2;
/* Force the page encoding to Shift_JIS */
SetForcedCharset("Shift_JIS");
setTimeout(afterChangeCharset, 3000);
}
function afterChangeCharset() {
testPage.events.removeListener("load", afterChangeCharset);
is(testPage.document.getElementById("testpar").innerHTML, rightText,
"encoding successfully changed");
is(testPage.document.getElementById("testtextarea").value, enteredText1,

View File

@ -25,15 +25,17 @@ function testContent(text) {
}
function afterOpen() {
testPage.events.removeListener("load", afterOpen);
testPage.events.addListener("load", afterChangeCharset);
/* Test that the content on load is the expected wrong decoding */
testContent(wrongText);
/* Force the page encoding to Shift_JIS */
SetForcedCharset("Shift_JIS");
setTimeout(afterChangeCharset, 3000);
}
function afterChangeCharset() {
testPage.events.removeListener("load", afterChangeCharset);
/* test that the content is decoded correctly */
testContent(rightText);
testPage.close();
@ -42,9 +44,10 @@ function afterChangeCharset() {
function test() {
var activeWin = Application.activeWindow;
testPage = activeWin.open(url("chrome://mochikit/content/browser/docshell/test/browser/test-form_sjis.html"));
testPage = activeWin.open(url("about:blank"));
testPage.events.addListener("load", afterOpen);
testPage.load(url("chrome://mochikit/content/browser/docshell/test/browser/test-form_sjis.html"));
testPage.focus();
waitForExplicitFinish();
setTimeout(afterOpen, 1000);
}