Merge pull request #2309 from brendandahl/forward-original-request
Forward original request to avoid firefox assertion.
This commit is contained in:
commit
8cdb683b80
@ -95,7 +95,9 @@ function log(aMsg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDOMWindow(aChannel) {
|
function getDOMWindow(aChannel) {
|
||||||
var requestor = aChannel.notificationCallbacks;
|
var requestor = aChannel.notificationCallbacks ?
|
||||||
|
aChannel.notificationCallbacks :
|
||||||
|
aChannel.loadGroup.notificationCallbacks;
|
||||||
var win = requestor.getInterface(Components.interfaces.nsIDOMWindow);
|
var win = requestor.getInterface(Components.interfaces.nsIDOMWindow);
|
||||||
return win;
|
return win;
|
||||||
}
|
}
|
||||||
@ -591,6 +593,8 @@ PdfStreamConverter.prototype = {
|
|||||||
// Cancel the request so the viewer can handle it.
|
// Cancel the request so the viewer can handle it.
|
||||||
aRequest.cancel(Cr.NS_BINDING_ABORTED);
|
aRequest.cancel(Cr.NS_BINDING_ABORTED);
|
||||||
}
|
}
|
||||||
|
// Change the content type so we don't get stuck in a loop.
|
||||||
|
aRequest.contentType = 'text/html';
|
||||||
|
|
||||||
// Create a new channel that is viewer loaded as a resource.
|
// Create a new channel that is viewer loaded as a resource.
|
||||||
var ioService = Services.io;
|
var ioService = Services.io;
|
||||||
@ -598,17 +602,20 @@ PdfStreamConverter.prototype = {
|
|||||||
PDF_VIEWER_WEB_PAGE, null, null);
|
PDF_VIEWER_WEB_PAGE, null, null);
|
||||||
|
|
||||||
var listener = this.listener;
|
var listener = this.listener;
|
||||||
var self = this;
|
|
||||||
// Proxy all the request observer calls, when it gets to onStopRequest
|
// Proxy all the request observer calls, when it gets to onStopRequest
|
||||||
// we can get the dom window.
|
// we can get the dom window. We also intentionally pass on the original
|
||||||
|
// request(aRequest) below so we don't overwrite the original channel and
|
||||||
|
// trigger an assertion.
|
||||||
var proxy = {
|
var proxy = {
|
||||||
onStartRequest: function() {
|
onStartRequest: function(request, context) {
|
||||||
listener.onStartRequest.apply(listener, arguments);
|
listener.onStartRequest(aRequest, context);
|
||||||
},
|
},
|
||||||
onDataAvailable: function() {
|
onDataAvailable: function(request, context, inputStream, offset, count) {
|
||||||
listener.onDataAvailable.apply(listener, arguments);
|
listener.onDataAvailable(aRequest, context, inputStream, offset, count);
|
||||||
},
|
},
|
||||||
onStopRequest: function() {
|
onStopRequest: function(request, context, statusCode) {
|
||||||
|
// We get the DOM window here instead of before the request since it
|
||||||
|
// may have changed during a redirect.
|
||||||
var domWindow = getDOMWindow(channel);
|
var domWindow = getDOMWindow(channel);
|
||||||
// Double check the url is still the correct one.
|
// Double check the url is still the correct one.
|
||||||
if (domWindow.document.documentURIObject.equals(aRequest.URI)) {
|
if (domWindow.document.documentURIObject.equals(aRequest.URI)) {
|
||||||
@ -624,14 +631,17 @@ PdfStreamConverter.prototype = {
|
|||||||
chromeWindow);
|
chromeWindow);
|
||||||
findEventManager.bind();
|
findEventManager.bind();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log('Dom window url did not match request url.');
|
||||||
}
|
}
|
||||||
listener.onStopRequest.apply(listener, arguments);
|
listener.onStopRequest(aRequest, context, statusCode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Keep the URL the same so the browser sees it as the same.
|
// Keep the URL the same so the browser sees it as the same.
|
||||||
channel.originalURI = aRequest.URI;
|
channel.originalURI = aRequest.URI;
|
||||||
channel.asyncOpen(proxy, aContext);
|
channel.loadGroup = aRequest.loadGroup;
|
||||||
|
|
||||||
if (useFetchByChrome) {
|
if (useFetchByChrome) {
|
||||||
// We can use resource principal when data is fetched by the chrome
|
// We can use resource principal when data is fetched by the chrome
|
||||||
// e.g. useful for NoScript
|
// e.g. useful for NoScript
|
||||||
@ -645,6 +655,7 @@ PdfStreamConverter.prototype = {
|
|||||||
securityManager.getCodebasePrincipal(uri);
|
securityManager.getCodebasePrincipal(uri);
|
||||||
channel.owner = resourcePrincipal;
|
channel.owner = resourcePrincipal;
|
||||||
}
|
}
|
||||||
|
channel.asyncOpen(proxy, aContext);
|
||||||
},
|
},
|
||||||
|
|
||||||
// nsIRequestObserver::onStopRequest
|
// nsIRequestObserver::onStopRequest
|
||||||
|
Loading…
x
Reference in New Issue
Block a user