refactor-864370: Remove motivate() naffness

Which also means we are returning a string rather than html.

Does not need review for mozilla-central.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Minor updates

Trivia: Adding missing semi-colons, !== not !=, brace positioning, removal of
function names (debugger does a better job), documentation updates,
plus, an actual fix for selection types that protects against a
prediction having no actual value, only a name.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Fix Settings.getSetting bug

In GCLI settings names are short simple things, bug prefs in Firefox are
generally longer, so there is a prefix that we use when a GCLI setting
is stored in a Firefox pref. getSetting was failing to use this prefix.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Add 'rank' to speller

See docs for what it does. This change also move the speller module into
'util' because we're going to want it from the file type completer.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Update spell for low cost case change

"FRED" is clearly a closer match to "fred" than "bill" but Damerau
Levenshtein doesn't allow that. So we add a 1/10th cost of a case change
compared to a normal swap cost.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Allow low cost prefix matches in spell.js

If the user has typed "re" then it's more likely that they are going to
want "readme.txt" than "xx" which would otherwise be closer according to
DL. So this adjusts to reduce the cost of prefix matches.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Create XHR module

Several things are going to want to do XHR. This creates a small wrapper
which is used from client and server to mediate the protocol.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Update test commands

Changes:
* Move test command from lib/test/commands to lib/gcli/commands since
  it depends on GCLI.
* Convert it to use the exports.items syntax
* Add 'suite' param to server side version of same command.
* Simplify command line test output

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Several tidy-ups (see details)

A number of issues fixed:
* Add requisition.getStatusMessage() which will return the biggest error
  from a requisition
* Add Status.fromString(str) for deserializing status messages
* Expose helpers.arrayIs(arr1, arr2, desc) for test modules to use
* Fix syntax error in examiner.suites which was causing test suite
  completion to fail.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Create custom command serializers

Perviously we the contained things that were not JSONable. Now they
should not.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Chrome console breakage

"var f = console.log; f('hi');" is broken on chrome. This is a
workaround.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Add missing returns from unit tests

helpers.audit returns a promise of completion. If the tests complete
synchronously, this can be missed out, but doing so runs the risk that
a test will later become asynchronous. So it's better to have them in.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Clearer flags for tests

Be clearer about what environment we are running in by explicitly
setting isNode, isFirefox, etc.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Allow easy upgrading of nodes modules

There will be a growing number of cases where we want to override the
implementation of modules in GCLI for the web, when GCLI is used in
NodeJS. This makes that process easier.

(Skip FF review)

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: s/skipArgUpdate/internal

Requisition.setAssignment had a skipArgUpdate option which obviously
skipped the 'arg update' process. This processing is needed when
setAssignment is being called from outside of a Requisition, but not
when it is an internal part of a call to update(). Since we are about
to add other processing with the same internal/extenal switch it seems
sensible to rename the option.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Use property for assignments

Previously Arguments and Conversions were set with an assign(…) function
but read with a property. This was confusing, and part of some bug
hunting so this change makes us use properties for get and set.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Refactor setAssignmentInternal

It now returns a promise so setAssignment can return it directly.
Also it's now declared as a var and bound so we can use it in a 'then'
clause. Also it's better commented.
No functionality changes.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Unnest 'if's. Use return instead

The logic in Requisition.assign is complex and can be simplified by
reducing the indents and using return.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Introduce updateIds to Requisition

Calls to update() and setAssignment() happen asynchronously, which means
we could call update twice before the first has completed. This change
adds an updateId which tracks a count of the changes so we can bail out
if we notice that the current change id is greater than the one we're
working on.

This (partially, see the next changeset) fixes an old bug, which wasn't
really noticeable until file types brought genuinely slow parsing.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Tell callers to update about overtaking

If a call to update() is overtaken by something else then we may need to
take action (as is the case for UP/DOWN navigation to menus) This
exposes the a boolean (it worked/didn't work) to the callers of update()

Signed-off-by: Joe Walker <jwalker@mozilla.com>