Skip to content

Commit

Permalink
fix(restart): preserve waitForAngularEnabled on restart
Browse files Browse the repository at this point in the history
Missed in angular#4037

Also fixed minor (so minor I think it was impossible to trigger) in initializing
plugins.
  • Loading branch information
sjelin committed Feb 1, 2017
1 parent 5899b67 commit e1ea3c3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
20 changes: 12 additions & 8 deletions lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
* tests to become flaky. This should be used only when necessary, such as
* when a page continuously polls an API using $timeout.
*
* Initialized to `false` by the runner.
*
* This property is deprecated - please use waitForAngularEnabled instead.
*
* @deprecated
Expand Down Expand Up @@ -356,7 +358,6 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
this.$$ = build$$(this.element, By);
this.baseUrl = opt_baseUrl || '';
this.angularAppRoot(opt_rootElement || '');
this.ignoreSynchronization = false;
this.getPageTimeout = DEFAULT_GET_PAGE_TIMEOUT;
this.params = {};
this.resetUrl = DEFAULT_RESET_URL;
Expand Down Expand Up @@ -413,15 +414,18 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
* Call waitForAngularEnabled() without passing a value to read the current
* state without changing it.
*/
waitForAngularEnabled(enabled: boolean = null): wdpromise.Promise<boolean> {
waitForAngularEnabled(enabled: boolean|wdpromise.Promise<boolean> = null):
wdpromise.Promise<boolean> {
if (enabled != null) {
const ret = this.driver.controlFlow().execute(() => {
if (this.bpClient) {
logger.debug('Setting waitForAngular' + !enabled);
return this.bpClient.setWaitEnabled(enabled).then(() => {
return enabled;
});
}
return wdpromise.when(enabled).then((enabled: boolean) => {
if (this.bpClient) {
logger.debug('Setting waitForAngular' + !enabled);
return this.bpClient.setWaitEnabled(enabled).then(() => {
return enabled;
});
}
});
}, `Set proxy synchronization enabled to ${enabled}`);
this.internalIgnoreSynchronization = !enabled;
return ret;
Expand Down
9 changes: 5 additions & 4 deletions lib/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ export class Runner extends EventEmitter {
getPageTimeout: config.getPageTimeout,
allScriptsTimeout: config.allScriptsTimeout,
debuggerServerPort: config.debuggerServerPort,
ng12Hybrid: config.ng12Hybrid
ng12Hybrid: config.ng12Hybrid,
waitForAngularEnabled: true as boolean | wdpromise.Promise<boolean>
};

if (parentBrowser) {
Expand All @@ -249,16 +250,16 @@ export class Runner extends EventEmitter {
initProperties.allScriptsTimeout = parentBrowser.allScriptsTimeout;
initProperties.debuggerServerPort = parentBrowser.debuggerServerPort;
initProperties.ng12Hybrid = parentBrowser.ng12Hybrid;
initProperties.waitForAngularEnabled = parentBrowser.waitForAngularEnabled();
}

let browser_ = new ProtractorBrowser(
driver, initProperties.baseUrl, initProperties.rootElement,
initProperties.untrackOutstandingTimeouts, blockingProxyUrl);

browser_.params = initProperties.params;
if (plugins) {
browser_.plugins_ = plugins;
}
browser_.plugins_ = plugins || new Plugins({});
browser_.waitForAngularEnabled(initProperties.waitForAngularEnabled);
if (initProperties.getPageTimeout) {
browser_.getPageTimeout = initProperties.getPageTimeout;
}
Expand Down

0 comments on commit e1ea3c3

Please sign in to comment.