This repository was archived by the owner on Aug 4, 2026. It is now read-only.
feat: add iframe target to recorded actions - #8
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds iframe-awareness to the action recorder so recorded actions can be replayed/generated against elements inside iframes (rather than always targeting the top document).
Changes:
- Inject the recorder content script into all frames and capture the sender
frameIdfor recorded actions. - Resolve an iframe CSS selector from a
frameId(viachrome.webNavigation) and attach it to recorded actions (iframeSelector), then use it during script/preaction generation. - Show the recording badge only in the top frame; add
webNavigationpermission.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
background.js |
Injects recorder into all frames; resolves iframeSelector for frame messages using webNavigation and uses it in recorded actions. |
manifest.json |
Adds the webNavigation permission required to enumerate frames. |
recorder.js |
Ensures the recording badge only renders in the top frame when injected into all frames. |
script_generator.js |
Updates script/preaction generation to scope selectors/actions to an iframe document/target when iframeSelector is present. |
Comments suppressed due to low confidence (1)
script_generator.js:1873
convertRecordingToPreactionsaddstargetfor click/type/select, butsetCheckedstill emits a script without anytarget. Checkbox/radio recordings inside iframes will therefore lose iframe targeting when saved as preactions.
preactions.push(preaction);
continue;
}
if (action.type === "setChecked") {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3229
to
+3233
| const frameId = sender.frameId; | ||
| if (frameId && frameId !== 0) { | ||
| resolveIframeSelector(tabId, frameId).then((iframeSelector) => { | ||
| rec.actions.push({ ...message.payload, iframeSelector: iframeSelector ?? null }); | ||
| }); |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
background.js:3238
stop-recordingnow runs the cleanup in all frames and setswindow.__vpRecorderInstalled = false. Sincerecorder.jsdoes not remove its event listeners, restarting recording in the same tab/frame can install duplicate listeners and produce duplicated recorded actions. This was already risky in the top frame; withallFrames: trueit can multiply across iframes.
await chrome.scripting.executeScript({
target: { tabId, allFrames: true },
func: () => {
document.getElementById("__vp-recorder-badge")?.remove();
window.__vpRecorderInstalled = false;
},
Comment on lines
+1867
to
+1869
| const preaction = { select: { field, value: action.value } }; | ||
| if (target) preaction.target = target; | ||
| preactions.push(preaction); |
Comment on lines
+2681
to
+2687
| const parentFrameId = frame.parentFrameId; | ||
| if (parentFrameId == null || parentFrameId < 0) return null; | ||
| const frameUrl = frame.url; | ||
|
|
||
| const results = await chrome.scripting.executeScript({ | ||
| target: { tabId, frameIds: [parentFrameId] }, | ||
| func: (url) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.