@@ -27,29 +27,35 @@ testSingleMap("/external-map");
2727testSingleMap ( "/inline-map" ) ;
2828
2929test ( `single mapped class works on /no-map` , async t => {
30- const { page, browser, server} = await setup ( "/no-map" , async msg => {
31- if ( msg . css ) {
32- const lines = msg . css . split ( "\n" ) ;
33- t . equal ( lines [ 0 ] , ".__debug-1 {}" , "has expected class on line 1" ) ;
34- const consumer = await getConsumer ( msg . css ) ;
35- const pos = consumer . originalPositionFor ( { line : 1 , column : 0 } ) ;
36- t . equal ( pos . line , 1 , "mapped line number matches expected" ) ;
37- t . equal ( pos . column , 0 , "mapped column matches expected" ) ;
38- const { hostname, pathname, protocol} = new URL ( pos . source ) ;
39- t . equal ( hostname , "localhost" ) ;
40- t . equal ( pathname , "/no-map.js" ) ;
41- t . equal ( protocol , "http:" ) ;
42- const content = consumer . sourceContentFor ( pos . source ) ;
43- t . equal (
44- content ,
45- fixtures . clientNoMapRaw ,
46- "mapped source content matches expected" ,
47- ) ;
48- await browser . close ( ) ;
49- server . close ( ) ;
50- t . end ( ) ;
51- }
52- } ) ;
30+ const { page, browser, server} = await setup (
31+ "/no-map" ,
32+ async msg => {
33+ if ( msg . css ) {
34+ const lines = msg . css . split ( "\n" ) ;
35+ t . equal ( lines [ 0 ] , ".__debug-1 {}" , "has expected class on line 1" ) ;
36+ const consumer = await getConsumer ( msg . css ) ;
37+ const pos = consumer . originalPositionFor ( { line : 1 , column : 0 } ) ;
38+ t . equal ( pos . line , 1 , "mapped line number matches expected" ) ;
39+ t . equal ( pos . column , 0 , "mapped column matches expected" ) ;
40+ const { hostname, pathname, protocol} = new URL ( pos . source ) ;
41+ t . equal ( hostname , "localhost" ) ;
42+ t . equal ( pathname , "/no-map.js" ) ;
43+ t . equal ( protocol , "http:" ) ;
44+ const content = consumer . sourceContentFor ( pos . source ) ;
45+ t . equal (
46+ content ,
47+ fixtures . clientNoMapRaw ,
48+ "mapped source content matches expected" ,
49+ ) ;
50+ await browser . close ( ) ;
51+ server . close ( ) ;
52+ t . end ( ) ;
53+ }
54+ } ,
55+ ( ) => {
56+ t . fail ( "recieved error" ) ;
57+ } ,
58+ ) ;
5359 page . evaluate ( ( ) => {
5460 window . worker . postMessage ( {
5561 id : "init_wasm" ,
@@ -69,30 +75,36 @@ test(`single mapped class works on /no-map`, async t => {
6975} ) ;
7076
7177test ( `replaying requests after invalidation` , async t => {
72- const { page, browser, server} = await setup ( "/external-map" , async msg => {
73- if ( msg . css ) {
74- const lines = msg . css . split ( "\n" ) ;
75- t . equal ( lines [ 0 ] , ".__debug-1 {}" , "has expected class on line 1" ) ;
76- const consumer = await getConsumer ( msg . css ) ;
77- const pos = consumer . originalPositionFor ( { line : 1 , column : 0 } ) ;
78- t . equal ( pos . line , 5 , "mapped line number matches expected" ) ;
79- t . equal ( pos . column , 0 , "mapped column matches expected" ) ;
80- t . equal (
81- pos . source ,
82- "webpack:///client.js" ,
83- "mapped source matches expected" ,
84- ) ;
85- const content = consumer . sourceContentFor ( "webpack:///client.js" ) ;
86- t . equal (
87- content ,
88- fixtures . clientSource ,
89- "mapped source content matches expected" ,
90- ) ;
91- await browser . close ( ) ;
92- server . close ( ) ;
93- t . end ( ) ;
94- }
95- } ) ;
78+ const { page, browser, server} = await setup (
79+ "/external-map" ,
80+ async msg => {
81+ if ( msg . css ) {
82+ const lines = msg . css . split ( "\n" ) ;
83+ t . equal ( lines [ 0 ] , ".__debug-1 {}" , "has expected class on line 1" ) ;
84+ const consumer = await getConsumer ( msg . css ) ;
85+ const pos = consumer . originalPositionFor ( { line : 1 , column : 0 } ) ;
86+ t . equal ( pos . line , 5 , "mapped line number matches expected" ) ;
87+ t . equal ( pos . column , 0 , "mapped column matches expected" ) ;
88+ t . equal (
89+ pos . source ,
90+ "webpack:///client.js" ,
91+ "mapped source matches expected" ,
92+ ) ;
93+ const content = consumer . sourceContentFor ( "webpack:///client.js" ) ;
94+ t . equal (
95+ content ,
96+ fixtures . clientSource ,
97+ "mapped source content matches expected" ,
98+ ) ;
99+ await browser . close ( ) ;
100+ server . close ( ) ;
101+ t . end ( ) ;
102+ }
103+ } ,
104+ ( ) => {
105+ t . fail ( "recieved error" ) ;
106+ } ,
107+ ) ;
96108 server . blockAllRequests ( ) ;
97109 page . evaluate ( ( ) => {
98110 window . worker . postMessage ( {
@@ -172,7 +184,7 @@ function startServer() {
172184 } ) ;
173185}
174186
175- async function setup ( route , msgHandler ) {
187+ async function setup ( route , msgHandler , errHandler ) {
176188 const { port, server} = await startServer ( ) ;
177189 const browser = await puppeteer . launch (
178190 isCI ? { args : [ "--no-sandbox" , "--disable-dev-shm-usage" ] } : { } ,
@@ -184,6 +196,8 @@ async function setup(route, msgHandler) {
184196 Promise . all ( msg . args ( ) . map ( a => a . jsonValue ( ) ) ) . then ( async args => {
185197 if ( args [ 0 ] === "__on_message__" ) {
186198 msgHandler ( args [ 1 ] ) ;
199+ } else if ( args [ 0 ] === "Debug worker error" ) {
200+ errHandler ( args [ 1 ] ) ;
187201 }
188202 } ) ;
189203 } ) ;
0 commit comments