Skip to content

Commit

Permalink
Merge pull request #2694 from jridgewell/remove-dynamic-css-experiment
Browse files Browse the repository at this point in the history
Remove DynamicCssClasses Experiment
  • Loading branch information
jridgewell committed Mar 25, 2016
2 parents adc2993 + 7a166a9 commit 378e5b5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 52 deletions.
16 changes: 2 additions & 14 deletions extensions/amp-dynamic-css-classes/0.1/amp-dynamic-css-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@
*/

import {getService} from '../../../src/service';
import {isExperimentOn} from '../../../src/experiments';
import {user} from '../../../src/log';
import {parseUrl} from '../../../src/url';
import {viewerFor} from '../../../src/viewer';
import {vsyncFor} from '../../../src/vsync';

/** @const */
const TAG = 'AmpDynamicCssClasses';

/** @const */
const EXPERIMENT = 'dynamic-css-classes';

/**
* Strips everything but the domain from referrer string.
* @param {!Window} win
Expand Down Expand Up @@ -143,12 +135,8 @@ function addViewerClass(win) {
* @param {!Window} win
*/
function addRuntimeClasses(win) {
if (isExperimentOn(win, EXPERIMENT)) {
addReferrerClasses(win);
addViewerClass(win);
} else {
user.warn(TAG, `Experiment ${EXPERIMENT} disabled`);
}
addReferrerClasses(win);
addViewerClass(win);
}

/**
Expand Down
39 changes: 10 additions & 29 deletions extensions/amp-dynamic-css-classes/0.1/test/test-runtime-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import {createServedIframe} from '../../../../testing/iframe';
import {toggleExperiment} from '../../../../src/experiments';
import {viewerFor} from '../../../../src/viewer';
import {vsyncFor} from '../../../../src/vsync';

Expand Down Expand Up @@ -45,12 +44,11 @@ describe('dynamic classes are inserted at runtime', () => {
};
}

function setup(enabled, userAgent, referrer) {
function setup(userAgent, referrer) {
return createServedIframe(iframeSrc).then(fixture => {
const win = fixture.win;
documentElement = fixture.doc.documentElement;

toggleExperiment(win, 'dynamic-css-classes', enabled);
mockVsync(win);

if (userAgent !== undefined) {
Expand All @@ -64,48 +62,32 @@ describe('dynamic classes are inserted at runtime', () => {
});
}

describe('when experiment is disabled', () => {
beforeEach(function() {
this.timeout(5000);
return setup(false);
});

it('should not include referrer classes', () => {
expect(documentElement).not.to.have.class('amp-referrer-localhost');
});

it('should not include viewer class', () => {
expect(documentElement).not.to.have.class('amp-viewer');
});
beforeEach(function() {
this.timeout(5000);
});

describe('when experiment is enabled', () => {
beforeEach(function() {
this.timeout(5000);
return setup(true);
});

it('should include referrer classes', () => {
it('should include referrer classes', () => {
return setup().then(() => {
expect(documentElement).to.have.class('amp-referrer-localhost');
});
});

it('should include viewer class', () => {
it('should include viewer class', () => {
return setup().then(() => {
expect(documentElement).to.have.class('amp-viewer');
});
});

describe('Normalizing Referrers', () => {
it('should normalize twitter shortlinks to twitter', function() {
this.timeout(5000);
return setup(true, '', tcoReferrer).then(() => {
return setup('', tcoReferrer).then(() => {
expect(documentElement).to.have.class('amp-referrer-com');
expect(documentElement).to.have.class('amp-referrer-twitter-com');
});
});

it('should normalize pinterest on android', function() {
this.timeout(5000);
return setup(true, PinterestUA, '').then(() => {
return setup(PinterestUA, '').then(() => {
expect(documentElement).to.have.class('amp-referrer-com');
expect(documentElement).to.have.class('amp-referrer-pinterest-com');
expect(documentElement).to.have.class('amp-referrer-www-pinterest-com');
Expand All @@ -114,7 +96,6 @@ describe('dynamic classes are inserted at runtime', () => {
});

it('should delay unhiding the body', function() {
this.timeout(5000);
return createServedIframe(iframeSrc).then(fixture => {
expect(fixture.doc.body).to.be.hidden;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ limitations under the License.
</tr>
<tr>
<td width="40%"><strong>Availability</strong></td>
<td><a href="https://www.ampproject.org/docs/reference/experimental.html">Experimental</a></td>
<td><a href="https://www.ampproject.org/docs/reference/experimental.html">Stable</a></td>
</tr>
<tr>
<td width="40%"><strong>Examples</strong></td>
Expand Down
8 changes: 0 additions & 8 deletions tools/experiments/experiments.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@ const EXPERIMENTS = [
spec: 'https://github.com/ampproject/amphtml/blob/master/' +
'README.md#amp-dev-channel',
},

// Dynamic CSS Classes
{
id: 'dynamic-css-classes',
name: 'Dynamic CSS Classes',
spec: 'https://github.com/ampproject/amphtml/blob/master/extensions/' +
'amp-dynamic-css-classes/amp-dynamic-css-classes.md',
},
];


Expand Down

0 comments on commit 378e5b5

Please sign in to comment.