Fix JS integration tests Pt. 2.

Only convert roots to 'ws' endpoints if browspr has registered an
endpoint formatter.  Kinda gross.

Change-Id: I4c6d54c395e853b91f9b9c5cd1ddb738f260a031
diff --git a/services/wsprd/browspr/browspr.go b/services/wsprd/browspr/browspr.go
index f9a8fd0..a6282d7 100644
--- a/services/wsprd/browspr/browspr.go
+++ b/services/wsprd/browspr/browspr.go
@@ -12,9 +12,14 @@
 	"veyron.io/veyron/veyron2/vlog"
 	"veyron.io/wspr/veyron/services/wsprd/account"
 	"veyron.io/wspr/veyron/services/wsprd/lib"
+	"veyron.io/wspr/veyron/services/wsprd/namespace"
 	"veyron.io/wspr/veyron/services/wsprd/principal"
 )
 
+func init() {
+	namespace.EpFormatter = lib.EndpointsToWs
+}
+
 // Browspr is an intermediary between our javascript code and the veyron network that allows our javascript library to use veyron.
 type Browspr struct {
 	rt             veyron2.Runtime
diff --git a/services/wsprd/namespace/request_handler.go b/services/wsprd/namespace/request_handler.go
index 33a2cad..91d6bbd 100644
--- a/services/wsprd/namespace/request_handler.go
+++ b/services/wsprd/namespace/request_handler.go
@@ -15,6 +15,9 @@
 	"veyron.io/wspr/veyron/services/wsprd/lib"
 )
 
+// Function to format endpoints.  Used by browspr to swap 'tcp' for 'ws'.
+var EpFormatter func(veyron2.Runtime, []string) ([]string, error) = nil
+
 // request struct represents a request to call a method on the runtime's namespace client
 type request struct {
 	Method namespaceMethod
@@ -309,12 +312,18 @@
 		return
 	}
 
-	wsRoots, err := lib.EndpointsToWs(rt, args.Roots)
-	if err != nil {
-		w.Error(verror2.Convert(verror2.Internal, ctx, err))
+	var formattedRoots []string
+	var err error
+	if EpFormatter != nil {
+		formattedRoots, err = EpFormatter(rt, args.Roots)
+		if err != nil {
+			w.Error(verror2.Convert(verror2.Internal, ctx, err))
+		}
+	} else {
+		formattedRoots = args.Roots
 	}
 
-	if err := ns.SetRoots(wsRoots...); err != nil {
+	if err := ns.SetRoots(formattedRoots...); err != nil {
 		w.Error(verror2.Convert(verror2.Internal, ctx, err))
 		return
 	}