Skip to content

Instantly share code, notes, and snippets.

@xulapp
Created April 3, 2011 14:05

Revisions

  1. xulapp revised this gist Jun 23, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Bug330458.uc.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    // ==uc==
    // @include *
    // @exclude chrome://browser/content/preferences/preferences.xul
    // ==/uc==


  2. xulapp created this gist Apr 3, 2011.
    51 changes: 51 additions & 0 deletions Bug330458.uc.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    // ==uc==
    // @include *
    // ==/uc==


    (function Bug330458() {
    var orgLoadOverlay = document.loadOverlay;
    var queue = [];
    var loading = false;

    function Observer(org) {
    this.org = org;
    }
    Observer.prototype = {
    constructor: Observer,
    observe: function observe(subject, topic, data) {
    try {
    if (this.org instanceof Ci.nsIObserver)
    this.org.observe(subject, topic, data);
    } catch (e) {
    Cu.reportError(e);
    }

    if (topic === 'xul-overlay-merged')
    setTimeout(next, 0);
    },
    QueryInterface: function(iId) {
    if(iId.equals(Ci.nsISupports) || iId.equals(Ci.nsIObserver))
    return this;

    throw Cr.NS_ERROR_NO_INTERFACE;
    },
    };
    function next() {
    loading = false;
    var args = queue.shift();
    if (args)
    loadOverlay.apply(document, args);
    }
    function loadOverlay(url, observer) {
    if (loading) {
    queue.push([url, observer]);
    return;
    }

    loading = true;
    orgLoadOverlay.call(this, url, new Observer(observer));
    }

    document.loadOverlay = loadOverlay;
    })();