From d9e983aed4222a98ffaa59a6f368abcdf57784ec Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 14 Apr 2025 16:12:35 +0200 Subject: [PATCH] fix: do not show "back to home" button in iframes Co-authored-by: David Larlet --- umap/static/umap/js/modules/umap.js | 2 +- umap/tests/integration/test_iframe.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 umap/tests/integration/test_iframe.py diff --git a/umap/static/umap/js/modules/umap.js b/umap/static/umap/js/modules/umap.js index b941205a..3e7def06 100644 --- a/umap/static/umap/js/modules/umap.js +++ b/umap/static/umap/js/modules/umap.js @@ -108,7 +108,7 @@ export default class Umap { // Do not display in an iframe. if (window.self !== window.top) { - geojson.properties.homeControl = false + this.properties.homeControl = false } this._leafletMap.setup() diff --git a/umap/tests/integration/test_iframe.py b/umap/tests/integration/test_iframe.py new file mode 100644 index 00000000..8c1f770c --- /dev/null +++ b/umap/tests/integration/test_iframe.py @@ -0,0 +1,25 @@ +from playwright.sync_api import expect + + +def test_home_control_is_hidden(live_server, map, tilelayer, page): + body = f""" + + + + + + + """ + + def handle(route): + route.fulfill(body=body) + + url = f"{live_server.url}/test-iframe" + # Intercept the route + page.route(url, handle) + + page.goto(url) + expect( + page.locator("iframe").content_frame.get_by_role("link", name="Home logo") + ).to_be_hidden()