Skip to content

Commit 221f260

Browse files
committed
vscode api: Raise compatibility to webview content
The webview (or its `acquireVsCodeApi` injector) adds the vscode api but also deletes the properties `window.parent`, `window.top` and `window.frameElement`. This voilates the HTML Spec and makes problems with some code like `if (window.parent === window)` to detect if we are running in an iframe. Yes, this affects Hyrum's Law and https://xkcd.com/1172/ but detecting `acquireVsCodeApi` object itself feels to be cleaner anyway.
1 parent c20ffd0 commit 221f260

File tree

1 file changed

+3
-3
lines changed
  • src/vs/workbench/contrib/webview/browser/pre

1 file changed

+3
-3
lines changed

src/vs/workbench/contrib/webview/browser/pre/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@
221221
});
222222
};
223223
})();
224-
delete window.parent;
225-
delete window.top;
226-
delete window.frameElement;
224+
window.parent = window;
225+
window.top = window;
226+
window.frameElement = null;
227227
`;
228228
}
229229

0 commit comments

Comments
 (0)