chore: cleanup spec-main/ambient.d.ts (#32363)
This commit is contained in:
parent
88ae6c0635
commit
7678a0aebb
5 changed files with 11 additions and 29 deletions
|
@ -317,7 +317,6 @@ class WebContents : public ExclusiveAccessContext,
|
||||||
std::vector<base::FilePath> GetPreloadPaths() const;
|
std::vector<base::FilePath> GetPreloadPaths() const;
|
||||||
|
|
||||||
// Returns the web preferences of current WebContents.
|
// Returns the web preferences of current WebContents.
|
||||||
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate) const;
|
|
||||||
v8::Local<v8::Value> GetLastWebPreferences(v8::Isolate* isolate) const;
|
v8::Local<v8::Value> GetLastWebPreferences(v8::Isolate* isolate) const;
|
||||||
|
|
||||||
// Returns the owner window.
|
// Returns the owner window.
|
||||||
|
|
12
spec-main/ambient.d.ts
vendored
12
spec-main/ambient.d.ts
vendored
|
@ -1,14 +1,4 @@
|
||||||
declare let standardScheme: string;
|
declare let standardScheme: string;
|
||||||
|
declare let serviceWorkerScheme: string;
|
||||||
declare namespace Electron {
|
|
||||||
interface WebContents {
|
|
||||||
getOwnerBrowserWindow(): BrowserWindow | null;
|
|
||||||
getWebPreferences(): WebPreferences | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Session {
|
|
||||||
destroy(): void;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module 'dbus-native';
|
declare module 'dbus-native';
|
||||||
|
|
|
@ -743,7 +743,6 @@ describe('protocol module', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('protocol.registerSchemesAsPrivileged allowServiceWorkers', () => {
|
describe('protocol.registerSchemesAsPrivileged allowServiceWorkers', () => {
|
||||||
const { serviceWorkerScheme } = global as any;
|
|
||||||
protocol.registerStringProtocol(serviceWorkerScheme, (request, cb) => {
|
protocol.registerStringProtocol(serviceWorkerScheme, (request, cb) => {
|
||||||
if (request.url.endsWith('.js')) {
|
if (request.url.endsWith('.js')) {
|
||||||
cb({
|
cb({
|
||||||
|
@ -773,7 +772,6 @@ describe('protocol module', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('protocol.registerSchemesAsPrivileged standard', () => {
|
describe('protocol.registerSchemesAsPrivileged standard', () => {
|
||||||
const standardScheme = (global as any).standardScheme;
|
|
||||||
const origin = `${standardScheme}://fake-host`;
|
const origin = `${standardScheme}://fake-host`;
|
||||||
const imageURL = `${origin}/test.png`;
|
const imageURL = `${origin}/test.png`;
|
||||||
const filePath = path.join(fixturesPath, 'pages', 'b.html');
|
const filePath = path.join(fixturesPath, 'pages', 'b.html');
|
||||||
|
@ -854,7 +852,6 @@ describe('protocol module', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('protocol.registerSchemesAsPrivileged cors-fetch', function () {
|
describe('protocol.registerSchemesAsPrivileged cors-fetch', function () {
|
||||||
const standardScheme = (global as any).standardScheme;
|
|
||||||
let w: BrowserWindow = null as unknown as BrowserWindow;
|
let w: BrowserWindow = null as unknown as BrowserWindow;
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
w = new BrowserWindow({ show: false });
|
w = new BrowserWindow({ show: false });
|
||||||
|
@ -957,7 +954,6 @@ describe('protocol module', () => {
|
||||||
const pagePath = path.join(fixturesPath, 'pages', 'video.html');
|
const pagePath = path.join(fixturesPath, 'pages', 'video.html');
|
||||||
const videoSourceImagePath = path.join(fixturesPath, 'video-source-image.webp');
|
const videoSourceImagePath = path.join(fixturesPath, 'video-source-image.webp');
|
||||||
const videoPath = path.join(fixturesPath, 'video.webm');
|
const videoPath = path.join(fixturesPath, 'video.webm');
|
||||||
const standardScheme = (global as any).standardScheme;
|
|
||||||
let w: BrowserWindow = null as unknown as BrowserWindow;
|
let w: BrowserWindow = null as unknown as BrowserWindow;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
|
|
@ -893,7 +893,6 @@ describe('webContents module', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('zoom api', () => {
|
describe('zoom api', () => {
|
||||||
const scheme = (global as any).standardScheme;
|
|
||||||
const hostZoomMap: Record<string, number> = {
|
const hostZoomMap: Record<string, number> = {
|
||||||
host1: 0.3,
|
host1: 0.3,
|
||||||
host2: 0.7,
|
host2: 0.7,
|
||||||
|
@ -902,7 +901,7 @@ describe('webContents module', () => {
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
const protocol = session.defaultSession.protocol;
|
const protocol = session.defaultSession.protocol;
|
||||||
protocol.registerStringProtocol(scheme, (request, callback) => {
|
protocol.registerStringProtocol(standardScheme, (request, callback) => {
|
||||||
const response = `<script>
|
const response = `<script>
|
||||||
const {ipcRenderer} = require('electron')
|
const {ipcRenderer} = require('electron')
|
||||||
ipcRenderer.send('set-zoom', window.location.hostname)
|
ipcRenderer.send('set-zoom', window.location.hostname)
|
||||||
|
@ -916,7 +915,7 @@ describe('webContents module', () => {
|
||||||
|
|
||||||
after(() => {
|
after(() => {
|
||||||
const protocol = session.defaultSession.protocol;
|
const protocol = session.defaultSession.protocol;
|
||||||
protocol.unregisterProtocol(scheme);
|
protocol.unregisterProtocol(standardScheme);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(closeAllWindows);
|
afterEach(closeAllWindows);
|
||||||
|
@ -1008,7 +1007,7 @@ describe('webContents module', () => {
|
||||||
if (finalNavigation) {
|
if (finalNavigation) {
|
||||||
done();
|
done();
|
||||||
} else {
|
} else {
|
||||||
w.loadURL(`${scheme}://host2`);
|
w.loadURL(`${standardScheme}://host2`);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
done(e);
|
done(e);
|
||||||
|
@ -1025,7 +1024,7 @@ describe('webContents module', () => {
|
||||||
done(e);
|
done(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
w.loadURL(`${scheme}://host1`);
|
w.loadURL(`${standardScheme}://host1`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can propagate zoom level across same session', async () => {
|
it('can propagate zoom level across same session', async () => {
|
||||||
|
@ -1037,10 +1036,10 @@ describe('webContents module', () => {
|
||||||
w2.close();
|
w2.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
await w.loadURL(`${scheme}://host3`);
|
await w.loadURL(`${standardScheme}://host3`);
|
||||||
w.webContents.zoomLevel = hostZoomMap.host3;
|
w.webContents.zoomLevel = hostZoomMap.host3;
|
||||||
|
|
||||||
await w2.loadURL(`${scheme}://host3`);
|
await w2.loadURL(`${standardScheme}://host3`);
|
||||||
const zoomLevel1 = w.webContents.zoomLevel;
|
const zoomLevel1 = w.webContents.zoomLevel;
|
||||||
expect(zoomLevel1).to.equal(hostZoomMap.host3);
|
expect(zoomLevel1).to.equal(hostZoomMap.host3);
|
||||||
|
|
||||||
|
@ -1057,7 +1056,7 @@ describe('webContents module', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const protocol = w2.webContents.session.protocol;
|
const protocol = w2.webContents.session.protocol;
|
||||||
protocol.registerStringProtocol(scheme, (request, callback) => {
|
protocol.registerStringProtocol(standardScheme, (request, callback) => {
|
||||||
callback('hello');
|
callback('hello');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1065,13 +1064,13 @@ describe('webContents module', () => {
|
||||||
w2.setClosable(true);
|
w2.setClosable(true);
|
||||||
w2.close();
|
w2.close();
|
||||||
|
|
||||||
protocol.unregisterProtocol(scheme);
|
protocol.unregisterProtocol(standardScheme);
|
||||||
});
|
});
|
||||||
|
|
||||||
await w.loadURL(`${scheme}://host3`);
|
await w.loadURL(`${standardScheme}://host3`);
|
||||||
w.webContents.zoomLevel = hostZoomMap.host3;
|
w.webContents.zoomLevel = hostZoomMap.host3;
|
||||||
|
|
||||||
await w2.loadURL(`${scheme}://host3`);
|
await w2.loadURL(`${standardScheme}://host3`);
|
||||||
const zoomLevel1 = w.webContents.zoomLevel;
|
const zoomLevel1 = w.webContents.zoomLevel;
|
||||||
expect(zoomLevel1).to.equal(hostZoomMap.host3);
|
expect(zoomLevel1).to.equal(hostZoomMap.host3);
|
||||||
|
|
||||||
|
|
|
@ -585,7 +585,6 @@ describe('chromium features', () => {
|
||||||
|
|
||||||
it('should register for custom scheme', (done) => {
|
it('should register for custom scheme', (done) => {
|
||||||
const customSession = session.fromPartition('custom-scheme');
|
const customSession = session.fromPartition('custom-scheme');
|
||||||
const { serviceWorkerScheme } = global as any;
|
|
||||||
customSession.protocol.registerFileProtocol(serviceWorkerScheme, (request, callback) => {
|
customSession.protocol.registerFileProtocol(serviceWorkerScheme, (request, callback) => {
|
||||||
let file = url.parse(request.url).pathname!;
|
let file = url.parse(request.url).pathname!;
|
||||||
if (file[0] === '/' && process.platform === 'win32') file = file.slice(1);
|
if (file[0] === '/' && process.platform === 'win32') file = file.slice(1);
|
||||||
|
@ -1250,7 +1249,6 @@ describe('chromium features', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('enableWebSQL webpreference', () => {
|
describe('enableWebSQL webpreference', () => {
|
||||||
const standardScheme = (global as any).standardScheme;
|
|
||||||
const origin = `${standardScheme}://fake-host`;
|
const origin = `${standardScheme}://fake-host`;
|
||||||
const filePath = path.join(fixturesPath, 'pages', 'storage', 'web_sql.html');
|
const filePath = path.join(fixturesPath, 'pages', 'storage', 'web_sql.html');
|
||||||
const sqlPartition = 'web-sql-preference-test';
|
const sqlPartition = 'web-sql-preference-test';
|
||||||
|
|
Loading…
Reference in a new issue