fix(agent-browser): preserve preview injection origin
This commit is contained in:
@@ -609,6 +609,33 @@ describe('AgentBrowserModule', () => {
|
||||
expect(externalGlobal.__MAKELORE_DATA__).toBeUndefined();
|
||||
});
|
||||
|
||||
it('uses the target Origin when the prime navigation reports about:blank', async () => {
|
||||
const adapter = new FakeAdapter();
|
||||
const preview = new FakePreviewDataSession();
|
||||
adapter.onCreate = (view) => {
|
||||
view.webContents.loadHandler = async (url) => {
|
||||
view.webContents.emit('did-navigate', {}, url);
|
||||
};
|
||||
view.webContents.debugger.responders.set('Page.addScriptToEvaluateOnNewDocument', async () => ({
|
||||
identifier: 'script-root',
|
||||
}));
|
||||
};
|
||||
const module = new AgentBrowserModule(adapter, { previewDataSession: preview });
|
||||
|
||||
await module.open({
|
||||
projectId: 'clock',
|
||||
projectPath,
|
||||
url: 'http://127.0.0.1:4173/',
|
||||
injectProjectData: true,
|
||||
});
|
||||
|
||||
expect(preview.opens).toEqual([{
|
||||
projectPath,
|
||||
origin: 'http://127.0.0.1:4173',
|
||||
browserGeneration: 1,
|
||||
}]);
|
||||
});
|
||||
|
||||
it('fails and tears down before target load when preview session setup fails', async () => {
|
||||
const adapter = new FakeAdapter();
|
||||
const preview = new FakePreviewDataSession();
|
||||
|
||||
Reference in New Issue
Block a user