Skip to content

Commit b8452b0

Browse files
committed
Merge branch 'master' into canary
2 parents 8c2d252 + f0b1ccb commit b8452b0

File tree

20 files changed

+231
-117
lines changed

20 files changed

+231
-117
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ script:
2727
- gulp test
2828
# Integration tests with all saucelabs browsers
2929
- gulp test --saucelabs --integration
30+
- gulp test --saucelabs --integration --compiled
3031
# All unit tests with an old chrome (best we can do right now to pass tests
3132
# and not start relying on new features).
3233
- gulp test --saucelabs --oldchrome

3p/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ We highly prefer integrations that do not use iframes. JSONP cannot be used for
1111
Examples: Youtube, Vimeo videos; Tweets, Instagrams; comment systems; polls; quizzes; document viewers
1212

1313
- Our intent is to provide first class support for all embeds that fulfill the notability guidelines laid out in [CONTRIBUTING.md](../CONTRIBUTING.md).
14-
- Consider whether a click-to-play solution fits your use case where iframe generation is not done immediately (can be done before user action for instant loading of iframe).
14+
- Consider whether a iframe-with-placeholder solution fits your use case where iframe generation is not done immediately (can be done before user action for instant loading of iframe).
1515
- Consider whether all that is needed is some documentation for how to use the embed with `amp-iframe`.
1616
- Iframes and all sub resources must be served from HTTPS.
1717
- Avoid client side rendering of iframe content.

build-system/config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ var karma = {
6161
configFile: karmaConf,
6262
singleRun: true,
6363
client: {
64-
captureConsole: false
64+
captureConsole: false,
65+
amp: {
66+
useCompiledJs: false
67+
}
6568
}
6669
},
6770
firefox: {

build-system/tasks/presubmit-checks.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ var forbiddenTerms = {
133133
'setCookie\\W': {
134134
message: requiresReviewPrivacy,
135135
whitelist: [
136+
'src/service/cid-impl.js',
136137
'src/cookies.js',
137138
'src/experiments.js',
138139
'tools/experiments/experiments.js',

build-system/tasks/test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ gulp.task('test', 'Runs tests in chrome', ['build'], function(done) {
8484
c.files = config.testPaths;
8585
}
8686

87+
if (argv.compiled) {
88+
if (!argv.integration) {
89+
throw new Error('Compiled tests are only supported for integration tests');
90+
}
91+
c.client.amp.useCompiledJs = true;
92+
}
93+
8794
karma.start(c, done);
8895
}, {
8996
options: {
@@ -93,6 +100,8 @@ gulp.task('test', 'Runs tests in chrome', ['build'], function(done) {
93100
'safari': ' Runs tests in Safari',
94101
'firefox': ' Runs tests in Firefox',
95102
'integration': 'Run only integration tests.',
103+
'compiled': 'Changes integration tests to use production JS ' +
104+
'binaries for execution',
96105
'oldchrome': 'Runs test with an old chrome. Saucelabs only.',
97106
}
98107
});

docs/include_features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Display an iframe in your page using the
1414

1515
`amp-iframe` requirements:
1616

17-
* Must be at least 600px or 75% of the first viewport away from the top (except for `click-to-play` iframes as described below).
17+
* Must be at least 600px or 75% of the first viewport away from the top (except for iframes implemented with a placeholder, as described below).
1818
* Can only request resources via HTTPS, and they must not be in the same origin as the container,
1919
unless they do not specify allow-same-origin.
2020

extensions/amp-access/0.1/amp-access.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ export class AccessService {
239239
// No consent - an essential part of the access system.
240240
const consent = Promise.resolve();
241241
this.readerIdPromise_ = this.cid_.then(cid => {
242-
return cid.get('amp-access', consent);
242+
return cid.get({scope: 'amp-access', createCookieIfNotPresent: true},
243+
consent);
243244
});
244245
}
245246
return this.readerIdPromise_;

extensions/amp-access/0.1/test/test-amp-access.js

Lines changed: 35 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -260,30 +260,17 @@ describe('AccessService authorization', () => {
260260
sandbox = null;
261261
});
262262

263-
it('should run authorization flow', () => {
263+
function expectGetReaderId(result) {
264264
cidMock.expects('get')
265-
.withExactArgs('amp-access', sinon.match(() => true))
266-
.returns(Promise.resolve('reader1'))
267-
.once();
268-
xhrMock.expects('fetchJson')
269-
.withExactArgs('https://acme.com/a?rid=reader1',
270-
{credentials: 'include'})
271-
.returns(Promise.resolve({access: true}))
265+
.withExactArgs(
266+
{scope: 'amp-access', createCookieIfNotPresent: true},
267+
sinon.match(() => true))
268+
.returns(Promise.resolve(result))
272269
.once();
273-
const promise = service.runAuthorization_();
274-
expect(document.documentElement).to.have.class('amp-access-loading');
275-
return promise.then(() => {
276-
expect(document.documentElement).not.to.have.class('amp-access-loading');
277-
expect(elementOn).not.to.have.attribute('amp-access-hide');
278-
expect(elementOff).to.have.attribute('amp-access-hide');
279-
});
280-
});
270+
}
281271

282272
it('should run authorization flow', () => {
283-
cidMock.expects('get')
284-
.withExactArgs('amp-access', sinon.match(() => true))
285-
.returns(Promise.resolve('reader1'))
286-
.once();
273+
expectGetReaderId('reader1');
287274
xhrMock.expects('fetchJson')
288275
.withExactArgs('https://acme.com/a?rid=reader1',
289276
{credentials: 'include'})
@@ -299,10 +286,7 @@ describe('AccessService authorization', () => {
299286
});
300287

301288
it('should recover from authorization failure', () => {
302-
cidMock.expects('get')
303-
.withExactArgs('amp-access', sinon.match(() => true))
304-
.returns(Promise.resolve('reader1'))
305-
.once();
289+
expectGetReaderId('reader1');
306290
xhrMock.expects('fetchJson')
307291
.withExactArgs('https://acme.com/a?rid=reader1',
308292
{credentials: 'include'})
@@ -318,10 +302,7 @@ describe('AccessService authorization', () => {
318302
});
319303

320304
it('should resolve first-authorization promise after success', () => {
321-
cidMock.expects('get')
322-
.withExactArgs('amp-access', sinon.match(() => true))
323-
.returns(Promise.resolve('reader1'))
324-
.once();
305+
expectGetReaderId('reader1');
325306
xhrMock.expects('fetchJson')
326307
.withExactArgs('https://acme.com/a?rid=reader1',
327308
{credentials: 'include'})
@@ -334,10 +315,7 @@ describe('AccessService authorization', () => {
334315
});
335316

336317
it('should NOT resolve first-authorization promise after failure', () => {
337-
cidMock.expects('get')
338-
.withExactArgs('amp-access', sinon.match(() => true))
339-
.returns(Promise.resolve('reader1'))
340-
.once();
318+
expectGetReaderId('reader1');
341319
xhrMock.expects('fetchJson')
342320
.withExactArgs('https://acme.com/a?rid=reader1',
343321
{credentials: 'include'})
@@ -553,6 +531,15 @@ describe('AccessService pingback', () => {
553531
sandbox = null;
554532
});
555533

534+
function expectGetReaderId(result) {
535+
cidMock.expects('get')
536+
.withExactArgs(
537+
{scope: 'amp-access', createCookieIfNotPresent: true},
538+
sinon.match(() => true))
539+
.returns(Promise.resolve(result))
540+
.once();
541+
}
542+
556543
it('should register "viewed" signal after timeout', () => {
557544
service.reportViewToServer_ = sandbox.spy();
558545
const p = service.reportWhenViewed_();
@@ -685,10 +672,7 @@ describe('AccessService pingback', () => {
685672
});
686673

687674
it('should send POST pingback', () => {
688-
cidMock.expects('get')
689-
.withExactArgs('amp-access', sinon.match(() => true))
690-
.returns(Promise.resolve('reader1'))
691-
.once();
675+
expectGetReaderId('reader1');
692676
xhrMock.expects('sendSignal')
693677
.withExactArgs('https://acme.com/p?rid=reader1', sinon.match(init => {
694678
return (init.method == 'POST' &&
@@ -754,24 +738,27 @@ describe('AccessService login', () => {
754738
sandbox = null;
755739
});
756740

741+
function expectGetReaderId(result) {
742+
cidMock.expects('get')
743+
.withExactArgs(
744+
{scope: 'amp-access', createCookieIfNotPresent: true},
745+
sinon.match(() => true))
746+
.returns(Promise.resolve(result))
747+
.once();
748+
}
749+
757750
it('should open dialog in the same microtask', () => {
758751
service.openLoginDialog_ = sandbox.stub();
759752
service.openLoginDialog_.returns(Promise.resolve());
760-
cidMock.expects('get')
761-
.withExactArgs('amp-access', sinon.match(() => true))
762-
.returns(Promise.resolve('reader1'))
763-
.once();
753+
expectGetReaderId('reader1');
764754
service.login();
765755
expect(service.openLoginDialog_.callCount).to.equal(1);
766756
expect(service.openLoginDialog_.firstCall.args[0].then).to.exist;
767757
});
768758

769759
it('should succeed login with success=true', () => {
770760
service.runAuthorization_ = sandbox.spy();
771-
cidMock.expects('get')
772-
.withExactArgs('amp-access', sinon.match(() => true))
773-
.returns(Promise.resolve('reader1'))
774-
.once();
761+
expectGetReaderId('reader1');
775762
let urlPromise = null;
776763
serviceMock.expects('openLoginDialog_')
777764
.withExactArgs(sinon.match(arg => {
@@ -792,10 +779,7 @@ describe('AccessService login', () => {
792779

793780
it('should fail login with success=no', () => {
794781
service.runAuthorization_ = sandbox.spy();
795-
cidMock.expects('get')
796-
.withExactArgs('amp-access', sinon.match(() => true))
797-
.returns(Promise.resolve('reader1'))
798-
.once();
782+
expectGetReaderId('reader1');
799783
serviceMock.expects('openLoginDialog_')
800784
.withExactArgs(sinon.match(arg => !!arg.then))
801785
.returns(Promise.resolve('#success=no'))
@@ -808,10 +792,7 @@ describe('AccessService login', () => {
808792

809793
it('should fail login with empty response', () => {
810794
service.runAuthorization_ = sandbox.spy();
811-
cidMock.expects('get')
812-
.withExactArgs('amp-access', sinon.match(() => true))
813-
.returns(Promise.resolve('reader1'))
814-
.once();
795+
expectGetReaderId('reader1');
815796
serviceMock.expects('openLoginDialog_')
816797
.withExactArgs(sinon.match(arg => !!arg.then))
817798
.returns(Promise.resolve(''))
@@ -824,10 +805,7 @@ describe('AccessService login', () => {
824805

825806
it('should fail login with aborted dialog', () => {
826807
service.runAuthorization_ = sandbox.spy();
827-
cidMock.expects('get')
828-
.withExactArgs('amp-access', sinon.match(() => true))
829-
.returns(Promise.resolve('reader1'))
830-
.once();
808+
expectGetReaderId('reader1');
831809
serviceMock.expects('openLoginDialog_')
832810
.withExactArgs(sinon.match(arg => !!arg.then))
833811
.returns(Promise.reject('abort'))
@@ -841,10 +819,7 @@ describe('AccessService login', () => {
841819

842820
it('should run login only once at a time', () => {
843821
service.runAuthorization_ = sandbox.spy();
844-
cidMock.expects('get')
845-
.withExactArgs('amp-access', sinon.match(() => true))
846-
.returns(Promise.resolve('reader1'))
847-
.once();
822+
expectGetReaderId('reader1');
848823
serviceMock.expects('openLoginDialog_')
849824
.withExactArgs(sinon.match(arg => !!arg.then))
850825
.returns(new Promise(() => {}))

extensions/amp-iframe/amp-iframe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Here are some factors that affect how fast the resize will be executed:
9090
- Whether the resize is requested for a currently active IFrame;
9191
- Whether the resize is requested for an IFrame below the viewport or above the viewport.
9292

93-
#### Iframe Click-To-Play
93+
#### Iframe with Placeholder
9494
It is possible to have an `amp-iframe` appear on the top of a document when the `amp-iframe` has a `placeholder` element as shown in the example below.
9595

9696
```html

gulpfile.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,10 @@ function buildExamples(watch) {
324324
buildExample('user-notification.amp.html');
325325
buildExample('vine.amp.html');
326326

327-
// Examples are also copied into `c/` directory for AMP-proxy testing.
328-
fs.copy('examples.build/', 'c/', {clobber: true},
329-
copyHandler.bind(null, 'examples.build to c folder'));
327+
// TODO(dvoytenko, #1393): Enable for proxy-testing.
328+
// // Examples are also copied into `c/` directory for AMP-proxy testing.
329+
// fs.copy('examples.build/', 'c/', {clobber: true},
330+
// copyHandler.bind(null, 'examples.build to c folder'));
330331

331332
function copyHandler(name, err) {
332333
if (err) {

0 commit comments

Comments
 (0)