Only allow iframe embedding

This commit is contained in:
Surma
2019-03-20 17:51:32 +00:00
parent 5270553f27
commit 956e064c8c

View File

@@ -9,6 +9,11 @@ export interface ReadyMessage {
}
export function exposeAPI(app: App) {
if (window === top) {
// Someone opened Squoosh in a window rather than an iframe.
// This can be deceiving and we wont allow that.
return;
}
self.parent.postMessage({ type: 'READY', version: MAJOR_VERSION }, '*');
self.addEventListener('message', (event: MessageEvent) => {
if (event.data !== 'READY?') {