From 4a0a71838f58e355f3ae86f217fdb3f52f8c0478 Mon Sep 17 00:00:00 2001 From: Noitidart Date: Sun, 24 Apr 2016 06:58:39 -0700 Subject: [PATCH] 1.8 RELEASE resotring donotsign to default on defualt button click --- bootstrap.js | 90 +++++++-------- install.rdf | 4 +- modules/MainWorker/MainWorker.js | 140 +++++++++++------------ options.xul | 2 +- resources/scripts/ab-react-components.js | 14 +-- resources/scripts/fsInlay.js | 80 ++++++------- 6 files changed, 165 insertions(+), 165 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index b2b1c2c..78981cb 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.8' // 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'); @@ -258,7 +258,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']; @@ -278,7 +278,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']; @@ -298,7 +298,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; @@ -355,7 +355,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); @@ -488,7 +488,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); @@ -553,19 +553,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'); + }, ensureInitedIntoWindow: function(aDOMWindow) { // dont run this yoruself, ensureInstancesToWindow runs this. so if you want to run yourself, then run ensureInstancesToWindow(aDOMWindow) @@ -575,11 +575,11 @@ var AB = { // AB stands for attention bar domIdPrefix: AB.domIdPrefix }; // ab stands for attention bar if (!aDOMWindow.React) { - console.error('WILL NOW LOAD IN REACT'); + 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.error('WILL NOW LOAD IN REACTDOM'); + Services.scriptloader.loadSubScript(core.addon.path.scripts + 'react-dom.js?' + core.addon.cache_key, aDOMWindow); } Services.scriptloader.loadSubScript(core.addon.path.scripts + 'ab-react-components.js?' + core.addon.cache_key, aDOMWindow); @@ -611,7 +611,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; @@ -646,7 +646,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 { @@ -655,7 +655,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); @@ -741,7 +741,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); @@ -755,7 +755,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); @@ -766,7 +766,7 @@ function startup(aData, aReason) { name: 'promise_initMainWorker', aReason: aReason }; - console.warn('Rejected - promise_initMainWorker - ', rejObj); + } ).catch( function(aCaught) { @@ -774,7 +774,7 @@ function startup(aData, aReason) { name: 'promise_initMainWorker', aCaught: aCaught }; - console.error('Caught - promise_initMainWorker - ', rejObj); + } ); @@ -797,7 +797,7 @@ function shutdown(aData, aReason) { // terminate worker if (typeof(MainWorker) != 'undefined') { MainWorker._worker.terminate(); - console.log('ok terminated worker'); + } } @@ -807,7 +807,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, @@ -867,7 +867,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); @@ -881,7 +881,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]); } @@ -892,7 +892,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]); } @@ -908,7 +908,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; @@ -931,23 +931,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 + } }; @@ -1041,7 +1041,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'); } } @@ -1096,7 +1096,7 @@ function genericReject(aPromiseName, aPromiseToReject, aReason) { name: aPromiseName, aReason: aReason }; - console.error('Rejected - ' + aPromiseName + ' - ', rejObj); + if (aPromiseToReject) { aPromiseToReject.reject(rejObj); } @@ -1106,7 +1106,7 @@ function genericCatch(aPromiseName, aPromiseToReject, aCaught) { name: aPromiseName, aCaught: aCaught }; - console.error('Caught - ' + aPromiseName + ' - ', rejObj); + if (aPromiseToReject) { aPromiseToReject.reject(rejObj); } @@ -1139,10 +1139,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) { @@ -1159,7 +1159,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 { @@ -1167,12 +1167,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]]); } ); @@ -1188,7 +1188,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); @@ -1204,20 +1204,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 8abc0b3..36d8484 100644 --- a/install.rdf +++ b/install.rdf @@ -5,7 +5,7 @@ Chrome-Store-Foxified@jetpack - 1.8b + 1.8 2 true @@ -14,7 +14,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 42.0 - 44.0 + 46.0 diff --git a/modules/MainWorker/MainWorker.js b/modules/MainWorker/MainWorker.js index 1d8b08c..832fcfb 100644 --- a/modules/MainWorker/MainWorker.js +++ b/modules/MainWorker/MainWorker.js @@ -58,14 +58,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) } }); @@ -80,7 +80,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); @@ -103,7 +103,7 @@ MainWorkerError.prototype.toMsg = function() { ////// 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 @@ -132,7 +132,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 } @@ -160,7 +160,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 @@ -212,7 +212,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); } @@ -241,17 +241,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 @@ -277,7 +277,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]); @@ -299,15 +299,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 { @@ -328,30 +328,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; } @@ -363,7 +363,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]); @@ -372,7 +372,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 @@ -381,13 +381,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) { var fieldTokenHtml = /input[^<]+csrfmiddlewaretoken[^>]+/i.exec(reqAmoKeys.response); - console.log('fieldTokenHtml:', fieldTokenHtml); + var token = /value=["']?(.*?)["' \/<]/i.exec(fieldTokenHtml)[1]; - console.log('token:', token); + xhrUrl = 'https://addons.mozilla.org/en-US/developers/addon/submit/agreement/'; xhrOpts.method = 'POST'; @@ -451,7 +451,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' }; @@ -460,15 +460,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 = 'https://addons.mozilla.org/en-US/developers/addon/api/key/'; xhrOpts.method = 'POST'; @@ -486,8 +486,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; } @@ -523,12 +523,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); } */ @@ -538,14 +538,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, @@ -553,7 +553,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 @@ -562,7 +562,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 @@ -588,7 +588,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 { @@ -599,7 +599,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'}); @@ -612,7 +612,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 { @@ -637,7 +637,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; @@ -649,7 +649,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'); @@ -659,34 +659,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); } }); @@ -722,7 +722,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'); } } @@ -736,7 +736,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 = { @@ -761,9 +761,9 @@ function xhr(aUrlOrFileUri, aOptions={}) { cRequest.responseType = aOptions.responseType; cRequest.send(aOptions.data); - // console.log('response:', cRequest.response); + - // console.error('done xhr!!!'); + return cRequest; } @@ -787,7 +787,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/options.xul b/options.xul index 73d57b6..b445689 100644 --- a/options.xul +++ b/options.xul @@ -6,6 +6,6 @@ -