-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
add version parameter to AMP.extension signature #5989
add version parameter to AMP.extension signature #5989
Conversation
/to @dvoytenko @zhouyx |
@@ -235,6 +235,6 @@ class AmpStickyAd extends AMP.BaseElement { | |||
} | |||
} | |||
|
|||
AMP.extension('amp-sticky-ad', AMP => { | |||
AMP.extension('amp-sticky-ad', 0.1, AMP => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.0 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -179,10 +179,11 @@ function adoptShared(global, opts, callback) { | |||
if (!global.AMP.extension) { | |||
/** | |||
* @param {string} unusedName | |||
* @param {number|string} version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make it to be 0.1 by default? and make the version optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id rather this be explicit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then you probably want to search global.AMP.extension
in our codebase. I think there are other elements that use this function.
global.AMP.extension = function(name, installer) { | ||
describes.bufferExtension(name, installer); | ||
global.AMP.extension = function(name, version, installer) { | ||
describes.bufferExtension(`${name}:${version}`, installer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we also need to change the describes.js
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain what needs to be updated there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry about describes
. I'll pick that refactoring up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dvoytenko do you want me to remove this change? or just leave as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave as is.
b9b372d
to
6139ba4
Compare
if (extensionId.indexOf(':') == -1) { | ||
// We default to 0.1 if the user did not give an explicit | ||
// version. | ||
extensionId = `${extensionId}:0.1`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't overwrite extensionId
here if we can't find an installer. We would need the extension name w/o version number to call resetScheduledElementForTesting(win, extensionId);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed to bufferId
* @param {function(!Object)} installer | ||
* @const | ||
*/ | ||
global.AMP.extension = function(unusedName, installer) { | ||
global.AMP.extension = function(unusedName, version, installer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to combine unusedName
and version
to a single object, and make the version to be 0.1
as default. But this can be done afterwards.
6139ba4
to
eeed48d
Compare
@@ -429,7 +429,13 @@ class AmpFixture { | |||
} | |||
if (spec.extensions) { | |||
spec.extensions.forEach(extensionId => { | |||
const installer = extensionsBuffer[extensionId]; | |||
let bufferId = extensionId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
LGTM, defer to @dvoytenko for final approval. |
eeed48d
to
e389c69
Compare
@@ -48,6 +48,8 @@ | |||
private final Map<String, Node> prodAssignmentReplacements; | |||
final boolean isProd; | |||
|
|||
final Integer ampExtensionCallbackPosition = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add javadoc here to describe what the signature looks like.
Also, why not just go with the "last" arg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
went with the last arg.
@@ -179,10 +179,11 @@ function adoptShared(global, opts, callback) { | |||
if (!global.AMP.extension) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we go ahead and replace this if
with minified
or whatever if
that will strip this function from PROD version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. switched to minified. will double check
global.AMP.extension = function(name, installer) { | ||
describes.bufferExtension(name, installer); | ||
global.AMP.extension = function(name, version, installer) { | ||
describes.bufferExtension(`${name}:${version}`, installer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry about describes
. I'll pick that refactoring up.
@@ -429,7 +429,13 @@ class AmpFixture { | |||
} | |||
if (spec.extensions) { | |||
spec.extensions.forEach(extensionId => { | |||
const installer = extensionsBuffer[extensionId]; | |||
let bufferId = extensionId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite. See extensionId
usage lower in this method. I recommend to do this:
- Rename
extensionId =>
arg tobufferId
orextensionWithVersion
or such. - First thing in the method, parse it out into
extensionId
andversion
. - Use
${extensionId}:${version}
to lookup installer in theextensionsBuffer
. - For everything else, use
extensionId
by itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. PTAL
e389c69
to
5f8d2e5
Compare
@@ -176,13 +176,14 @@ function adoptShared(global, opts, callback) { | |||
// as `AMP.push()` in production. | |||
// TODO(dvoytenko, #5507): Only expose this method for `!getMode().minified` | |||
// once the compile-time inlining is done. | |||
if (!global.AMP.extension) { | |||
if (!getMode().minified) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove TODO
above. Is !minified
already DCE'd?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, double checked. code isn't there in production binary.
global.AMP.extension = function(name, installer) { | ||
describes.bufferExtension(name, installer); | ||
global.AMP.extension = function(name, version, installer) { | ||
describes.bufferExtension(`${name}:${version}`, installer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave as is.
LGTM with one small request |
@cramforce apologies :D bug in bot. |
@dvoytenko done. |
LGTM |
…tion rewrite (ampproject#5982) * Update amp-ad-network-doubleclick-impl.md * Reverting doc changes The previous change was made in error (wrong branch). * Initial changes, need to update tests * Start fixing tests * Fix unit test coverage * revert a4a examples Introduce amp-auto-id attribute to AMP element. (ampproject#5973) * Introduce amp-auto-id attribute to AMP element. * Fix tests * Address comments * Address comments * revert amp-live-list.md polling clarification (ampproject#5991) Only report 1% of errors if a page has non-AMP JS (ampproject#5994) Fixes ampproject#5732 Allow for hosted testing to override where third party frame is retrieved from (ampproject#5890) * Allow for hosted testing to override where third party frame is retrieved from * test my own site * fix ava tests Remove unsupported query selector feature (ampproject#5999) Workaround for misbehaving webview viewer (ampproject#6001) A webview viewer from Google is seing origins of the form `www.google.com`. For the time being we accept these as they trigger errors in our error reporting that aren't useful. As this form of origins can only occur with webviews that have full control over the page via JS injection anyway, this change should make no difference for normal web usage. A4A integration tests (ampproject#5812) * First draft of full integration tests for A4A. * First draft of full integration tests for A4A. * Got tests of exception conditions working. Refactored some common stuff to utils.js. * Refactored XDom and friendly iframe tests to helpers. * Added tests. * Resolved merge conflicts. * Centralized visibility check and updated visibility test. * Moved all A4A tests to using central visibility test. * Lint fixes. * Changed custom expectations to local functions. * Replaced stringToArrayBuffer with utf8Encode. * Fixed visibility assertion. * Lint fixes. * Added a comment (partly in order to get Travis to re-run). * Changes in response to reviews. * Rebased and fixed small rebase error. Fixes an issue where ads are not correctly centered on certain platforms. (ampproject#6003) * Centralized creative centering in doubleclick.js, and changed css 'transform' to a more commonly supported property. * Added check for existence and changed to plain old 'transform'. * Now asserting the existence of the container. amp-sticky-ad close button new style (ampproject#5979) * unit style * fix css * fix test * rebase * fix z-index Other JS errors: Use startsWith (ampproject#6006) Fixes ampproject#5994 (comment). Fix log calls without TAGNAME (ampproject#6005) My presubmit was a bit too lenient, and too strict at the same time. refactor amp-ad.css (ampproject#5992) Combine amp-analytics var docs with var substitutions doc re: ampproject#1302 (ampproject#5576) * Combine amp-analytics var docs with var substitutions doc re: ampproject#1302 * Updated non-supported vars + format changes for amp-analytics vars * Updates per Avi's feedback * Updated descriptions for amp-carousel vars add version parameter to AMP.extension signature (ampproject#5989) * add version parameter to AMP.extension signature * apply recommendations * remove TODO Improve error reporting (ampproject#6019) - Include the current `location.hash`. We are missing it, because it is not included in the referrer. - Include previously recorded errors, so it is easier to identify follow on errors. - Kill the 2000 char limit as it isn't important for AMP's target browsers. Include the originalHash (ampproject#6020) We remove the hash in embedding mode, so the original code doesn't actually work. Fix error: "Can't find variable: TextDecoder" (ampproject#6011) * Update amp-ad-network-doubleclick-impl.md * Reverting doc changes The previous change was made in error (wrong branch). * Initial changes, need to update tests * Start fixing tests * Fix unit test coverage * revert a4a examples * Include self (window) when verifying TextDecoder/TextEncoder existence * fix upstream conflict * PR feedback * PR feedback
Update ads.amp.html Modify A4A AMP Creative to use ampRuntimeUtf16CharOffsets from validation rewrite (ampproject#5982) * Update amp-ad-network-doubleclick-impl.md * Reverting doc changes The previous change was made in error (wrong branch). * Initial changes, need to update tests * Start fixing tests * Fix unit test coverage * revert a4a examples Introduce amp-auto-id attribute to AMP element. (ampproject#5973) * Introduce amp-auto-id attribute to AMP element. * Fix tests * Address comments * Address comments * revert amp-live-list.md polling clarification (ampproject#5991) Only report 1% of errors if a page has non-AMP JS (ampproject#5994) Fixes ampproject#5732 Allow for hosted testing to override where third party frame is retrieved from (ampproject#5890) * Allow for hosted testing to override where third party frame is retrieved from * test my own site * fix ava tests Remove unsupported query selector feature (ampproject#5999) Workaround for misbehaving webview viewer (ampproject#6001) A webview viewer from Google is seing origins of the form `www.google.com`. For the time being we accept these as they trigger errors in our error reporting that aren't useful. As this form of origins can only occur with webviews that have full control over the page via JS injection anyway, this change should make no difference for normal web usage. A4A integration tests (ampproject#5812) * First draft of full integration tests for A4A. * First draft of full integration tests for A4A. * Got tests of exception conditions working. Refactored some common stuff to utils.js. * Refactored XDom and friendly iframe tests to helpers. * Added tests. * Resolved merge conflicts. * Centralized visibility check and updated visibility test. * Moved all A4A tests to using central visibility test. * Lint fixes. * Changed custom expectations to local functions. * Replaced stringToArrayBuffer with utf8Encode. * Fixed visibility assertion. * Lint fixes. * Added a comment (partly in order to get Travis to re-run). * Changes in response to reviews. * Rebased and fixed small rebase error. Fixes an issue where ads are not correctly centered on certain platforms. (ampproject#6003) * Centralized creative centering in doubleclick.js, and changed css 'transform' to a more commonly supported property. * Added check for existence and changed to plain old 'transform'. * Now asserting the existence of the container. amp-sticky-ad close button new style (ampproject#5979) * unit style * fix css * fix test * rebase * fix z-index Other JS errors: Use startsWith (ampproject#6006) Fixes ampproject#5994 (comment). Fix log calls without TAGNAME (ampproject#6005) My presubmit was a bit too lenient, and too strict at the same time. refactor amp-ad.css (ampproject#5992) Combine amp-analytics var docs with var substitutions doc re: ampproject#1302 (ampproject#5576) * Combine amp-analytics var docs with var substitutions doc re: ampproject#1302 * Updated non-supported vars + format changes for amp-analytics vars * Updates per Avi's feedback * Updated descriptions for amp-carousel vars add version parameter to AMP.extension signature (ampproject#5989) * add version parameter to AMP.extension signature * apply recommendations * remove TODO Improve error reporting (ampproject#6019) - Include the current `location.hash`. We are missing it, because it is not included in the referrer. - Include previously recorded errors, so it is easier to identify follow on errors. - Kill the 2000 char limit as it isn't important for AMP's target browsers. Include the originalHash (ampproject#6020) We remove the hash in embedding mode, so the original code doesn't actually work. Fix error: "Can't find variable: TextDecoder" (ampproject#6011) * Update amp-ad-network-doubleclick-impl.md * Reverting doc changes The previous change was made in error (wrong branch). * Initial changes, need to update tests * Start fixing tests * Fix unit test coverage * revert a4a examples * Include self (window) when verifying TextDecoder/TextEncoder existence * fix upstream conflict * PR feedback * PR feedback
* add version parameter to AMP.extension signature * apply recommendations * remove TODO
* add version parameter to AMP.extension signature * apply recommendations * remove TODO
Fixes #5987
Fixes #5507.