diff --git a/spec/api-app-spec.js b/spec/api-app-spec.js index 340132b95844..e341f7efa780 100644 --- a/spec/api-app-spec.js +++ b/spec/api-app-spec.js @@ -42,7 +42,7 @@ describe('electron module', () => { it('always returns the internal electron module', (done) => { ipcMain.once('answer', () => done()) - window.loadURL(`file://${path.join(__dirname, 'fixtures', 'api', 'electron-module-app', 'index.html')}`) + window.loadFile(path.join(__dirname, 'fixtures', 'api', 'electron-module-app', 'index.html')) }) }) }) diff --git a/spec/api-browser-window-affinity-spec.js b/spec/api-browser-window-affinity-spec.js index f90e784bed51..1bf59960c12e 100644 --- a/spec/api-browser-window-affinity-spec.js +++ b/spec/api-browser-window-affinity-spec.js @@ -22,7 +22,7 @@ describe('BrowserWindow with affinity module', () => { webPreferences: webPrefs || {} }) w.webContents.on('did-finish-load', () => { resolve(w) }) - w.loadURL(`file://${path.join(fixtures, 'api', 'blank.html')}`) + w.loadFile(path.join(fixtures, 'api', 'blank.html')) }) } diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 05a6bca51a8e..17d278ffc7e6 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -158,12 +158,12 @@ describe('BrowserWindow module', () => { assert.equal(String(content), 'unload') done() }) - w.loadURL('file://' + path.join(fixtures, 'api', 'unload.html')) + w.loadFile(path.join(fixtures, 'api', 'unload.html')) }) it('should emit beforeunload handler', (done) => { w.once('onbeforeunload', () => { done() }) w.webContents.on('did-finish-load', () => { w.close() }) - w.loadURL(`file://${path.join(fixtures, 'api', 'beforeunload-false.html')}`) + w.loadFile(path.join(fixtures, 'api', 'beforeunload-false.html')) }) it('should not crash when invoked synchronously inside navigation observer', (done) => { const events = [ @@ -205,11 +205,11 @@ describe('BrowserWindow module', () => { assert.equal(String(content), 'close') done() }) - w.loadURL(`file://${path.join(fixtures, 'api', 'close.html')}`) + w.loadFile(path.join(fixtures, 'api', 'close.html')) }) it('should emit beforeunload handler', (done) => { w.once('onbeforeunload', () => { done() }) - w.loadURL(`file://${path.join(fixtures, 'api', 'close-beforeunload-false.html')}`) + w.loadFile(path.join(fixtures, 'api', 'close-beforeunload-false.html')) }) }) @@ -255,7 +255,7 @@ describe('BrowserWindow module', () => { assert.equal(isMainFrame, false) done() }) - w.loadURL(`file://${path.join(fixtures, 'api', 'did-fail-load-iframe.html')}`) + w.loadFile(path.join(fixtures, 'api', 'did-fail-load-iframe.html')) }) it('does not crash in did-fail-provisional-load handler', (done) => { w.webContents.once('did-fail-provisional-load', () => { @@ -334,7 +334,7 @@ describe('BrowserWindow module', () => { it('allows the window to be closed from the event listener', (done) => { ipcRenderer.send('close-on-will-navigate', w.id) ipcRenderer.once('closed-on-will-navigate', () => { done() }) - w.loadURL(`file://${fixtures}/pages/will-navigate.html`) + w.loadFile(path.join(fixtures, 'pages', 'will-navigate.html')) }) }) @@ -1202,7 +1202,7 @@ describe('BrowserWindow module', () => { preload: preload } }) - w.loadURL(`file://${path.join(fixtures, 'api', 'preload.html')}`) + w.loadFile(path.join(fixtures, 'api', 'preload.html')) }) it('can successfully delete the Buffer global', (done) => { const preload = path.join(fixtures, 'module', 'delete-buffer.js') @@ -1217,7 +1217,7 @@ describe('BrowserWindow module', () => { preload: preload } }) - w.loadURL(`file://${path.join(fixtures, 'api', 'preload.html')}`) + w.loadFile(path.join(fixtures, 'api', 'preload.html')) }) }) @@ -1254,7 +1254,7 @@ describe('BrowserWindow module', () => { preload: path.join(fixtures, 'module', 'set-global-preload-3.js') } }) - w.loadURL('file://' + path.join(fixtures, 'api', 'preloads.html')) + w.loadFile(path.join(fixtures, 'api', 'preloads.html')) }) }) @@ -1273,7 +1273,7 @@ describe('BrowserWindow module', () => { additionalArguments: ['--my-magic-arg'] } }) - w.loadURL(`file://${path.join(fixtures, 'api', 'blank.html')}`) + w.loadFile(path.join(fixtures, 'api', 'blank.html')) }) it('adds extra value args to process.argv in the renderer process', (done) => { @@ -1290,7 +1290,7 @@ describe('BrowserWindow module', () => { additionalArguments: ['--my-magic-arg=foo'] } }) - w.loadURL(`file://${path.join(fixtures, 'api', 'blank.html')}`) + w.loadFile(path.join(fixtures, 'api', 'blank.html')) }) }) @@ -1310,7 +1310,7 @@ describe('BrowserWindow module', () => { nodeIntegration: false } }) - w.loadURL(`file://${path.join(fixtures, 'api', 'blank.html')}`) + w.loadFile(path.join(fixtures, 'api', 'blank.html')) }) }) @@ -1362,7 +1362,7 @@ describe('BrowserWindow module', () => { preload: preload } }) - w.loadURL('file://' + path.join(fixtures, 'api', 'preload.html')) + w.loadFile(path.join(fixtures, 'api', 'preload.html')) }) it('exposes ipcRenderer to preload script (path has special chars)', function (done) { @@ -1379,7 +1379,7 @@ describe('BrowserWindow module', () => { preload: preloadSpecialChars } }) - w.loadURL('file://' + path.join(fixtures, 'api', 'preload.html')) + w.loadFile(path.join(fixtures, 'api', 'preload.html')) }) it('exposes "exit" event to preload script', function (done) { @@ -1487,7 +1487,7 @@ describe('BrowserWindow module', () => { assert.equal(args.includes('--enable-sandbox'), true) done() }) - w.loadURL(`file://${path.join(fixtures, 'api', 'new-window.html')}`) + w.loadFile(path.join(fixtures, 'api', 'new-window.html')) }) it('should open windows with the options configured via new-window event listeners', (done) => { @@ -1506,7 +1506,7 @@ describe('BrowserWindow module', () => { assert.equal(webPreferences.foo, 'bar') done() }) - w.loadURL(`file://${path.join(fixtures, 'api', 'new-window.html')}`) + w.loadFile(path.join(fixtures, 'api', 'new-window.html')) }) it('should set ipc event sender correctly', (done) => { @@ -1630,7 +1630,7 @@ describe('BrowserWindow module', () => { done() }, 100) }) - w.loadURL('file://' + path.join(fixtures, 'pages', 'window-open.html')) + w.loadFile(path.join(fixtures, 'pages', 'window-open.html')) }) it('releases memory after popup is closed', (done) => { @@ -1747,7 +1747,7 @@ describe('BrowserWindow module', () => { preload: preload } }) - w.loadURL('file://' + path.join(fixtures, 'api', 'preload.html')) + w.loadFile(path.join(fixtures, 'api', 'preload.html')) }) it('webview in sandbox renderer', async () => { @@ -1760,7 +1760,7 @@ describe('BrowserWindow module', () => { webviewTag: true } }) - w.loadURL(`file://${fixtures}/pages/webview-did-attach-event.html`) + w.loadFile(path.join(fixtures, 'pages', 'webview-did-attach-event.html')) const [, webContents] = await emittedOnce(w.webContents, 'did-attach-webview') const [, id] = await emittedOnce(ipcMain, 'webview-dom-ready') @@ -1784,28 +1784,28 @@ describe('BrowserWindow module', () => { assert.equal(content, 'Hello') done() }) - w.loadURL(`file://${path.join(fixtures, 'api', 'native-window-open-blank.html')}`) + w.loadFile(path.join(fixtures, 'api', 'native-window-open-blank.html')) }) it('opens window of same domain with cross-scripting enabled', (done) => { ipcMain.once('answer', (event, content) => { assert.equal(content, 'Hello') done() }) - w.loadURL(`file://${path.join(fixtures, 'api', 'native-window-open-file.html')}`) + w.loadFile(path.join(fixtures, 'api', 'native-window-open-file.html')) }) it('blocks accessing cross-origin frames', (done) => { ipcMain.once('answer', (event, content) => { assert.equal(content, 'Blocked a frame with origin "file://" from accessing a cross-origin frame.') done() }) - w.loadURL(`file://${path.join(fixtures, 'api', 'native-window-open-cross-origin.html')}`) + w.loadFile(path.join(fixtures, 'api', 'native-window-open-cross-origin.html')) }) it('opens window from