Bug 1462983: Check for redundant "loaded" messages from opened window, in test_bug607529.html. r=bz

Such messages happen intermittently on Android, presumably from bfcache being
purged due to memory pressure (which would then cause the back() operation
behave like a fresh load).  So on Android, we'll now treat these redundant
messages as a "todo()" failure, to indicate that something went wrong but avoid
turning the testsuite orange.

MozReview-Commit-ID: GkaxB06vL7q

--HG--
extra : rebase_source : 64c0c0a41452d573062774b2300a26aad179b309
This commit is contained in:
Daniel Holbert 2018-07-13 08:38:52 -07:00
Родитель 2c005280e2
Коммит 76f667e72e
1 изменённых файлов: 27 добавлений и 9 удалений

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

@ -23,15 +23,35 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=607529
back, and verify that the animations are still running. */
var doneOneLoad = false;
var done = false;
/** Test for Bug 607529 **/
var done = false;
function closeWindowAndFinish() {
w.close();
window.onmessage = null;
SimpleTest.finish();
}
window.onmessage = function(e) {
isnot(e.data, "notcached", "Should never end up not being cached");
if (e.data == "loaded" && !doneOneLoad) {
doneOneLoad = true;
w.location = "file_bug607529-1.html";
if (e.data == "loaded") {
if (!doneOneLoad) {
doneOneLoad = true;
w.location = "file_bug607529-1.html";
} else {
// This is unexpected, but it can happen on Android, probably when
// bfcache gets purged due to memory pressure. Hence, "soft fail" there.
var message = "onload handler shouldn't fire on restore from bfcache";
if (navigator.appVersion.includes("Android")) {
todo(false, message);
} else {
ok(false, message);
}
// In any case, more messages aren't coming, so finish up.
closeWindowAndFinish();
}
}
else if (e.data == "goback") {
w.history.back();
@ -44,17 +64,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=607529
// more than one callbackHappened message before we manage to close it.
// Protect against calling SimpleTest.finish() more than once.
if (!done) {
w.close();
window.onmessage = null;
SimpleTest.finish();
closeWindowAndFinish();
done = true;
}
} else {
try {
var msg = JSON.parse(e.data);
} catch (ex) {
// Diagnostic for Bug 1462983: if JSON.parse throws, pause to print
// the string that it choked on, and then resume throwing the exception.
// In case JSON.parse throws, we pause to print the string that it
// choked on, and then resume throwing the exception.
ok(false, "JSON.parse threw, when passed string '" + e.data + "'");
throw ex;
}