web: Enforce ESLint's `camelcase` rule

This commit is contained in:
relrelb 2023-05-30 23:24:43 +03:00
parent 5d3544ddc7
commit 17e0eb112b
50 changed files with 275 additions and 282 deletions

View File

@ -5,6 +5,11 @@ extends:
- eslint:recommended
- plugin:prettier/recommended
rules:
camelcase:
- error
- properties: never
allow:
- __webpack_public_path__
curly: error
eqeqeq: error
no-constructor-return: error

View File

@ -184,13 +184,14 @@ export class PublicAPI {
* Look up a specific Ruffle version (or any version satisfying a given set
* of requirements) and return it's API.
*
* @param ver_requirement A set of semantic version requirement
* @param requirementString A set of semantic version requirement
* strings that the player version must satisfy.
* @returns An instance of the Source API, if one or more
* sources satisfied the requirement.
*/
satisfying(ver_requirement: string): typeof SourceAPI | null {
const requirement = VersionRange.fromRequirementString(ver_requirement);
satisfying(requirementString: string): typeof SourceAPI | null {
const requirement =
VersionRange.fromRequirementString(requirementString);
let valid = null;
for (const k in this.sources) {

View File

@ -2145,20 +2145,19 @@ export function isBuiltInContextMenuVisible(menu: string | null): boolean {
export function isYoutubeFlashSource(filename: string | null): boolean {
if (filename) {
let pathname = "";
let cleaned_hostname = "";
let hostname = "";
try {
// A base URL is required if `filename` is a relative URL, but we don't need to detect the real URL origin.
const url = new URL(filename, RUFFLE_ORIGIN);
pathname = url.pathname;
cleaned_hostname = url.hostname.replace("www.", "");
hostname = url.hostname.replace("www.", "");
} catch (err) {
// Some invalid filenames, like `///`, could raise a TypeError. Let's fail silently in this situation.
}
// See https://wiki.mozilla.org/QA/Youtube_Embedded_Rewrite
if (
pathname.startsWith("/v/") &&
(cleaned_hostname === "youtube.com" ||
cleaned_hostname === "youtube-nocookie.com")
(hostname === "youtube.com" || hostname === "youtube-nocookie.com")
) {
return true;
}
@ -2176,16 +2175,16 @@ export function workaroundYoutubeMixedContent(
elem: Element,
attr: string
): void {
const elem_attr = elem.getAttribute(attr);
const window_config = window.RufflePlayer?.config ?? {};
if (elem_attr) {
const value = elem.getAttribute(attr);
const config = window.RufflePlayer?.config ?? {};
if (value) {
try {
const url = new URL(elem_attr);
const url = new URL(value);
if (
url.protocol === "http:" &&
window.location.protocol === "https:" &&
(!("upgradeToHttps" in window_config) ||
window_config.upgradeToHttps !== false)
(!("upgradeToHttps" in config) ||
config.upgradeToHttps !== false)
) {
url.protocol = "https:";
elem.setAttribute(attr, url.toString());

View File

@ -1,7 +1,7 @@
const replace = require("replace-in-file");
const fs = require("fs");
const bundled_texts = {};
const bundledTexts = {};
const locales = [];
fs.readdirSync("texts", { withFileTypes: true }).forEach((entry) => {
@ -25,9 +25,9 @@ locales.forEach((locale) => {
);
files.sort();
if (files.length > 0) {
bundled_texts[locale] = {};
bundledTexts[locale] = {};
files.forEach((filename) => {
bundled_texts[locale][filename] = fs
bundledTexts[locale][filename] = fs
.readFileSync("texts/" + locale + "/" + filename, "utf8")
.replaceAll("\r\n", "\n");
});
@ -37,7 +37,7 @@ locales.forEach((locale) => {
const options = {
files: "dist/**",
from: [/\{\s*\/\*\s*%BUNDLED_TEXTS%\s*\*\/\s*}/g],
to: [JSON.stringify(bundled_texts, null, 2)],
to: [JSON.stringify(bundledTexts, null, 2)],
};
replace.sync(options);

View File

@ -2,10 +2,10 @@ const replace = require("replace-in-file");
const childProcess = require("child_process");
const fs = require("fs");
let version_number = process.env.npm_package_version;
let version_channel = process.env.CFG_RELEASE_CHANNEL || "nightly";
let build_date = new Date().toISOString();
const firefox_extension_id =
let versionNumber = process.env.npm_package_version;
let versionChannel = process.env.CFG_RELEASE_CHANNEL || "nightly";
let buildDate = new Date().toISOString();
const firefoxExtensionId =
process.env.FIREFOX_EXTENSION_ID || "ruffle@ruffle.rs";
let commitHash = "unknown";
@ -16,35 +16,35 @@ try {
console.log("Couldn't fetch latest git commit...");
}
let version_name =
version_channel === "nightly"
? `nightly ${build_date.substr(0, 10)}`
let versionName =
versionChannel === "nightly"
? `nightly ${buildDate.substr(0, 10)}`
: process.env.npm_package_version;
let version_seal = {};
let versionSeal = {};
if (process.env.ENABLE_VERSION_SEAL === "true") {
if (fs.existsSync("version_seal.json")) {
// Using the version seal stored previously.
version_seal = JSON.parse(fs.readFileSync("version_seal.json"));
versionSeal = JSON.parse(fs.readFileSync("version_seal.json"));
version_number = version_seal.version_number;
version_name = version_seal.version_name;
version_channel = version_seal.version_channel;
build_date = version_seal.build_date;
commitHash = version_seal.commitHash;
versionNumber = versionSeal.version_number;
versionName = versionSeal.version_name;
versionChannel = versionSeal.version_channel;
buildDate = versionSeal.build_date;
commitHash = versionSeal.commitHash;
} else {
version_seal = {
version_number: version_number,
version_name: version_name,
version_channel: version_channel,
build_date: build_date,
versionSeal = {
version_number: versionNumber,
version_name: versionName,
version_channel: versionChannel,
build_date: buildDate,
commitHash: commitHash,
build_id: process.env.BUILD_ID,
firefox_extension_id: firefox_extension_id,
firefox_extension_id: firefoxExtensionId,
};
fs.writeFileSync("version_seal.json", JSON.stringify(version_seal));
fs.writeFileSync("version_seal.json", JSON.stringify(versionSeal));
}
}
@ -57,7 +57,7 @@ const options = {
/%BUILD_DATE%/g,
/%COMMIT_HASH%/g,
],
to: [version_number, version_name, version_channel, build_date, commitHash],
to: [versionNumber, versionName, versionChannel, buildDate, commitHash],
};
replace.sync(options);

View File

@ -3,7 +3,7 @@ import fs from "fs";
// Search-and-replace the manual polyfill injection with the actual code it
// needs to insert.
const plugin_polyfill_source = fs
const pluginPolyfillSource = fs
.readFileSync("assets/dist/pluginPolyfill.js", "utf8")
.replaceAll("\r", "\\r")
.replaceAll("\n", "\\n")
@ -12,5 +12,5 @@ const plugin_polyfill_source = fs
replace.sync({
files: "./assets/dist/content.js",
from: [/%PLUGIN_POLYFILL_SOURCE%/g],
to: plugin_polyfill_source,
to: pluginPolyfillSource,
});

View File

@ -16,21 +16,21 @@ function transformManifest(content, env) {
let packageVersion = process.env["npm_package_version"];
let versionChannel = process.env["CFG_RELEASE_CHANNEL"] || "nightly";
let buildDate = new Date().toISOString().substring(0, 10);
let build_id = process.env["BUILD_ID"];
let firefox_extension_id =
let buildId = process.env["BUILD_ID"];
let firefoxExtensionId =
process.env["FIREFOX_EXTENSION_ID"] || "ruffle@ruffle.rs";
if (process.env["ENABLE_VERSION_SEAL"] === "true") {
if (fs.existsSync("../../version_seal.json")) {
const version_seal = JSON.parse(
const versionSeal = JSON.parse(
fs.readFileSync("../../version_seal.json", "utf8")
);
packageVersion = version_seal.version_number;
versionChannel = version_seal.version_channel;
buildDate = version_seal.build_date.substring(0, 10);
build_id = version_seal.build_id;
firefox_extension_id = version_seal.firefox_extension_id;
packageVersion = versionSeal.version_number;
versionChannel = versionSeal.version_channel;
buildDate = versionSeal.build_date.substring(0, 10);
buildId = versionSeal.build_id;
firefoxExtensionId = versionSeal.firefox_extension_id;
} else {
throw new Error(
"Version seal requested but not found. Please run web/packages/core/tools/set_version.js with ENABLE_VERSION_SEAL to generate it."
@ -45,14 +45,14 @@ function transformManifest(content, env) {
// The extension marketplaces require the version to monotonically increase,
// so append the build number onto the end of the manifest version.
manifest.version = build_id
? `${packageVersion}.${build_id}`
manifest.version = buildId
? `${packageVersion}.${buildId}`
: packageVersion;
if (env["firefox"]) {
manifest.browser_specific_settings = {
gecko: {
id: firefox_extension_id,
id: firefoxExtensionId,
},
};
} else {

View File

@ -1,17 +1,17 @@
const { js_api_before, play_and_monitor } = require("../utils");
const { jsApiBefore, playAndMonitor } = require("../utils");
const { use } = require("chai");
const chaiHtml = require("chai-html");
use(chaiHtml);
describe("RufflePlayer.load", () => {
js_api_before();
jsApiBefore();
it("loads and plays a URL", async () => {
const player = await browser.$("<ruffle-player>");
await browser.execute((player) => {
player.load("/test_assets/example.swf");
}, player);
await play_and_monitor(browser, player);
await playAndMonitor(browser, player);
});
});

View File

@ -1,11 +1,11 @@
const { js_api_before } = require("../utils");
const { jsApiBefore } = require("../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
use(chaiHtml);
describe("RufflePlayer.metadata", () => {
js_api_before("/test_assets/example.swf");
jsApiBefore("/test_assets/example.swf");
it("has metadata after load", async () => {
const player = await browser.$("<ruffle-player>");

View File

@ -1,4 +1,4 @@
const { open_test, inject_ruffle_and_wait } = require("../../utils");
const { openTest, injectRuffleAndWait } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("Flash inside frame with injected ruffle", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills inside a frame", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
await browser.switchToFrame(await browser.$("#test-frame"));
await browser.$("<ruffle-object />").waitForExist();

View File

@ -1,4 +1,4 @@
const { open_test } = require("../../utils");
const { openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,7 +7,7 @@ use(chaiHtml);
describe("Flash inside frame with provided ruffle", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills inside a frame", async () => {

View File

@ -1,7 +1,7 @@
const {
open_test,
inject_ruffle_and_wait,
play_and_monitor,
openTest,
injectRuffleAndWait,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -12,18 +12,18 @@ 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 open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("Polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-embed />")
);

View File

@ -1,7 +1,7 @@
const {
inject_ruffle_and_wait,
open_test,
play_and_monitor,
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,18 +11,18 @@ use(chaiHtml);
describe("Embed tag", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-embed />")
);

View File

@ -1,7 +1,7 @@
const {
open_test,
inject_ruffle_and_wait,
play_and_monitor,
openTest,
injectRuffleAndWait,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,11 +11,11 @@ use(chaiHtml);
describe("Embed with case-insensitive MIME type", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("Polyfills", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
await browser.$("<ruffle-embed />").waitForExist();
const actual = await browser.$("#test-container").getHTML(false);
@ -24,7 +24,7 @@ describe("Embed with case-insensitive MIME type", () => {
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-embed />")
);

View File

@ -1,4 +1,4 @@
const { inject_ruffle_and_wait, open_test } = require("../../utils");
const { injectRuffleAndWait, openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("Embed inside audio node", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("doesn't polyfill with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);

View File

@ -1,4 +1,4 @@
const { inject_ruffle_and_wait, open_test } = require("../../utils");
const { injectRuffleAndWait, openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("Embed without src attribute", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("doesn't polyfill with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);

View File

@ -1,7 +1,7 @@
const {
inject_ruffle_and_wait,
open_test,
play_and_monitor,
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,18 +11,18 @@ use(chaiHtml);
describe("Embed without type attribute", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-embed />")
);

View File

@ -1,4 +1,4 @@
const { inject_ruffle_and_wait, open_test } = require("../../utils");
const { injectRuffleAndWait, openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("Embed with unexpected string", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);

View File

@ -1,4 +1,4 @@
const { inject_ruffle_and_wait, open_test } = require("../../utils");
const { injectRuffleAndWait, openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("Embed with wrong type attribute value", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);

View File

@ -1,4 +1,4 @@
const { open_test, inject_ruffle_and_wait } = require("../../utils");
const { openTest, injectRuffleAndWait } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("Embed with Flash YouTube video", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("doesn't polyfill with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);

View File

@ -1,4 +1,4 @@
const { open_test, inject_ruffle_and_wait } = require("../../utils");
const { openTest, injectRuffleAndWait } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("Flash inside iframe with injected ruffle", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills inside an iframe", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
await browser.switchToFrame(await browser.$("#test-frame"));
await browser.$("<ruffle-object />").waitForExist();

View File

@ -1,4 +1,4 @@
const { open_test, inject_ruffle_and_wait } = require("../../utils");
const { openTest, injectRuffleAndWait } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("iframe onload", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("runs the iframe onload event", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
await browser.$("<div />").waitForExist();
const actual = await browser.$("#container").getHTML(false);

View File

@ -1,4 +1,4 @@
const { open_test } = require("../../utils");
const { openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,7 +7,7 @@ use(chaiHtml);
describe("Flash inside iframe with provided ruffle", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills inside an iframe", async () => {

View File

@ -1,7 +1,7 @@
const {
open_test,
inject_ruffle_and_wait,
play_and_monitor,
openTest,
injectRuffleAndWait,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,11 +11,11 @@ use(chaiHtml);
describe("Object with case-insensitive MIME type", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("Polyfills", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
await browser.$("<ruffle-object />").waitForExist();
const actual = await browser.$("#test-container").getHTML(false);
@ -24,7 +24,7 @@ describe("Object with case-insensitive MIME type", () => {
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-object />")
);

View File

@ -1,7 +1,7 @@
const {
open_test,
inject_ruffle_and_wait,
play_and_monitor,
openTest,
injectRuffleAndWait,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,11 +11,11 @@ use(chaiHtml);
describe("Object with case-insensitive clsid", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("Polyfills", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
await browser.$("<ruffle-object />").waitForExist();
const actual = await browser.$("#test-container").getHTML(false);
@ -24,7 +24,7 @@ describe("Object with case-insensitive clsid", () => {
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-object />")
);

View File

@ -1,7 +1,7 @@
const {
inject_ruffle_and_wait,
open_test,
play_and_monitor,
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,18 +11,18 @@ use(chaiHtml);
describe("Object with clsid and embed", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-embed />")
);

View File

@ -1,7 +1,7 @@
const {
open_test,
inject_ruffle_and_wait,
play_and_monitor,
openTest,
injectRuffleAndWait,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,11 +11,11 @@ use(chaiHtml);
describe("Object with only data attribute", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("Polyfills", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
await browser.$("<ruffle-object />").waitForExist();
const actual = await browser.$("#test-container").getHTML(false);
@ -24,7 +24,7 @@ describe("Object with only data attribute", () => {
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-object />")
);

View File

@ -1,7 +1,7 @@
const {
inject_ruffle_and_wait,
open_test,
play_and_monitor,
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,18 +11,18 @@ use(chaiHtml);
describe("Object tag", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-embed />")
);

View File

@ -1,7 +1,7 @@
const {
inject_ruffle_and_wait,
open_test,
play_and_monitor,
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,18 +11,18 @@ use(chaiHtml);
describe("Object with another object tag", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills only the first tag with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-object />")
);

View File

@ -1,7 +1,7 @@
const {
inject_ruffle_and_wait,
open_test,
play_and_monitor,
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,18 +11,18 @@ use(chaiHtml);
describe("Object using classid with another object tag without classid", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills only the second tag with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-object />")
);

View File

@ -1,7 +1,7 @@
const {
inject_ruffle_and_wait,
open_test,
play_and_monitor,
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,18 +11,18 @@ use(chaiHtml);
describe("Object tag", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("Plays a movie with flashvars", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-embed />"),
`// _level0.a

View File

@ -1,7 +1,7 @@
const {
inject_ruffle_and_wait,
open_test,
play_and_monitor,
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,18 +11,18 @@ use(chaiHtml);
describe("Object tag", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("Plays a movie with flashvars", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-embed />"),
`// _level0.a

View File

@ -1,7 +1,7 @@
const {
inject_ruffle_and_wait,
open_test,
play_and_monitor,
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,18 +11,18 @@ use(chaiHtml);
describe("Object for old IE must work everywhere", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-object />")
);

View File

@ -1,4 +1,4 @@
const { inject_ruffle_and_wait, open_test } = require("../../utils");
const { injectRuffleAndWait, openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("Object inside audio node", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("doesn't polyfill with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);

View File

@ -1,4 +1,4 @@
const { open_test, inject_ruffle_and_wait } = require("../../utils");
const { openTest, injectRuffleAndWait } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("Object without data attribute", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("doesn't polyfill with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);

View File

@ -1,7 +1,7 @@
const {
inject_ruffle_and_wait,
open_test,
play_and_monitor,
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,18 +11,18 @@ use(chaiHtml);
describe("Object without type attribute", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-embed />")
);

View File

@ -1,7 +1,7 @@
const {
inject_ruffle_and_wait,
open_test,
play_and_monitor,
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,18 +11,18 @@ use(chaiHtml);
describe("Object without type and classid attributes", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-object />")
);

View File

@ -1,7 +1,7 @@
const {
inject_ruffle_and_wait,
open_test,
play_and_monitor,
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,18 +11,18 @@ use(chaiHtml);
describe("Object with unexpected string", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-embed />")
);

View File

@ -1,4 +1,4 @@
const { inject_ruffle_and_wait, open_test } = require("../../utils");
const { injectRuffleAndWait, openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("Object with ruffle-embed tag", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("already polyfilled with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);

View File

@ -1,7 +1,7 @@
const {
inject_ruffle_and_wait,
open_test,
play_and_monitor,
injectRuffleAndWait,
openTest,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,18 +11,18 @@ use(chaiHtml);
describe("Object with wrong type attribute value", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-embed />")
);

View File

@ -1,4 +1,4 @@
const { open_test, inject_ruffle_and_wait } = require("../../utils");
const { openTest, injectRuffleAndWait } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("Object with Flash YouTube video", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("doesn't polyfill with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);

View File

@ -1,4 +1,4 @@
const { inject_ruffle_and_wait, open_test } = require("../../utils");
const { injectRuffleAndWait, openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("PDF object", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("doesn't polyfill with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);

View File

@ -1,4 +1,4 @@
const { inject_ruffle_and_wait, open_test } = require("../../utils");
const { injectRuffleAndWait, openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("PDF with .swf GET", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("doesn't polyfill with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);

View File

@ -1,4 +1,4 @@
const { inject_ruffle_and_wait, open_test } = require("../../utils");
const { injectRuffleAndWait, openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("Remove object", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);

View File

@ -1,4 +1,4 @@
const { inject_ruffle_and_wait, open_test } = require("../../utils");
const { injectRuffleAndWait, openTest } = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
@ -7,11 +7,11 @@ use(chaiHtml);
describe("SPL", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("polyfills with ruffle", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
const actual = await browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);

View File

@ -1,7 +1,7 @@
const {
open_test,
inject_ruffle_and_wait,
play_and_monitor,
openTest,
injectRuffleAndWait,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,11 +11,11 @@ use(chaiHtml);
describe("SWF extension insensitive", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("Polyfills", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
await browser.$("<ruffle-object />").waitForExist();
const actual = await browser.$("#test-container").getHTML(false);
@ -24,7 +24,7 @@ describe("SWF extension insensitive", () => {
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-object />")
);

View File

@ -1,7 +1,7 @@
const {
open_test,
inject_ruffle_and_wait,
play_and_monitor,
openTest,
injectRuffleAndWait,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,11 +11,11 @@ use(chaiHtml);
describe("SWF extension, file with fragment", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("Polyfills", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
await browser.$("<ruffle-object />").waitForExist();
const actual = await browser.$("#test-container").getHTML(false);
@ -24,7 +24,7 @@ describe("SWF extension, file with fragment", () => {
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-object />")
);

View File

@ -1,7 +1,7 @@
const {
open_test,
inject_ruffle_and_wait,
play_and_monitor,
openTest,
injectRuffleAndWait,
playAndMonitor,
} = require("../../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
@ -11,11 +11,11 @@ use(chaiHtml);
describe("SWF extension, file with GET parameter", () => {
it("loads the test", async () => {
await open_test(browser, __dirname);
await openTest(browser, __dirname);
});
it("Polyfills", async () => {
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
await browser.$("<ruffle-object />").waitForExist();
const actual = await browser.$("#test-container").getHTML(false);
@ -24,7 +24,7 @@ describe("SWF extension, file with GET parameter", () => {
});
it("Plays a movie", async () => {
await play_and_monitor(
await playAndMonitor(
browser,
await browser.$("#test-container").$("<ruffle-object />")
);

View File

@ -1,6 +1,6 @@
const path = require("path");
async function is_ruffle_loaded(browser) {
async function isRuffleLoaded(browser) {
return await browser.execute(
() =>
window !== undefined &&
@ -9,14 +9,14 @@ async function is_ruffle_loaded(browser) {
);
}
async function wait_for_ruffle(browser) {
await browser.waitUntil(async () => await is_ruffle_loaded(browser), {
async function waitForRuffle(browser) {
await browser.waitUntil(async () => await isRuffleLoaded(browser), {
timeoutMsg: "Expected Ruffle to load",
});
await throw_if_error(browser);
await throwIfError(browser);
}
async function setup_error_handler(browser) {
async function setupErrorHandler(browser) {
await browser.execute(() => {
window.ruffleErrors = [];
window.addEventListener("error", (error) => {
@ -25,13 +25,13 @@ async function setup_error_handler(browser) {
});
}
async function has_error(browser) {
async function hasError(browser) {
return await browser.execute(
() => window.ruffleErrors && window.ruffleErrors.length > 0
);
}
async function throw_if_error(browser) {
async function throwIfError(browser) {
return await browser.execute(() => {
if (window.ruffleErrors && window.ruffleErrors.length > 0) {
throw window.ruffleErrors[0];
@ -39,24 +39,24 @@ async function throw_if_error(browser) {
});
}
async function inject_ruffle(browser) {
await setup_error_handler(browser);
async function injectRuffle(browser) {
await setupErrorHandler(browser);
await browser.execute(() => {
const script = document.createElement("script");
script.type = "text/javascript";
script.src = "/dist/ruffle.js";
document.head.appendChild(script);
});
await throw_if_error(browser);
await throwIfError(browser);
}
async function play_and_monitor(browser, player, expected_output) {
await throw_if_error(browser);
async function playAndMonitor(browser, player, expectedOutput) {
await throwIfError(browser);
// TODO: better way to test for this in the API
await browser.waitUntil(
async () =>
(await has_error(browser)) ||
(await hasError(browser)) ||
(await browser.execute((player) => player.instance, player)),
{
timeoutMsg: "Expected player to have initialized",
@ -71,8 +71,8 @@ async function play_and_monitor(browser, player, expected_output) {
player.play();
}, player);
if (expected_output === undefined) {
expected_output = "Hello from Flash!\n";
if (expectedOutput === undefined) {
expectedOutput = "Hello from Flash!\n";
}
await browser.waitUntil(
@ -80,36 +80,36 @@ async function play_and_monitor(browser, player, expected_output) {
(await browser.execute(
(player) => player.__ruffle_log__,
player
)) === expected_output,
)) === expectedOutput,
{
timeoutMsg: "Expected Ruffle to trace a message",
}
);
}
async function inject_ruffle_and_wait(browser) {
await inject_ruffle(browser);
await wait_for_ruffle(browser);
async function injectRuffleAndWait(browser) {
await injectRuffle(browser);
await waitForRuffle(browser);
}
async function open_test(browser, absolute_dir, file_name) {
const dir_name = path.basename(absolute_dir);
if (file_name === undefined) {
file_name = "index.html";
async function openTest(browser, absoluteDir, filename) {
const dirname = path.basename(absoluteDir);
if (filename === undefined) {
filename = "index.html";
}
await browser.url(
`http://localhost:4567/test/polyfill/${dir_name}/${file_name}`
`http://localhost:4567/test/polyfill/${dirname}/${filename}`
);
}
/** Test set-up for JS API testing. */
function js_api_before(swf) {
function jsApiBefore(swf) {
let player = null;
before("Loads the test", async () => {
await browser.url("http://localhost:4567/test_assets/js_api.html");
await inject_ruffle_and_wait(browser);
await injectRuffleAndWait(browser);
player = await browser.execute(() => {
const ruffle = window.RufflePlayer.newest();
@ -123,18 +123,18 @@ function js_api_before(swf) {
await browser.execute((player) => {
player.load("/test_assets/example.swf");
}, player);
await play_and_monitor(browser, player);
await playAndMonitor(browser, player);
}
});
}
module.exports = {
is_ruffle_loaded,
wait_for_ruffle,
play_and_monitor,
inject_ruffle,
inject_ruffle_and_wait,
open_test,
setup_error_handler,
js_api_before,
isRuffleLoaded,
waitForRuffle,
playAndMonitor,
injectRuffle,
injectRuffleAndWait,
openTest,
setupErrorHandler,
jsApiBefore,
};

View File

@ -1,16 +1,5 @@
/* eslint-env node */
let chrome_binary = undefined;
if (process.platform === "win32" && process.env.CI) {
// Chrome 84->85 changed the location where Chrome is installed on Windows.
// ChromeDriver can't find it yet, so we'll manually specify it for GitHub Actions.
// See https://github.com/actions/virtual-environments/issues/1546
// See https://developercommunity.visualstudio.com/content/problem/1170486/selenium-ui-test-can-no-longer-find-chrome-binary.html#reply-1171966
chrome_binary =
"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe";
}
exports.config = {
//
// ====================
@ -66,7 +55,6 @@ exports.config = {
browserName: "chrome",
"goog:chromeOptions": {
args: ["--headless", "--disable-gpu"],
binary: chrome_binary,
},
// If outputDir is provided WebdriverIO can capture driver session logs
// it is possible to configure which logTypes to include/exclude.