refactor: use loadFile when appropriate in tests (#14422)
This commit is contained in:
		
					parent
					
						
							
								e8782f2c2d
							
						
					
				
			
			
				commit
				
					
						c63014c256
					
				
			
		
					 13 changed files with 115 additions and 137 deletions
				
			
		| 
						 | 
				
			
			@ -75,7 +75,7 @@ describe('chromium feature', () => {
 | 
			
		|||
      w = new BrowserWindow({show: false})
 | 
			
		||||
      w.webContents.once('did-finish-load', () => { done() })
 | 
			
		||||
      w.webContents.once('crashed', () => done(new Error('WebContents crashed.')))
 | 
			
		||||
      w.loadURL(`file://${fixtures}/pages/external-string.html`)
 | 
			
		||||
      w.loadFile(path.join(fixtures, 'pages', 'external-string.html'))
 | 
			
		||||
    })
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -89,7 +89,7 @@ describe('chromium feature', () => {
 | 
			
		|||
      })
 | 
			
		||||
      w.webContents.once('did-finish-load', () => { done() })
 | 
			
		||||
      w.webContents.once('crashed', () => done(new Error('WebContents crashed.')))
 | 
			
		||||
      w.loadURL(`file://${fixtures}/pages/jquery.html`)
 | 
			
		||||
      w.loadFile(path.join(fixtures, 'pages', 'jquery.html'))
 | 
			
		||||
    })
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -162,7 +162,7 @@ describe('chromium feature', () => {
 | 
			
		|||
          })
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
      w.loadURL(`file://${fixtures}/pages/media-id-reset.html`)
 | 
			
		||||
      w.loadFile(path.join(fixtures, 'pages', 'media-id-reset.html'))
 | 
			
		||||
    })
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -201,7 +201,7 @@ describe('chromium feature', () => {
 | 
			
		|||
        }
 | 
			
		||||
      })
 | 
			
		||||
      w.webContents.on('crashed', () => done(new Error('WebContents crashed.')))
 | 
			
		||||
      w.loadURL(`file://${fixtures}/pages/service-worker/index.html`)
 | 
			
		||||
      w.loadFile(path.join(fixtures, 'pages', 'service-worker', 'index.html'))
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    it('should register for intercepted file scheme', (done) => {
 | 
			
		||||
| 
						 | 
				
			
			@ -239,7 +239,7 @@ describe('chromium feature', () => {
 | 
			
		|||
        }
 | 
			
		||||
      })
 | 
			
		||||
      w.webContents.on('crashed', () => done(new Error('WebContents crashed.')))
 | 
			
		||||
      w.loadURL(`file://${fixtures}/pages/service-worker/index.html`)
 | 
			
		||||
      w.loadFile(path.join(fixtures, 'pages', 'service-worker', 'index.html'))
 | 
			
		||||
    })
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -280,7 +280,7 @@ describe('chromium feature', () => {
 | 
			
		|||
          callback(true)
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
      w.loadURL(`file://${fixtures}/pages/geolocation/index.html`)
 | 
			
		||||
      w.loadFile(path.join(fixtures, 'pages', 'geolocation', 'index.html'))
 | 
			
		||||
    })
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -333,7 +333,7 @@ describe('chromium feature', () => {
 | 
			
		|||
          w.close()
 | 
			
		||||
          done()
 | 
			
		||||
        })
 | 
			
		||||
        w.loadURL(`file://${fixtures}/pages/window-open.html`)
 | 
			
		||||
        w.loadFile(path.join(fixtures, 'pages', 'window-open.html'))
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -454,7 +454,7 @@ describe('chromium feature', () => {
 | 
			
		|||
 | 
			
		||||
    it('handles cycles when merging the parent options into the child options', (done) => {
 | 
			
		||||
      w = BrowserWindow.fromId(ipcRenderer.sendSync('create-window-with-options-cycle'))
 | 
			
		||||
      w.loadURL(`file://${fixtures}/pages/window-open.html`)
 | 
			
		||||
      w.loadFile(path.join(fixtures, 'pages', 'window-open.html'))
 | 
			
		||||
      w.webContents.once('new-window', (event, url, frameName, disposition, options) => {
 | 
			
		||||
        assert.equal(options.show, false)
 | 
			
		||||
        assert.deepEqual(options.foo, {
 | 
			
		||||
| 
						 | 
				
			
			@ -572,14 +572,13 @@ describe('chromium feature', () => {
 | 
			
		|||
 | 
			
		||||
  describe('window.opener', () => {
 | 
			
		||||
    let url = `file://${fixtures}/pages/window-opener.html`
 | 
			
		||||
 | 
			
		||||
    it('is null for main window', (done) => {
 | 
			
		||||
      w = new BrowserWindow({ show: false })
 | 
			
		||||
      w.webContents.once('ipc-message', (event, args) => {
 | 
			
		||||
        assert.deepEqual(args, ['opener', null])
 | 
			
		||||
        done()
 | 
			
		||||
      })
 | 
			
		||||
      w.loadURL(url)
 | 
			
		||||
      w.loadFile(path.join(fixtures, 'pages', 'window-opener.html'))
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    it('is not null for window opened by window.open', (done) => {
 | 
			
		||||
| 
						 | 
				
			
			@ -1159,7 +1158,7 @@ describe('chromium feature', () => {
 | 
			
		|||
          assert.equal(parsedURL.query.src, pagePath)
 | 
			
		||||
          assert.equal(w.webContents.getTitle(), 'cat.pdf')
 | 
			
		||||
        })
 | 
			
		||||
        w.webContents.loadURL(pagePath)
 | 
			
		||||
        w.loadFile(path.join(fixtures, 'pages', page))
 | 
			
		||||
      }
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue