Skip to content

Conversation

@shs96c
Copy link
Member

@shs96c shs96c commented Dec 18, 2025

User description

And re-enable them in CI. These tests are only expected to pass when run with pinned browsers in the RBE.


PR Type

Bug fix


Description

  • Fix DOM visibility detection for text nodes with structural whitespace

  • Correct keyboard event handling for Firefox browsers

  • Fix form submission logic for Firefox engine version 93+

  • Update shadow DOM text extraction to handle multiple instances

  • Re-enable previously failing JavaScript atoms tests


Diagram Walkthrough

flowchart LR
  A["DOM Visibility Logic"] -->|"Filter structural whitespace"| B["Text Node Handling"]
  C["Keyboard Events"] -->|"Firefox-specific logic"| D["Event Creation"]
  E["Form Submission"] -->|"Version check"| F["Firefox 93+ Support"]
  G["Shadow DOM"] -->|"Multiple instances"| H["Text Extraction"]
  I["Test Configuration"] -->|"Remove skip entries"| J["Re-enable Atoms Tests"]
Loading

File Walkthrough

Relevant files
Bug fix
dom.js
Improve DOM visibility and shadow DOM text handling           

javascript/atoms/dom.js

  • Enhanced text node visibility detection to ignore structural
    whitespace (newlines, tabs)
  • Added regex check to filter text nodes containing only whitespace with
    structural characters
  • Fixed shadow DOM text extraction to retrieve effective styles from
    shadow host element
  • Pass whitespace and text-transform styles to child node processing
+18/-3   
events.js
Fix keyboard event handling for Firefox                                   

javascript/atoms/events.js

  • Added Firefox-specific keyboard event handling logic
  • Set keyCode to 0 for charCode events in Firefox, preserve keyCode
    otherwise
  • Maintain existing WebKit and Edge charCode behavior
+9/-4     
keyboard.js
Add Firefox 93+ version check for form submission               

javascript/atoms/keyboard.js

  • Add version check to exclude Firefox engine version 93+ from form
    submission logic
  • Prevent form auto-submission on Enter key for Firefox 93 and later
+1/-1     
Tests
shown_test.html
Update test assertions to use firstElementChild                   

javascript/atoms/test/shown_test.html

  • Replace deprecated firstChild with firstElementChild in test
    assertions
  • Update 5 test cases to use modern DOM API for element access
  • Improves compatibility with modern browser implementations
+5/-5     
text_shadow_test.html
Fix shadow DOM setup for multiple element instances           

javascript/atoms/test/text_shadow_test.html

  • Fix setCustomElement to update all open-shadow-element instances using
    querySelectorAll
  • Update tearDown to properly clear shadow DOM for all
    open-shadow-element instances
  • Prevent test interference by ensuring all shadow DOM instances are
    cleaned
+7/-4     
Configuration changes
.skipped-tests
Re-enable JavaScript atoms tests                                                 

.skipped-tests

  • Remove three JavaScript atoms test entries from skip list
  • Re-enable //javascript/atoms:test-chrome, test-edge, and
    test-firefox-beta
  • Tests now expected to pass with pinned browsers in RBE
+0/-3     

@selenium-ci selenium-ci added the B-atoms JavaScript chunks generated by Google closure label Dec 18, 2025
@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Dec 18, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

🔴
Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Missing null guard: The new regex checks assume n.nodeValue is always a string, but if it is null the
RegExp.test() calls will throw instead of handling the edge case gracefully.

Referred Code
if (n.nodeType == goog.dom.NodeType.TEXT) {
  var text = n.nodeValue;
  // Ignore text nodes that are purely structural whitespace
  // (contain newlines or tabs and nothing else besides spaces)
  if (/^[\s]*$/.test(text) && /[\n\r\t]/.test(text)) {
    return false;
  }
  return true;

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Dec 18, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Add null check before teardown

Add a null check for the closed element in tearDown to prevent a TypeError if
the element is not found, making the test cleanup more robust.

javascript/atoms/test/text_shadow_test.html [64-70]

 function tearDown() {
   document.querySelectorAll('open-shadow-element').forEach(elem => {
     elem.shadowRoot.innerHTML = '';
   });
   let closed = document.querySelector('closed-shadow-element');
-
-  closed._shadowRoot.innerHTML = '';
+  if (closed) {
+    closed._shadowRoot.innerHTML = '';
+  }
 }
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies a potential TypeError if querySelector returns null and proposes a simple fix that improves the robustness of the test's tearDown function.

Low
Learned
best practice
Guard nullable text node values

nodeValue can be null for some text nodes; coerce it to an empty string before
running regex tests to avoid runtime errors.

javascript/atoms/dom.js [548-556]

 if (n.nodeType == goog.dom.NodeType.TEXT) {
-  var text = n.nodeValue;
+  var text = n.nodeValue || '';
   // Ignore text nodes that are purely structural whitespace
   // (contain newlines or tabs and nothing else besides spaces)
   if (/^[\s]*$/.test(text) && /[\n\r\t]/.test(text)) {
     return false;
   }
   return true;
 }
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why:
Relevant best practice - Validate and sanitize external inputs before processing (defensively handle nullable DOM text values to avoid invalid operations).

Low
Extract repeated DOM iteration helper

Factor the repeated querySelectorAll('open-shadow-element').forEach(...) into a
small helper to keep setup/teardown logic consistent and easier to maintain.

javascript/atoms/test/text_shadow_test.html [58-67]

-document.querySelectorAll(`open-shadow-element`).forEach(elem => {
+function forEachOpenShadowElement(fn) {
+  document.querySelectorAll('open-shadow-element').forEach(fn);
+}
+...
+forEachOpenShadowElement(elem => {
   elem.shadowRoot.innerHTML = html;
 });
 ...
-document.querySelectorAll('open-shadow-element').forEach(elem => {
+forEachOpenShadowElement(elem => {
   elem.shadowRoot.innerHTML = '';
 });

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 5

__

Why:
Relevant best practice - Replace ad-hoc duplication with shared helpers/utilities to reduce repetition and centralize logic.

Low
  • Update

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@titusfortner titusfortner merged commit 0daefd7 into SeleniumHQ:trunk Dec 18, 2025
38 checks passed
@shs96c shs96c deleted the fix-atoms branch December 19, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-atoms JavaScript chunks generated by Google closure Review effort 3/5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants