@@ -2124,4 +2124,133 @@ describe("overlay", () => {
2124
2124
await server . stop ( ) ;
2125
2125
}
2126
2126
} ) ;
2127
+
2128
+ it ( "should navigate between multiple errors when Trusted Types are enabled" , async ( ) => {
2129
+ const compiler = webpack ( trustedTypesConfig ) ;
2130
+
2131
+ // Create multiple distinct errors for navigation testing
2132
+ new ErrorPlugin ( "First error message" ) . apply ( compiler ) ;
2133
+ new ErrorPlugin ( "Second error message" ) . apply ( compiler ) ;
2134
+ new ErrorPlugin ( "Third error message" ) . apply ( compiler ) ;
2135
+
2136
+ const devServerOptions = {
2137
+ port,
2138
+ client : {
2139
+ overlay : {
2140
+ trustedTypesPolicyName : "webpack#dev-overlay" ,
2141
+ } ,
2142
+ } ,
2143
+ } ;
2144
+ const server = new Server ( devServerOptions , compiler ) ;
2145
+
2146
+ await server . start ( ) ;
2147
+
2148
+ const { page, browser } = await runBrowser ( ) ;
2149
+
2150
+ try {
2151
+ const consoleMessages = [ ] ;
2152
+
2153
+ page . on ( "console" , ( message ) => {
2154
+ consoleMessages . push ( message . text ( ) ) ;
2155
+ } ) ;
2156
+
2157
+ await page . goto ( `http://localhost:${ port } /` , {
2158
+ waitUntil : "networkidle0" ,
2159
+ } ) ;
2160
+
2161
+ // Delay for the overlay to appear
2162
+ await delay ( 1000 ) ;
2163
+
2164
+ // Get the overlay iframe and its content frame
2165
+ const overlayHandle = await page . $ ( "#webpack-dev-server-client-overlay" ) ;
2166
+ const overlayFrame = await overlayHandle . contentFrame ( ) ;
2167
+
2168
+ // Check initial error counter display
2169
+ let errorCounter = await overlayFrame . $eval (
2170
+ ".error-counter" ,
2171
+ ( el ) => el . textContent ,
2172
+ ) ;
2173
+ expect ( errorCounter ) . toBe ( "ERROR 1/3" ) ;
2174
+
2175
+ // Check initial error content
2176
+ let errorContent = await overlayFrame . $eval (
2177
+ ".error-message" ,
2178
+ ( el ) => el . textContent ,
2179
+ ) ;
2180
+ expect ( errorContent ) . toContain ( "First error message" ) ;
2181
+
2182
+ // Test navigation button - next
2183
+ const nextButton = await overlayFrame . $ ( "button:nth-of-type(2)" ) ;
2184
+ await nextButton . click ( ) ;
2185
+ await delay ( 100 ) ;
2186
+
2187
+ // Verify we moved to second error
2188
+ errorCounter = await overlayFrame . $eval (
2189
+ ".error-counter" ,
2190
+ ( el ) => el . textContent ,
2191
+ ) ;
2192
+ expect ( errorCounter ) . toBe ( "ERROR 2/3" ) ;
2193
+ errorContent = await overlayFrame . $eval (
2194
+ ".error-message" ,
2195
+ ( el ) => el . textContent ,
2196
+ ) ;
2197
+ expect ( errorContent ) . toContain ( "Second error message" ) ;
2198
+
2199
+ // Test keyboard navigation - ⌘/Ctrl + →
2200
+ await page . keyboard . down (
2201
+ process . platform === "darwin" ? "Meta" : "Control" ,
2202
+ ) ;
2203
+ await page . keyboard . press ( "ArrowRight" ) ;
2204
+ await page . keyboard . up (
2205
+ process . platform === "darwin" ? "Meta" : "Control" ,
2206
+ ) ;
2207
+ await delay ( 100 ) ;
2208
+
2209
+ // Verify we moved to third error
2210
+ errorCounter = await overlayFrame . $eval (
2211
+ ".error-counter" ,
2212
+ ( el ) => el . textContent ,
2213
+ ) ;
2214
+ expect ( errorCounter ) . toBe ( "ERROR 3/3" ) ;
2215
+ errorContent = await overlayFrame . $eval (
2216
+ ".error-message" ,
2217
+ ( el ) => el . textContent ,
2218
+ ) ;
2219
+ expect ( errorContent ) . toContain ( "Third error message" ) ;
2220
+
2221
+ // Test keyboard navigation - ⌘/Ctrl + ← (going back to previous error)
2222
+ await page . keyboard . down (
2223
+ process . platform === "darwin" ? "Meta" : "Control" ,
2224
+ ) ;
2225
+ await page . keyboard . press ( "ArrowLeft" ) ;
2226
+ await page . keyboard . up (
2227
+ process . platform === "darwin" ? "Meta" : "Control" ,
2228
+ ) ;
2229
+ await delay ( 100 ) ;
2230
+
2231
+ // Verify we moved back to second error
2232
+ errorCounter = await overlayFrame . $eval (
2233
+ ".error-counter" ,
2234
+ ( el ) => el . textContent ,
2235
+ ) ;
2236
+ expect ( errorCounter ) . toBe ( "ERROR 2/3" ) ;
2237
+ errorContent = await overlayFrame . $eval (
2238
+ ".error-message" ,
2239
+ ( el ) => el . textContent ,
2240
+ ) ;
2241
+ expect ( errorContent ) . toContain ( "Second error message" ) ;
2242
+
2243
+ // Ensure no Trusted Types violations were reported
2244
+ expect (
2245
+ consoleMessages . filter ( ( item ) =>
2246
+ / r e q u i r e s ' T r u s t e d H T M L ' a s s i g n m e n t / . test ( item ) ,
2247
+ ) ,
2248
+ ) . toHaveLength ( 0 ) ;
2249
+ } catch ( error ) {
2250
+ throw error ;
2251
+ } finally {
2252
+ await browser . close ( ) ;
2253
+ await server . stop ( ) ;
2254
+ }
2255
+ } ) ;
2127
2256
} ) ;
0 commit comments