diff --git a/extensions/amp-carousel/0.1/slidescroll.js b/extensions/amp-carousel/0.1/slidescroll.js index 22e40e56043f..e98aeacfc16d 100644 --- a/extensions/amp-carousel/0.1/slidescroll.js +++ b/extensions/amp-carousel/0.1/slidescroll.js @@ -211,7 +211,7 @@ export class AmpSlideScroll extends BaseSlides { if (args) { this.showSlideWhenReady(args['index']); } - }, ActionTrust.LOW); + }, ActionTrust.MEDIUM); // TODO(choumx, #9699): LOW. } /** @override */ diff --git a/extensions/amp-form/0.1/amp-form.js b/extensions/amp-form/0.1/amp-form.js index 5d8b518b5ce6..1d1e798dbad8 100644 --- a/extensions/amp-form/0.1/amp-form.js +++ b/extensions/amp-form/0.1/amp-form.js @@ -191,8 +191,9 @@ export class AmpForm { this.verifier_ = getFormVerifier( this.form_, () => this.handleXhrVerify_()); + // TODO(choumx, #9699): HIGH. this.actions_.installActionHandler( - this.form_, this.actionHandler_.bind(this), ActionTrust.HIGH); + this.form_, this.actionHandler_.bind(this), ActionTrust.MEDIUM); this.installEventHandlers_(); /** @private {?Promise} */ @@ -348,7 +349,7 @@ export class AmpForm { event.preventDefault(); } // Submits caused by user input have high trust. - this.submit_(ActionTrust.HIGH); + this.submit_(ActionTrust.MEDIUM); // TODO(choumx, #9699): HIGH. } /** diff --git a/extensions/amp-live-list/0.1/amp-live-list.js b/extensions/amp-live-list/0.1/amp-live-list.js index 10d9c654a0b3..72d69f2dcd9b 100644 --- a/extensions/amp-live-list/0.1/amp-live-list.js +++ b/extensions/amp-live-list/0.1/amp-live-list.js @@ -224,8 +224,9 @@ export class AmpLiveList extends AMP.BaseElement { this.curNumOfLiveItems_ = this.validateLiveListItems_( this.itemsSlot_, true); + // TODO(choumx, #9699): LOW. this.registerAction( - 'update', this.updateAction_.bind(this), ActionTrust.LOW); + 'update', this.updateAction_.bind(this), ActionTrust.MEDIUM); if (!this.element.hasAttribute('aria-live')) { this.element.setAttribute('aria-live', 'polite'); diff --git a/extensions/amp-selector/0.1/amp-selector.js b/extensions/amp-selector/0.1/amp-selector.js index 0aa33eedf999..36bf1dd873ea 100644 --- a/extensions/amp-selector/0.1/amp-selector.js +++ b/extensions/amp-selector/0.1/amp-selector.js @@ -292,8 +292,9 @@ export class AmpSelector extends AMP.BaseElement { targetOption: el.getAttribute('option'), selectedOptions: selectedValues, }); + // TODO(choumx, #9699): HIGH. this.action_.trigger(this.element, name, selectEvent, - ActionTrust.HIGH); + ActionTrust.MEDIUM); } }); } diff --git a/spec/amp-actions-and-events.md b/spec/amp-actions-and-events.md index 50800f23ee79..2940ec1b3e48 100644 --- a/spec/amp-actions-and-events.md +++ b/spec/amp-actions-and-events.md @@ -58,11 +58,13 @@ You can listen to multiple events on an element by separating the two events wit Example: `on="submit-success:lightbox1;submit-error:lightbox2"` + ## Multiple Actions For One Event You can execute multiple actions in sequence for the same event by separating the two actions with a comma ','. Example: `on="tap:target1.actionA,target2.actionB"` + ## Globally defined Events and Actions Currently AMP defines `tap` event globally that you can listen to on any HTML element (including amp-elements). @@ -78,18 +80,6 @@ For example, the following is possible in AMP. ``` -## Trust - -Each event has a "trust" level that corresponds to the user's intentionality -behind that event. Each action has a "required trust" which is the minimum trust -level of an event to trigger the action. - -For example, a medium-trust event (e.g. `slideChange`) cannot trigger a -high-required-trust action (e.g. `navigateTo`). - -See the tables below for the trust levels of each event and required trust for -each action. - ## Element Specific Events ### * - all elements @@ -97,12 +87,10 @@ each action. Event Description - Trust tap Fired when the element is clicked/tapped. - High @@ -113,40 +101,29 @@ each action. Description Elements Data - Trust - change - Fired when the value of the element is changed and committed. + change + Fired when the value of the element is changed and committed. input[type="range"] event.min : The minimum value of the range
event.value : The current value of the range
event.max : The maximum value of the range
- Medium input[type="radio"], input[type="checkbox"] event.checked : If the element is checked - Medium - input[type="text"] - - event.value : String of the text or selected option - - Medium - - - select + input[type="text"], select event.value : String of the text or selected option - High @@ -154,7 +131,6 @@ each action. Fired when the value of the element is changed. This is similar to the standard input event, but it only fires when 300ms have passed after the value of the input has stopped changing. Elements that fire input event. Same as above. - Medium @@ -164,13 +140,11 @@ each action. Event Description Data - Trust slideChange Fired when the user manually changes the carousel's current slide. Does not fire on autoplay or the goToSlide action. event.index : slide number - Medium @@ -180,13 +154,11 @@ each action. Event Description Data - Trust select Fired when the user manually selects an option. event.targetOption : The option attribute value of the selected element - High @@ -196,51 +168,43 @@ each action. Event Description Data - Trust submit Fired when the form is submitted. - High submit-success Fired when the form submission response is success. event.response : JSON response - Medium submit-error Fired when the form submission response is an error. event.response : JSON response - Medium -## Element Specific Actions +## Element Specific Actions ### * (all elements) - - - -
Action DescriptionRequired Trust
hide Hides the target element.Medium
show Shows the target element.Medium
toggleVisibility Toggles the visibility of the target element.Medium
@@ -249,12 +213,10 @@ each action. Action Description - Required Trust goToSlide(index=INTEGER) Advances the carousel to a specified slide index. - Low @@ -263,12 +225,10 @@ each action. Action Description - Required Trust open (default) Opens the image lightbox with the source image being the one that triggered the action. - Medium @@ -277,17 +237,14 @@ each action. Action Description - Required Trust open (default) Opens the lightbox. - Medium close Closes the lightbox. - Medium @@ -296,12 +253,10 @@ each action. Action Description - Required Trust update (default) Updates the DOM items to show updated content. - Low @@ -310,22 +265,32 @@ each action. Action Description - Required Trust open (default) Opens the sidebar. - Medium close Closes the sidebar. - Medium toggle Toggles the state of the sidebar. - Medium + + + +### amp-state + + + + + + + +
ActionDescription
(default)Updates the amp-state's data with the data contained in the event. Requires + amp-bind. +
@@ -334,12 +299,10 @@ each action. Action Description - Required Trust dismiss (default) Hides the referenced user notification element. - Medium @@ -348,27 +311,22 @@ each action. Action Description - Required Trust play Plays the video. - High pause Pauses the video. - Low mute Mutes the video. - Low unmute Unmutes the video. - High @@ -377,12 +335,10 @@ each action. Action Description - Required Trust submit Submits the form. - High @@ -399,22 +355,18 @@ actions that apply to the whole document. Action Description - Required Trust navigateTo(url=STRING) Navigates current window to given URL. Supports standard URL subsitutions. Can only be invoked via tap or change events. - High goBack Navigates back in history. - High setState Updates amp-bind's state. See details. - Medium diff --git a/src/document-submit.js b/src/document-submit.js index dccdf5879bb3..4092d89cafd1 100644 --- a/src/document-submit.js +++ b/src/document-submit.js @@ -131,6 +131,7 @@ export function onDocumentFormSubmit_(e) { e.stopImmediatePropagation(); const actions = actionServiceForDoc(form); - actions.execute(form, 'submit', /*args*/ null, form, e, ActionTrust.HIGH); + // TODO(choumx, #9699): HIGH. + actions.execute(form, 'submit', /*args*/ null, form, e, ActionTrust.MEDIUM); } } diff --git a/src/service/action-impl.js b/src/service/action-impl.js index bed8be8cc39f..cece1665d64f 100644 --- a/src/service/action-impl.js +++ b/src/service/action-impl.js @@ -246,7 +246,8 @@ export class ActionService { } else if (name == 'submit') { this.root_.addEventListener(name, event => { const element = dev().assertElement(event.target); - this.trigger(element, name, event, ActionTrust.HIGH); + // TODO(choumx, #9699): HIGH. + this.trigger(element, name, event, ActionTrust.MEDIUM); }); } else if (name == 'change') { this.root_.addEventListener(name, event => { diff --git a/src/service/standard-actions-impl.js b/src/service/standard-actions-impl.js index f79a1b752cad..fb677f622646 100644 --- a/src/service/standard-actions-impl.js +++ b/src/service/standard-actions-impl.js @@ -155,7 +155,8 @@ export class StandardActions { * @private */ handleAmpGoBack_(invocation) { - if (!invocation.satisfiesTrust(ActionTrust.HIGH)) { + // TODO(choumx, #9699): HIGH. + if (!invocation.satisfiesTrust(ActionTrust.MEDIUM)) { return; } historyForDoc(this.ampdoc).goBack(); diff --git a/src/service/video-manager-impl.js b/src/service/video-manager-impl.js index 2184d731aa09..f073f6fc4fbf 100644 --- a/src/service/video-manager-impl.js +++ b/src/service/video-manager-impl.js @@ -125,12 +125,15 @@ export class VideoManager { * @private */ registerCommonActions_(video) { + // TODO(choumx, #9699): HIGH for unmuted play, LOW for muted play. video.registerAction('play', video.play.bind(video, /* isAutoplay */ false), - ActionTrust.HIGH); - video.registerAction('pause', video.pause.bind(video), ActionTrust.LOW); - video.registerAction('mute', video.mute.bind(video), ActionTrust.LOW); + ActionTrust.MEDIUM); + // TODO(choumx, #9699): LOW. + video.registerAction('pause', video.pause.bind(video), ActionTrust.MEDIUM); + video.registerAction('mute', video.mute.bind(video), ActionTrust.MEDIUM); + // TODO(choumx, #9699): HIGH. video.registerAction('unmute', video.unmute.bind(video), - ActionTrust.HIGH); + ActionTrust.MEDIUM); } /**