rem: if(!tor_tag && 
add: torbutton_log(1, "Check hook: " + torbutton_check_flag(win, "__tb_did_hook")); if(!tor_tag && doc.contentType.indexOf("text/html") != -1 && torbutton_check_load_state(doc, tor_tag) && 
context: function torbutton_hookdoc(win, doc) {    torbutton_log(1, "Hooking document");    if(doc.doctype) {        torbutton_log(1, "Hooking document: "+doc.doctype.name);    }    if (!m_tb_wasinited) {        torbutton_init();    }    var tor_tag = !m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled");        // We can't just tag the document here because it is possible    // to hit reload at just the right point such that the document    // has been cleared but the window remained.    if(torbutton_check_flag(win, "__tb_did_hook")) {        torbutton_log(1, "Did hook "                 + torbutton_check_flag(win, "__tb_did_hook"));        /* XXX: Remove this once bug #460 is resolved */        if(!tor_tag &&                 !torbutton_check_flag(win.window.wrappedJSObject,                     "__tb_hooks_ran")) {            torbutton_log(5, "FALSE WIN HOOKING. Please reprot bug+website!");            win.alert("False win hooking. Please report bug+website!");        }        return; // Ran already    }    torbutton_set_flag(win, "__tb_did_hook");    // We also can't just tag the window either, because it gets    // cleared on back/fwd(!??)    if(torbutton_check_flag(doc, "__tb_did_hook")) {        /* XXX: Remove this once bug #460 is resolved */        if(!tor_tag &&                 !torbutton_check_flag(win.window.wrappedJSObject, "__tb_hooks_ran")) {            torbutton_log(5, "FALSE DOC HOOKING. Please report bug+website!");            win.alert("False doc hooking. Please report bug+website!");        }         return; // Ran already    }    torbutton_set_flag(doc, "__tb_did_hook");    torbutton_log(1, "JS to be set to: " +m_tb_prefs.getBoolPref("javascript.enabled"));    var browser = getBrowser();    var kill_plugins = m_tb_prefs.getBoolPref("extensions.torbutton.no_tor_plugins");    var js_enabled = m_tb_prefs.getBoolPref("javascript.enabled");    // TODO: try nsIWindowWatcher.getChromeForWindow()    if (browser.contentDocument == doc) {        browser.__tb_js_state = tor_tag;        browser.docShell.allowPlugins = tor_tag || !kill_plugins;        browser.docShell.allowJavascript = js_enabled;    }     // Find proper browser for this document.. ugh.    for (var i = 0; i < browser.browsers.length; ++i) {        var b = browser.browsers[i];        if (b && b.contentDocument == doc) {            b.__tb_js_state = tor_tag;            b.docShell.allowPlugins = tor_tag || !kill_plugins;            b.docShell.allowJavascript = js_enabled;        }    }    torbutton_log(1, "JS set to: "         + m_tb_prefs.getBoolPref("javascript.enabled"));        // No need to hook js if tor is off, right?    if(!m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")             || !m_tb_prefs.getBoolPref('extensions.torbutton.kill_bad_js'))        return;    // Date Hooking:    /* Q: Do this better with XPCOM?     *    http://www.mozilla.org/projects/xpcom/nsIClassInfo.html     * A: Negatory.. Date() is not an XPCOM component :(     */    var str = "<"+"script>\r\n";    str += "window.__tb_set_uagent="+m_tb_prefs.getBoolPref('extensions.torbutton.set_uagent')+";\r\n";    str += "window.__tb_oscpu=\""+m_tb_prefs.getCharPref('extensions.torbutton.oscpu_override')+"\";\r\n";    str += "window.__tb_platform=\""+m_tb_prefs.getCharPref('extensions.torbutton.platform_override')+"\";\r\n";    str += "window.__tb_productSub=\""+m_tb_prefs.getCharPref('extensions.torbutton.productsub_override')+"\";\r\n";    str += m_tb_jshooks;     str += "</"+"script>";    var d = doc.createElement("div");    d.style.visibility = 'hidden';    d.innerHTML = str;    var di = torbutton_getbody(doc).insertBefore(d,             torbutton_getbody(doc).firstChild);    if(di != d) {        torbutton_log(5, "Inserted and return not equal");    }    // Remove javascript code for rendering issues/DOM traversals    if(!torbutton_getbody(doc).removeChild(di)) {        torbutton_log(5, "Failed to remove js!");    } }
meta: 3444	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/3444/4fdec65f12b0aff96e4f4bf3321e871fc8d6f52d/torbutton.js/buggy/src/chrome/content/torbutton.js