Bug 746131: CFX in JS - Use an SDK addon called by cfx in python that is going to install the xpi #410

Closed
wants to merge 19 commits into
from

Conversation

Projects
None yet
4 participants
@ochameau
Member

ochameau commented Apr 24, 2012

Still a work in progress but feedback is welcomed.
(Based on top of PR #406)
https://bugzilla.mozilla.org/show_bug.cgi?id=746131

@Gozala

View changes

cfx/cfx.js
+ main();
+}
+catch(e) {
+ console.log("CFX.js exception:\n" + e);

This comment has been minimized.

@Gozala

Gozala Apr 24, 2012

Member

maybe console.exception probably would be better

@Gozala

Gozala Apr 24, 2012

Member

maybe console.exception probably would be better

@Gozala

View changes

cfx/cfx.js
+ }
+ let data = null;
+ try {
+ data = file.read(optionsFile);

This comment has been minimized.

@Gozala

Gozala Apr 24, 2012

Member

Maybe we should read this async as well (XHR) ?

@Gozala

Gozala Apr 24, 2012

Member

Maybe we should read this async as well (XHR) ?

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

Has not @ZER0 landed a readURI util function yet ?

@Gozala

Gozala Jun 6, 2012

Member

Has not @ZER0 landed a readURI util function yet ?

This comment has been minimized.

@ochameau

ochameau Jun 13, 2012

Member

Still nothing, bug 748086.

@ochameau

ochameau Jun 13, 2012

Member

Still nothing, bug 748086.

@Gozala

This comment has been minimized.

Show comment
Hide comment
@Gozala

Gozala Apr 24, 2012

Member

I think it would be useful to add Readme.md to cfx folder explaining what it dose or how to use it. I'm not sure I understand how how to cause cfx to use it.

Member

Gozala commented Apr 24, 2012

I think it would be useful to add Readme.md to cfx folder explaining what it dose or how to use it. I'm not sure I understand how how to cause cfx to use it.

@Gozala

View changes

cfx/cfx.js
+}
+
+try {
+ main();

This comment has been minimized.

@Gozala

Gozala Apr 24, 2012

Member

Might be worth doing following instead:

if (require.main === module) main()
@Gozala

Gozala Apr 24, 2012

Member

Might be worth doing following instead:

if (require.main === module) main()
@Gozala

View changes

cfx/xulrunner-app/CommandLineHandler.js
@@ -0,0 +1,83 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

Currently established convention for module names is hypen-delimited-name.js let's stick to it please.

@Gozala

Gozala Jun 6, 2012

Member

Currently established convention for module names is hypen-delimited-name.js let's stick to it please.

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

Ok, now I see that it's not really a module, but still not sure it's a good enough reason to don't follow conventions. Although I'm ok with having it as is if you feel very strongly about it (in that case probably .jsm would make more sense though)

@Gozala

Gozala Jun 6, 2012

Member

Ok, now I see that it's not really a module, but still not sure it's a good enough reason to don't follow conventions. Although I'm ok with having it as is if you feel very strongly about it (in that case probably .jsm would make more sense though)

@Gozala

View changes

cfx/README.md
@@ -0,0 +1,101 @@
+cfx.js
+======

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

Nit: We usually use # H1 instead of

H1
==
@Gozala

Gozala Jun 6, 2012

Member

Nit: We usually use # H1 instead of

H1
==
@Gozala

View changes

cfx/README.md
+cfx.js is an SDK addon meant to replace python command line application.
+This addon is currently quite limited but it is going to implement all features
+of cfx python application in order to remove python dependency.
+It currently just install an XPI file and run it into the Firefox.

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

into -> in a

@Gozala

Gozala Jun 6, 2012

Member

into -> in a

@Gozala

View changes

cfx/README.md
+of cfx python application in order to remove python dependency.
+It currently just install an XPI file and run it into the Firefox.
+For now, it is not meant to be used standalone, it is only an utility addon
+used by cfx python application.

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

I'd say helper addon used by an add-on sdk.

@Gozala

Gozala Jun 6, 2012

Member

I'd say helper addon used by an add-on sdk.

@Gozala

View changes

cfx/README.md
+
+ $ cfx xpi
+
+ * Eventually copy it to the xulrunner application template

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

Either title or this section is confusing. Is it embedding into app ?
Or do you mean install instructions ?

@Gozala

Gozala Jun 6, 2012

Member

Either title or this section is confusing. Is it embedding into app ?
Or do you mean install instructions ?

@Gozala

View changes

cfx/README.md
+ to be accomplished by this addon
+ * Run firefox with this addon installed, or run it through the xulrunner
+ template.
+ * The addon retrieve that JSON object and execute actions based on these data

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

Maybe: The addon reads JSON from CFX_OPTIONS_FILE and performs tasks described by it.

@Gozala

Gozala Jun 6, 2012

Member

Maybe: The addon reads JSON from CFX_OPTIONS_FILE and performs tasks described by it.

@Gozala

View changes

cfx/README.md
+ {
+ command: "string" // Name of the command to execute
+ options: "object" // Arguments needed to execute this command
+ }

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

Is it a key value map ?

@Gozala

Gozala Jun 6, 2012

Member

Is it a key value map ?

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

Could you write some other (real) example this one is very confusing.

@Gozala

Gozala Jun 25, 2012

Member

Could you write some other (real) example this one is very confusing.

@Gozala

View changes

cfx/README.md
+ options: "object" // Arguments needed to execute this command
+ }
+
+Available commands

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

Supported commands

@Gozala

Gozala Jun 6, 2012

Member

Supported commands

@Gozala

View changes

cfx/README.md
+
+ Install a given xpi into the currently running firefox/xulrunner application
+
+ Expected options:

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

Required options

@Gozala

Gozala Jun 6, 2012

Member

Required options

@Gozala

View changes

cfx/README.md
+
+ Expected options:
+ {
+ xpiPath: "string" // Absolute path to the xpi to install

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

Would be nice if we could stick to same convention either "xpi-path" or "installXpi". Also I think it could be just path here as install-xpi makes it quite obvious.

@Gozala

Gozala Jun 6, 2012

Member

Would be nice if we could stick to same convention either "xpi-path" or "installXpi". Also I think it could be just path here as install-xpi makes it quite obvious.

@Gozala

View changes

cfx/README.md
+Available commands
+==================
+
+== install-xpi ==

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

Nit: Not sure it's even valid markdown we usually use

## install-xpi
@Gozala

Gozala Jun 6, 2012

Member

Nit: Not sure it's even valid markdown we usually use

## install-xpi
@Gozala

View changes

cfx/README.md
+ Expected options:
+ {
+ xpiPath: "string" // Absolute path to the xpi we want to build
+ harnessRootDir: "string" // Absolute path to the temaplate folder.

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

can it be just template ? or template-path / templatePath

@Gozala

Gozala Jun 6, 2012

Member

can it be just template ? or template-path / templatePath

@Gozala

View changes

cfx/README.md
+ harnessRootDir: "string" // Absolute path to the temaplate folder.
+ // All files from this folder are going to be
+ // written in the xpi
+ manifest: "string" // Content of the `install.rdf` to write in the xpi

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

Can we call it something else but manifest ? It's pretty confusing since we'll be call manifest something completely different. Maybe install-rdf or something like that ?

@Gozala

Gozala Jun 6, 2012

Member

Can we call it something else but manifest ? It's pretty confusing since we'll be call manifest something completely different. Maybe install-rdf or something like that ?

@Gozala

View changes

cfx/README.md
+ // All files from this folder are going to be
+ // written in the xpi
+ manifest: "string" // Content of the `install.rdf` to write in the xpi
+ harnessOptions: {

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

harnessOptions was pretty unfortunate name, that we always wanted to change. Maybe we can fix this now ?

@Gozala

Gozala Jun 6, 2012

Member

harnessOptions was pretty unfortunate name, that we always wanted to change. Maybe we can fix this now ?

This comment has been minimized.

@ochameau

ochameau Jun 13, 2012

Member

I'm fine renaming this to manifest?
But I don't think it really worth modifying the final name of harness-options.json file in xpi.

@ochameau

ochameau Jun 13, 2012

Member

I'm fine renaming this to manifest?
But I don't think it really worth modifying the final name of harness-options.json file in xpi.

This comment has been minimized.

@Gozala

Gozala Jun 27, 2012

Member

I'm fine renaming this to manifest?
But I don't think it really worth modifying the final name of harness-options.json file in xpi.

That's a different discussion, and I'd like to learn you're argument, but let's defer it for the future.

@Gozala

Gozala Jun 27, 2012

Member

I'm fine renaming this to manifest?
But I don't think it really worth modifying the final name of harness-options.json file in xpi.

That's a different discussion, and I'd like to learn you're argument, but let's defer it for the future.

This comment has been minimized.

@ochameau

ochameau Jun 28, 2012

Member

Some scripts in the wild are unpacking xpi files and are expecting to find this manifest file.
https://github.com/mozilla/amo-validator
I wouldn't be surprised if these guys are reading it:
https://bugzilla.mozilla.org/show_bug.cgi?id=730776#c0
Flightdeck team are most likely playing with it.
There is a chance to break stuff in the wild although it doesn't add a big value to rename this file.

@ochameau

ochameau Jun 28, 2012

Member

Some scripts in the wild are unpacking xpi files and are expecting to find this manifest file.
https://github.com/mozilla/amo-validator
I wouldn't be surprised if these guys are reading it:
https://bugzilla.mozilla.org/show_bug.cgi?id=730776#c0
Flightdeck team are most likely playing with it.
There is a chance to break stuff in the wild although it doesn't add a big value to rename this file.

@Gozala

View changes

cfx/cfx.js
+ else if (command == "no-quit") {
+ // Test command in order to simulate a run that never quits
+ let { Cu } = require("chrome");
+ let { Services } = Cu.import("resource://gre/modules/Services.jsm");

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

Could you please move imports to the top of the file ? I think you're trying to optimize here, but I think that JSM will be loaded anyway and require chrome is cheap.

@Gozala

Gozala Jun 6, 2012

Member

Could you please move imports to the top of the file ? I think you're trying to optimize here, but I think that JSM will be loaded anyway and require chrome is cheap.

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

Also I think it would be much simpler and clear to use a service instead:

Cc['@mozilla.org/toolkit/app-startup;1'].
  getService(Ci.nsIAppStartup).
  enterLastWindowClosingSurvivalArea()
@Gozala

Gozala Jun 6, 2012

Member

Also I think it would be much simpler and clear to use a service instead:

Cc['@mozilla.org/toolkit/app-startup;1'].
  getService(Ci.nsIAppStartup).
  enterLastWindowClosingSurvivalArea()
@Gozala

View changes

cfx/cfx.js
+}
+
+function main() {
+ let { command, options } = getOptions();

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

I think we should read files async, which could be delayed for the future, but API should be adjusted accordingly.

@Gozala

Gozala Jun 6, 2012

Member

I think we should read files async, which could be delayed for the future, but API should be adjusted accordingly.

This comment has been minimized.

@ochameau

ochameau Jun 13, 2012

Member

I'd prefer waiting for such asynchronous file API to be here before changing the layout of this code. It should be straightforward to do later.

@ochameau

ochameau Jun 13, 2012

Member

I'd prefer waiting for such asynchronous file API to be here before changing the layout of this code. It should be straightforward to do later.

This comment has been minimized.

@Gozala

Gozala Jun 13, 2012

Member

The problem is not weather it will be simple change or not, problem is an API breakage, that's why I prefer to start with async API from the beginning.

@Gozala

Gozala Jun 13, 2012

Member

The problem is not weather it will be simple change or not, problem is an API breakage, that's why I prefer to start with async API from the beginning.

This comment has been minimized.

@ochameau

ochameau Jun 13, 2012

Member

There is no API exposed here. Nothing is exported out of cfx.js. Am I misunderstanding something?

@ochameau

ochameau Jun 13, 2012

Member

There is no API exposed here. Nothing is exported out of cfx.js. Am I misunderstanding something?

This comment has been minimized.

@Gozala

Gozala Jun 13, 2012

Member

Right, I have not realized that :) In that case sure feel free to keep as is.

@Gozala

Gozala Jun 13, 2012

Member

Right, I have not realized that :) In that case sure feel free to keep as is.

@Gozala

View changes

cfx/xulrunner-app/CommandLineHandler.js
+
+ // Fake 'final-ui-startup' which is expected to fire in
+ // `api-utils/addon/runner.js`
+ Services.obs.notifyObservers(null, "final-ui-startup", null);

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

I'm not sure it's a good idea. I think we should dispatch our custom notification and handle it from addon/runner

@Gozala

Gozala Jun 6, 2012

Member

I'm not sure it's a good idea. I think we should dispatch our custom notification and handle it from addon/runner

@Gozala

View changes

cfx/xulrunner-app/CommandLineHandler.js
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+/*

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

It's little confusing why do you you use https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsICommandLine for this

@Gozala

View changes

cfx/xulrunner-app/application.ini
@@ -0,0 +1,11 @@
+[App]
+Vendor=Mozilla
+Name=CFX in Javascript

This comment has been minimized.

@Gozala

Gozala Jun 6, 2012

Member

I think "Cuddlefish" would make more sense here

@Gozala

Gozala Jun 6, 2012

Member

I think "Cuddlefish" would make more sense here

@Gozala

View changes

cfx/xulrunner-app/chrome.manifest
@@ -0,0 +1,3 @@
+component {537df286-d9ae-4c7a-a633-6266b1325289} CommandLineHandler.js
+contract @mozilla.org/stdoutapp/clh;1 {537df286-d9ae-4c7a-a633-6266b1325289}
+category command-line-handler x-default @mozilla.org/stdoutapp/clh;1

This comment has been minimized.

This comment has been minimized.

@ochameau

ochameau Jun 13, 2012

Member

I'm not following you here?
In any case, according to this documentation I changed x-default to m-cfx.
And used a more specific xpcom name @mozilla.org/cfx/clh;1

@ochameau

ochameau Jun 13, 2012

Member

I'm not following you here?
In any case, according to this documentation I changed x-default to m-cfx.
And used a more specific xpcom name @mozilla.org/cfx/clh;1

This comment has been minimized.

@Gozala

Gozala Jun 13, 2012

Member

I thought x-deafult was a special entry that was not documented on MDN, so I suggested to document it. But m-cfx is fine as well.

@Gozala

Gozala Jun 13, 2012

Member

I thought x-deafult was a special entry that was not documented on MDN, so I suggested to document it. But m-cfx is fine as well.

@ochameau

This comment has been minimized.

Show comment
Hide comment
@ochameau

ochameau Jun 13, 2012

Member

I've tried to address all your comments, except the one I replied to.
And I forgot to commit test file in the previous revision ...

Member

ochameau commented Jun 13, 2012

I've tried to address all your comments, except the one I replied to.
And I forgot to commit test file in the previous revision ...

@Gozala

View changes

cfx/README.md
+ Build an addon SDK addon.
+
+ Required `options` object:
+ {

This comment has been minimized.

@Gozala

Gozala Jun 13, 2012

Member

You're still mixing two naming conventions in the single JSON, please stick to either camel case or dash delimited naming convention. The later one seems to be more popular in JSON so I'd prefer that one.

@Gozala

Gozala Jun 13, 2012

Member

You're still mixing two naming conventions in the single JSON, please stick to either camel case or dash delimited naming convention. The later one seems to be more popular in JSON so I'd prefer that one.

This comment has been minimized.

@ochameau

ochameau Jun 13, 2012

Member

I used camel case in order to be able to use destructuring and/or regular attribute access like option.xpiPath/let { xpiPath } = options;, instead of only options["xpi-path"]. Having said that I'm fine about dash-delimited too.

@ochameau

ochameau Jun 13, 2012

Member

I used camel case in order to be able to use destructuring and/or regular attribute access like option.xpiPath/let { xpiPath } = options;, instead of only options["xpi-path"]. Having said that I'm fine about dash-delimited too.

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

I see why you used camel case and it's convenient, but I still think that consistency is more important. So if you don't mind let's go with either dash-delimited keys or single word names. I think you could just use xpi, template, rdf as names.

@Gozala

Gozala Jun 25, 2012

Member

I see why you used camel case and it's convenient, but I still think that consistency is more important. So if you don't mind let's go with either dash-delimited keys or single word names. I think you could just use xpi, template, rdf as names.

This comment has been minimized.

@ochameau

ochameau Jun 26, 2012

Member

Renamed to dash-delimited. I kept long names as they are explicit.

@ochameau

ochameau Jun 26, 2012

Member

Renamed to dash-delimited. I kept long names as they are explicit.

cfx/README.md
+
+ * cfx python application set `CFX_OPTIONS_FILE` environnement variable to an
+ absolute path to a JSON file that contains necessary information to execute
+ some commands,

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

I don't think you want to end with , here.

@Gozala

Gozala Jun 25, 2012

Member

I don't think you want to end with , here.

This comment has been minimized.

@ochameau

ochameau Jun 27, 2012

Member

Actually I did. Isn't the same rule between french and english ?
When you have multiple bullets, you end up with coma for all bullets expect the last one, with a point.

@ochameau

ochameau Jun 27, 2012

Member

Actually I did. Isn't the same rule between french and english ?
When you have multiple bullets, you end up with coma for all bullets expect the last one, with a point.

cfx/README.md
+ described by it.
+
+(We aren't putting JSON content into environnement variable as the size of an
+ environnement variable is quite limited)

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

I don't think such implementation details needs to be in readme. If you really want it, just add "(use JSON file since options may not fit in environment variable)" at the end of first bullet (line 15).

@Gozala

Gozala Jun 25, 2012

Member

I don't think such implementation details needs to be in readme. If you really want it, just add "(use JSON file since options may not fit in environment variable)" at the end of first bullet (line 15).

cfx/README.md
+ Required `options` object:
+ {
+ path: "string" // Absolute path to the xpi to install
+ }

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

I think more complete examples would help a lot:

{
  "command": "install-xpi",
  "options": {
    "path": "/path/to/addon.xpi"
  }
}

Maybe also note what the path format will be for windows.

@Gozala

Gozala Jun 25, 2012

Member

I think more complete examples would help a lot:

{
  "command": "install-xpi",
  "options": {
    "path": "/path/to/addon.xpi"
  }
}

Maybe also note what the path format will be for windows.

cfx/README.md
+ // All files from this folder are going to be
+ // written in the xpi
+ installRdf: "string" // Content of the `install.rdf` to write in the xpi
+ harnessOptions: {

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

Maybe we can change harnessOptions to metadata ?

@Gozala

Gozala Jun 25, 2012

Member

Maybe we can change harnessOptions to metadata ?

This comment has been minimized.

@ochameau

ochameau Jun 26, 2012

Member

Do you mind renaming this old beast in the next step ? i.e. when we are going to build the manifest from JS side.
Just because it is called harness options all over the place in python, so I'd like to avoid using two different names in two sides, nor modifying the whole python code.

@ochameau

ochameau Jun 26, 2012

Member

Do you mind renaming this old beast in the next step ? i.e. when we are going to build the manifest from JS side.
Just because it is called harness options all over the place in python, so I'd like to avoid using two different names in two sides, nor modifying the whole python code.

This comment has been minimized.

@Gozala

Gozala Jun 26, 2012

Member

Sure, just was trying to come up with a better name, no rush though.

@Gozala

Gozala Jun 26, 2012

Member

Sure, just was trying to come up with a better name, no rush though.

cfx/README.md
+ // but you can pass other attributes. They will be written into
+ // `harness-options.json` at xpi's root folder
+ },
+ extraHarnessOptions: "dictionnary" // A set of additional attributes to

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

I think just extra would do here as well.

@Gozala

Gozala Jun 25, 2012

Member

I think just extra would do here as well.

cfx/cfx.js
+function getOptions() {
+ let optionsFile = system.env["CFX_OPTIONS_FILE"];
+ if (!optionsFile) {
+ throw new Error("Unable to locate options file, environnement not set.");

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

environnement -> environment

Also I'd say "environment variable is not set" instead.

@Gozala

Gozala Jun 25, 2012

Member

environnement -> environment

Also I'd say "environment variable is not set" instead.

cfx/cfx.js
+ data = file.read(optionsFile);
+ }
+ catch(e) {
+ throw new Error("Unable to read options file: " + optionsFile + "\n" + e);

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

Nit: We tend to just use Error without new.

@Gozala

Gozala Jun 25, 2012

Member

Nit: We tend to just use Error without new.

cfx/cfx.js
+
+function main() {
+ let { command, options } = getOptions();
+ if (command === "install-xpi") {

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

I would find it easier to read & maintain if it was something like:

commands[command] || commands.help(options)

Where commands is a dictionary of command functions that extract their options and do whatever they need to.

@Gozala

Gozala Jun 25, 2012

Member

I would find it easier to read & maintain if it was something like:

commands[command] || commands.help(options)

Where commands is a dictionary of command functions that extract their options and do whatever they need to.

cfx/cfx.js
+ }
+}
+
+try {

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

Also if you're ok with previous suggestion I would rather move try / catch into main itself so it will end up like:

function main() {
  try {
    let { command, options } = getOptions();
    commands[command] || commands.help(options)
  } catch (error) {
    if (error instanceof CfxError) {
      // Stacktrace isn't usefull in case of custom cfx exceptions,
      // prints custom message instead
      console.log(e);
    }
    else {
      console.error("Unknown internal error in cfx.js:");
      console.exception(e);
    }
    system.exit(system.E_FORCE);
  }
}
@Gozala

Gozala Jun 25, 2012

Member

Also if you're ok with previous suggestion I would rather move try / catch into main itself so it will end up like:

function main() {
  try {
    let { command, options } = getOptions();
    commands[command] || commands.help(options)
  } catch (error) {
    if (error instanceof CfxError) {
      // Stacktrace isn't usefull in case of custom cfx exceptions,
      // prints custom message instead
      console.log(e);
    }
    else {
      console.error("Unknown internal error in cfx.js:");
      console.exception(e);
    }
    system.exit(system.E_FORCE);
  }
}
cfx/exception.js
+function CfxError(name) {
+ this.name = name;
+}
+CfxError.prototype = new Error();

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

Please use CfxError.prototype = Object.create(Error.prototype) as new Error is not quite right.

@Gozala

Gozala Jun 25, 2012

Member

Please use CfxError.prototype = Object.create(Error.prototype) as new Error is not quite right.

cfx/exception.js
+// Set of custom exception class for cfx.js
+// Designed to be handled nicely from main module
+
+function CfxError(name) {

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

Honestly I don't see any value in making this prototype hierarchies. They just make whole thing look more complicated. This would have worked just fine:

function cfxError(message, name) {
  var error = Error(message);
  error.cfxError = true;
  error.name = name || 'CFXError'
  return error;
}

function InvalidArgument(message) {
  return cfxError(message, 'InvalidArgument')
}

function InternalCfxError(message) {
  return cfxError(message, 'InternalCfxError')
}
@Gozala

Gozala Jun 25, 2012

Member

Honestly I don't see any value in making this prototype hierarchies. They just make whole thing look more complicated. This would have worked just fine:

function cfxError(message, name) {
  var error = Error(message);
  error.cfxError = true;
  error.name = name || 'CFXError'
  return error;
}

function InvalidArgument(message) {
  return cfxError(message, 'InvalidArgument')
}

function InternalCfxError(message) {
  return cfxError(message, 'InternalCfxError')
}

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

Although in catch you would just did if (error.cfxError) { ...

@Gozala

Gozala Jun 25, 2012

Member

Although in catch you would just did if (error.cfxError) { ...

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

After reading code of other modules, I'm convinced that you don't even need this module. Just set error.cfxError = true on throw or define helper error functions in the appropriate modules.

@Gozala

Gozala Jun 25, 2012

Member

After reading code of other modules, I'm convinced that you don't even need this module. Just set error.cfxError = true on throw or define helper error functions in the appropriate modules.

This comment has been minimized.

@ochameau

ochameau Jun 26, 2012

Member

I'm expecting these exceptions to be used by all cfx modules, in order to classify kind of errors and print the most meaningfull error message we can. And especially distinguish user error from internal errors.
Otherwise, implementation wise, I've just followed this page: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error
I'm fine with dropping the prototype usage in favor of your code snippet, but I think it make sense to keep this module in order to reuse these normalized errors?

@ochameau

ochameau Jun 26, 2012

Member

I'm expecting these exceptions to be used by all cfx modules, in order to classify kind of errors and print the most meaningfull error message we can. And especially distinguish user error from internal errors.
Otherwise, implementation wise, I've just followed this page: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error
I'm fine with dropping the prototype usage in favor of your code snippet, but I think it make sense to keep this module in order to reuse these normalized errors?

This comment has been minimized.

@Gozala

Gozala Jun 26, 2012

Member

I think what I was trying to say is that this complicates things, as you like to say users will have to learn about these error types. If only desire is to handle such errors differently we could just set isInternal or alike property and avoid a lot of complexity. If you want to have custom error types it's still ok by me (just make sure to use Object.create(Error.prototype) instead), although I would prefer more simpler approach.

@Gozala

Gozala Jun 26, 2012

Member

I think what I was trying to say is that this complicates things, as you like to say users will have to learn about these error types. If only desire is to handle such errors differently we could just set isInternal or alike property and avoid a lot of complexity. If you want to have custom error types it's still ok by me (just make sure to use Object.create(Error.prototype) instead), although I would prefer more simpler approach.

cfx/preferences.js
+ let value = pref.value;
+
+ // isFloat
+ // TODO: Understand why python code ignore float and only floats?

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

Please use function form of typeof as suggested by style guide.

@Gozala

Gozala Jun 25, 2012

Member

Please use function form of typeof as suggested by style guide.

This comment has been minimized.

@Gozala

Gozala Jun 25, 2012

Member

Maybe @warner can tell us why python code was ignoring floats ?

@Gozala

Gozala Jun 25, 2012

Member

Maybe @warner can tell us why python code was ignoring floats ?

This comment has been minimized.

@warner

warner Jun 25, 2012

Member

No idea. The code (python in python-lib/cuddlefish/options_defaults.py and JS in python-lib/cuddlefish/app-extension/bootstrap.js) was ignoring floats when I got there. Looks like Erik Vold added that in 299ec79. Can prefs be floats? The comments on that commit suggest they have to be integers.

@warner

warner Jun 25, 2012

Member

No idea. The code (python in python-lib/cuddlefish/options_defaults.py and JS in python-lib/cuddlefish/app-extension/bootstrap.js) was ignoring floats when I got there. Looks like Erik Vold added that in 299ec79. Can prefs be floats? The comments on that commit suggest they have to be integers.

This comment has been minimized.

@ochameau

ochameau Jun 26, 2012

Member

@erikvold would you be able to take a look at this and confirm that I implemented preferences correctly in JS?

@ochameau

ochameau Jun 26, 2012

Member

@erikvold would you be able to take a look at this and confirm that I implemented preferences correctly in JS?

This comment has been minimized.

@ochameau

ochameau Jun 26, 2012

Member

Please use function form of typeof as suggested by style guide.

https://github.com/mozilla/addon-sdk/wiki/Coding-style-guide
There isn't anything about typeof?

@ochameau

ochameau Jun 26, 2012

Member

Please use function form of typeof as suggested by style guide.

https://github.com/mozilla/addon-sdk/wiki/Coding-style-guide
There isn't anything about typeof?

This comment has been minimized.

@Gozala

Gozala Jun 26, 2012

Member

There isn't anything about typeof?

Inherited from general mozilla style guide :)
https://developer.mozilla.org/En/Developer_Guide/Coding_Style#Operators

Good point, I'll add that to our style guide as well!

@Gozala

Gozala Jun 26, 2012

Member

There isn't anything about typeof?

Inherited from general mozilla style guide :)
https://developer.mozilla.org/En/Developer_Guide/Coding_Style#Operators

Good point, I'll add that to our style guide as well!

This comment has been minimized.

@erikvold

erikvold Jun 26, 2012

Contributor
Can prefs be floats? 

no, unless a string type is used.

@erikvold

erikvold Jun 26, 2012

Contributor
Can prefs be floats? 

no, unless a string type is used.

This comment has been minimized.

@erikvold

erikvold Jun 26, 2012

Contributor
@erikvold would you be able to take a look at this and confirm that I implemented preferences correctly in JS?

Sure I'll take a look tonight.

@erikvold

erikvold Jun 26, 2012

Contributor
@erikvold would you be able to take a look at this and confirm that I implemented preferences correctly in JS?

Sure I'll take a look tonight.

This comment has been minimized.

@erikvold

erikvold Jun 27, 2012

Contributor

the preferences.js file looks good to me @ochameau I'll have time to test it out tomorrow night.

@erikvold

erikvold Jun 27, 2012

Contributor

the preferences.js file looks good to me @ochameau I'll have time to test it out tomorrow night.

@ochameau

This comment has been minimized.

Show comment
Hide comment
@ochameau

ochameau Jun 26, 2012

Member

I addressed all comments except ones where I've added comments + the one about nsIDOMParser (haven't had time to looked at it - #410 (comment))

Member

ochameau commented Jun 26, 2012

I addressed all comments except ones where I've added comments + the one about nsIDOMParser (haven't had time to looked at it - #410 (comment))

cfx/preferences.js
+ let pref = options[key];
+ if (!('value' in pref))
+ continue;
+ // TODO: Understand why python code ignore float and only floats?

This comment has been minimized.

@erikvold

erikvold Jun 27, 2012

Contributor

the only acceptable types are bool, int, and string. So that is why floats were ignored. It might be better to throw a warning, or error here tho, and the other acceptable JSON types (ie: object, array, and null) should be treated the same as a float.

@erikvold

erikvold Jun 27, 2012

Contributor

the only acceptable types are bool, int, and string. So that is why floats were ignored. It might be better to throw a warning, or error here tho, and the other acceptable JSON types (ie: object, array, and null) should be treated the same as a float.

This comment has been minimized.

@ochameau

ochameau Jun 27, 2012

Member

I've updated this patch again in order to accept only bool, int or string and throw an error otherwise.
Feel free to tell me if there is still something wrong.

@ochameau

ochameau Jun 27, 2012

Member

I've updated this patch again in order to accept only bool, int or string and throw an error otherwise.
Feel free to tell me if there is still something wrong.

@ochameau

This comment has been minimized.

Show comment
Hide comment
@ochameau

ochameau Jun 27, 2012

Member

About build step. I agree it is kind of painfull to have such build step. The benefit is that cfx.js is just a regular SDK "addon". And if we want to keep it as being a regular SDK addon, we have to face the mandatory build step.
We can make it easier with some build-update script. Otherwise we can do some hacks like this:
ochameau/addon-sdk@ochameau:cfx.js...ochameau:cfx.js-no-build
Where we instanciate a custom loader to make it work dynamically. But I'd prefer to avoid such thing. I don't think it is a good idea to maintain such code in cfx itself. We should either integrate such behavior into the SDK itself or at least modify bootstrap/cuddlefish/loader in order to make it super easy. (In this experiement cfx.js works, but I'm lacking of addon-kit, self support, locales, ...)
Would it be something we can later iterate on?

Member

ochameau commented Jun 27, 2012

About build step. I agree it is kind of painfull to have such build step. The benefit is that cfx.js is just a regular SDK "addon". And if we want to keep it as being a regular SDK addon, we have to face the mandatory build step.
We can make it easier with some build-update script. Otherwise we can do some hacks like this:
ochameau/addon-sdk@ochameau:cfx.js...ochameau:cfx.js-no-build
Where we instanciate a custom loader to make it work dynamically. But I'd prefer to avoid such thing. I don't think it is a good idea to maintain such code in cfx itself. We should either integrate such behavior into the SDK itself or at least modify bootstrap/cuddlefish/loader in order to make it super easy. (In this experiement cfx.js works, but I'm lacking of addon-kit, self support, locales, ...)
Would it be something we can later iterate on?

@Gozala

This comment has been minimized.

Show comment
Hide comment
@Gozala

Gozala Jun 27, 2012

Member

Would it be something we can later iterate on?

This is huge change for a users, I believe decisions on weather we should or not do such changes is up to project manager @dcm-moz / @canuckistani I personally would rather see custom cfx-js specefic loader instance than a build step. Alternatively we could do bundle build add-on or do it transparently from users.

We should either integrate such behavior into the SDK itself or at least modify bootstrap/cuddlefish/loader in order to
make it super easy

Do you have something specific in mind ?

Member

Gozala commented Jun 27, 2012

Would it be something we can later iterate on?

This is huge change for a users, I believe decisions on weather we should or not do such changes is up to project manager @dcm-moz / @canuckistani I personally would rather see custom cfx-js specefic loader instance than a build step. Alternatively we could do bundle build add-on or do it transparently from users.

We should either integrate such behavior into the SDK itself or at least modify bootstrap/cuddlefish/loader in order to
make it super easy

Do you have something specific in mind ?

cfx/preferences.js
+ continue;
+
+ if (["boolean", "number", "string"].indexOf(typeof(pref.value)) === -1
+ || isFloat(pref.value))

This comment has been minimized.

@Gozala

Gozala Jun 27, 2012

Member

I think this would have being little easier:

if (!isPrimitive(pref.value) || isFloat(pref.value)) { ...
@Gozala

Gozala Jun 27, 2012

Member

I think this would have being little easier:

if (!isPrimitive(pref.value) || isFloat(pref.value)) { ...
cfx/xpi.js
+ // the harness will try to access it.
+ zip.mkdir('resources/' + packageName);
+ for (let sectionName in packages[packageName]) {
+ let abs_dirname = packages[packageName][sectionName]

This comment has been minimized.

@Gozala

Gozala Jun 27, 2012

Member

camelCase please, here and below. Also little more descriptive names would help.

@Gozala

Gozala Jun 27, 2012

Member

camelCase please, here and below. Also little more descriptive names would help.

cfx/xpi.js
+ writePreferences(zip, harnessOptions.jetpackID,
+ harnessOptions.preferences || null);
+ // We delete harnessOptions attributes in order to avoid writing them
+ // into xpi's manifest file.

This comment has been minimized.

@Gozala

Gozala Jun 27, 2012

Member

I would honestly prefer something like serialize(harnessOptions) that would omit keys that should not be written (or maybe in writeManifest itself can do it). That way cherry-picking of properties is encapsulated in one location that is easy to find / maintain in contrast to deletes all over the place.

@Gozala

Gozala Jun 27, 2012

Member

I would honestly prefer something like serialize(harnessOptions) that would omit keys that should not be written (or maybe in writeManifest itself can do it). That way cherry-picking of properties is encapsulated in one location that is easy to find / maintain in contrast to deletes all over the place.

This comment has been minimized.

@ochameau

ochameau Jul 4, 2012

Member

I pushed new revision with some modification on python side in order to avoid adding such attribute in first place.
So that harnessOptions will only contain attribute that have to end up in harness-options.json file.
All others (locale, packages, icon, icon64) are now in options object.
This changed allowed me to prepare the next step. So now the JS side receive SDK and Addon absolute path,
so that you can start building manifest in JS.

@ochameau

ochameau Jul 4, 2012

Member

I pushed new revision with some modification on python side in order to avoid adding such attribute in first place.
So that harnessOptions will only contain attribute that have to end up in harness-options.json file.
All others (locale, packages, icon, icon64) are now in options object.
This changed allowed me to prepare the next step. So now the JS side receive SDK and Addon absolute path,
so that you can start building manifest in JS.

+ try {
+ // We do not care about any error while removing the xpi file,
+ // we try to ensure that we do not leave any temporary file around.
+ // It may not even be created.

This comment has been minimized.

@Gozala

Gozala Jun 27, 2012

Member

What's a point of catching and re-throwing more detailed errors from rm if they are ignored anyway ?

@Gozala

Gozala Jun 27, 2012

Member

What's a point of catching and re-throwing more detailed errors from rm if they are ignored anyway ?

This comment has been minimized.

@ochameau

ochameau Jul 3, 2012

Member

Here I ignore errors from rm but not errors from the upper try/catch statement. i.e. errors happening in one of these writeSomething functions. I'm using finally as suggested in previous comment #410 (comment)

@ochameau

ochameau Jul 3, 2012

Member

Here I ignore errors from rm but not errors from the upper try/catch statement. i.e. errors happening in one of these writeSomething functions. I'm using finally as suggested in previous comment #410 (comment)

@Gozala

This comment has been minimized.

Show comment
Hide comment
@Gozala

Gozala Jun 27, 2012

Member

I made few minor points and I think only few things need to be sorted out before we can land:

  • Need to make sure that build step is fine by project managers and there is no better way to go about this.
  • Document why nsICommandLineHandler is used (comments).

In addition you might want to:

  • Get someone to do a python review, I looked at it and code makes sense to me, but I don't have enough
    expertise to tell if you do something in a way that considered to be a bad practice or if it will work for all python
    versions etc..
  • I don't know if you still plan to do this https://github.com/mozilla/addon-sdk/pull/410/files#r1047385 or if you were
    planning to do it in the separate step.

Happy to see this coming along nicely!

Member

Gozala commented Jun 27, 2012

I made few minor points and I think only few things need to be sorted out before we can land:

  • Need to make sure that build step is fine by project managers and there is no better way to go about this.
  • Document why nsICommandLineHandler is used (comments).

In addition you might want to:

  • Get someone to do a python review, I looked at it and code makes sense to me, but I don't have enough
    expertise to tell if you do something in a way that considered to be a bad practice or if it will work for all python
    versions etc..
  • I don't know if you still plan to do this https://github.com/mozilla/addon-sdk/pull/410/files#r1047385 or if you were
    planning to do it in the separate step.

Happy to see this coming along nicely!

@ochameau

This comment has been minimized.

Show comment
Hide comment
@ochameau

ochameau Jun 28, 2012

Member

I'm not sure it is clear about the build step. You won't have to build cfx.js if you want to use the SDK, but only if you want to patch cfx javascript code!

Member

ochameau commented Jun 28, 2012

I'm not sure it is clear about the build step. You won't have to build cfx.js if you want to use the SDK, but only if you want to patch cfx javascript code!

@Gozala

This comment has been minimized.

Show comment
Hide comment
@Gozala

Gozala Jun 28, 2012

Member

I'm not sure it is clear about the build step. You won't have to build cfx.js if you want to use the SDK, but only if you want > to patch cfx javascript code!

Ok then I clearly don't understand how this works :( Could we maybe talk on vidyo tomorrow morning I think little go through would be very helpful.

Member

Gozala commented Jun 28, 2012

I'm not sure it is clear about the build step. You won't have to build cfx.js if you want to use the SDK, but only if you want > to patch cfx javascript code!

Ok then I clearly don't understand how this works :( Could we maybe talk on vidyo tomorrow morning I think little go through would be very helpful.

cfx/cfx.js
+const xpi = require("./xpi");
+
+function getOptions() {
+ let optionsFile = system.env["CFX_OPTIONS_FILE"];

This comment has been minimized.

@Gozala

Gozala Jul 5, 2012

Member

Nit: Why not just system.env.CFX_OPTIONS_FILE ?

@Gozala

Gozala Jul 5, 2012

Member

Nit: Why not just system.env.CFX_OPTIONS_FILE ?

cfx/preferences.js
+ if (pref.type == "control" && !("label" in pref))
+ throw new InvalidArgument("The 'control' inline pref type requires a 'label'");
+
+ // TODO: Check that pref["type"] matches default value type

This comment has been minimized.

@Gozala

Gozala Jul 5, 2012

Member

Wanna subbmit a follow-up bug for this and put a link here, to make sure we do that at some point ?

@Gozala

Gozala Jul 5, 2012

Member

Wanna subbmit a follow-up bug for this and put a link here, to make sure we do that at some point ?

This comment has been minimized.

@ochameau

ochameau Jul 9, 2012

Member

Filled: https://bugzilla.mozilla.org/show_bug.cgi?id=772126
This TODO comes from python code. Good candidate for a follow-up!

@ochameau

ochameau Jul 9, 2012

Member

Filled: https://bugzilla.mozilla.org/show_bug.cgi?id=772126
This TODO comes from python code. Good candidate for a follow-up!

cfx/preferences.js
+exports.validate = validate;
+
+function createXULDocument(content) {
+ let str = "<?xml version=\"1.0\"?>" + content;

This comment has been minimized.

@Gozala

Gozala Jul 5, 2012

Member

Nit: not sure it's worth appending this header to the content, I think content should probably come with it's own.

@Gozala

Gozala Jul 5, 2012

Member

Nit: not sure it's worth appending this header to the content, I think content should probably come with it's own.

@Gozala

This comment has been minimized.

Show comment
Hide comment
@Gozala

Gozala Jul 5, 2012

Member

@ochameau Thanks for the hard work. I think it's looking good now!
I still would like to hold on landing till our weekly meeting so we can discuss what's the best time / place for this to land. With that it would be also great if we could have a vidyo meeting on Monday where we could walk though the whole patch to make sure I don't miss(understood) something.

Member

Gozala commented Jul 5, 2012

@ochameau Thanks for the hard work. I think it's looking good now!
I still would like to hold on landing till our weekly meeting so we can discuss what's the best time / place for this to land. With that it would be also great if we could have a vidyo meeting on Monday where we could walk though the whole patch to make sure I don't miss(understood) something.

@ochameau

This comment has been minimized.

Show comment
Hide comment
@ochameau

ochameau Jul 10, 2012

Member

Some late changes. I had to fix an issue in preferences support. nsIDOMParser/nsIDOMSerializer are throwing errors with XUL document. options.xul file were badly generated.
I discovered that during a stress test session. I've tweaked the code a bit in order to avoid generating different files.
For example, python code sort JSON object keys and used only one space for indentation.
I'd like to avoid introducing any unecessary difference in order to ease automatic repacking.

Member

ochameau commented Jul 10, 2012

Some late changes. I had to fix an issue in preferences support. nsIDOMParser/nsIDOMSerializer are throwing errors with XUL document. options.xul file were badly generated.
I discovered that during a stress test session. I've tweaked the code a bit in order to avoid generating different files.
For example, python code sort JSON object keys and used only one space for indentation.
I'd like to avoid introducing any unecessary difference in order to ease automatic repacking.

@Gozala

This comment has been minimized.

Show comment
Hide comment
@Gozala

Gozala Sep 17, 2012

Member

I just was trying to integrate my cfx-js work with this and run into issues when running tests. For whatever reason it fails with a following trace:

Running tests on Firefox 18.0a1/Gecko 18.0a1 ({ec8030f7-c20a-464f-9b0e-13a3a9e97384}) under darwin/x86.
error: TEST FAILED: test-xpi.testIt (exception)
error: An exception occurred.
Traceback (most recent call last):
  File "resource://cfx-at-jetpack/api-utils/lib/timer.js", line 28, in notify
    callback.apply(null, args);
  File "resource://cfx-at-jetpack/test-harness/lib/run-tests.js", line 59, in null
    onDone: onDone});
  File "resource://cfx-at-jetpack/test-harness/lib/harness.js", line 314, in runTests
    nextIteration();
  File "resource://cfx-at-jetpack/test-harness/lib/harness.js", line 240, in nextIteration
    onDone: nextIteration
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 20, in findAndRunTests
    function (tests) {
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test-finder.js", line 73, in findTests
    cb(tests);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 23, in null
    onDone: options.onDone});
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 417, in startMany
    runNextTest(this);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 412, in runNextTest
    self.start({test: test, onDone: runNextTest});
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 435, in start
    this.test.testFunction(this);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test-finder.js", line 25, in runTest
    test(runner);
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 65, in null
    writeFile(file.join(section, "test.js"), rootJsFile);
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 57, in writeFile
    let testFile = file.open(path, "w");
  File "resource://cfx-at-jetpack/api-utils/lib/file.js", line 143, in open
    stream.init(file, openFlags, permFlags, 0);
[Exception... "Component returned failure code: 0x80520015 (NS_ERROR_FILE_ACCESS_DENIED) [nsIFileOutputStream.init]"  nsresult: "0x80520015 (NS_ERROR_FILE_ACCESS_DENIED)"  location: "JS frame :: resource://cfx-at-jetpack/api-utils/lib/loader.js -> resource://cfx-at-jetpack/api-utils/lib/file.js :: open :: line 143"  data: no]

I'll be investigating into this further, but just wanted to make you aware.

Member

Gozala commented Sep 17, 2012

I just was trying to integrate my cfx-js work with this and run into issues when running tests. For whatever reason it fails with a following trace:

Running tests on Firefox 18.0a1/Gecko 18.0a1 ({ec8030f7-c20a-464f-9b0e-13a3a9e97384}) under darwin/x86.
error: TEST FAILED: test-xpi.testIt (exception)
error: An exception occurred.
Traceback (most recent call last):
  File "resource://cfx-at-jetpack/api-utils/lib/timer.js", line 28, in notify
    callback.apply(null, args);
  File "resource://cfx-at-jetpack/test-harness/lib/run-tests.js", line 59, in null
    onDone: onDone});
  File "resource://cfx-at-jetpack/test-harness/lib/harness.js", line 314, in runTests
    nextIteration();
  File "resource://cfx-at-jetpack/test-harness/lib/harness.js", line 240, in nextIteration
    onDone: nextIteration
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 20, in findAndRunTests
    function (tests) {
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test-finder.js", line 73, in findTests
    cb(tests);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 23, in null
    onDone: options.onDone});
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 417, in startMany
    runNextTest(this);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 412, in runNextTest
    self.start({test: test, onDone: runNextTest});
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 435, in start
    this.test.testFunction(this);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test-finder.js", line 25, in runTest
    test(runner);
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 65, in null
    writeFile(file.join(section, "test.js"), rootJsFile);
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 57, in writeFile
    let testFile = file.open(path, "w");
  File "resource://cfx-at-jetpack/api-utils/lib/file.js", line 143, in open
    stream.init(file, openFlags, permFlags, 0);
[Exception... "Component returned failure code: 0x80520015 (NS_ERROR_FILE_ACCESS_DENIED) [nsIFileOutputStream.init]"  nsresult: "0x80520015 (NS_ERROR_FILE_ACCESS_DENIED)"  location: "JS frame :: resource://cfx-at-jetpack/api-utils/lib/loader.js -> resource://cfx-at-jetpack/api-utils/lib/file.js :: open :: line 143"  data: no]

I'll be investigating into this further, but just wanted to make you aware.

@ochameau

This comment has been minimized.

Show comment
Hide comment
@ochameau

ochameau Sep 17, 2012

Member

It is failing for me too, but on other assertions:

info: executing 'test-xpi.testIt'
info: pass: a == b == "test-install-rdf@jetpack"
info: pass: a == b == "test install.rdf"
info: pass: a == b == "test install.rdf description"
info: pass: a == b == "1.2"
info: pass: a == b == "test creator"
info: pass: a == b == "icon"
info: pass: a == b == "icon64"
error: TEST FAILED: test-xpi.testIt (failure)
error: fail: "{\n \"extra\": \"option\",\n \"jetpackID\": \"foo@bar.com\",\n \"m
anifest\": {}\n}" != "{\n  \"jetpackID\": \"foo@bar.com\",\n  \"manifest\": {},\
n  \"extra\": \"option\"\n}"
info: Traceback (most recent call last):
  File "resource:///modules/XPIProvider.jsm", line 4111, in null
    this.callback(this.addons);
  File "resource:///modules/XPIProvider.jsm", line 5163, in null
    aCallback(aAddons[0]);
  File "resource:///modules/XPIProvider.jsm", line 3193, in null
    aCallback(createWrapper(aAddon));
  File "resource://gre/modules/AddonManager.jsm", line 1556, in null
    safeCall(aCallback, aAddon);
  File "resource://gre/modules/AddonManager.jsm", line 80, in safeCall
    aCallback.apply(null, args);
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 153, in null
    prettyJSON(expectedHarnessOptions));
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 139, in assert
FileContent
    test.assertEqual(data, content);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 164, in asse
rtEqual
    this.fail(message);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 71, in fail
    this.console.trace();
info: pass: a == b == "function install() {}; function startup() {};"
info: pass: a == b == "An arbitrary file from template in a folder"
info: pass: a == b == "root js file"
info: pass: a == b == "js file in a sub folder"
info: pass: a == b == "root js file"
info: pass: a == b == "js file in a sub folder"
info: pass: assertion successful
info: pass: assertion successful
info: pass: assertion successful
info: pass: assertion successful
error: fail: "{\n \"locales\": [\n  \"en-US\",\n  \"en-reverse\"\n ]\n}\n" != "{
\n  \"locales\": [\n    \"en-US\",\n    \"en-reverse\"\n  ]\n}\n"
info: Traceback (most recent call last):
  File "resource:///modules/XPIProvider.jsm", line 4111, in null
    this.callback(this.addons);
  File "resource:///modules/XPIProvider.jsm", line 5163, in null
    aCallback(aAddons[0]);
  File "resource:///modules/XPIProvider.jsm", line 3193, in null
    aCallback(createWrapper(aAddon));
  File "resource://gre/modules/AddonManager.jsm", line 1556, in null
    safeCall(aCallback, aAddon);
  File "resource://gre/modules/AddonManager.jsm", line 80, in safeCall
    aCallback.apply(null, args);
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 173, in null
    prettyJSON({locales: ["en-US", "en-reverse"]}) + "\n");
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 139, in assert
FileContent
    test.assertEqual(data, content);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 164, in asse
rtEqual
    this.fail(message);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 71, in fail
    this.console.trace();
error: fail: "{\n \"key\": \"uo\u0131\u0287\u0250\u05DFsu\u0250\u0279\u0287\"\n}
" != "{\n  \"key\": \"uo\u0131\u0287\u0250\u05DFsu\u0250\u0279\u0287\"\n}"
info: Traceback (most recent call last):
  File "resource:///modules/XPIProvider.jsm", line 4111, in null
    this.callback(this.addons);
  File "resource:///modules/XPIProvider.jsm", line 5163, in null
    aCallback(aAddons[0]);
  File "resource:///modules/XPIProvider.jsm", line 3193, in null
    aCallback(createWrapper(aAddon));
  File "resource://gre/modules/AddonManager.jsm", line 1556, in null
    safeCall(aCallback, aAddon);
  File "resource://gre/modules/AddonManager.jsm", line 80, in safeCall
    aCallback.apply(null, args);
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 175, in null
    prettyJSON({key: reverseTranslation}));
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 139, in assert
FileContent
    test.assertEqual(data, content);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 164, in asse
rtEqual
    this.fail(message);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 71, in fail
    this.console.trace();
error: fail: "{\n \"key\": \"translation\"\n}" != "{\n  \"key\": \"translation\"
\n}"
info: Traceback (most recent call last):
  File "resource:///modules/XPIProvider.jsm", line 4111, in null
    this.callback(this.addons);
  File "resource:///modules/XPIProvider.jsm", line 5163, in null
    aCallback(aAddons[0]);
  File "resource:///modules/XPIProvider.jsm", line 3193, in null
    aCallback(createWrapper(aAddon));
  File "resource://gre/modules/AddonManager.jsm", line 1556, in null
    safeCall(aCallback, aAddon);
  File "resource://gre/modules/AddonManager.jsm", line 80, in safeCall
    aCallback.apply(null, args);
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 177, in null
    prettyJSON({key: usTranslation}));
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 139, in assert
FileContent
    test.assertEqual(data, content);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 164, in asse
rtEqual
    this.fail(message);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 71, in fail
    this.console.trace();

17 of 21 tests passed.

The following tests failed:
  test-xpi.testIt: failure

I'll try to fix that tomorrow.

Member

ochameau commented Sep 17, 2012

It is failing for me too, but on other assertions:

info: executing 'test-xpi.testIt'
info: pass: a == b == "test-install-rdf@jetpack"
info: pass: a == b == "test install.rdf"
info: pass: a == b == "test install.rdf description"
info: pass: a == b == "1.2"
info: pass: a == b == "test creator"
info: pass: a == b == "icon"
info: pass: a == b == "icon64"
error: TEST FAILED: test-xpi.testIt (failure)
error: fail: "{\n \"extra\": \"option\",\n \"jetpackID\": \"foo@bar.com\",\n \"m
anifest\": {}\n}" != "{\n  \"jetpackID\": \"foo@bar.com\",\n  \"manifest\": {},\
n  \"extra\": \"option\"\n}"
info: Traceback (most recent call last):
  File "resource:///modules/XPIProvider.jsm", line 4111, in null
    this.callback(this.addons);
  File "resource:///modules/XPIProvider.jsm", line 5163, in null
    aCallback(aAddons[0]);
  File "resource:///modules/XPIProvider.jsm", line 3193, in null
    aCallback(createWrapper(aAddon));
  File "resource://gre/modules/AddonManager.jsm", line 1556, in null
    safeCall(aCallback, aAddon);
  File "resource://gre/modules/AddonManager.jsm", line 80, in safeCall
    aCallback.apply(null, args);
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 153, in null
    prettyJSON(expectedHarnessOptions));
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 139, in assert
FileContent
    test.assertEqual(data, content);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 164, in asse
rtEqual
    this.fail(message);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 71, in fail
    this.console.trace();
info: pass: a == b == "function install() {}; function startup() {};"
info: pass: a == b == "An arbitrary file from template in a folder"
info: pass: a == b == "root js file"
info: pass: a == b == "js file in a sub folder"
info: pass: a == b == "root js file"
info: pass: a == b == "js file in a sub folder"
info: pass: assertion successful
info: pass: assertion successful
info: pass: assertion successful
info: pass: assertion successful
error: fail: "{\n \"locales\": [\n  \"en-US\",\n  \"en-reverse\"\n ]\n}\n" != "{
\n  \"locales\": [\n    \"en-US\",\n    \"en-reverse\"\n  ]\n}\n"
info: Traceback (most recent call last):
  File "resource:///modules/XPIProvider.jsm", line 4111, in null
    this.callback(this.addons);
  File "resource:///modules/XPIProvider.jsm", line 5163, in null
    aCallback(aAddons[0]);
  File "resource:///modules/XPIProvider.jsm", line 3193, in null
    aCallback(createWrapper(aAddon));
  File "resource://gre/modules/AddonManager.jsm", line 1556, in null
    safeCall(aCallback, aAddon);
  File "resource://gre/modules/AddonManager.jsm", line 80, in safeCall
    aCallback.apply(null, args);
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 173, in null
    prettyJSON({locales: ["en-US", "en-reverse"]}) + "\n");
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 139, in assert
FileContent
    test.assertEqual(data, content);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 164, in asse
rtEqual
    this.fail(message);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 71, in fail
    this.console.trace();
error: fail: "{\n \"key\": \"uo\u0131\u0287\u0250\u05DFsu\u0250\u0279\u0287\"\n}
" != "{\n  \"key\": \"uo\u0131\u0287\u0250\u05DFsu\u0250\u0279\u0287\"\n}"
info: Traceback (most recent call last):
  File "resource:///modules/XPIProvider.jsm", line 4111, in null
    this.callback(this.addons);
  File "resource:///modules/XPIProvider.jsm", line 5163, in null
    aCallback(aAddons[0]);
  File "resource:///modules/XPIProvider.jsm", line 3193, in null
    aCallback(createWrapper(aAddon));
  File "resource://gre/modules/AddonManager.jsm", line 1556, in null
    safeCall(aCallback, aAddon);
  File "resource://gre/modules/AddonManager.jsm", line 80, in safeCall
    aCallback.apply(null, args);
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 175, in null
    prettyJSON({key: reverseTranslation}));
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 139, in assert
FileContent
    test.assertEqual(data, content);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 164, in asse
rtEqual
    this.fail(message);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 71, in fail
    this.console.trace();
error: fail: "{\n \"key\": \"translation\"\n}" != "{\n  \"key\": \"translation\"
\n}"
info: Traceback (most recent call last):
  File "resource:///modules/XPIProvider.jsm", line 4111, in null
    this.callback(this.addons);
  File "resource:///modules/XPIProvider.jsm", line 5163, in null
    aCallback(aAddons[0]);
  File "resource:///modules/XPIProvider.jsm", line 3193, in null
    aCallback(createWrapper(aAddon));
  File "resource://gre/modules/AddonManager.jsm", line 1556, in null
    safeCall(aCallback, aAddon);
  File "resource://gre/modules/AddonManager.jsm", line 80, in safeCall
    aCallback.apply(null, args);
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 177, in null
    prettyJSON({key: usTranslation}));
  File "resource://cfx-at-jetpack/cfx-js/tests/test-xpi.js", line 139, in assert
FileContent
    test.assertEqual(data, content);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 164, in asse
rtEqual
    this.fail(message);
  File "resource://cfx-at-jetpack/api-utils/lib/unit-test.js", line 71, in fail
    this.console.trace();

17 of 21 tests passed.

The following tests failed:
  test-xpi.testIt: failure

I'll try to fix that tomorrow.

@ochameau

This comment has been minimized.

Show comment
Hide comment
@ochameau

ochameau Jan 17, 2013

Member

From what I remember I fixed review comments before landing that to cfx-js upstream repo branch.

Member

ochameau commented Jan 17, 2013

From what I remember I fixed review comments before landing that to cfx-js upstream repo branch.

@ochameau ochameau closed this Jan 17, 2013

@erikvold

This comment has been minimized.

Show comment
Hide comment
@erikvold

erikvold Jul 12, 2013

Contributor

Reopening this, I'll try to pick it up where it was left off.

Contributor

erikvold commented Jul 12, 2013

Reopening this, I'll try to pick it up where it was left off.

@erikvold erikvold reopened this Jul 12, 2013

@erikvold

This comment has been minimized.

Show comment
Hide comment
@erikvold

erikvold Jul 12, 2013

Contributor

Ah I see it was merge to the cfx-js branch

Contributor

erikvold commented Jul 12, 2013

Ah I see it was merge to the cfx-js branch

@erikvold erikvold closed this Jul 12, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment