Bug 1293499 - Fix PageThumbs.captureAndStore for e10s: redirects and channel errors. r=markh

MozReview-Commit-ID: HULg4Ja0NmF
This commit is contained in:
Drew Willcoxon 2016-08-09 17:48:34 -07:00
Родитель 41e9dbb0bb
Коммит ba64c256df
4 изменённых файлов: 55 добавлений и 31 удалений

Просмотреть файл

@ -324,5 +324,24 @@ this.PageThumbUtils = {
}
} // httpChannel
return true;
}
},
/**
* Given a channel, returns true if it should be considered an "error
* response", false otherwise.
*/
isChannelErrorResponse: function(channel) {
// No valid document channel sounds like an error to me!
if (!channel)
return true;
if (!(channel instanceof Ci.nsIHttpChannel))
// it might be FTP etc, so assume it's ok.
return false;
try {
return !channel.requestSucceeded;
} catch (_) {
// not being able to determine success is surely failure!
return true;
}
},
};

Просмотреть файл

@ -368,17 +368,26 @@ this.PageThumbs = {
let originalURL;
let channelError = false;
if (!aBrowser.isRemoteBrowser) {
let channel = aBrowser.docShell.currentDocumentChannel;
originalURL = channel.originalURI.spec;
// see if this was an error response.
channelError = this._isChannelErrorResponse(channel);
} else {
// We need channel info (bug 1073957)
originalURL = url;
}
Task.spawn((function* task() {
if (!aBrowser.isRemoteBrowser) {
let channel = aBrowser.docShell.currentDocumentChannel;
originalURL = channel.originalURI.spec;
// see if this was an error response.
channelError = PageThumbUtils.isChannelErrorResponse(channel);
} else {
let resp = yield new Promise(resolve => {
let mm = aBrowser.messageManager;
let respName = "Browser:Thumbnail:GetOriginalURL:Response";
mm.addMessageListener(respName, function onResp(msg) {
mm.removeMessageListener(respName, onResp);
resolve(msg.data);
});
mm.sendAsyncMessage("Browser:Thumbnail:GetOriginalURL");
});
originalURL = resp.originalURL || url;
channelError = resp.channelError;
}
let isSuccess = true;
try {
let blob = yield this.captureToBlob(aBrowser);
@ -495,25 +504,6 @@ this.PageThumbs = {
return PageThumbUtils.createCanvas(aWindow);
},
/**
* Given a channel, returns true if it should be considered an "error
* response", false otherwise.
*/
_isChannelErrorResponse: function(channel) {
// No valid document channel sounds like an error to me!
if (!channel)
return true;
if (!(channel instanceof Ci.nsIHttpChannel))
// it might be FTP etc, so assume it's ok.
return false;
try {
return !channel.requestSucceeded;
} catch (_) {
// not being able to determine success is surely failure!
return true;
}
},
_prefEnabled: function PageThumbs_prefEnabled() {
try {
return !Services.prefs.getBoolPref("browser.pagethumbnails.capturing_disabled");

Просмотреть файл

@ -34,7 +34,6 @@ skip-if = buildapp == 'mulet'
[browser_thumbnails_expiration.js]
[browser_thumbnails_privacy.js]
[browser_thumbnails_redirect.js]
skip-if = e10s # bug 1050869
[browser_thumbnails_storage.js]
[browser_thumbnails_storage_migrate3.js]
skip-if = buildapp == 'mulet'

Просмотреть файл

@ -549,6 +549,22 @@ addMessageListener("Browser:Thumbnail:CheckState", function (aMessage) {
});
});
/**
* Remote GetOriginalURL request handler for PageThumbs.
*/
addMessageListener("Browser:Thumbnail:GetOriginalURL", function (aMessage) {
let channel = docShell.currentDocumentChannel;
let channelError = PageThumbUtils.isChannelErrorResponse(channel);
let originalURL;
try {
originalURL = channel.originalURI.spec;
} catch (ex) {}
sendAsyncMessage("Browser:Thumbnail:GetOriginalURL:Response", {
channelError: channelError,
originalURL: originalURL,
});
});
// The AddonsChild needs to be rooted so that it stays alive as long as
// the tab.
var AddonsChild = RemoteAddonsChild.init(this);