Skip to content

Commit e028932

Browse files
committedSep 12, 2014
JS: Address flakiness with setting copying a Firefox profile
The third-party package used to copy a template Firefox profile would somtimes fail to copy all of the files in a directory. This would yield an incomplete profile causing the FirefoxDriver to fail to initialize properly (up to 10% failrue rate on OS X 10.9.4 with node 0.10.x). This change removes the problematic dependency infavor of a simple, synchronous, recursive copy. At some point I will revisit this change to support fully asynchronous copying.
1 parent 1ad5929 commit e028932

File tree

3 files changed

+37
-26
lines changed

3 files changed

+37
-26
lines changed
 

Diff for: ‎javascript/node/selenium-webdriver/CHANGES.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v2.43.1
2+
3+
* Fixed an issue with flakiness when setting up the Firefox profile that could
4+
prevent the driver from initializing properly.
5+
16
## v2.43.0
27

38
* Added native support for Firefox - the Java Selenium server is no longer

Diff for: ‎javascript/node/selenium-webdriver/io/index.js

+31-24
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// limitations under the License.
1515

1616
var fs = require('fs'),
17-
ncp = require('ncp').ncp,
1817
path = require('path'),
1918
tmp = require('tmp');
2019

@@ -24,25 +23,6 @@ var promise = require('..').promise;
2423
var PATH_SEPARATOR = process.platform === 'win32' ? ';' : ':';
2524

2625

27-
/**
28-
* Creates the specified directory and any necessary parent directories. No
29-
* action is taken if the directory already exists.
30-
* @param {string} dir The directory to create.
31-
* @param {function(Error)} callback Callback function; accepts a single error
32-
* or {@code null}.
33-
*/
34-
function createDirectories(dir, callback) {
35-
fs.mkdir(dir, function(err) {
36-
if (!err || err.code === 'EEXIST') {
37-
callback();
38-
} else {
39-
createDirectories(path.dirname(dir), function(err) {
40-
err && callback(err) || fs.mkdir(dir, callback);
41-
});
42-
}
43-
});
44-
};
45-
4626
// PUBLIC API
4727

4828

@@ -89,11 +69,38 @@ exports.copyDir = function(src, dst, opt_exclude) {
8969
};
9070
}
9171

92-
var copied = promise.defer();
93-
ncp(src, dst, {filter: predicate}, function(err) {
94-
err && copied.reject(err) || copied.fulfill(dst);
72+
// TODO(jleyba): Make this function completely async.
73+
if (!fs.existsSync(dst)) {
74+
fs.mkdirSync(dst);
75+
}
76+
77+
var files = fs.readdirSync(src);
78+
files = files.map(function(file) {
79+
return path.join(src, file);
80+
});
81+
82+
if (predicate) {
83+
files = files.filter(predicate);
84+
}
85+
86+
var results = [];
87+
files.forEach(function(file) {
88+
var stats = fs.statSync(file);
89+
var target = path.join(dst, path.basename(file));
90+
91+
if (stats.isDirectory()) {
92+
if (!fs.existsSync(target)) {
93+
fs.mkdirSync(target, stats.mode);
94+
}
95+
results.push(exports.copyDir(file, target, predicate));
96+
} else {
97+
results.push(exports.copy(file, target));
98+
}
99+
});
100+
101+
return promise.all(results).then(function() {
102+
return dst;
95103
});
96-
return copied.promise;
97104
};
98105

99106

Diff for: ‎javascript/node/selenium-webdriver/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "selenium-webdriver",
3-
"version": "2.43.0",
3+
"version": "2.43.1",
44
"description": "The official WebDriver JavaScript bindings from the Selenium project",
55
"keywords": [
66
"automation",
@@ -23,7 +23,6 @@
2323
},
2424
"dependencies": {
2525
"adm-zip": "0.4.4",
26-
"ncp": "0.6.0",
2726
"tmp": "0.0.24",
2827
"xml2js": "0.4.4"
2928
},

0 commit comments

Comments
 (0)
Please sign in to comment.