Skip to content

Commit

Permalink
1.9
Browse files Browse the repository at this point in the history
RELEASE
  • Loading branch information
Noitidart committed May 2, 2016
1 parent b2ea2b2 commit 63c7788
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 163 deletions.
90 changes: 45 additions & 45 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.9' // set to version on release
},
os: {
name: OS.Constants.Sys.Name.toLowerCase(),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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'];
Expand All @@ -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'];
Expand All @@ -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;
Expand Down Expand Up @@ -376,7 +376,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);
Expand Down Expand Up @@ -509,7 +509,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);
Expand Down Expand Up @@ -574,19 +574,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)
Expand All @@ -596,11 +596,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);
Expand Down Expand Up @@ -632,7 +632,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;
Expand Down Expand Up @@ -667,7 +667,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 {
Expand All @@ -676,7 +676,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);
Expand Down Expand Up @@ -762,7 +762,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);

Expand All @@ -776,7 +776,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);
Expand All @@ -787,15 +787,15 @@ function startup(aData, aReason) {
name: 'promise_initMainWorker',
aReason: aReason
};
console.warn('Rejected - promise_initMainWorker - ', rejObj);

}
).catch(
function(aCaught) {
var rejObj = {
name: 'promise_initMainWorker',
aCaught: aCaught
};
console.error('Caught - promise_initMainWorker - ', rejObj);

}
);

Expand All @@ -818,7 +818,7 @@ function shutdown(aData, aReason) {
// terminate worker
if (typeof(MainWorker) != 'undefined') {
MainWorker._worker.terminate();
console.log('ok terminated worker');

}
}

Expand All @@ -828,7 +828,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,
Expand Down Expand Up @@ -888,7 +888,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);
Expand All @@ -902,7 +902,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]);
}
Expand All @@ -913,7 +913,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]);
}
Expand All @@ -929,7 +929,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;
Expand All @@ -952,23 +952,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


}
};
Expand Down Expand Up @@ -1062,7 +1062,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');
}
}
Expand Down Expand Up @@ -1117,7 +1117,7 @@ function genericReject(aPromiseName, aPromiseToReject, aReason) {
name: aPromiseName,
aReason: aReason
};
console.error('Rejected - ' + aPromiseName + ' - ', rejObj);

if (aPromiseToReject) {
aPromiseToReject.reject(rejObj);
}
Expand All @@ -1127,7 +1127,7 @@ function genericCatch(aPromiseName, aPromiseToReject, aCaught) {
name: aPromiseName,
aCaught: aCaught
};
console.error('Caught - ' + aPromiseName + ' - ', rejObj);

if (aPromiseToReject) {
aPromiseToReject.reject(rejObj);
}
Expand Down Expand Up @@ -1160,10 +1160,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) {
Expand All @@ -1180,20 +1180,20 @@ 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 {
bootstrap[workerScopeName]._worker.postMessage([callbackPendingId, aVal]);
}
},
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]]);
}
);
Expand All @@ -1209,7 +1209,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);
Expand All @@ -1225,20 +1225,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);
}
);
Expand Down
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>Chrome-Store-Foxified@jetpack</em:id>
<em:version>1.9b</em:version>
<em:version>1.9</em:version>
<em:type>2</em:type>
<em:bootstrap>true</em:bootstrap>

Expand Down
Loading

0 comments on commit 63c7788

Please sign in to comment.