Bug 698371 - Fixup front-end callers and enable some thumbnail tests for e10s. r=dao
authorJim Mathies <jmathies@mozilla.com>
Sat, 18 Oct 2014 09:09:32 -0500
changeset 211235 d700cacf3994b7512e07fee4df37be85f4aefa8d
parent 211234 d67b8fed95c695f302f380cc99ebad0227e7e539
child 211236 59ee437c92c67b3e54e62d7d5e35776408b41e54
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdao
bugs698371
milestone36.0a1
Bug 698371 - Fixup front-end callers and enable some thumbnail tests for e10s. r=dao
browser/base/content/browser-tabPreviews.js
browser/base/content/browser-thumbnails.js
browser/base/content/socialchat.xml
browser/base/content/tabbrowser.xml
browser/components/tabview/tabitems.js
toolkit/components/thumbnails/test/browser.ini
toolkit/components/thumbnails/test/head.js
--- a/browser/base/content/browser-tabPreviews.js
+++ b/browser/base/content/browser-tabPreviews.js
@@ -42,20 +42,16 @@ var tabPreviews = {
       img.src = PageThumbs.getThumbnailURL(uri);
       return img;
     }
 
     return this.capture(aTab, !aTab.hasAttribute("busy"));
   },
 
   capture: function tabPreviews_capture(aTab, aShouldCache) {
-    // Bug 863512 - Make page thumbnails work in electrolysis
-    if (gMultiProcessBrowser)
-      return new Image();
-
     let browser = aTab.linkedBrowser;
     let uri = browser.currentURI.spec;
 
     // FIXME: The gBrowserThumbnails._shouldCapture determines whether
     //        thumbnails should be written to disk. This should somehow be part
     //        of the PageThumbs API. (bug 1062414)
     if (aShouldCache &&
         gBrowserThumbnails._shouldCapture(browser)) {
@@ -72,17 +68,17 @@ var tabPreviews = {
 
     let canvas = PageThumbs.createCanvas(window);
 
     if (aShouldCache) {
       aTab.__thumbnail = canvas;
       aTab.__thumbnail_lastURI = uri;
     }
 
-    PageThumbs.captureToCanvas(aTab.linkedBrowser.contentWindow, canvas);
+    PageThumbs.captureToCanvas(browser, canvas);
     return canvas;
   },
 
   handleEvent: function tabPreviews_handleEvent(event) {
     switch (event.type) {
       case "TabSelect":
         if (this._selectedTab &&
             this._selectedTab.parentNode &&
--- a/browser/base/content/browser-thumbnails.js
+++ b/browser/base/content/browser-thumbnails.js
@@ -28,39 +28,31 @@ let gBrowserThumbnails = {
   _timeouts: null,
 
   /**
    * List of tab events we want to listen for.
    */
   _tabEvents: ["TabClose", "TabSelect"],
 
   init: function Thumbnails_init() {
-    // Bug 863512 - Make page thumbnails work in electrolysis
-    if (gMultiProcessBrowser)
-      return;
-
     PageThumbs.addExpirationFilter(this);
     gBrowser.addTabsProgressListener(this);
     Services.prefs.addObserver(this.PREF_DISK_CACHE_SSL, this, false);
 
     this._sslDiskCacheEnabled =
       Services.prefs.getBoolPref(this.PREF_DISK_CACHE_SSL);
 
     this._tabEvents.forEach(function (aEvent) {
       gBrowser.tabContainer.addEventListener(aEvent, this, false);
     }, this);
 
     this._timeouts = new WeakMap();
   },
 
   uninit: function Thumbnails_uninit() {
-    // Bug 863512 - Make page thumbnails work in electrolysis
-    if (gMultiProcessBrowser)
-      return;
-
     PageThumbs.removeExpirationFilter(this);
     gBrowser.removeTabsProgressListener(this);
     Services.prefs.removeObserver(this.PREF_DISK_CACHE_SSL, this);
 
     this._tabEvents.forEach(function (aEvent) {
       gBrowser.tabContainer.removeEventListener(aEvent, this, false);
     }, this);
   },
@@ -120,43 +112,43 @@ let gBrowserThumbnails = {
       this._capture(aBrowser);
     }.bind(this), this._captureDelayMS);
 
     this._timeouts.set(aBrowser, timeout);
   },
 
   // FIXME: This should be part of the PageThumbs API. (bug 1062414)
   _shouldCapture: function Thumbnails_shouldCapture(aBrowser) {
-    // Don't try to capture in e10s yet (because of bug 698371)
-    if (gMultiProcessBrowser)
-      return false;
-
     // Capture only if it's the currently selected tab.
     if (aBrowser != gBrowser.selectedBrowser)
       return false;
 
     // Don't capture in per-window private browsing mode.
     if (PrivateBrowsingUtils.isWindowPrivate(window))
       return false;
 
     let doc = aBrowser.contentDocument;
 
     // FIXME Bug 720575 - Don't capture thumbnails for SVG or XML documents as
     //       that currently regresses Talos SVG tests.
     if (doc instanceof SVGDocument || doc instanceof XMLDocument)
       return false;
 
+    // Don't take screenshots of about: pages.
+    if (aBrowser.currentURI.schemeIs("about"))
+      return false;
+
+    // FIXME e10s work around, we need channel information. bug 1073957
+    if (!aBrowser.docShell)
+      return true;
+
     // There's no point in taking screenshot of loading pages.
     if (aBrowser.docShell.busyFlags != Ci.nsIDocShell.BUSY_FLAGS_NONE)
       return false;
 
-    // Don't take screenshots of about: pages.
-    if (aBrowser.currentURI.schemeIs("about"))
-      return false;
-
     let channel = aBrowser.docShell.currentDocumentChannel;
 
     // No valid document channel. We shouldn't take a screenshot.
     if (!channel)
       return false;
 
     // Don't take screenshots of internally redirecting about: pages.
     // This includes error pages.
--- a/browser/base/content/socialchat.xml
+++ b/browser/base/content/socialchat.xml
@@ -702,17 +702,17 @@
         // canvas size (in CSS pixels) to the window's backing resolution in order
         // to get a full-resolution drag image for use on HiDPI displays.
         let windowUtils = window.getInterface(Ci.nsIDOMWindowUtils);
         let scale = windowUtils.screenPixelsPerCSSPixel / windowUtils.fullZoom;
         let canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
         canvas.mozOpaque = true;
         canvas.width = 160 * scale;
         canvas.height = 90 * scale;
-        PageThumbs.captureToCanvas(chatbox.contentWindow, canvas);
+        PageThumbs.captureToCanvas(chatbox, canvas);
         dt.setDragImage(canvas, -16 * scale, -16 * scale);
 
         event.stopPropagation();
       ]]></handler>
 
       <handler event="dragend"><![CDATA[
         let dt = event.dataTransfer;
         let draggedChat = dt.mozGetDataAt("application/x-moz-chatbox", 0);
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -4525,17 +4525,17 @@
         let windowUtils = window.getInterface(Ci.nsIDOMWindowUtils);
         let scale = windowUtils.screenPixelsPerCSSPixel / windowUtils.fullZoom;
         let canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
         canvas.mozOpaque = true;
         canvas.width = 160 * scale;
         canvas.height = 90 * scale;
         if (!gMultiProcessBrowser) {
           // Bug 863512 - Make page thumbnails work in e10s
-          PageThumbs.captureToCanvas(browser.contentWindow, canvas);
+          PageThumbs.captureToCanvas(browser, canvas);
         }
         dt.setDragImage(canvas, -16 * scale, -16 * scale);
 
         // _dragData.offsetX/Y give the coordinates that the mouse should be
         // positioned relative to the corner of the new window created upon
         // dragend such that the mouse appears to have the same position
         // relative to the corner of the dragged tab.
         function clientX(ele) ele.getBoundingClientRect().left;
--- a/browser/components/tabview/tabitems.js
+++ b/browser/components/tabview/tabitems.js
@@ -1378,25 +1378,19 @@ TabCanvas.prototype = Utils.extend(new S
   // ----------
   // Function: paint
   paint: function TabCanvas_paint(evt) {
     var w = this.canvas.width;
     var h = this.canvas.height;
     if (!w || !h)
       return;
 
-    if (!this.tab.linkedBrowser.contentWindow) {
-      Utils.log('no tab.linkedBrowser.contentWindow in TabCanvas.paint()');
-      return;
-    }
-
-    let win = this.tab.linkedBrowser.contentWindow;
-    gPageThumbnails.captureToCanvas(win, this.canvas);
-
-    this._sendToSubscribers("painted");
+    gPageThumbnails.captureToCanvas(this.tab.linkedBrowser, this.canvas, () => {
+      this._sendToSubscribers("painted");
+    });
   },
 
   // ----------
   // Function: toImageData
   toImageData: function TabCanvas_toImageData() {
     return this.canvas.toDataURL("image/png");
   }
 });
--- a/toolkit/components/thumbnails/test/browser.ini
+++ b/toolkit/components/thumbnails/test/browser.ini
@@ -1,40 +1,46 @@
 [DEFAULT]
-skip-if = e10s # Bug 863512 - thumbnails are disabled with e10s enabled.
 support-files =
   background_red.html
   background_red_redirect.sjs
   background_red_scroll.html
   head.js
   privacy_cache_control.sjs
   thumbnails_background.sjs
   thumbnails_crash_content_helper.js
   thumbnails_update.sjs
 
 [browser_thumbnails_bg_bad_url.js]
 [browser_thumbnails_bg_crash_during_capture.js]
-skip-if = buildapp == 'mulet' || !crashreporter
+skip-if = buildapp == 'mulet' || !crashreporter || e10s # crashing the remote thumbnailer crashes the remote test tab
 [browser_thumbnails_bg_crash_while_idle.js]
-skip-if = buildapp == 'mulet' || !crashreporter
+skip-if = buildapp == 'mulet' || !crashreporter || e10s
 [browser_thumbnails_bg_basic.js]
 [browser_thumbnails_bg_queueing.js]
 [browser_thumbnails_bg_timeout.js]
 [browser_thumbnails_bg_redirect.js]
 [browser_thumbnails_bg_destroy_browser.js]
 [browser_thumbnails_bg_no_cookies_sent.js]
+skip-if = e10s # e10s cookie problems
 [browser_thumbnails_bg_no_cookies_stored.js]
 [browser_thumbnails_bg_no_auth_prompt.js]
 [browser_thumbnails_bg_no_alert.js]
 [browser_thumbnails_bg_no_duplicates.js]
 [browser_thumbnails_bg_captureIfMissing.js]
 [browser_thumbnails_bug726727.js]
 skip-if = buildapp == 'mulet'
 [browser_thumbnails_bug727765.js]
+skip-if = e10s # tries to open crypto/local file from the child
 [browser_thumbnails_bug818225.js]
+skip-if = e10s # load event issues, bug 1084637.
 [browser_thumbnails_capture.js]
+skip-if = e10s # tries to call drawWindow with a remote browser.
 [browser_thumbnails_expiration.js]
 [browser_thumbnails_privacy.js]
+skip-if = e10s # nsSSLStatus has null mServerCert, bug 820466
 [browser_thumbnails_redirect.js]
+skip-if = e10s # bug 1050869
 [browser_thumbnails_storage.js]
 [browser_thumbnails_storage_migrate3.js]
 skip-if = buildapp == 'mulet'
 [browser_thumbnails_update.js]
+skip-if = e10s # tries to open crypto/local file from the child
--- a/toolkit/components/thumbnails/test/head.js
+++ b/toolkit/components/thumbnails/test/head.js
@@ -132,16 +132,17 @@ function captureAndCheckColor(aRed, aGre
       next();
     });
   });
 }
 
 /**
  * For a given URL, loads the corresponding thumbnail
  * to a canvas and passes its image data to the callback.
+ * Note, not compat with e10s!
  * @param aURL The url associated with the thumbnail.
  * @param aCallback The function to pass the image data to.
  */
 function retrieveImageDataForURL(aURL, aCallback) {
   let width = 100, height = 100;
   let thumb = PageThumbs.getThumbnailURL(aURL, width, height);
   // create a tab with a chrome:// URL so it can host the thumbnail image.
   // Note that we tried creating the element directly in the top-level chrome