|
@@ -4,9 +4,10 @@ import * as path from 'node:path';
|
|
|
import * as fs from 'node:fs';
|
|
|
import * as qs from 'node:querystring';
|
|
|
import * as http from 'node:http';
|
|
|
+import * as nodeUrl from 'node:url';
|
|
|
import * as os from 'node:os';
|
|
|
import { AddressInfo } from 'node:net';
|
|
|
-import { app, BrowserWindow, BrowserView, dialog, ipcMain, OnBeforeSendHeadersListenerDetails, protocol, screen, webContents, webFrameMain, session, WebContents, WebFrameMain } from 'electron/main';
|
|
|
+import { app, BrowserWindow, BrowserView, dialog, ipcMain, OnBeforeSendHeadersListenerDetails, net, protocol, screen, webContents, webFrameMain, session, WebContents, WebFrameMain } from 'electron/main';
|
|
|
|
|
|
import { emittedUntil, emittedNTimes } from './lib/events-helpers';
|
|
|
import { ifit, ifdescribe, defer, listen } from './lib/spec-helpers';
|
|
@@ -296,15 +297,16 @@ describe('BrowserWindow module', () => {
|
|
|
describe('BrowserWindow.loadURL(url)', () => {
|
|
|
let w: BrowserWindow;
|
|
|
const scheme = 'other';
|
|
|
- const srcPath = path.join(fixtures, 'api', 'loaded-from-dataurl.js');
|
|
|
+ const srcPath = path.join(fixtures, 'api');
|
|
|
before(() => {
|
|
|
- protocol.registerFileProtocol(scheme, (request, callback) => {
|
|
|
- callback(srcPath);
|
|
|
+ protocol.handle(scheme, (req) => {
|
|
|
+ const reqURL = new URL(req.url);
|
|
|
+ return net.fetch(nodeUrl.pathToFileURL(path.join(srcPath, reqURL.pathname)).toString());
|
|
|
});
|
|
|
});
|
|
|
|
|
|
after(() => {
|
|
|
- protocol.unregisterProtocol(scheme);
|
|
|
+ protocol.unhandle(scheme);
|
|
|
});
|
|
|
|
|
|
beforeEach(() => {
|
|
@@ -496,7 +498,7 @@ describe('BrowserWindow module', () => {
|
|
|
// FIXME(#43730): fix underlying bug and re-enable asap
|
|
|
it.skip('should support base url for data urls', async () => {
|
|
|
await w
|
|
|
- .loadURL('data:text/html,<script src="loaded-from-dataurl.js"></script>', { baseURLForDataURL: `other://${path.join(fixtures, 'api')}${path.sep}` })
|
|
|
+ .loadURL('data:text/html,<script src="loaded-from-dataurl.js"></script>', { baseURLForDataURL: 'other://' })
|
|
|
.catch((e) => console.log(e));
|
|
|
expect(await w.webContents.executeJavaScript('window.ping')).to.equal('pong');
|
|
|
});
|