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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed the dead getViewerUrl function #17404

Merged
merged 5 commits into from Aug 21, 2018

Conversation

torch2424
Copy link
Contributor

@torch2424 torch2424 commented Aug 10, 2018

closes #15425

馃毊 Simply removes the unused function getViewerUrl. This is not used anywhere as mentioned in the issue.

However, this also removes tests found in test/functional/test-viewer.js for this function, which may/may not be desired. Let me know in the comments below.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@googlebot
Copy link

CLAs look good, thanks!

@@ -1499,135 +1499,6 @@ describe('Viewer', () => {
const viewer = new Viewer(ampdoc);
expect(viewer.getResolvedViewerUrl()).to.equal('https://acme.org/doc1');
});

it('should always return current location for top-level window', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd seem some of these tests are still valid...

Copy link
Contributor Author

@torch2424 torch2424 Aug 14, 2018

Choose a reason for hiding this comment

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

Yes, but I figured there may be similar tests for just the viewer.getResolvedViewerUrl(), since these tests appear to mostly be testing viewer.getViewerUrl(). Would you like me to remove calls to viewer.getViewerUrl() and replace with viewer.getResolvedViewerUrl() to get these tests running and valid?

My apologies, I just don't have much context on how/where this feature is used, and how the tests relate to the separate calls.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good question. I think you can just replace isTrustedViewer() in the tests and only test the getResolvedViewerUrl()?

Copy link
Contributor Author

@torch2424 torch2424 Aug 17, 2018

Choose a reason for hiding this comment

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

So Implemented this change in a local commit, and noticed the following code within the this.viewerUrl_ promise: https://github.com/ampproject/amphtml/blob/master/src/service/viewer-impl.js#L425

Meaning, the resolved URL is not updated without calling the promise that is returned by viewer.getViewerUrl() which is simply this.viewerUrl_.

I tried replacing with isTrustedViewer(), but that wont update the this.resolvedViewerUrl_, therefore the tests will break because the viewer url never actually updates.

Perhaps this code is not entirely dead as mentioned in #15425 ? Or we need to update the viewer-impl.js accordingly to update it's resolved url.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. Please consult @lannka if that code is indeed dead. Obviously some part of it is still in use.

* @return {!Promise<string>}
*/
getViewerUrl() {
return this.viewerUrl_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, what about this variable itself? Should it be removed as well?

@torch2424
Copy link
Contributor Author

cc @dvoytenko

After talking with @lannka we came to the conclusion that the code was only used by tests, but were an important part of testing overriding viewer urls. Thus we marked the function as visible for testing. Though, we feel like the file should still be refactored.

@@ -890,7 +891,12 @@ export class Viewer {
isTrustedViewerOrigin_(urlString) {
/** @const {!Location} */
const url = parseUrlDeprecated(urlString);
if (url.protocol != 'https:') {
const {protocol} = url;
Copy link
Contributor

Choose a reason for hiding this comment

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

is this bad merge?

@torch2424
Copy link
Contributor Author

@dvoytenko Whenever you get the chance can you approve and merge this in? It became a 1 line fix in the end. 馃槃

@dvoytenko dvoytenko merged commit 2de9d7a into ampproject:master Aug 21, 2018
@torch2424 torch2424 deleted the getViewerUrl-15425 branch August 22, 2018 00:02
Enriqe pushed a commit to Enriqe/amphtml that referenced this pull request Nov 28, 2018
* Simply removed the dead `getViewerUrl` function

* Removed tests with calls to getViewerUrl

* Marked the getViewerUrl at visible for testing

* Removed som random code that got added by syncing with master

* Removed more random code that got added by the sync
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.

getViewerUrl is it dead?
4 participants