Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
fix(experiment): Disable A/B experiment interface for navigator.webdr…
Browse files Browse the repository at this point in the history
…iver r=@rfk

Fixes #6026
  • Loading branch information
vladikoff committed Apr 10, 2018
1 parent a5ab837 commit 203858b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/scripts/lib/experiment.js
Expand Up @@ -63,8 +63,9 @@ define(function (require, exports, module) {
this.user = options.user;

const agent = this.window.navigator.userAgent;
const isWebDriver = this.window.navigator.webdriver;
// if this is running in functional test mode then we do not want any unpredictable experiments
if (agent.indexOf(UA_OVERRIDE) >= 0 && ! this.forceExperiment) {
if ((isWebDriver || agent.indexOf(UA_OVERRIDE) >= 0) && ! this.forceExperiment) {
this.initialized = false;
return;
}
Expand Down
11 changes: 11 additions & 0 deletions app/tests/spec/lib/experiment.js
Expand Up @@ -70,6 +70,17 @@ define(function (require, exports, module) {
assert.equal(expInt3.forceExperiment, 'something');
assert.isTrue(expInt3.initialized, 'forceExperiment overrides user agent');
});

it('supports webdriver override', () => {
expOptions.window.navigator.webdriver = true;
const expInt = new ExperimentInterface(expOptions);
assert.isFalse(expInt.initialized, 'do not init if webdriver override');

expOptions.window.location.search = 'forceExperiment=something';
const expInt2 = new ExperimentInterface(expOptions);
assert.equal(expInt2.forceExperiment, 'something');
assert.isTrue(expInt2.initialized, 'forceExperiment overrides user agent');
});
});

describe('createExperiment', () => {
Expand Down

0 comments on commit 203858b

Please sign in to comment.