Skip to content

Commit 233e12a

Browse files
committed
add isCrossOriginSubframe to check if window.showSaveFilePicker will fail
1 parent 17a10d6 commit 233e12a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

core/utils.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@
6767
return !isNWApp() && !isChromeWebApp();
6868
}
6969

70+
function isCrossOriginSubframe() {
71+
if (!window.parent) return false;
72+
try {
73+
return window.parent.location.host != window.location.host;
74+
// if actually cross origin, this will throw "Blocked a frame with origin ... from accessing a cross-origin frame."
75+
} catch (e) {
76+
return true;
77+
}
78+
}
79+
7080
/// Does the currently connected board have an ARM processor that can execute Thumb code?
7181
function isARMThumb() {
7282
var data = Espruino.Core.Env.getData();
@@ -971,6 +981,7 @@ while (d!==undefined) {console.log(btoa(d));d=f.read(${CHUNKSIZE});}
971981
isChromeWebApp : isChromeWebApp,
972982
isProgressiveWebApp : isProgressiveWebApp,
973983
hasNativeTitleBar : hasNativeTitleBar,
984+
isCrossOriginSubframe : isCrossOriginSubframe,
974985
isARMThumb : isARMThumb,
975986
escapeHTML : escapeHTML,
976987
fixBrokenCode : fixBrokenCode,

0 commit comments

Comments
 (0)