@@ -49,6 +49,31 @@ Dispatcher.notImplemented = function(request, response) {
49
49
} ;
50
50
51
51
52
+ /**
53
+ * Execute a command
54
+ * @param {Request } request The request to respond to.
55
+ * @param {Response } response Class used to send the response.
56
+ */
57
+ Dispatcher . prototype . execute_v1 = function ( request , response ) {
58
+ var callback = function ( jsonResponseString ) {
59
+ var jsonResponse = JSON . parse ( jsonResponseString ) ;
60
+ // Going to need more granularity here I think.
61
+ if ( jsonResponse . status != bot . ErrorCode . SUCCESS ) {
62
+ response . setStatus ( Response . INTERNAL_ERROR ) ;
63
+ }
64
+
65
+ response . setContentType ( 'application/json' ) ;
66
+ response . setBody ( jsonResponseString ) ;
67
+ response . commit ( ) ;
68
+ } ;
69
+
70
+ // Dispatch the command.
71
+ Components . classes [ '@googlecode.com/webdriver/command-processor;1' ] .
72
+ getService ( Components . interfaces . nsICommandProcessor ) .
73
+ execute ( request . getBody ( ) , callback ) ;
74
+ } ;
75
+
76
+
52
77
/**
53
78
* Returns a function that translates a WebDriver HTTP request to a legacy
54
79
* command.
@@ -261,11 +286,11 @@ Dispatcher.prototype.init_ = function() {
261
286
this . bind_ ( '/session/:sessionId/element/:id/click' ) .
262
287
on ( Request . Method . POST , Dispatcher . executeAs ( 'clickElement' ) ) ;
263
288
this . bind_ ( '/session/:sessionId/moveto' ) .
264
- on ( Request . Method . POST , Dispatcher . executeAs ( 'mouseMove ' ) ) ;
289
+ on ( Request . Method . POST , Dispatcher . executeAs ( 'mouseMoveTo ' ) ) ;
265
290
this . bind_ ( '/session/:sessionId/buttondown' ) .
266
- on ( Request . Method . POST , Dispatcher . executeAs ( 'mouseDown ' ) ) ;
291
+ on ( Request . Method . POST , Dispatcher . executeAs ( 'mouseButtonDown ' ) ) ;
267
292
this . bind_ ( '/session/:sessionId/buttonup' ) .
268
- on ( Request . Method . POST , Dispatcher . executeAs ( 'mouseUp ' ) ) ;
293
+ on ( Request . Method . POST , Dispatcher . executeAs ( 'mouseButtonUp ' ) ) ;
269
294
this . bind_ ( '/session/:sessionId/click' ) .
270
295
on ( Request . Method . POST , Dispatcher . executeAs ( 'mouseClick' ) ) ;
271
296
this . bind_ ( '/session/:sessionId/doubleclick' ) .
@@ -308,6 +333,17 @@ Dispatcher.prototype.bind_ = function(path) {
308
333
} ;
309
334
310
335
336
+ /**
337
+ * Dispatches a request to the appropriately registered handler.
338
+ * @param {Request } request The request to dispatch.
339
+ * @param {Response } response The request response.
340
+ */
341
+ Dispatcher . prototype . dispatch_v1 = function ( request , response ) {
342
+ var path = request . getPathInfo ( ) ;
343
+ request . setServletPath ( '/v1' ) ;
344
+ this . execute_v1 ( request , response ) ;
345
+ } ;
346
+
311
347
312
348
/**
313
349
* Dispatches a request to the appropriately registered handler.
0 commit comments