diff --git a/Libraries/LibWeb/DOM/DocumentOrShadowRoot.h b/Libraries/LibWeb/DOM/DocumentOrShadowRoot.h index 17fb41cf578..e6857d28348 100644 --- a/Libraries/LibWeb/DOM/DocumentOrShadowRoot.h +++ b/Libraries/LibWeb/DOM/DocumentOrShadowRoot.h @@ -26,7 +26,7 @@ GC::Ptr calculate_active_element(T& self) candidate = as(retarget(candidate, &self)); // 3. If candidate's root is not this, then return null. - if (&candidate->root() != &self) + if (!candidate || &candidate->root() != &self) return nullptr; // 4. If candidate is not a Document object, then return candidate. diff --git a/Tests/LibWeb/Crash/DOM/shadow-root-active-element.html b/Tests/LibWeb/Crash/DOM/shadow-root-active-element.html new file mode 100644 index 00000000000..82b6966952b --- /dev/null +++ b/Tests/LibWeb/Crash/DOM/shadow-root-active-element.html @@ -0,0 +1,6 @@ + +
+ diff --git a/Tests/LibWeb/Text/expected/wpt-import/shadow-dom/ShadowRoot-interface.txt b/Tests/LibWeb/Text/expected/wpt-import/shadow-dom/ShadowRoot-interface.txt new file mode 100644 index 00000000000..24fb3fe962f --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/shadow-dom/ShadowRoot-interface.txt @@ -0,0 +1,18 @@ +Harness status: OK + +Found 12 tests + +10 Pass +2 Fail +Pass Check the existence of ShadowRoot interface +Pass ShadowRoot must inherit from DocumentFragment +Pass ShadowRoot must not be a constructor +Fail ShadowRoot.activeElement must return the focused element of the context object when shadow root is open. +Fail ShadowRoot.activeElement must return the focused element of the context object when shadow root is closed. +Pass ShadowRoot.host must return the shadow host of the context object. +Pass ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is open. +Pass ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is closed. +Pass ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is open. +Pass ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is closed. +Pass ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is open. +Pass ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is closed. \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/shadow-dom/ShadowRoot-interface.html b/Tests/LibWeb/Text/input/wpt-import/shadow-dom/ShadowRoot-interface.html new file mode 100644 index 00000000000..d5fb03ab00d --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/shadow-dom/ShadowRoot-interface.html @@ -0,0 +1,120 @@ + + + +Shadow DOM: ShadowRoot interface + + + + + + + +
+ + +