From bffa2e8efd719c65561550b8c871dd666f70541f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=96R=C3=96K=20Attila?= Date: Thu, 4 Apr 2024 23:01:36 +0200 Subject: [PATCH] web: Port the selfhosted package to modules --- web/packages/selfhosted/.eslintrc.yaml | 2 ++ web/packages/selfhosted/js/.eslintrc.yaml | 2 -- web/packages/selfhosted/package.json | 1 + .../integration_tests/keyboard_input/test.js | 8 ++++---- web/packages/selfhosted/test/js_api/load.js | 6 +++--- .../selfhosted/test/js_api/metadata.js | 6 +++--- .../polyfill/classic_frames_injected/test.js | 20 ++++++++++++------- .../polyfill/classic_frames_provided/test.js | 20 ++++++++++++------- .../polyfill/crossorigin_broken_cors/test.js | 19 +++++++++--------- .../test/polyfill/embed_default/test.js | 19 +++++++++--------- .../test/polyfill/embed_insensitive/test.js | 19 +++++++++--------- .../test/polyfill/embed_inside_audio/test.js | 15 ++++++++------ .../test/polyfill/embed_missing_src/test.js | 15 ++++++++------ .../test/polyfill/embed_missing_type/test.js | 19 +++++++++--------- .../polyfill/embed_unexpected_string/test.js | 15 ++++++++------ .../test/polyfill/embed_wrong_type/test.js | 15 ++++++++------ .../test/polyfill/embed_youtube/test.js | 15 ++++++++------ .../test/polyfill/iframes_injected/test.js | 20 ++++++++++++------- .../test/polyfill/iframes_onload/test.js | 15 ++++++++------ .../test/polyfill/iframes_provided/test.js | 20 ++++++++++++------- .../polyfill/object_MIME_insensitive/test.js | 19 +++++++++--------- .../polyfill/object_clsid_insensitive/test.js | 19 +++++++++--------- .../polyfill/object_clsid_with_embed/test.js | 19 +++++++++--------- .../test/polyfill/object_data/test.js | 19 +++++++++--------- .../test/polyfill/object_default/test.js | 19 +++++++++--------- .../polyfill/object_double_object/test.js | 19 +++++++++--------- .../object_double_object_classid/test.js | 19 +++++++++--------- .../test/polyfill/object_flashvars/test.js | 19 +++++++++--------- .../polyfill/object_flashvars_in_url/test.js | 19 +++++++++--------- .../test/polyfill/object_ie_only/test.js | 19 +++++++++--------- .../test/polyfill/object_inside_audio/test.js | 15 ++++++++------ .../test/polyfill/object_missing_data/test.js | 15 ++++++++------ .../test/polyfill/object_missing_type/test.js | 19 +++++++++--------- .../object_missing_type_and_classid/test.js | 19 +++++++++--------- .../polyfill/object_unexpected_string/test.js | 19 +++++++++--------- .../polyfill/object_with_ruffle_embed/test.js | 15 ++++++++------ .../test/polyfill/object_wrong_type/test.js | 19 +++++++++--------- .../test/polyfill/object_youtube/test.js | 15 ++++++++------ .../selfhosted/test/polyfill/pdf/test.js | 15 ++++++++------ .../test/polyfill/pdf_with_get/test.js | 15 ++++++++------ .../test/polyfill/remove_object/test.js | 15 ++++++++------ .../selfhosted/test/polyfill/spl/test.js | 15 ++++++++------ .../swf_extension_insensitive/test.js | 19 +++++++++--------- .../swf_extension_with_fragment/test.js | 19 +++++++++--------- .../polyfill/swf_extension_with_get/test.js | 19 +++++++++--------- web/packages/selfhosted/test/utils.js | 6 +++--- web/packages/selfhosted/wdio.conf.js | 2 +- web/packages/selfhosted/webpack.config.js | 20 +++++++++---------- 48 files changed, 394 insertions(+), 348 deletions(-) create mode 100644 web/packages/selfhosted/.eslintrc.yaml diff --git a/web/packages/selfhosted/.eslintrc.yaml b/web/packages/selfhosted/.eslintrc.yaml new file mode 100644 index 000000000000..add5a7856f31 --- /dev/null +++ b/web/packages/selfhosted/.eslintrc.yaml @@ -0,0 +1,2 @@ +parserOptions: + sourceType: module diff --git a/web/packages/selfhosted/js/.eslintrc.yaml b/web/packages/selfhosted/js/.eslintrc.yaml index 8a396409957a..5c9fc4c25534 100644 --- a/web/packages/selfhosted/js/.eslintrc.yaml +++ b/web/packages/selfhosted/js/.eslintrc.yaml @@ -1,4 +1,2 @@ env: browser: true -parserOptions: - sourceType: module diff --git a/web/packages/selfhosted/package.json b/web/packages/selfhosted/package.json index 7fbc76830f27..e2f287b8bed5 100644 --- a/web/packages/selfhosted/package.json +++ b/web/packages/selfhosted/package.json @@ -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" diff --git a/web/packages/selfhosted/test/integration_tests/keyboard_input/test.js b/web/packages/selfhosted/test/integration_tests/keyboard_input/test.js index 96b5c6021ec0..8cc41467e87a 100644 --- a/web/packages/selfhosted/test/integration_tests/keyboard_input/test.js +++ b/web/packages/selfhosted/test/integration_tests/keyboard_input/test.js @@ -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); diff --git a/web/packages/selfhosted/test/js_api/load.js b/web/packages/selfhosted/test/js_api/load.js index 66f5681ca07b..d6feb9f2f588 100644 --- a/web/packages/selfhosted/test/js_api/load.js +++ b/web/packages/selfhosted/test/js_api/load.js @@ -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); diff --git a/web/packages/selfhosted/test/js_api/metadata.js b/web/packages/selfhosted/test/js_api/metadata.js index d12a621a3f12..b40f075cfbb5 100644 --- a/web/packages/selfhosted/test/js_api/metadata.js +++ b/web/packages/selfhosted/test/js_api/metadata.js @@ -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); diff --git a/web/packages/selfhosted/test/polyfill/classic_frames_injected/test.js b/web/packages/selfhosted/test/polyfill/classic_frames_injected/test.js index f80331a13413..bc186d1b2b5c 100644 --- a/web/packages/selfhosted/test/polyfill/classic_frames_injected/test.js +++ b/web/packages/selfhosted/test/polyfill/classic_frames_injected/test.js @@ -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 () => { @@ -16,7 +16,10 @@ describe("Flash inside frame with injected ruffle", () => { await browser.$("").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); }); @@ -37,7 +40,10 @@ describe("Flash inside frame with injected ruffle", () => { await browser.$("").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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/classic_frames_provided/test.js b/web/packages/selfhosted/test/polyfill/classic_frames_provided/test.js index 0d50f9c7e9c5..dbebfbab4955 100644 --- a/web/packages/selfhosted/test/polyfill/classic_frames_provided/test.js +++ b/web/packages/selfhosted/test/polyfill/classic_frames_provided/test.js @@ -1,13 +1,13 @@ -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 () => { @@ -15,7 +15,10 @@ describe("Flash inside frame with provided ruffle", () => { await browser.$("").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); }); @@ -36,7 +39,10 @@ describe("Flash inside frame with provided ruffle", () => { await browser.$("").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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/crossorigin_broken_cors/test.js b/web/packages/selfhosted/test/polyfill/crossorigin_broken_cors/test.js index df85a9b45164..f18343fb0ab7 100644 --- a/web/packages/selfhosted/test/polyfill/crossorigin_broken_cors/test.js +++ b/web/packages/selfhosted/test/polyfill/crossorigin_broken_cors/test.js @@ -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); }); diff --git a/web/packages/selfhosted/test/polyfill/embed_default/test.js b/web/packages/selfhosted/test/polyfill/embed_default/test.js index 520974191b3a..4ce51f9f1af4 100644 --- a/web/packages/selfhosted/test/polyfill/embed_default/test.js +++ b/web/packages/selfhosted/test/polyfill/embed_default/test.js @@ -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); }); diff --git a/web/packages/selfhosted/test/polyfill/embed_insensitive/test.js b/web/packages/selfhosted/test/polyfill/embed_insensitive/test.js index d1ab65a6797d..02af7f947991 100644 --- a/web/packages/selfhosted/test/polyfill/embed_insensitive/test.js +++ b/web/packages/selfhosted/test/polyfill/embed_insensitive/test.js @@ -1,17 +1,13 @@ -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 () => { @@ -19,7 +15,10 @@ describe("Embed with case-insensitive MIME type", () => { await browser.$("").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); }); diff --git a/web/packages/selfhosted/test/polyfill/embed_inside_audio/test.js b/web/packages/selfhosted/test/polyfill/embed_inside_audio/test.js index c1524d6fa96e..edeecc6fd725 100644 --- a/web/packages/selfhosted/test/polyfill/embed_inside_audio/test.js +++ b/web/packages/selfhosted/test/polyfill/embed_inside_audio/test.js @@ -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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/embed_missing_src/test.js b/web/packages/selfhosted/test/polyfill/embed_missing_src/test.js index 8e503f310194..8ab6344cbb4c 100644 --- a/web/packages/selfhosted/test/polyfill/embed_missing_src/test.js +++ b/web/packages/selfhosted/test/polyfill/embed_missing_src/test.js @@ -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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/embed_missing_type/test.js b/web/packages/selfhosted/test/polyfill/embed_missing_type/test.js index e56059f83bf3..bbbf13eb9e63 100644 --- a/web/packages/selfhosted/test/polyfill/embed_missing_type/test.js +++ b/web/packages/selfhosted/test/polyfill/embed_missing_type/test.js @@ -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); }); diff --git a/web/packages/selfhosted/test/polyfill/embed_unexpected_string/test.js b/web/packages/selfhosted/test/polyfill/embed_unexpected_string/test.js index 8b51128fd2ce..77551f8bb70a 100644 --- a/web/packages/selfhosted/test/polyfill/embed_unexpected_string/test.js +++ b/web/packages/selfhosted/test/polyfill/embed_unexpected_string/test.js @@ -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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/embed_wrong_type/test.js b/web/packages/selfhosted/test/polyfill/embed_wrong_type/test.js index 2613b0cb457e..5bfd026bd277 100644 --- a/web/packages/selfhosted/test/polyfill/embed_wrong_type/test.js +++ b/web/packages/selfhosted/test/polyfill/embed_wrong_type/test.js @@ -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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/embed_youtube/test.js b/web/packages/selfhosted/test/polyfill/embed_youtube/test.js index 0d97827433c8..62fac449e70e 100644 --- a/web/packages/selfhosted/test/polyfill/embed_youtube/test.js +++ b/web/packages/selfhosted/test/polyfill/embed_youtube/test.js @@ -1,19 +1,22 @@ -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("Embed with Flash YouTube video", () => { 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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/iframes_injected/test.js b/web/packages/selfhosted/test/polyfill/iframes_injected/test.js index 2cb80ca2372d..0cdf31623997 100644 --- a/web/packages/selfhosted/test/polyfill/iframes_injected/test.js +++ b/web/packages/selfhosted/test/polyfill/iframes_injected/test.js @@ -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 iframe with injected ruffle", () => { it("loads the test", async () => { - await openTest(browser, __dirname); + await openTest(browser, import.meta.dirname); }); it("polyfills inside an iframe", async () => { @@ -16,7 +16,10 @@ describe("Flash inside iframe with injected ruffle", () => { await browser.$("").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); }); @@ -36,7 +39,10 @@ describe("Flash inside iframe with injected ruffle", () => { await browser.$("").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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/iframes_onload/test.js b/web/packages/selfhosted/test/polyfill/iframes_onload/test.js index 70ff3862d91b..9a8400d3d3e3 100644 --- a/web/packages/selfhosted/test/polyfill/iframes_onload/test.js +++ b/web/packages/selfhosted/test/polyfill/iframes_onload/test.js @@ -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("iframe onload", () => { it("loads the test", async () => { - await openTest(browser, __dirname); + await openTest(browser, import.meta.dirname); }); it("runs the iframe onload event", async () => { @@ -15,7 +15,10 @@ describe("iframe onload", () => { await browser.$("
").waitForExist(); const actual = await browser.$("#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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/iframes_provided/test.js b/web/packages/selfhosted/test/polyfill/iframes_provided/test.js index 67e54dbadba2..5e0911a6ec30 100644 --- a/web/packages/selfhosted/test/polyfill/iframes_provided/test.js +++ b/web/packages/selfhosted/test/polyfill/iframes_provided/test.js @@ -1,13 +1,13 @@ -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 iframe with provided ruffle", () => { it("loads the test", async () => { - await openTest(browser, __dirname); + await openTest(browser, import.meta.dirname); }); it("polyfills inside an iframe", async () => { @@ -15,7 +15,10 @@ describe("Flash inside iframe with provided ruffle", () => { await browser.$("").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); }); @@ -35,7 +38,10 @@ describe("Flash inside iframe with provided ruffle", () => { await browser.$("").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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/object_MIME_insensitive/test.js b/web/packages/selfhosted/test/polyfill/object_MIME_insensitive/test.js index 69e8b5fa299d..06d5021d9047 100644 --- a/web/packages/selfhosted/test/polyfill/object_MIME_insensitive/test.js +++ b/web/packages/selfhosted/test/polyfill/object_MIME_insensitive/test.js @@ -1,17 +1,13 @@ -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("Object with case-insensitive MIME type", () => { it("loads the test", async () => { - await openTest(browser, __dirname); + await openTest(browser, import.meta.dirname); }); it("Polyfills", async () => { @@ -19,7 +15,10 @@ describe("Object with case-insensitive MIME type", () => { await browser.$("").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); }); diff --git a/web/packages/selfhosted/test/polyfill/object_clsid_insensitive/test.js b/web/packages/selfhosted/test/polyfill/object_clsid_insensitive/test.js index 2d8cf87f6840..e92810fea892 100644 --- a/web/packages/selfhosted/test/polyfill/object_clsid_insensitive/test.js +++ b/web/packages/selfhosted/test/polyfill/object_clsid_insensitive/test.js @@ -1,17 +1,13 @@ -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("Object with case-insensitive clsid", () => { it("loads the test", async () => { - await openTest(browser, __dirname); + await openTest(browser, import.meta.dirname); }); it("Polyfills", async () => { @@ -19,7 +15,10 @@ describe("Object with case-insensitive clsid", () => { await browser.$("").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); }); diff --git a/web/packages/selfhosted/test/polyfill/object_clsid_with_embed/test.js b/web/packages/selfhosted/test/polyfill/object_clsid_with_embed/test.js index c8d44afa7834..5ed67388b36f 100644 --- a/web/packages/selfhosted/test/polyfill/object_clsid_with_embed/test.js +++ b/web/packages/selfhosted/test/polyfill/object_clsid_with_embed/test.js @@ -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("Object with clsid and embed", () => { 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); }); diff --git a/web/packages/selfhosted/test/polyfill/object_data/test.js b/web/packages/selfhosted/test/polyfill/object_data/test.js index 5b4435e70854..c5143c6a81a4 100644 --- a/web/packages/selfhosted/test/polyfill/object_data/test.js +++ b/web/packages/selfhosted/test/polyfill/object_data/test.js @@ -1,17 +1,13 @@ -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("Object with only data attribute", () => { it("loads the test", async () => { - await openTest(browser, __dirname); + await openTest(browser, import.meta.dirname); }); it("Polyfills", async () => { @@ -19,7 +15,10 @@ describe("Object with only data attribute", () => { await browser.$("").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); }); diff --git a/web/packages/selfhosted/test/polyfill/object_default/test.js b/web/packages/selfhosted/test/polyfill/object_default/test.js index 981e4f559218..1c0828376d2b 100644 --- a/web/packages/selfhosted/test/polyfill/object_default/test.js +++ b/web/packages/selfhosted/test/polyfill/object_default/test.js @@ -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("Object 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); }); diff --git a/web/packages/selfhosted/test/polyfill/object_double_object/test.js b/web/packages/selfhosted/test/polyfill/object_double_object/test.js index 18335bbbe470..7556f13c3412 100644 --- a/web/packages/selfhosted/test/polyfill/object_double_object/test.js +++ b/web/packages/selfhosted/test/polyfill/object_double_object/test.js @@ -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("Object with another object tag", () => { it("loads the test", async () => { - await openTest(browser, __dirname); + await openTest(browser, import.meta.dirname); }); it("polyfills only the first tag 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); }); diff --git a/web/packages/selfhosted/test/polyfill/object_double_object_classid/test.js b/web/packages/selfhosted/test/polyfill/object_double_object_classid/test.js index 846ef01d7d5a..3d5d71f6549d 100644 --- a/web/packages/selfhosted/test/polyfill/object_double_object_classid/test.js +++ b/web/packages/selfhosted/test/polyfill/object_double_object_classid/test.js @@ -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("Object using classid with another object tag without classid", () => { it("loads the test", async () => { - await openTest(browser, __dirname); + await openTest(browser, import.meta.dirname); }); it("polyfills only the second tag 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); }); diff --git a/web/packages/selfhosted/test/polyfill/object_flashvars/test.js b/web/packages/selfhosted/test/polyfill/object_flashvars/test.js index b51308f45495..df5107b68490 100644 --- a/web/packages/selfhosted/test/polyfill/object_flashvars/test.js +++ b/web/packages/selfhosted/test/polyfill/object_flashvars/test.js @@ -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("Object 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); }); diff --git a/web/packages/selfhosted/test/polyfill/object_flashvars_in_url/test.js b/web/packages/selfhosted/test/polyfill/object_flashvars_in_url/test.js index b51308f45495..df5107b68490 100644 --- a/web/packages/selfhosted/test/polyfill/object_flashvars_in_url/test.js +++ b/web/packages/selfhosted/test/polyfill/object_flashvars_in_url/test.js @@ -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("Object 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); }); diff --git a/web/packages/selfhosted/test/polyfill/object_ie_only/test.js b/web/packages/selfhosted/test/polyfill/object_ie_only/test.js index d153ac4c8cab..3b711622f116 100644 --- a/web/packages/selfhosted/test/polyfill/object_ie_only/test.js +++ b/web/packages/selfhosted/test/polyfill/object_ie_only/test.js @@ -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("Object for old IE must work everywhere", () => { 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); }); diff --git a/web/packages/selfhosted/test/polyfill/object_inside_audio/test.js b/web/packages/selfhosted/test/polyfill/object_inside_audio/test.js index 596add3ebf69..6a94c177b3b6 100644 --- a/web/packages/selfhosted/test/polyfill/object_inside_audio/test.js +++ b/web/packages/selfhosted/test/polyfill/object_inside_audio/test.js @@ -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("Object 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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/object_missing_data/test.js b/web/packages/selfhosted/test/polyfill/object_missing_data/test.js index 9f2bd9f39a1d..b3c6d44ccf2e 100644 --- a/web/packages/selfhosted/test/polyfill/object_missing_data/test.js +++ b/web/packages/selfhosted/test/polyfill/object_missing_data/test.js @@ -1,19 +1,22 @@ -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("Object without data 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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/object_missing_type/test.js b/web/packages/selfhosted/test/polyfill/object_missing_type/test.js index 7678af59b9fc..df75c08a45f0 100644 --- a/web/packages/selfhosted/test/polyfill/object_missing_type/test.js +++ b/web/packages/selfhosted/test/polyfill/object_missing_type/test.js @@ -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("Object 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); }); diff --git a/web/packages/selfhosted/test/polyfill/object_missing_type_and_classid/test.js b/web/packages/selfhosted/test/polyfill/object_missing_type_and_classid/test.js index d6a50aebdc54..55b9e66932bf 100644 --- a/web/packages/selfhosted/test/polyfill/object_missing_type_and_classid/test.js +++ b/web/packages/selfhosted/test/polyfill/object_missing_type_and_classid/test.js @@ -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("Object without type and classid attributes", () => { 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); }); diff --git a/web/packages/selfhosted/test/polyfill/object_unexpected_string/test.js b/web/packages/selfhosted/test/polyfill/object_unexpected_string/test.js index 57a1b3675aec..93701c1ff5ff 100644 --- a/web/packages/selfhosted/test/polyfill/object_unexpected_string/test.js +++ b/web/packages/selfhosted/test/polyfill/object_unexpected_string/test.js @@ -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("Object 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); }); diff --git a/web/packages/selfhosted/test/polyfill/object_with_ruffle_embed/test.js b/web/packages/selfhosted/test/polyfill/object_with_ruffle_embed/test.js index ad81d453da7e..5d298d213f72 100644 --- a/web/packages/selfhosted/test/polyfill/object_with_ruffle_embed/test.js +++ b/web/packages/selfhosted/test/polyfill/object_with_ruffle_embed/test.js @@ -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("Object with ruffle-embed tag", () => { it("loads the test", async () => { - await openTest(browser, __dirname); + await openTest(browser, import.meta.dirname); }); it("already polyfilled 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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/object_wrong_type/test.js b/web/packages/selfhosted/test/polyfill/object_wrong_type/test.js index 0fbc6be78712..0dd81f5209db 100644 --- a/web/packages/selfhosted/test/polyfill/object_wrong_type/test.js +++ b/web/packages/selfhosted/test/polyfill/object_wrong_type/test.js @@ -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("Object 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); }); diff --git a/web/packages/selfhosted/test/polyfill/object_youtube/test.js b/web/packages/selfhosted/test/polyfill/object_youtube/test.js index 68b5daa733ad..5c427c31b102 100644 --- a/web/packages/selfhosted/test/polyfill/object_youtube/test.js +++ b/web/packages/selfhosted/test/polyfill/object_youtube/test.js @@ -1,19 +1,22 @@ -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("Object with Flash YouTube video", () => { 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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/pdf/test.js b/web/packages/selfhosted/test/polyfill/pdf/test.js index a41487f2cebe..ec5ba9428e43 100644 --- a/web/packages/selfhosted/test/polyfill/pdf/test.js +++ b/web/packages/selfhosted/test/polyfill/pdf/test.js @@ -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("PDF object", () => { 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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/pdf_with_get/test.js b/web/packages/selfhosted/test/polyfill/pdf_with_get/test.js index afd5a7f53d67..fe495123166a 100644 --- a/web/packages/selfhosted/test/polyfill/pdf_with_get/test.js +++ b/web/packages/selfhosted/test/polyfill/pdf_with_get/test.js @@ -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("PDF with .swf GET", () => { 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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/remove_object/test.js b/web/packages/selfhosted/test/polyfill/remove_object/test.js index f1b14909e617..4d8e1df89ad4 100644 --- a/web/packages/selfhosted/test/polyfill/remove_object/test.js +++ b/web/packages/selfhosted/test/polyfill/remove_object/test.js @@ -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("Remove object", () => { 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); }); diff --git a/web/packages/selfhosted/test/polyfill/spl/test.js b/web/packages/selfhosted/test/polyfill/spl/test.js index 75215122063f..2b9d09f33c0a 100644 --- a/web/packages/selfhosted/test/polyfill/spl/test.js +++ b/web/packages/selfhosted/test/polyfill/spl/test.js @@ -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("SPL", () => { 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); }); }); diff --git a/web/packages/selfhosted/test/polyfill/swf_extension_insensitive/test.js b/web/packages/selfhosted/test/polyfill/swf_extension_insensitive/test.js index ac6f74d36c05..377c1a0d1c83 100644 --- a/web/packages/selfhosted/test/polyfill/swf_extension_insensitive/test.js +++ b/web/packages/selfhosted/test/polyfill/swf_extension_insensitive/test.js @@ -1,17 +1,13 @@ -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("SWF extension insensitive", () => { it("loads the test", async () => { - await openTest(browser, __dirname); + await openTest(browser, import.meta.dirname); }); it("Polyfills", async () => { @@ -19,7 +15,10 @@ describe("SWF extension insensitive", () => { await browser.$("").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); }); diff --git a/web/packages/selfhosted/test/polyfill/swf_extension_with_fragment/test.js b/web/packages/selfhosted/test/polyfill/swf_extension_with_fragment/test.js index 88c1684c8397..e5bf0280e170 100644 --- a/web/packages/selfhosted/test/polyfill/swf_extension_with_fragment/test.js +++ b/web/packages/selfhosted/test/polyfill/swf_extension_with_fragment/test.js @@ -1,17 +1,13 @@ -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("SWF extension, file with fragment", () => { it("loads the test", async () => { - await openTest(browser, __dirname); + await openTest(browser, import.meta.dirname); }); it("Polyfills", async () => { @@ -19,7 +15,10 @@ describe("SWF extension, file with fragment", () => { await browser.$("").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); }); diff --git a/web/packages/selfhosted/test/polyfill/swf_extension_with_get/test.js b/web/packages/selfhosted/test/polyfill/swf_extension_with_get/test.js index 1f159824ffbb..351d35e3ce65 100644 --- a/web/packages/selfhosted/test/polyfill/swf_extension_with_get/test.js +++ b/web/packages/selfhosted/test/polyfill/swf_extension_with_get/test.js @@ -1,17 +1,13 @@ -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("SWF extension, file with GET parameter", () => { it("loads the test", async () => { - await openTest(browser, __dirname); + await openTest(browser, import.meta.dirname); }); it("Polyfills", async () => { @@ -19,7 +15,10 @@ describe("SWF extension, file with GET parameter", () => { await browser.$("").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); }); diff --git a/web/packages/selfhosted/test/utils.js b/web/packages/selfhosted/test/utils.js index 8e4c596962ba..da330ff42042 100644 --- a/web/packages/selfhosted/test/utils.js +++ b/web/packages/selfhosted/test/utils.js @@ -1,5 +1,5 @@ -const path = require("path"); -const { expect } = require("chai"); +import path from "path"; +import { expect } from "chai"; async function isRuffleLoaded(browser) { return await browser.execute( @@ -151,7 +151,7 @@ function jsApiBefore(swf) { }); } -module.exports = { +export { isRuffleLoaded, waitForRuffle, playAndMonitor, diff --git a/web/packages/selfhosted/wdio.conf.js b/web/packages/selfhosted/wdio.conf.js index 08ecacb335ae..cc69f9bbb5ed 100644 --- a/web/packages/selfhosted/wdio.conf.js +++ b/web/packages/selfhosted/wdio.conf.js @@ -1,6 +1,6 @@ /* eslint-env node */ -exports.config = { +export const config = { // // ==================== // Runner Configuration diff --git a/web/packages/selfhosted/webpack.config.js b/web/packages/selfhosted/webpack.config.js index 74b293688314..011de5bdb105 100644 --- a/web/packages/selfhosted/webpack.config.js +++ b/web/packages/selfhosted/webpack.config.js @@ -1,12 +1,12 @@ /* eslint-env node */ -const path = require("path"); -const json5 = require("json5"); -const CopyPlugin = require("copy-webpack-plugin"); -const TerserPlugin = require("terser-webpack-plugin"); +import url from "url"; +import json5 from "json5"; +import CopyPlugin from "copy-webpack-plugin"; +import TerserPlugin from "terser-webpack-plugin"; function transformPackage(content) { - const package = json5.parse(content); + const pkg = json5.parse(content); const packageVersion = process.env.npm_package_version; @@ -19,15 +19,15 @@ function transformPackage(content) { // The npm registry requires the version to monotonically increase, // so append the build date onto the end of the package version. - package.version = + pkg.version = versionChannel !== "stable" ? `${packageVersion}-${versionChannel}.${buildDate}` : packageVersion; - return JSON.stringify(package); + return JSON.stringify(pkg); } -module.exports = (_env, _argv) => { +export default function (_env, _argv) { const mode = process.env.NODE_ENV || "production"; console.log(`Building ${mode}...`); @@ -35,7 +35,7 @@ module.exports = (_env, _argv) => { mode, entry: "./js/ruffle.js", output: { - path: path.resolve(__dirname, "dist"), + path: url.fileURLToPath(new URL("dist", import.meta.url)), filename: "ruffle.js", publicPath: "", chunkFilename: "core.ruffle.[contenthash].js", @@ -71,4 +71,4 @@ module.exports = (_env, _argv) => { }), ], }; -}; +}