Skip to content

Commit

Permalink
fix(plugins): do not force ManagedPromise in plugins.ts (#4036)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjelin committed Jan 31, 2017
1 parent 0cd156d commit 0b0c224
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
1 change: 0 additions & 1 deletion lib/browser.ts
Expand Up @@ -359,7 +359,6 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
this.ignoreSynchronization = false;
this.getPageTimeout = DEFAULT_GET_PAGE_TIMEOUT;
this.params = {};
this.plugins_ = new Plugins({});
this.resetUrl = DEFAULT_RESET_URL;
this.debugHelper = new DebugHelper(this);

Expand Down
10 changes: 8 additions & 2 deletions lib/plugins.ts
Expand Up @@ -4,6 +4,7 @@ import * as webdriver from 'selenium-webdriver';
import {Config} from './config';
import {ConfigParser} from './configParser';
import {Logger} from './logger';
import {protractor} from './ptor';

let logger = new Logger('plugins');

Expand Down Expand Up @@ -457,8 +458,13 @@ export class Plugins {
logError(e);
}
};
return promiseType == PromiseType.Q ? q.Promise(resolver) :
new webdriver.promise.Promise(resolver);
if (promiseType == PromiseType.Q) {
return q.Promise(resolver);
} else if (protractor.browser.controlFlowIsEnabled()) {
return new webdriver.promise.Promise(resolver);
} else {
return new Promise(resolver);
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions scripts/test.js
Expand Up @@ -39,6 +39,7 @@ var passingTests = [
'node built/cli.js spec/angular2Conf.js',
'node built/cli.js spec/hybridConf.js',
'node built/cli.js spec/built/noCFSmokeConf.js',
'node built/cli.js spec/built/noCFPluginConf.js',
'node scripts/driverProviderAttachSession.js',
'node scripts/errorTest.js',
// Interactive Element Explorer tasks
Expand Down
8 changes: 8 additions & 0 deletions spec/ts/noCF/plugin_spec.ts
@@ -0,0 +1,8 @@
import {browser, protractor} from '../../..';

describe('category', function() {
it('name', async function() {
await browser.get('index.html');
await expect((protractor as any).ON_PAGE_LOAD).toBe(true);
});
});
29 changes: 29 additions & 0 deletions spec/ts/noCFPluginConf.ts
@@ -0,0 +1,29 @@
import * as q from 'q';
import {Config, protractor} from '../..';
const env = require('../environment.js');

export let config: Config = {
seleniumAddress: env.seleniumAddress,

framework: 'jasmine',

specs: [
'noCF/plugin_spec.js'
],

capabilities: env.capabilities,

baseUrl: env.baseUrl + '/ng1/',

plugins: [{
inline: {
onPageLoad: function() {
return q.delay(100).then(function() {
(protractor as any).ON_PAGE_LOAD = true;
});
}
}
}],

SELENIUM_PROMISE_MANAGER: false
};

0 comments on commit 0b0c224

Please sign in to comment.