Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 3b03ab2

Browse files
committed
tests(control-flow): add a test onPrepare to make sure control flow doesn't lock
Closes #1385
1 parent 5a404c2 commit 3b03ab2

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

Diff for: scripts/test.js

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var passingTests = [
2626
'node lib/cli.js spec/directConnectConf.js',
2727
'node lib/cli.js spec/restartBrowserBetweenTestsConf.js',
2828
'node lib/cli.js spec/getCapabilitiesConf.js',
29+
'node lib/cli.js spec/controlLockConf.js',
2930
'node node_modules/.bin/jasmine JASMINE_CONFIG_PATH=scripts/unit_test.json'
3031
];
3132

Diff for: spec/control/spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
describe('protractor control flow', function() {
2+
it('should not deadlock', function() {
3+
browser.driver.wait(function() {
4+
return true;
5+
}, 1000);
6+
expect(true).toEqual(true);
7+
});
8+
});

Diff for: spec/controlLockConf.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
var env = require('./environment.js');
2+
var webdriver = require('selenium-webdriver');
3+
4+
// Tests for cases that have caused WebDriver promise locks in
5+
// the past.
6+
exports.config = {
7+
seleniumAddress: env.seleniumAddress,
8+
9+
framework: 'jasmine2',
10+
11+
specs: [
12+
'control/spec.js',
13+
],
14+
15+
capabilities: env.capabilities,
16+
17+
baseUrl: env.baseUrl,
18+
19+
onPrepare: function() {
20+
21+
// This is a reasonable use case - do some promise that takes some time,
22+
// and then do a wait until something is set up correctly.
23+
return webdriver.promise.delayed(100).then(function() {
24+
// This could also be replaced by an 'execute' to see the same behavior.
25+
return browser.driver.wait(function() {
26+
return true;
27+
}, 10000, 'onPrepare wait');
28+
});
29+
}
30+
};

0 commit comments

Comments
 (0)