mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-08 08:39:59 +00:00
64 lines
1.5 KiB
JavaScript
64 lines
1.5 KiB
JavaScript
"use strict";
|
|
|
|
const path = require("path");
|
|
const glob = require("glob");
|
|
const fs = require("fs");
|
|
|
|
const webdriver = require("selenium-webdriver");
|
|
const firefox = require("selenium-webdriver/firefox");
|
|
const chrome = require("selenium-webdriver/chrome");
|
|
|
|
const { __extensionName
|
|
, __extensionVersion } = require("../ext/package.json");
|
|
|
|
|
|
const extensionArchivePath = path.join(
|
|
path.join(__dirname, "../dist/ext/")
|
|
, `${__extensionName}-${__extensionVersion}.xpi`);
|
|
|
|
if (!fs.existsSync(extensionArchivePath)) {
|
|
console.error("Extension archive not found.");
|
|
process.exit(1);
|
|
}
|
|
|
|
|
|
const TEST_PAGE_URL = `file:///${__dirname}/test.html`;
|
|
|
|
const firefoxOptions = new firefox.Options()
|
|
.setBinary(firefox.Channel.NIGHTLY)
|
|
.headless()
|
|
.addExtensions(extensionArchivePath)
|
|
.setPreference("xpinstall.signatures.required", false);
|
|
|
|
const chromeOptions = new chrome.Options()
|
|
.headless()
|
|
.excludeSwitches([ "disable-background-networking"
|
|
, "disable-default-apps"]);
|
|
|
|
|
|
async function create () {
|
|
const driver = new webdriver.Builder()
|
|
.forBrowser("firefox")
|
|
.setFirefoxOptions(firefoxOptions)
|
|
.setChromeOptions(chromeOptions)
|
|
.build();
|
|
|
|
await driver.get(TEST_PAGE_URL);
|
|
|
|
try {
|
|
// Allow access from other specs
|
|
this.driver = driver;
|
|
} catch (err) {}
|
|
|
|
return driver;
|
|
}
|
|
|
|
function destroy (driver = this.driver) {
|
|
driver.quit();
|
|
}
|
|
|
|
module.exports = {
|
|
create
|
|
, destroy
|
|
}
|