From 9e01004564071a2c3da4a61de0fff7ed566ee933 Mon Sep 17 00:00:00 2001 From: 00Fjongl <65314359+00Fjongl@users.noreply.github.com> Date: Wed, 10 Jul 2024 20:27:23 -0500 Subject: [PATCH] Modified test script and minor commenting changes. Testing still not accurate due to Axios bug though. --- test.js | 19 +++++++++++++------ views/assets/js/common-16451543478.js | 2 +- views/assets/js/register-sw.js | 6 +++--- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/test.js b/test.js index 288b5ae0..0245438a 100644 --- a/test.js +++ b/test.js @@ -104,17 +104,24 @@ async function testCommonJSOnPage() { async function testUltraviolet() { await page.goto("http://localhost:8080/?q"); - // Wait for the service worker to be active - await page.waitForFunction( - () => navigator.serviceWorker.controller !== null - ); - const testResults = await page.evaluate(async () => { const results = {}; + await new Promise((resolve) => { + + const waitForDocument = () => document.readyState === "complete" + ? resolve() + : window.addEventListener("load", resolve); + +// Wait until a service worker is registered before continuing. +// Also make sure the document is loaded. + const waitForWorker = async () => setTimeout(async () => (await navigator.serviceWorker.getRegistrations()).length >= 1 ? waitForDocument() : waitForWorker(), 1000); + + waitForWorker(); + }); if (window.goProx && window.goProx.ultraviolet) { try { - const generatedUrl = await window.goProx.ultraviolet( + const generatedUrl = window.goProx.ultraviolet( "example.com", false ); diff --git a/views/assets/js/common-16451543478.js b/views/assets/js/common-16451543478.js index 9fd70de2..96fecf82 100644 --- a/views/assets/js/common-16451543478.js +++ b/views/assets/js/common-16451543478.js @@ -334,7 +334,7 @@ const RammerheadEncode = async baseUrl => { * * Key: 1 = "stealth" * 0 = "window" - * Nothing = return as string variable + * Nothing = return URL as a string * * Examples: * Stealth mode - diff --git a/views/assets/js/register-sw.js b/views/assets/js/register-sw.js index d5723796..bc893cd6 100644 --- a/views/assets/js/register-sw.js +++ b/views/assets/js/register-sw.js @@ -17,10 +17,10 @@ async function registerSW() { let wispUrl = (location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/"; await BareMux.SetTransport("EpxMod.EpoxyClient", { wisp: wispUrl }); - //When testing proxy support CLEAR service workers from 8080 (oI'lr whatever current port you are using) +// When testing proxy support CLEAR service workers from 8080 (or whatever current port you are using) + +// navigator.serviceWorker.register(stockSW).then(register => register.unregister().then(bool => console.log("Unregistered: " + bool))); - // navigator.serviceWorker.register(stockSW).then(register => register.unregister().then(bool => console.log("Unregistered: " + bool))); - } registerSW(); \ No newline at end of file