refactor-864370: Revert to SDK promises until perf issues fixed

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Remove mentions of isHttp

PhantomJS used to be able to run tests from file:// URLs as well as
http:// URLs, but when we changed module formats (from AMD to CommonJS)
then we lost the ability to load from file:// URLs, however the code
checks for this remained. This removes them.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Use the first connector as a default

Previously you had to specify a connector type when calling
connector.get(…), but this allows null to mean ‘the first registered
connector’.
This will be useful to avoid hardcoding connector types.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Connect to a URL not a host/port

Having a connection string (generally a URL) is more flexible to the
needs of various connection types.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Replace --allowexec with --xhr and --websocket

The reality is that we’ve got 3 ways of remoting stuff. The Mozilla
debug protocol, XHR and websocket, so we don’t really need to enable
remoting and say how - we just need to say how.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Fix broken operator precedence

This saves the message being chopped of at the ||.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Various minor bug fixes

Created requisitions should be registered so we can later look them
up by context. Fix mixup in function name and parameter name in
connect.js. Node has a setTimeout in its global object, so remove the
‘window’ prefix. Remove the ‘predictor’ member using delete rather than
‘= undefined’ to make sure it is really gone.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Update remote unit tests

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Additional unit tests and fixes to JS execution

Allow JS execution to return typed data, and add tests to make sure it
works properly.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Expose a centralCanon not a set of functions

This is the first step in allowing the canon to be replaceable, which
makes it easier to make our remoting totally transparent.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Remove predictions from json summary

When everything is async then they won’t show anyway, and it was always
a bit of a nasty hack.

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

The former name is a hangover from back when we had arg_fetch.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Pass a context to getPredictions()

We keep having the problem that getBlank() needs a context and there are
some places where we just don’t have a context to pass it, so this is
an experiment to pass the context to getPredictions() instead to see if
we can avoid these problems.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Pass options to mockCommands

We want to enable requisition to use a custom canon so we can remote a
complete set of commands, so when we setup the mock commands for
testing, we should use whatever canon the current requisition uses.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Automatically add/remote requisition mappings

Previously things that created a Requisition were responsible for adding
and removing the mapping, but this change moves this responsibility
from the creator to the Requisition itself.

Requisition is the model behind a command line, but it’s API isn’t
designed for external use, so we have conversionContext and
executionContext which are designed to be passed to commands and types.
But there are times when bits of the guts of GCLI need to get at a
Requisition, when all they have is a context. So we had a mapping to
allow them to get at the Requisition.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Pass a context to getPredictions() (part 2)

Now that we’re passing a context into getPredictions(), we pass this on
use this context in SelectionType.getBlank rather than the context
that was sometimes passed to getBlank() and sometimes not. We also
simplify the Converter ctor so we don’t call the prediction function
just to check that’s it works properly (as we now need a context to do
this anyway).

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Use a per-Requisition canon not a global one

Those changes all built up to being able to have a canon (i.e. list of
available commands) that is per-requisition rather than being global
(or at least per-loader)

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Make Requisition ctor take options object

Now that the canon is customisable, swap from using parameters to using
an options object in the constructor since all the parameters are
optional anyway.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Make prefix optional Canon.addProxyCommands

After this change, Canon.addProxyCommands can add a set of proxy
commands without a prefix so we can remote an entire canon without
changes to the individual commands.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Replace types singleton with a Types object

Just as a remoted command canon is better kept separate, the types that
the commands work on are better kept separate too.

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