passbolt-styleguide 5.17.1 → 5.17.2

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.
Files changed (81) hide show
  1. package/RELEASE_NOTES.md +4 -5
  2. package/build/css/help.min.css +2 -2
  3. package/build/css/public.min.css +2 -2
  4. package/build/css/themes/default/api_authentication.min.css +2 -2
  5. package/build/css/themes/default/api_cloud.min.css +2 -2
  6. package/build/css/themes/default/api_main.min.css +2 -2
  7. package/build/css/themes/default/api_reports.min.css +2 -2
  8. package/build/css/themes/default/api_webinstaller.min.css +2 -2
  9. package/build/css/themes/default/ext_app.min.css +2 -2
  10. package/build/css/themes/default/ext_authentication.min.css +2 -2
  11. package/build/css/themes/default/ext_external.min.css +2 -2
  12. package/build/css/themes/default/ext_in_form_cta.min.css +2 -2
  13. package/build/css/themes/default/ext_in_form_menu.min.css +2 -2
  14. package/build/css/themes/default/ext_quickaccess.min.css +2 -2
  15. package/build/css/themes/midgar/api_authentication.min.css +2 -2
  16. package/build/css/themes/midgar/api_main.min.css +2 -2
  17. package/build/css/themes/midgar/api_reports.min.css +2 -2
  18. package/build/css/themes/midgar/ext_app.min.css +2 -2
  19. package/build/css/themes/midgar/ext_authentication.min.css +2 -2
  20. package/build/css/themes/midgar/ext_in_form_cta.min.css +2 -2
  21. package/build/css/themes/midgar/ext_in_form_menu.min.css +2 -2
  22. package/build/css/themes/midgar/ext_quickaccess.min.css +2 -2
  23. package/build/css/themes/solarized_dark/api_authentication.min.css +2 -2
  24. package/build/css/themes/solarized_dark/api_main.min.css +2 -2
  25. package/build/css/themes/solarized_dark/api_reports.min.css +2 -2
  26. package/build/css/themes/solarized_dark/ext_app.min.css +2 -2
  27. package/build/css/themes/solarized_dark/ext_authentication.min.css +2 -2
  28. package/build/css/themes/solarized_dark/ext_in_form_cta.min.css +2 -2
  29. package/build/css/themes/solarized_dark/ext_in_form_menu.min.css +2 -2
  30. package/build/css/themes/solarized_dark/ext_quickaccess.min.css +2 -2
  31. package/build/css/themes/solarized_light/api_authentication.min.css +2 -2
  32. package/build/css/themes/solarized_light/api_main.min.css +2 -2
  33. package/build/css/themes/solarized_light/api_reports.min.css +2 -2
  34. package/build/css/themes/solarized_light/ext_app.min.css +2 -2
  35. package/build/css/themes/solarized_light/ext_authentication.min.css +2 -2
  36. package/build/css/themes/solarized_light/ext_in_form_cta.min.css +2 -2
  37. package/build/css/themes/solarized_light/ext_in_form_menu.min.css +2 -2
  38. package/build/css/themes/solarized_light/ext_quickaccess.min.css +2 -2
  39. package/build/js/dist/api-app.js +1 -1
  40. package/build/locales/cs-CZ/common.json +158 -96
  41. package/build/locales/de-DE/common.json +146 -90
  42. package/build/locales/es-ES/common.json +148 -92
  43. package/build/locales/fr-FR/common.json +148 -92
  44. package/build/locales/it-IT/common.json +149 -93
  45. package/build/locales/ja-JP/common.json +145 -92
  46. package/build/locales/ko-KR/common.json +67 -14
  47. package/build/locales/lt-LT/common.json +163 -101
  48. package/build/locales/nl-NL/common.json +151 -95
  49. package/build/locales/pl-PL/common.json +155 -93
  50. package/build/locales/pt-BR/common.json +150 -94
  51. package/build/locales/ro-RO/common.json +147 -88
  52. package/build/locales/ru-RU/common.json +158 -96
  53. package/build/locales/sl-SI/common.json +158 -96
  54. package/build/locales/sv-SE/common.json +151 -95
  55. package/build/locales/uk-UA/common.json +166 -104
  56. package/package.json +1 -1
  57. package/src/locales/cs-CZ/common.json +158 -96
  58. package/src/locales/de-DE/common.json +146 -90
  59. package/src/locales/es-ES/common.json +148 -92
  60. package/src/locales/fr-FR/common.json +148 -92
  61. package/src/locales/it-IT/common.json +149 -93
  62. package/src/locales/ja-JP/common.json +145 -92
  63. package/src/locales/ko-KR/common.json +67 -14
  64. package/src/locales/lt-LT/common.json +163 -101
  65. package/src/locales/nl-NL/common.json +151 -95
  66. package/src/locales/pl-PL/common.json +155 -93
  67. package/src/locales/pt-BR/common.json +150 -94
  68. package/src/locales/ro-RO/common.json +147 -88
  69. package/src/locales/ru-RU/common.json +158 -96
  70. package/src/locales/sl-SI/common.json +158 -96
  71. package/src/locales/sv-SE/common.json +151 -95
  72. package/src/locales/uk-UA/common.json +166 -104
  73. package/src/react-extension/components/Administration/DisplayAdministrationWorkspaceActions/DisplayAdministrationMfaActions/DisplayAdministrationMfaActions.js +14 -6
  74. package/src/react-web-integration/lib/InForm/InFormManager.js +14 -4
  75. package/src/react-web-integration/lib/InForm/InformManager.test.js +53 -6
  76. package/src/react-web-integration/services/DomExtraction/FieldAggregatorService.js +23 -1
  77. package/src/react-web-integration/services/DomExtraction/FieldAggregatorService.test.js +37 -0
  78. package/src/react-web-integration/services/ShadowDom/ShadowDomFocusHealerService.js +2 -2
  79. package/src/react-web-integration/services/ShadowDom/ShadowDomFocusHealerService.test.js +18 -6
  80. package/src/react-web-integration/services/ShadowDom/ShadowMutationObserverService.js +5 -3
  81. package/src/react-web-integration/services/ShadowDom/ShadowMutationObserverService.test.js +12 -1
@@ -78,15 +78,23 @@ class DisplayAdministrationMfaActions extends React.Component {
78
78
 
79
79
  /**
80
80
  * Handle save operation error.
81
- * @param {object} error The returned error
81
+ * @param {object} e The returned error
82
82
  */
83
- async handleSaveError(error) {
83
+ async handleSaveError(e) {
84
84
  // It can happen when the user has closed the passphrase entry dialog by instance.
85
- if (error.name !== "UserAbortsOperationError") {
86
- // Unexpected error occurred.
87
- console.error(error);
88
- await this.handleError(error);
85
+ if (e.name === "UserAbortsOperationError") {
86
+ return;
89
87
  }
88
+
89
+ let error = e;
90
+ // Handles specific webauthn error messages
91
+ if (error?.data?.body?.webauthn) {
92
+ const errorMessage = Object.values(error.data.body.webauthn).join(". ");
93
+ error = new Error(errorMessage);
94
+ }
95
+
96
+ console.error(error);
97
+ await this.handleError(error);
90
98
  }
91
99
 
92
100
  /**
@@ -326,7 +326,8 @@ class InFormManager {
326
326
  * If a field was previously found, we reuse the same InformUsernameField, otherwise we create one.
327
327
  * Else we clean and reset callToActionFields.
328
328
  */
329
- const { fields } = PageClassificationService.classifyPage();
329
+ const { fields: classifiedFields } = PageClassificationService.classifyPage();
330
+ const fields = classifiedFields.filter(({ element }) => !element.disabled);
330
331
  const newUsernameFields = fields.filter((field) => IDENTIFIER_ROLES.includes(field.role));
331
332
  const newPasswordFields = fields.filter((field) => PASSWORD_ROLES.includes(field.role));
332
333
  const newOTPFields = fields.filter((field) => field.role === FieldRole.TOTP);
@@ -563,15 +564,17 @@ class InFormManager {
563
564
  * @param {Document|ShadowRoot|Element} root The observed node.
564
565
  * @param {MutationRecord[]} mutations The list of mutations.
565
566
  * @param {boolean} shadowRootsChanged Whether the mutation includes a change in the shadowRoots.
567
+ * @param {object} [options]
568
+ * @param {boolean} [options.fromFocus=false] Whether the notification comes from the user focusing a field.
566
569
  */
567
- onShadowMutation(root, mutations, shadowRootsChanged) {
570
+ onShadowMutation(root, mutations, shadowRootsChanged, { fromFocus = false } = {}) {
568
571
  // Never scan our own CTA shadow root
569
572
  if (root === this.shadowRoot) {
570
573
  return;
571
574
  }
572
575
 
573
- // A new shadow root appeared: re-scan right away so the focused field gets its call-to-action
574
- if (shadowRootsChanged) {
576
+ // The user focused a field: re-scan right away so it gets its call-to-action on first focus
577
+ if (fromFocus) {
575
578
  this.findAndSetAuthenticationFields();
576
579
  this.handleInformCallToActionClickEvent();
577
580
  this._pendingFieldScan = true;
@@ -579,6 +582,13 @@ class InFormManager {
579
582
  return;
580
583
  }
581
584
 
585
+ // A new shadow root appeared: wait for the page to settle, a component-heavy page adds hundreds at once
586
+ if (shadowRootsChanged) {
587
+ this._pendingFieldScan = true;
588
+ this.updateAuthenticationFieldsDebounce?.();
589
+ return;
590
+ }
591
+
582
592
  // Does this batch actually touch a credential-relevant node or attribute?
583
593
  const affectsFields =
584
594
  this._mutationsAffectAuthenticationFields(mutations) || this._attributeMutationAffectsField(mutations);
@@ -2229,27 +2229,52 @@ describe("InformManager", () => {
2229
2229
  expect(InFormManager._pendingFieldScan).toBe(true);
2230
2230
  });
2231
2231
 
2232
- it("should re-scan synchronously and schedule a debounced follow-up when a shadow root becomes known", async () => {
2233
- // The focus healer signals shadowRootsChanged=true when a field is focused. The re-scan must be
2234
- // synchronous (so the call-to-action is attached within the same focus turn) AND also scheduled once
2235
- // more (debounced) to catch a web component that hydrates just after an autofocus.
2236
- expect.assertions(2);
2232
+ it("should re-scan synchronously and schedule a debounced follow-up when the user focuses a field", async () => {
2233
+ // The focus healer notifies with fromFocus when a field is focused. The re-scan must be synchronous
2234
+ // (so the call-to-action is attached within the same focus turn) AND also scheduled once more
2235
+ // (debounced) to catch a web component that hydrates just after an autofocus.
2236
+ expect.assertions(3);
2237
2237
 
2238
2238
  document.body.innerHTML = domElementLoginWithNameAttributeUsername;
2239
2239
  await act(async () => new InformManagerPage());
2240
2240
  InFormManager.updateAuthenticationFieldsDebounce = jest.fn();
2241
+ InFormManager._pendingFieldScan = false;
2241
2242
  const findSpy = jest.spyOn(InFormManager, "findAndSetAuthenticationFields").mockImplementation();
2242
2243
 
2243
- InFormManager.onShadowMutation(document, [], true);
2244
+ InFormManager.onShadowMutation(document, [], true, { fromFocus: true });
2244
2245
 
2245
2246
  expect(InFormManager.findAndSetAuthenticationFields).toHaveBeenCalledTimes(1);
2246
2247
  expect(InFormManager.updateAuthenticationFieldsDebounce).toHaveBeenCalledTimes(1);
2248
+ expect(InFormManager._pendingFieldScan).toBe(true);
2247
2249
 
2248
2250
  // The suite clears (not restores) mocks between tests, so restore the persistent no-op now to avoid
2249
2251
  // leaking it into the tests below.
2250
2252
  findSpy.mockRestore();
2251
2253
  });
2252
2254
 
2255
+ it("should only schedule a debounced re-scan when a mutation adds shadow roots", async () => {
2256
+ // A component-heavy page (e.g. Reddit) adds hundreds of shadow roots per render: each observer batch
2257
+ // must not trigger a synchronous full-page scan, only arm the gate and schedule a single debounced one.
2258
+ expect.assertions(3);
2259
+
2260
+ document.body.innerHTML = domElementLoginWithNameAttributeUsername;
2261
+ await act(async () => new InformManagerPage());
2262
+ InFormManager.updateAuthenticationFieldsDebounce = jest.fn();
2263
+ InFormManager._pendingFieldScan = false;
2264
+ const findSpy = jest.spyOn(InFormManager, "findAndSetAuthenticationFields").mockImplementation();
2265
+ const otherShadowRoot = document.createElement("div").attachShadow({ mode: "open" });
2266
+
2267
+ for (let i = 0; i < 200; i++) {
2268
+ InFormManager.onShadowMutation(otherShadowRoot, [], true);
2269
+ }
2270
+
2271
+ expect(InFormManager.findAndSetAuthenticationFields).not.toHaveBeenCalled();
2272
+ expect(InFormManager.updateAuthenticationFieldsDebounce).toHaveBeenCalledTimes(200);
2273
+ expect(InFormManager._pendingFieldScan).toBe(true);
2274
+
2275
+ findSpy.mockRestore();
2276
+ });
2277
+
2253
2278
  it("should NOT queue an expensive field scan for a non-relevant document mutation (only the host check)", async () => {
2254
2279
  expect.assertions(2);
2255
2280
 
@@ -2321,6 +2346,28 @@ describe("InformManager", () => {
2321
2346
 
2322
2347
  expect(InFormManager.callToActionFields).toHaveLength(1);
2323
2348
  });
2349
+
2350
+ it("should not attach a call-to-action to a disabled field until it is enabled", async () => {
2351
+ expect.assertions(3);
2352
+
2353
+ // Second step of a multi-step login: the identifier is recalled in a disabled field above the password.
2354
+ document.body.innerHTML = `<form>
2355
+ <input type='email' id='email' name='email' disabled value='admin@passbolt.com'/>
2356
+ <input type='password' id='password' name='password'/>
2357
+ </form>`;
2358
+ await act(async () => new InformManagerPage());
2359
+ const ctaElements = () => InFormManager.callToActionFields.map(({ field }) => field);
2360
+ expect(ctaElements()).not.toContain(document.getElementById("email"));
2361
+ expect(ctaElements()).toContain(document.getElementById("password"));
2362
+
2363
+ // The site enables the field: the next scan attaches its call-to-action.
2364
+ await act(async () => {
2365
+ document.getElementById("email").disabled = false;
2366
+ });
2367
+ InFormManager.findAndSetAuthenticationFields();
2368
+
2369
+ expect(ctaElements()).toContain(document.getElementById("email"));
2370
+ });
2324
2371
  });
2325
2372
 
2326
2373
  describe("Focus healer integration", () => {
@@ -36,11 +36,33 @@ class FieldAggregatorService {
36
36
  * @returns {Element[]} The visible fillable fields.
37
37
  */
38
38
  static gatherCandidates(containerElement) {
39
- return ShadowDomQueryService.querySelectorAllDeep(containerElement, TEXT_FIELDS).filter(
39
+ const elements = new Set(ShadowDomQueryService.querySelectorAllDeep(containerElement, TEXT_FIELDS));
40
+ FieldAggregatorService.gatherSlottedFields(containerElement).forEach((element) => elements.add(element));
41
+
42
+ return [...elements].filter(
40
43
  (element) => ShadowDomQueryService.isElement(element) && ElementVisibilityService.isElementViewable(element),
41
44
  );
42
45
  }
43
46
 
47
+ /**
48
+ * TEXT_FIELDS assigned to the slots of a container. A web component may render the light DOM fields of its host
49
+ * through slots of its shadow root: they are displayed inside the container but are not its descendants.
50
+ * @param {Element} containerElement The container to scan.
51
+ * @returns {Element[]} The slotted fields.
52
+ */
53
+ static gatherSlottedFields(containerElement) {
54
+ const slots = ShadowDomQueryService.querySelectorAllDeep(containerElement, "slot");
55
+
56
+ return slots.flatMap((slot) =>
57
+ slot
58
+ .assignedElements({ flatten: true })
59
+ .flatMap((assigned) => [
60
+ ...(assigned.matches(TEXT_FIELDS) ? [assigned] : []),
61
+ ...ShadowDomQueryService.querySelectorAllDeep(assigned, TEXT_FIELDS),
62
+ ]),
63
+ );
64
+ }
65
+
44
66
  /**
45
67
  * Populate `fields[]` of every container record with `{ fieldElement, deepestFormContainer }`
46
68
  * (replacing whatever seed/skeleton fields it carried), then purge containers left with no field.
@@ -45,6 +45,43 @@ describe("FieldAggregatorService", () => {
45
45
  expect(result[0].fields.map((field) => field.fieldElement.id)).toContain("reg-phone");
46
46
  });
47
47
 
48
+ it("should populate the fields slotted into a container living in a web component shadow root", () => {
49
+ expect.assertions(2);
50
+
51
+ jest.spyOn(ElementVisibilityService, "isElementViewable").mockReturnValue(true);
52
+ // The landal.de shape: the host's light DOM inputs are rendered through named slots of its shadow root.
53
+ document.body.innerHTML = `<login-panel-component>
54
+ <input slot="username" type="email" id="username"/>
55
+ <input slot="password" type="password" id="current-password"/>
56
+ </login-panel-component>`;
57
+ const host = document.querySelector("login-panel-component");
58
+ const shadowRoot = host.attachShadow({ mode: "open" });
59
+ shadowRoot.innerHTML = '<div id="panel"><slot name="username"></slot><slot name="password"></slot></div>';
60
+ const container = shadowRoot.getElementById("panel");
61
+
62
+ const result = FieldAggregatorService.aggregateFields([
63
+ { containerElement: container, fields: [], isPseudoForm: true },
64
+ ]);
65
+
66
+ expect(result).toHaveLength(1);
67
+ expect(result[0].fields.map((field) => field.fieldElement.id)).toEqual(["username", "current-password"]);
68
+ });
69
+
70
+ it("should not duplicate a field found both as a descendant and through a slot", () => {
71
+ expect.assertions(1);
72
+
73
+ jest.spyOn(ElementVisibilityService, "isElementViewable").mockReturnValue(true);
74
+ document.body.innerHTML = '<login-panel-component><input slot="username" id="username"/></login-panel-component>';
75
+ const host = document.querySelector("login-panel-component");
76
+ host.attachShadow({ mode: "open" }).innerHTML = '<slot name="username"></slot>';
77
+
78
+ const result = FieldAggregatorService.aggregateFields([
79
+ { containerElement: host, fields: [], isPseudoForm: true },
80
+ ]);
81
+
82
+ expect(result[0].fields).toHaveLength(1);
83
+ });
84
+
48
85
  it("should keep only visible fields", () => {
49
86
  expect.assertions(2);
50
87
 
@@ -43,7 +43,7 @@ const focusHandler = (event) => {
43
43
  }
44
44
 
45
45
  if (invalidated) {
46
- ShadowMutationObserverService.notifyShadowMutationSubscribers(document, [], true);
46
+ ShadowMutationObserverService.notifyShadowMutationSubscribers(document, [], true, { fromFocus: true });
47
47
  return;
48
48
  }
49
49
 
@@ -55,7 +55,7 @@ const focusHandler = (event) => {
55
55
  !ShadowDomFocusHealerService._healAttempted.has(target)
56
56
  ) {
57
57
  ShadowDomFocusHealerService._healAttempted.add(target);
58
- ShadowMutationObserverService.notifyShadowMutationSubscribers(document, [], true);
58
+ ShadowMutationObserverService.notifyShadowMutationSubscribers(document, [], true, { fromFocus: true });
59
59
  }
60
60
  };
61
61
 
@@ -158,7 +158,9 @@ describe("ShadowDomFocusHealerService", () => {
158
158
  focusHandler({ composedPath: () => [input, document.body, document] });
159
159
 
160
160
  expect(ShadowRootCacheService.invalidate).not.toHaveBeenCalled();
161
- expect(ShadowMutationObserverService.notifyShadowMutationSubscribers).toHaveBeenCalledWith(document, [], true);
161
+ expect(ShadowMutationObserverService.notifyShadowMutationSubscribers).toHaveBeenCalledWith(document, [], true, {
162
+ fromFocus: true,
163
+ });
162
164
  });
163
165
 
164
166
  it("should not trigger a rescan when the focused light-DOM input is already tracked", () => {
@@ -202,7 +204,9 @@ describe("ShadowDomFocusHealerService", () => {
202
204
 
203
205
  expect(ShadowRootCacheService.invalidate).toHaveBeenCalledTimes(1);
204
206
  expect(ShadowRootCacheService.invalidate).toHaveBeenCalledWith(document);
205
- expect(ShadowMutationObserverService.notifyShadowMutationSubscribers).toHaveBeenCalledWith(document, [], true);
207
+ expect(ShadowMutationObserverService.notifyShadowMutationSubscribers).toHaveBeenCalledWith(document, [], true, {
208
+ fromFocus: true,
209
+ });
206
210
  });
207
211
 
208
212
  it("should invalidate the parent scope when the shadow root in the path is not an instance of ShadowRoot (cross-realm/isolated world)", () => {
@@ -220,7 +224,9 @@ describe("ShadowDomFocusHealerService", () => {
220
224
  focusHandler({ composedPath: () => [input, crossRealmShadowRoot, host, document.body, document] });
221
225
 
222
226
  expect(ShadowRootCacheService.invalidate).toHaveBeenCalledWith(document);
223
- expect(ShadowMutationObserverService.notifyShadowMutationSubscribers).toHaveBeenCalledWith(document, [], true);
227
+ expect(ShadowMutationObserverService.notifyShadowMutationSubscribers).toHaveBeenCalledWith(document, [], true, {
228
+ fromFocus: true,
229
+ });
224
230
  });
225
231
 
226
232
  it("should invalidate the parent scopes of late-attached nested roots", () => {
@@ -243,7 +249,9 @@ describe("ShadowDomFocusHealerService", () => {
243
249
  expect(ShadowRootCacheService.invalidate).toHaveBeenCalledWith(outerRoot);
244
250
  expect(ShadowRootCacheService.invalidate).toHaveBeenCalledWith(document);
245
251
  expect(ShadowMutationObserverService.notifyShadowMutationSubscribers).toHaveBeenCalledTimes(1);
246
- expect(ShadowMutationObserverService.notifyShadowMutationSubscribers).toHaveBeenCalledWith(document, [], true);
252
+ expect(ShadowMutationObserverService.notifyShadowMutationSubscribers).toHaveBeenCalledWith(document, [], true, {
253
+ fromFocus: true,
254
+ });
247
255
  });
248
256
 
249
257
  it("should not invalidate when the focused field is inside a known shadow root", () => {
@@ -280,7 +288,9 @@ describe("ShadowDomFocusHealerService", () => {
280
288
  focusHandler({ composedPath: () => [input, shadowRoot, host, document.body, document] });
281
289
 
282
290
  expect(ShadowRootCacheService.invalidate).toHaveBeenCalledWith(document);
283
- expect(ShadowMutationObserverService.notifyShadowMutationSubscribers).toHaveBeenCalledWith(document, [], true);
291
+ expect(ShadowMutationObserverService.notifyShadowMutationSubscribers).toHaveBeenCalledWith(document, [], true, {
292
+ fromFocus: true,
293
+ });
284
294
  });
285
295
 
286
296
  it("should invalidate only the scope of the unknown root when its parent root is already known", () => {
@@ -306,7 +316,9 @@ describe("ShadowDomFocusHealerService", () => {
306
316
 
307
317
  expect(ShadowRootCacheService.invalidate).toHaveBeenCalledTimes(1);
308
318
  expect(ShadowRootCacheService.invalidate).toHaveBeenCalledWith(outerRoot);
309
- expect(ShadowMutationObserverService.notifyShadowMutationSubscribers).toHaveBeenCalledWith(document, [], true);
319
+ expect(ShadowMutationObserverService.notifyShadowMutationSubscribers).toHaveBeenCalledWith(document, [], true, {
320
+ fromFocus: true,
321
+ });
310
322
  });
311
323
  });
312
324
  });
@@ -103,7 +103,7 @@ class ShadowMutationObserverService {
103
103
 
104
104
  /**
105
105
  * Register a subscriber to the shadow root mutations
106
- * @param {(root: Document|ShadowRoot|Element, mutations: MutationRecord[], shadowRootsChanged: boolean) => void} callback
106
+ * @param {(root: Document|ShadowRoot|Element, mutations: MutationRecord[], shadowRootsChanged: boolean, options: {fromFocus?: boolean}) => void} callback
107
107
  * @return {() => void} unsubscribe closure — must be called in the consumer's teardown.
108
108
  */
109
109
  static subscribeToShadowMutations(callback) {
@@ -116,11 +116,13 @@ class ShadowMutationObserverService {
116
116
  * @param {Document|ShadowRoot|Element} root
117
117
  * @param {MutationRecord[]} mutations
118
118
  * @param {boolean} shadowRootsChanged
119
+ * @param {object} [options]
120
+ * @param {boolean} [options.fromFocus=false] Whether the notification comes from the user focusing a field.
119
121
  */
120
- static notifyShadowMutationSubscribers(root, mutations, shadowRootsChanged) {
122
+ static notifyShadowMutationSubscribers(root, mutations, shadowRootsChanged, options = {}) {
121
123
  for (const callback of ShadowMutationObserverService._shadowMutationSubscribers) {
122
124
  try {
123
- callback(root, mutations, shadowRootsChanged);
125
+ callback(root, mutations, shadowRootsChanged, options);
124
126
  } catch (error) {
125
127
  console.warn("ShadowMutationObserverService shadow-mutation subscriber threw", error);
126
128
  }
@@ -221,7 +221,18 @@ describe("ShadowMutationObserverService", () => {
221
221
 
222
222
  ShadowMutationObserverService.notifyShadowMutationSubscribers(root, mutations, true);
223
223
 
224
- expect(callback).toHaveBeenCalledWith(root, mutations, true);
224
+ expect(callback).toHaveBeenCalledWith(root, mutations, true, {});
225
+ });
226
+
227
+ it("should forward the notification options to the subscribers", () => {
228
+ expect.assertions(1);
229
+
230
+ const callback = jest.fn();
231
+ ShadowMutationObserverService._shadowMutationSubscribers.add(callback);
232
+
233
+ ShadowMutationObserverService.notifyShadowMutationSubscribers(document, [], true, { fromFocus: true });
234
+
235
+ expect(callback).toHaveBeenCalledWith(document, [], true, { fromFocus: true });
225
236
  });
226
237
 
227
238
  it("should isolate a throwing subscriber so the others still run", () => {