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

Delegate trust check to action handler #21553

Conversation

dreamofabear
Copy link

Prerequisite for #21322.

For action handlers of non-AMP elements, remove the ActionTrust check from registration time and allow the handler itself to do the check instead.

This is a simple solution to support both HIGH and LOW trust actions in a single handler.

/to @alabiaga

@dreamofabear dreamofabear force-pushed the action-handler-delegate-trust-check branch from 702acf1 to 52f7ba4 Compare March 22, 2019 22:28
@@ -775,7 +779,7 @@ export class ActionService {
* @return {boolean}
* @private
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, why this change? Is a trailing underscore no longer going to be used to identify @private? You're consistent as you introduced isAmpTagName which follows the same naming scheme and is private.

Copy link
Author

Choose a reason for hiding this comment

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

I think it's more important for class functions than module-level functions. I.e. it's possible to accidentally invoke a private class function but not a module-level function that's not exported.

// Dequeue the current queue.
if (isArray(currentQueue)) {
const queuedInvocations = target[ACTION_QUEUE_];
if (isArray(queuedInvocations)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit. not related to your change but is the isArray check for queuedInvocations is not necessary here. It is either null or an Array based on the type annotation associated with it and if so then checking for its presence would suffice. Just if(queuedInvocations) vs if (isArray(queuedInvocations))

Copy link
Author

Choose a reason for hiding this comment

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

My guess is it's a safety measure in case some other code accidentally sets the same property on the element.

Copy link
Author

@dreamofabear dreamofabear left a comment

Choose a reason for hiding this comment

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

Thanks for the review.

@@ -775,7 +779,7 @@ export class ActionService {
* @return {boolean}
* @private
Copy link
Author

Choose a reason for hiding this comment

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

I think it's more important for class functions than module-level functions. I.e. it's possible to accidentally invoke a private class function but not a module-level function that's not exported.

// Dequeue the current queue.
if (isArray(currentQueue)) {
const queuedInvocations = target[ACTION_QUEUE_];
if (isArray(queuedInvocations)) {
Copy link
Author

Choose a reason for hiding this comment

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

My guess is it's a safety measure in case some other code accidentally sets the same property on the element.

@dreamofabear dreamofabear merged commit 391a431 into ampproject:master Mar 23, 2019
@dreamofabear dreamofabear deleted the action-handler-delegate-trust-check branch March 23, 2019 22:05
erwinmombay added a commit to erwinmombay/amphtml that referenced this pull request Mar 25, 2019
@cvializ cvializ mentioned this pull request Mar 26, 2019
erwinmombay added a commit that referenced this pull request Mar 26, 2019
dreamofabear pushed a commit to dreamofabear/amphtml that referenced this pull request Apr 1, 2019
dreamofabear pushed a commit that referenced this pull request Apr 3, 2019
* Revert "Revert "Delegate trust check to action handler (#21553)" (#21563)"

This reverts commit d96498b.

* Fix type check.

* Fix test-amp-access.js.

* Fix test-amp-form.js.

* Test trust check in amp-access.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants