[Pkg-mozext-commits] [requestpolicy] 03/80: Merge branch 'hotfix-1.0.beta9.2' into dev-1.0

David Prévot taffit at moszumanska.debian.org
Sun Jul 5 15:02:23 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository requestpolicy.

commit 5bff8cfafd5176e34119d5b9d6f3710c15033c73
Merge: b38bc45 f3dd2b4
Author: Martin Kimmerle <dev at 256k.de>
Date:   Thu May 7 19:12:53 2015 +0200

    Merge branch 'hotfix-1.0.beta9.2' into dev-1.0

 ChangeLog.md                                       |  3 +
 src/content/lib/http-response.jsm                  | 21 ++++++-
 src/content/lib/request-processor.redirects.js     | 65 +++++++++++++++++-----
 tests/content/redirect-iframe.html                 | 24 ++++++++
 tests/mozmill/tests/testRedirect/manifest.ini      |  2 +-
 .../tests/testRedirect/testInlineRedirect.js       |  1 +
 6 files changed, 99 insertions(+), 17 deletions(-)

diff --cc src/content/lib/request-processor.redirects.js
index 24d1858,685bc77..7814de3
--- a/src/content/lib/request-processor.redirects.js
+++ b/src/content/lib/request-processor.redirects.js
@@@ -332,29 -319,52 +318,78 @@@ let RequestProcessor = (function(self) 
    /**
     * @param {RedirectRequest} aRequest
     */
+   function eventuallyShowRedirectNotification(aRequest) {
+     var httpResponse = aRequest.httpResponse;
+ 
+     // Check whether the request is associated with a `document` element.
+     {
+       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;
+       }
+ 
+       if (loadContext.associatedWindow !== loadContext.topWindow) {
+         // this request belongs to a sub-document, e.g. an iframe.
+         return;
+       }
+     }
+ 
+     showRedirectNotification(aRequest) || Logger.warning(
+         Logger.TYPE_HEADER_REDIRECT,
+         "A redirection of a top-level document has been observed, " +
+         "but it was not possible to notify the user! The redirection " +
+         "was from page <" + request.originURI + "> " +
+         "to <" + request.destURI + ">.");
+   }
+ 
++  /**
++   * @param {RedirectRequest} aRequest
++   */
 +  function getOriginOfInitialRedirect(aRequest) {
 +    var initialOrigin = aRequest.originURI;
 +    var initialDest = aRequest.destURI;
 +
 +    // Prevent infinite loops, that is, bound the number of iterations.
 +    // Note: An apparent redirect loop doesn't mean a problem with a
 +    //       website as the site may be using other information,
 +    //       such as cookies that get set in the redirection process,
 +    //       to stop the redirection.
 +    const ASSUME_REDIRECT_LOOP = 100; // Chosen arbitrarily.
 +
 +    for (let i = 0; i < ASSUME_REDIRECT_LOOP; ++i) {
 +      if (false === (initialOrigin in internal.allowedRedirectsReverse)) {
 +        // break the loop
 +        break;
 +      }
 +
 +      initialDest = initialOrigin;
 +      initialOrigin = internal.allowedRedirectsReverse[initialOrigin];
 +    }
 +
 +    return initialOrigin;
 +  }
  
  
  

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git



More information about the Pkg-mozext-commits mailing list