Visualizzazione dei risultati da 1 a 6 su 6
  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2013
    Messaggi
    4

    Error 0x8007000e (NS_ERROR_OUT_OF_MEMORY)

    Ciao

    sto lavorando su un addon di un forum e ottengo questo errore:

    Error: Component returned failure code: 0x8007000e (NS_ERROR_OUT_OF_MEMORY) [nsIXPCComponents_Utils.evalInSandbox]

    ho letto che l'errore implica che lo script va in loop infinito finché la sandbox si riempie.

    a quanto pare il file js che porta a questo errore è script-compiler.js

    questo lo script

    codice:
    var ddplus_gmCompiler={
    
    // getUrlContents adapted from Greasemonkey Compiler
    // http://www.letitblog.com/code/python/greasemonkey.py.txt
    // used under GPL permission
    //
    // most everything else below based heavily off of Greasemonkey
    // http://greasemonkey.mozdev.org/
    // used under GPL permission
    
    getUrlContents: function(aUrl){
        var    ioService=Components.classes["@mozilla.org/network/io-service;1"]
            .getService(Components.interfaces.nsIIOService);
        var    scriptableStream=Components
            .classes["@mozilla.org/scriptableinputstream;1"]
            .getService(Components.interfaces.nsIScriptableInputStream);
    
        var    channel=ioService.newChannel(aUrl, null, null);
        var    input=channel.open();
        scriptableStream.init(input);
        var    str=scriptableStream.read(input.available());
        scriptableStream.close();
        input.close();
    
        return str;
    },
    
    isGreasemonkeyable: function(url) {
        var scheme=Components.classes["@mozilla.org/network/io-service;1"]
            .getService(Components.interfaces.nsIIOService)
            .extractScheme(url);
        return (
            (scheme == "http" || scheme == "https" || scheme == "file") &&
            !/hiddenWindow\.html$/.test(url)
        );
    },
    
    contentLoad: function(e) {
        var unsafeWin=e.target.defaultView;
        if (unsafeWin.wrappedJSObject) unsafeWin=unsafeWin.wrappedJSObject;
    
        var unsafeLoc=new XPCNativeWrapper(unsafeWin, "location").location;
        var href=new XPCNativeWrapper(unsafeLoc, "href").href;
    
        if (
            ddplus_gmCompiler.isGreasemonkeyable(href)
            && ( /http:\/\/ddunlimited\.net/.test(href) )
            && true
        ) {
            var script=ddplus_gmCompiler.getUrlContents(
                'chrome://ddplus/content/ddplus.js'
            );
            ddplus_gmCompiler.injectScript(script, href, unsafeWin);
        }
    },
    
    injectScript: function(script, url, unsafeContentWin) {
        var sandbox, script, logger, storage, xmlhttpRequester;
        var safeWin=new XPCNativeWrapper(unsafeContentWin);
    
        sandbox=new Components.utils.Sandbox(safeWin);
    
        var storage=new ddplus_ScriptStorage();
        xmlhttpRequester=new ddplus_xmlhttpRequester(
            unsafeContentWin, window//appSvc.hiddenDOMWindow
        );
    
        sandbox.window=safeWin;
        sandbox.document=sandbox.window.document;
        sandbox.unsafeWindow=unsafeContentWin;
    
        // patch missing properties on xpcnw
        sandbox.XPathResult=Components.interfaces.nsIDOMXPathResult;
    
        // add our own APIs
        sandbox.GM_addStyle=function(css) { ddplus_gmCompiler.addStyle(sandbox.document, css) };
        sandbox.GM_setValue=ddplus_gmCompiler.hitch(storage, "setValue");
        sandbox.GM_getValue=ddplus_gmCompiler.hitch(storage, "getValue");
    // kick : aggiunta la funzione
        sandbox.GM_remove=ddplus_gmCompiler.hitch(storage, "remove");
        
        sandbox.GM_openInTab=ddplus_gmCompiler.hitch(this, "openInTab", unsafeContentWin);
        sandbox.GM_xmlhttpRequest=ddplus_gmCompiler.hitch(
            xmlhttpRequester, "contentStartRequest"
        );
        //unsupported
        sandbox.GM_registerMenuCommand=function(){};
        sandbox.GM_log=function(){};
        sandbox.GM_getResourceURL=function(){};
        sandbox.GM_getResourceText=function(){};
    
        sandbox.__proto__=sandbox.window;
    
        try {
            this.evalInSandbox(
                "(function(){"+script+"})()",
                url,
                sandbox);
        } catch (e) {
            var e2=new Error(typeof e=="string" ? e : e.message);
            e2.fileName=script.filename;
            e2.lineNumber=0;
            //GM_logError(e2);
            alert(e2);
        }
    },
    
    evalInSandbox: function(code, codebase, sandbox) {
        if (Components.utils && Components.utils.Sandbox) {
            // DP beta+
            Components.utils.evalInSandbox(code, sandbox);
        } else if (Components.utils && Components.utils.evalInSandbox) {
            // DP alphas
            Components.utils.evalInSandbox(code, codebase, sandbox);
        } else if (Sandbox) {
            // 1.0.x
            evalInSandbox(code, sandbox, codebase);
        } else {
            throw new Error("Could not create sandbox.");
        }
    },
    
    openInTab: function(unsafeContentWin, url) {
        var tabBrowser = getBrowser(), browser, isMyWindow = false;
        for (var i = 0; browser = tabBrowser.browsers[i]; i++)
            if (browser.contentWindow == unsafeContentWin) {
                isMyWindow = true;
                break;
            }
        if (!isMyWindow) return;
     
        var loadInBackground, sendReferrer, referrer = null;
        loadInBackground = tabBrowser.mPrefs.getBoolPref("browser.tabs.loadInBackground");
        sendReferrer = tabBrowser.mPrefs.getIntPref("network.http.sendRefererHeader");
        if (sendReferrer) {
            var ios = Components.classes["@mozilla.org/network/io-service;1"]
                                .getService(Components.interfaces.nsIIOService);
            referrer = ios.newURI(content.document.location.href, null, null);
         }
         tabBrowser.loadOneTab(url, referrer, null, null, loadInBackground);
     },
     
     hitch: function(obj, meth) {
        var unsafeTop = new XPCNativeWrapper(unsafeContentWin, "top").top;
    
        for (var i = 0; i < this.browserWindows.length; i++) {
            this.browserWindows[i].openInTab(unsafeTop, url);
        }
    },
    
    apiLeakCheck: function(allowedCaller) {
        var stack=Components.stack;
    
        var leaked=false;
        do {
            if (2==stack.language) {
                if ('chrome'!=stack.filename.substr(0, 6) &&
                    allowedCaller!=stack.filename 
                ) {
                    leaked=true;
                    break;
                }
            }
    
            stack=stack.caller;
        } while (stack);
    
        return leaked;
    },
    
    hitch: function(obj, meth) {
        if (!obj[meth]) {
            throw "method '" + meth + "' does not exist on object '" + obj + "'";
        }
    
        var hitchCaller=Components.stack.caller.filename;
        var staticArgs = Array.prototype.splice.call(arguments, 2, arguments.length);
    
        return function() {
            if (ddplus_gmCompiler.apiLeakCheck(hitchCaller)) {
                return;
            }
            
            // make a copy of staticArgs (don't modify it because it gets reused for
            // every invocation).
            var args = staticArgs.concat();
    
            // add all the new arguments
            for (var i = 0; i < arguments.length; i++) {
                args.push(arguments[i]);
            }
    
            // invoke the original function with the correct this obj and the combined
            // list of static and dynamic arguments.
            return obj[meth].apply(obj, args);
        };
    },
    
    addStyle:function(doc, css) {
        var head, style;
        head = doc.getElementsByTagName('head')[0];
        if (!head) { return; }
        style = doc.createElement('style');
        style.type = 'text/css';
        style.innerHTML = css;
        head.appendChild(style);
    },
    
    onLoad: function() {
        var    appcontent=window.document.getElementById("appcontent");
        if (appcontent && !appcontent.greased_ddplus_gmCompiler) {
            appcontent.greased_ddplus_gmCompiler=true;
            appcontent.addEventListener("DOMContentLoaded", ddplus_gmCompiler.contentLoad, false);
        }
    },
    
    onUnLoad: function() {
        //remove now unnecessary listeners
        window.removeEventListener('load', ddplus_gmCompiler.onLoad, false);
        window.removeEventListener('unload', ddplus_gmCompiler.onUnLoad, false);
        window.document.getElementById("appcontent")
            .removeEventListener("DOMContentLoaded", ddplus_gmCompiler.contentLoad, false);
    },
    
    }; //object ddplus_gmCompiler
    
    
    function ddplus_ScriptStorage() {
        this.prefMan=new ddplus_PrefManager();
    }
    ddplus_ScriptStorage.prototype.setValue = function(name, val) {
        this.prefMan.setValue(name, val);
    }
    ddplus_ScriptStorage.prototype.getValue = function(name, defVal) {
        return this.prefMan.getValue(name, defVal);
    }
    ddplus_ScriptStorage.prototype.remove = function(name) {
        return this.prefMan.remove(name);
    }
    
    window.addEventListener('load', ddplus_gmCompiler.onLoad, false);
    window.addEventListener('unload', ddplus_gmCompiler.onUnLoad, false);

    secondo voi dove sta l'inghippo?

    grazie in ogni caso

  2. #2
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Ciao e benvenuto, stai lavorando in locale o online?
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2013
    Messaggi
    4
    Ciao e grazie. in pratica è un tool creato appositamente per un forum...con delle funzioni mirate al semplificare le azioni giornaliere del moderatore. Ora il forum ha cambiato dominio e ho cercato di renderla compatibile con il nuovo forum. in pratica st modificando il file js con un semplice editor di testo. l'errore lo ettendo quando modifico lo script che ho postato sopra...più precisamente questa parte:

    codice:
    if (
            ddplus_gmCompiler.isGreasemonkeyable(href)
            && ( /http:\/\/ddunlimited\.net/.test(href) )
            && true
        ) {
    il resto lo lascio tutto invariato.
    nel caso non tocco questo script...alcune funzioni spariscono e non sono più presenti.

  4. #4
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    In questi casi io consiglio di contattare lo sviluppatore del tool, oltretutto qui sul forum si sviluppa poco (praticamente nulla) tool/estensioni per browser
    Ultima modifica di cavicchiandrea; 24-10-2013 a 20:37
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  5. #5
    Utente di HTML.it
    Registrato dal
    Oct 2013
    Messaggi
    4
    purtroppo non è contattabile

  6. #6
    Utente di HTML.it
    Registrato dal
    Oct 2013
    Messaggi
    4
    ciao

    aggiorno la situazione dopo varie richieste in rete...

    l'errore sta a significare che appunto c'è un loop infinito e che a un certo punto non c'è più memoria disponibile.
    lo script compiler che ho postato non è quello che causa l'errore ma, evalInSandbox è proprio la funzione che valuta lo script utente. lo script è questo https://gist.github.com/anonymous/7152904

    il motivo è un ciclo infinito nel codice alla riga 425 (segue):

    codice:
    var max = textArea.parentNode.parentNode.clientHeight;
    while (max == textArea.parentNode.parentNode.clientHeight)
      textArea.rows++;
    questo ciclo non terminerà mai perchè la condizione non sarà mai false.
    il codice in questione tenta di determinare il numero di righe (altezza in righe) in un <textarea> , non le linee.
    L'errore per ora sono riuscito a toglierlo...ma la funzione salva testi personali tramite un tasto e aggiungi/rimuovi un set emoticon personali non funzionano...
    Mi è stato linkato questo: http://jsfiddle.net/qkkYu/

    idee su come mettere in pratica il consiglio? Purtroppo io so fare solo piccole modifiche e aggiunte...non di più

Tag per questa discussione

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.