bug 868886 fix intermittent test failure with socialmark tests, r=felipe
authorShane Caraveo <scaraveo@mozilla.com>
Tue, 07 May 2013 12:54:06 -0700
changeset 142237 14417f00ec418970b82851cb08daa66d67578dff
parent 142236 a23eea95bf64672dcab5fedfad76339028c9593b
child 142238 0182997de0f4ceecc99dfc1def129c88c5cca8db
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe
bugs868886
milestone23.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 868886 fix intermittent test failure with socialmark tests, r=felipe
browser/base/content/test/social/browser_social_markButton.js
--- a/browser/base/content/test/social/browser_social_markButton.js
+++ b/browser/base/content/test/social/browser_social_markButton.js
@@ -4,17 +4,17 @@
 
 let prefName = "social.enabled",
     gFinishCB;
 
 function test() {
   waitForExplicitFinish();
 
   // Need to load a http/https/ftp/ftps page for the social mark button to appear
-  let tab = gBrowser.selectedTab = gBrowser.addTab("https://example.com", {skipAnimation: true});
+  let tab = gBrowser.selectedTab = gBrowser.addTab("https://test1.example.com", {skipAnimation: true});
   tab.linkedBrowser.addEventListener("load", function tabLoad(event) {
     tab.linkedBrowser.removeEventListener("load", tabLoad, true);
     executeSoon(tabLoaded);
   }, true);
 
   registerCleanupFunction(function() {
     Services.prefs.clearUserPref(prefName);
     gBrowser.removeTab(tab);
@@ -69,20 +69,21 @@ function testInitial(finishcb) {
         });
       });
     });
     markButton.click();
   }, "provider didn't provide page-mark-config");
 }
 
 function testStillMarkedIn2Tabs() {
-  let toMark = "http://example.com";
+  let toMark = "http://test2.example.com";
   let markUri = Services.io.newURI(toMark, null, null);
   let markButton = SocialMark.button;
   let initialTab = gBrowser.selectedTab;
+  info("initialTab has loaded " + gBrowser.currentURI.spec);
   is(markButton.hasAttribute("marked"), false, "SocialMark button should not have 'marked' for the initial tab");
   let tab1 = gBrowser.selectedTab = gBrowser.addTab(toMark);
   let tab1b = gBrowser.getBrowserForTab(tab1);
 
   tab1b.addEventListener("load", function tabLoad(event) {
     tab1b.removeEventListener("load", tabLoad, true);
     let tab2 = gBrowser.selectedTab = gBrowser.addTab(toMark);
     let tab2b = gBrowser.getBrowserForTab(tab2);
@@ -94,41 +95,45 @@ function testStillMarkedIn2Tabs() {
         ok(!marked, "page is unmarked in annotations");
         markButton.click();
         waitForCondition(function() markButton.hasAttribute("marked"), function() {
           Social.isURIMarked(markUri, function(marked) {
             ok(marked, "page is marked in annotations");
             // and switching to the first tab (with the same URL) should still reflect marked.
             gBrowser.selectedTab = tab1;
             is(markButton.hasAttribute("marked"), true, "SocialMark button should reflect the marked state");
+            // wait for tabselect
+            gBrowser.tabContainer.addEventListener("TabSelect", function onTabSelect() {
+              gBrowser.tabContainer.removeEventListener("TabSelect", onTabSelect, false);
+              waitForCondition(function() !markButton.hasAttribute("marked"), function() {
+                gBrowser.selectedTab = tab1;
+      
+                SocialMark.togglePageMark(function() {
+                  Social.isURIMarked(gBrowser.currentURI, function(marked) {
+                    ok(!marked, "page is unmarked in annotations");
+                    is(markButton.hasAttribute("marked"), false, "mark button should not be marked");
+                    gBrowser.removeTab(tab1);
+                    gBrowser.removeTab(tab2);
+                    executeSoon(testStillMarkedAfterReopen);
+                  });
+                });
+              }, "button has been unmarked");
+            }, false);
             // but switching back the initial one should reflect not marked.
             gBrowser.selectedTab = initialTab;
-            waitForCondition(function() !markButton.hasAttribute("marked"), function() {
-              gBrowser.selectedTab = tab1;
-    
-              SocialMark.togglePageMark(function() {
-                Social.isURIMarked(gBrowser.currentURI, function(marked) {
-                  ok(!marked, "page is unmarked in annotations");
-                  is(markButton.hasAttribute("marked"), false, "mark button should not be marked");
-                  gBrowser.removeTab(tab1);
-                  gBrowser.removeTab(tab2);
-                  executeSoon(testStillMarkedAfterReopen);
-                });
-              });
-            }, "button has been unmarked");
           });
         }, "button has been marked");
       });
 
     }, true);
   }, true);
 }
 
 function testStillMarkedAfterReopen() {
-  let toMark = "http://example.com";
+  let toMark = "http://test2.example.com";
   let markButton = SocialMark.button;
 
   is(markButton.hasAttribute("marked"), false, "Reopen: SocialMark button should not have 'marked' for the initial tab");
   let tab = gBrowser.selectedTab = gBrowser.addTab(toMark);
   let tabb = gBrowser.getBrowserForTab(tab);
   tabb.addEventListener("load", function tabLoad(event) {
     tabb.removeEventListener("load", tabLoad, true);
     SocialMark.togglePageMark(function() {
@@ -149,17 +154,17 @@ function testStillMarkedAfterReopen() {
           });
         }, true);
       }, "button is now unmarked");
     });
   }, true);
 }
 
 function testOnlyMarkCertainUrlsTabSwitch() {
-  let toMark = "http://example.com";
+  let toMark = "http://test2.example.com";
   let notSharable = "about:blank";
   let markButton = SocialMark.button;
   let tab = gBrowser.selectedTab = gBrowser.addTab(toMark);
   let tabb = gBrowser.getBrowserForTab(tab);
   tabb.addEventListener("load", function tabLoad(event) {
     tabb.removeEventListener("load", tabLoad, true);
     ok(!markButton.hidden, "SocialMark button not hidden for http url");
     let tab2 = gBrowser.selectedTab = gBrowser.addTab(notSharable);
@@ -174,17 +179,17 @@ function testOnlyMarkCertainUrlsTabSwitc
       gBrowser.removeTab(tab);
       gBrowser.removeTab(tab2);
       executeSoon(testOnlyMarkCertainUrlsSameTab);
     }, true);
   }, true);
 }
 
 function testOnlyMarkCertainUrlsSameTab() {
-  let toMark = "http://example.com";
+  let toMark = "http://test2.example.com";
   let notSharable = "about:blank";
   let markButton = SocialMark.button;
   let tab = gBrowser.selectedTab = gBrowser.addTab(toMark);
   let tabb = gBrowser.getBrowserForTab(tab);
   tabb.addEventListener("load", function tabLoad(event) {
     tabb.removeEventListener("load", tabLoad, true);
     ok(!markButton.disabled, "SocialMark button not disabled for http url");
     tabb.addEventListener("load", function tabLoad(event) {