docs: move protocol-ns to protocol.md (#23883)
* docs: move protocol-ns to protocol.md * chore: fix up tests and implement missing pieces required for tests
This commit is contained in:
parent
edc5050a2e
commit
d3fa5ed1e8
13 changed files with 285 additions and 733 deletions
|
@ -312,11 +312,11 @@ describe('session module', () => {
|
|||
});
|
||||
afterEach(closeAllWindows);
|
||||
|
||||
it('does not affect defaultSession', async () => {
|
||||
const result1 = await protocol.isProtocolHandled(protocolName);
|
||||
it('does not affect defaultSession', () => {
|
||||
const result1 = protocol.isProtocolRegistered(protocolName);
|
||||
expect(result1).to.equal(false);
|
||||
|
||||
const result2 = await customSession.protocol.isProtocolHandled(protocolName);
|
||||
const result2 = customSession.protocol.isProtocolRegistered(protocolName);
|
||||
expect(result2).to.equal(true);
|
||||
});
|
||||
|
||||
|
@ -424,18 +424,16 @@ describe('session module', () => {
|
|||
if (request.method === 'GET') {
|
||||
callback({ data: content, mimeType: 'text/html' });
|
||||
} else if (request.method === 'POST') {
|
||||
const uuid = request.uploadData[1].blobUUID;
|
||||
const uuid = request.uploadData![1].blobUUID;
|
||||
expect(uuid).to.be.a('string');
|
||||
session.defaultSession.getBlobData(uuid!).then(result => {
|
||||
expect(result.toString()).to.equal(postData);
|
||||
done();
|
||||
});
|
||||
}
|
||||
}, (error) => {
|
||||
if (error) return done(error);
|
||||
const w = new BrowserWindow({ show: false });
|
||||
w.loadURL(url);
|
||||
});
|
||||
const w = new BrowserWindow({ show: false });
|
||||
w.loadURL(url);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -644,18 +642,16 @@ describe('session module', () => {
|
|||
const handler = (ignoredError: any, callback: Function) => {
|
||||
callback({ url: `${url}:${port}` });
|
||||
};
|
||||
protocol.registerHttpProtocol(protocolName, handler, (error) => {
|
||||
if (error) return done(error);
|
||||
const w = new BrowserWindow({ show: false });
|
||||
w.webContents.session.once('will-download', function (e, item) {
|
||||
item.savePath = downloadFilePath;
|
||||
item.on('done', function (e, state) {
|
||||
assertDownload(state, item, true);
|
||||
done();
|
||||
});
|
||||
protocol.registerHttpProtocol(protocolName, handler);
|
||||
const w = new BrowserWindow({ show: false });
|
||||
w.webContents.session.once('will-download', function (e, item) {
|
||||
item.savePath = downloadFilePath;
|
||||
item.on('done', function (e, state) {
|
||||
assertDownload(state, item, true);
|
||||
done();
|
||||
});
|
||||
w.webContents.downloadURL(`${protocolName}://item`);
|
||||
});
|
||||
w.webContents.downloadURL(`${protocolName}://item`);
|
||||
});
|
||||
|
||||
it('can download using WebView.downloadURL', async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue