bug 446346 - test_Microformats_count.html can fail sporadically with Error thrown during test: test_MicroformatsAPI is not defined - got 0, expected 1. fix the test to move the script block before an iframe whose onload calls a function from it. r=mkaply
bug 446346 - test_Microformats_count.html can fail sporadically with Error thrown during test: test_MicroformatsAPI is not defined - got 0, expected 1. fix the test to move the script block before an iframe whose onload calls a function from it. r=mkaply
--- a/toolkit/components/microformats/tests/test_Microformats_count.html
+++ b/toolkit/components/microformats/tests/test_Microformats_count.html
@@ -78,28 +78,19 @@
<abbr class="dtend" title="2005-10-08">7</abbr>,
at the <span class="location">Argent Hotel, San Francisco, CA</span>
</a>
</span>
</div>
</frame>
</frameset>
- <!-- Geo Fire the test from here so we know this is loaded at the outset -->
- <iframe src="geo.html" onload="test_MicroformatsAPI();">
- </iframe>
-
- <!-- adr -->
- <div class="adr" id="01-extended-address">
- <span class="extended-address">Park Bench</span>
- </div>
- <!-- Ok, the test, here we go -->
- <pre id="test">
+ <!-- Put the test code before the iframe just to be
+ extra-sure it's been evaluated before the iframe onload fires -->
<script class="testbody" type="text/javascript">
-
// Called from the onload of the iframe
function test_MicroformatsAPI() {
// I'm going to try to do this without getting XPConnect priv's, make sure
// we throw
try {
Components.utils.import("resource://gre/modules/Microformats.js");
ok(false, "Should not execute this code");
} catch(ex) {
@@ -146,10 +137,20 @@
is(count, 1, "One hCalendar");
count = Microformats.count("hCard",
document.getElementById("contentbody"),
{recurseExternalFrames: true});
is(count, 1, "One hCard");
}
</script>
+
+ <!-- Geo Fire the test from here so we know this is loaded at the outset -->
+ <iframe src="geo.html" onload="test_MicroformatsAPI();">
+ </iframe>
+
+ <!-- adr -->
+ <div class="adr" id="01-extended-address">
+ <span class="extended-address">Park Bench</span>
+ </div>
+
</body>
</html>