Skip to content

Commit

Permalink
[fix] http-on-examine-response: top-level doc detection
Browse files Browse the repository at this point in the history
On E10s there was an error in the "http-on-examine-response"
observer, specifically in the function
`eventuallyShowRedirectNotification()`. The function checks if
the load corresponding to the request is a top-level document
request. If true, the redirection notification is shown.

The function used the DocShell's "busy" flags, but the DocShell
lives in the content process. The solution is to use the
channel's load flags instead. It's compatible with E10s and it's
even less code.

However, the redirection notification still isn't shown on
http://www.maindomain.test/redirect-http-location-header-png.php
because there are more issues. See also #721.
  • Loading branch information
myrdd committed Oct 22, 2015
1 parent aeda47e commit 53a1174
Showing 1 changed file with 4 additions and 31 deletions.
35 changes: 4 additions & 31 deletions src/content/lib/request-processor.redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,39 +320,12 @@ RequestProcessor = (function(self) {
* @param {RedirectRequest} aRequest
*/
function eventuallyShowRedirectNotification(aRequest) {
var httpResponse = aRequest.httpResponse;

// Check whether the request is associated with a `document` element.
// Check if the request corresponds to a top-level document load.
{
let docShell = httpResponse.docShell;

if (docShell === null) {
return;
}

let busyFlags = docShell.busyFlags;
const expectedFlags = Ci.nsIDocShell.BUSY_FLAGS_BUSY
| Ci.nsIDocShell.BUSY_FLAGS_BEFORE_PAGE_LOAD;

// The document is loading AND nothing has been received yet.
let isDocumentRequest = (busyFlags & expectedFlags) === expectedFlags;

if (isDocumentRequest === false) {
// This is probably a redirect of an "inline" element, e.g. <img>.
return;
}
}

// Check whether it's the top-level document that is being loaded.
{
let loadContext = httpResponse.loadContext;

if (loadContext === null) {
return;
}
let loadFlags = aRequest.httpResponse.httpChannel.loadFlags;
let topLevelDocFlag = Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;

if (loadContext.associatedWindow !== loadContext.topWindow) {
// this request belongs to a sub-document, e.g. an iframe.
if ((loadFlags & topLevelDocFlag) !== topLevelDocFlag) {
return;
}
}
Expand Down

0 comments on commit 53a1174

Please sign in to comment.