Skip to content

Commit

Permalink
web: Port the selfhosted package to modules
Browse files Browse the repository at this point in the history
  • Loading branch information
torokati44 committed Apr 4, 2024
1 parent 4e40e15 commit 3dca3e7
Show file tree
Hide file tree
Showing 48 changed files with 394 additions and 348 deletions.
2 changes: 2 additions & 0 deletions web/packages/selfhosted/.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parserOptions:
sourceType: module
2 changes: 0 additions & 2 deletions web/packages/selfhosted/js/.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
env:
browser: true
parserOptions:
sourceType: module
1 change: 1 addition & 0 deletions web/packages/selfhosted/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Putting Flash back on the web. Ruffle will polyfill all Flash content and replace it with the Ruffle flash player.",
"license": "(MIT OR Apache-2.0)",
"private": true,
"type": "module",
"keywords": [
"flash",
"swf"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { jsApiBefore, getTraceOutput } = require("../../utils");
const { use, expect } = require("chai");
const chaiHtml = require("chai-html");
const { Key } = require("webdriverio");
import { jsApiBefore, getTraceOutput } from "../../utils.js";
import { use, expect } from "chai";
import chaiHtml from "chai-html";
import { Key } from "webdriverio";

use(chaiHtml);

Expand Down
6 changes: 3 additions & 3 deletions web/packages/selfhosted/test/js_api/load.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { jsApiBefore, playAndMonitor } = require("../utils");
const { use } = require("chai");
const chaiHtml = require("chai-html");
import { jsApiBefore, playAndMonitor } from "../utils.js";
import { use } from "chai";
import chaiHtml from "chai-html";

use(chaiHtml);

Expand Down
6 changes: 3 additions & 3 deletions web/packages/selfhosted/test/js_api/metadata.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { jsApiBefore } = require("../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
import { jsApiBefore } from "../utils.js";
import { expect, use } from "chai";
import chaiHtml from "chai-html";

use(chaiHtml);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const { openTest, injectRuffleAndWait } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
import { openTest, injectRuffleAndWait } from "../../utils.js";
import { expect, use } from "chai";
import chaiHtml from "chai-html";
import fs from "fs";

use(chaiHtml);

describe("Flash inside frame with injected ruffle", () => {
it("loads the test", async () => {
await openTest(browser, __dirname);
await openTest(browser, import.meta.dirname);
});

it("polyfills inside a frame", async () => {
Expand All @@ -16,7 +16,10 @@ describe("Flash inside frame with injected ruffle", () => {
await browser.$("<ruffle-object />").waitForExist();

const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
);
expect(actual).html.to.equal(expected);
});

Expand All @@ -37,7 +40,10 @@ describe("Flash inside frame with injected ruffle", () => {
await browser.$("<ruffle-object />").waitForExist();

const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
);
expect(actual).html.to.equal(expected);
});
});
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
const { openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
import { openTest } from "../../utils.js";
import { expect, use } from "chai";
import chaiHtml from "chai-html";
import fs from "fs";

use(chaiHtml);

describe("Flash inside frame with provided ruffle", () => {
it("loads the test", async () => {
await openTest(browser, __dirname);
await openTest(browser, import.meta.dirname);
});

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

const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
);
expect(actual).html.to.equal(expected);
});

Expand All @@ -36,7 +39,10 @@ describe("Flash inside frame with provided ruffle", () => {
await browser.$("<ruffle-object />").waitForExist();

const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
);
expect(actual).html.to.equal(expected);
});
});
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
const {
openTest,
injectRuffleAndWait,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
import { openTest, injectRuffleAndWait, playAndMonitor } from "../../utils.js";
import { expect, use } from "chai";
import chaiHtml from "chai-html";
import fs from "fs";

use(chaiHtml);

// [NA] Disabled for now as the test can take too long on CI
describe.skip("Doesn't error with cross-origin frames", () => {
it("Loads the test", async () => {
await openTest(browser, __dirname);
await openTest(browser, import.meta.dirname);
});

it("Polyfills with ruffle", async () => {
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
);
expect(actual).html.to.equal(expected);
});

Expand Down
19 changes: 9 additions & 10 deletions web/packages/selfhosted/test/polyfill/embed_default/test.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
const {
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
import { injectRuffleAndWait, openTest, playAndMonitor } from "../../utils.js";
import { expect, use } from "chai";
import chaiHtml from "chai-html";
import fs from "fs";

use(chaiHtml);

describe("Embed tag", () => {
it("loads the test", async () => {
await openTest(browser, __dirname);
await openTest(browser, import.meta.dirname);
});

it("polyfills with ruffle", async () => {
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
);
expect(actual).html.to.equal(expected);
});

Expand Down
19 changes: 9 additions & 10 deletions web/packages/selfhosted/test/polyfill/embed_insensitive/test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
const {
openTest,
injectRuffleAndWait,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
import { openTest, injectRuffleAndWait, playAndMonitor } from "../../utils.js";
import { expect, use } from "chai";
import chaiHtml from "chai-html";
import fs from "fs";

use(chaiHtml);

describe("Embed with case-insensitive MIME type", () => {
it("loads the test", async () => {
await openTest(browser, __dirname);
await openTest(browser, import.meta.dirname);
});

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

const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
);
expect(actual).html.to.equal(expected);
});

Expand Down
15 changes: 9 additions & 6 deletions web/packages/selfhosted/test/polyfill/embed_inside_audio/test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
const { injectRuffleAndWait, openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
import { injectRuffleAndWait, openTest } from "../../utils.js";
import { expect, use } from "chai";
import chaiHtml from "chai-html";
import fs from "fs";

use(chaiHtml);

describe("Embed inside audio node", () => {
it("loads the test", async () => {
await openTest(browser, __dirname);
await openTest(browser, import.meta.dirname);
});

it("doesn't polyfill with ruffle", async () => {
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
);
expect(actual).html.to.equal(expected);
});
});
15 changes: 9 additions & 6 deletions web/packages/selfhosted/test/polyfill/embed_missing_src/test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
const { injectRuffleAndWait, openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
import { injectRuffleAndWait, openTest } from "../../utils.js";
import { expect, use } from "chai";
import chaiHtml from "chai-html";
import fs from "fs";

use(chaiHtml);

describe("Embed without src attribute", () => {
it("loads the test", async () => {
await openTest(browser, __dirname);
await openTest(browser, import.meta.dirname);
});

it("doesn't polyfill with ruffle", async () => {
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
);
expect(actual).html.to.equal(expected);
});
});
19 changes: 9 additions & 10 deletions web/packages/selfhosted/test/polyfill/embed_missing_type/test.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
const {
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
import { injectRuffleAndWait, openTest, playAndMonitor } from "../../utils.js";
import { expect, use } from "chai";
import chaiHtml from "chai-html";
import fs from "fs";

use(chaiHtml);

describe("Embed without type attribute", () => {
it("loads the test", async () => {
await openTest(browser, __dirname);
await openTest(browser, import.meta.dirname);
});

it("polyfills with ruffle", async () => {
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
);
expect(actual).html.to.equal(expected);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
const { injectRuffleAndWait, openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
import { injectRuffleAndWait, openTest } from "../../utils.js";
import { expect, use } from "chai";
import chaiHtml from "chai-html";
import fs from "fs";

use(chaiHtml);

describe("Embed with unexpected string", () => {
it("loads the test", async () => {
await openTest(browser, __dirname);
await openTest(browser, import.meta.dirname);
});

it("polyfills with ruffle", async () => {
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
);
expect(actual).html.to.equal(expected);
});
});
15 changes: 9 additions & 6 deletions web/packages/selfhosted/test/polyfill/embed_wrong_type/test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
const { injectRuffleAndWait, openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
import { injectRuffleAndWait, openTest } from "../../utils.js";
import { expect, use } from "chai";
import chaiHtml from "chai-html";
import fs from "fs";

use(chaiHtml);

describe("Embed with wrong type attribute value", () => {
it("loads the test", async () => {
await openTest(browser, __dirname);
await openTest(browser, import.meta.dirname);
});

it("polyfills with ruffle", async () => {
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
const expected = fs.readFileSync(
`${import.meta.dirname}/expected.html`,
"utf8",
);
expect(actual).html.to.equal(expected);
});
});

0 comments on commit 3dca3e7

Please sign in to comment.