From 7acaf3baed0d0d8f608ee17de0b5752d72e99fc5 Mon Sep 17 00:00:00 2001 From: Noitidart Date: Wed, 11 May 2016 18:17:02 -0700 Subject: [PATCH] 1.10 RELEASE --- bootstrap.js | 92 +++++++-------- install.rdf | 4 +- modules/MainWorker/MainWorker.js | 144 +++++++++++------------ resources/scripts/ab-react-components.js | 18 +-- resources/scripts/fsInlay.js | 80 ++++++------- 5 files changed, 169 insertions(+), 169 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 893bb05..86f8edd 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -46,7 +46,7 @@ const core = { modules: 'chrome://chrome-store-foxified/content/modules/', workers: 'chrome://chrome-store-foxified/content/modules/workers/', }, - cache_key: Math.random() // set to version on release + cache_key: 'v1.10' // set to version on release }, os: { name: OS.Constants.Sys.Name.toLowerCase(), @@ -95,7 +95,7 @@ var MainWorkerMainThreadFuncs = { var installListener = { onInstallEnded: function(aInstall, aAddon) { var str = []; - console.log('ok install ended'); + //str.push('"' + aAddon.name + '" Install Ended!'); if (aAddon.appDisabled) { //str.push('appDisabled: ' + aAddon.appDisabled); @@ -150,14 +150,14 @@ var MainWorkerMainThreadFuncs = { } }; - console.log('ok making nsifile'); + var xpiNsiFile = new FileUtils.File(aXpiPlatPath); - console.log('ok made'); + AddonManager.getInstallForFile(xpiNsiFile, function(aInstall) { // aInstall is an instance of AddonInstall - console.log('ok adding listeners'); + aInstall.addListener(installListener); - console.log('ok kicking off install'); + aInstall.install(); //does silent install // AddonManager.installAddonsFromWebpage('application/x-xpinstall', Services.wm.getMostRecentWindow('navigator:browser').gBrowser.selectedBrowser, null, [aInstall]); //does regular popup install }, 'application/x-xpinstall'); @@ -279,7 +279,7 @@ var MainWorkerMainThreadFuncs = { var promise_tempInstall = AddonManager.installTemporaryAddon(xpi); promise_tempInstall.then( function(aVal) { - console.log('Fullfilled - promise_tempInstall - ', aVal, 'arguments:', arguments); + aAttnBarInfoObj.aPriority = 6; aAttnBarInfoObj.aTxt = gL10N.bootstrap['installed-as-temp']; @@ -299,7 +299,7 @@ var MainWorkerMainThreadFuncs = { name: 'promise_tempInstall', aReason: aReason }; - console.error('Rejected - promise_tempInstall - ', rejObj); + aAttnBarInfoObj.aPriority = 10; aAttnBarInfoObj.aTxt = gL10N.bootstrap['install-as-temp-fail']; @@ -319,7 +319,7 @@ var MainWorkerMainThreadFuncs = { name: 'promise_tempInstall', aCaught: aCaught }; - console.error('Caught - promise_tempInstall - ', rejObj); + Services.prompt.alert(null, 'Error', "devleoper error!!! Error while installing the addon: see browser console!!\n"); // xpi.append('noida.txt'); xpi = null; @@ -377,7 +377,7 @@ var AB = { // AB stands for attention bar if (winAB) { if (aInstId in winAB.Insts) { // unmount this - console.error('aInstId:', aInstId, 'notificationbox-' + aInstId + '--' + AB.domIdPrefix); + var cNotificationBox = aDOMWindow.document.getElementById('notificationbox-' + aInstId + '--' + AB.domIdPrefix); aDOMWindow.ReactDOM.unmountComponentAtNode(cNotificationBox); cNotificationBox.parentNode.removeChild(cNotificationBox); @@ -511,7 +511,7 @@ var AB = { // AB stands for attention bar aDOMWindow[core.addon.id + '-AB'].Insts[aInstState.aId].state = aDOMWindow.JSON.parse(aDOMWindow.JSON.stringify(aInstState)); var cDeck = aDOMWindow.document.getElementById('content-deck'); var cNotificationBox = aDOMWindow.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'notificationbox'); - console.error('inserting', 'notificationbox-' + aInstState.aId + '--' + AB.domIdPrefix); + cNotificationBox.setAttribute('id', 'notificationbox-' + aInstState.aId + '--' + AB.domIdPrefix); if (!aInstState.aPos) { cDeck.parentNode.appendChild(cNotificationBox); @@ -576,19 +576,19 @@ var AB = { // AB stands for attention bar if (!aDOMWindow[core.addon.id + '-AB']) { return; } - console.error('doing uninit from window'); + // start - original block link77728110 var winAB = aDOMWindow[core.addon.id + '-AB']; for (var aInstsId in winAB.Insts) { // unmount this - console.error('aInstsId:', aInstsId, 'notificationbox-' + aInstsId + '--' + AB.domIdPrefix); + var cNotificationBox = aDOMWindow.document.getElementById('notificationbox-' + aInstsId + '--' + AB.domIdPrefix); aDOMWindow.ReactDOM.unmountComponentAtNode(cNotificationBox); cNotificationBox.parentNode.removeChild(cNotificationBox); } // end - original block link77728110 delete aDOMWindow[core.addon.id + '-AB']; - console.error('done uninit'); + aDOMWindow.removeEventListener(core.addon.id + '-AB', AB.msgEventListener, false); }, ensureInitedIntoWindow: function(aDOMWindow) { @@ -599,12 +599,12 @@ var AB = { // AB stands for attention bar domIdPrefix: AB.domIdPrefix }; // ab stands for attention bar if (!aDOMWindow.React) { - console.log('WILL NOW LOAD IN REACT'); + // resource://devtools/client/shared/vendor/react.js Services.scriptloader.loadSubScript(core.addon.path.scripts + 'react.js?' + core.addon.cache_key, aDOMWindow); // even if i load it into aDOMWindow.blah and .blah is an object, it goes into global, so i just do aDOMWindow now } if (!aDOMWindow.ReactDOM) { - console.log('WILL NOW LOAD IN REACTDOM'); + // resource://devtools/client/shared/vendor/react-dom.js Services.scriptloader.loadSubScript(core.addon.path.scripts + 'react-dom.js?' + core.addon.cache_key, aDOMWindow); } @@ -636,7 +636,7 @@ var AB = { // AB stands for attention bar } }, msgEventListener: function(e) { - console.error('getting aMsgEvent, data:', e.detail); + var cCallbackId = e.detail.cbid; var cBrowser = e.detail.browser; if (AB.Callbacks[cCallbackId]) { // need this check because react components always send message on click, but it may not have a callback @@ -646,7 +646,7 @@ var AB = { // AB stands for attention bar // msgListener: { // receiveMessage: function(aMsgEvent) { // var aMsgEventData = aMsgEvent.data; - // console.error('getting aMsgEvent, data:', aMsgEventData); + // // this means trigger a callback with id aMsgEventData // var cCallbackId = aMsgEventData; // var cBrowser = aMsgEvent.target; @@ -681,7 +681,7 @@ var AB = { // AB stands for attention bar for (var aInstId in AB.Insts) { var aInstState = AB.Insts[aInstId].state; if (aInstState.aId in aDOMWindow[core.addon.id + '-AB'].Insts) { - console.error('this is really weird, it should never happen, as i only call this function when a new window opens'); + aDOMWindow[core.addon.id + '-AB'].Insts[aInstState.aId].state = aDOMWindow.JSON.parse(aDOMWindow.JSON.stringify(aInstState)); aDOMWindow[core.addon.id + '-AB'].Insts[aInstState.aId].setState(JSON.parse(JSON.stringify(aInstState))); } else { @@ -690,7 +690,7 @@ var AB = { // AB stands for attention bar aDOMWindow[core.addon.id + '-AB'].Insts[aInstState.aId].state = aDOMWindow.JSON.parse(aDOMWindow.JSON.stringify(aInstState)); var cDeck = aDOMWindow.document.getElementById('content-deck'); var cNotificationBox = aDOMWindow.document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'notificationbox'); - console.error('inserting', 'notificationbox-' + aInstState.aId + '--' + AB.domIdPrefix); + cNotificationBox.setAttribute('id', 'notificationbox-' + aInstState.aId + '--' + AB.domIdPrefix); if (!aInstState.aPos) { cDeck.parentNode.appendChild(cNotificationBox); @@ -777,7 +777,7 @@ function startup(aData, aReason) { var aTimer = Cc['@mozilla.org/timer;1'].createInstance(Ci.nsITimer); aTimer.initWithCallback({ notify: function() { - console.error('ok starting up adding'); + // register framescript listener Services.mm.addMessageListener(core.addon.id, fsMsgListener); @@ -791,7 +791,7 @@ function startup(aData, aReason) { var promise_initMainWorker = SIPWorker('MainWorker', core.addon.path.modules + 'MainWorker/MainWorker.js?' + core.addon.cache_key, core, MainWorkerMainThreadFuncs); promise_initMainWorker.then( function(aInitObj) { - console.log('Fullfilled - promise_initMainWorker - ', aInitObj); + // start - do stuff here - promise_initMainWorker setupMainWorkerCustomErrors(); afterWorker(aInitObj); @@ -802,7 +802,7 @@ function startup(aData, aReason) { name: 'promise_initMainWorker', aReason: aReason }; - console.warn('Rejected - promise_initMainWorker - ', rejObj); + } ).catch( function(aCaught) { @@ -810,7 +810,7 @@ function startup(aData, aReason) { name: 'promise_initMainWorker', aCaught: aCaught }; - console.error('Caught - promise_initMainWorker - ', rejObj); + } ); @@ -833,7 +833,7 @@ function shutdown(aData, aReason) { // terminate worker if (typeof(MainWorker) != 'undefined') { MainWorker._worker.terminate(); - console.log('ok terminated worker'); + } } @@ -843,7 +843,7 @@ var fsFuncs = { // can use whatever, but by default its setup to use this requestInit: function(aMsgEvent) { // start - l10n injection into fs - console.error('in requestinit server side'); + return [{ aCore: core, @@ -903,7 +903,7 @@ var fsFuncs = { // can use whatever, but by default its setup to use this var rez_pwcall = MainWorker.post(aArrOfWorker_FuncnameThenArgs.shift(), aArrOfWorker_FuncnameThenArgs); rez_pwcall.then( function(aVal) { - console.log('Fullfilled - rez_pwcall - ', aVal); + if (returnToFramescript) { if (Array.isArray(aVal)) { mainDeferred_callInPromiseWorker.resolve(aVal); @@ -917,7 +917,7 @@ var fsFuncs = { // can use whatever, but by default its setup to use this name: 'rez_pwcall', aReason: aReason }; - console.error('Rejected - rez_pwcall - ', rejObj); + if (returnToFramescript) { mainDeferred_callInPromiseWorker.resolve([rejObj]); } @@ -928,7 +928,7 @@ var fsFuncs = { // can use whatever, but by default its setup to use this name: 'rez_pwcall', aCaught: aCaught }; - console.error('Caught - rez_pwcall - ', rejObj); + if (returnToFramescript) { mainDeferred_callInPromiseWorker.resolve([rejObj]); } @@ -944,7 +944,7 @@ var fsMsgListener = { funcScope: fsFuncs, receiveMessage: function(aMsgEvent) { var aMsgEventData = aMsgEvent.data; - console.log('fsMsgListener getting aMsgEventData:', aMsgEventData, 'aMsgEvent:', aMsgEvent); + // aMsgEvent.data should be an array, with first item being the unfction name in bootstrapCallbacks var callbackPendingId; @@ -967,23 +967,23 @@ var fsMsgListener = { aMsgEvent.target.messageManager.sendAsyncMessage(core.addon.id, [callbackPendingId, aVal]); }, function(aReason) { - console.error('aReject:', aReason); + aMsgEvent.target.messageManager.sendAsyncMessage(core.addon.id, [callbackPendingId, ['promise_rejected', aReason]]); } ).catch( function(aCatch) { - console.error('aCatch:', aCatch); + aMsgEvent.target.messageManager.sendAsyncMessage(core.addon.id, [callbackPendingId, ['promise_rejected', aCatch]]); } ); } else { // assume array - console.warn('ok responding to callback id:', callbackPendingId, aMsgEvent.target); + aMsgEvent.target.messageManager.sendAsyncMessage(core.addon.id, [callbackPendingId, rez_parentscript_call]); } } } - else { console.warn('funcName', funcName, 'not in scope of this.funcScope') } // else is intentionally on same line with console. so on finde replace all console. lines on release it will take this out + } }; @@ -1077,7 +1077,7 @@ function validateOptionsObj(aOptions, aOptionsDefaults) { // ensures no invalid keys are found in aOptions, any key found in aOptions not having a key in aOptionsDefaults causes throw new Error as invalid option for (var aOptKey in aOptions) { if (!(aOptKey in aOptionsDefaults)) { - console.error('aOptKey of ' + aOptKey + ' is an invalid key, as it has no default value, aOptionsDefaults:', aOptionsDefaults, 'aOptions:', aOptions); + throw new Error('aOptKey of ' + aOptKey + ' is an invalid key, as it has no default value'); } } @@ -1132,7 +1132,7 @@ function genericReject(aPromiseName, aPromiseToReject, aReason) { name: aPromiseName, aReason: aReason }; - console.error('Rejected - ' + aPromiseName + ' - ', rejObj); + if (aPromiseToReject) { aPromiseToReject.reject(rejObj); } @@ -1142,7 +1142,7 @@ function genericCatch(aPromiseName, aPromiseToReject, aCaught) { name: aPromiseName, aCaught: aCaught }; - console.error('Caught - ' + aPromiseName + ' - ', rejObj); + if (aPromiseToReject) { aPromiseToReject.reject(rejObj); } @@ -1175,10 +1175,10 @@ function SIPWorker(workerScopeName, aPath, aCore=core, aFuncExecScope) { bootstrap[workerScopeName]._worker.onmessage = function(aMsgEvent) { ////// start - my custom stuff var aMsgEventData = aMsgEvent.data; - console.log('promiseworker receiving msg:', aMsgEventData); + if (Array.isArray(aMsgEventData)) { // my custom stuff, PromiseWorker did self.postMessage to call a function from here - console.log('promsieworker is trying to execute function in mainthread'); + var callbackPendingId; if (typeof aMsgEventData[aMsgEventData.length-1] == 'string' && aMsgEventData[aMsgEventData.length-1].indexOf(SIP_CB_PREFIX) == 0) { @@ -1195,7 +1195,7 @@ function SIPWorker(workerScopeName, aPath, aCore=core, aFuncExecScope) { function(aVal) { if (aVal.length >= 2 && aVal[aVal.length-1] == SIP_TRANS_WORD && Array.isArray(aVal[aVal.length-2])) { // to transfer in callback, set last element in arr to SIP_TRANS_WORD and 2nd to last element an array of the transferables // cannot transfer on promise reject, well can, but i didnt set it up as probably makes sense not to - console.error('doing transferrrrr'); + aVal.pop(); bootstrap[workerScopeName]._worker.postMessage([callbackPendingId, aVal], aVal.pop()); } else { @@ -1203,12 +1203,12 @@ function SIPWorker(workerScopeName, aPath, aCore=core, aFuncExecScope) { } }, function(aReason) { - console.error('aReject:', aReason); + bootstrap[workerScopeName]._worker.postMessage([callbackPendingId, ['promise_rejected', aReason]]); } ).catch( function(aCatch) { - console.error('aCatch:', aCatch); + bootstrap[workerScopeName]._worker.postMessage([callbackPendingId, ['promise_rejected', aCatch]]); } ); @@ -1224,7 +1224,7 @@ function SIPWorker(workerScopeName, aPath, aCore=core, aFuncExecScope) { } } } - else { console.error('funcName', funcName, 'not in scope of aFuncExecScope') } // else is intentionally on same line with console. so on finde replace all console. lines on release it will take this out + ////// end - my custom stuff } else { origOnmessage(aMsgEvent); @@ -1240,20 +1240,20 @@ function SIPWorker(workerScopeName, aPath, aCore=core, aFuncExecScope) { var promise_initWorker = bootstrap[workerScopeName].post('init', [aCore]); promise_initWorker.then( function(aVal) { - console.log('Fullfilled - promise_initWorker - ', aVal); + // start - do stuff here - promise_initWorker deferredMain_SIPWorker.resolve(aVal); // end - do stuff here - promise_initWorker }, function(aReason) { var rejObj = {name:'promise_initWorker', aReason:aReason}; - console.warn('Rejected - promise_initWorker - ', rejObj); + deferredMain_SIPWorker.reject(rejObj); } ).catch( function(aCaught) { var rejObj = {name:'promise_initWorker', aCaught:aCaught}; - console.error('Caught - promise_initWorker - ', rejObj); + deferredMain_SIPWorker.reject(rejObj); } ); diff --git a/install.rdf b/install.rdf index 7b3fa67..f459bc4 100644 --- a/install.rdf +++ b/install.rdf @@ -5,7 +5,7 @@ Chrome-Store-Foxified@jetpack - 1.10b + 1.10 2 true @@ -14,7 +14,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 42.0 - 46.0 + 49.0 diff --git a/modules/MainWorker/MainWorker.js b/modules/MainWorker/MainWorker.js index 772a958..e3ebc23 100644 --- a/modules/MainWorker/MainWorker.js +++ b/modules/MainWorker/MainWorker.js @@ -55,14 +55,14 @@ var WORKER = this; self.addEventListener('message', function(aMsgEvent) { // this is what you do if you want SIPWorker mainthread calling ability var aMsgEventData = aMsgEvent.data; if (Array.isArray(aMsgEventData)) { - console.error('worker got response for main thread calling SIPWorker functionality:', aMsgEventData) + var funcName = aMsgEventData.shift(); if (funcName in WORKER) { var rez_worker_call = WORKER[funcName].apply(null, aMsgEventData); } - else { console.error('funcName', funcName, 'not in scope of WORKER') } // else is intentionally on same line with console. so on finde replace all console. lines on release it will take this out + } else { - console.error('no this is just regular promise worker message'); + worker.handleMessage(aMsgEvent) } }); @@ -77,7 +77,7 @@ self.postMessageWithCallback = function(aPostMessageArr, aCB, aPostMessageTransf var thisCallbackId = SIP_CB_PREFIX + sip_last_cb_id; aFuncExecScope[thisCallbackId] = function() { delete aFuncExecScope[thisCallbackId]; - console.log('in worker callback trigger wrap, will apply aCB with these arguments:', arguments); + aCB.apply(null, arguments[0]); }; aPostMessageArr.push(thisCallbackId); @@ -148,7 +148,7 @@ function jwtSignOlympia(aKey, aSecret, aDateMs) { ////// end of imports and definitions function init(objCore) { // function name init required for SIPWorker - //console.log('in worker init'); + // merge objCore into core // core and objCore is object with main keys, the sub props @@ -177,7 +177,7 @@ function init(objCore) { // function name init required for SIPWorker var rezInit = {}; rezInit.l10n = _cache_formatStringFromName_packages; - console.log('MainWorker init success'); + return rezInit; // required for SIPWorker } @@ -205,7 +205,7 @@ function jpmSign(aPathOrBlobToXpi, aAddonVersionInXpi, aAddonIdInXpi, aPlatofrmP // assume its blob fileXpi = new File([aPathOrBlobToXpi], aOptions.filename + ' -- unsigned.xpi'); // doing = new File(aBlob) is not working, the xhr response is coming from amo saying "key of `upload` is missing" } - console.log('fileXpi:', fileXpi); + // create form data var formData = new FormData(); // Cc['@mozilla.org/files/formdata;1'].createInstance(Ci.nsIDOMFormData); // http://stackoverflow.com/q/25038292/1828637 @@ -225,8 +225,8 @@ function jpmSign(aPathOrBlobToXpi, aAddonVersionInXpi, aAddonIdInXpi, aPlatofrmP Authorization: 'JWT ' + jwtSignOlympia(aAmoApiKey, aAmoApiSecret, getNowDateFromServer()) } }); - console.log('request_amoSubmit.status:', request_amoSubmit.status); - console.log('request_amoSubmit.response:', request_amoSubmit.response); + + var downloadIt = function(aDownloadSignedURL) { if (aOptions.aAttnBarInstState) { @@ -259,7 +259,7 @@ function jpmSign(aPathOrBlobToXpi, aAddonVersionInXpi, aAddonIdInXpi, aPlatofrmP try { OS.File.writeAtomic(downloadSignedToPlatPath, new Uint8Array(request_downloadSigned.response), {noOverwrite:false}); } catch(ex) { - console.error('Failed writing signed XPI to disk:', ex); + throw new MainWorkerError('Failed writing signed XPI to disk', ex); } @@ -288,17 +288,17 @@ function jpmSign(aPathOrBlobToXpi, aAddonVersionInXpi, aAddonIdInXpi, aPlatofrmP } }); - console.log('request_fetchExisting.status:', request_fetchExisting.status); - console.log('request_fetchExisting.response:', request_fetchExisting.response); + + if (request_fetchExisting.status == 200) { if (request_fetchExisting.response.files && request_fetchExisting.response.files.length == 1) { return downloadIt(request_fetchExisting.response.files[0].download_url); } else { - console.error('addon existing, and successfully got exiswting status check, but files are not yet ready! not yet handled :todo:'); + // throw new Error('addon existing, and successfully got exiswting status check, but files are not yet ready! not yet handled :todo:'); // wait 5 seconds then try again - console.log('wait 5 seconds then try again as it has not been signed yet'); + // if (request_fetchExisting.response) if (Array.isArray(request_fetchExisting.response.files) && request_fetchExisting.response.reviewed && !request_fetchExisting.response.passed_review) { // i was using .response.processed however it was not right, as it gets processed before reviewed. so updated to .response.reviewed. as with fullscreenshot thing i got that warning for binary - https://chrome.google.com/webstore/detail/full-page-screen-capture/fdpohaocaechififmbbbbbknoalclacl @@ -324,7 +324,7 @@ function jpmSign(aPathOrBlobToXpi, aAddonVersionInXpi, aAddonIdInXpi, aPlatofrmP } }; } - console.log('cumulativeCheckCount:', cumulativeCheckCount); + for (var i=10; i>=1; i--) { if (aOptions.aAttnBarInstState) { aOptions.aAttnBarInstState.aTxt = formatStringFromName('attn-signing-check-waiting', 'bootstrap', [aOptions.aExtName, i, cumulativeCheckCount, maxCumCheckCount]); @@ -346,15 +346,15 @@ function jpmSign(aPathOrBlobToXpi, aAddonVersionInXpi, aAddonIdInXpi, aPlatofrmP } }; - console.log('request_amoSubmit.status:', request_amoSubmit.status, 'request_amoSubmit.response:', request_amoSubmit.response); + if (request_amoSubmit.status == 409) { // the version already exists - console.log('version already exists'); + return waitForReview(); } else { if (request_amoSubmit.status == 201 || request_amoSubmit.status == 202) { // ok new submission went through - console.log('ok new submission went through'); + return waitForReview(); } else { throw { @@ -375,30 +375,30 @@ function getNowDateFromServer() { var requestDuration = Date.now() - requestStartDate; - console.log('request took:', requestDuration, 'ms'); + if (requestUnixNow.status != 200) { - console.log('response status was bad, will wait 5 sec then try again'); + setTimeoutSync(5000); - console.log('ok waitied, will now try'); + return getNowDateFromServer(); } - console.log('requestUnixNow.status:', requestUnixNow.status); - // console.log('requestUnixNow.response:', requestUnixNow.response); + + var nowDateServerMatch = /current_time = (\d+);/.exec(requestUnixNow.response); if (!nowDateServerMatch) { throw new Error('failed to get now date from server'); } - console.log('nowDateServerMatch:', nowDateServerMatch); + var nowDateServerUncompensated = parseInt(nowDateServerMatch[1]) * 1000; - console.log('nowDateServerUncompensated:', nowDateServerUncompensated); + var nowDateServer = nowDateServerUncompensated - requestDuration; - console.log('nowDateServer:', nowDateServer); + return nowDateServer; } @@ -410,7 +410,7 @@ function setTimeoutSync(aMilliseconds) { function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { try { - console.log('in doit:', aExtId, aExtName); + // step - download crx aAttnBarInstState.aTxt = formatStringFromName('attn-downloading', 'bootstrap', [aExtName]); @@ -419,7 +419,7 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { var requestGoogle = xhr('https://clients2.google.com/service/update2/crx?response=redirect&prodversion=38.0&x=id%3D' + aExtId + '%26installsource%3Dondemand%26uc', { responseType: 'arraybuffer' }); - console.log('requestGoogle:', requestGoogle); + var crxArrBuf = requestGoogle.response; // step - make crx a zip @@ -428,13 +428,13 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { // var crxBlob = new Blob([new Uint8Array(requestGoogle.response)], {type: 'application/octet-binary'}); var locOfPk = new Uint8Array(crxArrBuf.slice(0, 1000)); - // console.log('locOfPk:', locOfPk); + for (var i=0; i -1) { throw { @@ -486,9 +486,9 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { }; break; // var fieldTokenHtml = /input[^<]+csrfmiddlewaretoken[^>]+/i.exec(reqAmoKeys.response); - // console.log('fieldTokenHtml:', fieldTokenHtml); + // var token = /value=["']?(.*?)["' \/<]/i.exec(fieldTokenHtml)[1]; - // console.log('token:', token); + // xhrUrl = AMODOMAIN + '/en-US/developers/addon/submit/agreement/'; // xhrOpts.method = 'POST'; @@ -502,7 +502,7 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { // loopXhr = true; } else if (reqAmoKeys.response.indexOf('firefox/users/edit') == -1) { - console.error('you are not logged in'); + throw { msg: 'signing-failed:not logged in' }; @@ -511,15 +511,15 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { var fieldKeyHtml = /input[^<]+jwtkey[^>]+/i.exec(reqAmoKeys.response); var fieldSecretHtml = /input[^<]+jwtsecret[^>]+/i.exec(reqAmoKeys.response); - console.log('fieldKeyHtml:', fieldKeyHtml); - console.log('fieldSecretHtml:', fieldSecretHtml); + + if (!fieldKeyHtml) { // keys are not there, need to generate var fieldTokenHtml = /input[^<]+csrfmiddlewaretoken[^>]+/i.exec(reqAmoKeys.response); - console.log('fieldTokenHtml:', fieldTokenHtml); + var token = /value=["']?(.*?)["' \/<]/i.exec(fieldTokenHtml)[1]; - console.log('token:', token); + xhrUrl = AMODOMAIN + '/en-US/developers/addon/api/key/'; xhrOpts.method = 'POST'; @@ -538,8 +538,8 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { gAmoApiKey = /value=["']?(.*?)["' \/<]/i.exec(fieldKeyHtml)[1]; gAmoApiSecret = /value=["']?(.*?)["' \/<]/i.exec(fieldSecretHtml)[1]; - console.log('gAmoApiKey:', gAmoApiKey); - console.log('gAmoApiSecret:', gAmoApiSecret); + + break; } @@ -575,12 +575,12 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { xpiSavePath = OS.Path.join(OS.Constants.Path.tmpDir, xpiFileName + '.xpi'); } - console.log('xpiSavePath:', xpiSavePath); + try { OS.File.writeAtomic(xpiSavePath, jszipUint8, {noOverwrite:false}); } catch(ex) { - console.error('Failed writing XPI to disk:', ex); + throw new MainWorkerError('Failed writing XPI to disk', ex); } */ @@ -590,14 +590,14 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { var xpiSaveDir = aPrefs.save ? aPrefs['save-path'] : OS.Constants.Path.tmpDir; var xpiSavePath = OS.Path.join(xpiSaveDir, xpiFileName + '.xpi'); - console.error('aPrefs.donotsign:', aPrefs.donotsign); + if (!aPrefs.donotsign) { aAttnBarInstState.aTxt = formatStringFromName('attn-signing', 'bootstrap', [aExtName]); self.postMessage(['updateAttnBar', aAttnBarInstState]); var jszipBlob = zipJSZIP.generate({type:'blob'}); - console.log('xpiSavePath:', xpiSavePath); + var rez_sign = jpmSign(jszipBlob, xpiVersion, xpiId, xpiSaveDir, gAmoApiKey, gAmoApiSecret, { filename: xpiFileName + '.xpi', aAttnBarInstState: aAttnBarInstState, @@ -605,7 +605,7 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { }); if (rez_sign) { - console.log('succesfully downloaded signed xpi to: ', rez_sign, 'xpiSavePath:', xpiSavePath); + // rez_sign should === xpiSavePath } else { // should never get here, because if jpmSign fails it throws, but just in case ill put this here @@ -614,7 +614,7 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { // install xpi self.postMessageWithCallback(['installXpi', xpiSavePath], function(aStatusObj) { // :note: this is how to call WITH callback - console.log('ok back from installXpi, aStatusObj:', aStatusObj); + if (aStatusObj.status) { // installed @@ -640,7 +640,7 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { // after install, if user has set aPrefs.save to false, then delete it if (!aPrefs.save) { OS.File.remove(xpiSavePath); - console.log('ok because user had marked not to save file, deleted the file'); + } }); } else { @@ -651,7 +651,7 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { // no return because no longer working with framescript-sendAsyncMessageWithCallback // return ['promise_rejected']; // must return array as this function is designed to return to framescript-sendAsyncMessageWithCallback callInPromiseWorker } catch(ex) { - console.error('Something went wrong error is:', ex, uneval(ex)); + var dataForInstallAsTemp; // either string, or arraybuffer var uint8JSZIP = zipJSZIP.generate({type:'uint8array'}); @@ -665,7 +665,7 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { try { OS.File.writeAtomic(unsignedXpiSavePath, uint8JSZIP, {noOverwrite:false}); } catch(OSFileError) { - console.error('Failed writing unsigned XPI to disk:', OSFileError); + throw new MainWorkerError('Failed unsigned signed XPI to disk', OSFileError); } } else { @@ -693,7 +693,7 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { transferList = [dataForInstallAsTemp]; } self.postMessage(['updateAttnBar', aAttnBarInstState, aLocalizedKey, aExtName, ex, dataForInstallAsTemp], transferList); - console.log('dataForInstallAsTemp.byteLength from worker:', dataForInstallAsTemp.byteLength); + } else { aAttnBarInstState.aPriority = 9; aAttnBarInstState.aHideClose = false; @@ -705,7 +705,7 @@ function doit(aExtId, aExtName, aPrefs, aAttnBarInstState) { } function installAsTempAddon(aExtName, dataForInstallAsTemp, aPrefs, aAttnBarInstState) { - console.log('in installAsTempAddon worker side'); + aAttnBarInstState.aPriority = 1; aAttnBarInstState.aTxt = formatStringFromName('installing-as-temp', 'bootstrap'); @@ -715,34 +715,34 @@ function installAsTempAddon(aExtName, dataForInstallAsTemp, aPrefs, aAttnBarInst var xpiPath; if (typeof(dataForInstallAsTemp) != 'string') { - console.log('creating xpi'); + var unsignedXpiFileName = formatStringFromName('unsigned-xpi-filename-template', 'bootstrap', [safedForPlatFS(aExtName), new Date().getTime()]); // need unique file name, as writing to temp directory, and the old one is not yet deleted - console.log('unsignedXpiFileName:', unsignedXpiFileName); + var xpiSaveDir = aPrefs.save ? aPrefs['save-path'] : OS.Constants.Path.tmpDir; - console.log('xpiSaveDir:', xpiSaveDir); + var xpiSavePath = OS.Path.join(xpiSaveDir, unsignedXpiFileName + '.xpi'); - console.log('xpiSavePath:', xpiSavePath); + var unsignedXpiSavePath = OS.Path.join(xpiSaveDir, unsignedXpiFileName + '.xpi'); xpiPath = unsignedXpiSavePath; - console.log('xpiPath:', xpiPath); + try { OS.File.writeAtomic(unsignedXpiSavePath, new Uint8Array(dataForInstallAsTemp), {noOverwrite:false}); } catch(OSFileError) { - console.error('Failed writing unsigned XPI to disk:', OSFileError); + throw new MainWorkerError('Failed unsigned signed XPI to disk', OSFileError); } } else { - console.log('already created'); + xpiPath = dataForInstallAsTemp; } - console.log('xpiPath:', xpiPath); + self.postMessageWithCallback(['installAsTemp', xpiPath, aAttnBarInstState], function(aStatusObj) { - console.log('ok back in worker after trying installAsTemp, aStatusObj:', aStatusObj); + if (typeof(dataForInstallAsTemp) != 'string') { - console.log('ok removed temp file'); + OS.File.remove(xpiPath); } }); @@ -778,7 +778,7 @@ function validateOptionsObj(aOptions, aOptionsDefaults) { // ensures no invalid keys are found in aOptions, any key found in aOptions not having a key in aOptionsDefaults causes throw new Error as invalid option for (var aOptKey in aOptions) { if (!(aOptKey in aOptionsDefaults)) { - console.error('aOptKey of ' + aOptKey + ' is an invalid key, as it has no default value, aOptionsDefaults:', aOptionsDefaults, 'aOptions:', aOptions); + throw new Error('aOptKey of ' + aOptKey + ' is an invalid key, as it has no default value'); } } @@ -792,7 +792,7 @@ function validateOptionsObj(aOptions, aOptionsDefaults) { } function xhr(aUrlOrFileUri, aOptions={}) { - // console.error('in xhr!!! aUrlOrFileUri:', aUrlOrFileUri); + // all requests are sync - as this is in a worker var aOptionsDefaults = { @@ -817,9 +817,9 @@ function xhr(aUrlOrFileUri, aOptions={}) { cRequest.responseType = aOptions.responseType; cRequest.send(aOptions.data); - // console.log('response:', cRequest.response); + - // console.error('done xhr!!!'); + return cRequest; } @@ -843,7 +843,7 @@ function formatStringFromName(aKey, aLocalizedPackageName, aReplacements) { _cache_formatStringFromName_packages[aLocalizedPackageName] = packageJson; - console.log('packageJson:', packageJson); + } var cLocalizedStr = _cache_formatStringFromName_packages[aLocalizedPackageName][aKey]; diff --git a/resources/scripts/ab-react-components.js b/resources/scripts/ab-react-components.js index 3d250a6..a6321c7 100644 --- a/resources/scripts/ab-react-components.js +++ b/resources/scripts/ab-react-components.js @@ -9,7 +9,7 @@ Notification: React.createClass({ displayName: 'Notification', componentDidMount: function() { - console.error('ok mounted'); // for some reason this doesnt trigger + window[aAddonId + '-AB'].Insts[this.props.aId].setState = this.setState.bind(this); window[aAddonId + '-AB'].Node = node; @@ -82,12 +82,12 @@ }, shouldMirrorProps: function(aNextProps, aIsMount) { // works with this.customAttrs var node = ReactDOM.findDOMNode(this); - console.log('node:', node); + for (var nProp in aNextProps) { if (nProp in this.customAttrs) { if (aIsMount || this.props[nProp] !== aNextProps[nProp]) { // // i do aIsMount check, because on mount, old prop is same as new prop, becase i call in componentDidMount shouldMirrorProps(this.props) - console.log(['setting custom attr "' + nProp + '"','old: ' + this.props[nProp], 'new: ' + aNextProps[nProp]].join('\n')); + if (!aIsMount && (aNextProps[nProp] === null || aNextProps[nProp] === undefined)) { node.removeAttribute(this.customAttrs[nProp]); } else { @@ -151,11 +151,11 @@ }, shouldMirrorProps: function(aNextProps, aIsMount) { // works with this.customAttrs var node = ReactDOM.findDOMNode(this); - console.log('node:', node); + for (var nProp in aNextProps) { if (nProp in this.customAttrs) { if (aIsMount || this.props[nProp] !== aNextProps[nProp]) { // // i do aIsMount check, because on mount, old prop is same as new prop, becase i call in componentDidMount shouldMirrorProps(this.props) - console.log(['setting custom attr "' + nProp + '"','old: ' + this.props[nProp], 'new: ' + aNextProps[nProp]].join('\n')); + if (!aIsMount && (aNextProps[nProp] === null || aNextProps[nProp] === undefined)) { node.removeAttribute(this.customAttrs[nProp]); } else { @@ -217,10 +217,10 @@ componentDidMount: function() { this.shouldMirrorProps(this.props, true); if (!this.props.cMenu) { - console.log('ok its a menuitem so attach command listener'); + ReactDOM.findDOMNode(this).addEventListener('command', this.click); } - else { console.log('will not add event listener for command because its a menu NOT a menuitem') } + }, componentWillReceiveProps: function(aNextProps) { this.shouldMirrorProps(aNextProps); @@ -230,11 +230,11 @@ }, shouldMirrorProps: function(aNextProps, aIsMount) { // works with this.customAttrs var node = ReactDOM.findDOMNode(this); - console.log('node:', node); + for (var nProp in aNextProps) { if (nProp in this.customAttrs) { if (aIsMount || this.props[nProp] !== aNextProps[nProp]) { // // i do aIsMount check, because on mount, old prop is same as new prop, becase i call in componentDidMount shouldMirrorProps(this.props) - console.log(['setting custom attr "' + nProp + '"','old: ' + this.props[nProp], 'new: ' + aNextProps[nProp]].join('\n')); + if (!aIsMount && (aNextProps[nProp] === null || aNextProps[nProp] === undefined)) { node.removeAttribute(this.customAttrs[nProp]); } else { diff --git a/resources/scripts/fsInlay.js b/resources/scripts/fsInlay.js index dfbcdbe..f8066e7 100644 --- a/resources/scripts/fsInlay.js +++ b/resources/scripts/fsInlay.js @@ -9,7 +9,7 @@ var core = { name: 'chrome-store-foxified', scripts: 'chrome://chrome-store-foxified/content/resources/scripts/' }, - cache_key: Math.random() // set to version on release + cache_key: 'v1.10' // set to version on release } }; @@ -23,7 +23,7 @@ var PAGE_UNLOADERS = []; // start - addon functionalities function doPageUnloaders() { - console.error('kicking of page unloaders'); + for (var i=0; i div:nth-of-type(3) > div:nth-of-type(1)').textContent; - console.log('query selector string:', ('a[href="' + theHref + '"]')); + var aWithHref = domEl_withHref.parentNode.querySelectorAll('a[href="' + theHref + '"]'); - console.log('aWithHref:', aWithHref); + var extName = aWithHref[1].textContent.trim(); aContentWindow.alert('extName: ' + extName); actOnExt(extId, extName); @@ -163,7 +163,7 @@ function domInsert(aContentWindow) { */ if (aContentDocument.getElementById('chrome-store-foxified_stylesheet')) { - console.warn('already inserted into this document, so dont insert again'); + return; } @@ -179,7 +179,7 @@ function domInsert(aContentWindow) { return; } else { firstNonFind = 0; - console.error('warning, could not find download gchrome link!'); + // throw new Error('warning, could not find download gchrome link!'); return; } @@ -197,7 +197,7 @@ function domInsert(aContentWindow) { } if (aContentWindow.getComputedStyle(domEl_downloadGoogleChromeMainDiv).position != 'fixed') { - console.error('warning, could not find download gchrome link main container!'); + // throw new Error('warning, could not find download gchrome link main container!'); return; } @@ -256,21 +256,21 @@ function bodyOnDOMContentLoaded(aContentWindow) { // check if got error loading page: var webnav = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation); var docuri = webnav.document.documentURI; - // console.info('docuri:', docuri); + if (docuri.indexOf('about:') == 0) { // twitter didnt really load, it was an error page - console.log('twitter hostname page ready, but an error page loaded, so like offline or something:', content.location, 'docuri:', docuri); + // unregReason = 'error-loading'; return; } else { // twitter actually loaded // twitterReady = true; - console.error('ok twitter page ready, lets ensure page loaded finished'); + domInsert(content); // ensureLoaded(content); // :note: commented out as not needing content script right now } } else { - // console.log('page ready, but its not twitter so do nothing:', uneval(content.location)); + return; } } @@ -283,10 +283,10 @@ function bodyOnDOMContentLoaded(aContentWindow) { var bootstrapCallbacks = { // can use whatever, but by default it uses this // put functions you want called by bootstrap/server here destroySelf: function() { - // console.log('content.location.hostname:', content.location.hostname); - console.error('doing destroySelf'); + + doPageUnloaders(); - console.error('doing fs unloaders'); + for (var i=0; i