Bug 1250958 - fix browser_markPageAsFollowedLink.js for e10s (and fix framed link coloring to make it pass). r=jaws
☠☠ backed out by 5048f088aedf ☠ ☠
authorMarco Bonardo <mbonardo@mozilla.com>
Fri, 26 Feb 2016 18:55:36 +0100
changeset 324450 e427eb78d33b11fa735abd416d6680c02c515070
parent 324449 da2dadcaf4c636b5faf366732b443ea6eb1f2917
child 324451 1c87ce4424478e99539f4b054ba0e6b0576ce8ec
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1250958
milestone47.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 1250958 - fix browser_markPageAsFollowedLink.js for e10s (and fix framed link coloring to make it pass). r=jaws MozReview-Commit-ID: 9k58B16nPL8
browser/components/places/tests/browser/browser.ini
browser/components/places/tests/browser/browser_markPageAsFollowedLink.js
browser/modules/ContentClick.jsm
--- a/browser/components/places/tests/browser/browser.ini
+++ b/browser/components/places/tests/browser/browser.ini
@@ -41,15 +41,14 @@ skip-if = e10s # Bug ?????? - test fails
 [browser_library_left_pane_select_hierarchy.js]
 [browser_library_middleclick.js]
 [browser_library_open_leak.js]
 [browser_library_openFlatContainer.js]
 [browser_library_panel_leak.js]
 [browser_library_search.js]
 [browser_library_views_liveupdate.js]
 [browser_markPageAsFollowedLink.js]
-skip-if = e10s # Bug 933103 - mochitest's EventUtils.synthesizeMouse functions not e10s friendly (test does EventUtils.sendMouseEvent...)
 [browser_sidebarpanels_click.js]
 skip-if = true # temporarily disabled for breaking the treeview - bug 658744
 [browser_sort_in_library.js]
 [browser_toolbar_migration.js]
 [browser_toolbarbutton_menu_context.js]
 [browser_views_liveupdate.js]
--- a/browser/components/places/tests/browser/browser_markPageAsFollowedLink.js
+++ b/browser/components/places/tests/browser/browser_markPageAsFollowedLink.js
@@ -1,86 +1,61 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
 /**
  * Tests that visits across frames are correctly represented in the database.
  */
 
 const BASE_URL = "http://mochi.test:8888/browser/browser/components/places/tests/browser";
 const PAGE_URL = BASE_URL + "/framedPage.html";
 const LEFT_URL = BASE_URL + "/frameLeft.html";
 const RIGHT_URL = BASE_URL + "/frameRight.html";
 
-var gTabLoaded = false;
-var gLeftFrameVisited = false;
+add_task(function* test() {
+  // We must wait for both frames to be loaded and the visits to be registered.
+  let deferredLeftFrameVisit = PromiseUtils.defer();
+  let deferredRightFrameVisit = PromiseUtils.defer();
 
-var observer = {
-  observe: function(aSubject, aTopic, aData)
-  {
-    let url = aSubject.QueryInterface(Ci.nsIURI).spec;
-    if (url == LEFT_URL ) {
-      is(getTransitionForUrl(url), null,
-         "Embed visits should not get a database entry.");
-      gLeftFrameVisited = true;
-      maybeClickLink();
-    }
-    else if (url == RIGHT_URL ) {
-      is(getTransitionForUrl(url), PlacesUtils.history.TRANSITION_FRAMED_LINK,
-         "User activated visits should get a FRAMED_LINK transition.");
-      finish();
-    }
-  },
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
-};
-Services.obs.addObserver(observer, "uri-visit-saved", false);
+  Services.obs.addObserver(function observe(subject) {
+    Task.spawn(function* () {
+      let url = subject.QueryInterface(Ci.nsIURI).spec;
+      if (url == LEFT_URL ) {
+        is((yield getTransitionForUrl(url)), null,
+           "Embed visits should not get a database entry.");
+        deferredLeftFrameVisit.resolve();
+      }
+      else if (url == RIGHT_URL ) {
+        is((yield getTransitionForUrl(url)),
+           PlacesUtils.history.TRANSITION_FRAMED_LINK,
+           "User activated visits should get a FRAMED_LINK transition.");
+        Services.obs.removeObserver(observe, "uri-visit-saved");
+        deferredRightFrameVisit.resolve();
+      }
+    });
+  }, "uri-visit-saved", false);
 
-function test()
-{
-  waitForExplicitFinish();
-  gBrowser.selectedTab = gBrowser.addTab(PAGE_URL);
-  let frameCount = 0;
-  gBrowser.selectedBrowser.addEventListener("DOMContentLoaded",
-    function (event)
-    {
-      // Wait for all the frames.
-      if (frameCount++ < 2)
-        return;
-      gBrowser.selectedBrowser.removeEventListener("DOMContentLoaded", arguments.callee, false)
-      gTabLoaded = true;
-      maybeClickLink();
-    }, false
-  );
-}
+  let tab = gBrowser.selectedTab = gBrowser.addTab(PAGE_URL);
+  // Wait for all the subframes loads.
+  yield BrowserTestUtils.browserLoaded(tab.linkedBrowser, true);
+  // wait for the left frame visit to be registered;
+  yield deferredLeftFrameVisit.promise;
+
+  // Click on the link in the left frame to cause a page load in the
+  // right frame.
+  yield BrowserTestUtils.synthesizeMouseAtCenter(
+    () => content.frames[0].document.getElementById("clickme"), {}, tab.linkedBrowser);
+
+  // wait for the right frame visit to be registered;
+  yield deferredRightFrameVisit.promise;
 
-function maybeClickLink() {
-  if (gTabLoaded && gLeftFrameVisited) {
-    // Click on the link in the left frame to cause a page load in the
-    // right frame.
-    EventUtils.sendMouseEvent({type: "click"}, "clickme", content.frames[0]);
+  yield BrowserTestUtils.removeTab(tab);
+});
+
+function* getTransitionForUrl(url) {
+  let db = yield PlacesUtils.promiseDBConnection();
+  let rows = yield db.execute(`
+    SELECT visit_type
+    FROM moz_historyvisits
+    WHERE place_id = (SELECT id FROM moz_places WHERE url = :url)`,
+    { url });
+  if (rows.length) {
+    return rows[0].getResultByName("visit_type");
   }
+  return null;
 }
-
-function getTransitionForUrl(aUrl)
-{
-  let dbConn = PlacesUtils.history
-                          .QueryInterface(Ci.nsPIPlacesDatabase).DBConnection;
-  let stmt = dbConn.createStatement(
-    "SELECT visit_type FROM moz_historyvisits WHERE place_id = " +
-      "(SELECT id FROM moz_places WHERE url = :page_url)");
-  stmt.params.page_url = aUrl;
-  try {
-    if (!stmt.executeStep()) {
-      return null;
-    }
-    return stmt.row.visit_type;
-  }
-  finally {
-    stmt.finalize();
-  }
-}
-
-registerCleanupFunction(function ()
-{
-  gBrowser.removeTab(gBrowser.selectedTab);
-  Services.obs.removeObserver(observer, "uri-visit-saved");
-})
--- a/browser/modules/ContentClick.jsm
+++ b/browser/modules/ContentClick.jsm
@@ -58,26 +58,24 @@ var ContentClick = {
                                        }, window);
       return;
     }
 
     // Note: We don't need the sidebar code here.
 
     // This part is based on handleLinkClick.
     var where = window.whereToOpenLink(json);
-    if (where == "current")
-      return;
-
     // Todo(903022): code for where == save
-
-    let params = { charset: browser.characterSet,
-                   referrerURI: browser.documentURI,
-                   referrerPolicy: json.referrerPolicy,
-                   noReferrer: json.noReferrer };
-    window.openLinkIn(json.href, where, params);
+    if (where != "current") {
+      let params = { charset: browser.characterSet,
+                     referrerURI: browser.documentURI,
+                     referrerPolicy: json.referrerPolicy,
+                     noReferrer: json.noReferrer };
+      window.openLinkIn(json.href, where, params);
+    }
 
     // Mark the page as a user followed link.  This is done so that history can
     // distinguish automatic embed visits from user activated ones.  For example
     // pages loaded in frames are embed visits and lost with the session, while
     // visits across frames should be preserved.
     try {
       if (!PrivateBrowsingUtils.isWindowPrivate(window))
         PlacesUIUtils.markPageAsFollowedLink(json.href);