diff --git a/addons/web/static/src/core/browser/feature_detection.js b/addons/web/static/src/core/browser/feature_detection.js index 58dd52b0451..b493ceeb204 100644 --- a/addons/web/static/src/core/browser/feature_detection.js +++ b/addons/web/static/src/core/browser/feature_detection.js @@ -16,7 +16,7 @@ export function isBrowserChrome() { } export function isMacOS() { - return Boolean(browser.navigator.platform.match(/Mac/i)); + return Boolean(browser.navigator.userAgent.match(/Mac/i)); } export function isMobileOS() { diff --git a/addons/web/static/tests/core/hotkeys/hotkey_service_tests.js b/addons/web/static/tests/core/hotkeys/hotkey_service_tests.js index c1d34345bbb..1dfbd7147a4 100644 --- a/addons/web/static/tests/core/hotkeys/hotkey_service_tests.js +++ b/addons/web/static/tests/core/hotkeys/hotkey_service_tests.js @@ -139,12 +139,6 @@ QUnit.test("hook", async (assert) => { QUnit.test("non-MacOS usability", async (assert) => { assert.expect(6); - patchWithCleanup(browser, { - navigator: { - platform: "OdooOS", - }, - }); - const hotkey = env.services.hotkey; const key = "q"; @@ -186,7 +180,7 @@ QUnit.test("MacOS usability", async (assert) => { patchWithCleanup(browser, { navigator: { - platform: "Mac", + userAgent: browser.navigator.userAgent.replace(/\([^)]*\)/, "(MacOs)"), }, }); @@ -491,12 +485,6 @@ QUnit.test("registrations and elements belong to the correct UI owner", async (a QUnit.test("replace the overlayModifier for non-MacOs", async (assert) => { assert.expect(3); - patchWithCleanup(browser, { - navigator: { - platform: "OdooOS", - }, - }); - const hotkeyService = serviceRegistry.get("hotkey"); patchWithCleanup(hotkeyService, { overlayModifier: "alt+shift", @@ -531,7 +519,7 @@ QUnit.test("replace the overlayModifier for MacOs", async (assert) => { patchWithCleanup(browser, { navigator: { - platform: "Mac", + userAgent: browser.navigator.userAgent.replace(/\([^)]*\)/, "(MacOs)"), }, }); diff --git a/addons/web/static/tests/helpers/utils.js b/addons/web/static/tests/helpers/utils.js index 553ffd913e5..4b130a11578 100644 --- a/addons/web/static/tests/helpers/utils.js +++ b/addons/web/static/tests/helpers/utils.js @@ -199,6 +199,7 @@ export function triggerHotkey(hotkey, addOverlayModParts = false, eventAttrs = { } window.dispatchEvent(new KeyboardEvent("keydown", eventAttrs)); + window.dispatchEvent(new KeyboardEvent("keyup", eventAttrs)); } export async function legacyExtraNextTick() { diff --git a/addons/web/static/tests/setup.js b/addons/web/static/tests/setup.js index 6143793a7a8..b99c5470c3c 100644 --- a/addons/web/static/tests/setup.js +++ b/addons/web/static/tests/setup.js @@ -113,6 +113,9 @@ function patchBrowserWithCleanup() { originalRemoveEventListener(...arguments); }); }, + navigator: { + userAgent: browser.navigator.userAgent.replace(/\([^)]*\)/, "(X11; Linux x86_64)"), + }, // in tests, we never want to interact with the real url or reload the page location: mockLocation, history: { diff --git a/addons/web/static/tests/webclient/commands/command_service_tests.js b/addons/web/static/tests/webclient/commands/command_service_tests.js index 3dfbef016fa..2438272afba 100644 --- a/addons/web/static/tests/webclient/commands/command_service_tests.js +++ b/addons/web/static/tests/webclient/commands/command_service_tests.js @@ -406,12 +406,6 @@ QUnit.test("data-command-category", async (assert) => { }); QUnit.test("display shortcuts correctly for non-MacOS ", async (assert) => { - patchWithCleanup(browser, { - navigator: { - platform: "OdooOS", - }, - }); - class MyComponent extends Component {} MyComponent.components = { TestComponent }; MyComponent.template = xml` @@ -448,7 +442,7 @@ QUnit.test("display shortcuts correctly for non-MacOS ", async (assert) => { QUnit.test("display shortcuts correctly for MacOS ", async (assert) => { patchWithCleanup(browser, { navigator: { - platform: "Mac", + userAgent: browser.navigator.userAgent.replace(/\([^)]*\)/, "(MacOs)"), }, }); @@ -488,12 +482,6 @@ QUnit.test("display shortcuts correctly for MacOS ", async (assert) => { QUnit.test( "display shortcuts correctly for non-MacOS with a new overlayModifier", async (assert) => { - patchWithCleanup(browser, { - navigator: { - platform: "OdooOS", - }, - }); - const hotkeyService = serviceRegistry.get("hotkey"); patchWithCleanup(hotkeyService, { overlayModifier: "alt+control", @@ -523,7 +511,7 @@ QUnit.test( QUnit.test("display shortcuts correctly for MacOS with a new overlayModifier", async (assert) => { patchWithCleanup(browser, { navigator: { - platform: "Mac", + userAgent: browser.navigator.userAgent.replace(/\([^)]*\)/, "(MacOs)"), }, });