@@ -9,6 +9,7 @@ const config = require("../fixtures/overlay-config/webpack.config");
9
9
const trustedTypesConfig = require ( "../fixtures/overlay-config/trusted-types.webpack.config" ) ;
10
10
const runBrowser = require ( "../helpers/run-browser" ) ;
11
11
const port = require ( "../ports-map" ) . overlay ;
12
+ const isWebpack5 = require ( "../helpers/isWebpack5" ) ;
12
13
13
14
class ErrorPlugin {
14
15
constructor ( message , skipCounter ) {
@@ -773,80 +774,86 @@ describe("overlay", () => {
773
774
await server . stop ( ) ;
774
775
} ) ;
775
776
776
- it ( "should show overlay when Trusted Types are enabled" , async ( ) => {
777
- const compiler = webpack ( trustedTypesConfig ) ;
777
+ ( isWebpack5 ? it : it . skip ) (
778
+ "should show overlay when Trusted Types are enabled" ,
779
+ async ( ) => {
780
+ const compiler = webpack ( trustedTypesConfig ) ;
778
781
779
- new ErrorPlugin ( ) . apply ( compiler ) ;
782
+ new ErrorPlugin ( ) . apply ( compiler ) ;
780
783
781
- const devServerOptions = {
782
- port,
783
- client : {
784
- overlay : {
785
- trustedTypesPolicyName : "webpack#dev-overlay" ,
784
+ const devServerOptions = {
785
+ port,
786
+ client : {
787
+ overlay : {
788
+ trustedTypesPolicyName : "webpack#dev-overlay" ,
789
+ } ,
786
790
} ,
787
- } ,
788
- } ;
789
- const server = new Server ( devServerOptions , compiler ) ;
790
-
791
- await server . start ( ) ;
792
-
793
- const { page, browser } = await runBrowser ( ) ;
794
-
795
- await page . goto ( `http://localhost:${ port } /` , {
796
- waitUntil : "networkidle0" ,
797
- } ) ;
798
-
799
- const pageHtml = await page . evaluate ( ( ) => document . body . outerHTML ) ;
800
- const overlayHandle = await page . $ ( "#webpack-dev-server-client-overlay" ) ;
801
- const overlayFrame = await overlayHandle . contentFrame ( ) ;
802
- const overlayHtml = await overlayFrame . evaluate (
803
- ( ) => document . body . outerHTML
804
- ) ;
805
-
806
- expect ( prettier . format ( pageHtml , { parser : "html" } ) ) . toMatchSnapshot (
807
- "page html"
808
- ) ;
809
- expect ( prettier . format ( overlayHtml , { parser : "html" } ) ) . toMatchSnapshot (
810
- "overlay html"
811
- ) ;
791
+ } ;
792
+ const server = new Server ( devServerOptions , compiler ) ;
812
793
813
- await browser . close ( ) ;
814
- await server . stop ( ) ;
815
- } ) ;
794
+ await server . start ( ) ;
816
795
817
- it ( "should not show overlay when Trusted Types are enabled, but policy is not allowed" , async ( ) => {
818
- const compiler = webpack ( trustedTypesConfig ) ;
796
+ const { page, browser } = await runBrowser ( ) ;
819
797
820
- new ErrorPlugin ( ) . apply ( compiler ) ;
798
+ await page . goto ( `http://localhost:${ port } /` , {
799
+ waitUntil : "networkidle0" ,
800
+ } ) ;
821
801
822
- const devServerOptions = {
823
- port,
824
- client : {
825
- overlay : {
826
- trustedTypesPolicyName : "disallowed-policy" ,
802
+ const pageHtml = await page . evaluate ( ( ) => document . body . outerHTML ) ;
803
+ const overlayHandle = await page . $ ( "#webpack-dev-server-client-overlay" ) ;
804
+ const overlayFrame = await overlayHandle . contentFrame ( ) ;
805
+ const overlayHtml = await overlayFrame . evaluate (
806
+ ( ) => document . body . outerHTML
807
+ ) ;
808
+
809
+ expect ( prettier . format ( pageHtml , { parser : "html" } ) ) . toMatchSnapshot (
810
+ "page html"
811
+ ) ;
812
+ expect ( prettier . format ( overlayHtml , { parser : "html" } ) ) . toMatchSnapshot (
813
+ "overlay html"
814
+ ) ;
815
+
816
+ await browser . close ( ) ;
817
+ await server . stop ( ) ;
818
+ }
819
+ ) ;
820
+
821
+ ( isWebpack5 ? it : it . skip ) (
822
+ "should not show overlay when Trusted Types are enabled, but policy is not allowed" ,
823
+ async ( ) => {
824
+ const compiler = webpack ( trustedTypesConfig ) ;
825
+
826
+ new ErrorPlugin ( ) . apply ( compiler ) ;
827
+
828
+ const devServerOptions = {
829
+ port,
830
+ client : {
831
+ overlay : {
832
+ trustedTypesPolicyName : "disallowed-policy" ,
833
+ } ,
827
834
} ,
828
- } ,
829
- } ;
830
- const server = new Server ( devServerOptions , compiler ) ;
835
+ } ;
836
+ const server = new Server ( devServerOptions , compiler ) ;
831
837
832
- await server . start ( ) ;
838
+ await server . start ( ) ;
833
839
834
- const { page, browser } = await runBrowser ( ) ;
840
+ const { page, browser } = await runBrowser ( ) ;
835
841
836
- await page . goto ( `http://localhost:${ port } /` , {
837
- waitUntil : "networkidle0" ,
838
- } ) ;
839
-
840
- const pageHtml = await page . evaluate ( ( ) => document . body . outerHTML ) ;
841
- const overlayHandle = await page . $ ( "#webpack-dev-server-client-overlay" ) ;
842
- expect ( overlayHandle ) . toBe ( null ) ;
843
- expect ( prettier . format ( pageHtml , { parser : "html" } ) ) . toMatchSnapshot (
844
- "page html"
845
- ) ;
842
+ await page . goto ( `http://localhost:${ port } /` , {
843
+ waitUntil : "networkidle0" ,
844
+ } ) ;
846
845
847
- await browser . close ( ) ;
848
- await server . stop ( ) ;
849
- } ) ;
846
+ const pageHtml = await page . evaluate ( ( ) => document . body . outerHTML ) ;
847
+ const overlayHandle = await page . $ ( "#webpack-dev-server-client-overlay" ) ;
848
+ expect ( overlayHandle ) . toBe ( null ) ;
849
+ expect ( prettier . format ( pageHtml , { parser : "html" } ) ) . toMatchSnapshot (
850
+ "page html"
851
+ ) ;
852
+
853
+ await browser . close ( ) ;
854
+ await server . stop ( ) ;
855
+ }
856
+ ) ;
850
857
851
858
it ( 'should show an error when "client.overlay.errors" is "true"' , async ( ) => {
852
859
const compiler = webpack ( config ) ;
0 commit comments