Experimental changes to randomly failing sessionstore browser tests (will backout if noting changes)
authorMarco Bonardo <mbonardo@mozilla.com>
Fri, 16 Oct 2009 15:19:51 +0200
changeset 33911 af0ade2a9a1d4c105242453a12a164f37e6329cb
parent 33910 1917a92c3a7c7e6b2815cb57a9c7d20e346cfe46
child 33912 50a858927fad21de3a85e9d626d9f0d4350961cc
push idunknown
push userunknown
push dateunknown
milestone1.9.3a1pre
Experimental changes to randomly failing sessionstore browser tests (will backout if noting changes)
browser/components/sessionstore/test/browser/browser_394759_privatebrowsing.js
browser/components/sessionstore/test/browser/browser_459906.js
browser/components/sessionstore/test/browser/browser_461743.js
--- a/browser/components/sessionstore/test/browser/browser_394759_privatebrowsing.js
+++ b/browser/components/sessionstore/test/browser/browser_394759_privatebrowsing.js
@@ -87,19 +87,20 @@ function test() {
   let uniqueKey_B = "bug 394759 PB";
   let uniqueValue_B = "uniq" + Date.now();
 
 
   // Open a window
   let newWin = openDialog(location, "_blank", "chrome,all,dialog=no", testURL_A);
   newWin.addEventListener("load", function(aEvent) {
     newWin.removeEventListener("load", arguments.callee, false);
-    newWin.gBrowser.addEventListener("load", function(aEvent) {
-      newWin.gBrowser.removeEventListener("load", arguments.callee, true);
-      info("Window has been loaded");
+    info("New window has been opened");
+    newWin.gBrowser.addEventListener("pageshow", function(aEvent) {
+      newWin.gBrowser.removeEventListener("pageshow", arguments.callee, true);
+      info("Content has been loaded");
       executeSoon(function() {
         newWin.gBrowser.addTab();
         executeSoon(function() {
           // mark the window with some unique data to be restored later on
           ss.setWindowValue(newWin, uniqueKey_A, uniqueValue_A);
 
           newWin.close();
 
@@ -121,18 +122,18 @@ function test() {
              "Recently Closed Windows are removed when entering Private Browsing");
           is(ss.getClosedWindowData(), "[]",
              "Recently Closed Windows data is cleared when entering Private Browsing");
 
           // open another window in PB
           let pbWin = openDialog(location, "_blank", "chrome,all,dialog=no", testURL_B);
           pbWin.addEventListener("load", function(aEvent) {
             pbWin.removeEventListener("load", arguments.callee, false);
-            pbWin.gBrowser.addEventListener("load", function(aEvent) {
-              pbWin.gBrowser.removeEventListener("load", arguments.callee, true);
+            pbWin.gBrowser.addEventListener("pageshow", function(aEvent) {
+              pbWin.gBrowser.removeEventListener("pageshow", arguments.callee, true);
 
               executeSoon(function() {
                 // Add another tab, though it's not strictly needed
                 pbWin.gBrowser.addTab();
                 executeSoon(function() {
                   // mark the window with some unique data to be restored later on
                   ss.setWindowValue(pbWin, uniqueKey_B, uniqueValue_B);
 
--- a/browser/components/sessionstore/test/browser/browser_459906.js
+++ b/browser/components/sessionstore/test/browser/browser_459906.js
@@ -51,40 +51,42 @@ function test() {
       return;
     this.removeEventListener("load", arguments.callee, true);
     
     let iframes = tab.linkedBrowser.contentWindow.frames;
     iframes[1].document.body.innerHTML = uniqueValue;
     
     frameCount = 0;
     let tab2 = gBrowser.duplicateTab(tab);
-    tab2.linkedBrowser.addEventListener("load", function(aEvent) {
-      // wait for all frames to load (and reload!) completely
-      if (frameCount++ < 2)
-        return;
-      this.removeEventListener("load", arguments.callee, true);
-
-      let maxWait = Date.now() + 1000;
-      executeSoon(function() {
-        let iframes = tab2.linkedBrowser.contentWindow.frames;
-        if (iframes[1].document.body.innerHTML != uniqueValue && Date.now() < maxWait) {
-          executeSoon(arguments.callee);
+    executeSoon(function() {
+      tab2.linkedBrowser.addEventListener("load", function(aEvent) {
+        // wait for all frames to load (and reload!) completely
+        if (frameCount++ < 2)
           return;
-        }
-        is(iframes[1].document.body.innerHTML, uniqueValue,
-           "rich textarea's content correctly duplicated");
-        
-        let innerDomain = null;
-        try {
-          innerDomain = iframes[0].document.domain;
-        }
-        catch (ex) { /* throws for chrome: documents */ }
-        is(innerDomain, "localhost", "XSS exploit prevented!");
-        
-        // clean up
-        gBrowser.removeTab(tab2);
-        gBrowser.removeTab(tab);
-        
-        finish();
-      });
-    }, true);
+        this.removeEventListener("load", arguments.callee, true);
+
+        let maxWait = Date.now() + 1000;
+        executeSoon(function() {
+          let iframes = tab2.linkedBrowser.contentWindow.frames;
+          if (iframes[1].document.body.innerHTML != uniqueValue && Date.now() < maxWait) {
+            executeSoon(arguments.callee);
+            return;
+          }
+          is(iframes[1].document.body.innerHTML, uniqueValue,
+             "rich textarea's content correctly duplicated");
+          
+          let innerDomain = null;
+          try {
+            innerDomain = iframes[0].document.domain;
+          }
+          catch (ex) { /* throws for chrome: documents */ }
+          is(innerDomain, "localhost", "XSS exploit prevented!");
+          
+          // clean up
+          gBrowser.removeTab(tab2);
+          gBrowser.removeTab(tab);
+          
+          finish();
+        });
+      }, true);
+    });
   }, true);
 }
--- a/browser/components/sessionstore/test/browser/browser_461743.js
+++ b/browser/components/sessionstore/test/browser/browser_461743.js
@@ -42,28 +42,30 @@ function test() {
   let testURL = "http://localhost:8888/browser/" +
     "browser/components/sessionstore/test/browser/browser_461743_sample.html";
   
   let tab = gBrowser.addTab(testURL);
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     this.removeEventListener("load", arguments.callee, true);
     executeSoon(function() {
       let tab2 = gBrowser.duplicateTab(tab);
-      tab2.linkedBrowser.addEventListener("461743", function(aEvent) {
-        tab2.linkedBrowser.removeEventListener("461743", arguments.callee, true);
-        is(aEvent.data, "done", "XSS injection was attempted");
-        
-        executeSoon(function() {
-          let iframes = tab2.linkedBrowser.contentWindow.frames;
-          let innerHTML = iframes[1].document.body.innerHTML;
-          isnot(innerHTML, Components.utils.reportError.toString(),
-                "chrome access denied!");
+      executeSoon(function() {
+        tab2.linkedBrowser.addEventListener("461743", function(aEvent) {
+          tab2.linkedBrowser.removeEventListener("461743", arguments.callee, true);
+          is(aEvent.data, "done", "XSS injection was attempted");
           
-          // clean up
-          gBrowser.removeTab(tab2);
-          gBrowser.removeTab(tab);
-          
-          finish();
-        });
-      }, true, true);
+          executeSoon(function() {
+            let iframes = tab2.linkedBrowser.contentWindow.frames;
+            let innerHTML = iframes[1].document.body.innerHTML;
+            isnot(innerHTML, Components.utils.reportError.toString(),
+                  "chrome access denied!");
+            
+            // clean up
+            gBrowser.removeTab(tab2);
+            gBrowser.removeTab(tab);
+            
+            finish();
+          });
+        }, true, true);
+      });
     });
   }, true);
 }