Bug 974747 - Intermittents, split up and simplify some tests. a=test-only
authorShane Caraveo <scaraveo@mozilla.com>
Mon, 31 Aug 2015 13:41:26 -0700
changeset 289056 300ff02943f6392cab57427e3cc3b9245d5d5331
parent 289055 4c75025480b62e05822c5de8151af6436d4ad80b
child 289057 f027a14fdf66456b7a2fb3db5ff83af236f86be5
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstest-only
bugs974747
milestone42.0a2
Bug 974747 - Intermittents, split up and simplify some tests. a=test-only
browser/base/content/test/social/browser.ini
browser/base/content/test/social/browser_social_activation.js
browser/base/content/test/social/browser_social_marks.js
browser/base/content/test/social/browser_social_marks_context.js
browser/base/content/test/social/social_activate_basic.html
browser/base/content/test/social/social_activate_iframe.html
--- a/browser/base/content/test/social/browser.ini
+++ b/browser/base/content/test/social/browser.ini
@@ -8,16 +8,17 @@ support-files =
   opengraph/opengraph.html
   opengraph/shortlink_linkrel.html
   opengraph/shorturl_link.html
   opengraph/shorturl_linkrel.html
   microdata.html
   share.html
   share_activate.html
   social_activate.html
+  social_activate_basic.html
   social_activate_iframe.html
   social_chat.html
   social_crash_content_helper.js
   social_flyout.html
   social_mark.html
   social_panel.html
   social_postActivation.html
   social_sidebar.html
@@ -42,16 +43,18 @@ skip-if = e10s # tab crash on data url u
 [browser_social_contextmenu.js]
 skip-if = e10s # Bug 1072669 context menu relies on target element
 [browser_social_errorPage.js]
 [browser_social_flyout.js]
 skip-if = e10s # when we backed out bug 1047603, this test broke.
 [browser_social_isVisible.js]
 [browser_social_marks.js]
 skip-if = e10s && debug # Leaking docshells (bug 1150147)
+[browser_social_marks_context.js]
+skip-if = e10s && debug
 [browser_social_multiprovider.js]
 skip-if = e10s # Bug 1069162 - lots of orange
 [browser_social_multiworker.js]
 [browser_social_perwindowPB.js]
 [browser_social_sidebar.js]
 [browser_social_status.js]
 [browser_social_window.js]
 [browser_social_workercrash.js]
--- a/browser/base/content/test/social/browser_social_activation.js
+++ b/browser/base/content/test/social/browser_social_activation.js
@@ -62,17 +62,17 @@ function addTab(url, callback) {
 function sendActivationEvent(tab, callback, nullManifest) {
   // hack Social.lastEventReceived so we don't hit the "too many events" check.
   Social.lastEventReceived = 0;
   BrowserTestUtils.synthesizeMouseAtCenter("#activation", {}, tab.linkedBrowser);
   executeSoon(callback);
 }
 
 function activateProvider(domain, callback, nullManifest) {
-  let activationURL = domain+"/browser/browser/base/content/test/social/social_activate.html"
+  let activationURL = domain+"/browser/browser/base/content/test/social/social_activate_basic.html"
   addTab(activationURL, function(tab) {
     sendActivationEvent(tab, callback, nullManifest);
   });
 }
 
 function activateIFrameProvider(domain, callback) {
   let activationURL = domain+"/browser/browser/base/content/test/social/social_activate_iframe.html"
   addTab(activationURL, function(tab) {
@@ -258,17 +258,17 @@ var tests = {
       gBrowser.selectedBrowser.removeEventListener("load", tabLoad, true);
       let browser = blanktab.linkedBrowser;
       is(browser.currentURI.spec, "about:addons", "about:addons should load into blank tab.");
 
       activateOneProvider(gProviders[0], true, function() {
         info("first activation completed");
         is(gBrowser.contentDocument.location.href, gProviders[0].origin + "/browser/browser/base/content/test/social/social_postActivation.html", "postActivationURL loaded");
         gBrowser.removeTab(gBrowser.selectedTab);
-        is(gBrowser.contentDocument.location.href, gProviders[0].origin + "/browser/browser/base/content/test/social/social_activate.html", "activation page selected");
+        is(gBrowser.contentDocument.location.href, gProviders[0].origin + "/browser/browser/base/content/test/social/social_activate_basic.html", "activation page selected");
         gBrowser.removeTab(gBrowser.selectedTab);
         tabsToRemove.pop();
         // uninstall the provider
         clickAddonRemoveButton(blanktab, function(addon) {
           checkSocialUI();
           activateOneProvider(gProviders[0], true, function() {
             info("second activation completed");
             is(gBrowser.contentDocument.location.href, gProviders[0].origin + "/browser/browser/base/content/test/social/social_postActivation.html", "postActivationURL loaded");
--- a/browser/base/content/test/social/browser_social_marks.js
+++ b/browser/base/content/test/social/browser_social_marks.js
@@ -1,21 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
 
-let manifest = { // builtin provider
-  name: "provider example.com",
-  origin: "https://example.com",
-  sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",
-  workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
-  iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png"
-};
 let manifest2 = { // used for testing install
   name: "provider test1",
   origin: "https://test1.example.com",
   workerURL: "https://test1.example.com/browser/browser/base/content/test/social/social_worker.js",
   markURL: "https://test1.example.com/browser/browser/base/content/test/social/social_mark.html?url=%{url}",
   markedIcon: "https://test1.example.com/browser/browser/base/content/test/social/unchecked.jpg",
   unmarkedIcon: "https://test1.example.com/browser/browser/base/content/test/social/checked.jpg",
 
@@ -24,44 +17,24 @@ let manifest2 = { // used for testing in
 };
 let manifest3 = { // used for testing install
   name: "provider test2",
   origin: "https://test2.example.com",
   sidebarURL: "https://test2.example.com/browser/browser/base/content/test/social/social_sidebar.html",
   iconURL: "https://test2.example.com/browser/browser/base/content/test/general/moz.png",
   version: 1
 };
-function makeMarkProvider(origin) {
-  return { // used for testing install
-    name: "mark provider " + origin,
-    origin: "https://" + origin + ".example.com",
-    workerURL: "https://" + origin + ".example.com/browser/browser/base/content/test/social/social_worker.js",
-    markURL: "https://" + origin + ".example.com/browser/browser/base/content/test/social/social_mark.html?url=%{url}",
-    markedIcon: "https://" + origin + ".example.com/browser/browser/base/content/test/social/unchecked.jpg",
-    unmarkedIcon: "https://" + origin + ".example.com/browser/browser/base/content/test/social/checked.jpg",
-
-    iconURL: "https://" + origin + ".example.com/browser/browser/base/content/test/general/moz.png",
-    version: 1
-  }
-}
 
 function test() {
   waitForExplicitFinish();
 
-  let toolbar = document.getElementById("nav-bar");
-  let currentsetAtStart = toolbar.currentSet;
-  runSocialTestWithProvider(manifest, function (finishcb) {
-    runSocialTests(tests, undefined, undefined, function () {
-      Services.prefs.clearUserPref("social.remote-install.enabled");
-      // just in case the tests failed, clear these here as well
-      Services.prefs.clearUserPref("social.whitelist");
-      ok(CustomizableUI.inDefaultState, "Should be in the default state when we finish");
-      CustomizableUI.reset();
-      finishcb();
-    });
+  runSocialTests(tests, undefined, undefined, function () {
+    ok(CustomizableUI.inDefaultState, "Should be in the default state when we finish");
+    CustomizableUI.reset();
+    finish();
   });
 }
 
 var tests = {
   testButtonDisabledOnActivate: function(next) {
     // starting on about:blank page, share should be visible but disabled when
     // adding provider
     is(gBrowser.selectedBrowser.currentURI.spec, "about:blank");
@@ -105,18 +78,17 @@ var tests = {
       Social.installProvider(data, function(addonManifest) {
         // enable the provider so we know the button would have appeared
         SocialService.enableProvider(manifest3.origin, function(provider) {
           is(provider.origin, manifest3.origin, "provider is installed");
           let id = SocialMarks._toolbarHelper.idFromOrigin(provider.origin);
           let widget = CustomizableUI.getWidget(id);
           ok(!widget || !widget.forWindow(window).node, "no button added to widget set");
           Social.uninstallProvider(manifest3.origin, function() {
-            gBrowser.removeTab(tab);
-            next();
+            ensureBrowserTabClosed(tab).then(next);
           });
         });
       });
     });
   },
 
   testButtonOnEnable: function(next) {
     let panel = document.getElementById("servicesInstall-notification");
@@ -147,18 +119,17 @@ var tests = {
           let button = document.getElementById(id);
           is(button.disabled, false, "mark button is disabled");
           // verify the attribute for proper css
           ok(!button.hasAttribute("disabled"), "mark button attribute is disabled");
           // button should be visible
           is(button.hidden, false, "mark button is visible");
 
           checkSocialUI(window);
-          gBrowser.removeTab(tab);
-          next();
+          ensureBrowserTabClosed(tab).then(next);
         });
       });
     });
   },
 
   testMarkPanel: function(next) {
     // click on panel to open and wait for visibility
     let provider = Social._getProviderFromOrigin(manifest2.origin);
@@ -322,90 +293,10 @@ var tests = {
                         // getWidget now returns null since we've destroyed the widget
                         return !CustomizableUI.getWidget(id)
                        },
                        function() {
                          checkSocialUI(window);
                          Social.uninstallProvider(manifest2.origin, next);
                        }, "button does not exist after disabling the provider");
     });
-  },
-
-  testContextSubmenu: function(next) {
-    // install 4 providers to test that the menu's are added as submenus
-    let manifests = [
-      makeMarkProvider("sub1.test1"),
-      makeMarkProvider("sub2.test1"),
-      makeMarkProvider("sub1.test2"),
-      makeMarkProvider("sub2.test2")
-    ];
-    let installed = [];
-    let markLinkMenu = document.getElementById("context-marklinkMenu").firstChild;
-    let markPageMenu = document.getElementById("context-markpageMenu").firstChild;
-
-    function addProviders(callback) {
-      let manifest = manifests.pop();
-      if (!manifest) {
-        info("INSTALLATION FINISHED");
-        executeSoon(callback);
-        return;
-      }
-      info("INSTALLING " + manifest.origin);
-      let panel = document.getElementById("servicesInstall-notification");
-      ensureEventFired(PopupNotifications.panel, "popupshown").then(() => {
-        info("servicesInstall-notification panel opened");
-        panel.button.click();
-      });
-
-      let activationURL = manifest.origin + "/browser/browser/base/content/test/social/social_activate.html"
-      let id = SocialMarks._toolbarHelper.idFromOrigin(manifest.origin);
-      let toolbar = document.getElementById("nav-bar");
-      addTab(activationURL, function(tab) {
-        let doc = tab.linkedBrowser.contentDocument;
-        let data = {
-          origin: doc.nodePrincipal.origin,
-          url: doc.location.href,
-          manifest: manifest,
-          window: window
-        }
-
-        Social.installProvider(data, function(addonManifest) {
-          // enable the provider so we know the button would have appeared
-          SocialService.enableProvider(manifest.origin, function(provider) {
-            waitForCondition(function() { return CustomizableUI.getWidget(id) },
-                             function() {
-              gBrowser.removeTab(tab);
-              installed.push(manifest.origin);
-              // checkSocialUI will properly check where the menus are located
-              checkSocialUI(window);
-              executeSoon(function() {
-                addProviders(callback);
-              });
-            }, "button exists after enabling social");
-          });
-        });
-      });
-    }
-
-    function removeProviders(callback) {
-      let origin = installed.pop();
-      if (!origin) {
-        executeSoon(callback);
-        return;
-      }
-      Social.uninstallProvider(origin, function(provider) {
-        executeSoon(function() {
-          removeProviders(callback);
-        });
-      });
-    }
-
-    addProviders(function() {
-      removeProviders(function() {
-        is(SocialMarks.getProviders().length, 0, "mark providers removed");
-        is(markLinkMenu.childNodes.length, 0, "marklink menu ok");
-        is(markPageMenu.childNodes.length, 0, "markpage menu ok");
-        checkSocialUI(window);
-        next();
-      });
-    });
   }
 }
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/social/browser_social_marks_context.js
@@ -0,0 +1,105 @@
+let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
+
+function makeMarkProvider(origin) {
+  return { // used for testing install
+    name: "mark provider " + origin,
+    origin: "https://" + origin + ".example.com",
+    markURL: "https://" + origin + ".example.com/browser/browser/base/content/test/social/social_mark.html?url=%{url}",
+    markedIcon: "https://" + origin + ".example.com/browser/browser/base/content/test/social/unchecked.jpg",
+    unmarkedIcon: "https://" + origin + ".example.com/browser/browser/base/content/test/social/checked.jpg",
+    iconURL: "https://" + origin + ".example.com/browser/browser/base/content/test/general/moz.png",
+    version: 1
+  }
+}
+
+function test() {
+  waitForExplicitFinish();
+
+  runSocialTests(tests, undefined, undefined, function () {
+    ok(CustomizableUI.inDefaultState, "Should be in the default state when we finish");
+    CustomizableUI.reset();
+    finish();
+  });
+}
+
+var tests = {
+  testContextSubmenu: function(next) {
+    // install 4 providers to test that the menu's are added as submenus
+    let manifests = [
+      makeMarkProvider("sub1.test1"),
+      makeMarkProvider("sub2.test1"),
+      makeMarkProvider("sub1.test2"),
+      makeMarkProvider("sub2.test2")
+    ];
+    let installed = [];
+    let markLinkMenu = document.getElementById("context-marklinkMenu").firstChild;
+    let markPageMenu = document.getElementById("context-markpageMenu").firstChild;
+
+    function addProviders(callback) {
+      let manifest = manifests.pop();
+      if (!manifest) {
+        info("INSTALLATION FINISHED");
+        executeSoon(callback);
+        return;
+      }
+      info("INSTALLING " + manifest.origin);
+      let panel = document.getElementById("servicesInstall-notification");
+      ensureEventFired(PopupNotifications.panel, "popupshown").then(() => {
+        info("servicesInstall-notification panel opened");
+        panel.button.click();
+      });
+
+      let activationURL = manifest.origin + "/browser/browser/base/content/test/social/social_activate.html"
+      let id = SocialMarks._toolbarHelper.idFromOrigin(manifest.origin);
+      let toolbar = document.getElementById("nav-bar");
+      addTab(activationURL, function(tab) {
+        let doc = tab.linkedBrowser.contentDocument;
+        let data = {
+          origin: doc.nodePrincipal.origin,
+          url: doc.location.href,
+          manifest: manifest,
+          window: window
+        }
+
+        Social.installProvider(data, function(addonManifest) {
+          // enable the provider so we know the button would have appeared
+          SocialService.enableProvider(manifest.origin, function(provider) {
+            waitForCondition(function() { return CustomizableUI.getWidget(id) },
+                             function() {
+              gBrowser.removeTab(tab);
+              installed.push(manifest.origin);
+              // checkSocialUI will properly check where the menus are located
+              checkSocialUI(window);
+              executeSoon(function() {
+                addProviders(callback);
+              });
+            }, "button exists after enabling social");
+          });
+        });
+      });
+    }
+
+    function removeProviders(callback) {
+      let origin = installed.pop();
+      if (!origin) {
+        executeSoon(callback);
+        return;
+      }
+      Social.uninstallProvider(origin, function(provider) {
+        executeSoon(function() {
+          removeProviders(callback);
+        });
+      });
+    }
+
+    addProviders(function() {
+      removeProviders(function() {
+        is(SocialMarks.getProviders().length, 0, "mark providers removed");
+        is(markLinkMenu.childNodes.length, 0, "marklink menu ok");
+        is(markPageMenu.childNodes.length, 0, "markpage menu ok");
+        checkSocialUI(window);
+        next();
+      });
+    });
+  }
+}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/social/social_activate_basic.html
@@ -0,0 +1,40 @@
+<html>
+<head>
+	<title>Activation test</title>
+</head>
+<script>
+// icons from http://findicons.com/icon/158311/firefox?id=356182 by ipapun
+var data = {
+  // currently required
+  "name": "Demo Social Service",
+  "iconURL": "chrome://branding/content/icon16.png",
+  "icon32URL": "chrome://branding/content/favicon32.png",
+  "icon64URL": "chrome://branding/content/icon64.png",
+
+  // at least one of these must be defined
+  "sidebarURL": "/browser/browser/base/content/test/social/social_sidebar_empty.html",
+  "postActivationURL": "/browser/browser/base/content/test/social/social_postActivation.html",
+
+  // should be available for display purposes
+  "description": "A short paragraph about this provider",
+  "author": "Shane Caraveo, Mozilla",
+
+  // optional
+  "version": 1
+}
+
+function activate(node) {
+  node.setAttribute("data-service", JSON.stringify(data));
+  var event = new CustomEvent("ActivateSocialFeature");
+  node.dispatchEvent(event);
+}
+
+</script>
+<body>
+
+nothing to see here
+
+<button id="activation" onclick="activate(this)">Activate The Demo Provider</button>
+
+</body>
+</html>
--- a/browser/base/content/test/social/social_activate_iframe.html
+++ b/browser/base/content/test/social/social_activate_iframe.html
@@ -1,11 +1,11 @@
 <html>
 <head>
 	<title>Activation iframe test</title>
 </head>
 
 <body>
 
-<iframe src="social_activate.html"/>
+<iframe src="social_activate_basic.html"/>
 
 </body>
 </html>