From 60d9beda5af0909cb014af3b01a04595c1f02627 Mon Sep 17 00:00:00 2001 From: Jannik Becher Date: Sun, 13 Aug 2023 12:40:48 +0100 Subject: [PATCH] Send link navigation event inside iframe to parent (#2160) --- assets/js/hooks/js_view/iframe.js | 8 +- iframe/priv/static/iframe/v5.html | 240 ++++++++++++++++++++++++++++++ 2 files changed, 244 insertions(+), 4 deletions(-) create mode 100644 iframe/priv/static/iframe/v5.html diff --git a/assets/js/hooks/js_view/iframe.js b/assets/js/hooks/js_view/iframe.js index 32a8eec97..2aa12289e 100644 --- a/assets/js/hooks/js_view/iframe.js +++ b/assets/js/hooks/js_view/iframe.js @@ -26,14 +26,14 @@ import { sha256Base64 } from "../../lib/utils"; // (2): https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox // (3): https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts -const IFRAME_SHA256 = "vd7g1B8fLBFZH6C6KNpG4H8B0SQ/oIuqKaTW6jD053A="; +const IFRAME_SHA256 = "48LZtKkFYMd+4gsmVvbhvw9mTpJPw+ItRdGxPPs+5xw="; export function initializeIframeSource(iframe, iframePort, iframeUrl) { const url = getIframeUrl(iframePort, iframeUrl); return verifyIframeSource(url).then(() => { iframe.sandbox = - "allow-scripts allow-same-origin allow-downloads allow-modals allow-popups"; + "allow-scripts allow-same-origin allow-downloads allow-modals allow-popups allow-top-navigation"; iframe.allow = "accelerometer; ambient-light-sensor; camera; display-capture; encrypted-media; fullscreen; geolocation; gyroscope; microphone; midi; usb; xr-spatial-tracking; clipboard-read; clipboard-write"; iframe.src = url; @@ -48,8 +48,8 @@ function getIframeUrl(iframePort, iframeUrl) { } return protocol === "https:" - ? "https://livebookusercontent.com/iframe/v4.html" - : `http://${window.location.hostname}:${iframePort}/iframe/v4.html`; + ? "https://livebookusercontent.com/iframe/v5.html" + : `http://${window.location.hostname}:${iframePort}/iframe/v5.html`; } let iframeVerificationPromise = null; diff --git a/iframe/priv/static/iframe/v5.html b/iframe/priv/static/iframe/v5.html new file mode 100644 index 000000000..9a1741c7b --- /dev/null +++ b/iframe/priv/static/iframe/v5.html @@ -0,0 +1,240 @@ + + + + + Output + + + +
+ + +