(links, metas)
| 12 | }); |
| 13 | |
| 14 | function getWin(links, metas) { |
| 15 | return createIframePromise().then((iframe) => { |
| 16 | if (links) { |
| 17 | for (const rel in links) { |
| 18 | const hrefs = links[rel]; |
| 19 | for (let i = 0; i < hrefs.length; i++) { |
| 20 | const link = iframe.doc.createElement('link'); |
| 21 | link.setAttribute('rel', rel); |
| 22 | link.setAttribute('href', hrefs[i]); |
| 23 | iframe.doc.head.appendChild(link); |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | if (metas) { |
| 28 | for (const name in metas) { |
| 29 | const contents = metas[name]; |
| 30 | for (let i = 0; i < contents.length; i++) { |
| 31 | const meta = iframe.doc.createElement('meta'); |
| 32 | meta.setAttribute('name', name); |
| 33 | meta.setAttribute('content', contents[i]); |
| 34 | iframe.doc.head.appendChild(meta); |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | const {win} = iframe; |
| 39 | installDocService(win, /* isSingleDoc */ true); |
| 40 | env.sandbox.stub(win.Math, 'random').callsFake(() => 0.123456789); |
| 41 | win.__AMP_SERVICES.documentInfo = null; |
| 42 | installDocumentInfoServiceForDoc(win.document); |
| 43 | return iframe.win; |
| 44 | }); |
| 45 | } |
| 46 | |
| 47 | it('should provide the canonicalUrl', () => { |
| 48 | return getWin({'canonical': ['https://x.com/']}).then((win) => { |
no test coverage detected