* @param {!AmpScript} ampScript * @param {!Array } sandboxTokens
(ampScript, sandboxTokens)
| 713 | * @param {!Array<string>} sandboxTokens |
| 714 | */ |
| 715 | constructor(ampScript, sandboxTokens) { |
| 716 | /** @private @const {!Window} */ |
| 717 | this.win_ = ampScript.win; |
| 718 | |
| 719 | /** @private @const {!Element} */ |
| 720 | this.element_ = ampScript.element; |
| 721 | |
| 722 | registerServiceBuilder(this.win_, 'purifier-inplace', function () { |
| 723 | return new Purifier( |
| 724 | ampScript.win.document, |
| 725 | {'IN_PLACE': true}, |
| 726 | rewriteAttributeValue |
| 727 | ); |
| 728 | }); |
| 729 | |
| 730 | /** @private @const {!Purifier} */ |
| 731 | this.purifier_ = getService(this.win_, 'purifier-inplace'); |
| 732 | |
| 733 | /** @private @const {!{[key: string]: boolean}} */ |
| 734 | this.allowedTags_ = this.purifier_.getAllowedTags(); |
| 735 | |
| 736 | /** |
| 737 | * @private |
| 738 | * @return {boolean} |
| 739 | */ |
| 740 | this.allowFullEval_ = () => ampScript.isMutationAllowedByUserGesture(); |
| 741 | |
| 742 | /** |
| 743 | * @private |
| 744 | * @return {boolean} |
| 745 | */ |
| 746 | this.shouldConstrainEval_ = () => |
| 747 | !this.allowFullEval_() && ampScript.isMutationAllowedByFixedSize(); |
| 748 | |
| 749 | // TODO(choumx): Support opt-in for variable substitutions. |
| 750 | // For now, only allow built-in AMP components except amp-pixel. |
| 751 | this.allowedTags_['amp-img'] = true; |
| 752 | this.allowedTags_['amp-layout'] = true; |
| 753 | this.allowedTags_['amp-pixel'] = false; |
| 754 | |
| 755 | /** @private @const {boolean} */ |
| 756 | this.allowForms_ = sandboxTokens.includes('allow-forms'); |
| 757 | FORM_ELEMENTS.forEach((fe) => { |
| 758 | this.allowedTags_[fe] = this.allowForms_; |
| 759 | }); |
| 760 | } |
| 761 | |
| 762 | /** |
| 763 | * This is called by worker-dom on node creation, so all invocations are on |
nothing calls this directly
no test coverage detected