Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ AoG: Add amp-viewer-assistance extension. #20725

Merged
merged 14 commits into from Feb 21, 2019

Conversation

hellokoji
Copy link
Contributor

Implements the amp-viewer-assistance extension proposed in Issue (#15195).

The new extension creates a messaging channel between AMP pages and AMP viewers to optimize for flows between the embedded page and the external viewer.

cc @choumx

Change-Id: I78dac3ec9f85c3bbd1ceb4ce88a61b3f7d0dc539
Change-Id: I874c096e75e9428872b6609df4acb75a82ee5b09
@dreamofabear dreamofabear self-requested a review February 7, 2019 22:22
Change-Id: I6692ccec7eaccfce9227115c1ebca24b3a5fe118
Change-Id: I3d282f2571cc48e388ddd222676a23ed0d61b67b
Change-Id: I5335d7d63843800a88319d760504fef7caab4d4f
Change-Id: If066222b53ed7912140c1e526e231aca43d9a38c
# amp-viewer-assistance

The amp-viewer-assistance element provides specification of AMP viewer
configuration information and invocation of AMP viewer assisted behavior.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation needs some love. :)

We ought to:

  1. Clearly describe the high-level product use case. E.g. this is meant for "assistive behaviors on AMP pages, facilitated by the viewer."
  2. Document AMP page/viewer API contract e.g. "requestSignIn".
  3. Document element actions like "signIn" and "updateActionState".
  4. Follow the format from other extension documentation (see amp-access.md).

/cc @CrystalOnScript

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! More documentation will be committed to this PR soon.

P.S. That is a very nice way of requesting for more documentation! 👍 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just updated the documentation to address some of those comments.

}
return this.viewer_.isTrustedViewer().then(isTrustedViewer => {
if (!isTrustedViewer &&
!isExperimentOn(this.ampdoc_.win, 'amp-viewer-assistance-untrusted')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intended to be enabled eventually?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the experiment was our method of forgoing the trusted viewer check with testing locally since local viewers are inherently not trusted.

If there are other ways of accomplishing the same effect, we are open to suggestions.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, we usually use getMode().localDev for this. It returns true when compiling with --fortesting flag, e.g. gulp dist --extensions=amp-viewer-assistance --fortesting.

Though if you don't do testing with a locally-build AMP runtime, then you'd need local proxy software like Charles to replace the CDN-fetched JS with your local version. Is that the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is specifically for developing/testing with a local viewer using a remote (or local) runtime. Does that make sense?

src/url.js Show resolved Hide resolved
Change-Id: I1c06c45a2159fcb5286db2a36e168907073a77fa
Change-Id: I9031cc6930c18de3ca691f41274f868670b72c7a
@hellokoji
Copy link
Contributor Author

Friendly ping.

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

Googlers can find more info about SignCLA and this PR by following this link.

Change-Id: I5c3194a511b64321500025e59375f618ed4660a4
@googlebot
Copy link

CLAs look good, thanks!

Googlers can find more info about SignCLA and this PR by following this link.

Copy link
Contributor

@honeybadgerdontcare honeybadgerdontcare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, from validation looks fine. @choumx for other changes which still need approval

Copy link

@dreamofabear dreamofabear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Just one comment and a couple questions.

}
return this.viewer_.isTrustedViewer().then(isTrustedViewer => {
if (!isTrustedViewer &&
!isExperimentOn(this.ampdoc_.win, 'amp-viewer-assistance-untrusted')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, we usually use getMode().localDev for this. It returns true when compiling with --fortesting flag, e.g. gulp dist --extensions=amp-viewer-assistance --fortesting.

Though if you don't do testing with a locally-build AMP runtime, then you'd need local proxy software like Charles to replace the CDN-fetched JS with your local version. Is that the case?

src/url.js Show resolved Hide resolved
tools/experiments/experiments.js Outdated Show resolved Hide resolved
Change-Id: Ib20566f920d3c92da648d49dc7dd30fc78eb313f
Change-Id: If962d4a174593b2eed997acfbc01844c0a3b0f72
Change-Id: Icaf921248e6f5f7f096c43cde4688d28f4943545
Change-Id: I65dfc764cb7a1a226b6aac444392f5936b21478d
Change-Id: I78849d7d82c98d3353b2a9ad5a1ed99d5c04e2d4
* @return {?Promise}
* @private
*/
actionHandler_(invocation) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry didn't catch this earlier. You should actually use this.registerAction() here instead. See base-element.js#registerAction.

Then you can also remove the whitelisting in presubmit-checks.js.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed offline, we are following the pattern set by amp-access to justify using our own action handler since we are using a <script> tag instead of an <amp-viewer-assistance> element.

@dreamofabear dreamofabear merged commit 518a6b0 into ampproject:master Feb 21, 2019
@hellokoji hellokoji deleted the amp-viewer-assistance branch February 21, 2019 23:42
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Mar 22, 2019
* Add amp-viewer-assistance extension (ampproject#15195).

Change-Id: I78dac3ec9f85c3bbd1ceb4ce88a61b3f7d0dc539

* Address PR comments 1.

Change-Id: I874c096e75e9428872b6609df4acb75a82ee5b09

* remove amp-viewer-integration styles

Change-Id: I6692ccec7eaccfce9227115c1ebca24b3a5fe118

* Fix javascript closure typing.

Change-Id: I3d282f2571cc48e388ddd222676a23ed0d61b67b

* Add copyright and license comments to amp-viewer-assistance files.

Change-Id: I5335d7d63843800a88319d760504fef7caab4d4f

* Remove newline.

Change-Id: If066222b53ed7912140c1e526e231aca43d9a38c

* Address PR comments 2.

Change-Id: I1c06c45a2159fcb5286db2a36e168907073a77fa

* Update amp-viewer-assistance documentation.

Change-Id: I9031cc6930c18de3ca691f41274f868670b72c7a

* Remove redundant amp-viewer-assistnace validator files.

Change-Id: I5c3194a511b64321500025e59375f618ed4660a4

* Remove amp-viewer-assistance-unstrusted experiement from experiments.js.

Change-Id: Ib20566f920d3c92da648d49dc7dd30fc78eb313f

* Address amp-viewer-assistance presubmit errors.

Change-Id: If962d4a174593b2eed997acfbc01844c0a3b0f72

* Lint.

Change-Id: Icaf921248e6f5f7f096c43cde4688d28f4943545

* Fix types.

Change-Id: I65dfc764cb7a1a226b6aac444392f5936b21478d

* Add expectAsyncConsoleError to catch error message in test.

Change-Id: I78849d7d82c98d3353b2a9ad5a1ed99d5c04e2d4
bramanudom pushed a commit to bramanudom/amphtml that referenced this pull request Mar 22, 2019
* Add amp-viewer-assistance extension (ampproject#15195).

Change-Id: I78dac3ec9f85c3bbd1ceb4ce88a61b3f7d0dc539

* Address PR comments 1.

Change-Id: I874c096e75e9428872b6609df4acb75a82ee5b09

* remove amp-viewer-integration styles

Change-Id: I6692ccec7eaccfce9227115c1ebca24b3a5fe118

* Fix javascript closure typing.

Change-Id: I3d282f2571cc48e388ddd222676a23ed0d61b67b

* Add copyright and license comments to amp-viewer-assistance files.

Change-Id: I5335d7d63843800a88319d760504fef7caab4d4f

* Remove newline.

Change-Id: If066222b53ed7912140c1e526e231aca43d9a38c

* Address PR comments 2.

Change-Id: I1c06c45a2159fcb5286db2a36e168907073a77fa

* Update amp-viewer-assistance documentation.

Change-Id: I9031cc6930c18de3ca691f41274f868670b72c7a

* Remove redundant amp-viewer-assistnace validator files.

Change-Id: I5c3194a511b64321500025e59375f618ed4660a4

* Remove amp-viewer-assistance-unstrusted experiement from experiments.js.

Change-Id: Ib20566f920d3c92da648d49dc7dd30fc78eb313f

* Address amp-viewer-assistance presubmit errors.

Change-Id: If962d4a174593b2eed997acfbc01844c0a3b0f72

* Lint.

Change-Id: Icaf921248e6f5f7f096c43cde4688d28f4943545

* Fix types.

Change-Id: I65dfc764cb7a1a226b6aac444392f5936b21478d

* Add expectAsyncConsoleError to catch error message in test.

Change-Id: I78849d7d82c98d3353b2a9ad5a1ed99d5c04e2d4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants