@@ -86,6 +86,12 @@ describe("previewWindowOpenAction", () => {
8686 ) . toBe ( "popup" ) ;
8787 } ) ;
8888
89+ it ( "opens HTTP links in preview tabs" , ( ) => {
90+ for ( const disposition of [ "foreground-tab" , "background-tab" ] as const ) {
91+ expect ( PreviewManager . previewWindowOpenAction ( details ( { disposition } ) ) ) . toBe ( "new-tab" ) ;
92+ }
93+ } ) ;
94+
8995 it ( "keeps a form POST with a body on the in-place path" , ( ) => {
9096 const postBody = { data : [ ] , contentType : "application/x-www-form-urlencoded" } ;
9197 expect (
@@ -98,15 +104,32 @@ describe("previewWindowOpenAction", () => {
98104
99105 it ( "does not hand a window to schemes that cannot be hardened" , ( ) => {
100106 for ( const url of [
101- "javascript:alert(1)" ,
102- "file:///etc/passwd" ,
103107 "vscode://vscode-remote/ssh-remote+box/tmp" ,
104- "not a url " ,
108+ "blob:https://example.com/0b6c6a5e-55d4-4b4c-9d47-8f1b0c1d2e3f " ,
105109 ] ) {
106110 expect ( PreviewManager . previewWindowOpenAction ( details ( { url } ) ) ) . toBe ( "navigate" ) ;
107111 }
108112 } ) ;
109113
114+ it ( "denies local and inline schemes that no page could open in place itself" , ( ) => {
115+ for ( const url of [
116+ "data:text/html,<h1>hi</h1>" ,
117+ "DaTa:text/html,<h1>hi</h1>" ,
118+ "file:///etc/passwd" ,
119+ "javascript:alert(1)" ,
120+ "view-source:https://example.com" ,
121+ "chrome://gpu" ,
122+ "about:srcdoc" ,
123+ "devtools://devtools/bundled/inspector.html" ,
124+ "filesystem:https://example.com/temporary/page.html" ,
125+ "not a url" ,
126+ ] ) {
127+ for ( const disposition of [ "new-window" , "foreground-tab" , "background-tab" ] as const ) {
128+ expect ( PreviewManager . previewWindowOpenAction ( details ( { url, disposition } ) ) ) . toBe ( "deny" ) ;
129+ }
130+ }
131+ } ) ;
132+
110133 it ( "denies a blank window instead of blanking the opener" , ( ) => {
111134 for ( const url of [ "about:blank" , "" ] ) {
112135 for ( const disposition of [ "new-window" , "foreground-tab" ] as const ) {
0 commit comments