passbolt-styleguide 5.15.0 → 5.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RELEASE_NOTES.md +2 -4
- package/build/css/help.min.css +2 -2
- package/build/css/public.min.css +2 -2
- package/build/css/themes/default/api_authentication.min.css +2 -2
- package/build/css/themes/default/api_cloud.min.css +2 -2
- package/build/css/themes/default/api_main.min.css +2 -2
- package/build/css/themes/default/api_reports.min.css +2 -2
- package/build/css/themes/default/api_webinstaller.min.css +2 -2
- package/build/css/themes/default/ext_app.min.css +2 -2
- package/build/css/themes/default/ext_authentication.min.css +2 -2
- package/build/css/themes/default/ext_external.min.css +2 -2
- package/build/css/themes/default/ext_in_form_cta.min.css +2 -2
- package/build/css/themes/default/ext_in_form_menu.min.css +2 -2
- package/build/css/themes/default/ext_quickaccess.min.css +2 -2
- package/build/css/themes/midgar/api_authentication.min.css +2 -2
- package/build/css/themes/midgar/api_main.min.css +2 -2
- package/build/css/themes/midgar/api_reports.min.css +2 -2
- package/build/css/themes/midgar/ext_app.min.css +2 -2
- package/build/css/themes/midgar/ext_authentication.min.css +2 -2
- package/build/css/themes/midgar/ext_in_form_cta.min.css +2 -2
- package/build/css/themes/midgar/ext_in_form_menu.min.css +2 -2
- package/build/css/themes/midgar/ext_quickaccess.min.css +2 -2
- package/build/css/themes/solarized_dark/api_authentication.min.css +2 -2
- package/build/css/themes/solarized_dark/api_main.min.css +2 -2
- package/build/css/themes/solarized_dark/api_reports.min.css +2 -2
- package/build/css/themes/solarized_dark/ext_app.min.css +2 -2
- package/build/css/themes/solarized_dark/ext_authentication.min.css +2 -2
- package/build/css/themes/solarized_dark/ext_in_form_cta.min.css +2 -2
- package/build/css/themes/solarized_dark/ext_in_form_menu.min.css +2 -2
- package/build/css/themes/solarized_dark/ext_quickaccess.min.css +2 -2
- package/build/css/themes/solarized_light/api_authentication.min.css +2 -2
- package/build/css/themes/solarized_light/api_main.min.css +2 -2
- package/build/css/themes/solarized_light/api_reports.min.css +2 -2
- package/build/css/themes/solarized_light/ext_app.min.css +2 -2
- package/build/css/themes/solarized_light/ext_authentication.min.css +2 -2
- package/build/css/themes/solarized_light/ext_in_form_cta.min.css +2 -2
- package/build/css/themes/solarized_light/ext_in_form_menu.min.css +2 -2
- package/build/css/themes/solarized_light/ext_quickaccess.min.css +2 -2
- package/package.json +1 -1
- package/src/react-web-integration/services/ShadowDom/ShadowMutationObserverService.js +8 -2
- package/src/react-web-integration/services/ShadowDom/ShadowMutationObserverService.test.js +58 -0
- package/src/react-web-integration/services/ShadowDom/ShadowRootCollectorService.js +43 -10
- package/src/react-web-integration/services/ShadowDom/ShadowRootCollectorService.test.js +29 -0
- package/src/react-web-integration/services/ShadowDom/ShadowRootResolverService.js +36 -19
- package/src/react-web-integration/services/ShadowDom/ShadowRootResolverService.test.js +26 -0
package/RELEASE_NOTES.md
CHANGED
package/build/css/help.min.css
CHANGED
package/build/css/public.min.css
CHANGED
package/package.json
CHANGED
|
@@ -47,10 +47,16 @@ class ShadowMutationObserverService {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
let foundRoots;
|
|
50
|
-
// Filter out shadow roots whose host was removed
|
|
50
|
+
// Filter out shadow roots whose host was removed.
|
|
51
51
|
let hasRemovals = mutations.some((mutation) => mutation.removedNodes.length > 0);
|
|
52
52
|
if (hasRemovals) {
|
|
53
|
-
|
|
53
|
+
// Prune via the host captured at collection time, NEVER `shadowRoot.host`: reading `.host` on a root
|
|
54
|
+
// whose host has been torn down (e.g. a <video> user-agent widget) crashes the Firefox content
|
|
55
|
+
// process (Gecko bug 2063234, PB-54190). A root with no known/connected host is dropped.
|
|
56
|
+
foundRoots = cached.filter((shadowRoot) => {
|
|
57
|
+
const host = ShadowRootCollectorService.getHost(shadowRoot);
|
|
58
|
+
return Boolean(host) && root.contains(host);
|
|
59
|
+
});
|
|
54
60
|
// We reuse this flag to indicate whether we actually removed any roots
|
|
55
61
|
hasRemovals = foundRoots.length < cached.length;
|
|
56
62
|
} else {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import ShadowMutationObserverService from "./ShadowMutationObserverService";
|
|
16
16
|
import ShadowRootCacheService from "./ShadowRootCacheService";
|
|
17
|
+
import ShadowRootCollectorService from "./ShadowRootCollectorService";
|
|
17
18
|
|
|
18
19
|
describe("ShadowMutationObserverService", () => {
|
|
19
20
|
beforeEach(() => {
|
|
@@ -22,6 +23,7 @@ describe("ShadowMutationObserverService", () => {
|
|
|
22
23
|
ShadowRootCacheService._shadowRootsCache = new WeakMap();
|
|
23
24
|
ShadowMutationObserverService._shadowRootsObservers = new WeakMap();
|
|
24
25
|
ShadowMutationObserverService._shadowMutationSubscribers = new Set();
|
|
26
|
+
ShadowRootCollectorService._hostByShadowRoot = new WeakMap();
|
|
25
27
|
|
|
26
28
|
document.body.innerHTML = "";
|
|
27
29
|
});
|
|
@@ -86,6 +88,62 @@ describe("ShadowMutationObserverService", () => {
|
|
|
86
88
|
expect(ShadowRootCacheService.peekCache(root)).toEqual([]);
|
|
87
89
|
});
|
|
88
90
|
|
|
91
|
+
it("should prune a stale cached root via the captured host without reading shadowRoot.host", () => {
|
|
92
|
+
// Regression PB-54190 / Gecko bug 2063234: on Firefox, reading `.host` on a root whose host has been
|
|
93
|
+
// torn down (e.g. a <video> user-agent widget) crashes the content process. Pruning must rely on the
|
|
94
|
+
// host captured at collection time, never on `shadowRoot.host`. We make `.host` throw to prove it is
|
|
95
|
+
// never read.
|
|
96
|
+
expect.assertions(3);
|
|
97
|
+
|
|
98
|
+
const root = document.createElement("div");
|
|
99
|
+
document.body.appendChild(root);
|
|
100
|
+
const detachedHost = document.createElement("div");
|
|
101
|
+
const staleRoot = detachedHost.attachShadow({ mode: "open" });
|
|
102
|
+
Object.defineProperty(staleRoot, "host", {
|
|
103
|
+
get() {
|
|
104
|
+
throw new Error("SIGSEGV: ShadowRoot::Host() null dereference");
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
// Host captured at collection time; the host is NOT attached under `root`, so the root is stale.
|
|
108
|
+
ShadowRootCollectorService._hostByShadowRoot.set(staleRoot, detachedHost);
|
|
109
|
+
ShadowRootCacheService.setCache(root, [staleRoot]);
|
|
110
|
+
|
|
111
|
+
let result;
|
|
112
|
+
expect(() => {
|
|
113
|
+
result = ShadowMutationObserverService.applyIncrementalMutationsToCache(root, [
|
|
114
|
+
{ addedNodes: [], removedNodes: [detachedHost] },
|
|
115
|
+
]);
|
|
116
|
+
}).not.toThrow();
|
|
117
|
+
expect(result).toBe(true);
|
|
118
|
+
expect(ShadowRootCacheService.peekCache(root)).toEqual([]);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("should keep a cached root whose captured host is still attached under the root", () => {
|
|
122
|
+
expect.assertions(2);
|
|
123
|
+
|
|
124
|
+
const root = document.createElement("div");
|
|
125
|
+
document.body.appendChild(root);
|
|
126
|
+
const child = document.createElement("div");
|
|
127
|
+
const childRoot = child.attachShadow({ mode: "open" });
|
|
128
|
+
root.appendChild(child);
|
|
129
|
+
Object.defineProperty(childRoot, "host", {
|
|
130
|
+
get() {
|
|
131
|
+
throw new Error("SIGSEGV: ShadowRoot::Host() null dereference");
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
ShadowRootCollectorService._hostByShadowRoot.set(childRoot, child);
|
|
135
|
+
ShadowRootCacheService.setCache(root, [childRoot]);
|
|
136
|
+
|
|
137
|
+
// An unrelated removal elsewhere still triggers the prune path.
|
|
138
|
+
const removedElsewhere = document.createElement("span");
|
|
139
|
+
const result = ShadowMutationObserverService.applyIncrementalMutationsToCache(root, [
|
|
140
|
+
{ addedNodes: [], removedNodes: [removedElsewhere] },
|
|
141
|
+
]);
|
|
142
|
+
|
|
143
|
+
expect(result).toBe(false);
|
|
144
|
+
expect(ShadowRootCacheService.peekCache(root)).toEqual([childRoot]);
|
|
145
|
+
});
|
|
146
|
+
|
|
89
147
|
it("should not append shadow roots already present in the cache", () => {
|
|
90
148
|
expect.assertions(2);
|
|
91
149
|
|
|
@@ -16,6 +16,28 @@ import ShadowRootResolverService from "./ShadowRootResolverService";
|
|
|
16
16
|
import { IGNORED_SUBTREES } from "./ShadowDomDictionary";
|
|
17
17
|
|
|
18
18
|
class ShadowRootCollectorService {
|
|
19
|
+
/**
|
|
20
|
+
* Host element of each shadow root we have ever collected, captured from the element we resolved the
|
|
21
|
+
* root *from* — never by reading `shadowRoot.host`.
|
|
22
|
+
*
|
|
23
|
+
* Reading `shadowRoot.host` on a root whose host has been torn down crashes the Firefox content process
|
|
24
|
+
* (Gecko bug 2063234, PB-54190). Consumers that need to know a cached root's host (e.g. to prune it on
|
|
25
|
+
* host disconnect) must read it here instead of from the root itself.
|
|
26
|
+
* @private
|
|
27
|
+
* @type {WeakMap<ShadowRoot, Element>}
|
|
28
|
+
*/
|
|
29
|
+
static _hostByShadowRoot = new WeakMap();
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Return the host element captured for a shadow root at collection time, or `undefined` if unknown.
|
|
33
|
+
* Safe to call on a root whose host is gone: it never touches `shadowRoot.host`.
|
|
34
|
+
* @param {ShadowRoot} shadowRoot
|
|
35
|
+
* @return {Element|undefined}
|
|
36
|
+
*/
|
|
37
|
+
static getHost(shadowRoot) {
|
|
38
|
+
return ShadowRootCollectorService._hostByShadowRoot.get(shadowRoot);
|
|
39
|
+
}
|
|
40
|
+
|
|
19
41
|
/**
|
|
20
42
|
* Find the shadow roots contained in `element` and its descendants
|
|
21
43
|
*
|
|
@@ -31,11 +53,7 @@ class ShadowRootCollectorService {
|
|
|
31
53
|
// We consider that if `element` IS a shadow root, it is already known.
|
|
32
54
|
// Also, if it is a document, there is no direct shadow root to resolve.
|
|
33
55
|
if (element.nodeType === Node.ELEMENT_NODE) {
|
|
34
|
-
|
|
35
|
-
if (shadowRoot && !seen.has(shadowRoot)) {
|
|
36
|
-
seen.add(shadowRoot);
|
|
37
|
-
shadowRoots.push(shadowRoot);
|
|
38
|
-
}
|
|
56
|
+
ShadowRootCollectorService._collect(element, seen, shadowRoots);
|
|
39
57
|
}
|
|
40
58
|
|
|
41
59
|
// Walk the DOM to find all elements that may contain shadow roots
|
|
@@ -45,16 +63,31 @@ class ShadowRootCollectorService {
|
|
|
45
63
|
|
|
46
64
|
// For each accepted element, try to resolve its shadow root and add it to the list if it's not already
|
|
47
65
|
while (walker.nextNode()) {
|
|
48
|
-
|
|
49
|
-
if (shadowRoot && !seen.has(shadowRoot)) {
|
|
50
|
-
seen.add(shadowRoot);
|
|
51
|
-
shadowRoots.push(shadowRoot);
|
|
52
|
-
}
|
|
66
|
+
ShadowRootCollectorService._collect(walker.currentNode, seen, shadowRoots);
|
|
53
67
|
}
|
|
54
68
|
}
|
|
55
69
|
|
|
56
70
|
return shadowRoots;
|
|
57
71
|
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Resolve `element`'s shadow root and, if new, record it (along with `element` as its host) and push it.
|
|
75
|
+
* The host is captured from `element` — the element we resolved *from* — so we never read
|
|
76
|
+
* `shadowRoot.host`, which would crash on a torn-down host (see {@link _hostByShadowRoot}).
|
|
77
|
+
* @private
|
|
78
|
+
* @param {Element} element The candidate host element.
|
|
79
|
+
* @param {Set<ShadowRoot>} seen Already known roots to avoid duplication.
|
|
80
|
+
* @param {ShadowRoot[]} shadowRoots The accumulator to push newly found roots into.
|
|
81
|
+
* @return {void}
|
|
82
|
+
*/
|
|
83
|
+
static _collect(element, seen, shadowRoots) {
|
|
84
|
+
const shadowRoot = ShadowRootResolverService.resolveShadowRoot(element);
|
|
85
|
+
if (shadowRoot && !seen.has(shadowRoot)) {
|
|
86
|
+
seen.add(shadowRoot);
|
|
87
|
+
ShadowRootCollectorService._hostByShadowRoot.set(shadowRoot, element);
|
|
88
|
+
shadowRoots.push(shadowRoot);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
58
91
|
}
|
|
59
92
|
|
|
60
93
|
export default ShadowRootCollectorService;
|
|
@@ -91,4 +91,33 @@ describe("ShadowRootCollectorService", () => {
|
|
|
91
91
|
expect(ShadowRootCollectorService.collectShadowRoots(script)).toEqual([]);
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
|
+
|
|
95
|
+
describe("ShadowRootCollectorService::getHost", () => {
|
|
96
|
+
it("should capture the host of every collected root from the element resolved from, never from shadowRoot.host", () => {
|
|
97
|
+
// Regression PB-54190: consumers must be able to find a cached root's host without reading
|
|
98
|
+
// `shadowRoot.host`, which crashes Firefox once the host is torn down. The host is recorded here from
|
|
99
|
+
// the element we resolved *from*, so it is available even for a root whose `.host` would throw.
|
|
100
|
+
expect.assertions(2);
|
|
101
|
+
|
|
102
|
+
const { host, shadowRoot } = appendShadowHost();
|
|
103
|
+
Object.defineProperty(shadowRoot, "host", {
|
|
104
|
+
get() {
|
|
105
|
+
throw new Error("SIGSEGV: ShadowRoot::Host() null dereference");
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const collected = ShadowRootCollectorService.collectShadowRoots(document);
|
|
110
|
+
|
|
111
|
+
expect(collected).toContain(shadowRoot);
|
|
112
|
+
expect(ShadowRootCollectorService.getHost(shadowRoot)).toBe(host);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("should return undefined for a root that was never collected", () => {
|
|
116
|
+
expect.assertions(1);
|
|
117
|
+
|
|
118
|
+
const { shadowRoot } = appendShadowHost();
|
|
119
|
+
|
|
120
|
+
expect(ShadowRootCollectorService.getHost(shadowRoot)).toBeUndefined();
|
|
121
|
+
});
|
|
122
|
+
});
|
|
94
123
|
});
|
|
@@ -22,30 +22,47 @@ class ShadowRootResolverService {
|
|
|
22
22
|
* @return {ShadowRoot?} The shadow root of the given element, or null if it doesn't have one.
|
|
23
23
|
*/
|
|
24
24
|
static resolveShadowRoot(element) {
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
// An author-attached *open* shadow root is always safe to read directly: `element.shadowRoot` never
|
|
26
|
+
// exposes user-agent widgets, so it needs no gating.
|
|
27
|
+
if (element.shadowRoot) {
|
|
28
|
+
return element.shadowRoot;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// We only consider elements that are likely to host an author-created shadow root: either elements
|
|
32
|
+
// allowed to attach one, or custom elements (including a dash [`-`] character).
|
|
33
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow#elements_you_can_attach_a_shadow_to
|
|
34
|
+
//
|
|
35
|
+
// This gate MUST also cover the closed-root resolution below. Unlike `element.shadowRoot`, both the
|
|
36
|
+
// Firefox `openOrClosedShadowRoot` property and the `browser.dom` API also expose user-agent widget
|
|
37
|
+
// shadow roots — the native controls of <video>/<audio>, <input type=range|date>, <select>… Firefox
|
|
38
|
+
// mounts and tears those down on every playback-state change; once cached, reading `.host` on a
|
|
39
|
+
// torn-down widget dereferences a null host and crashes the content process (Gecko bug 2063234,
|
|
40
|
+
// PB-54190). `attachShadow()` throws on all those elements, so gating here never drops a legitimate
|
|
41
|
+
// author shadow root.
|
|
42
|
+
const tag = element.nodeName;
|
|
43
|
+
const canHostShadowRoot =
|
|
44
|
+
SHADOW_ROOT_CANDIDATE_NODE_NAMES.has(tag) || (element instanceof HTMLElement && tag.includes("-"));
|
|
45
|
+
if (!canHostShadowRoot) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
29
48
|
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
// Closed author shadow root, exposed directly by the Firefox content-script property.
|
|
50
|
+
// `openOrClosedShadowRoot` is only available on Firefox.
|
|
51
|
+
// @see Refer to compatibility table here: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/dom/openOrClosedShadowRoot#browser_compatibility
|
|
52
|
+
if (element.openOrClosedShadowRoot) {
|
|
53
|
+
return element.openOrClosedShadowRoot;
|
|
54
|
+
}
|
|
33
55
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
if (browser?.dom?.openOrClosedShadowRoot) {
|
|
40
|
-
shadowRoot = browser.dom.openOrClosedShadowRoot(element);
|
|
41
|
-
}
|
|
42
|
-
} catch (error) {
|
|
43
|
-
console.warn("ShadowRootResolverService.resolveShadowRoot threw on element", element, error);
|
|
44
|
-
}
|
|
56
|
+
// Otherwise fall back to the extension API to get the closed shadow root (chromium browsers).
|
|
57
|
+
try {
|
|
58
|
+
if (browser?.dom?.openOrClosedShadowRoot) {
|
|
59
|
+
return browser.dom.openOrClosedShadowRoot(element) ?? null;
|
|
45
60
|
}
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.warn("ShadowRootResolverService.resolveShadowRoot threw on element", element, error);
|
|
46
63
|
}
|
|
47
64
|
|
|
48
|
-
return
|
|
65
|
+
return null;
|
|
49
66
|
}
|
|
50
67
|
}
|
|
51
68
|
|
|
@@ -105,6 +105,32 @@ describe("ShadowRootResolverService", () => {
|
|
|
105
105
|
expect(browser.dom.openOrClosedShadowRoot).not.toHaveBeenCalled();
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
+
it("should ignore a Firefox user-agent widget shadow root exposed on a media element", () => {
|
|
109
|
+
// Regression: on Firefox `openOrClosedShadowRoot` also exposes user-agent widget shadow roots (the
|
|
110
|
+
// native controls of <video>/<audio>, <input type=range|date>...). Resolving and observing those
|
|
111
|
+
// storms the MutationObserver during media playback and crashes the tab. Non-host elements must be
|
|
112
|
+
// gated out before this property is ever read.
|
|
113
|
+
expect.assertions(4);
|
|
114
|
+
|
|
115
|
+
const video = document.createElement("video");
|
|
116
|
+
video.openOrClosedShadowRoot = document.createElement("div").attachShadow({ mode: "closed" });
|
|
117
|
+
|
|
118
|
+
const rangeInput = document.createElement("input");
|
|
119
|
+
rangeInput.type = "range";
|
|
120
|
+
rangeInput.openOrClosedShadowRoot = document.createElement("div").attachShadow({ mode: "closed" });
|
|
121
|
+
|
|
122
|
+
browser.dom = { openOrClosedShadowRoot: jest.fn() };
|
|
123
|
+
|
|
124
|
+
expect(ShadowRootResolverService.resolveShadowRoot(video)).toBeNull();
|
|
125
|
+
expect(ShadowRootResolverService.resolveShadowRoot(rangeInput)).toBeNull();
|
|
126
|
+
expect(browser.dom.openOrClosedShadowRoot).not.toHaveBeenCalled();
|
|
127
|
+
// A legitimate open author shadow root on the same media element is still not resolvable (can't attach one),
|
|
128
|
+
// but a candidate host keeps resolving its Firefox closed root.
|
|
129
|
+
const div = document.createElement("div");
|
|
130
|
+
div.openOrClosedShadowRoot = document.createElement("div").attachShadow({ mode: "closed" });
|
|
131
|
+
expect(ShadowRootResolverService.resolveShadowRoot(div)).toBe(div.openOrClosedShadowRoot);
|
|
132
|
+
});
|
|
133
|
+
|
|
108
134
|
it("should return null when no shadow root can be resolved", () => {
|
|
109
135
|
expect.assertions(1);
|
|
110
136
|
|