2024-04-04 21:01:36 +00:00
|
|
|
import { openTest, injectRuffleAndWait } from "../../utils.js";
|
|
|
|
import { expect, use } from "chai";
|
|
|
|
import chaiHtml from "chai-html";
|
|
|
|
import fs from "fs";
|
2020-05-23 17:37:06 +00:00
|
|
|
|
|
|
|
use(chaiHtml);
|
|
|
|
|
2020-05-25 14:40:49 +00:00
|
|
|
describe("Flash inside frame with injected ruffle", () => {
|
2021-08-21 14:34:08 +00:00
|
|
|
it("loads the test", async () => {
|
2024-05-27 20:19:52 +00:00
|
|
|
await openTest(browser, `polyfill/classic_frames_injected`);
|
2020-05-23 17:37:06 +00:00
|
|
|
});
|
|
|
|
|
2021-08-21 14:34:08 +00:00
|
|
|
it("polyfills inside a frame", async () => {
|
2023-05-30 20:24:43 +00:00
|
|
|
await injectRuffleAndWait(browser);
|
2021-08-21 14:34:08 +00:00
|
|
|
await browser.switchToFrame(await browser.$("#test-frame"));
|
|
|
|
await browser.$("<ruffle-object />").waitForExist();
|
2020-05-23 17:37:06 +00:00
|
|
|
|
2021-08-21 14:34:08 +00:00
|
|
|
const actual = await browser.$("#test-container").getHTML(false);
|
2024-04-04 21:01:36 +00:00
|
|
|
const expected = fs.readFileSync(
|
|
|
|
`${import.meta.dirname}/expected.html`,
|
|
|
|
"utf8",
|
|
|
|
);
|
2020-05-23 17:37:06 +00:00
|
|
|
expect(actual).html.to.equal(expected);
|
|
|
|
});
|
|
|
|
|
2021-08-21 14:34:08 +00:00
|
|
|
it("polyfills even after a reload", async () => {
|
2020-05-23 17:37:06 +00:00
|
|
|
// Contaminate the old contents, to ensure we get a "fresh" state
|
2021-08-21 14:34:08 +00:00
|
|
|
await browser.execute(() => {
|
2024-05-27 19:47:55 +00:00
|
|
|
document.getElementById("test-container")?.remove();
|
2020-05-23 17:37:06 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Then reload
|
2024-07-09 14:36:04 +00:00
|
|
|
await browser.switchToFrame(null);
|
2021-08-21 14:34:08 +00:00
|
|
|
await browser.switchToFrame(await browser.$("#nav-frame"));
|
|
|
|
await browser.$("#reload-link").click();
|
2020-05-23 17:37:06 +00:00
|
|
|
|
|
|
|
// And finally, check
|
2024-07-09 14:36:04 +00:00
|
|
|
await browser.switchToFrame(null);
|
2021-08-21 14:34:08 +00:00
|
|
|
await browser.switchToFrame(await browser.$("#test-frame"));
|
|
|
|
await browser.$("<ruffle-object />").waitForExist();
|
2020-05-23 17:37:06 +00:00
|
|
|
|
2021-08-21 14:34:08 +00:00
|
|
|
const actual = await browser.$("#test-container").getHTML(false);
|
2024-04-04 21:01:36 +00:00
|
|
|
const expected = fs.readFileSync(
|
|
|
|
`${import.meta.dirname}/expected.html`,
|
|
|
|
"utf8",
|
|
|
|
);
|
2020-05-23 17:37:06 +00:00
|
|
|
expect(actual).html.to.equal(expected);
|
|
|
|
});
|
|
|
|
});
|