Skip to content

Commit a28b94e

Browse files
ergunshDevtools-frontend LUCI CQ
authored andcommitted
[AiAssistance] Fix not showing blockedByCrossOrigin after hide
See the bug for more details Fixed: 398839335 Change-Id: I574782f044cdbed08f35abe56834d0e22921b270 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6298135 Reviewed-by: Nikolay Vitkov <[email protected]> Auto-Submit: Ergün Erdoğmuş <[email protected]> Commit-Queue: Ergün Erdoğmuş <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]>
1 parent 71631b3 commit a28b94e

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

front_end/panels/ai_assistance/AiAssistancePanel.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,49 @@ describeWithMockConnection('AI Assistance Panel', () => {
888888
},
889889
]);
890890
});
891+
892+
it('blocks input on cross origin request, when the selected context is changed while the panel was hidden',
893+
async () => {
894+
const networkRequest = createNetworkRequest({
895+
url: urlString`https://a.test`,
896+
});
897+
UI.Context.Context.instance().setFlavor(SDK.NetworkRequest.NetworkRequest, networkRequest);
898+
899+
const {panel, expectViewUpdate} = await createAiAssistancePanel({
900+
aidaClient: mockAidaClient([
901+
[{explanation: 'test'}],
902+
])
903+
});
904+
const updatedViewInput = await expectViewUpdate(() => {
905+
panel.handleAction('drjones.network-floating-button');
906+
});
907+
908+
assert.isFalse(updatedViewInput.blockedByCrossOrigin);
909+
assert.strictEqual(updatedViewInput.selectedContext?.getItem(), networkRequest);
910+
911+
// Send a query for https://a.test.
912+
await expectViewUpdate(() => {
913+
panel.handleAction('drjones.network-floating-button');
914+
updatedViewInput.onTextSubmit('test');
915+
});
916+
917+
// Hide the panel
918+
panel.hideWidget();
919+
920+
// Change context to https://b.test.
921+
const networkRequest2 = createNetworkRequest({
922+
url: urlString`https://b.test`,
923+
});
924+
UI.Context.Context.instance().setFlavor(SDK.NetworkRequest.NetworkRequest, networkRequest2);
925+
926+
// Show the widget again
927+
const updatedViewInputWithCrossOriginContext = await expectViewUpdate(() => {
928+
panel.showWidget();
929+
});
930+
931+
assert.isTrue(updatedViewInputWithCrossOriginContext.blockedByCrossOrigin);
932+
assert.strictEqual(updatedViewInputWithCrossOriginContext.selectedContext?.getItem(), networkRequest2);
933+
});
891934
});
892935

893936
describe('auto agent selection for panels', () => {

front_end/panels/ai_assistance/AiAssistancePanel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ export class AiAssistancePanel extends UI.Panel.Panel {
647647
this.#selectedPerformanceInsight =
648648
createPerfInsightContext(UI.Context.Context.instance().flavor(TimelineUtils.InsightAIContext.ActiveInsight));
649649
this.#selectedFile = createFileContext(UI.Context.Context.instance().flavor(Workspace.UISourceCode.UISourceCode));
650-
this.#selectedContext = this.#getConversationContext();
650+
this.#onContextSelectionChanged();
651651
this.requestUpdate();
652652

653653
this.#aiAssistanceEnabledSetting?.addChangeListener(this.requestUpdate, this);

0 commit comments

Comments
 (0)