Skip to content

Created attributes.js#7129

Merged
lannka merged 16 commits intoampproject:masterfrom
google:frizz-create-attributes-file
Feb 1, 2017
Merged

Created attributes.js#7129
lannka merged 16 commits intoampproject:masterfrom
google:frizz-create-attributes-file

Conversation

@bradfrizzell
Copy link
Copy Markdown
Contributor

This new file provides the getContextMetadata and getNameAttribute functions. getContextMetadata is a generalized function for assigning the metadata needed for setting up window.context

This addition was part of #6825 but I've realized that PR had a mixture of things that could be better suited to review by breaking apart further.

@jridgewell
Copy link
Copy Markdown
Contributor

These are both 3p iframe specific. Maybe put in the 3p directory?

@bradfrizzell
Copy link
Copy Markdown
Contributor Author

These will also be used in the A4A flow for non-amp ads, so it is not only for 3p frames.

@jridgewell
Copy link
Copy Markdown
Contributor

These will also be used in the A4A flow for non-amp ads, so it is not only for 3p frames.
View changes

But that just creates a 3p frame... right?

@bradfrizzell
Copy link
Copy Markdown
Contributor Author

No, although it is rendering a non-amp ad, it doesn't actually use a 3p-frame. https://github.com/ampproject/amphtml/blob/master/extensions/amp-a4a/0.1/amp-a4a.js#L1077

* - data-* attributes of the <amp-ad> tag with the "data-" removed.
* - A _context object for internal use.
*/
export function getContextMetadata(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can remove a fair amount (which I have done, but it's not in this pr). If you'd like that all to be in this PR, I can do that, but getting this attributes.js file in for the next release is important for us fixing an issue with a4a so I didn't want to slow down if there were any issues integrating this file into 3p-frame.js

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As long as there's a quick follow up. I hate adding duplicated code.

for the next release is important for us fixing an issue with a4a

Where's the code using this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bradfrizzell
Copy link
Copy Markdown
Contributor Author

this blocks #7132

@jridgewell
Copy link
Copy Markdown
Contributor

LGTM, @lannka?

@bradfrizzell
Copy link
Copy Markdown
Contributor Author

Would like to get this into today's release

Copy link
Copy Markdown
Contributor

@lannka lannka left a comment

Choose a reason for hiding this comment

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

Can you also move the test here?

BTW, this code is not used, why do you care if it gets cut in this release?

I'm not sure your exact refactoring plan. Is it hard to remove the old code in the same PR? That will be easier for reviewer to see the diff.

attributes.src = adSrc;
}
return attributes;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: remove blank line

@bradfrizzell
Copy link
Copy Markdown
Contributor Author

I want it in this release so that I can also get #7132 in today's release (which this is blocking)

@bradfrizzell
Copy link
Copy Markdown
Contributor Author

Refactored it as requested

@lannka
Copy link
Copy Markdown
Contributor

lannka commented Jan 27, 2017

Thanks @bradfrizzell . were there any tests need to be moved as well?

@bradfrizzell
Copy link
Copy Markdown
Contributor Author

I think the tests in test-3p-frame provide good testing of the getContextMetadata, there was nothing in the other PR already written that wasn't moved at least. I can add more if you think getContextMetadata isn't well tested enough. In the pr that uses it for a4a, there are tests of it's use for the a4a case that will cover it more

@lannka
Copy link
Copy Markdown
Contributor

lannka commented Jan 30, 2017

@bradfrizzell I think it make a lot sense to move those tests from test-3p-frame.js to test-attributes.js, since the major logic is moved.

@bradfrizzell
Copy link
Copy Markdown
Contributor Author

reverted the last two commits that I made to break out the tests, because I was getting really weird errors with state leakage in the tests. basically, test-iframe-attributes.js was passing if I ran it alone, but if I ran it as part of the suite as a whole it was not. Getting this PR into today's cut is of very high importance to the A4A team, so I need to push off breaking this test apart if we can

Copy link
Copy Markdown
Contributor

@lannka lannka left a comment

Choose a reason for hiding this comment

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

@bradfrizzell please add a TODO in the test-3p-frame.js to indicate the part needs to be moved to new test.

@lannka lannka merged commit bbe8b35 into ampproject:master Feb 1, 2017
torch2424 pushed a commit to torch2424/amphtml that referenced this pull request Feb 14, 2017
* Created attributes.js

* Whitelisted src/attributes for unconfirmed referrer url

* Renamed attributes.js to iframe-attributes.js

* Fixed name of file in presubmit-checks

* Add sentinel name change exp / add func to generate sentinel and context

* Refactored to use getContextMetadata

* Removed blank line

* Removed unneeded import

* Moved function to fix check-types and fixed docstring

* Made new test file / broke out tests

* Changed test name

* Revert "Changed test name"

This reverts commit a509951.

* Revert "Made new test file / broke out tests"

This reverts commit 1961923.

* Added todo
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
* Created attributes.js

* Whitelisted src/attributes for unconfirmed referrer url

* Renamed attributes.js to iframe-attributes.js

* Fixed name of file in presubmit-checks

* Add sentinel name change exp / add func to generate sentinel and context

* Refactored to use getContextMetadata

* Removed blank line

* Removed unneeded import

* Moved function to fix check-types and fixed docstring

* Made new test file / broke out tests

* Changed test name

* Revert "Changed test name"

This reverts commit a509951.

* Revert "Made new test file / broke out tests"

This reverts commit 1961923.

* Added todo
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.

3 participants