Skip to content

Commit c20e376

Browse files
authored
v1.2.2 - Improve checkbox event. Update example file (#16)
* v1.2.2 - Improve checkbox event. Update example file * fix checkbox/radio handler
1 parent b33cd25 commit c20e376

8 files changed

Lines changed: 37 additions & 13 deletions

File tree

OUTPUT-EXAMPLE.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Result Example
1+
# Output Example
22

33
JSON example containing all possible step types produced by the sequence recorder.
44

@@ -124,6 +124,14 @@ JSON example containing all possible step types produced by the sequence recorde
124124
"type": "click",
125125
"value": "Submit",
126126
"frame": "#content-iframe"
127+
},
128+
{
129+
"timestamp": 1718724013000,
130+
"css": ".nested-btn",
131+
"xpath": "/html/body/div/button",
132+
"type": "click",
133+
"value": "Confirm",
134+
"frame": "#outer-iframe >>> #inner-iframe"
127135
}
128136
]
129137
```
@@ -153,4 +161,4 @@ JSON example containing all possible step types produced by the sequence recorde
153161
| `xpath` | XPath selector for the target element |
154162
| `type` | Event type identifier |
155163
| `value` | Element value or trimmed text content (max 20 chars for clicks) |
156-
| `frame` | CSS selector of the containing iframe, empty string if top-level |
164+
| `frame` | CSS selector of the containing iframe, empty string if top-level. For nested iframes, selectors are joined with ` >>> ` from outermost to innermost (e.g. `#outer-iframe >>> #inner-iframe`) |

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "snyk-api-and-web-record-sequence",
3-
"version": "1.2.0",
3+
"version": "1.2.2",
44
"description": "Snyk API & Web Record login/sequence",
55
"license": "MIT",
66
"scripts": {

src/manifest-firefox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Snyk API & Web Sequence Recorder",
3-
"version": "1.2.0",
3+
"version": "1.2.2",
44
"browser_specific_settings": {
55
"gecko": {
66
"id": "sequence-recorder@probely.com",

src/pages/Content/modules/collectEvents.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,27 @@ export function interceptEvents(event, doc, ifrSelector, callback) {
199199
) {
200200
return;
201201
}
202-
if (nodeName === 'label') {
203-
const forAttr = tgt.getAttribute('for');
204-
if (forAttr && document.getElementById(forAttr)) {
205-
// can be ignored... will fire checkbox
206-
return;
202+
const parentLabel = tgt.closest && tgt.closest('label');
203+
if (parentLabel) {
204+
// Only suppress when the click is actually forwarded to the labeled control.
205+
// Clicks on interactive descendants (links, buttons, other fields) are NOT
206+
// forwarded by the browser and must still be recorded.
207+
const interactiveHit = tgt.closest('a, button, input, select, textarea');
208+
const forwardsToControl = !interactiveHit || !parentLabel.contains(interactiveHit);
209+
if (forwardsToControl) {
210+
const forAttr = parentLabel.getAttribute('for');
211+
if (forAttr) {
212+
const root = tgt.getRootNode();
213+
const lookup = root && root.getElementById ? root : document; // shadow-DOM safe
214+
const forEl = lookup.getElementById(forAttr);
215+
if (forEl && forEl.nodeName.toLowerCase() === 'input' &&
216+
(forEl.type === 'checkbox' || forEl.type === 'radio')) {
217+
return;
218+
}
219+
}
220+
if (parentLabel.querySelector('input[type="checkbox"], input[type="radio"]')) {
221+
return;
222+
}
207223
}
208224
}
209225
let typeStr = 'click';

test-build-firefox/contentScript.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-build-firefox/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Snyk API & Web Sequence Recorder",
3-
"version": "1.2.0",
3+
"version": "1.2.2",
44
"browser_specific_settings": {
55
"gecko": {
66
"id": "sequence-recorder@probely.com",

test-build/contentScript.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-build/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"1.2.0","manifest_version":3,"name":"Snyk API & Web Sequence Recorder","action":{"default_popup":"popup.html","default_icon":{"16":"icon-34.png","48":"icon-48.png"}},"icons":{"128":"icon-128.png"},"background":{"service_worker":"background.bundle.js"},"content_scripts":[{"matches":["http://*/*","https://*/*"],"js":["contentScript.bundle.js"],"css":["content.styles.css"],"run_at":"document_start","all_frames":true,"match_about_blank":true}],"web_accessible_resources":[{"resources":["content.styles.css","icon-128.png","icon-34.png"],"matches":["<all_urls>"]}],"permissions":["storage","activeTab"],"host_permissions":["http://*/*","https://*/*"]}
1+
{"version":"1.2.2","manifest_version":3,"name":"Snyk API & Web Sequence Recorder","action":{"default_popup":"popup.html","default_icon":{"16":"icon-34.png","48":"icon-48.png"}},"icons":{"128":"icon-128.png"},"background":{"service_worker":"background.bundle.js"},"content_scripts":[{"matches":["http://*/*","https://*/*"],"js":["contentScript.bundle.js"],"css":["content.styles.css"],"run_at":"document_start","all_frames":true,"match_about_blank":true}],"web_accessible_resources":[{"resources":["content.styles.css","icon-128.png","icon-34.png"],"matches":["<all_urls>"]}],"permissions":["storage","activeTab"],"host_permissions":["http://*/*","https://*/*"]}

0 commit comments

Comments
 (0)