Add failing spec for webview visiblity changes
This commit is contained in:
		
					parent
					
						
							
								b86ded3b54
							
						
					
				
			
			
				commit
				
					
						1e15ce6ccd
					
				
			
		
					 3 changed files with 40 additions and 0 deletions
				
			
		
							
								
								
									
										11
									
								
								spec/fixtures/pages/visibilitychange.html
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								spec/fixtures/pages/visibilitychange.html
									
										
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,11 @@
 | 
				
			||||||
 | 
					<html>
 | 
				
			||||||
 | 
					<body>
 | 
				
			||||||
 | 
					<script type="text/javascript" charset="utf-8">
 | 
				
			||||||
 | 
					  const {ipcRenderer} = require('electron')
 | 
				
			||||||
 | 
					  ipcRenderer.send('pong', document.visibilityState, document.hidden)
 | 
				
			||||||
 | 
					  document.addEventListener('visibilitychange', function () {
 | 
				
			||||||
 | 
					    ipcRenderer.send('pong', document.visibilityState, document.hidden)
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					</body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
							
								
								
									
										8
									
								
								spec/fixtures/pages/webview-visibilitychange.html
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								spec/fixtures/pages/webview-visibilitychange.html
									
										
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,8 @@
 | 
				
			||||||
 | 
					<html>
 | 
				
			||||||
 | 
					<body>
 | 
				
			||||||
 | 
					<script>
 | 
				
			||||||
 | 
					  console.log(document.visibilityState, document.hidden)
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					<webview nodeintegration src="visibilitychange.html"/>
 | 
				
			||||||
 | 
					</body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
| 
						 | 
					@ -867,4 +867,25 @@ describe('<webview> tag', function () {
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
    w.loadURL('file://' + fixtures + '/pages/webview-zoom-factor.html')
 | 
					    w.loadURL('file://' + fixtures + '/pages/webview-zoom-factor.html')
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('has the initial hidden state and receives visibilitychange events', function (done) {
 | 
				
			||||||
 | 
					    w = new BrowserWindow({
 | 
				
			||||||
 | 
					      show: false
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ipcMain.once('pong', function (event, visibilityState, hidden) {
 | 
				
			||||||
 | 
					      assert.equal(visibilityState, 'hidden')
 | 
				
			||||||
 | 
					      assert.equal(hidden, true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      w.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', 'visible')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      ipcMain.once('pong', function (event, visibilityState, hidden) {
 | 
				
			||||||
 | 
					        assert.equal(visibilityState, 'visible')
 | 
				
			||||||
 | 
					        assert.equal(hidden, false)
 | 
				
			||||||
 | 
					        done()
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    w.loadURL('file://' + fixtures + '/pages/webview-visibilitychange.html')
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue