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

Commit 0b0c224

Browse files
authored
fix(plugins): do not force ManagedPromise in plugins.ts (#4036)
1 parent 0cd156d commit 0b0c224

File tree

5 files changed

+46
-3
lines changed

5 files changed

+46
-3
lines changed

lib/browser.ts

-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
359359
this.ignoreSynchronization = false;
360360
this.getPageTimeout = DEFAULT_GET_PAGE_TIMEOUT;
361361
this.params = {};
362-
this.plugins_ = new Plugins({});
363362
this.resetUrl = DEFAULT_RESET_URL;
364363
this.debugHelper = new DebugHelper(this);
365364

lib/plugins.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as webdriver from 'selenium-webdriver';
44
import {Config} from './config';
55
import {ConfigParser} from './configParser';
66
import {Logger} from './logger';
7+
import {protractor} from './ptor';
78

89
let logger = new Logger('plugins');
910

@@ -457,8 +458,13 @@ export class Plugins {
457458
logError(e);
458459
}
459460
};
460-
return promiseType == PromiseType.Q ? q.Promise(resolver) :
461-
new webdriver.promise.Promise(resolver);
461+
if (promiseType == PromiseType.Q) {
462+
return q.Promise(resolver);
463+
} else if (protractor.browser.controlFlowIsEnabled()) {
464+
return new webdriver.promise.Promise(resolver);
465+
} else {
466+
return new Promise(resolver);
467+
}
462468
}
463469

464470
/**

scripts/test.js

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var passingTests = [
3939
'node built/cli.js spec/angular2Conf.js',
4040
'node built/cli.js spec/hybridConf.js',
4141
'node built/cli.js spec/built/noCFSmokeConf.js',
42+
'node built/cli.js spec/built/noCFPluginConf.js',
4243
'node scripts/driverProviderAttachSession.js',
4344
'node scripts/errorTest.js',
4445
// Interactive Element Explorer tasks

spec/ts/noCF/plugin_spec.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {browser, protractor} from '../../..';
2+
3+
describe('category', function() {
4+
it('name', async function() {
5+
await browser.get('index.html');
6+
await expect((protractor as any).ON_PAGE_LOAD).toBe(true);
7+
});
8+
});

spec/ts/noCFPluginConf.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import * as q from 'q';
2+
import {Config, protractor} from '../..';
3+
const env = require('../environment.js');
4+
5+
export let config: Config = {
6+
seleniumAddress: env.seleniumAddress,
7+
8+
framework: 'jasmine',
9+
10+
specs: [
11+
'noCF/plugin_spec.js'
12+
],
13+
14+
capabilities: env.capabilities,
15+
16+
baseUrl: env.baseUrl + '/ng1/',
17+
18+
plugins: [{
19+
inline: {
20+
onPageLoad: function() {
21+
return q.delay(100).then(function() {
22+
(protractor as any).ON_PAGE_LOAD = true;
23+
});
24+
}
25+
}
26+
}],
27+
28+
SELENIUM_PROMISE_MANAGER: false
29+
};

0 commit comments

Comments
 (0)