Commit d58567d0 authored by Robert Knight's avatar Robert Knight

Remove strict checks on source/target frame roles

These checks had not been updated for the addition of the "profile" application.
Also at a conceptual level the responsibility for deciding which types of frames
are allowed to connect to each other belongs to the `PortProvider` in the host
frame, not the `PortFinder` in other frames.
parent fcf87072
......@@ -49,20 +49,6 @@ export class PortFinder implements Destroyable {
* @param target - the frame aiming to be discovered
*/
async discover(target: Frame): Promise<MessagePort> {
let isValidRequest = false;
if (
(this._source === 'guest' && target === 'host') ||
(this._source === 'guest' && target === 'sidebar') ||
(this._source === 'sidebar' && target === 'host') ||
(this._source === 'notebook' && target === 'sidebar')
) {
isValidRequest = true;
}
if (!isValidRequest) {
throw new Error('Invalid request of channel/port');
}
const requestId = generateHexString(6);
return new Promise((resolve, reject) => {
......
......@@ -87,18 +87,6 @@ describe('PortFinder', () => {
});
describe('#discover', () => {
['guest', 'invalid'].forEach(target =>
it('rejects if requesting an invalid port', async () => {
let error;
try {
await portFinder.discover(target);
} catch (e) {
error = e;
}
assert.equal(error.message, 'Invalid request of channel/port');
}),
);
it('sends port request to host frame', async () => {
const clock = sinon.useFakeTimers();
try {
......@@ -128,7 +116,7 @@ describe('PortFinder', () => {
{ source: 'sidebar', target: 'host' },
{ source: 'notebook', target: 'sidebar' },
].forEach(({ source, target }) =>
it('resolves if requesting a valid port', async () => {
it('resolves when port is returned', async () => {
const { port1 } = new MessageChannel();
let resolvedPort;
portFinder = createPortFinder(source);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment