Skip to content

Commit 34bc66d

Browse files
committed
Bug 2036752 - allow skeleton UI when MOZ_BYPASS_FELT is set for tests
1 parent 9b9a912 commit 34bc66d

3 files changed

Lines changed: 66 additions & 2 deletions

File tree

mozglue/misc/PreXULSkeletonUI.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,7 @@ static Result<Ok, PreXULSkeletonUIError> ValidateCmdlineArguments(
16331633
#endif
16341634

16351635
bool approved = false;
1636+
int j = 0;
16361637
for (const char* approvedArg : approvedArguments) {
16371638
// We do a case-insensitive compare here with _stricmp. Even though some
16381639
// of these arguments are *not* read as case-insensitive, others *are*.
@@ -1644,25 +1645,35 @@ static Result<Ok, PreXULSkeletonUIError> ValidateCmdlineArguments(
16441645
if (!_stricmp(flag, approvedArg)) {
16451646
approved = true;
16461647

1647-
if (i == profileArgIndex) {
1648+
if (j == profileArgIndex) {
16481649
*explicitProfile = true;
16491650
}
16501651
break;
16511652
}
1653+
++j;
16521654
}
16531655

16541656
if (!approved) {
16551657
return Err(PreXULSkeletonUIError::Cmdline);
16561658
}
16571659
}
16581660

1661+
#if defined(MOZ_ENTERPRISE)
1662+
// If there is MOZ_BYPASS_FELT environment variable, then likely tests are
1663+
// executing and thus no `-felt <socket>` argument can be found to verify if
1664+
// this is running a browser. By essence of that variable it is known the
1665+
// browser is running and not Felt UI so explicitely use the PreSkeletonUI
1666+
// in this case.
1667+
if (EnvHasValue("MOZ_BYPASS_FELT")) {
1668+
return Ok();
1669+
}
1670+
16591671
// When starting FELT, disable the PreXULSkeletonUI. Checking with
16601672
// is_felt_browser() is not doable here because this symbol is defined in
16611673
// libxul however the present code runs in firefox.exe. Hence checking the
16621674
// existence of "-felt" as is_felt_browser() would be doing, so
16631675
// PreXULSkeletonUI is kept for normal browser, just disabled for FELT
16641676
// window.
1665-
#if defined(MOZ_ENTERPRISE)
16661677
if (!hasFeltFlag) {
16671678
return Err(PreXULSkeletonUIError::Cmdline);
16681679
}
@@ -2116,6 +2127,9 @@ HWND ConsumePreXULSkeletonUIHandle() {
21162127
::CloseHandle(sPreXULSKeletonUIAnimationThread);
21172128
sPreXULSKeletonUIAnimationThread = nullptr;
21182129
HWND result = sPreXULSkeletonUIWindow;
2130+
if (sPreXULSkeletonUIWindow) {
2131+
sPreXULSkeletonUIShown = true;
2132+
}
21192133
sPreXULSkeletonUIWindow = nullptr;
21202134
free(sPixelBuffer);
21212135
sPixelBuffer = nullptr;

testing/enterprise/manifest.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ run-if = [
5454

5555
["test_felt_browser_signout_verify.py"]
5656

57+
["test_felt_browser_skeleton_ui.py"]
58+
run-if = [
59+
"os == 'win'",
60+
]
61+
5762
["test_felt_browser_starts.py"]
5863

5964
["test_felt_browser_starts_missing_bin.py"]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
# This Source Code Form is subject to the terms of the Mozilla Public
3+
# License, v. 2.0. If a copy of the MPL was not distributed with this
4+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
6+
import os
7+
import sys
8+
9+
sys.path.append(os.path.dirname(__file__))
10+
11+
from test_felt_browser_signout import BaseBrowserSignout
12+
13+
14+
class BrowserSkeletonUI(BaseBrowserSignout):
15+
def test_skeleton_ui_not_shown_for_felt(self):
16+
self.run_check_skeleton_ui(self._driver, expected=False)
17+
18+
super().run_felt_base()
19+
self.connect_child_browser(
20+
capabilities={
21+
# Do not auto-handle prompts.
22+
"unhandledPromptBehavior": "ignore"
23+
}
24+
)
25+
# Skeleton UI is not shown for the child browser either, which is
26+
# expected since we use FELT and don't need it.
27+
self.run_check_skeleton_ui(self._child_driver, expected=False)
28+
self._do_signout()
29+
30+
self._logger.info("Restarting felt out-of-process")
31+
self.marionette.restart(in_app=False)
32+
self._logger.info("Felt restarted")
33+
self.run_check_skeleton_ui(self._driver, expected=False)
34+
self._manually_closed_child = True
35+
36+
def run_check_skeleton_ui(self, driver, expected):
37+
with driver.using_context(driver.CONTEXT_CHROME):
38+
showed = driver.execute_script(
39+
"return Services.startup.showedPreXULSkeletonUI;"
40+
)
41+
self._logger.info(f"showedPreXULSkeletonUI: {showed}")
42+
43+
assert showed == expected, (
44+
f"Expected showedPreXULSkeletonUI to be {expected}, got {showed}"
45+
)

0 commit comments

Comments
 (0)