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

Added a var for Viewer. #1894

Merged
merged 1 commit into from
Feb 16, 2016
Merged

Added a var for Viewer. #1894

merged 1 commit into from
Feb 16, 2016

Conversation

avimehta
Copy link
Contributor

This var is returns the hostname found in the 'origin' param of the
viewer or the referrer.

There are a couple of open issues in this PR. Comments and suggestions welcome.

  1. The code currently reads the origin param from the iframe and parses the domain out of it. Should it return the value without any processing instead? That way, apps don't have to pass in a domain or a URL and can instead just pass in a string.
  2. The code returns the referrer information if the origin is not found. I am not sure if that should be done or if it makes sense.

Fixes #1493

@@ -29,6 +29,9 @@ import {userNotificationManagerFor} from './user-notification';
/** @private {string} */
const TAG_ = 'UrlReplacements';

/** @private {string} */
const VIEWPORT_ORIGIN_PARAM_ = 'origin';
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be "VIEWER", not a "VIEWPORT"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@avimehta
Copy link
Contributor Author

ptal. The test failures seem unrelated. Can't reproduce on my machine. Not sure what is going wrong.

Provides an identifier for the viewer that contains the AMP document. Empty string is provided when the document is loaded directly in the browser or if the id is not found.
For instance:
```html
<amp-pixel src="https://foo.com/pixel?title=VIEWER"></amp-pixel>
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: title=VIEWER -> viewer=VIEWER

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@avimehta
Copy link
Contributor Author

Not sure why @dvoytenko 's commit got involved here. Will try to fix it but this happened in someone else's PR as well today.

@@ -157,6 +164,9 @@ export class Viewer {
/** @private {?string} */
this.messagingOrigin_ = null;

/** @private {?string} */
this.viewerOrigin_ = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove. The definition below is the correct one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@dvoytenko
Copy link
Contributor

Looking good - just a couple more comments.

This var is returns the hostname found in the 'origin' param of the
viewer or the referrer.

Fixes ampproject#1493

Review feedback, lint fixes.

Review feedback.
@dvoytenko
Copy link
Contributor

LGTM. Is this ready to be merged?

@avimehta
Copy link
Contributor Author

Yes sir
On Feb 16, 2016 10:26 AM, "Dima Voytenko" notifications@github.com wrote:

LGTM. Is this ready to be merged?


Reply to this email directly or view it on GitHub
#1894 (comment).

dvoytenko added a commit that referenced this pull request Feb 16, 2016
@dvoytenko dvoytenko merged commit 1bdef7d into ampproject:master Feb 16, 2016
@avimehta avimehta deleted the viewer branch April 16, 2016 21:01
@qidonna qidonna mentioned this pull request Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants