Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browser] easy prep for Firefox #101138

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ public static partial class Capability
{
public static bool IsNtlmInstalled()
{
if (OperatingSystem.IsBrowser())
{
return false;
}
return
// Linux bionic uses managed NTLM implementation
(OperatingSystem.IsLinux() && RuntimeInformation.RuntimeIdentifier.StartsWith("linux-bionic-", StringComparison.Ordinal)) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ public static int SlowRuntimeTimeoutModifier
public static bool IsNotBrowserDomSupported => !IsBrowserDomSupported;
public static bool IsWebSocketSupported => IsEnvironmentVariableTrue("IsWebSocketSupported");
public static bool IsNodeJS => IsEnvironmentVariableTrue("IsNodeJS");
public static bool IsFirefox => IsEnvironmentVariableTrue("IsFirefox");
public static bool IsChromium => IsEnvironmentVariableTrue("IsChromium");
public static bool IsNotNodeJS => !IsNodeJS;
public static bool IsNodeJSOnWindows => GetNodeJSPlatform() == "win32";
public static bool LocalEchoServerIsNotAvailable => !LocalEchoServerIsAvailable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class ChromeProvider : WasmHostProvider
private DebuggerProxy? _debuggerProxy;
private static readonly Lazy<string> s_browserPath = new(() =>
{
string artifactsBinDir = Path.Combine(Path.GetDirectoryName(typeof(ChromeProvider).Assembly.Location)!, "..", "..", "..");
string artifactsBinDir = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(typeof(ChromeProvider).Assembly.Location)!, "..", "..", ".."));
return BrowserLocator.FindChrome(artifactsBinDir, "BROWSER_PATH_FOR_TESTS");
});
private static readonly string[] s_messagesToFilterOut = new[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class FirefoxProvider : WasmHostProvider
private FirefoxDebuggerProxy? _firefoxDebuggerProxy;
private static readonly Lazy<string> s_browserPath = new(() =>
{
string artifactsBinDir = Path.Combine(Path.GetDirectoryName(typeof(ChromeProvider).Assembly.Location)!, "..", "..", "..");
string artifactsBinDir = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(typeof(ChromeProvider).Assembly.Location)!, "..", "..", ".."));
return BrowserLocator.FindFirefox(artifactsBinDir, "BROWSER_PATH_FOR_TESTS");
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en-us">
<head>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en-us">
<head>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en-us">

<head>
Expand Down
19 changes: 17 additions & 2 deletions src/mono/browser/test-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export const ENVIRONMENT_IS_SIDECAR = ENVIRONMENT_IS_WEB_WORKER && typeof dotnet
export const ENVIRONMENT_IS_WORKER = ENVIRONMENT_IS_WEB_WORKER && !ENVIRONMENT_IS_SIDECAR; // we redefine what ENVIRONMENT_IS_WORKER, we replace it in emscripten internals, so that sidecar works
export const ENVIRONMENT_IS_WEB = typeof window == "object" || (ENVIRONMENT_IS_WEB_WORKER && !ENVIRONMENT_IS_NODE);
export const ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE;
export const isFirefox = !!(ENVIRONMENT_IS_WEB && navigator.userAgent.includes("Firefox"));
export const isChromium = !!(ENVIRONMENT_IS_WEB && navigator.userAgentData && navigator.userAgentData.brands.some(b => b.brand === "Google Chrome" || b.brand === "Microsoft Edge" || b.brand === "Chromium"));

if (ENVIRONMENT_IS_NODE && process.versions.node.split(".")[0] < 14) {
throw new Error(`NodeJS at '${process.execPath}' has too low version '${process.versions.node}'`);
Expand Down Expand Up @@ -51,8 +53,13 @@ if (!ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WEB && typeof globalThis.crypto ===
}
}

if (ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER) {
console.log("Running '" + globalThis.navigator.userAgent + "' at: \n" + globalThis.location.href + "\n");
if (ENVIRONMENT_IS_WEB && isFirefox) {
Error.stackTraceLimit = 1000;
}

if (ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER && !isFirefox) {
console.log("Running in: " + globalThis.navigator.userAgent);
console.log("Running at: " + globalThis.location.href);
}

let v8args;
Expand Down Expand Up @@ -179,6 +186,8 @@ function processArguments(incomingArguments, runArgs) {
// cheap way to let the testing infrastructure know we're running in a browser context (or not)
runArgs.environmentVariables["IsBrowserDomSupported"] = ENVIRONMENT_IS_WEB.toString().toLowerCase();
runArgs.environmentVariables["IsNodeJS"] = ENVIRONMENT_IS_NODE.toString().toLowerCase();
runArgs.environmentVariables["IsFirefox"] = isFirefox.toString().toLowerCase();
runArgs.environmentVariables["IsChromium"] = isChromium.toString().toLowerCase();

return runArgs;
}
Expand Down Expand Up @@ -312,6 +321,12 @@ async function run() {
App.runtime = await dotnet.create();
App.runArgs = runArgs

if (ENVIRONMENT_IS_WEB && isFirefox) {
ilonatommy marked this conversation as resolved.
Show resolved Hide resolved
console.log("Application arguments: " + runArgs.applicationArguments.join(' '));
ilonatommy marked this conversation as resolved.
Show resolved Hide resolved
console.log("Running in: " + globalThis.navigator.userAgent);
console.log("Running at: " + globalThis.location.href);
}

console.info("Initializing dotnet version " + App.runtime.runtimeBuildInfo.productVersion + " commit hash " + App.runtime.runtimeBuildInfo.gitHash);

for (let i = 0; i < runArgs.profilers.length; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/Wasm.Build.Tests/TestMainJsTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected TestMainJsTestBase(ITestOutputHelper output, SharedBuildPerTestClassFi
Path.Combine(_projectDir, "test-main.js")
);

File.WriteAllText(Path.Combine(_projectDir!, "index.html"), @"<html><body><script type=""module"" src=""test-main.js""></script></body></html>");
File.WriteAllText(Path.Combine(_projectDir!, "index.html"), @"<!DOCTYPE html><html><body><script type=""module"" src=""test-main.js""></script></body></html>");
}
else if (_projectDir is null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/Common/wasm-test-runner/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html><body><script type='module' src='test-main.js'></script></body></html>
<!DOCTYPE html><html><body><script type='module' src='test-main.js'></script></body></html>
Loading