Skip to content

Commit 6742b97

Browse files
thaystgilonatommy
andauthored
[wasm][debugger] Trying to fix firefox flaky tests on CI. (#75090)
* Trying to fix firefox tests flaky tests on CI. * Fix tab taking a long time to open. * Trying to fix CI. * Trying to debug on CI. * Debugging CI. * Debug on CI. * debug on ci * Fix merge * Test with timeout * 2. * Debug on CI. * Removing messages and increasing timeout. * Undoing the changes on CI * Removing unrelated changes * Remove unrelated change * Applied review changes. * Trying to fix new tests. * Update firefox. Co-authored-by: Ilona Tomkowicz <[email protected]>
1 parent 620239a commit 6742b97

File tree

7 files changed

+49
-36
lines changed

7 files changed

+49
-36
lines changed

eng/testing/ProvisioningVersions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
</PropertyGroup>
5353

5454
<PropertyGroup Condition="'$(BrowserHost)' != 'windows'">
55-
<FirefoxRevision>97.0.1</FirefoxRevision>
55+
<FirefoxRevision>108.0.1</FirefoxRevision>
5656
<FirefoxUrl>https://ftp.mozilla.org/pub/firefox/releases/$(FirefoxRevision)/linux-x86_64/en-US/firefox-$(FirefoxRevision).tar.bz2</FirefoxUrl>
5757
<FirefoxBinaryName>firefox</FirefoxBinaryName>
5858
</PropertyGroup>

src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public static WasmHost RunningOn
3939
#endif
4040
public static bool RunningOnChrome => RunningOn == WasmHost.Chrome;
4141

42+
public static bool RunningOnChromeAndLinux => RunningOn == WasmHost.Chrome && PlatformDetection.IsLinux;
43+
4244
public const int FirefoxProxyPort = 6002;
4345

4446
internal InspectorClient cli;

src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestFirefox.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace DebuggerTests;
1414

1515
public class DebuggerTestFirefox : DebuggerTestBase
1616
{
17+
private new TimeSpan TestTimeout => base.TestTimeout * 5;
1718
internal FirefoxInspectorClient _client;
1819
public DebuggerTestFirefox(ITestOutputHelper testOutput, string driver = "debugger-driver.html"):base(testOutput, driver)
1920
{

src/mono/wasm/debugger/DebuggerTestSuite/FirefoxInspectorClient.cs

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -71,38 +71,50 @@ protected override async Task<WasmDebuggerConnection> SetupConnection(Uri webser
7171
throw new Exception($"Failed to connect to the proxy at {endpoint}", se);
7272
}
7373
}
74+
public async Task<bool> ProcessTabInfo(Result command, CancellationToken token)
75+
{
76+
var resultTabs = command.Value?["result"]?["value"]?["tabs"];
77+
if (resultTabs == null ||
78+
resultTabs.Value<JArray>()?.Count == 0 ||
79+
resultTabs[0]?["url"]?.Value<string>()?.StartsWith("about:") == true)
80+
return false;
81+
var toCmd = resultTabs[0]?["actor"]?.Value<string>();
82+
var res = await SendCommand("getWatcher", JObject.FromObject(new { type = "getWatcher", isServerTargetSwitchingEnabled = true, to = toCmd}), token);
83+
var watcherId = res.Value?["result"]?["value"]?["actor"]?.Value<string>();
84+
res = await SendCommand("watchResources", JObject.FromObject(new { type = "watchResources", resourceTypes = new JArray("console-message"), to = watcherId}), token);
85+
res = await SendCommand("watchTargets", JObject.FromObject(new { type = "watchTargets", targetType = "frame", to = watcherId}), token);
86+
UpdateTarget(res.Value?["result"]?["value"]?["target"] as JObject);
87+
res = await SendCommand("attach", JObject.FromObject(new
88+
{
89+
type = "attach",
90+
options = JObject.FromObject(new
91+
{
92+
pauseOnExceptions = false,
93+
ignoreCaughtExceptions = true,
94+
shouldShowOverlay = true,
95+
shouldIncludeSavedFrames = true,
96+
shouldIncludeAsyncLiveFrames = false,
97+
skipBreakpoints = false,
98+
logEventBreakpoints = false,
99+
observeAsmJS = true,
100+
breakpoints = new JArray(),
101+
eventBreakpoints = new JArray()
102+
}),
103+
to = ThreadActorId
104+
}), token);
105+
res = await SendCommand("getBreakpointListActor", JObject.FromObject(new { type = "getBreakpointListActor", to = watcherId}), token);
106+
BreakpointActorId = res.Value?["result"]?["value"]?["breakpointList"]?["actor"]?.Value<string>();
107+
return true;
108+
}
74109

75110
public override async Task ProcessCommand(Result command, CancellationToken token)
76111
{
77-
if (command.Value?["result"]?["value"]?["tabs"] != null)
112+
if (await ProcessTabInfo(command, token))
113+
return;
114+
do
78115
{
79-
var toCmd = command.Value?["result"]?["value"]?["tabs"]?[0]?["actor"]?.Value<string>();
80-
var res = await SendCommand("getWatcher", JObject.FromObject(new { type = "getWatcher", isServerTargetSwitchingEnabled = true, to = toCmd}), token);
81-
var watcherId = res.Value?["result"]?["value"]?["actor"]?.Value<string>();
82-
res = await SendCommand("watchResources", JObject.FromObject(new { type = "watchResources", resourceTypes = new JArray("console-message"), to = watcherId}), token);
83-
res = await SendCommand("watchTargets", JObject.FromObject(new { type = "watchTargets", targetType = "frame", to = watcherId}), token);
84-
UpdateTarget(res.Value?["result"]?["value"]?["target"] as JObject);
85-
await SendCommand("attach", JObject.FromObject(new
86-
{
87-
type = "attach",
88-
options = JObject.FromObject(new
89-
{
90-
pauseOnExceptions = false,
91-
ignoreCaughtExceptions = true,
92-
shouldShowOverlay = true,
93-
shouldIncludeSavedFrames = true,
94-
shouldIncludeAsyncLiveFrames = false,
95-
skipBreakpoints = false,
96-
logEventBreakpoints = false,
97-
observeAsmJS = true,
98-
breakpoints = new JArray(),
99-
eventBreakpoints = new JArray()
100-
}),
101-
to = ThreadActorId
102-
}), token);
103-
res = await SendCommand("getBreakpointListActor", JObject.FromObject(new { type = "getBreakpointListActor", to = watcherId}), token);
104-
BreakpointActorId = res.Value?["result"]?["value"]?["breakpointList"]?["actor"]?.Value<string>();
105-
}
116+
command = await SendCommand("listTabs", JObject.FromObject(new { type = "listTabs", to = "root"}), token);
117+
} while (!await ProcessTabInfo(command, token));
106118
}
107119

108120
protected override Task? HandleMessage(string msg, CancellationToken token)
@@ -187,7 +199,6 @@ public override Task<Result> SendCommand(SessionId sessionId, string method, JOb
187199
{
188200
if (args == null)
189201
args = new JObject();
190-
191202
var tcs = new TaskCompletionSource<Result>();
192203
MessageId msgId;
193204
if (args["to"]?.Value<string>() is not string to_str)

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ public async Task StartBrowserAndProxyAsync(HttpContext context,
5252
context,
5353
str =>
5454
{
55-
// FIXME: instead of this, we can wait for the port to open
56-
//for running debugger tests on firefox
57-
if (str?.Contains("console.log: \"ready\"") == true)
55+
if (str?.Contains("Started devtools server on ") == true)
5856
return $"http://localhost:{remoteDebuggingPort}";
5957

6058
return null;
@@ -136,6 +134,7 @@ private static string GetProfilePath(string Id)
136134
user_pref("devtools.debugger.remote-enabled", true);
137135
user_pref("devtools.debugger.prompt-connection", false);
138136
user_pref("devtools.console.stdout.content", true);
137+
user_pref("browser.dom.window.dump.enabled", true);
139138
""";
140139

141140
string profilePath = Path.GetFullPath(Path.Combine(DebuggerTestBase.DebuggerTestAppPath, $"test-profile-{Id}"));

src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ await EvaluateAndCheck(
958958
}
959959
//TODO add tests covering basic stepping behavior as step in/out/over
960960

961-
[Theory]
961+
[ConditionalTheory(nameof(RunningOnChrome))]
962962
[InlineData(
963963
"DebuggerTests.CheckSpecialCharactersInPath",
964964
"dotnet://debugger-test-special-char-in-path.dll/test%23.cs",
@@ -980,7 +980,7 @@ public async Task SetBreakpointInProjectWithSpecialCharactersInPath(
980980
Assert.EndsWith(expectedFileNameEscaped, ret["callFrames"][0]["url"].Value<string>(), StringComparison.InvariantCulture);
981981
}
982982

983-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsLinux))]
983+
[ConditionalFact(nameof(RunningOnChromeAndLinux))]
984984
public async Task SetBreakpointInProjectWithColonInSourceName()
985985
{
986986
var bp = await SetBreakpointInMethod("debugger-test-with-colon-in-source-name.dll", "DebuggerTests.CheckColonInSourceName", "Evaluate", 1);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
App.method_with_structs = exports.DebuggerTests.ValueTypesTest.MethodWithLocalStructs;
1818
App.run_all = exports.DebuggerTest.run_all;
1919
App.static_method_table = {};
20-
console.debug ("#debugger-app-ready#"); console.log ("ready"); // HACK: firefox tests are looking for this "ready"
20+
console.debug ("#debugger-app-ready#");
2121
},
2222
};
2323
function invoke_static_method (method_name, ...args) {

0 commit comments

Comments
 (0)