fix(agent-browser): enable preview page domain
This commit is contained in:
@@ -579,9 +579,16 @@ describe('AgentBrowserModule', () => {
|
||||
'load:about:blank',
|
||||
'attach:1.3',
|
||||
'command:Target.setAutoAttach',
|
||||
'command:Page.enable',
|
||||
'command:Page.addScriptToEvaluateOnNewDocument',
|
||||
'load:http://127.0.0.1:4173/',
|
||||
]);
|
||||
expect(view.webContents.debugger.operationLog.indexOf('command:Page.enable'))
|
||||
.toBeLessThan(view.webContents.debugger.operationLog.indexOf(
|
||||
'command:Page.addScriptToEvaluateOnNewDocument',
|
||||
));
|
||||
expect(view.webContents.debugger.commands.find((command) => command.method === 'Page.enable')?.sessionRef)
|
||||
.toBeUndefined();
|
||||
expect(addScript?.params?.sessionRef).toBeUndefined();
|
||||
expect(addScript?.params?.source).toContain('globalThis.location?.origin');
|
||||
expect(addScript?.params?.source).toContain('http://127.0.0.1:13210/api/runtime/data/v1');
|
||||
@@ -745,6 +752,10 @@ describe('AgentBrowserModule', () => {
|
||||
});
|
||||
await vi.waitFor(() => {
|
||||
expect(view.webContents.debugger.commands).toEqual(expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
method: 'Page.enable',
|
||||
sessionRef: 'child-session',
|
||||
}),
|
||||
expect.objectContaining({
|
||||
method: 'Page.addScriptToEvaluateOnNewDocument',
|
||||
sessionRef: 'child-session',
|
||||
@@ -754,6 +765,15 @@ describe('AgentBrowserModule', () => {
|
||||
sessionRef: 'child-session',
|
||||
}),
|
||||
]));
|
||||
const childEnableIndex = view.webContents.debugger.commands.findIndex(
|
||||
(command) => command.method === 'Page.enable' && command.sessionRef === 'child-session',
|
||||
);
|
||||
const childAddScriptIndex = view.webContents.debugger.commands.findIndex(
|
||||
(command) => command.method === 'Page.addScriptToEvaluateOnNewDocument'
|
||||
&& command.sessionRef === 'child-session',
|
||||
);
|
||||
expect(childEnableIndex).toBeGreaterThanOrEqual(0);
|
||||
expect(childEnableIndex).toBeLessThan(childAddScriptIndex);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user