File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
PuppeteerSharp.Tests/PageTests Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -38,9 +38,35 @@ public async Task ShouldIntercept()
3838 } ;
3939 var response = await Page . GoToAsync ( TestConstants . EmptyPage ) ;
4040 Assert . True ( response . Ok ) ;
41+
4142 Assert . Equal ( TestConstants . Port , response . RemoteAddress . Port ) ;
4243 }
4344
45+ [ Fact ]
46+ public async Task ShouldWorkWithInterventionHeaders ( )
47+ {
48+ Server . SetRoute ( "/intervention" , context => context . Response . WriteAsync ( $@ "
49+ <script>
50+ document.write('<script src=""{ TestConstants . CrossProcessHttpPrefix } /intervention.js"">' + '</scr' + 'ipt>');
51+ </script>
52+ " ) ) ;
53+ Server . SetRedirect ( "/intervention.js" , "/redirect.js" ) ;
54+
55+ string interventionHeader = null ;
56+ Server . SetRoute ( "/redirect.js" , context =>
57+ {
58+ interventionHeader = context . Request . Headers [ "intervention" ] ;
59+ return context . Response . WriteAsync ( "console.log(1);" ) ;
60+ } ) ;
61+
62+ await Page . SetRequestInterceptionAsync ( true ) ;
63+ Page . Request += async ( sender , e ) => await e . Request . ContinueAsync ( ) ;
64+
65+ await Page . GoToAsync ( TestConstants . ServerUrl + "/intervention" ) ;
66+
67+ Assert . Contains ( "www.chromestatus.com" , interventionHeader ) ;
68+ }
69+
4470 [ Fact ]
4571 public async Task ShouldWorkWhenPostIsEedirectedWith302 ( )
4672 {
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ public class Payload
2121 "x-devtools-emulate-network-conditions-client-id" ,
2222 "cookie" ,
2323 "origin" ,
24- "content-type"
24+ "content-type" ,
25+ "intervention"
2526 } ;
2627
2728 /// <summary>
You can’t perform that action at this time.
0 commit comments