Skip to content

Commit 44e29c2

Browse files
authored
[browser] easy prep for Firefox (#101138)
1 parent e126f8f commit 44e29c2

File tree

10 files changed

+30
-9
lines changed

10 files changed

+30
-9
lines changed

src/libraries/Common/tests/System/Net/Capability.Security.Unix.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ public static partial class Capability
99
{
1010
public static bool IsNtlmInstalled()
1111
{
12+
if (OperatingSystem.IsBrowser())
13+
{
14+
return false;
15+
}
1216
return
1317
// Linux bionic uses managed NTLM implementation
1418
(OperatingSystem.IsLinux() && RuntimeInformation.RuntimeIdentifier.StartsWith("linux-bionic-", StringComparison.Ordinal)) ||

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ public static int SlowRuntimeTimeoutModifier
152152
public static bool IsNotBrowserDomSupported => !IsBrowserDomSupported;
153153
public static bool IsWebSocketSupported => IsEnvironmentVariableTrue("IsWebSocketSupported");
154154
public static bool IsNodeJS => IsEnvironmentVariableTrue("IsNodeJS");
155+
public static bool IsFirefox => IsEnvironmentVariableTrue("IsFirefox");
156+
public static bool IsChromium => IsEnvironmentVariableTrue("IsChromium");
155157
public static bool IsNotNodeJS => !IsNodeJS;
156158
public static bool IsNodeJSOnWindows => GetNodeJSPlatform() == "win32";
157159
public static bool LocalEchoServerIsNotAvailable => !LocalEchoServerIsAvailable;

src/mono/browser/debugger/DebuggerTestSuite/ChromeProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal class ChromeProvider : WasmHostProvider
2828
private DebuggerProxy? _debuggerProxy;
2929
private static readonly Lazy<string> s_browserPath = new(() =>
3030
{
31-
string artifactsBinDir = Path.Combine(Path.GetDirectoryName(typeof(ChromeProvider).Assembly.Location)!, "..", "..", "..");
31+
string artifactsBinDir = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(typeof(ChromeProvider).Assembly.Location)!, "..", "..", ".."));
3232
return BrowserLocator.FindChrome(artifactsBinDir, "BROWSER_PATH_FOR_TESTS");
3333
});
3434
private static readonly string[] s_messagesToFilterOut = new[]

src/mono/browser/debugger/DebuggerTestSuite/FirefoxProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal class FirefoxProvider : WasmHostProvider
2323
private FirefoxDebuggerProxy? _firefoxDebuggerProxy;
2424
private static readonly Lazy<string> s_browserPath = new(() =>
2525
{
26-
string artifactsBinDir = Path.Combine(Path.GetDirectoryName(typeof(ChromeProvider).Assembly.Location)!, "..", "..", "..");
26+
string artifactsBinDir = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(typeof(ChromeProvider).Assembly.Location)!, "..", "..", ".."));
2727
return BrowserLocator.FindFirefox(artifactsBinDir, "BROWSER_PATH_FOR_TESTS");
2828
});
2929

src/mono/browser/debugger/tests/debugger-test/debugger-driver.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en-us">
33
<head>
44
</head>

src/mono/browser/debugger/tests/debugger-test/non-wasm-page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en-us">
33
<head>
44
</head>

src/mono/browser/debugger/tests/debugger-test/wasm-page-without-assets.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en-us">
33

44
<head>

src/mono/browser/test-main.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export const ENVIRONMENT_IS_SIDECAR = ENVIRONMENT_IS_WEB_WORKER && typeof dotnet
2424
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
2525
export const ENVIRONMENT_IS_WEB = typeof window == "object" || (ENVIRONMENT_IS_WEB_WORKER && !ENVIRONMENT_IS_NODE);
2626
export const ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE;
27+
export const isFirefox = !!(ENVIRONMENT_IS_WEB && navigator.userAgent.includes("Firefox"));
28+
export const isChromium = !!(ENVIRONMENT_IS_WEB && navigator.userAgentData && navigator.userAgentData.brands.some(b => b.brand === "Google Chrome" || b.brand === "Microsoft Edge" || b.brand === "Chromium"));
2729

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

54-
if (ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER) {
55-
console.log("Running '" + globalThis.navigator.userAgent + "' at: \n" + globalThis.location.href + "\n");
56+
if (ENVIRONMENT_IS_WEB && isFirefox) {
57+
Error.stackTraceLimit = 1000;
58+
}
59+
60+
if (ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER && !isFirefox) {
61+
console.log("Running in: " + globalThis.navigator.userAgent);
62+
console.log("Running at: " + globalThis.location.href);
5663
}
5764

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

183192
return runArgs;
184193
}
@@ -312,6 +321,12 @@ async function run() {
312321
App.runtime = await dotnet.create();
313322
App.runArgs = runArgs
314323

324+
if (ENVIRONMENT_IS_WEB && isFirefox) {
325+
console.log("Application arguments: " + runArgs.applicationArguments.join(' '));
326+
console.log("Running in: " + globalThis.navigator.userAgent);
327+
console.log("Running at: " + globalThis.location.href);
328+
}
329+
315330
console.info("Initializing dotnet version " + App.runtime.runtimeBuildInfo.productVersion + " commit hash " + App.runtime.runtimeBuildInfo.gitHash);
316331

317332
for (let i = 0; i < runArgs.profilers.length; ++i) {

src/mono/wasm/Wasm.Build.Tests/TestMainJsTestBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected TestMainJsTestBase(ITestOutputHelper output, SharedBuildPerTestClassFi
5555
Path.Combine(_projectDir, "test-main.js")
5656
);
5757

58-
File.WriteAllText(Path.Combine(_projectDir!, "index.html"), @"<html><body><script type=""module"" src=""test-main.js""></script></body></html>");
58+
File.WriteAllText(Path.Combine(_projectDir!, "index.html"), @"<!DOCTYPE html><html><body><script type=""module"" src=""test-main.js""></script></body></html>");
5959
}
6060
else if (_projectDir is null)
6161
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html><html><body><script type='module' src='test-main.js'></script></body></html>
1+
<!DOCTYPE html><html><body><script type='module' src='test-main.js'></script></body></html>

0 commit comments

Comments
 (0)