Skip to content

Commit

Permalink
web: Try to fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhjacobs committed Aug 16, 2024
1 parent 35becf4 commit a067ead
Show file tree
Hide file tree
Showing 39 changed files with 132 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe("ExternalInterface", () => {
it("loads the test", async () => {
await openTest(browser, "integration_tests/external_interface");
await injectRuffleAndWait(browser);
const player = await browser.$("<ruffle-object>");
const player = await browser.$("ruffle-object");
await playAndMonitor(
browser,
player,
Expand Down Expand Up @@ -108,7 +108,7 @@ ExternalInterface.objectID: "flash_name"
});

it("responds to 'log'", async () => {
const player = await browser.$("<ruffle-object>");
const player = await browser.$("ruffle-object");
await browser.execute(
(player) =>
player.log("Hello world!", {
Expand Down Expand Up @@ -136,7 +136,7 @@ ExternalInterface.objectID: "flash_name"
});

it("returns a value", async () => {
const player = await browser.$("<ruffle-object>");
const player = await browser.$("ruffle-object");
const returned = await browser.execute(
(player) => player.returnAValue(123.4),
player,
Expand All @@ -155,11 +155,11 @@ ExternalInterface.objectID: "flash_name"
});

it("calls a method with delay", async () => {
const player = await browser.$("<ruffle-object>");
const player = await browser.$("ruffle-object");
await browser.execute(
(player) =>
player.callMethodWithDelay("window.RuffleTest.set", true),
player,
await player,
);
const actualValue = await getCalledValue(browser);
expect(actualValue).to.eql([true]);
Expand All @@ -179,13 +179,16 @@ ExternalInterface.objectID: "flash_name"
// [NA] Broken on Ruffle at time of writing
it.skip("calls a reentrant JS method", async () => {
// JS -> Flash -> JS within one call
const player = await browser.$("<ruffle-object>");
const actualValue = await browser.execute((player) => {
player.callMethodImmediately("window.RuffleTest.set", {
nested: { object: { complex: true } },
});
return window.RuffleTest.get();
}, player);
const player = await browser.$("ruffle-object");
const actualValue = await browser.execute(
(player) => {
player.callMethodImmediately("window.RuffleTest.set", {
nested: { object: { complex: true } },
});
return window.RuffleTest.get();
},
await player,
);

expect(actualValue).to.eql({
nested: { object: { complex: true } },
Expand All @@ -211,10 +214,16 @@ ExternalInterface.objectID: "flash_name"

it("calls a reentrant Flash method", async () => {
// Flash -> JS -> Flash within one call
const player = await browser.$("<ruffle-object>");
await browser.execute((player) => {
player.callMethodWithDelay("window.RuffleTest.log", "Reentrant!");
}, player);
const player = await browser.$("ruffle-object");
await browser.execute(
(player) => {
player.callMethodWithDelay(
"window.RuffleTest.log",
"Reentrant!",
);
},
await player,
);

// [NA] Because of the delay, if we fetch immediately we *may* just get part of the log.
await browser.pause(200);
Expand All @@ -236,13 +245,16 @@ log called with 1 argument
});

it("supports a JS function as name", async () => {
const player = await browser.$("<ruffle-object>");
await browser.execute((player) => {
player.callMethodWithDelay(
"function(name){window.RuffleTest.set(name)}",
"test",
);
}, player);
const player = await browser.$("ruffle-object");
await browser.execute(
(player) => {
player.callMethodWithDelay(
"function(name){window.RuffleTest.set(name)}",
"test",
);
},
await player,
);

// [NA] Because of the delay, if we fetch immediately we *may* just get part of the log.
await browser.pause(200);
Expand All @@ -263,10 +275,13 @@ log called with 1 argument
});

it("supports calling a method that doesn't exist", async () => {
const player = await browser.$("<ruffle-object>");
await browser.execute((player) => {
player.callMethodWithDelay("does.not.exist");
}, player);
const player = await browser.$("ruffle-object");
await browser.execute(
(player) => {
player.callMethodWithDelay("does.not.exist");
},
await player,
);

// [NA] Because of the delay, if we fetch immediately we *may* just get part of the log.
await browser.pause(200);
Expand All @@ -283,12 +298,15 @@ log called with 1 argument
});

it("doesn't enforce Strict Mode", async () => {
const player = await browser.$("<ruffle-object>");
await browser.execute((player) => {
player.callMethodWithDelay(
"function(){return aPropertyThatDoesntExist = 'success!'}",
);
}, player);
const player = await browser.$("ruffle-object");
await browser.execute(
(player) => {
player.callMethodWithDelay(
"function(){return aPropertyThatDoesntExist = 'success!'}",
);
},
await player,
);

// [NA] Because of the delay, if we fetch immediately we *may* just get part of the log.
await browser.pause(200);
Expand All @@ -305,7 +323,7 @@ log called with 1 argument
});

it("allows overriding a Ruffle method", async () => {
const player = await browser.$("<ruffle-object>");
const player = await browser.$("ruffle-object");
await browser.execute((player) => {
player.addAnotherCallback("isPlaying", "isPlaying from EI");
}, player);
Expand All @@ -325,7 +343,7 @@ log called with 1 argument
});

it("allows redefining a method", async () => {
const player = await browser.$("<ruffle-object>");
const player = await browser.$("ruffle-object");

// First definition
await browser.execute((player) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ describe("Flash inside frame with injected ruffle", () => {
it("polyfills inside a frame", async () => {
await injectRuffleAndWait(browser);
await browser.switchToFrame(await browser.$("#test-frame"));
await browser.$("<ruffle-object />").waitForExist();
await browser.$("ruffle-object").waitForExist();

const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.getHTML({ includeSelectorTag: false, pierceShadowRoot: false });
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
Expand All @@ -39,11 +39,11 @@ describe("Flash inside frame with injected ruffle", () => {
// And finally, check
await browser.switchToFrame(null);
await browser.switchToFrame(await browser.$("#test-frame"));
await browser.$("<ruffle-object />").waitForExist();
await browser.$("ruffle-object").waitForExist();

const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.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
Expand Up @@ -12,11 +12,11 @@ describe("Flash inside frame with provided ruffle", () => {

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

const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.getHTML({ includeSelectorTag: false, pierceShadowRoot: false });
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
Expand All @@ -38,11 +38,11 @@ describe("Flash inside frame with provided ruffle", () => {
// And finally, check
await browser.switchToFrame(null);
await browser.switchToFrame(await browser.$("#test-frame"));
await browser.$("<ruffle-object />").waitForExist();
await browser.$("ruffle-object").waitForExist();

const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.getHTML({ includeSelectorTag: false, pierceShadowRoot: false });
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
Expand Down
4 changes: 2 additions & 2 deletions web/packages/selfhosted/test/polyfill/embed_default/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("Embed tag", () => {
await injectRuffleAndWait(browser);
const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.getHTML({ includeSelectorTag: false, pierceShadowRoot: false });
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
Expand All @@ -25,7 +25,7 @@ describe("Embed tag", () => {
it("Plays a movie", async () => {
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-embed />"),
await browser.$("#test-container").$("ruffle-embed"),
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ describe("Embed with case-insensitive MIME type", () => {

it("Polyfills", async () => {
await injectRuffleAndWait(browser);
await browser.$("<ruffle-embed />").waitForExist();
await browser.$("ruffle-embed").waitForExist();

const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.getHTML({ includeSelectorTag: false, pierceShadowRoot: false });
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
Expand All @@ -27,7 +27,7 @@ describe("Embed with case-insensitive MIME type", () => {
it("Plays a movie", async () => {
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-embed />"),
await browser.$("#test-container").$("ruffle-embed"),
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("Embed inside audio node", () => {
await injectRuffleAndWait(browser);
const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.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
Expand Up @@ -14,7 +14,7 @@ describe("Embed without src attribute", () => {
await injectRuffleAndWait(browser);
const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.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
Expand Up @@ -14,7 +14,7 @@ describe("Embed without type attribute", () => {
await injectRuffleAndWait(browser);
const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.getHTML({ includeSelectorTag: false, pierceShadowRoot: false });
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
Expand All @@ -25,7 +25,7 @@ describe("Embed without type attribute", () => {
it("Plays a movie", async () => {
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-embed />"),
await browser.$("#test-container").$("ruffle-embed"),
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("Embed with unexpected string", () => {
await injectRuffleAndWait(browser);
const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.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
Expand Up @@ -14,7 +14,7 @@ describe("Embed with wrong type attribute value", () => {
await injectRuffleAndWait(browser);
const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.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
Expand Up @@ -14,7 +14,7 @@ describe("Embed with Flash YouTube video", () => {
await injectRuffleAndWait(browser);
const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.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
Expand Up @@ -13,11 +13,11 @@ describe("Flash inside iframe with injected ruffle", () => {
it("polyfills inside an iframe", async () => {
await injectRuffleAndWait(browser);
await browser.switchToFrame(await browser.$("#test-frame"));
await browser.$("<ruffle-object />").waitForExist();
await browser.$("ruffle-object").waitForExist();

const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.getHTML({ includeSelectorTag: false, pierceShadowRoot: false });
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
Expand All @@ -38,11 +38,11 @@ describe("Flash inside iframe with injected ruffle", () => {
// And finally, check
await browser.switchToFrame(null);
await browser.switchToFrame(await browser.$("#test-frame"));
await browser.$("<ruffle-object />").waitForExist();
await browser.$("ruffle-object").waitForExist();

const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.getHTML({ includeSelectorTag: false, pierceShadowRoot: false });
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
Expand Down
4 changes: 2 additions & 2 deletions web/packages/selfhosted/test/polyfill/iframes_onload/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ describe("iframe onload", () => {

it("runs the iframe onload event", async () => {
await injectRuffleAndWait(browser);
await browser.$("<div />").waitForExist();
await browser.$("div").waitForExist();

const actual = await browser
.$("#container")
.getHTML({ includeSelectorTag: false });
.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
Expand Up @@ -12,11 +12,11 @@ describe("Flash inside iframe with provided ruffle", () => {

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

const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.getHTML({ includeSelectorTag: false, pierceShadowRoot: false });
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
Expand All @@ -37,11 +37,11 @@ describe("Flash inside iframe with provided ruffle", () => {
// And finally, check
await browser.switchToFrame(null);
await browser.switchToFrame(await browser.$("#test-frame"));
await browser.$("<ruffle-object />").waitForExist();
await browser.$("ruffle-object").waitForExist();

const actual = await browser
.$("#test-container")
.getHTML({ includeSelectorTag: false });
.getHTML({ includeSelectorTag: false, pierceShadowRoot: false });
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
Expand Down
Loading

0 comments on commit a067ead

Please sign in to comment.