@@ -1980,36 +1980,43 @@ test('should show all actions', async ({ runAndTrace, page }) => {
19801980 ] ) ;
19811981} ) ;
19821982
1983- test ( 'should handle failed snapshots due to dialog' , async ( { page, server, runAndTrace } ) => {
1984- const traceViewer = await runAndTrace ( async ( ) => {
1985- await page . setContent ( `
1986- <head>
1987- <style>
1988- button { color: red; }
1989- </style>
1990- </head>
1991- <body>
1992- <button>Click me</button>
1993- <script>
1994- const button = document.querySelector('button');
1995- window.history.pushState({ page: 'stay' }, '', window.location.href);
1996- window.addEventListener('popstate', () => {
1997- if (window.confirm('ready?'))
1998- button.textContent = 'Clicked';
1999- });
2000- </script>
2001- </body>
2002- ` ) ;
2003- let dialogMessage = '' ;
2004- page . on ( 'dialog' , async dialog => {
2005- dialogMessage = dialog . message ( ) ;
2006- await dialog . accept ( ) ;
1983+ test . describe ( ( ) => {
1984+ // NOTE: In Firefox/WebKit, history.pushState() requires a SecureContext.
1985+ // On http/about:blank it throws "The operation is insecure".
1986+ test . use ( { ignoreHTTPSErrors : true } ) ;
1987+
1988+ test ( 'should handle failed snapshots due to dialog' , async ( { page, httpsServer, runAndTrace } ) => {
1989+ const traceViewer = await runAndTrace ( async ( ) => {
1990+ await page . goto ( httpsServer . EMPTY_PAGE ) ;
1991+ await page . setContent ( `
1992+ <head>
1993+ <style>
1994+ button { color: red; }
1995+ </style>
1996+ </head>
1997+ <body>
1998+ <button>Click me</button>
1999+ <script>
2000+ const button = document.querySelector('button');
2001+ window.history.pushState({ page: 'stay' }, '', window.location.href);
2002+ window.addEventListener('popstate', () => {
2003+ if (window.confirm('ready?'))
2004+ button.textContent = 'Clicked';
2005+ });
2006+ </script>
2007+ </body>
2008+ ` ) ;
2009+ let dialogMessage = '' ;
2010+ page . on ( 'dialog' , async dialog => {
2011+ dialogMessage = dialog . message ( ) ;
2012+ await dialog . accept ( ) ;
2013+ } ) ;
2014+ await page . goBack ( ) ;
2015+ await expect . poll ( ( ) => dialogMessage ) . toBe ( 'ready?' ) ;
2016+ await expect ( page . getByRole ( 'button' ) ) . toHaveText ( 'Clicked' ) ;
20072017 } ) ;
2008- await page . goBack ( ) ;
2009- await expect . poll ( ( ) => dialogMessage ) . toBe ( 'ready?' ) ;
2010- await expect ( page . getByRole ( 'button' ) ) . toHaveText ( 'Clicked' ) ;
2011- } ) ;
20122018
2013- const frame = await traceViewer . snapshotFrame ( 'Expect' ) ;
2014- await expect ( frame . getByRole ( 'button' ) ) . toHaveCSS ( 'color' , 'rgb(255, 0, 0)' ) ;
2019+ const frame = await traceViewer . snapshotFrame ( 'Expect' ) ;
2020+ await expect ( frame . getByRole ( 'button' ) ) . toHaveCSS ( 'color' , 'rgb(255, 0, 0)' ) ;
2021+ } ) ;
20152022} ) ;
0 commit comments