Permalink
Browse files

Merge pull request #269 from Gozala/bug/undefined-options.699564

fix Bug 699564 - "ReferenceError: options is not defined" in cuddlefish.js unload function when quitting Firefox r=@ochameau
  • Loading branch information...
2 parents 0497353 + a6e7a73 commit d32b895239c7991f1705608aec36bb6b80b8912c @Gozala Gozala committed Nov 22, 2011
@@ -308,10 +308,6 @@ const Loader = {
},
unload: function unload(reason, callback) {
this.require('api-utils/unload').send(reason, callback);
- // `cfx run` expects to see 'OK' or 'FAIL' to be written into a `resultFile`
- // as a signal of quit.
- if ('resultFile' in options && reason === 'shutdown')
- this.require('api-utils/system').exit(0);
}
};
exports.Loader = Loader;
@@ -62,11 +62,14 @@ function process(target, id, uri, scope) {
// the same turn of event loop).
loadScript(target, packaging.loader, false);
- loadScript(target, 'data:,let options = ' + JSON.stringify(packaging));
- loadScript(target, 'data:,let loader = Loader.new(options);\n' +
+ loadScript(target, 'data:,let loader = Loader.new(' +
+ JSON.stringify(packaging) + ');\n' +
'loader.main("' + id + '", "' + uri + '");', false);
when(function (reason) {
+ // Please note that it's important to unload remote loader
+ // synchronously (using synchronous frame script), to make sure that we
+ // don't stop during unload.
loadScript(target, 'data:,loader.unload("' + reason + '")', true);
});
@@ -179,6 +179,13 @@ function startup(data, reason) {
function shutdown(data, reason) {
// If loader is already present unload it, since add-on is disabled.
- if (loader)
- loader.unload(REASON[reason]);
+ if (loader) {
+ reason = REASON[reason]
+ let options = loader.require('@packaging');
+ loader.unload(reason);
+ // `cfx run` expects to see 'OK' or 'FAIL' to be written into a `resultFile`
+ // as a signal of quit.
+ if ('resultFile' in options && reason === 'shutdown')
+ loader.require('api-utils/system').exit(0);
+ }
};

0 comments on commit d32b895

Please sign in to comment.