diff --git a/src/components/custom-widget/ko/runtime/customWidget.ts b/src/components/custom-widget/ko/runtime/customWidget.ts index b25cbb109..b713720a7 100644 --- a/src/components/custom-widget/ko/runtime/customWidget.ts +++ b/src/components/custom-widget/ko/runtime/customWidget.ts @@ -1,7 +1,7 @@ import * as ko from "knockout"; import { Component, RuntimeComponent, OnMounted, OnDestroyed, Param } from "@paperbits/common/ko/decorators"; import { Environment } from "@azure/api-management-custom-widgets-tools"; -import { iframeAllows, iframeSandboxAllows } from "../../../../constants"; +import { iframeAllows, iframeSandboxAllows, iframeSandboxAllowsBrowserSpecific } from "../../../../constants"; import { widgetRuntimeSelector } from "../../constants"; import template from "./customWidget.html"; @@ -14,13 +14,19 @@ import template from "./customWidget.html"; }) export class CustomWidget { public readonly iframeAllows: string = iframeAllows; - public readonly iframeSandboxAllows: string = iframeSandboxAllows; + public iframeSandboxAllows: string = iframeSandboxAllows; private windowRef = window; constructor() { this.src = ko.observable(); this.name = ko.observable(); this.instanceId = ko.observable(); + + const iframe = document.getElementsByTagName("iframe")[0]; + this.iframeSandboxAllows = `${iframeSandboxAllows} ${iframeSandboxAllowsBrowserSpecific}` + .split(" ") + .filter(token=> iframe?.sandbox.supports(token)) + .join(" "); } @Param() diff --git a/src/constants.ts b/src/constants.ts index 3a5824150..46b7fa07a 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -316,7 +316,8 @@ export const iframeAllows = "clipboard-read; clipboard-write; camera; microphone /** * List of allowed attributes for a sandboxed iframe. */ -export const iframeSandboxAllows = "allow-same-origin allow-scripts allow-modals allow-forms allow-popups allow-popups-to-escape-sandbox allow-top-navigation allow-pointer-lock"; +export const iframeSandboxAllows = "allow-scripts allow-modals allow-forms allow-popups allow-popups-to-escape-sandbox allow-top-navigation allow-pointer-lock"; +export const iframeSandboxAllowsBrowserSpecific = "allow-downloads allow-presentation allow-orientation-lock"; /** * List of downloadable content types