Bug 655240 - Trying to fix intermittent failure in content/html/document/test/test_bug448564.html f=ehsan r=sicking
authorMounir Lamouri <mounir.lamouri@gmail.com>
Thu, 23 Jun 2011 12:03:18 +0200
changeset 71861 e00de9b8df15e5e2a5ea4a92c4e09ad044e15815
parent 71860 c70b05ca6e880a0e9c93154b5909018575df795b
child 71862 c931c8b1d8f623693c4d630777a63447cd7de417
child 71879 ed60c3abdb71e54383257e8ff16bd1a69c295377
push id209
push userbzbarsky@mozilla.com
push dateTue, 05 Jul 2011 17:42:16 +0000
treeherdermozilla-aurora@cc6e30cce8af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs655240, 448564
milestone7.0a1
Bug 655240 - Trying to fix intermittent failure in content/html/document/test/test_bug448564.html f=ehsan r=sicking
content/html/document/test/bug448564-echo.sjs
content/html/document/test/test_bug448564.html
--- a/content/html/document/test/bug448564-echo.sjs
+++ b/content/html/document/test/bug448564-echo.sjs
@@ -1,8 +1,6 @@
 function handleRequest(request, response) {
   response.setHeader("Cache-Control", "no-cache", false);
   response.setStatusLine(request.httpVersion, 200, "OK");
-  
-  response.write("<script>");
-  response.write("  parent.checkQueryString('" + request.queryString + "');");
-  response.write("</script>");
+
+  response.write(request.queryString);
 }
--- a/content/html/document/test/test_bug448564.html
+++ b/content/html/document/test/test_bug448564.html
@@ -3,61 +3,52 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=448564
 -->
 <head>
   <title>Test for Bug 448564</title>
   <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-  
-  <script type="text/javascript;version=1.8">
-    var toCheck = [];
-
-    function flush() {
-      if (!check)
-        return;
-
-      for each (let qs in toCheck)
-        check(qs);
-
-      toCheck.length = 0;
-    }
-
-    function checkQueryString(queryString) {
-      toCheck.push(queryString);
-      flush();
-    }
-  </script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=448564">Mozilla Bug 448564</a>
 <p id="display">
   <iframe src="bug448564-iframe-1.html"></iframe>
   <iframe src="bug448564-iframe-2.html"></iframe>
   <iframe src="bug448564-iframe-3.html"></iframe>
 </p>
 <div id="content" style="display: none">
-  
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 448564 **/
 
-var checksToDo = document.getElementsByTagName("iframe").length;
+/**
+ * The three iframes are going to be loaded with some dirty constructed forms.
+ * Each of them will be submitted before the load event and a SJS will replace
+ * the frame content with the query string.
+ * Then, on the load event, our test file will check the content of each iframes
+ * and check if the query string were correctly formatted (implying that all
+ * iframes were correctly submitted.
+ */
 
-function check(queryString) {
+function checkQueryString(frame) {
+  var queryString = frame.document.body.textContent;
   is(queryString.split("&").sort().join("&"),
      "a=aval&b=bval&c=cval&d=dval",
      "Not all form fields were properly submitted.");
-  if (--checksToDo == 0)
-    SimpleTest.finish();
 }
 
-flush();
+SimpleTest.waitForExplicitFinish();
 
-SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+  checkQueryString(frames[0]);
+  checkQueryString(frames[1]);
+  checkQueryString(frames[2]);
+  SimpleTest.finish();
+});
 
 </script>
 </pre>
 </body>
 </html>