Skip to content

Commit 7dc683e

Browse files
committed
added shadow dom support
1 parent bb7ee91 commit 7dc683e

File tree

7 files changed

+32
-9
lines changed

7 files changed

+32
-9
lines changed

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": "0.0.6",
3+
"version": "0.0.7",
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": "0.0.5",
3+
"version": "0.0.7",
44
"browser_specific_settings": {
55
"gecko": {
66

src/pages/Content/modules/collectEvents.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,22 @@ let stoMouseover = false;
2222

2323
export function interceptEvents(event, doc, ifrSelector, callback) {
2424
let hasKeyReturn = false;
25-
const tgt = event.target;
25+
let tgt = null;
26+
let composedPath = null;
27+
if (event && event.composed && event.composedPath) {
28+
composedPath = event.composedPath();
29+
}
30+
let shadowRootIdx = -1;
31+
if (composedPath && composedPath.length > 0) {
32+
shadowRootIdx = composedPath.findIndex(
33+
(item) => item instanceof ShadowRoot
34+
);
35+
}
36+
if (shadowRootIdx > -1) {
37+
tgt = composedPath[0];
38+
} else {
39+
tgt = event.target;
40+
}
2641
const type = event.type;
2742
let nodeName = null;
2843
let nodeType = null;
@@ -74,12 +89,20 @@ export function interceptEvents(event, doc, ifrSelector, callback) {
7489
if (selector && selector.toLowerCase() === 'html') {
7590
return;
7691
}
77-
const xpath = getXPath(bestElm, doc);
92+
let xpath = null;
93+
try {
94+
xpath = getXPath(bestElm, doc);
95+
} catch (ex) {
96+
// ignore
97+
}
98+
if (shadowRootIdx > -1) {
99+
xpath = '/html/node/shadow';
100+
}
78101

79102
let oEventBase = {
80103
timestamp: new Date().getTime(),
81104
css: selector || tgt,
82-
xpath: xpath,
105+
xpath: xpath || '',
83106
};
84107

85108
let oEventToSend = {};

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": "0.0.5",
3+
"version": "0.0.7",
44
"browser_specific_settings": {
55
"gecko": {
66

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":"0.0.6","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"}],"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":"0.0.7","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"}],"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)