Infocatcher / Private_Tab

Adds private tabs, restartless extension for Firefox (20.0+) and SeaMonkey (2.17+)
https://addons.mozilla.org/addon/private-tab/
Other
86 stars 20 forks source link

Doesn't work in Firefox 51.0a1+ (SyntaxError: non-generator method definitions may not contain yield) #228

Closed Infocatcher closed 8 years ago

Infocatcher commented 8 years ago

Currently used (and doesn't work anymore):

var o = {
    get windows() {
        var ws = Services.wm.getEnumerator("navigator:browser");
        while(ws.hasMoreElements())
            yield ws.getNext(); // SyntaxError: non-generator method definitions may not contain yield
    }
};
for(var w in o.windows)
    alert(w.document.title);

Alternatives:

// Legacy generator, will be removed: https://bugzilla.mozilla.org/show_bug.cgi?id=1083482
var o = {
    windows: function() {
        var ws = Services.wm.getEnumerator("navigator:browser");
        while(ws.hasMoreElements())
            yield ws.getNext();
    }
};
for(var w in o.windows())
    alert(w.document.title);
// Modern generator, Firefox 26+
var o = {
    windows: function*() {
        var ws = Services.wm.getEnumerator("navigator:browser");
        while(ws.hasMoreElements())
            yield ws.getNext();
    }
};
for(var w of o.windows())
    alert(w.document.title);
// Old-school array (Firefox 1.5+) + for-of (Firefox 13+)
var o = {
    get windows() {
        var windows = [];
        var ws = Services.wm.getEnumerator("navigator:browser");
        while(ws.hasMoreElements())
            windows.push(ws.getNext());
        return windows;
    }
};
for(var w of o.windows)
    alert(w.document.title);
Infocatcher commented 8 years ago

Yet another trick:

var o = {
    get windows() {
        return (function*() {
            var ws = Services.wm.getEnumerator("navigator:browser");
            while(ws.hasMoreElements())
                yield ws.getNext();
        })();
    }
};
for(var w of o.windows)
    alert(w.document.title);
Infocatcher commented 8 years ago

Test version: private_tab-0.1.9.2pre4-fx-sm.xpi (source code).

mikhoul commented 8 years ago

Test Version work under 47.0.1 version.

Will this "test" version will update automatically or it's better to update to the release to have automatic update ?

Regards 🐸

Infocatcher commented 8 years ago

Will this "test" version will update automatically or it's better to update to the release to have automatic update ?

There is custom update URL in test versions: https://github.com/Infocatcher/Private_Tab/blob/78ce514ba2132982c34ec8c0a953e8b8b55d3b62/install.rdf#L14-L17 But for now I'm configure this only to update to release versions (so, test version will be auto-updated to next non-test release).

mikhoul commented 8 years ago

Thanx for the reply ! :smile: