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

Fix Ampcontext variables in singlepass #19987

Merged
merged 3 commits into from Dec 21, 2018
Merged

Conversation

zhouyx
Copy link
Contributor

@zhouyx zhouyx commented Dec 19, 2018

Since ad script within iframe can access the variables, I believe we should add the vars to externs.
Let me know if this is the correct fix.

One thing that confuses me is that does it mean we should add every var and method from ampcontext.js to the extern list.

to @erwinmombay @lannka

Closes #20002

@lannka
Copy link
Contributor

lannka commented Dec 19, 2018

this could be caught by a skipped test #16825

@lannka
Copy link
Contributor

lannka commented Dec 19, 2018

pls hold this PR for the test unmute: #16828
so that we can catch all of them in one shot.

@lannka
Copy link
Contributor

lannka commented Dec 20, 2018

FYI, the blocking PR is merged.

@zhouyx
Copy link
Contributor Author

zhouyx commented Dec 21, 2018

Passing the JsonObject fix the issue. PTAL.

@erwinmombay please let me know if it is safe to remove the externs we have. Thanks.

@zhouyx zhouyx changed the title Add ad variables extern Fix Ampcontext variables in singlepass Dec 21, 2018
@@ -144,6 +144,9 @@ process.env.SERVE_MODE;
window.IS_AMP_ALT;

// Exposed to ads.
// TODO: @erwinmombay I do believe this is safe to remove because
// All are passed to ampcontext in JsonObject. While isMaster and master is
// calculated in ampcontext-integration within the iframe.
Copy link
Member

Choose a reason for hiding this comment

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

you'd have to change all the reads to use bracket notation if you want to remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Asked @erwinmombay offline. We want to leave the extern for future optimization that is not related to singlepass. I removed my comment. We will need to add missing variables to the externs, or use bracket notation.

@zhouyx zhouyx merged commit 6567a67 into ampproject:master Dec 21, 2018
@zhouyx zhouyx deleted the extern branch December 21, 2018 23:53
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Mar 22, 2019
* add to extern

* fix

* remove comment
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.

Fix amp-context API for single pass.
4 participants