|
| 1 | +import { test, expect } from '@playwright/test'; |
| 2 | +import { createServer } from "http-server"; |
| 3 | + |
| 4 | + |
| 5 | +test("same-domain embed is loading", async ({ page }) => { |
| 6 | + await page.goto("http://localhost:9990/embed.html"); |
| 7 | + |
| 8 | + const res = page.locator("replay-web-page").frameLocator("iframe").locator("replay-app-main wr-coll wr-coll-replay").frameLocator("iframe").frameLocator("iframe#twitter-widget-0").locator("body"); |
| 9 | + |
| 10 | + await expect(res).toContainText("Want to help"); |
| 11 | +}); |
| 12 | + |
| 13 | + |
| 14 | +test("cross-domain embed is loading", async ({ page }) => { |
| 15 | + await page.goto("http://localhost:8020/"); |
| 16 | + |
| 17 | + const res = page.locator("replay-web-page").frameLocator("iframe").locator("replay-app-main wr-coll wr-coll-replay").frameLocator("iframe").frameLocator("iframe#twitter-widget-0").locator("body"); |
| 18 | + |
| 19 | + await expect(res).toContainText("Want to help"); |
| 20 | +}); |
| 21 | + |
| 22 | + |
| 23 | +test("sandbox + cross-domain embed is loading", async ({ page }) => { |
| 24 | + await page.goto("http://localhost:8030/"); |
| 25 | + |
| 26 | + const sandboxFrame = page.locator("iframe"); |
| 27 | + await expect(await sandboxFrame.getAttribute("src")).toBe("http://localhost:8020/index-sandbox.html"); |
| 28 | + |
| 29 | + const res = page.frameLocator("iframe").locator("replay-web-page").frameLocator("iframe").locator("replay-app-main wr-coll wr-coll-replay").frameLocator("iframe").frameLocator("iframe#twitter-widget-0").locator("body"); |
| 30 | + |
| 31 | + await expect(res).toContainText("Want to help"); |
| 32 | +}); |
| 33 | + |
| 34 | + |
| 35 | +test("require subdomain iframe", async ({ page }) => { |
| 36 | + // load directly, should be blocked |
| 37 | + await page.goto("http://localhost:8020/index-sandbox.html"); |
| 38 | + |
| 39 | + const res = page.locator("replay-web-page"); |
| 40 | + |
| 41 | + await expect(res).toContainText("Sorry, due to security settings, this ReplayWeb.page embed only be viewed within a subdomain iframe."); |
| 42 | +}); |
0 commit comments