Bug 691601 - Update tests. r=felipe
authorJim Mathies <jmathies@mozilla.com>
Thu, 21 Aug 2014 10:42:42 -0500
changeset 200848 d870412529127feda45d2b2f64cbde970713ae10
parent 200847 82d1a1b7e098311f92cf56547d95e8eb18fee269
child 200849 359dfa6e087802ff51480cb806c6b81039cab9e4
push id48012
push userjmathies@mozilla.com
push dateThu, 21 Aug 2014 15:43:11 +0000
treeherdermozilla-inbound@d87041252912 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe
bugs691601
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 691601 - Update tests. r=felipe
browser/base/content/test/general/browser_bug561636.js
browser/base/content/test/general/browser_bug595507.js
--- a/browser/base/content/test/general/browser_bug561636.js
+++ b/browser/base/content/test/general/browser_bug561636.js
@@ -24,16 +24,32 @@ function checkPopupMessage(doc)
 let gObserver = {
   QueryInterface : XPCOMUtils.generateQI([Ci.nsIFormSubmitObserver]),
 
   notifyInvalidSubmit : function (aFormElement, aInvalidElements)
   {
   }
 };
 
+function getDocHeader()
+{
+  return "data:text/html,<html><head><meta charset='utf-8'></head><body>" + getEmptyFrame();
+}
+ 
+function getDocFooter()
+{
+  return "</body></html>";
+}
+ 
+function getEmptyFrame()
+{
+  return "<iframe style='width:100px; height:30px; margin:3px; border:1px solid lightgray;' " +
+         "name='t' srcdoc=\"<html><head><meta charset='utf-8'></head><body>form target</body></html>\"></iframe>";
+}
+
 var testId = -1;
 
 function nextTest()
 {
   testId++;
   if (testId >= tests.length) {
     finish();
     return;
@@ -49,17 +65,17 @@ function test()
 
 var tests = [
 
 /**
  * In this test, we check that no popup appears if the form is valid.
  */
 function()
 {
-  let uri = "data:text/html,<html><body><iframe name='t'></iframe><form target='t' action='data:text/html,'><input><input id='s' type='submit'></form></body></html>";
+  let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input><input id='s' type='submit'></form>" + getDocFooter();
   let tab = gBrowser.addTab();
 
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
     let doc = gBrowser.contentDocument;
 
     doc.getElementById('s').click();
 
@@ -77,17 +93,17 @@ function()
 },
 
 /**
  * In this test, we check that, when an invalid form is submitted,
  * the invalid element is focused and a popup appears.
  */
 function()
 {
-  let uri = "data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input required id='i'><input id='s' type='submit'></form>";
+  let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input required id='i'><input id='s' type='submit'></form>" + getDocFooter();
   let tab = gBrowser.addTab();
 
   gInvalidFormPopup.addEventListener("popupshown", function() {
     gInvalidFormPopup.removeEventListener("popupshown", arguments.callee, false);
 
     let doc = gBrowser.contentDocument;
     is(doc.activeElement, doc.getElementById('i'),
        "First invalid element should be focused");
@@ -97,31 +113,32 @@ function()
 
     // Clean-up and next test.
     gBrowser.removeTab(gBrowser.selectedTab);
     nextTest();
   }, false);
 
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
-
-    gBrowser.contentDocument.getElementById('s').click();
+    executeSoon(function() {
+      gBrowser.contentDocument.getElementById('s').click();
+    });
   }, true);
 
   gBrowser.selectedTab = tab;
   gBrowser.selectedTab.linkedBrowser.loadURI(uri);
 },
 
 /**
  * In this test, we check that, when an invalid form is submitted,
  * the first invalid element is focused and a popup appears.
  */
 function()
 {
-  let uri = "data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input><input id='i' required><input required><input id='s' type='submit'></form>";
+  let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input><input id='i' required><input required><input id='s' type='submit'></form>" + getDocFooter();
   let tab = gBrowser.addTab();
 
   gInvalidFormPopup.addEventListener("popupshown", function() {
     gInvalidFormPopup.removeEventListener("popupshown", arguments.callee, false);
 
     let doc = gBrowser.contentDocument;
     is(doc.activeElement, doc.getElementById('i'),
        "First invalid element should be focused");
@@ -131,31 +148,32 @@ function()
 
     // Clean-up and next test.
     gBrowser.removeTab(gBrowser.selectedTab);
     nextTest();
   }, false);
 
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
-
-    gBrowser.contentDocument.getElementById('s').click();
+    executeSoon(function() {
+      gBrowser.contentDocument.getElementById('s').click();
+    });
   }, true);
 
   gBrowser.selectedTab = tab;
   gBrowser.selectedTab.linkedBrowser.loadURI(uri);
 },
 
 /**
  * In this test, we check that, we hide the popup by interacting with the
  * invalid element if the element becomes valid.
  */
 function()
 {
-  let uri = "data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>";
+  let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter();
   let tab = gBrowser.addTab();
 
   gInvalidFormPopup.addEventListener("popupshown", function() {
     gInvalidFormPopup.removeEventListener("popupshown", arguments.callee, false);
 
     let doc = gBrowser.contentDocument;
     is(doc.activeElement, doc.getElementById('i'),
        "First invalid element should be focused");
@@ -171,31 +189,32 @@ function()
       // Clean-up and next test.
       gBrowser.removeTab(gBrowser.selectedTab);
       nextTest();
     });
   }, false);
 
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
-
-    gBrowser.contentDocument.getElementById('s').click();
+    executeSoon(function() {
+      gBrowser.contentDocument.getElementById('s').click();
+    });
   }, true);
 
   gBrowser.selectedTab = tab;
   gBrowser.selectedTab.linkedBrowser.loadURI(uri);
 },
 
 /**
  * In this test, we check that, we don't hide the popup by interacting with the
  * invalid element if the element is still invalid.
  */
 function()
 {
-  let uri = "data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input type='email' id='i' required><input id='s' type='submit'></form>";
+  let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input type='email' id='i' required><input id='s' type='submit'></form>" + getDocFooter();
   let tab = gBrowser.addTab();
 
   gInvalidFormPopup.addEventListener("popupshown", function() {
     gInvalidFormPopup.removeEventListener("popupshown", arguments.callee, false);
 
     let doc = gBrowser.contentDocument;
     is(doc.activeElement, doc.getElementById('i'),
        "First invalid element should be focused");
@@ -211,31 +230,32 @@ function()
       // Clean-up and next test.
       gBrowser.removeTab(gBrowser.selectedTab);
       nextTest();
     });
   }, false);
 
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
-
-    gBrowser.contentDocument.getElementById('s').click();
+    executeSoon(function() {
+      gBrowser.contentDocument.getElementById('s').click();
+    });
   }, true);
 
   gBrowser.selectedTab = tab;
   gBrowser.selectedTab.linkedBrowser.loadURI(uri);
 },
 
 /**
  * In this test, we check that we can hide the popup by blurring the invalid
  * element.
  */
 function()
 {
-  let uri = "data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>";
+  let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter();
   let tab = gBrowser.addTab();
 
   gInvalidFormPopup.addEventListener("popupshown", function() {
     gInvalidFormPopup.removeEventListener("popupshown", arguments.callee, false);
 
     let doc = gBrowser.contentDocument;
     is(doc.activeElement, doc.getElementById('i'),
        "First invalid element should be focused");
@@ -251,30 +271,31 @@ function()
       // Clean-up and next test.
       gBrowser.removeTab(gBrowser.selectedTab);
       nextTest();
     });
   }, false);
 
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
-
-    gBrowser.contentDocument.getElementById('s').click();
+    executeSoon(function() {
+      gBrowser.contentDocument.getElementById('s').click();
+    });
   }, true);
 
   gBrowser.selectedTab = tab;
   gBrowser.selectedTab.linkedBrowser.loadURI(uri);
 },
 
 /**
  * In this test, we check that we can hide the popup by pressing TAB.
  */
 function()
 {
-  let uri = "data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>";
+  let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter();
   let tab = gBrowser.addTab();
 
   gInvalidFormPopup.addEventListener("popupshown", function() {
     gInvalidFormPopup.removeEventListener("popupshown", arguments.callee, false);
 
     let doc = gBrowser.contentDocument;
     is(doc.activeElement, doc.getElementById('i'),
        "First invalid element should be focused");
@@ -290,30 +311,31 @@ function()
       // Clean-up and next test.
       gBrowser.removeTab(gBrowser.selectedTab);
       nextTest();
     });
   }, false);
 
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
-
-    gBrowser.contentDocument.getElementById('s').click();
+    executeSoon(function() {
+      gBrowser.contentDocument.getElementById('s').click();
+    });
   }, true);
 
   gBrowser.selectedTab = tab;
   gBrowser.selectedTab.linkedBrowser.loadURI(uri);
 },
 
 /**
  * In this test, we check that the popup will hide if we move to another tab.
  */
 function()
 {
-  let uri = "data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>";
+  let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter();
   let tab = gBrowser.addTab();
 
   gInvalidFormPopup.addEventListener("popupshown", function() {
     gInvalidFormPopup.removeEventListener("popupshown", arguments.callee, false);
 
     let doc = gBrowser.contentDocument;
     is(doc.activeElement, doc.getElementById('i'),
        "First invalid element should be focused");
@@ -331,40 +353,44 @@ function()
       gBrowser.removeTab(gBrowser.selectedTab);
       gBrowser.removeTab(gBrowser.selectedTab);
       nextTest();
     });
   }, false);
 
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
-
-    gBrowser.contentDocument.getElementById('s').click();
+    executeSoon(function() {
+      gBrowser.contentDocument.getElementById('s').click();
+    });
   }, true);
 
   gBrowser.selectedTab = tab;
   gBrowser.selectedTab.linkedBrowser.loadURI(uri);
 },
 
 /**
- * In this test, we check that nothing happen (no focus nor popup) if the
- * invalid form is submitted in another tab than the current focused one
- * (submitted in background).
+ * In this test, we check that nothing happen if the invalid form is
+ * submitted in a background tab.
  */
+
 function()
 {
-  let uri = "data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>";
+  // Observers don't propagate currently across processes. We may add support for this in the
+  // future via the addon compat layer.
+  if (gBrowser.isRemoteBrowser) {
+    nextTest();
+    return;
+  }
+
+  let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter();
   let tab = gBrowser.addTab();
 
   gObserver.notifyInvalidSubmit = function() {
     executeSoon(function() {
-      let doc = tab.linkedBrowser.contentDocument;
-      isnot(doc.activeElement, doc.getElementById('i'),
-            "We should not focus the invalid element when the form is submitted in background");
-
       checkPopupHide();
 
       // Clean-up
       Services.obs.removeObserver(gObserver, "invalidformsubmit");
       gObserver.notifyInvalidSubmit = function () {};
       gBrowser.removeTab(tab);
 
       nextTest();
@@ -376,29 +402,31 @@ function()
   tab.linkedBrowser.addEventListener("load", function(e) {
     // Ignore load events from the iframe.
     if (tab.linkedBrowser.contentDocument == e.target) {
       let browser = e.currentTarget;
       browser.removeEventListener("load", arguments.callee, true);
 
       isnot(gBrowser.selectedTab.linkedBrowser, browser,
             "This tab should have been loaded in background");
-      browser.contentDocument.getElementById('s').click();
+      executeSoon(function() {
+        browser.contentDocument.getElementById('s').click();
+      });
     }
   }, true);
 
   tab.linkedBrowser.loadURI(uri);
 },
 
 /**
  * In this test, we check that the author defined error message is shown.
  */
 function()
 {
-  let uri = "data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input x-moz-errormessage='foo' required id='i'><input id='s' type='submit'></form>";
+  let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input x-moz-errormessage='foo' required id='i'><input id='s' type='submit'></form>" + getDocFooter();
   let tab = gBrowser.addTab();
 
   gInvalidFormPopup.addEventListener("popupshown", function() {
     gInvalidFormPopup.removeEventListener("popupshown", arguments.callee, false);
 
     let doc = gBrowser.contentDocument;
     is(doc.activeElement, doc.getElementById('i'),
        "First invalid element should be focused");
@@ -410,30 +438,31 @@ function()
 
     // Clean-up and next test.
     gBrowser.removeTab(gBrowser.selectedTab);
     nextTest();
   }, false);
 
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
-
-    gBrowser.contentDocument.getElementById('s').click();
+    executeSoon(function() {
+      gBrowser.contentDocument.getElementById('s').click();
+    });
   }, true);
 
   gBrowser.selectedTab = tab;
   gBrowser.selectedTab.linkedBrowser.loadURI(uri);
 },
 
 /**
  * In this test, we check that the message is correctly updated when it changes.
  */
 function()
 {
-  let uri = "data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input type='email' required id='i'><input id='s' type='submit'></form>";
+  let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input type='email' required id='i'><input id='s' type='submit'></form>" + getDocFooter();
   let tab = gBrowser.addTab();
 
   gInvalidFormPopup.addEventListener("popupshown", function() {
     gInvalidFormPopup.removeEventListener("popupshown", arguments.callee, false);
 
     let doc = gBrowser.contentDocument;
     let input = doc.getElementById('i');
     is(doc.activeElement, input, "First invalid element should be focused");
@@ -458,17 +487,18 @@ function()
       });
     }, false);
 
     EventUtils.synthesizeKey('f', {});
   }, false);
 
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
-
-    gBrowser.contentDocument.getElementById('s').click();
+    executeSoon(function() {
+      gBrowser.contentDocument.getElementById('s').click();
+    });
   }, true);
 
   gBrowser.selectedTab = tab;
   gBrowser.selectedTab.linkedBrowser.loadURI(uri);
 },
 
 ];
--- a/browser/base/content/test/general/browser_bug595507.js
+++ b/browser/base/content/test/general/browser_bug595507.js
@@ -24,16 +24,17 @@ function test()
 
     // Clean-up and next test.
     gBrowser.removeTab(gBrowser.selectedTab, {animate: false});
     executeSoon(finish);
   }, false);
 
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
-
-    gBrowser.contentDocument.getElementsByTagName('iframe')[0].contentDocument
-      .getElementById('s').click();
+    executeSoon(function() {
+      gBrowser.contentDocument.getElementsByTagName('iframe')[0].contentDocument
+        .getElementById('s').click();
+    });
   }, true);
 
   gBrowser.selectedTab = tab;
   gBrowser.selectedTab.linkedBrowser.loadURI(uri);
 }