MCPcopy
hub / github.com/ampproject/amphtml / trigger

Function trigger

test/unit/builtins/test-amp-pixel.js:43–59  ·  view source on GitHub ↗

* @param {string=} opt_src * @param {string=} opt_attributionsrc * @return {!Promise<?Image>}

(opt_src, opt_attributionsrc)

Source from the content-addressed store, hash-verified

41 * @return {!Promise<?Image>}
42 */
43 function trigger(opt_src, opt_attributionsrc) {
44 if (opt_src != null) {
45 pixel.setAttribute('src', opt_src);
46 }
47 if (opt_attributionsrc != null) {
48 pixel.setAttribute('attributionsrc', opt_attributionsrc);
49 }
50 whenFirstVisibleResolver();
51 return whenFirstVisiblePromise
52 .then(() => {
53 return pixel.getImpl(false);
54 })
55 .then((impl) => {
56 expect(impl.triggerPromise_).to.be.not.null;
57 return impl.triggerPromise_;
58 });
59 }
60
61 it('should be non-displayed', () => {
62 expect(pixel.style.width).to.equal('0px');

Callers 1

test-amp-pixel.jsFile · 0.85

Calls 4

expectFunction · 0.85
getImplMethod · 0.80
setAttributeMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected