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
authorTed Mielczarek <ted.mielczarek@gmail.com>
Tue, 22 Jul 2008 16:28:47 -0400
changeset 16121 37f174b079502f575bc5c6defbf29620f07cf94e
parent 16120 4e82fbde25838c4bb5472cca47fa804ee220d34a
child 16122 5305b356a7b12c61d7b0896909c917b73dd6eae4
push idunknown
push userunknown
push dateunknown
reviewersmkaply
bugs446346
milestone1.9.1a1pre
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
toolkit/components/microformats/tests/test_Microformats_count.html
--- 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>