diff --git a/chrome/content/imglikeopera.js b/chrome/content/imglikeopera.js index f1806fd..79034a2 100755 --- a/chrome/content/imglikeopera.js +++ b/chrome/content/imglikeopera.js @@ -653,6 +653,6 @@ var ILO = { } }; -window.addEventListener("load", function() ILO.onLoad(), false); -window.addEventListener("unload", function() ILO.unLoad(), false); +window.addEventListener("load", function(){ILO.onLoad();}, false); +window.addEventListener("unload", function(){ILO.unLoad();}, false); window.addEventListener("delayLoadRefresher", ILO, false); diff --git a/chrome/content/preferences/filters.js b/chrome/content/preferences/filters.js index dbe90f6..11c0131 100755 --- a/chrome/content/preferences/filters.js +++ b/chrome/content/preferences/filters.js @@ -30,7 +30,7 @@ const Filters = { this.rButtons = document.getElementById("iloPermButtons").childNodes; this.rPopup = document.getElementById("iloFiltersPopup").childNodes; - let policyPatternsData = (this.settings.policy_patterns || []).split(" "); + let policyPatternsData = (this.settings.policy_patterns || []).toString().split(" "); for (let i = 0, len = policyPatternsData.length - 1; i < len; i++) this.treeAddItem(policyPatternsData[i].split(" ")); }, @@ -449,3 +449,9 @@ const Filters = { select[0]]; } }; + +Object.defineProperty(this, "Filters", { + value: Filters, + enumerable: true, + writable: false +}); diff --git a/chrome/content/preferences/preferences.js b/chrome/content/preferences/preferences.js index 62f936d..96f6ce2 100755 --- a/chrome/content/preferences/preferences.js +++ b/chrome/content/preferences/preferences.js @@ -128,8 +128,8 @@ const Preferences = { let actualValue = typeof preference.value != "undefined" ? preference.value : preference.defaultValue; let modesValue = (actualValue || "1,2,3,4") .split(",") - .map(function(mode) parseInt(mode, 10)) - .filter(function(mode) mode >= 1 && mode <= 4) + .map(function(mode) {parseInt(mode, 10)}) + .filter(function(mode) {mode >= 1 && mode <= 4}) .sort(); if (!modesValue.length) @@ -158,5 +158,11 @@ const Preferences = { } }; +Object.defineProperty(this, "Preferences", { + value: Preferences, + enumerable: true, + writable: false +}); + window.addEventListener("load", Preferences, false); window.addEventListener("paneload", Preferences, false); diff --git a/components/nsImgLikeOpera.js b/components/nsImgLikeOpera.js index d86fe43..37e9b63 100755 --- a/components/nsImgLikeOpera.js +++ b/components/nsImgLikeOpera.js @@ -35,6 +35,12 @@ const nsICacheEntryDescriptor = Ci.nsICacheEntryDescriptor; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); +function makeURI(aURL, aOriginCharset, aBaseURI) { + var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); + return ioService.newURI(aURL, aOriginCharset, aBaseURI); +} + + /************************************************************************ * * Smthng... @@ -47,16 +53,16 @@ Cu.import("resource://gre/modules/Services.jsm"); } CacheListener.prototype = { - onCacheEntryAvailable: function CacheListener_onCacheEntryAvailable(descriptor, accessGranted, status) { - this.descriptor = descriptor; + onCacheEntryCheck: function (entry, appcache) { + return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED; + }, + onCacheEntryAvailable: function (entry, isnew, appcache, status) { + this.descriptor = entry; this.status = status; this.done = true; }, - - onCacheEntryDoomed: function CacheListener_onCacheEntryDoomed() {}, - QueryInterface: function(iid) { - if (iid.equals(Ci.nsICacheListener)) + if (iid.equals(Ci.nsISupports) || iid.equals(Ci.nsICacheEntryOpenCallback)) return this; throw Cr.NS_NOINTERFACE; } @@ -64,10 +70,10 @@ Cu.import("resource://gre/modules/Services.jsm"); const THREAD_MANAGER = Cc["@mozilla.org/thread-manager;1"].getService(); - that.syncGetCacheEntry = function syncGetCacheEntry(aCacheSession, aKey, aAccessMode) { + that.syncGetCacheEntry = function syncGetCacheEntry(aCacheSession, aKey) { let startTime = Date.now(); let listener = new CacheListener(); - aCacheSession.asyncOpenCacheEntry(aKey, aAccessMode, listener, true); + aCacheSession.asyncOpenURI(makeURI(aKey), "", Ci.nsICacheStorage.OPEN_READONLY, listener); while (!(listener.done || Math.abs(Date.now() - startTime) > 5000)) { // if (Math.abs(Date.now() - startTime) > 5000) @@ -86,15 +92,12 @@ function nsImgLikeOpera() { this.wrappedJSObject = this; // cache sessions - const CACHE_SERVICE = Cc["@mozilla.org/network/cache-service;1"].getService(Ci.nsICacheService); + let {LoadContextInfo} = Cu.import( + "resource://gre/modules/LoadContextInfo.jsm", {}); + const CACHE_SERVICE = Cc["@mozilla.org/netwerk/cache-storage-service;1"].getService(Ci.nsICacheStorageService); + let httpCacheSession = CACHE_SERVICE.diskCacheStorage(LoadContextInfo.default, false); - let httpCacheSession = CACHE_SERVICE.createSession("HTTP", nsICache.STORE_ANYWHERE, nsICache.STREAM_BASED); - httpCacheSession.doomEntriesIfExpired = false; - - let imageCacheSession = CACHE_SERVICE.createSession("image", nsICache.STORE_ANYWHERE, nsICache.NOT_STREAM_BASED); - imageCacheSession.doomEntriesIfExpired = false; - - this.cacheSessions = [httpCacheSession, imageCacheSession]; + this.cacheSessions = [httpCacheSession]; Services.obs.addObserver(this, "profile-after-change", false); Services.obs.addObserver(this, "profile-before-change", false); @@ -128,7 +131,7 @@ nsImgLikeOpera.prototype = { "Settings", "DocumentData", "FileUtils" - ].forEach(function(moduleName) Cu.import("resource://imglikeopera-modules/" + moduleName + ".jsm")); + ].forEach(function(moduleName) {Cu.import("resource://imglikeopera-modules/" + moduleName + ".jsm")}); // TODO: loader/unloader AddonManager.startup(); @@ -284,8 +287,8 @@ nsImgLikeOpera.prototype = { if (this._policySwitchModes === null) { let modesValue = (this.settings.policy_switchModes || "1,2,3,4") .split(",") - .map(function(mode) parseInt(mode, 10)) - .filter(function(mode) mode >= 1 && mode <= 4); + .map(function(mode) {return parseInt(mode, 10);}) + .filter(function(mode) {return mode >= 1 && mode <= 4;}); if (!modesValue.length) modesValue = [1,2,3,4]; @@ -324,7 +327,7 @@ nsImgLikeOpera.prototype = { cssFileContent = cssFileContent.replace(/\/\*font\*\//, fontSettings); const sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService); - let u = Services.io.newURI("data:text/css," + cssFileContent, null, null); + let u = Services.io.newURI("data:text/css," + encodeURIComponent(cssFileContent), null, null); if (sss.sheetRegistered(u, sss.USER_SHEET)) sss.unregisterSheet(u, sss.USER_SHEET); @@ -375,7 +378,7 @@ nsImgLikeOpera.prototype = { return; try { - this._sessionStoreService.setTabValue(aTab, "ilo-tab-policy", aPolicy); + this._sessionStoreService.setTabValue(aTab, "ilo-tab-policy", aPolicy.toString()); } catch(e) {} }, @@ -420,7 +423,7 @@ nsImgLikeOpera.prototype = { /** * Policy (shouldProcess/shouldLoad) */ - shouldProcess: function ILO_shouldProcess() ACCEPT, + shouldProcess: function ILO_shouldProcess() {return ACCEPT;}, /** * So... should load? @@ -545,7 +548,7 @@ nsImgLikeOpera.prototype = { if (!wnd) return; - wnd.setTimeout(function() aNode[aAction].apply(aNode, aActionArguments), 0); + wnd.setTimeout(function() {aNode[aAction].apply(aNode, aActionArguments)}, 0); }, _getObjectWidthAndHeight: function ILO__getObjectWidthAndHeight(aObject) { @@ -621,11 +624,15 @@ nsImgLikeOpera.prototype = { removeCacheEntry: function ILO_removeCacheEntry(aURL) { this.cacheSessions.forEach(function(aCacheSession) { try { - let cacheEntryDescriptor = aCacheSession.openCacheEntry(aURL, nsICacheEntryDescriptor, false); - if (cacheEntryDescriptor) { - cacheEntryDescriptor.doom(); - cacheEntryDescriptor.close(); + aCacheSession.asyncOpenURI(makeURI(aURL), "", Ci.nsICacheStorage.OPEN_READONLY, + { + onCacheEntryCheck: function (entry, appcache) { + return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED; + }, + onCacheEntryAvailable: function (entry, isnew, appcache, status) { + if (entry) entry.asyncDoom(null); } + }); } catch(e) {} }); @@ -646,7 +653,7 @@ nsImgLikeOpera.prototype = { if (forcedExpTime > 0) { for each (let cacheSession in this.cacheSessions) { try { - cacheEntryDescriptor = syncGetCacheEntry(cacheSession, url, nsICache.ACCESS_READ_WRITE).descriptor; + cacheEntryDescriptor = syncGetCacheEntry(cacheSession, url).descriptor; } catch(e) {} if (cacheEntryDescriptor) { @@ -654,23 +661,20 @@ nsImgLikeOpera.prototype = { let expirationTime = cacheEntryDescriptor.lastModified + forcedExpTime; if (expirationTime < timenow) { // || !cacheEntryDescriptor.dataSize(?)) { - cacheEntryDescriptor.doom(); + cacheEntryDescriptor.asyncDoom(null); } else { expired = false; if (cacheEntryDescriptor.expirationTime != expirationTime) { cacheEntryDescriptor.setExpirationTime(expirationTime); - cacheEntryDescriptor.markValid(); } } } - cacheEntryDescriptor.close(); - if (!expired) { try { // Need to call this after setExpirationTime for properly expiration time. - syncGetCacheEntry(cacheSession, url, nsICache.ACCESS_READ); + syncGetCacheEntry(cacheSession, url); } catch(ex) { expired = true; } @@ -683,14 +687,13 @@ nsImgLikeOpera.prototype = { } else if (docpolicy == 3) { for each (let cacheSession in this.cacheSessions) { try { - cacheEntryDescriptor = syncGetCacheEntry(cacheSession, url, nsICache.ACCESS_READ).descriptor; + cacheEntryDescriptor = syncGetCacheEntry(cacheSession, url).descriptor; } catch(e) {} if (cacheEntryDescriptor) { if (cacheEntryDescriptor.expirationTime > timenow) expired = false; - cacheEntryDescriptor.close(); break; // for each } @@ -813,7 +816,9 @@ nsImgLikeOpera.prototype = { var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsImgLikeOpera]); -this.__defineGetter__("gILO", function gILOGetter() { - delete this.gILO; - return this.gILO = Cc["@mozilla.org/imglikeopera;1"].getService().wrappedJSObject; +Object.defineProperty(this, "gILO", { + get: function gILOGetter() { + delete this.gILO; + return this.gILO = Cc["@mozilla.org/imglikeopera;1"].getService().wrappedJSObject; + } }); diff --git a/install.rdf b/install.rdf index e1950e9..0ad0f56 100755 --- a/install.rdf +++ b/install.rdf @@ -35,7 +35,17 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} - 19.0 + 38.0 + 56.* + + + + + + + {8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4} + 26.0 + 28.* diff --git a/modules/AddonManager.jsm b/modules/AddonManager.jsm index 20585d9..af2dd08 100755 --- a/modules/AddonManager.jsm +++ b/modules/AddonManager.jsm @@ -18,15 +18,15 @@ const AddonManager = { // > 0 - curent > last addonVersionState: 0, // Is version changed? - get addonVersionChanged() this.addonVersionState != 0, + get addonVersionChanged() {return this.addonVersionState != 0;}, // ...up? - get addonUpgraded() this.addonVersionState > 0, + get addonUpgraded() {return this.addonVersionState > 0;}, // ...or down? - get addonDowngraded() this.addonVersionState < 0, + get addonDowngraded() {return this.addonVersionState < 0;}, // Previous version. addonLastVersion: "0", // true == "fresh" install. - get freshInstall() this.addonLastVersion === "0" + get freshInstall() {return this.addonLastVersion === "0";} }; this._start(); diff --git a/modules/DocumentData.jsm b/modules/DocumentData.jsm index 578231b..e98310d 100755 --- a/modules/DocumentData.jsm +++ b/modules/DocumentData.jsm @@ -1,6 +1,6 @@ "use strict"; -let EXPORTED_SYMBOLS = ["DocumentData"]; +var EXPORTED_SYMBOLS = ["DocumentData"]; function DocumentData(aTab, aDelay) { this.clearURLStatus(); diff --git a/modules/FileUtils.jsm b/modules/FileUtils.jsm index f19a37a..7b774cc 100755 --- a/modules/FileUtils.jsm +++ b/modules/FileUtils.jsm @@ -1,6 +1,6 @@ "use strict"; -let EXPORTED_SYMBOLS = ["FileUtils"]; +var EXPORTED_SYMBOLS = ["FileUtils"]; const { classes: Cc, diff --git a/modules/Preferences.jsm b/modules/Preferences.jsm index 4e308ae..98c2735 100755 --- a/modules/Preferences.jsm +++ b/modules/Preferences.jsm @@ -35,7 +35,7 @@ * * ***** END LICENSE BLOCK ***** */ -let EXPORTED_SYMBOLS = ["Preferences", "Prefs"]; +var EXPORTED_SYMBOLS = ["Preferences", "Prefs"]; const Cc = Components.classes; const Ci = Components.interfaces; @@ -76,7 +76,7 @@ Preferences.prototype = { */ get: function(prefName, defaultValue) { if (isArray(prefName)) - return prefName.map(function(v) this.get(v, defaultValue), this); + return prefName.map(function(v) {return this.get(v, defaultValue);}, this); if (this._site) return this._siteGet(prefName, defaultValue); @@ -106,7 +106,7 @@ Preferences.prototype = { } }, - get prefBranch() this._prefBranch, + get prefBranch() {return this._prefBranch;}, _siteGet: function(prefName, defaultValue) { let value = this._contentPrefSvc.getPref(this._site, this._prefBranch + prefName); @@ -278,11 +278,11 @@ Preferences.prototype = { * which is equivalent. * @deprecated */ - modified: function(prefName) { return this.isSet(prefName) }, + modified: function(prefName) { return this.isSet(prefName); }, reset: function(prefName) { if (isArray(prefName)) { - prefName.map(function(v) this.reset(v), this); + prefName.map(function(v) {return this.reset(v);}, this); return; } @@ -414,9 +414,9 @@ Preferences.prototype = { // make it. We could index by fullBranch, but we can't index by callback // or thisObject, as far as I know, since the keys to JavaScript hashes // (a.k.a. objects) can apparently only be primitive values. - let [observer] = observers.filter(function(v) v.prefName == fullPrefName && + let [observer] = observers.filter(function(v) {return v.prefName == fullPrefName && v.callback == callback && - v.thisObject == thisObject); + v.thisObject == thisObject;}); if (observer) { Preferences._prefSvc.removeObserver(fullPrefName, observer); @@ -459,7 +459,7 @@ Preferences.prototype = { getService(Ci.nsIPrefService). getBranch(this._prefBranch). QueryInterface(Ci.nsIPrefBranch2); - this.__defineGetter__("_prefSvc", function() prefSvc); + this.__defineGetter__("_prefSvc", function() {return prefSvc;}); return this._prefSvc; }, @@ -470,7 +470,7 @@ Preferences.prototype = { get _ioSvc() { let ioSvc = Cc["@mozilla.org/network/io-service;1"]. getService(Ci.nsIIOService); - this.__defineGetter__("_ioSvc", function() ioSvc); + this.__defineGetter__("_ioSvc", function() {return ioSvc;}); return this._ioSvc; }, @@ -481,7 +481,7 @@ Preferences.prototype = { get _contentPrefSvc() { let contentPrefSvc = Cc["@mozilla.org/content-pref/service;1"]. getService(Ci.nsIContentPrefService); - this.__defineGetter__("_contentPrefSvc", function() contentPrefSvc); + this.__defineGetter__("_contentPrefSvc", function() {return contentPrefSvc;}); return this._contentPrefSvc; } @@ -575,9 +575,9 @@ Preferences.prototype.observe2 = function(prefName, callback, thisObject) { Preferences.prototype.ignore2 = function(prefName, callback, thisObject) { let fullPrefName = this._prefBranch + (prefName || ""); - let [observer] = observers2.filter(function(v) v.prefName == fullPrefName && + let [observer] = observers2.filter(function(v) {return v.prefName == fullPrefName && v.callback == callback && - v.thisObject == thisObject); + v.thisObject == thisObject;}); if (observer) { Preferences._prefSvc.removeObserver(fullPrefName, observer); diff --git a/modules/Settings.jsm b/modules/Settings.jsm index 826fd3b..8269646 100755 --- a/modules/Settings.jsm +++ b/modules/Settings.jsm @@ -1,6 +1,6 @@ "use strict"; -let EXPORTED_SYMBOLS = ["Settings"]; +var EXPORTED_SYMBOLS = ["Settings"]; Components.utils.import("resource://imglikeopera-modules/Preferences.jsm"); @@ -12,7 +12,7 @@ Components.utils.import("resource://imglikeopera-modules/Preferences.jsm"); /************************************************************************/ -let Settings = Proxy.create({ +var Settings = new Proxy({}, { get: function SettingsProxy_get(aProxy, aName) { let prefName = propName2prefName(aName); @@ -51,5 +51,5 @@ Prefs.observe2("", settingsObserver); /************************************************************************/ -function prefName2propName(str) str.replace(/\./g, "_"); -function propName2prefName(str) str.replace(/_/g, "."); +function prefName2propName(str) {return str.replace(/\./g, "_");} +function propName2prefName(str) {return str.replace(/_/g, ".");}