From 5d165a1661694b570b270201da664b6cd98b49ca Mon Sep 17 00:00:00 2001 From: Jonathan Rubstein Date: Thu, 7 Aug 2014 15:30:44 -0700 Subject: [PATCH 1/3] Fix windows based paths. --- lib/blizzard/index.js | 4 ---- lib/hub/batch.js | 3 ++- lib/hub/index.js | 3 +-- lib/hub/null-test.js | 3 ++- lib/hub/test.js | 7 ++++--- lib/hub/tests.js | 6 +++--- lib/hub/url-builder.js | 12 +++++++----- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/blizzard/index.js b/lib/blizzard/index.js index a0c6a7dd..d90fbcf9 100644 --- a/lib/blizzard/index.js +++ b/lib/blizzard/index.js @@ -73,7 +73,6 @@ Blizzard.prototype.createSession = function (socket, instigator) { * @protected */ Blizzard.prototype.onClientUpgrade = function (cb, req, socket) { - //this.emit("connect", socket); cb(null, this.createSession(socket, true)); }; @@ -85,9 +84,6 @@ Blizzard.prototype.onClientUpgrade = function (cb, req, socket) { * @protected */ Blizzard.prototype.serverUpgrade = function (req, socket) { - // console.log("Recieved upgrade."); - // console.log("Headers =", req.headers); - var self = this, version = req.headers["sec-blizzard-version"]; diff --git a/lib/hub/batch.js b/lib/hub/batch.js index 180cc3be..a4e68f72 100644 --- a/lib/hub/batch.js +++ b/lib/hub/batch.js @@ -9,6 +9,7 @@ var TestSpecification = require("./test-specification"); var TestServer = require("./http/test-server"); var WebDriverCollection = require("./webdriver-collection"); +var path = require('path'); /** * A Batch represents a collection of tests on the Hub. @@ -319,7 +320,7 @@ Batch.prototype.handleFileRequest = function (server, agentId, filename) { } fileInBatch = batch.spec.tests.some(function (test) { - return test === filename; + return path.normalize(test) === path.normalize(filename); }); this.getFile(filename, function (err, buffer) { diff --git a/lib/hub/index.js b/lib/hub/index.js index bb16d46e..b2f9366b 100644 --- a/lib/hub/index.js +++ b/lib/hub/index.js @@ -97,7 +97,7 @@ var Hub = module.exports = function Hub(options) { this._setupEvents(); - this.mountpoint = "/"; + this.mountpoint = '/'; this.webdriver = options.webdriver; }; @@ -271,7 +271,6 @@ Hub.prototype._onTowerConnection = function (socket) { client.on("register", function (message) { var id = message.agentId; - if (!id || id === "undefined") { client.emit("error", "ID required"); } diff --git a/lib/hub/null-test.js b/lib/hub/null-test.js index 83741867..5e657dba 100644 --- a/lib/hub/null-test.js +++ b/lib/hub/null-test.js @@ -7,6 +7,7 @@ var util = require("util"); var Test = require("./test"); +var path = require('path'); /** * NullTest represents the absence of a Test. @@ -34,7 +35,7 @@ util.inherits(NullTest, Test); * @return {String} Relative URL for the capture page, relative to the mountpoint. */ NullTest.prototype.getUrlForAgentId = function (agentId) { - return this.mountpoint + "agent/" + agentId; + return this.mountpoint + "agent" + path.sep + agentId; }; /** diff --git a/lib/hub/test.js b/lib/hub/test.js index b8154735..40cda0b6 100644 --- a/lib/hub/test.js +++ b/lib/hub/test.js @@ -1,5 +1,6 @@ "use strict"; +var path = require('path'); /** * @module test */ @@ -34,9 +35,9 @@ function Test(options) { */ Test.prototype.getUrlForAgentId = function (agentId) { var url = this.mountpoint; - url += "agent/" + agentId; - url += "/batch/" + this.batchId; - url += "/test/" + this.location; + url += "agent" + path.sep + agentId; + url += path.sep + "batch" + path.sep + this.batchId; + url += path.sep + "test" + path.sep + this.location; if (this.query) { url += "?" + this.query; } return url; }; diff --git a/lib/hub/tests.js b/lib/hub/tests.js index 823c347b..dd0f8218 100644 --- a/lib/hub/tests.js +++ b/lib/hub/tests.js @@ -7,6 +7,7 @@ var Test = require("./test"); var LiteralTest = require("./literal-test"); var NullTest = require("./null-test"); +var path = require('path'); /** * Tests represent a collection of Test objects. @@ -47,9 +48,9 @@ Tests.prototype.getByUrl = function (url) { location; for (; index < length; index += 1) { - location = locations[index]; + location = path.normalize(locations[index]); - if (url.indexOf(location) !== -1) { + if (path.normalize(url).indexOf(location) !== -1) { return this.children[location]; } } @@ -114,7 +115,6 @@ Tests.prototype.initializeFromSpecification = function (spec) { options.query = spec.query; options.mountpoint = self.mountpoint; } - self.children[location] = new TestCtor(options); }); }; diff --git a/lib/hub/url-builder.js b/lib/hub/url-builder.js index e58032fe..c94b4b9a 100644 --- a/lib/hub/url-builder.js +++ b/lib/hub/url-builder.js @@ -1,20 +1,22 @@ "use strict"; +var path = require('path'); + module.exports = function makeURLFromComponents(mountpoint, agentId, batchId, test) { var url = mountpoint; - if (url !== "/") { + if (url !== path.sep) { // XXX So hacky. - url += "/"; + url += path.sep; } - url += "agent/" + agentId; + url += "agent" + path.sep + agentId; if (test && batchId) { // XXX if test is true, // batchId should always be set - url += "/batch/" + batchId; - url += "/test/" + test; + url += path.sep + "batch" + path.sep + batchId; + url += path.sep + "test" + path.sep + test; } return url; From 5817cdbc899321c9890892f3b42389e7fa22d02f Mon Sep 17 00:00:00 2001 From: "jonathan.rubstein" Date: Wed, 13 Aug 2014 12:29:52 -0700 Subject: [PATCH 2/3] Actions from code review --- lib/hub/batch.js | 2 +- lib/hub/index.js | 2 +- lib/hub/null-test.js | 2 +- lib/hub/test.js | 2 +- lib/hub/url-builder.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/hub/batch.js b/lib/hub/batch.js index a4e68f72..f84bb8fc 100644 --- a/lib/hub/batch.js +++ b/lib/hub/batch.js @@ -9,7 +9,7 @@ var TestSpecification = require("./test-specification"); var TestServer = require("./http/test-server"); var WebDriverCollection = require("./webdriver-collection"); -var path = require('path'); +var path = require("path"); /** * A Batch represents a collection of tests on the Hub. diff --git a/lib/hub/index.js b/lib/hub/index.js index b2f9366b..83fa60ec 100644 --- a/lib/hub/index.js +++ b/lib/hub/index.js @@ -97,7 +97,7 @@ var Hub = module.exports = function Hub(options) { this._setupEvents(); - this.mountpoint = '/'; + this.mountpoint = "/"; this.webdriver = options.webdriver; }; diff --git a/lib/hub/null-test.js b/lib/hub/null-test.js index 5e657dba..0b65807c 100644 --- a/lib/hub/null-test.js +++ b/lib/hub/null-test.js @@ -7,7 +7,7 @@ var util = require("util"); var Test = require("./test"); -var path = require('path'); +var path = require("path"); /** * NullTest represents the absence of a Test. diff --git a/lib/hub/test.js b/lib/hub/test.js index 40cda0b6..452d49eb 100644 --- a/lib/hub/test.js +++ b/lib/hub/test.js @@ -1,6 +1,6 @@ "use strict"; -var path = require('path'); +var path = require("path"); /** * @module test */ diff --git a/lib/hub/url-builder.js b/lib/hub/url-builder.js index c94b4b9a..5241818a 100644 --- a/lib/hub/url-builder.js +++ b/lib/hub/url-builder.js @@ -1,6 +1,6 @@ "use strict"; -var path = require('path'); +var path = require("path"); module.exports = function makeURLFromComponents(mountpoint, agentId, batchId, test) { var url = mountpoint; From be17fc55e3339afe84b8723e6f9f3768c54219c1 Mon Sep 17 00:00:00 2001 From: "jonathan.rubstein" Date: Wed, 13 Aug 2014 12:34:32 -0700 Subject: [PATCH 3/3] Change single quotes for double quotes in tests.js --- lib/hub/tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hub/tests.js b/lib/hub/tests.js index dd0f8218..48030dce 100644 --- a/lib/hub/tests.js +++ b/lib/hub/tests.js @@ -7,7 +7,7 @@ var Test = require("./test"); var LiteralTest = require("./literal-test"); var NullTest = require("./null-test"); -var path = require('path'); +var path = require("path"); /** * Tests represent a collection of Test objects.