amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Using on-action syntax in amp-date-countdown results in "insufficient trust"

Open micyeung opened this issue 8 years ago • 4 comments

What's the issue?

Running the following code:

<amp-date-countdown 
  on="timeout: AMP.setState({foo: 'bar'});" 
  end-date="2017-07-04T16:46:00+08:00" 
  when-ended="stop"> 

</amp-date-countdown>

or on simpler on-syntax action like

<amp-date-countdown 
  on="timeout: mydiv.show;" 
  end-date="2017-07-04T16:46:00+08:00" 
  when-ended="stop"> 

</amp-date-countdown>

results in the following error, contrary to the documentation:

Insufficient trust for "setState" (1 < 100).

However, there is no error when the on-syntax action is done with an amp-animation, like on="timeout: anim.start;"

What browsers are affected?

All browsers

Which AMP version is affected?

Found in 1530567757224

micyeung avatar Jul 04 '18 09:07 micyeung

Please refer to https://github.com/ampproject/amphtml/pull/13657#pullrequestreview-101786630 and https://github.com/ampproject/amphtml/issues/13973#issuecomment-372856471 for more informations

leonahliang90 avatar Jul 05 '18 03:07 leonahliang90

AMP.setState requires a user action to be triggered. We probably should have a more useful error message.

dreamofabear avatar Jul 06 '18 22:07 dreamofabear

@micyeung @leonalicious Can you describe your intended use case?

dreamofabear avatar Jul 06 '18 22:07 dreamofabear

@micyeung You can use amp-animation to hide and show sections of the page based on the timeout. https://github.com/ampproject/amphtml/blob/master/examples/amp-date-countdown.amp.html has an example for that.

aghassemi avatar Jul 08 '18 16:07 aghassemi