Skip to content

Commit 0a8aa60

Browse files
committed
Implement the W3C "status" endpoint in the firefoxdriver XPI
They say that there's nothing worse than someone trying to be something that they're not. We ignore this advice and will therefore serve this old mutton as fresh lamb.
1 parent d7bdd7c commit 0a8aa60

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

javascript/firefox-driver/js/nsCommandProcessor.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,25 @@ nsCommandProcessor.prototype.getStatus = function(response) {
669669
var xulRuntime = Components.classes['@mozilla.org/xre/app-info;1'].
670670
getService(Components.interfaces.nsIXULRuntime);
671671

672+
var sessionStore = Components.
673+
classes['@googlecode.com/webdriver/wdsessionstoreservice;1'].
674+
getService(Components.interfaces.nsISupports).
675+
wrappedJSObject;
676+
677+
var allSessions = sessionStore.getSessions();
678+
var readyState = false;
679+
var message = '';
680+
if (goog.array.isEmpty(allSessions)) {
681+
readyState = true;
682+
message = 'No currently active sessions';
683+
} else {
684+
readyState = false;
685+
message = 'Currently active sessions: ' + allSessions;
686+
}
687+
672688
response.value = {
689+
'ready': readyState,
690+
'message': message,
673691
'os': {
674692
'arch': (function() {
675693
try {

javascript/firefox-driver/js/sessionstore.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,20 @@ wdSessionStoreService.prototype.getSession = function(sessionId) {
255255
var session = this.sessions_[sessionId].wrappedJSObject; // XPConnect
256256
return this.sessions_[sessionId];
257257
}
258+
throw Components.results.NS_ERROR_NOT_AVAILABLE;
259+
};
260+
261+
262+
/**
263+
* Retrieve all the current active session IDs.
264+
* @returns {!Array.<string>}
265+
*/
266+
wdSessionStoreService.prototype.getSessions = function() {
258267
var sessions = [];
259-
for (var session in this.sessions_) {
260-
sessions.push(session);
268+
for (var sessionId in this.sessions_) {
269+
sessions.push(sessionId);
261270
}
262-
throw Components.results.NS_ERROR_NOT_AVAILABLE;
271+
return sessions;
263272
};
264273

265274

0 commit comments

Comments
 (0)