Bug 1308608 - test that opening about:rights from about:home actually works, r=mikedeboer
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 07 Oct 2016 21:26:21 +0100
changeset 317123 52bba388b92a30b8c5ca203336561f02861ba3c2
parent 317122 4429c8701a840b4b08c28507e909a429d37916d5
child 317124 df471131e1b68aadfdd7951776224c21142a37b8
push id20681
push userphilringnalda@gmail.com
push dateSat, 08 Oct 2016 23:57:20 +0000
treeherderfx-team@7a7ba250bb2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1308608
milestone52.0a1
Bug 1308608 - test that opening about:rights from about:home actually works, r=mikedeboer MozReview-Commit-ID: 7nIXmw1n26f
browser/base/content/test/general/browser_aboutHome.js
--- a/browser/base/content/test/general/browser_aboutHome.js
+++ b/browser/base/content/test/general/browser_aboutHome.js
@@ -161,30 +161,38 @@ add_task(function* () {
          args.expectedVersion,
          "cached-version is correct");
       ok(snippetsMap.has("snippets-last-update"), "last-update still exists");
     }, { expectedVersion: AboutHomeUtils.snippetsVersion });
 });
 
 add_task(function* () {
   info("Check if the 'Know Your Rights' default snippet is shown when " +
-    "'browser.rights.override' pref is set");
+    "'browser.rights.override' pref is set and that its link works");
 
   Services.prefs.setBoolPref("browser.rights.override", false);
 
   ok(AboutHomeUtils.showKnowYourRights, "AboutHomeUtils.showKnowYourRights should be TRUE");
 
   yield withSnippetsMap(null, function* () {
     let doc = content.document;
     let snippetsElt = doc.getElementById("snippets");
     ok(snippetsElt, "Found snippets element");
-    is(snippetsElt.getElementsByTagName("a")[0].href, "about:rights",
-      "Snippet link is present.");
+    let linkEl = snippetsElt.querySelector("a");
+    is(linkEl.href, "about:rights", "Snippet link is present.");
+  }, null, function* () {
+    let loadPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, "about:rights");
+    yield BrowserTestUtils.synthesizeMouseAtCenter("a[href='about:rights']", {
+      button: 0
+    }, gBrowser.selectedBrowser);
+    yield loadPromise;
+    is(gBrowser.currentURI.spec, "about:rights", "about:rights should have opened.");
   });
 
+
   Services.prefs.clearUserPref("browser.rights.override");
 });
 
 add_task(function* () {
   info("Check if the 'Know Your Rights' default snippet is NOT shown when " +
     "'browser.rights.override' pref is NOT set");
 
   Services.prefs.setBoolPref("browser.rights.override", true);
@@ -559,19 +567,25 @@ add_task(function* () {
 });
 
 /**
  * Cleans up snippets and ensures that by default we don't try to check for
  * remote snippets since that may cause network bustage or slowness.
  *
  * @param aSetupFn
  *        The setup function to be run.
+ * @param testFn
+ *        the content task to run
+ * @param testArgs (optional)
+ *        the parameters to pass to the content task
+ * @param parentFn (optional)
+ *        the function to run in the parent after the content task has completed.
  * @return {Promise} resolved when the snippets are ready.  Gets the snippets map.
  */
-function* withSnippetsMap(setupFn, testFn, testArgs = null) {
+function* withSnippetsMap(setupFn, testFn, testArgs = null, parentFn = null) {
   let setupFnSource;
   if (setupFn) {
     setupFnSource = setupFn.toSource();
   }
 
   yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function* (browser) {
     let promiseAfterLocationChange = () => {
       return ContentTask.spawn(browser, {
@@ -634,16 +648,19 @@ function* withSnippetsMap(setupFn, testF
 
     // Set the URL to 'about:home' here to allow capturing the 'AboutHomeLoadSnippets'
     // event.
     browser.loadURI("about:home");
     // Wait for LocationChange.
     yield promise;
 
     yield ContentTask.spawn(browser, testArgs, testFn);
+    if (parentFn) {
+      yield parentFn();
+    }
   });
 }
 
 function promiseContentSearchChange(browser, newEngineName) {
   return ContentTask.spawn(browser, { newEngineName }, function* (args) {
     return new Promise(resolve => {
       content.addEventListener("ContentSearchService", function listener(aEvent) {
         if (aEvent.detail.type == "CurrentState" &&