Re: Backward compatibility of page loading flags - Mozilla

This is a discussion on Re: Backward compatibility of page loading flags - Mozilla ; On 24 sep, 20:08, Luca Bruno wrote: > Hello, > we were developing an extension written in javascript for Firefox 3.0. We > then tried the same code on Firefox 3.5 and it didn't work. > We're listening to http-on-modify-request ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Re: Backward compatibility of page loading flags

  1. Re: Backward compatibility of page loading flags

    On 24 sep, 20:08, Luca Bruno wrote:
    > Hello,
    > we were developing an extension written in javascript for Firefox 3.0. We
    > then tried the same code on Firefox 3.5 and it didn't work.
    > We're listening to http-on-modify-request in order to catch the requests
    > explicitely made by the user (or at least to avoid requests for loading css,
    > images and so on) using this "if" statement:
    > if (!(subject.loadFlags & Components.interfaces.nsIChannel.LOAD_INITIAL_DOCU MENT_URI))
    > * * * * return; // returns even the request was made by the user
    >
    > subject is the channel passed to the observer.
    > The question: has the behavior of the browser changed since 3.0 when setting
    > the flags? The specs for the flags haven't changed in the while.
    > This happens for every website.
    >
    > In other words, we only need to catch the first request but the
    > css/images/background ones.
    >
    > --http://www.debian.org- The Universal Operating System
    >


    It's very strange, because this is works fine for me for both ff
    versions.

    Only one difference is that i predefine constant: const
    LOAD_INITIAL_DOCUMENT_URI = 524288;

    You can check flags of each request by using this function:

    function getFlagsForChannel(channel) {
    const LOAD_NORMAL = 0
    const LOAD_BACKGROUND = 1
    const INHIBIT_CACHING = 128
    const INHIBIT_PERSISTENT_CACHING = 256
    const LOAD_BYPASS_CACHE = 512
    const LOAD_FROM_CACHE = 1024
    const VALIDATE_ALWAYS = 2048
    const VALIDATE_NEVER = 4096
    const VALIDATE_ONCE_PER_SESSION = 8192
    const LOAD_ANONYMOUS = 16384
    const LOAD_DOCUMENT_URI = 65536
    const LOAD_RETARGETED_DOCUMENT_URI = 131072
    const LOAD_REPLACE = 262144
    const LOAD_INITIAL_DOCUMENT_URI = 524288
    const LOAD_TARGETED = 1048576
    const LOAD_CALL_CONTENT_SNIFFERS = 2097152

    var msg = "";
    if (channel.loadFlags & LOAD_NORMAL) msg += "LOAD_NORMAL ";
    if (channel.loadFlags & LOAD_BACKGROUND) msg += "LOAD_BACKGROUND
    ";
    if (channel.loadFlags & INHIBIT_CACHING) msg += "INHIBIT_CACHING
    ";
    if (channel.loadFlags & INHIBIT_PERSISTENT_CACHING) msg +=
    "INHIBIT_PERSISTENT_CACHING ";
    if (channel.loadFlags & LOAD_BYPASS_CACHE) msg +=
    "LOAD_BYPASS_CACHE ";
    if (channel.loadFlags & LOAD_FROM_CACHE) msg += "LOAD_FROM_CACHE
    ";
    if (channel.loadFlags & VALIDATE_ALWAYS) msg += "VALIDATE_ALWAYS
    ";
    if (channel.loadFlags & VALIDATE_NEVER) msg += "VALIDATE_NEVER ";
    if (channel.loadFlags & VALIDATE_ONCE_PER_SESSION) msg +=
    "VALIDATE_ONCE_PER_SESSION ";
    if (channel.loadFlags & LOAD_ANONYMOUS) msg += "LOAD_ANONYMOUS ";
    if (channel.loadFlags & LOAD_DOCUMENT_URI) msg +=
    "LOAD_DOCUMENT_URI ";
    if (channel.loadFlags & LOAD_RETARGETED_DOCUMENT_URI) msg +=
    "LOAD_RETARGETED_DOCUMENT_URI ";
    if (channel.loadFlags & LOAD_REPLACE) msg += "LOAD_REPLACE ";
    if (channel.loadFlags & LOAD_INITIAL_DOCUMENT_URI) msg +=
    "LOAD_INITIAL_DOCUMENT_URI ";
    if (channel.loadFlags & LOAD_TARGETED) msg += "LOAD_TARGETED ";
    if (channel.loadFlags & LOAD_CALL_CONTENT_SNIFFERS) msg +=
    "LOAD_CALL_CONTENT_SNIFFERS ";

    return msg;
    }

    if ff 3 and ff 3.5 has difference you will see it.

  2. Re: Backward compatibility of page loading flags

    On 29 sep, 20:04, Neil wrote:
    > Luca Bruno wrote:
    > >Thanks very much. We've just realized that an nsISupports is being passed to the http observer in ff 3.5 instead of an nsIChannel like in ff 3.0.

    >
    > All observers get an nsISupports, see nsIObserver and nsIObserverService.
    >


    i found that some extensions can influence on it. For example if
    Firebug installed nsIChannel available for subject. It happens because
    only one xpconnect object used for all observers and Firebug already
    call QueryInterface.

    Anyway you should always query required interface by yourself.


+ Reply to Thread