Skip to content

Commit

Permalink
Revert "web: Work around webdriverio frame-switching bug with selectors"
Browse files Browse the repository at this point in the history
This reverts commit 7ec4b7c.
  • Loading branch information
torokati44 committed Oct 28, 2024
1 parent aaaea30 commit 9f989ab
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
openTest,
injectRuffleAndWait,
waitForRuffleObjectInTestFrame,
getContainerHTMLFromTestFrame,
} from "../../utils.js";
import { openTest, injectRuffleAndWait } from "../../utils.js";
import { expect, use } from "chai";
import chaiHtml from "chai-html";
import fs from "fs";
Expand All @@ -17,10 +12,12 @@ describe("Flash inside frame with injected ruffle", () => {

it("polyfills inside a frame", async () => {
await injectRuffleAndWait(browser);
await browser.switchToFrame(await browser.$("#test-frame"));
await waitForRuffleObjectInTestFrame(browser);
await browser.switchFrame(await browser.$("#test-frame"));
await browser.$("<ruffle-object />").waitForExist();

const actual = await getContainerHTMLFromTestFrame(browser);
const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false, pierceShadowRoot: false });
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
Expand All @@ -35,16 +32,18 @@ describe("Flash inside frame with injected ruffle", () => {
});

// Then reload
await browser.switchToFrame(null);
await browser.switchToFrame(await browser.$("#nav-frame"));
await browser.switchFrame(null);
await browser.switchFrame(await browser.$("#nav-frame"));
await browser.$("#reload-link").click();

// And finally, check
await browser.switchToFrame(null);
await browser.switchToFrame(await browser.$("#test-frame"));
await waitForRuffleObjectInTestFrame(browser);
await browser.switchFrame(null);
await browser.switchFrame(await browser.$("#test-frame"));
await browser.$("<ruffle-object />").waitForExist();

const actual = await getContainerHTMLFromTestFrame(browser);
const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false, pierceShadowRoot: false });
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
openTest,
waitForRuffleObjectInTestFrame,
getContainerHTMLFromTestFrame,
} from "../../utils.js";
import { openTest } from "../../utils.js";
import { expect, use } from "chai";
import chaiHtml from "chai-html";
import fs from "fs";
Expand All @@ -15,10 +11,12 @@ describe("Flash inside frame with provided ruffle", () => {
});

it("polyfills inside a frame", async () => {
await browser.switchToFrame(await browser.$("#test-frame"));
await waitForRuffleObjectInTestFrame(browser);
await browser.switchFrame(await browser.$("#test-frame"));
await browser.$("<ruffle-object />").waitForExist();

const actual = await getContainerHTMLFromTestFrame(browser);
const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false, pierceShadowRoot: false });
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
Expand All @@ -33,16 +31,18 @@ describe("Flash inside frame with provided ruffle", () => {
});

// Then reload
await browser.switchToFrame(null);
await browser.switchToFrame(await browser.$("#nav-frame"));
await browser.switchFrame(null);
await browser.switchFrame(await browser.$("#nav-frame"));
await browser.$("#reload-link").click();

// And finally, check
await browser.switchToFrame(null);
await browser.switchToFrame(await browser.$("#test-frame"));
await waitForRuffleObjectInTestFrame(browser);
await browser.switchFrame(null);
await browser.switchFrame(await browser.$("#test-frame"));
await browser.$("<ruffle-object />").waitForExist();

const actual = await getContainerHTMLFromTestFrame(browser);
const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false, pierceShadowRoot: false });
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
Expand Down
35 changes: 0 additions & 35 deletions web/packages/selfhosted/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,38 +206,3 @@ export function loadJsAPI(swf?: string) {
}
});
}

// TODO: After https://github.com/webdriverio/webdriverio/issues/13218 is fixed,
// use `browser.$("<ruffle-object />").waitForExist()` at all call sites instead.
export async function waitForRuffleObjectInTestFrame(
browser: WebdriverIO.Browser,
) {
await browser
.$(
() =>
(
document.querySelector("#test-frame") as
| HTMLIFrameElement
| HTMLFrameElement
).contentDocument?.body.querySelector(
"ruffle-object",
) as HTMLElement,
)
.waitForExist();
}

// TODO: After https://github.com/webdriverio/webdriverio/issues/13218 is fixed, use
// `browser.$("#test-container").getHTML({ includeSelectorTag: false, pierceShadowRoot: false })`
// at all call sites instead.
export async function getContainerHTMLFromTestFrame(
browser: WebdriverIO.Browser,
) {
return await browser.execute(() => {
const el = (
document.querySelector("#test-frame") as
| HTMLIFrameElement
| HTMLFrameElement
).contentDocument?.body.querySelector("#test-container");
return el?.innerHTML;
});
}

0 comments on commit 9f989ab

Please sign in to comment.