@override
(env)
| 484 | |
| 485 | /** @override */ |
| 486 | async setup(env) { |
| 487 | const body = |
| 488 | typeof this.spec.body == 'function' ? this.spec.body() : this.spec.body; |
| 489 | const css = |
| 490 | typeof this.spec.css == 'function' ? this.spec.css() : this.spec.css; |
| 491 | const experiments = |
| 492 | this.spec.experiments == undefined |
| 493 | ? undefined |
| 494 | : this.spec.experiments.join(','); |
| 495 | const extensions = |
| 496 | this.spec.extensions == undefined |
| 497 | ? undefined |
| 498 | : this.spec.extensions.join(','); |
| 499 | const ampDocType = this.spec.ampdoc || 'single'; |
| 500 | const style = this.spec.frameStyle; |
| 501 | |
| 502 | let url = |
| 503 | this.spec.amp === false |
| 504 | ? '/amp4test/compose-html' |
| 505 | : '/amp4test/compose-doc'; |
| 506 | |
| 507 | if (this.spec.params) { |
| 508 | url = addParamsToUrl(url, this.spec.params); |
| 509 | } |
| 510 | |
| 511 | const docUrl = |
| 512 | addParamsToUrl(url, { |
| 513 | body, |
| 514 | css, |
| 515 | experiments, |
| 516 | extensions, |
| 517 | }) + `#${this.hash}`; |
| 518 | |
| 519 | // If shadow mode, wrap doc in shadow viewer. |
| 520 | const src = |
| 521 | ampDocType == 'shadow' |
| 522 | ? addParamsToUrl('/amp4test/compose-shadow', {docUrl}) |
| 523 | : docUrl; |
| 524 | |
| 525 | env.iframe = createElementWithAttributes(document, 'iframe', { |
| 526 | src, |
| 527 | style, |
| 528 | }); |
| 529 | |
| 530 | return new Promise((resolve, reject) => { |
| 531 | env.iframe.onload = function () { |
| 532 | env.win = env.iframe.contentWindow; |
| 533 | resolve(); |
| 534 | }; |
| 535 | env.iframe.onerror = reject; |
| 536 | |
| 537 | document.body.appendChild(env.iframe); |
| 538 | }); |
| 539 | } |
| 540 | |
| 541 | /** @override */ |
| 542 | teardown(env) { |
nothing calls this directly
no test coverage detected